documentation.d.ts 3.9 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975839768397783978839798398083981839828398383984839858398683987839888398983990839918399283993839948399583996839978399883999840008400184002840038400484005840068400784008840098401084011840128401384014840158401684017840188401984020840218402284023840248402584026840278402884029840308403184032840338403484035840368403784038840398404084041840428404384044840458404684047840488404984050840518405284053840548405584056840578405884059840608406184062840638406484065840668406784068840698407084071840728407384074840758407684077840788407984080840818408284083840848408584086840878408884089840908409184092840938409484095840968409784098840998410084101841028410384104841058410684107841088410984110841118411284113841148411584116841178411884119841208412184122841238412484125841268412784128841298413084131841328413384134841358413684137841388413984140841418414284143841448414584146841478414884149841508415184152841538415484155841568415784158841598416084161841628416384164841658416684167841688416984170841718417284173841748417584176841778417884179841808418184182841838418484185841868418784188841898419084191841928419384194841958419684197841988419984200842018420284203842048420584206842078420884209842108421184212842138421484215842168421784218842198422084221842228422384224842258422684227842288422984230842318423284233842348423584236842378423884239842408424184242842438424484245842468424784248842498425084251842528425384254842558425684257842588425984260842618426284263842648426584266842678426884269842708427184272842738427484275842768427784278842798428084281842828428384284842858428684287842888428984290842918429284293842948429584296842978429884299843008430184302843038430484305843068430784308843098431084311843128431384314843158431684317843188431984320843218432284323843248432584326843278432884329843308433184332843338433484335843368433784338843398434084341843428434384344843458434684347843488434984350843518435284353843548435584356843578435884359843608436184362843638436484365843668436784368843698437084371843728437384374843758437684377843788437984380843818438284383843848438584386843878438884389843908439184392843938439484395843968439784398843998440084401844028440384404844058440684407844088440984410844118441284413844148441584416844178441884419844208442184422844238442484425844268442784428844298443084431844328443384434844358443684437844388443984440844418444284443844448444584446844478444884449844508445184452844538445484455844568445784458844598446084461844628446384464844658446684467844688446984470844718447284473844748447584476844778447884479844808448184482844838448484485844868448784488844898449084491844928449384494844958449684497844988449984500845018450284503845048450584506845078450884509845108451184512845138451484515845168451784518845198452084521845228452384524845258452684527845288452984530845318453284533845348453584536845378453884539845408454184542845438454484545845468454784548845498455084551845528455384554845558455684557845588455984560845618456284563845648456584566845678456884569845708457184572845738457484575845768457784578845798458084581845828458384584845858458684587845888458984590845918459284593845948459584596845978459884599846008460184602846038460484605846068460784608846098461084611846128461384614846158461684617846188461984620846218462284623846248462584626846278462884629846308463184632846338463484635846368463784638846398464084641846428464384644846458464684647846488464984650846518465284653846548465584656846578465884659846608466184662846638466484665846668466784668846698467084671846728467384674846758467684677846788467984680846818468284683846848468584686846878468884689846908469184692846938469484695846968469784698846998470084701847028470384704847058470684707847088470984710847118471284713847148471584716847178471884719847208472184722847238472484725847268472784728847298473084731847328473384734847358473684737847388473984740847418474284743847448474584746847478474884749847508475184752847538475484755847568475784758847598476084761847628476384764847658476684767847688476984770847718477284773847748477584776847778477884779847808478184782847838478484785847868478784788847898479084791847928479384794847958479684797847988479984800848018480284803848048480584806848078480884809848108481184812848138481484815848168481784818848198482084821848228482384824848258482684827848288482984830848318483284833848348483584836848378483884839848408484184842848438484484845848468484784848848498485084851848528485384854848558485684857848588485984860848618486284863848648486584866848678486884869848708487184872848738487484875848768487784878848798488084881848828488384884848858488684887848888488984890848918489284893848948489584896848978489884899849008490184902849038490484905849068490784908849098491084911849128491384914849158491684917849188491984920849218492284923849248492584926849278492884929849308493184932849338493484935849368493784938849398494084941849428494384944849458494684947849488494984950849518495284953849548495584956849578495884959849608496184962849638496484965849668496784968849698497084971849728497384974849758497684977849788497984980849818498284983849848498584986849878498884989849908499184992849938499484995849968499784998849998500085001850028500385004850058500685007850088500985010850118501285013850148501585016850178501885019850208502185022850238502485025850268502785028850298503085031850328503385034850358503685037850388503985040850418504285043850448504585046850478504885049850508505185052850538505485055850568505785058850598506085061850628506385064850658506685067850688506985070850718507285073850748507585076850778507885079850808508185082850838508485085850868508785088850898509085091850928509385094850958509685097850988509985100851018510285103851048510585106851078510885109851108511185112851138511485115851168511785118851198512085121851228512385124851258512685127851288512985130851318513285133851348513585136851378513885139851408514185142851438514485145851468514785148851498515085151851528515385154851558515685157851588515985160851618516285163851648516585166851678516885169851708517185172851738517485175851768517785178851798518085181851828518385184851858518685187851888518985190851918519285193851948519585196851978519885199852008520185202852038520485205852068520785208852098521085211852128521385214852158521685217852188521985220852218522285223852248522585226852278522885229852308523185232852338523485235852368523785238852398524085241852428524385244852458524685247852488524985250852518525285253852548525585256852578525885259852608526185262852638526485265852668526785268852698527085271852728527385274852758527685277852788527985280852818528285283852848528585286852878528885289852908529185292852938529485295852968529785298852998530085301853028530385304853058530685307853088530985310853118531285313853148531585316853178531885319853208532185322853238532485325853268532785328853298533085331853328533385334853358533685337853388533985340853418534285343853448534585346853478534885349853508535185352853538535485355853568535785358853598536085361853628536385364853658536685367853688536985370853718537285373853748537585376853778537885379853808538185382853838538485385853868538785388853898539085391853928539385394853958539685397853988539985400854018540285403854048540585406854078540885409854108541185412854138541485415854168541785418854198542085421854228542385424854258542685427854288542985430854318543285433854348543585436854378543885439854408544185442854438544485445854468544785448854498545085451854528545385454854558545685457854588545985460854618546285463854648546585466854678546885469854708547185472854738547485475854768547785478854798548085481854828548385484854858548685487854888548985490854918549285493854948549585496854978549885499855008550185502855038550485505855068550785508855098551085511855128551385514855158551685517855188551985520855218552285523855248552585526855278552885529855308553185532855338553485535855368553785538855398554085541855428554385544855458554685547855488554985550855518555285553855548555585556855578555885559855608556185562855638556485565855668556785568855698557085571855728557385574855758557685577855788557985580855818558285583855848558585586855878558885589855908559185592855938559485595855968559785598855998560085601856028560385604856058560685607856088560985610856118561285613856148561585616856178561885619856208562185622856238562485625856268562785628856298563085631856328563385634856358563685637856388563985640856418564285643856448564585646856478564885649856508565185652856538565485655856568565785658856598566085661856628566385664856658566685667856688566985670856718567285673856748567585676856778567885679856808568185682856838568485685856868568785688856898569085691856928569385694856958569685697856988569985700857018570285703857048570585706857078570885709857108571185712857138571485715857168571785718857198572085721857228572385724857258572685727857288572985730857318573285733857348573585736857378573885739857408574185742857438574485745857468574785748857498575085751857528575385754857558575685757857588575985760857618576285763857648576585766857678576885769857708577185772857738577485775857768577785778857798578085781857828578385784857858578685787857888578985790857918579285793857948579585796857978579885799858008580185802858038580485805858068580785808858098581085811858128581385814858158581685817858188581985820858218582285823858248582585826858278582885829858308583185832858338583485835858368583785838858398584085841858428584385844858458584685847858488584985850858518585285853858548585585856858578585885859858608586185862858638586485865858668586785868858698587085871858728587385874858758587685877858788587985880858818588285883858848588585886858878588885889858908589185892858938589485895858968589785898858998590085901859028590385904859058590685907859088590985910859118591285913859148591585916859178591885919859208592185922859238592485925859268592785928859298593085931859328593385934859358593685937859388593985940859418594285943859448594585946859478594885949859508595185952859538595485955859568595785958859598596085961859628596385964859658596685967859688596985970859718597285973859748597585976859778597885979859808598185982859838598485985859868598785988859898599085991859928599385994859958599685997859988599986000860018600286003860048600586006860078600886009860108601186012860138601486015860168601786018860198602086021860228602386024860258602686027860288602986030860318603286033860348603586036860378603886039860408604186042860438604486045860468604786048860498605086051860528605386054860558605686057860588605986060860618606286063860648606586066860678606886069860708607186072860738607486075860768607786078860798608086081860828608386084860858608686087860888608986090860918609286093860948609586096860978609886099861008610186102861038610486105861068610786108861098611086111861128611386114861158611686117861188611986120861218612286123861248612586126861278612886129861308613186132861338613486135861368613786138861398614086141861428614386144861458614686147861488614986150861518615286153861548615586156861578615886159861608616186162861638616486165861668616786168861698617086171861728617386174861758617686177861788617986180861818618286183861848618586186861878618886189861908619186192861938619486195861968619786198861998620086201862028620386204862058620686207862088620986210862118621286213862148621586216862178621886219862208622186222862238622486225862268622786228862298623086231862328623386234862358623686237862388623986240862418624286243862448624586246862478624886249862508625186252862538625486255862568625786258862598626086261862628626386264862658626686267862688626986270862718627286273862748627586276862778627886279862808628186282862838628486285862868628786288862898629086291862928629386294862958629686297862988629986300863018630286303863048630586306863078630886309863108631186312863138631486315863168631786318863198632086321863228632386324863258632686327863288632986330863318633286333863348633586336863378633886339863408634186342863438634486345863468634786348863498635086351863528635386354863558635686357863588635986360863618636286363863648636586366863678636886369863708637186372863738637486375863768637786378863798638086381863828638386384863858638686387863888638986390863918639286393863948639586396863978639886399864008640186402864038640486405864068640786408864098641086411864128641386414864158641686417864188641986420864218642286423864248642586426864278642886429864308643186432864338643486435864368643786438864398644086441864428644386444864458644686447864488644986450864518645286453864548645586456864578645886459864608646186462864638646486465864668646786468864698647086471864728647386474864758647686477864788647986480864818648286483864848648586486864878648886489864908649186492864938649486495864968649786498864998650086501865028650386504865058650686507865088650986510865118651286513865148651586516865178651886519865208652186522865238652486525865268652786528865298653086531865328653386534865358653686537865388653986540865418654286543865448654586546865478654886549865508655186552865538655486555865568655786558865598656086561865628656386564865658656686567865688656986570865718657286573865748657586576865778657886579865808658186582865838658486585865868658786588865898659086591865928659386594865958659686597865988659986600866018660286603866048660586606866078660886609866108661186612866138661486615866168661786618866198662086621866228662386624866258662686627866288662986630866318663286633866348663586636866378663886639866408664186642866438664486645866468664786648866498665086651866528665386654866558665686657866588665986660866618666286663866648666586666866678666886669866708667186672866738667486675866768667786678866798668086681866828668386684866858668686687866888668986690866918669286693866948669586696866978669886699867008670186702867038670486705867068670786708867098671086711867128671386714867158671686717867188671986720867218672286723867248672586726867278672886729867308673186732867338673486735867368673786738867398674086741867428674386744867458674686747867488674986750867518675286753867548675586756867578675886759867608676186762867638676486765867668676786768867698677086771867728677386774867758677686777867788677986780867818678286783867848678586786867878678886789867908679186792867938679486795867968679786798867998680086801868028680386804868058680686807868088680986810868118681286813868148681586816868178681886819868208682186822868238682486825868268682786828868298683086831868328683386834868358683686837868388683986840868418684286843868448684586846868478684886849868508685186852868538685486855868568685786858868598686086861868628686386864868658686686867868688686986870868718687286873868748687586876868778687886879868808688186882868838688486885868868688786888868898689086891868928689386894868958689686897868988689986900869018690286903869048690586906869078690886909869108691186912869138691486915869168691786918869198692086921869228692386924869258692686927869288692986930869318693286933869348693586936869378693886939869408694186942869438694486945869468694786948869498695086951869528695386954869558695686957869588695986960869618696286963869648696586966869678696886969869708697186972869738697486975869768697786978869798698086981869828698386984869858698686987869888698986990869918699286993869948699586996869978699886999870008700187002870038700487005870068700787008870098701087011870128701387014870158701687017870188701987020870218702287023870248702587026870278702887029870308703187032870338703487035870368703787038870398704087041870428704387044870458704687047870488704987050870518705287053870548705587056870578705887059870608706187062870638706487065870668706787068870698707087071870728707387074870758707687077870788707987080870818708287083870848708587086870878708887089870908709187092870938709487095870968709787098870998710087101871028710387104871058710687107871088710987110871118711287113871148711587116871178711887119871208712187122871238712487125871268712787128871298713087131871328713387134871358713687137871388713987140871418714287143871448714587146871478714887149871508715187152871538715487155871568715787158871598716087161871628716387164871658716687167871688716987170871718717287173871748717587176871778717887179871808718187182871838718487185871868718787188871898719087191871928719387194871958719687197871988719987200872018720287203872048720587206872078720887209872108721187212872138721487215872168721787218872198722087221872228722387224872258722687227872288722987230872318723287233872348723587236872378723887239872408724187242872438724487245872468724787248872498725087251872528725387254872558725687257872588725987260872618726287263872648726587266872678726887269872708727187272872738727487275872768727787278872798728087281872828728387284872858728687287872888728987290872918729287293872948729587296872978729887299873008730187302873038730487305873068730787308873098731087311873128731387314873158731687317873188731987320873218732287323873248732587326873278732887329873308733187332873338733487335873368733787338873398734087341873428734387344873458734687347873488734987350873518735287353873548735587356873578735887359873608736187362873638736487365873668736787368873698737087371873728737387374873758737687377873788737987380873818738287383873848738587386873878738887389873908739187392873938739487395873968739787398873998740087401874028740387404874058740687407874088740987410874118741287413874148741587416874178741887419874208742187422874238742487425874268742787428874298743087431874328743387434874358743687437874388743987440874418744287443874448744587446874478744887449874508745187452874538745487455874568745787458874598746087461874628746387464874658746687467874688746987470874718747287473874748747587476874778747887479874808748187482874838748487485874868748787488874898749087491874928749387494874958749687497874988749987500875018750287503875048750587506875078750887509875108751187512875138751487515875168751787518875198752087521875228752387524875258752687527875288752987530875318753287533875348753587536875378753887539875408754187542875438754487545875468754787548875498755087551875528755387554875558755687557875588755987560875618756287563875648756587566875678756887569875708757187572875738757487575875768757787578875798758087581875828758387584875858758687587875888758987590875918759287593875948759587596875978759887599876008760187602876038760487605876068760787608876098761087611876128761387614876158761687617876188761987620876218762287623876248762587626876278762887629876308763187632876338763487635876368763787638876398764087641876428764387644876458764687647876488764987650876518765287653876548765587656876578765887659876608766187662876638766487665876668766787668876698767087671876728767387674876758767687677876788767987680876818768287683876848768587686876878768887689876908769187692876938769487695876968769787698876998770087701877028770387704877058770687707877088770987710877118771287713877148771587716877178771887719877208772187722877238772487725877268772787728877298773087731877328773387734877358773687737877388773987740877418774287743877448774587746877478774887749877508775187752877538775487755877568775787758877598776087761877628776387764877658776687767877688776987770877718777287773877748777587776877778777887779877808778187782877838778487785877868778787788877898779087791877928779387794877958779687797877988779987800878018780287803878048780587806878078780887809878108781187812878138781487815878168781787818878198782087821878228782387824878258782687827878288782987830878318783287833878348783587836878378783887839878408784187842878438784487845878468784787848878498785087851878528785387854878558785687857878588785987860878618786287863878648786587866878678786887869878708787187872878738787487875878768787787878878798788087881878828788387884878858788687887878888788987890878918789287893878948789587896878978789887899879008790187902879038790487905879068790787908879098791087911879128791387914879158791687917879188791987920879218792287923879248792587926879278792887929879308793187932879338793487935879368793787938879398794087941879428794387944879458794687947879488794987950879518795287953879548795587956879578795887959879608796187962879638796487965879668796787968879698797087971879728797387974879758797687977879788797987980879818798287983879848798587986879878798887989879908799187992879938799487995879968799787998879998800088001880028800388004880058800688007880088800988010880118801288013880148801588016880178801888019880208802188022880238802488025880268802788028880298803088031880328803388034880358803688037880388803988040880418804288043880448804588046880478804888049880508805188052880538805488055880568805788058880598806088061880628806388064880658806688067880688806988070880718807288073880748807588076880778807888079880808808188082880838808488085880868808788088880898809088091880928809388094880958809688097880988809988100881018810288103881048810588106881078810888109881108811188112881138811488115881168811788118881198812088121881228812388124881258812688127881288812988130881318813288133881348813588136881378813888139881408814188142881438814488145881468814788148881498815088151881528815388154881558815688157881588815988160881618816288163881648816588166881678816888169881708817188172881738817488175881768817788178881798818088181881828818388184881858818688187881888818988190881918819288193881948819588196881978819888199882008820188202882038820488205882068820788208882098821088211882128821388214882158821688217882188821988220882218822288223882248822588226882278822888229882308823188232882338823488235882368823788238882398824088241882428824388244882458824688247882488824988250882518825288253882548825588256882578825888259882608826188262882638826488265882668826788268882698827088271882728827388274882758827688277882788827988280882818828288283882848828588286882878828888289882908829188292882938829488295882968829788298882998830088301883028830388304883058830688307883088830988310883118831288313883148831588316883178831888319883208832188322883238832488325883268832788328883298833088331883328833388334883358833688337883388833988340883418834288343883448834588346883478834888349883508835188352883538835488355883568835788358883598836088361883628836388364883658836688367883688836988370883718837288373883748837588376883778837888379883808838188382883838838488385883868838788388883898839088391883928839388394883958839688397883988839988400884018840288403884048840588406884078840888409884108841188412884138841488415884168841788418884198842088421884228842388424884258842688427884288842988430884318843288433884348843588436884378843888439884408844188442884438844488445884468844788448884498845088451884528845388454884558845688457884588845988460884618846288463884648846588466884678846888469884708847188472884738847488475884768847788478884798848088481884828848388484884858848688487884888848988490884918849288493884948849588496884978849888499885008850188502885038850488505885068850788508885098851088511885128851388514885158851688517885188851988520885218852288523885248852588526885278852888529885308853188532885338853488535885368853788538885398854088541885428854388544885458854688547885488854988550885518855288553885548855588556885578855888559885608856188562885638856488565885668856788568885698857088571885728857388574885758857688577885788857988580885818858288583885848858588586885878858888589885908859188592885938859488595885968859788598885998860088601886028860388604886058860688607886088860988610886118861288613886148861588616886178861888619886208862188622886238862488625886268862788628886298863088631886328863388634886358863688637886388863988640886418864288643886448864588646886478864888649886508865188652886538865488655886568865788658886598866088661886628866388664886658866688667886688866988670886718867288673886748867588676886778867888679886808868188682886838868488685886868868788688886898869088691886928869388694886958869688697886988869988700887018870288703887048870588706887078870888709887108871188712887138871488715887168871788718887198872088721887228872388724887258872688727887288872988730887318873288733887348873588736887378873888739887408874188742887438874488745887468874788748887498875088751887528875388754887558875688757887588875988760887618876288763887648876588766887678876888769887708877188772887738877488775887768877788778887798878088781887828878388784887858878688787887888878988790887918879288793887948879588796887978879888799888008880188802888038880488805888068880788808888098881088811888128881388814888158881688817888188881988820888218882288823888248882588826888278882888829888308883188832888338883488835888368883788838888398884088841888428884388844888458884688847888488884988850888518885288853888548885588856888578885888859888608886188862888638886488865888668886788868888698887088871888728887388874888758887688877888788887988880888818888288883888848888588886888878888888889888908889188892888938889488895888968889788898888998890088901889028890388904889058890688907889088890988910889118891288913889148891588916889178891888919889208892188922889238892488925889268892788928889298893088931889328893388934889358893688937889388893988940889418894288943889448894588946889478894888949889508895188952889538895488955889568895788958889598896088961889628896388964889658896688967889688896988970889718897288973889748897588976889778897888979889808898188982889838898488985889868898788988889898899088991889928899388994889958899688997889988899989000890018900289003890048900589006890078900889009890108901189012890138901489015890168901789018890198902089021890228902389024890258902689027890288902989030890318903289033890348903589036890378903889039890408904189042890438904489045890468904789048890498905089051890528905389054890558905689057890588905989060890618906289063890648906589066890678906889069890708907189072890738907489075890768907789078890798908089081890828908389084890858908689087890888908989090890918909289093890948909589096890978909889099891008910189102891038910489105891068910789108891098911089111891128911389114891158911689117891188911989120891218912289123891248912589126891278912889129891308913189132891338913489135891368913789138891398914089141891428914389144891458914689147891488914989150891518915289153891548915589156891578915889159891608916189162891638916489165891668916789168891698917089171891728917389174891758917689177891788917989180891818918289183891848918589186891878918889189891908919189192891938919489195891968919789198891998920089201892028920389204892058920689207892088920989210892118921289213892148921589216892178921889219892208922189222892238922489225892268922789228892298923089231892328923389234892358923689237892388923989240892418924289243892448924589246892478924889249892508925189252892538925489255892568925789258892598926089261892628926389264892658926689267892688926989270892718927289273892748927589276892778927889279892808928189282892838928489285892868928789288892898929089291892928929389294892958929689297892988929989300893018930289303893048930589306893078930889309893108931189312893138931489315893168931789318893198932089321893228932389324893258932689327893288932989330893318933289333893348933589336893378933889339893408934189342893438934489345893468934789348893498935089351893528935389354893558935689357893588935989360893618936289363893648936589366893678936889369893708937189372893738937489375893768937789378893798938089381893828938389384893858938689387893888938989390893918939289393893948939589396893978939889399894008940189402894038940489405894068940789408894098941089411894128941389414894158941689417894188941989420894218942289423894248942589426894278942889429894308943189432894338943489435894368943789438894398944089441894428944389444894458944689447894488944989450894518945289453894548945589456894578945889459894608946189462894638946489465894668946789468894698947089471894728947389474894758947689477894788947989480894818948289483894848948589486894878948889489894908949189492894938949489495894968949789498894998950089501895028950389504895058950689507895088950989510895118951289513895148951589516895178951889519895208952189522895238952489525895268952789528895298953089531895328953389534895358953689537895388953989540895418954289543895448954589546895478954889549895508955189552895538955489555895568955789558895598956089561895628956389564895658956689567895688956989570895718957289573895748957589576895778957889579895808958189582895838958489585895868958789588895898959089591895928959389594895958959689597895988959989600896018960289603896048960589606896078960889609896108961189612896138961489615896168961789618896198962089621896228962389624896258962689627896288962989630896318963289633896348963589636896378963889639896408964189642896438964489645896468964789648896498965089651896528965389654896558965689657896588965989660896618966289663896648966589666896678966889669896708967189672896738967489675896768967789678896798968089681896828968389684896858968689687896888968989690896918969289693896948969589696896978969889699897008970189702897038970489705897068970789708897098971089711897128971389714897158971689717897188971989720897218972289723897248972589726897278972889729897308973189732897338973489735897368973789738897398974089741897428974389744897458974689747897488974989750897518975289753897548975589756897578975889759897608976189762897638976489765897668976789768897698977089771897728977389774897758977689777897788977989780897818978289783897848978589786897878978889789897908979189792897938979489795897968979789798897998980089801898028980389804898058980689807898088980989810898118981289813898148981589816898178981889819898208982189822898238982489825898268982789828898298983089831898328983389834898358983689837898388983989840898418984289843898448984589846898478984889849898508985189852898538985489855898568985789858898598986089861898628986389864898658986689867898688986989870898718987289873898748987589876898778987889879898808988189882898838988489885898868988789888898898989089891898928989389894898958989689897898988989989900899018990289903899048990589906899078990889909899108991189912899138991489915899168991789918899198992089921899228992389924899258992689927899288992989930899318993289933899348993589936899378993889939899408994189942899438994489945899468994789948899498995089951899528995389954899558995689957899588995989960899618996289963899648996589966899678996889969899708997189972899738997489975899768997789978899798998089981899828998389984899858998689987899888998989990899918999289993899948999589996899978999889999900009000190002900039000490005900069000790008900099001090011900129001390014900159001690017900189001990020900219002290023900249002590026900279002890029900309003190032900339003490035900369003790038900399004090041900429004390044900459004690047900489004990050900519005290053900549005590056900579005890059900609006190062900639006490065900669006790068900699007090071900729007390074900759007690077900789007990080900819008290083900849008590086900879008890089900909009190092900939009490095900969009790098900999010090101901029010390104901059010690107901089010990110901119011290113901149011590116901179011890119901209012190122901239012490125901269012790128901299013090131901329013390134901359013690137901389013990140901419014290143901449014590146901479014890149901509015190152901539015490155901569015790158901599016090161901629016390164901659016690167901689016990170901719017290173901749017590176901779017890179901809018190182901839018490185901869018790188901899019090191901929019390194901959019690197901989019990200902019020290203902049020590206902079020890209902109021190212902139021490215902169021790218902199022090221902229022390224902259022690227902289022990230902319023290233902349023590236902379023890239902409024190242902439024490245902469024790248902499025090251902529025390254902559025690257902589025990260902619026290263902649026590266902679026890269902709027190272902739027490275902769027790278902799028090281902829028390284902859028690287902889028990290902919029290293902949029590296902979029890299903009030190302903039030490305903069030790308903099031090311903129031390314903159031690317903189031990320903219032290323903249032590326903279032890329903309033190332903339033490335903369033790338903399034090341903429034390344903459034690347903489034990350903519035290353903549035590356903579035890359903609036190362903639036490365903669036790368903699037090371903729037390374903759037690377903789037990380903819038290383903849038590386903879038890389903909039190392903939039490395903969039790398903999040090401904029040390404904059040690407904089040990410904119041290413904149041590416904179041890419904209042190422904239042490425904269042790428904299043090431904329043390434904359043690437904389043990440904419044290443904449044590446904479044890449904509045190452904539045490455904569045790458904599046090461904629046390464904659046690467904689046990470904719047290473904749047590476904779047890479904809048190482904839048490485904869048790488904899049090491904929049390494904959049690497904989049990500905019050290503905049050590506905079050890509905109051190512905139051490515905169051790518905199052090521905229052390524905259052690527905289052990530905319053290533905349053590536905379053890539905409054190542905439054490545905469054790548905499055090551905529055390554905559055690557905589055990560905619056290563905649056590566905679056890569905709057190572905739057490575905769057790578905799058090581905829058390584905859058690587905889058990590905919059290593905949059590596905979059890599906009060190602906039060490605906069060790608906099061090611906129061390614906159061690617906189061990620906219062290623906249062590626906279062890629906309063190632906339063490635906369063790638906399064090641906429064390644906459064690647906489064990650906519065290653906549065590656906579065890659906609066190662906639066490665906669066790668906699067090671906729067390674906759067690677906789067990680906819068290683906849068590686906879068890689906909069190692906939069490695906969069790698906999070090701907029070390704907059070690707907089070990710907119071290713907149071590716907179071890719907209072190722907239072490725907269072790728907299073090731907329073390734907359073690737907389073990740907419074290743907449074590746907479074890749907509075190752907539075490755907569075790758907599076090761907629076390764907659076690767907689076990770907719077290773907749077590776907779077890779907809078190782907839078490785907869078790788907899079090791907929079390794907959079690797907989079990800908019080290803908049080590806908079080890809908109081190812908139081490815908169081790818908199082090821908229082390824908259082690827908289082990830908319083290833908349083590836908379083890839908409084190842908439084490845908469084790848908499085090851908529085390854908559085690857908589085990860908619086290863908649086590866908679086890869908709087190872908739087490875908769087790878908799088090881908829088390884908859088690887908889088990890908919089290893908949089590896908979089890899909009090190902909039090490905909069090790908909099091090911909129091390914909159091690917909189091990920909219092290923909249092590926909279092890929909309093190932909339093490935909369093790938909399094090941909429094390944909459094690947909489094990950909519095290953909549095590956909579095890959909609096190962909639096490965909669096790968909699097090971909729097390974909759097690977909789097990980909819098290983909849098590986909879098890989909909099190992909939099490995909969099790998909999100091001910029100391004910059100691007910089100991010910119101291013910149101591016910179101891019910209102191022910239102491025910269102791028910299103091031910329103391034910359103691037910389103991040910419104291043910449104591046910479104891049910509105191052910539105491055910569105791058910599106091061910629106391064910659106691067910689106991070910719107291073910749107591076910779107891079910809108191082910839108491085910869108791088910899109091091910929109391094910959109691097910989109991100911019110291103911049110591106911079110891109911109111191112911139111491115911169111791118911199112091121911229112391124911259112691127911289112991130911319113291133911349113591136911379113891139911409114191142911439114491145911469114791148911499115091151911529115391154911559115691157911589115991160911619116291163911649116591166911679116891169911709117191172911739117491175911769117791178911799118091181911829118391184911859118691187911889118991190911919119291193911949119591196911979119891199912009120191202912039120491205912069120791208912099121091211912129121391214912159121691217912189121991220912219122291223912249122591226912279122891229912309123191232912339123491235912369123791238912399124091241912429124391244912459124691247912489124991250912519125291253912549125591256912579125891259912609126191262912639126491265912669126791268912699127091271912729127391274912759127691277912789127991280912819128291283912849128591286912879128891289912909129191292912939129491295912969129791298912999130091301913029130391304913059130691307913089130991310913119131291313913149131591316913179131891319913209132191322913239132491325913269132791328913299133091331913329133391334913359133691337913389133991340913419134291343913449134591346913479134891349913509135191352913539135491355913569135791358913599136091361913629136391364913659136691367913689136991370913719137291373913749137591376913779137891379913809138191382913839138491385913869138791388913899139091391913929139391394913959139691397913989139991400914019140291403914049140591406914079140891409914109141191412914139141491415914169141791418914199142091421914229142391424914259142691427914289142991430914319143291433914349143591436914379143891439914409144191442914439144491445914469144791448914499145091451914529145391454914559145691457914589145991460914619146291463914649146591466914679146891469914709147191472914739147491475914769147791478914799148091481914829148391484914859148691487914889148991490914919149291493914949149591496914979149891499915009150191502915039150491505915069150791508915099151091511915129151391514915159151691517915189151991520915219152291523915249152591526915279152891529915309153191532915339153491535915369153791538915399154091541915429154391544915459154691547915489154991550915519155291553915549155591556915579155891559915609156191562915639156491565915669156791568915699157091571915729157391574915759157691577915789157991580915819158291583915849158591586915879158891589915909159191592915939159491595915969159791598915999160091601916029160391604916059160691607916089160991610916119161291613916149161591616916179161891619916209162191622916239162491625916269162791628916299163091631916329163391634916359163691637916389163991640916419164291643916449164591646916479164891649916509165191652916539165491655916569165791658916599166091661916629166391664916659166691667916689166991670916719167291673916749167591676916779167891679916809168191682916839168491685916869168791688916899169091691916929169391694916959169691697916989169991700917019170291703917049170591706917079170891709917109171191712917139171491715917169171791718917199172091721917229172391724917259172691727917289172991730917319173291733917349173591736917379173891739917409174191742917439174491745917469174791748917499175091751917529175391754917559175691757917589175991760917619176291763917649176591766917679176891769917709177191772917739177491775917769177791778917799178091781917829178391784917859178691787917889178991790917919179291793917949179591796917979179891799918009180191802918039180491805918069180791808918099181091811918129181391814918159181691817918189181991820918219182291823918249182591826918279182891829918309183191832918339183491835918369183791838918399184091841918429184391844918459184691847918489184991850918519185291853918549185591856918579185891859918609186191862918639186491865918669186791868918699187091871918729187391874918759187691877918789187991880918819188291883918849188591886918879188891889918909189191892918939189491895918969189791898918999190091901919029190391904919059190691907919089190991910919119191291913919149191591916919179191891919919209192191922919239192491925919269192791928919299193091931919329193391934919359193691937919389193991940919419194291943919449194591946919479194891949919509195191952919539195491955919569195791958919599196091961919629196391964919659196691967919689196991970919719197291973919749197591976919779197891979919809198191982919839198491985919869198791988919899199091991919929199391994919959199691997919989199992000920019200292003920049200592006920079200892009920109201192012920139201492015920169201792018920199202092021920229202392024920259202692027920289202992030920319203292033920349203592036920379203892039920409204192042920439204492045920469204792048920499205092051920529205392054920559205692057920589205992060920619206292063920649206592066920679206892069920709207192072920739207492075920769207792078920799208092081920829208392084920859208692087920889208992090920919209292093920949209592096920979209892099921009210192102921039210492105921069210792108921099211092111921129211392114921159211692117921189211992120921219212292123921249212592126921279212892129921309213192132921339213492135921369213792138921399214092141921429214392144921459214692147921489214992150921519215292153921549215592156921579215892159921609216192162921639216492165921669216792168921699217092171921729217392174921759217692177921789217992180921819218292183921849218592186921879218892189921909219192192921939219492195921969219792198921999220092201922029220392204922059220692207922089220992210922119221292213922149221592216922179221892219922209222192222922239222492225922269222792228922299223092231922329223392234922359223692237922389223992240922419224292243922449224592246922479224892249922509225192252922539225492255922569225792258922599226092261922629226392264922659226692267922689226992270922719227292273922749227592276922779227892279922809228192282922839228492285922869228792288922899229092291922929229392294922959229692297922989229992300923019230292303923049230592306923079230892309923109231192312923139231492315923169231792318923199232092321923229232392324923259232692327923289232992330923319233292333923349233592336923379233892339923409234192342923439234492345923469234792348923499235092351923529235392354923559235692357923589235992360923619236292363923649236592366923679236892369923709237192372923739237492375923769237792378923799238092381923829238392384923859238692387923889238992390923919239292393923949239592396923979239892399924009240192402924039240492405924069240792408924099241092411924129241392414924159241692417924189241992420924219242292423924249242592426924279242892429924309243192432924339243492435924369243792438924399244092441924429244392444924459244692447924489244992450924519245292453924549245592456924579245892459924609246192462924639246492465924669246792468924699247092471924729247392474924759247692477924789247992480924819248292483924849248592486924879248892489924909249192492924939249492495924969249792498924999250092501925029250392504925059250692507925089250992510925119251292513925149251592516925179251892519925209252192522925239252492525925269252792528925299253092531925329253392534925359253692537925389253992540925419254292543925449254592546925479254892549925509255192552925539255492555925569255792558925599256092561925629256392564925659256692567925689256992570925719257292573925749257592576925779257892579925809258192582925839258492585925869258792588925899259092591925929259392594925959259692597925989259992600926019260292603926049260592606926079260892609926109261192612926139261492615926169261792618926199262092621926229262392624926259262692627926289262992630926319263292633926349263592636926379263892639926409264192642926439264492645926469264792648926499265092651926529265392654926559265692657926589265992660926619266292663926649266592666926679266892669926709267192672926739267492675926769267792678926799268092681926829268392684926859268692687926889268992690926919269292693926949269592696926979269892699927009270192702927039270492705927069270792708927099271092711927129271392714927159271692717927189271992720927219272292723927249272592726927279272892729927309273192732927339273492735927369273792738927399274092741927429274392744927459274692747927489274992750927519275292753927549275592756927579275892759927609276192762927639276492765927669276792768927699277092771927729277392774927759277692777927789277992780927819278292783927849278592786927879278892789927909279192792927939279492795927969279792798927999280092801928029280392804928059280692807928089280992810928119281292813928149281592816928179281892819928209282192822928239282492825928269282792828928299283092831928329283392834928359283692837928389283992840928419284292843928449284592846928479284892849928509285192852928539285492855928569285792858928599286092861928629286392864928659286692867928689286992870928719287292873928749287592876928779287892879928809288192882928839288492885928869288792888928899289092891928929289392894928959289692897928989289992900929019290292903929049290592906929079290892909929109291192912929139291492915929169291792918929199292092921929229292392924929259292692927929289292992930929319293292933929349293592936929379293892939929409294192942929439294492945929469294792948929499295092951929529295392954929559295692957929589295992960929619296292963929649296592966929679296892969929709297192972929739297492975929769297792978929799298092981929829298392984929859298692987929889298992990929919299292993929949299592996929979299892999930009300193002930039300493005930069300793008930099301093011930129301393014930159301693017930189301993020930219302293023930249302593026930279302893029930309303193032930339303493035930369303793038930399304093041930429304393044930459304693047930489304993050930519305293053930549305593056930579305893059930609306193062930639306493065930669306793068930699307093071930729307393074930759307693077930789307993080930819308293083930849308593086930879308893089930909309193092930939309493095930969309793098930999310093101931029310393104931059310693107931089310993110931119311293113931149311593116931179311893119931209312193122931239312493125931269312793128931299313093131931329313393134931359313693137931389313993140931419314293143931449314593146931479314893149931509315193152931539315493155931569315793158931599316093161931629316393164931659316693167931689316993170931719317293173931749317593176931779317893179931809318193182931839318493185931869318793188931899319093191931929319393194931959319693197931989319993200932019320293203932049320593206932079320893209932109321193212932139321493215932169321793218932199322093221932229322393224932259322693227932289322993230932319323293233932349323593236932379323893239932409324193242932439324493245932469324793248932499325093251932529325393254932559325693257932589325993260932619326293263932649326593266932679326893269932709327193272932739327493275932769327793278932799328093281932829328393284932859328693287932889328993290932919329293293932949329593296932979329893299933009330193302933039330493305933069330793308933099331093311933129331393314933159331693317933189331993320933219332293323933249332593326933279332893329933309333193332933339333493335933369333793338933399334093341933429334393344933459334693347933489334993350933519335293353933549335593356933579335893359933609336193362933639336493365933669336793368933699337093371933729337393374933759337693377933789337993380933819338293383933849338593386933879338893389933909339193392933939339493395933969339793398933999340093401934029340393404934059340693407934089340993410934119341293413934149341593416934179341893419934209342193422934239342493425934269342793428934299343093431934329343393434934359343693437934389343993440934419344293443934449344593446934479344893449934509345193452934539345493455934569345793458934599346093461934629346393464934659346693467934689346993470934719347293473934749347593476934779347893479934809348193482934839348493485934869348793488934899349093491934929349393494934959349693497934989349993500935019350293503935049350593506935079350893509935109351193512935139351493515935169351793518935199352093521935229352393524935259352693527935289352993530935319353293533935349353593536935379353893539935409354193542935439354493545935469354793548935499355093551935529355393554935559355693557935589355993560935619356293563935649356593566935679356893569935709357193572935739357493575935769357793578935799358093581935829358393584935859358693587935889358993590935919359293593935949359593596935979359893599936009360193602936039360493605936069360793608936099361093611936129361393614936159361693617936189361993620936219362293623936249362593626936279362893629936309363193632936339363493635936369363793638936399364093641936429364393644936459364693647936489364993650936519365293653936549365593656936579365893659936609366193662936639366493665936669366793668936699367093671936729367393674936759367693677936789367993680936819368293683936849368593686936879368893689936909369193692936939369493695936969369793698936999370093701937029370393704937059370693707937089370993710937119371293713937149371593716937179371893719937209372193722937239372493725937269372793728937299373093731937329373393734937359373693737937389373993740937419374293743937449374593746937479374893749937509375193752937539375493755937569375793758937599376093761937629376393764937659376693767937689376993770937719377293773937749377593776937779377893779937809378193782937839378493785937869378793788937899379093791937929379393794937959379693797937989379993800938019380293803938049380593806938079380893809938109381193812938139381493815938169381793818938199382093821938229382393824938259382693827938289382993830938319383293833938349383593836938379383893839938409384193842938439384493845938469384793848938499385093851938529385393854938559385693857938589385993860938619386293863938649386593866938679386893869938709387193872938739387493875938769387793878938799388093881938829388393884938859388693887938889388993890938919389293893938949389593896938979389893899939009390193902939039390493905939069390793908939099391093911939129391393914939159391693917939189391993920939219392293923939249392593926939279392893929939309393193932939339393493935939369393793938939399394093941939429394393944939459394693947939489394993950939519395293953939549395593956939579395893959939609396193962
  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. MORPHTARGETS_TEXTURE: boolean;
  17892. /** IMAGE PROCESSING */
  17893. IMAGEPROCESSING: boolean;
  17894. VIGNETTE: boolean;
  17895. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17896. VIGNETTEBLENDMODEOPAQUE: boolean;
  17897. TONEMAPPING: boolean;
  17898. TONEMAPPING_ACES: boolean;
  17899. CONTRAST: boolean;
  17900. EXPOSURE: boolean;
  17901. COLORCURVES: boolean;
  17902. COLORGRADING: boolean;
  17903. COLORGRADING3D: boolean;
  17904. SAMPLER3DGREENDEPTH: boolean;
  17905. SAMPLER3DBGRMAP: boolean;
  17906. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17907. /** MISC. */
  17908. BUMPDIRECTUV: number;
  17909. constructor();
  17910. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  17911. }
  17912. /**
  17913. * Class used to configure NodeMaterial
  17914. */
  17915. export interface INodeMaterialOptions {
  17916. /**
  17917. * Defines if blocks should emit comments
  17918. */
  17919. emitComments: boolean;
  17920. }
  17921. /**
  17922. * Class used to create a node based material built by assembling shader blocks
  17923. */
  17924. export class NodeMaterial extends PushMaterial {
  17925. private static _BuildIdGenerator;
  17926. private _options;
  17927. private _vertexCompilationState;
  17928. private _fragmentCompilationState;
  17929. private _sharedData;
  17930. private _buildId;
  17931. private _buildWasSuccessful;
  17932. private _cachedWorldViewMatrix;
  17933. private _cachedWorldViewProjectionMatrix;
  17934. private _optimizers;
  17935. private _animationFrame;
  17936. /** Define the Url to load node editor script */
  17937. static EditorURL: string;
  17938. /** Define the Url to load snippets */
  17939. static SnippetUrl: string;
  17940. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  17941. static IgnoreTexturesAtLoadTime: boolean;
  17942. private BJSNODEMATERIALEDITOR;
  17943. /** Get the inspector from bundle or global */
  17944. private _getGlobalNodeMaterialEditor;
  17945. /**
  17946. * Snippet ID if the material was created from the snippet server
  17947. */
  17948. snippetId: string;
  17949. /**
  17950. * Gets or sets data used by visual editor
  17951. * @see https://nme.babylonjs.com
  17952. */
  17953. editorData: any;
  17954. /**
  17955. * 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)
  17956. */
  17957. ignoreAlpha: boolean;
  17958. /**
  17959. * Defines the maximum number of lights that can be used in the material
  17960. */
  17961. maxSimultaneousLights: number;
  17962. /**
  17963. * Observable raised when the material is built
  17964. */
  17965. onBuildObservable: Observable<NodeMaterial>;
  17966. /**
  17967. * Gets or sets the root nodes of the material vertex shader
  17968. */
  17969. _vertexOutputNodes: NodeMaterialBlock[];
  17970. /**
  17971. * Gets or sets the root nodes of the material fragment (pixel) shader
  17972. */
  17973. _fragmentOutputNodes: NodeMaterialBlock[];
  17974. /** Gets or sets options to control the node material overall behavior */
  17975. get options(): INodeMaterialOptions;
  17976. set options(options: INodeMaterialOptions);
  17977. /**
  17978. * Default configuration related to image processing available in the standard Material.
  17979. */
  17980. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17981. /**
  17982. * Gets the image processing configuration used either in this material.
  17983. */
  17984. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17985. /**
  17986. * Sets the Default image processing configuration used either in the this material.
  17987. *
  17988. * If sets to null, the scene one is in use.
  17989. */
  17990. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17991. /**
  17992. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  17993. */
  17994. attachedBlocks: NodeMaterialBlock[];
  17995. /**
  17996. * Specifies the mode of the node material
  17997. * @hidden
  17998. */
  17999. _mode: NodeMaterialModes;
  18000. /**
  18001. * Gets the mode property
  18002. */
  18003. get mode(): NodeMaterialModes;
  18004. /**
  18005. * A free comment about the material
  18006. */
  18007. comment: string;
  18008. /**
  18009. * Create a new node based material
  18010. * @param name defines the material name
  18011. * @param scene defines the hosting scene
  18012. * @param options defines creation option
  18013. */
  18014. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  18015. /**
  18016. * Gets the current class name of the material e.g. "NodeMaterial"
  18017. * @returns the class name
  18018. */
  18019. getClassName(): string;
  18020. /**
  18021. * Keep track of the image processing observer to allow dispose and replace.
  18022. */
  18023. private _imageProcessingObserver;
  18024. /**
  18025. * Attaches a new image processing configuration to the Standard Material.
  18026. * @param configuration
  18027. */
  18028. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  18029. /**
  18030. * Get a block by its name
  18031. * @param name defines the name of the block to retrieve
  18032. * @returns the required block or null if not found
  18033. */
  18034. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  18035. /**
  18036. * Get a block by its name
  18037. * @param predicate defines the predicate used to find the good candidate
  18038. * @returns the required block or null if not found
  18039. */
  18040. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  18041. /**
  18042. * Get an input block by its name
  18043. * @param predicate defines the predicate used to find the good candidate
  18044. * @returns the required input block or null if not found
  18045. */
  18046. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  18047. /**
  18048. * Gets the list of input blocks attached to this material
  18049. * @returns an array of InputBlocks
  18050. */
  18051. getInputBlocks(): InputBlock[];
  18052. /**
  18053. * Adds a new optimizer to the list of optimizers
  18054. * @param optimizer defines the optimizers to add
  18055. * @returns the current material
  18056. */
  18057. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  18058. /**
  18059. * Remove an optimizer from the list of optimizers
  18060. * @param optimizer defines the optimizers to remove
  18061. * @returns the current material
  18062. */
  18063. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  18064. /**
  18065. * Add a new block to the list of output nodes
  18066. * @param node defines the node to add
  18067. * @returns the current material
  18068. */
  18069. addOutputNode(node: NodeMaterialBlock): this;
  18070. /**
  18071. * Remove a block from the list of root nodes
  18072. * @param node defines the node to remove
  18073. * @returns the current material
  18074. */
  18075. removeOutputNode(node: NodeMaterialBlock): this;
  18076. private _addVertexOutputNode;
  18077. private _removeVertexOutputNode;
  18078. private _addFragmentOutputNode;
  18079. private _removeFragmentOutputNode;
  18080. /**
  18081. * Specifies if the material will require alpha blending
  18082. * @returns a boolean specifying if alpha blending is needed
  18083. */
  18084. needAlphaBlending(): boolean;
  18085. /**
  18086. * Specifies if this material should be rendered in alpha test mode
  18087. * @returns a boolean specifying if an alpha test is needed.
  18088. */
  18089. needAlphaTesting(): boolean;
  18090. private _initializeBlock;
  18091. private _resetDualBlocks;
  18092. /**
  18093. * Remove a block from the current node material
  18094. * @param block defines the block to remove
  18095. */
  18096. removeBlock(block: NodeMaterialBlock): void;
  18097. /**
  18098. * Build the material and generates the inner effect
  18099. * @param verbose defines if the build should log activity
  18100. */
  18101. build(verbose?: boolean): void;
  18102. /**
  18103. * Runs an otpimization phase to try to improve the shader code
  18104. */
  18105. optimize(): void;
  18106. private _prepareDefinesForAttributes;
  18107. /**
  18108. * Create a post process from the material
  18109. * @param camera The camera to apply the render pass to.
  18110. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18111. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18112. * @param engine The engine which the post process will be applied. (default: current engine)
  18113. * @param reusable If the post process can be reused on the same frame. (default: false)
  18114. * @param textureType Type of textures used when performing the post process. (default: 0)
  18115. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  18116. * @returns the post process created
  18117. */
  18118. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  18119. /**
  18120. * Create the post process effect from the material
  18121. * @param postProcess The post process to create the effect for
  18122. */
  18123. createEffectForPostProcess(postProcess: PostProcess): void;
  18124. private _createEffectForPostProcess;
  18125. /**
  18126. * Create a new procedural texture based on this node material
  18127. * @param size defines the size of the texture
  18128. * @param scene defines the hosting scene
  18129. * @returns the new procedural texture attached to this node material
  18130. */
  18131. createProceduralTexture(size: number | {
  18132. width: number;
  18133. height: number;
  18134. layers?: number;
  18135. }, scene: Scene): Nullable<ProceduralTexture>;
  18136. private _createEffectForParticles;
  18137. private _checkInternals;
  18138. /**
  18139. * Create the effect to be used as the custom effect for a particle system
  18140. * @param particleSystem Particle system to create the effect for
  18141. * @param onCompiled defines a function to call when the effect creation is successful
  18142. * @param onError defines a function to call when the effect creation has failed
  18143. */
  18144. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18145. private _processDefines;
  18146. /**
  18147. * Get if the submesh is ready to be used and all its information available.
  18148. * Child classes can use it to update shaders
  18149. * @param mesh defines the mesh to check
  18150. * @param subMesh defines which submesh to check
  18151. * @param useInstances specifies that instances should be used
  18152. * @returns a boolean indicating that the submesh is ready or not
  18153. */
  18154. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  18155. /**
  18156. * Get a string representing the shaders built by the current node graph
  18157. */
  18158. get compiledShaders(): string;
  18159. /**
  18160. * Binds the world matrix to the material
  18161. * @param world defines the world transformation matrix
  18162. */
  18163. bindOnlyWorldMatrix(world: Matrix): void;
  18164. /**
  18165. * Binds the submesh to this material by preparing the effect and shader to draw
  18166. * @param world defines the world transformation matrix
  18167. * @param mesh defines the mesh containing the submesh
  18168. * @param subMesh defines the submesh to bind the material to
  18169. */
  18170. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18171. /**
  18172. * Gets the active textures from the material
  18173. * @returns an array of textures
  18174. */
  18175. getActiveTextures(): BaseTexture[];
  18176. /**
  18177. * Gets the list of texture blocks
  18178. * @returns an array of texture blocks
  18179. */
  18180. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  18181. /**
  18182. * Specifies if the material uses a texture
  18183. * @param texture defines the texture to check against the material
  18184. * @returns a boolean specifying if the material uses the texture
  18185. */
  18186. hasTexture(texture: BaseTexture): boolean;
  18187. /**
  18188. * Disposes the material
  18189. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18190. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18191. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18192. */
  18193. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18194. /** Creates the node editor window. */
  18195. private _createNodeEditor;
  18196. /**
  18197. * Launch the node material editor
  18198. * @param config Define the configuration of the editor
  18199. * @return a promise fulfilled when the node editor is visible
  18200. */
  18201. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  18202. /**
  18203. * Clear the current material
  18204. */
  18205. clear(): void;
  18206. /**
  18207. * Clear the current material and set it to a default state
  18208. */
  18209. setToDefault(): void;
  18210. /**
  18211. * Clear the current material and set it to a default state for post process
  18212. */
  18213. setToDefaultPostProcess(): void;
  18214. /**
  18215. * Clear the current material and set it to a default state for procedural texture
  18216. */
  18217. setToDefaultProceduralTexture(): void;
  18218. /**
  18219. * Clear the current material and set it to a default state for particle
  18220. */
  18221. setToDefaultParticle(): void;
  18222. /**
  18223. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  18224. * @param url defines the url to load from
  18225. * @returns a promise that will fulfil when the material is fully loaded
  18226. */
  18227. loadAsync(url: string): Promise<void>;
  18228. private _gatherBlocks;
  18229. /**
  18230. * Generate a string containing the code declaration required to create an equivalent of this material
  18231. * @returns a string
  18232. */
  18233. generateCode(): string;
  18234. /**
  18235. * Serializes this material in a JSON representation
  18236. * @returns the serialized material object
  18237. */
  18238. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  18239. private _restoreConnections;
  18240. /**
  18241. * Clear the current graph and load a new one from a serialization object
  18242. * @param source defines the JSON representation of the material
  18243. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18244. * @param merge defines whether or not the source must be merged or replace the current content
  18245. */
  18246. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  18247. /**
  18248. * Makes a duplicate of the current material.
  18249. * @param name - name to use for the new material.
  18250. */
  18251. clone(name: string): NodeMaterial;
  18252. /**
  18253. * Creates a node material from parsed material data
  18254. * @param source defines the JSON representation of the material
  18255. * @param scene defines the hosting scene
  18256. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18257. * @returns a new node material
  18258. */
  18259. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  18260. /**
  18261. * Creates a node material from a snippet saved in a remote file
  18262. * @param name defines the name of the material to create
  18263. * @param url defines the url to load from
  18264. * @param scene defines the hosting scene
  18265. * @returns a promise that will resolve to the new node material
  18266. */
  18267. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  18268. /**
  18269. * Creates a node material from a snippet saved by the node material editor
  18270. * @param snippetId defines the snippet to load
  18271. * @param scene defines the hosting scene
  18272. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18273. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  18274. * @returns a promise that will resolve to the new node material
  18275. */
  18276. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  18277. /**
  18278. * Creates a new node material set to default basic configuration
  18279. * @param name defines the name of the material
  18280. * @param scene defines the hosting scene
  18281. * @returns a new NodeMaterial
  18282. */
  18283. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  18284. }
  18285. }
  18286. declare module BABYLON {
  18287. interface ThinEngine {
  18288. /**
  18289. * Unbind a list of render target textures from the webGL context
  18290. * This is used only when drawBuffer extension or webGL2 are active
  18291. * @param textures defines the render target textures to unbind
  18292. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  18293. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  18294. */
  18295. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  18296. /**
  18297. * Create a multi render target texture
  18298. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  18299. * @param size defines the size of the texture
  18300. * @param options defines the creation options
  18301. * @param initializeBuffers if set to true, the engine will make an initializing call of drawBuffers
  18302. * @returns the cube texture as an InternalTexture
  18303. */
  18304. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions, initializeBuffers?: boolean): InternalTexture[];
  18305. /**
  18306. * Update the sample count for a given multiple render target texture
  18307. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  18308. * @param textures defines the textures to update
  18309. * @param samples defines the sample count to set
  18310. * @param initializeBuffers if set to true, the engine will make an initializing call of drawBuffers
  18311. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  18312. */
  18313. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number, initializeBuffers?: boolean): number;
  18314. /**
  18315. * Select a subsets of attachments to draw to.
  18316. * @param attachments gl attachments
  18317. */
  18318. bindAttachments(attachments: number[]): void;
  18319. /**
  18320. * Creates a layout object to draw/clear on specific textures in a MRT
  18321. * @param textureStatus textureStatus[i] indicates if the i-th is active
  18322. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  18323. */
  18324. buildTextureLayout(textureStatus: boolean[]): number[];
  18325. /**
  18326. * Restores the webgl state to only draw on the main color attachment
  18327. * when the frame buffer associated is the canvas frame buffer
  18328. */
  18329. restoreSingleAttachment(): void;
  18330. /**
  18331. * Restores the webgl state to only draw on the main color attachment
  18332. * when the frame buffer associated is not the canvas frame buffer
  18333. */
  18334. restoreSingleAttachmentForRenderTarget(): void;
  18335. /**
  18336. * Clears a list of attachments
  18337. * @param attachments list of the attachments
  18338. * @param colorMain clear color for the main attachment (the first one)
  18339. * @param colorOthers clear color for the other attachments
  18340. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  18341. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  18342. */
  18343. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  18344. }
  18345. }
  18346. declare module BABYLON {
  18347. /**
  18348. * Creation options of the multi render target texture.
  18349. */
  18350. export interface IMultiRenderTargetOptions {
  18351. /**
  18352. * Define if the texture needs to create mip maps after render.
  18353. */
  18354. generateMipMaps?: boolean;
  18355. /**
  18356. * Define the types of all the draw buffers we want to create
  18357. */
  18358. types?: number[];
  18359. /**
  18360. * Define the sampling modes of all the draw buffers we want to create
  18361. */
  18362. samplingModes?: number[];
  18363. /**
  18364. * Define if a depth buffer is required
  18365. */
  18366. generateDepthBuffer?: boolean;
  18367. /**
  18368. * Define if a stencil buffer is required
  18369. */
  18370. generateStencilBuffer?: boolean;
  18371. /**
  18372. * Define if a depth texture is required instead of a depth buffer
  18373. */
  18374. generateDepthTexture?: boolean;
  18375. /**
  18376. * Define the number of desired draw buffers
  18377. */
  18378. textureCount?: number;
  18379. /**
  18380. * Define if aspect ratio should be adapted to the texture or stay the scene one
  18381. */
  18382. doNotChangeAspectRatio?: boolean;
  18383. /**
  18384. * Define the default type of the buffers we are creating
  18385. */
  18386. defaultType?: number;
  18387. /**
  18388. * Define the default type of the buffers we are creating
  18389. */
  18390. drawOnlyOnFirstAttachmentByDefault?: boolean;
  18391. }
  18392. /**
  18393. * A multi render target, like a render target provides the ability to render to a texture.
  18394. * Unlike the render target, it can render to several draw buffers in one draw.
  18395. * This is specially interesting in deferred rendering or for any effects requiring more than
  18396. * just one color from a single pass.
  18397. */
  18398. export class MultiRenderTarget extends RenderTargetTexture {
  18399. private _internalTextures;
  18400. private _textures;
  18401. private _multiRenderTargetOptions;
  18402. private _count;
  18403. private _drawOnlyOnFirstAttachmentByDefault;
  18404. /**
  18405. * Get if draw buffers are currently supported by the used hardware and browser.
  18406. */
  18407. get isSupported(): boolean;
  18408. /**
  18409. * Get the list of textures generated by the multi render target.
  18410. */
  18411. get textures(): Texture[];
  18412. /**
  18413. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  18414. */
  18415. get count(): number;
  18416. /**
  18417. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  18418. */
  18419. get depthTexture(): Texture;
  18420. /**
  18421. * Set the wrapping mode on U of all the textures we are rendering to.
  18422. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18423. */
  18424. set wrapU(wrap: number);
  18425. /**
  18426. * Set the wrapping mode on V of all the textures we are rendering to.
  18427. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18428. */
  18429. set wrapV(wrap: number);
  18430. /**
  18431. * Instantiate a new multi render target texture.
  18432. * A multi render target, like a render target provides the ability to render to a texture.
  18433. * Unlike the render target, it can render to several draw buffers in one draw.
  18434. * This is specially interesting in deferred rendering or for any effects requiring more than
  18435. * just one color from a single pass.
  18436. * @param name Define the name of the texture
  18437. * @param size Define the size of the buffers to render to
  18438. * @param count Define the number of target we are rendering into
  18439. * @param scene Define the scene the texture belongs to
  18440. * @param options Define the options used to create the multi render target
  18441. */
  18442. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  18443. private _initTypes;
  18444. /** @hidden */
  18445. _rebuild(forceFullRebuild?: boolean): void;
  18446. private _createInternalTextures;
  18447. private _createTextures;
  18448. /**
  18449. * Replaces a texture within the MRT.
  18450. * @param texture The new texture to insert in the MRT
  18451. * @param index The index of the texture to replace
  18452. */
  18453. replaceTexture(texture: Texture, index: number): void;
  18454. /**
  18455. * Define the number of samples used if MSAA is enabled.
  18456. */
  18457. get samples(): number;
  18458. set samples(value: number);
  18459. /**
  18460. * Resize all the textures in the multi render target.
  18461. * Be careful as it will recreate all the data in the new texture.
  18462. * @param size Define the new size
  18463. */
  18464. resize(size: any): void;
  18465. /**
  18466. * Changes the number of render targets in this MRT
  18467. * Be careful as it will recreate all the data in the new texture.
  18468. * @param count new texture count
  18469. * @param options Specifies texture types and sampling modes for new textures
  18470. */
  18471. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18472. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18473. /**
  18474. * Dispose the render targets and their associated resources
  18475. */
  18476. dispose(): void;
  18477. /**
  18478. * Release all the underlying texture used as draw buffers.
  18479. */
  18480. releaseInternalTextures(): void;
  18481. }
  18482. }
  18483. declare module BABYLON {
  18484. /** @hidden */
  18485. export var imageProcessingPixelShader: {
  18486. name: string;
  18487. shader: string;
  18488. };
  18489. }
  18490. declare module BABYLON {
  18491. /**
  18492. * ImageProcessingPostProcess
  18493. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  18494. */
  18495. export class ImageProcessingPostProcess extends PostProcess {
  18496. /**
  18497. * Default configuration related to image processing available in the PBR Material.
  18498. */
  18499. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18500. /**
  18501. * Gets the image processing configuration used either in this material.
  18502. */
  18503. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18504. /**
  18505. * Sets the Default image processing configuration used either in the this material.
  18506. *
  18507. * If sets to null, the scene one is in use.
  18508. */
  18509. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18510. /**
  18511. * Keep track of the image processing observer to allow dispose and replace.
  18512. */
  18513. private _imageProcessingObserver;
  18514. /**
  18515. * Attaches a new image processing configuration to the PBR Material.
  18516. * @param configuration
  18517. */
  18518. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  18519. /**
  18520. * If the post process is supported.
  18521. */
  18522. get isSupported(): boolean;
  18523. /**
  18524. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18525. */
  18526. get colorCurves(): Nullable<ColorCurves>;
  18527. /**
  18528. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18529. */
  18530. set colorCurves(value: Nullable<ColorCurves>);
  18531. /**
  18532. * Gets whether the color curves effect is enabled.
  18533. */
  18534. get colorCurvesEnabled(): boolean;
  18535. /**
  18536. * Sets whether the color curves effect is enabled.
  18537. */
  18538. set colorCurvesEnabled(value: boolean);
  18539. /**
  18540. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18541. */
  18542. get colorGradingTexture(): Nullable<BaseTexture>;
  18543. /**
  18544. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18545. */
  18546. set colorGradingTexture(value: Nullable<BaseTexture>);
  18547. /**
  18548. * Gets whether the color grading effect is enabled.
  18549. */
  18550. get colorGradingEnabled(): boolean;
  18551. /**
  18552. * Gets whether the color grading effect is enabled.
  18553. */
  18554. set colorGradingEnabled(value: boolean);
  18555. /**
  18556. * Gets exposure used in the effect.
  18557. */
  18558. get exposure(): number;
  18559. /**
  18560. * Sets exposure used in the effect.
  18561. */
  18562. set exposure(value: number);
  18563. /**
  18564. * Gets whether tonemapping is enabled or not.
  18565. */
  18566. get toneMappingEnabled(): boolean;
  18567. /**
  18568. * Sets whether tonemapping is enabled or not
  18569. */
  18570. set toneMappingEnabled(value: boolean);
  18571. /**
  18572. * Gets the type of tone mapping effect.
  18573. */
  18574. get toneMappingType(): number;
  18575. /**
  18576. * Sets the type of tone mapping effect.
  18577. */
  18578. set toneMappingType(value: number);
  18579. /**
  18580. * Gets contrast used in the effect.
  18581. */
  18582. get contrast(): number;
  18583. /**
  18584. * Sets contrast used in the effect.
  18585. */
  18586. set contrast(value: number);
  18587. /**
  18588. * Gets Vignette stretch size.
  18589. */
  18590. get vignetteStretch(): number;
  18591. /**
  18592. * Sets Vignette stretch size.
  18593. */
  18594. set vignetteStretch(value: number);
  18595. /**
  18596. * Gets Vignette centre X Offset.
  18597. */
  18598. get vignetteCentreX(): number;
  18599. /**
  18600. * Sets Vignette centre X Offset.
  18601. */
  18602. set vignetteCentreX(value: number);
  18603. /**
  18604. * Gets Vignette centre Y Offset.
  18605. */
  18606. get vignetteCentreY(): number;
  18607. /**
  18608. * Sets Vignette centre Y Offset.
  18609. */
  18610. set vignetteCentreY(value: number);
  18611. /**
  18612. * Gets Vignette weight or intensity of the vignette effect.
  18613. */
  18614. get vignetteWeight(): number;
  18615. /**
  18616. * Sets Vignette weight or intensity of the vignette effect.
  18617. */
  18618. set vignetteWeight(value: number);
  18619. /**
  18620. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18621. * if vignetteEnabled is set to true.
  18622. */
  18623. get vignetteColor(): Color4;
  18624. /**
  18625. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18626. * if vignetteEnabled is set to true.
  18627. */
  18628. set vignetteColor(value: Color4);
  18629. /**
  18630. * Gets Camera field of view used by the Vignette effect.
  18631. */
  18632. get vignetteCameraFov(): number;
  18633. /**
  18634. * Sets Camera field of view used by the Vignette effect.
  18635. */
  18636. set vignetteCameraFov(value: number);
  18637. /**
  18638. * Gets the vignette blend mode allowing different kind of effect.
  18639. */
  18640. get vignetteBlendMode(): number;
  18641. /**
  18642. * Sets the vignette blend mode allowing different kind of effect.
  18643. */
  18644. set vignetteBlendMode(value: number);
  18645. /**
  18646. * Gets whether the vignette effect is enabled.
  18647. */
  18648. get vignetteEnabled(): boolean;
  18649. /**
  18650. * Sets whether the vignette effect is enabled.
  18651. */
  18652. set vignetteEnabled(value: boolean);
  18653. private _fromLinearSpace;
  18654. /**
  18655. * Gets whether the input of the processing is in Gamma or Linear Space.
  18656. */
  18657. get fromLinearSpace(): boolean;
  18658. /**
  18659. * Sets whether the input of the processing is in Gamma or Linear Space.
  18660. */
  18661. set fromLinearSpace(value: boolean);
  18662. /**
  18663. * Defines cache preventing GC.
  18664. */
  18665. private _defines;
  18666. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  18667. /**
  18668. * "ImageProcessingPostProcess"
  18669. * @returns "ImageProcessingPostProcess"
  18670. */
  18671. getClassName(): string;
  18672. /**
  18673. * @hidden
  18674. */
  18675. _updateParameters(): void;
  18676. dispose(camera?: Camera): void;
  18677. }
  18678. }
  18679. declare module BABYLON {
  18680. /**
  18681. * A multi render target designed to render the prepass.
  18682. * Prepass is a scene component used to render information in multiple textures
  18683. * alongside with the scene materials rendering.
  18684. * Note : This is an internal class, and you should NOT need to instanciate this.
  18685. * Only the `PrePassRenderer` should instanciate this class.
  18686. * It is more likely that you need a regular `MultiRenderTarget`
  18687. * @hidden
  18688. */
  18689. export class PrePassRenderTarget extends MultiRenderTarget {
  18690. /**
  18691. * @hidden
  18692. */
  18693. _beforeCompositionPostProcesses: PostProcess[];
  18694. /**
  18695. * Image processing post process for composition
  18696. */
  18697. imageProcessingPostProcess: ImageProcessingPostProcess;
  18698. /**
  18699. * @hidden
  18700. */
  18701. _engine: Engine;
  18702. /**
  18703. * @hidden
  18704. */
  18705. _scene: Scene;
  18706. /**
  18707. * @hidden
  18708. */
  18709. _outputPostProcess: Nullable<PostProcess>;
  18710. /**
  18711. * @hidden
  18712. */
  18713. _internalTextureDirty: boolean;
  18714. /**
  18715. * Is this render target enabled for prepass rendering
  18716. */
  18717. enabled: boolean;
  18718. /**
  18719. * Render target associated with this prePassRenderTarget
  18720. * If this is `null`, it means this prePassRenderTarget is associated with the scene
  18721. */
  18722. renderTargetTexture: Nullable<RenderTargetTexture>;
  18723. constructor(name: string, renderTargetTexture: Nullable<RenderTargetTexture>, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions | undefined);
  18724. /**
  18725. * Creates a composition effect for this RT
  18726. * @hidden
  18727. */
  18728. _createCompositionEffect(): void;
  18729. /**
  18730. * Checks that the size of this RT is still adapted to the desired render size.
  18731. * @hidden
  18732. */
  18733. _checkSize(): void;
  18734. /**
  18735. * Changes the number of render targets in this MRT
  18736. * Be careful as it will recreate all the data in the new texture.
  18737. * @param count new texture count
  18738. * @param options Specifies texture types and sampling modes for new textures
  18739. */
  18740. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18741. /**
  18742. * Resets the post processes chains applied to this RT.
  18743. * @hidden
  18744. */
  18745. _resetPostProcessChain(): void;
  18746. /**
  18747. * Diposes this render target
  18748. */
  18749. dispose(): void;
  18750. }
  18751. }
  18752. declare module BABYLON {
  18753. /**
  18754. * Interface for defining prepass effects in the prepass post-process pipeline
  18755. */
  18756. export interface PrePassEffectConfiguration {
  18757. /**
  18758. * Name of the effect
  18759. */
  18760. name: string;
  18761. /**
  18762. * Post process to attach for this effect
  18763. */
  18764. postProcess?: PostProcess;
  18765. /**
  18766. * Textures required in the MRT
  18767. */
  18768. texturesRequired: number[];
  18769. /**
  18770. * Is the effect enabled
  18771. */
  18772. enabled: boolean;
  18773. /**
  18774. * Does the output of this prepass need to go through imageprocessing
  18775. */
  18776. needsImageProcessing?: boolean;
  18777. /**
  18778. * Disposes the effect configuration
  18779. */
  18780. dispose?: () => void;
  18781. /**
  18782. * Creates the associated post process
  18783. */
  18784. createPostProcess?: () => PostProcess;
  18785. }
  18786. }
  18787. declare module BABYLON {
  18788. /**
  18789. * Options to be used when creating a FresnelParameters.
  18790. */
  18791. export type IFresnelParametersCreationOptions = {
  18792. /**
  18793. * Define the color used on edges (grazing angle)
  18794. */
  18795. leftColor?: Color3;
  18796. /**
  18797. * Define the color used on center
  18798. */
  18799. rightColor?: Color3;
  18800. /**
  18801. * Define bias applied to computed fresnel term
  18802. */
  18803. bias?: number;
  18804. /**
  18805. * Defined the power exponent applied to fresnel term
  18806. */
  18807. power?: number;
  18808. /**
  18809. * Define if the fresnel effect is enable or not.
  18810. */
  18811. isEnabled?: boolean;
  18812. };
  18813. /**
  18814. * Serialized format for FresnelParameters.
  18815. */
  18816. export type IFresnelParametersSerialized = {
  18817. /**
  18818. * Define the color used on edges (grazing angle) [as an array]
  18819. */
  18820. leftColor: number[];
  18821. /**
  18822. * Define the color used on center [as an array]
  18823. */
  18824. rightColor: number[];
  18825. /**
  18826. * Define bias applied to computed fresnel term
  18827. */
  18828. bias: number;
  18829. /**
  18830. * Defined the power exponent applied to fresnel term
  18831. */
  18832. power?: number;
  18833. /**
  18834. * Define if the fresnel effect is enable or not.
  18835. */
  18836. isEnabled: boolean;
  18837. };
  18838. /**
  18839. * This represents all the required information to add a fresnel effect on a material:
  18840. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18841. */
  18842. export class FresnelParameters {
  18843. private _isEnabled;
  18844. /**
  18845. * Define if the fresnel effect is enable or not.
  18846. */
  18847. get isEnabled(): boolean;
  18848. set isEnabled(value: boolean);
  18849. /**
  18850. * Define the color used on edges (grazing angle)
  18851. */
  18852. leftColor: Color3;
  18853. /**
  18854. * Define the color used on center
  18855. */
  18856. rightColor: Color3;
  18857. /**
  18858. * Define bias applied to computed fresnel term
  18859. */
  18860. bias: number;
  18861. /**
  18862. * Defined the power exponent applied to fresnel term
  18863. */
  18864. power: number;
  18865. /**
  18866. * Creates a new FresnelParameters object.
  18867. *
  18868. * @param options provide your own settings to optionally to override defaults
  18869. */
  18870. constructor(options?: IFresnelParametersCreationOptions);
  18871. /**
  18872. * Clones the current fresnel and its values
  18873. * @returns a clone fresnel configuration
  18874. */
  18875. clone(): FresnelParameters;
  18876. /**
  18877. * Determines equality between FresnelParameters objects
  18878. * @param otherFresnelParameters defines the second operand
  18879. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  18880. */
  18881. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  18882. /**
  18883. * Serializes the current fresnel parameters to a JSON representation.
  18884. * @return the JSON serialization
  18885. */
  18886. serialize(): IFresnelParametersSerialized;
  18887. /**
  18888. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  18889. * @param parsedFresnelParameters Define the JSON representation
  18890. * @returns the parsed parameters
  18891. */
  18892. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  18893. }
  18894. }
  18895. declare module BABYLON {
  18896. /**
  18897. * This groups all the flags used to control the materials channel.
  18898. */
  18899. export class MaterialFlags {
  18900. private static _DiffuseTextureEnabled;
  18901. /**
  18902. * Are diffuse textures enabled in the application.
  18903. */
  18904. static get DiffuseTextureEnabled(): boolean;
  18905. static set DiffuseTextureEnabled(value: boolean);
  18906. private static _DetailTextureEnabled;
  18907. /**
  18908. * Are detail textures enabled in the application.
  18909. */
  18910. static get DetailTextureEnabled(): boolean;
  18911. static set DetailTextureEnabled(value: boolean);
  18912. private static _AmbientTextureEnabled;
  18913. /**
  18914. * Are ambient textures enabled in the application.
  18915. */
  18916. static get AmbientTextureEnabled(): boolean;
  18917. static set AmbientTextureEnabled(value: boolean);
  18918. private static _OpacityTextureEnabled;
  18919. /**
  18920. * Are opacity textures enabled in the application.
  18921. */
  18922. static get OpacityTextureEnabled(): boolean;
  18923. static set OpacityTextureEnabled(value: boolean);
  18924. private static _ReflectionTextureEnabled;
  18925. /**
  18926. * Are reflection textures enabled in the application.
  18927. */
  18928. static get ReflectionTextureEnabled(): boolean;
  18929. static set ReflectionTextureEnabled(value: boolean);
  18930. private static _EmissiveTextureEnabled;
  18931. /**
  18932. * Are emissive textures enabled in the application.
  18933. */
  18934. static get EmissiveTextureEnabled(): boolean;
  18935. static set EmissiveTextureEnabled(value: boolean);
  18936. private static _SpecularTextureEnabled;
  18937. /**
  18938. * Are specular textures enabled in the application.
  18939. */
  18940. static get SpecularTextureEnabled(): boolean;
  18941. static set SpecularTextureEnabled(value: boolean);
  18942. private static _BumpTextureEnabled;
  18943. /**
  18944. * Are bump textures enabled in the application.
  18945. */
  18946. static get BumpTextureEnabled(): boolean;
  18947. static set BumpTextureEnabled(value: boolean);
  18948. private static _LightmapTextureEnabled;
  18949. /**
  18950. * Are lightmap textures enabled in the application.
  18951. */
  18952. static get LightmapTextureEnabled(): boolean;
  18953. static set LightmapTextureEnabled(value: boolean);
  18954. private static _RefractionTextureEnabled;
  18955. /**
  18956. * Are refraction textures enabled in the application.
  18957. */
  18958. static get RefractionTextureEnabled(): boolean;
  18959. static set RefractionTextureEnabled(value: boolean);
  18960. private static _ColorGradingTextureEnabled;
  18961. /**
  18962. * Are color grading textures enabled in the application.
  18963. */
  18964. static get ColorGradingTextureEnabled(): boolean;
  18965. static set ColorGradingTextureEnabled(value: boolean);
  18966. private static _FresnelEnabled;
  18967. /**
  18968. * Are fresnels enabled in the application.
  18969. */
  18970. static get FresnelEnabled(): boolean;
  18971. static set FresnelEnabled(value: boolean);
  18972. private static _ClearCoatTextureEnabled;
  18973. /**
  18974. * Are clear coat textures enabled in the application.
  18975. */
  18976. static get ClearCoatTextureEnabled(): boolean;
  18977. static set ClearCoatTextureEnabled(value: boolean);
  18978. private static _ClearCoatBumpTextureEnabled;
  18979. /**
  18980. * Are clear coat bump textures enabled in the application.
  18981. */
  18982. static get ClearCoatBumpTextureEnabled(): boolean;
  18983. static set ClearCoatBumpTextureEnabled(value: boolean);
  18984. private static _ClearCoatTintTextureEnabled;
  18985. /**
  18986. * Are clear coat tint textures enabled in the application.
  18987. */
  18988. static get ClearCoatTintTextureEnabled(): boolean;
  18989. static set ClearCoatTintTextureEnabled(value: boolean);
  18990. private static _SheenTextureEnabled;
  18991. /**
  18992. * Are sheen textures enabled in the application.
  18993. */
  18994. static get SheenTextureEnabled(): boolean;
  18995. static set SheenTextureEnabled(value: boolean);
  18996. private static _AnisotropicTextureEnabled;
  18997. /**
  18998. * Are anisotropic textures enabled in the application.
  18999. */
  19000. static get AnisotropicTextureEnabled(): boolean;
  19001. static set AnisotropicTextureEnabled(value: boolean);
  19002. private static _ThicknessTextureEnabled;
  19003. /**
  19004. * Are thickness textures enabled in the application.
  19005. */
  19006. static get ThicknessTextureEnabled(): boolean;
  19007. static set ThicknessTextureEnabled(value: boolean);
  19008. }
  19009. }
  19010. declare module BABYLON {
  19011. /** @hidden */
  19012. export var defaultFragmentDeclaration: {
  19013. name: string;
  19014. shader: string;
  19015. };
  19016. }
  19017. declare module BABYLON {
  19018. /** @hidden */
  19019. export var sceneUboDeclaration: {
  19020. name: string;
  19021. shader: string;
  19022. };
  19023. }
  19024. declare module BABYLON {
  19025. /** @hidden */
  19026. export var meshUboDeclaration: {
  19027. name: string;
  19028. shader: string;
  19029. };
  19030. }
  19031. declare module BABYLON {
  19032. /** @hidden */
  19033. export var defaultUboDeclaration: {
  19034. name: string;
  19035. shader: string;
  19036. };
  19037. }
  19038. declare module BABYLON {
  19039. /** @hidden */
  19040. export var prePassDeclaration: {
  19041. name: string;
  19042. shader: string;
  19043. };
  19044. }
  19045. declare module BABYLON {
  19046. /** @hidden */
  19047. export var lightFragmentDeclaration: {
  19048. name: string;
  19049. shader: string;
  19050. };
  19051. }
  19052. declare module BABYLON {
  19053. /** @hidden */
  19054. export var lightUboDeclaration: {
  19055. name: string;
  19056. shader: string;
  19057. };
  19058. }
  19059. declare module BABYLON {
  19060. /** @hidden */
  19061. export var lightsFragmentFunctions: {
  19062. name: string;
  19063. shader: string;
  19064. };
  19065. }
  19066. declare module BABYLON {
  19067. /** @hidden */
  19068. export var shadowsFragmentFunctions: {
  19069. name: string;
  19070. shader: string;
  19071. };
  19072. }
  19073. declare module BABYLON {
  19074. /** @hidden */
  19075. export var fresnelFunction: {
  19076. name: string;
  19077. shader: string;
  19078. };
  19079. }
  19080. declare module BABYLON {
  19081. /** @hidden */
  19082. export var bumpFragmentMainFunctions: {
  19083. name: string;
  19084. shader: string;
  19085. };
  19086. }
  19087. declare module BABYLON {
  19088. /** @hidden */
  19089. export var bumpFragmentFunctions: {
  19090. name: string;
  19091. shader: string;
  19092. };
  19093. }
  19094. declare module BABYLON {
  19095. /** @hidden */
  19096. export var logDepthDeclaration: {
  19097. name: string;
  19098. shader: string;
  19099. };
  19100. }
  19101. declare module BABYLON {
  19102. /** @hidden */
  19103. export var fogFragmentDeclaration: {
  19104. name: string;
  19105. shader: string;
  19106. };
  19107. }
  19108. declare module BABYLON {
  19109. /** @hidden */
  19110. export var bumpFragment: {
  19111. name: string;
  19112. shader: string;
  19113. };
  19114. }
  19115. declare module BABYLON {
  19116. /** @hidden */
  19117. export var depthPrePass: {
  19118. name: string;
  19119. shader: string;
  19120. };
  19121. }
  19122. declare module BABYLON {
  19123. /** @hidden */
  19124. export var lightFragment: {
  19125. name: string;
  19126. shader: string;
  19127. };
  19128. }
  19129. declare module BABYLON {
  19130. /** @hidden */
  19131. export var logDepthFragment: {
  19132. name: string;
  19133. shader: string;
  19134. };
  19135. }
  19136. declare module BABYLON {
  19137. /** @hidden */
  19138. export var fogFragment: {
  19139. name: string;
  19140. shader: string;
  19141. };
  19142. }
  19143. declare module BABYLON {
  19144. /** @hidden */
  19145. export var defaultPixelShader: {
  19146. name: string;
  19147. shader: string;
  19148. };
  19149. }
  19150. declare module BABYLON {
  19151. /** @hidden */
  19152. export var defaultVertexDeclaration: {
  19153. name: string;
  19154. shader: string;
  19155. };
  19156. }
  19157. declare module BABYLON {
  19158. /** @hidden */
  19159. export var bonesDeclaration: {
  19160. name: string;
  19161. shader: string;
  19162. };
  19163. }
  19164. declare module BABYLON {
  19165. /** @hidden */
  19166. export var prePassVertexDeclaration: {
  19167. name: string;
  19168. shader: string;
  19169. };
  19170. }
  19171. declare module BABYLON {
  19172. /** @hidden */
  19173. export var bumpVertexDeclaration: {
  19174. name: string;
  19175. shader: string;
  19176. };
  19177. }
  19178. declare module BABYLON {
  19179. /** @hidden */
  19180. export var fogVertexDeclaration: {
  19181. name: string;
  19182. shader: string;
  19183. };
  19184. }
  19185. declare module BABYLON {
  19186. /** @hidden */
  19187. export var lightVxFragmentDeclaration: {
  19188. name: string;
  19189. shader: string;
  19190. };
  19191. }
  19192. declare module BABYLON {
  19193. /** @hidden */
  19194. export var lightVxUboDeclaration: {
  19195. name: string;
  19196. shader: string;
  19197. };
  19198. }
  19199. declare module BABYLON {
  19200. /** @hidden */
  19201. export var morphTargetsVertexGlobalDeclaration: {
  19202. name: string;
  19203. shader: string;
  19204. };
  19205. }
  19206. declare module BABYLON {
  19207. /** @hidden */
  19208. export var morphTargetsVertexDeclaration: {
  19209. name: string;
  19210. shader: string;
  19211. };
  19212. }
  19213. declare module BABYLON {
  19214. /** @hidden */
  19215. export var morphTargetsVertexGlobal: {
  19216. name: string;
  19217. shader: string;
  19218. };
  19219. }
  19220. declare module BABYLON {
  19221. /** @hidden */
  19222. export var morphTargetsVertex: {
  19223. name: string;
  19224. shader: string;
  19225. };
  19226. }
  19227. declare module BABYLON {
  19228. /** @hidden */
  19229. export var instancesVertex: {
  19230. name: string;
  19231. shader: string;
  19232. };
  19233. }
  19234. declare module BABYLON {
  19235. /** @hidden */
  19236. export var bonesVertex: {
  19237. name: string;
  19238. shader: string;
  19239. };
  19240. }
  19241. declare module BABYLON {
  19242. /** @hidden */
  19243. export var prePassVertex: {
  19244. name: string;
  19245. shader: string;
  19246. };
  19247. }
  19248. declare module BABYLON {
  19249. /** @hidden */
  19250. export var bumpVertex: {
  19251. name: string;
  19252. shader: string;
  19253. };
  19254. }
  19255. declare module BABYLON {
  19256. /** @hidden */
  19257. export var fogVertex: {
  19258. name: string;
  19259. shader: string;
  19260. };
  19261. }
  19262. declare module BABYLON {
  19263. /** @hidden */
  19264. export var shadowsVertex: {
  19265. name: string;
  19266. shader: string;
  19267. };
  19268. }
  19269. declare module BABYLON {
  19270. /** @hidden */
  19271. export var pointCloudVertex: {
  19272. name: string;
  19273. shader: string;
  19274. };
  19275. }
  19276. declare module BABYLON {
  19277. /** @hidden */
  19278. export var logDepthVertex: {
  19279. name: string;
  19280. shader: string;
  19281. };
  19282. }
  19283. declare module BABYLON {
  19284. /** @hidden */
  19285. export var defaultVertexShader: {
  19286. name: string;
  19287. shader: string;
  19288. };
  19289. }
  19290. declare module BABYLON {
  19291. /**
  19292. * @hidden
  19293. */
  19294. export interface IMaterialDetailMapDefines {
  19295. DETAIL: boolean;
  19296. DETAILDIRECTUV: number;
  19297. DETAIL_NORMALBLENDMETHOD: number;
  19298. /** @hidden */
  19299. _areTexturesDirty: boolean;
  19300. }
  19301. /**
  19302. * Define the code related to the detail map parameters of a material
  19303. *
  19304. * Inspired from:
  19305. * 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
  19306. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  19307. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  19308. */
  19309. export class DetailMapConfiguration {
  19310. private _texture;
  19311. /**
  19312. * The detail texture of the material.
  19313. */
  19314. texture: Nullable<BaseTexture>;
  19315. /**
  19316. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  19317. * Bigger values mean stronger blending
  19318. */
  19319. diffuseBlendLevel: number;
  19320. /**
  19321. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  19322. * Bigger values mean stronger blending. Only used with PBR materials
  19323. */
  19324. roughnessBlendLevel: number;
  19325. /**
  19326. * Defines how strong the bump effect from the detail map is
  19327. * Bigger values mean stronger effect
  19328. */
  19329. bumpLevel: number;
  19330. private _normalBlendMethod;
  19331. /**
  19332. * The method used to blend the bump and detail normals together
  19333. */
  19334. normalBlendMethod: number;
  19335. private _isEnabled;
  19336. /**
  19337. * Enable or disable the detail map on this material
  19338. */
  19339. isEnabled: boolean;
  19340. /** @hidden */
  19341. private _internalMarkAllSubMeshesAsTexturesDirty;
  19342. /** @hidden */
  19343. _markAllSubMeshesAsTexturesDirty(): void;
  19344. /**
  19345. * Instantiate a new detail map
  19346. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19347. */
  19348. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19349. /**
  19350. * Gets whether the submesh is ready to be used or not.
  19351. * @param defines the list of "defines" to update.
  19352. * @param scene defines the scene the material belongs to.
  19353. * @returns - boolean indicating that the submesh is ready or not.
  19354. */
  19355. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  19356. /**
  19357. * Update the defines for detail map usage
  19358. * @param defines the list of "defines" to update.
  19359. * @param scene defines the scene the material belongs to.
  19360. */
  19361. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  19362. /**
  19363. * Binds the material data.
  19364. * @param uniformBuffer defines the Uniform buffer to fill in.
  19365. * @param scene defines the scene the material belongs to.
  19366. * @param isFrozen defines whether the material is frozen or not.
  19367. */
  19368. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19369. /**
  19370. * Checks to see if a texture is used in the material.
  19371. * @param texture - Base texture to use.
  19372. * @returns - Boolean specifying if a texture is used in the material.
  19373. */
  19374. hasTexture(texture: BaseTexture): boolean;
  19375. /**
  19376. * Returns an array of the actively used textures.
  19377. * @param activeTextures Array of BaseTextures
  19378. */
  19379. getActiveTextures(activeTextures: BaseTexture[]): void;
  19380. /**
  19381. * Returns the animatable textures.
  19382. * @param animatables Array of animatable textures.
  19383. */
  19384. getAnimatables(animatables: IAnimatable[]): void;
  19385. /**
  19386. * Disposes the resources of the material.
  19387. * @param forceDisposeTextures - Forces the disposal of all textures.
  19388. */
  19389. dispose(forceDisposeTextures?: boolean): void;
  19390. /**
  19391. * Get the current class name useful for serialization or dynamic coding.
  19392. * @returns "DetailMap"
  19393. */
  19394. getClassName(): string;
  19395. /**
  19396. * Add the required uniforms to the current list.
  19397. * @param uniforms defines the current uniform list.
  19398. */
  19399. static AddUniforms(uniforms: string[]): void;
  19400. /**
  19401. * Add the required samplers to the current list.
  19402. * @param samplers defines the current sampler list.
  19403. */
  19404. static AddSamplers(samplers: string[]): void;
  19405. /**
  19406. * Add the required uniforms to the current buffer.
  19407. * @param uniformBuffer defines the current uniform buffer.
  19408. */
  19409. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19410. /**
  19411. * Makes a duplicate of the current instance into another one.
  19412. * @param detailMap define the instance where to copy the info
  19413. */
  19414. copyTo(detailMap: DetailMapConfiguration): void;
  19415. /**
  19416. * Serializes this detail map instance
  19417. * @returns - An object with the serialized instance.
  19418. */
  19419. serialize(): any;
  19420. /**
  19421. * Parses a detail map setting from a serialized object.
  19422. * @param source - Serialized object.
  19423. * @param scene Defines the scene we are parsing for
  19424. * @param rootUrl Defines the rootUrl to load from
  19425. */
  19426. parse(source: any, scene: Scene, rootUrl: string): void;
  19427. }
  19428. }
  19429. declare module BABYLON {
  19430. /** @hidden */
  19431. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  19432. MAINUV1: boolean;
  19433. MAINUV2: boolean;
  19434. DIFFUSE: boolean;
  19435. DIFFUSEDIRECTUV: number;
  19436. DETAIL: boolean;
  19437. DETAILDIRECTUV: number;
  19438. DETAIL_NORMALBLENDMETHOD: number;
  19439. AMBIENT: boolean;
  19440. AMBIENTDIRECTUV: number;
  19441. OPACITY: boolean;
  19442. OPACITYDIRECTUV: number;
  19443. OPACITYRGB: boolean;
  19444. REFLECTION: boolean;
  19445. EMISSIVE: boolean;
  19446. EMISSIVEDIRECTUV: number;
  19447. SPECULAR: boolean;
  19448. SPECULARDIRECTUV: number;
  19449. BUMP: boolean;
  19450. BUMPDIRECTUV: number;
  19451. PARALLAX: boolean;
  19452. PARALLAXOCCLUSION: boolean;
  19453. SPECULAROVERALPHA: boolean;
  19454. CLIPPLANE: boolean;
  19455. CLIPPLANE2: boolean;
  19456. CLIPPLANE3: boolean;
  19457. CLIPPLANE4: boolean;
  19458. CLIPPLANE5: boolean;
  19459. CLIPPLANE6: boolean;
  19460. ALPHATEST: boolean;
  19461. DEPTHPREPASS: boolean;
  19462. ALPHAFROMDIFFUSE: boolean;
  19463. POINTSIZE: boolean;
  19464. FOG: boolean;
  19465. SPECULARTERM: boolean;
  19466. DIFFUSEFRESNEL: boolean;
  19467. OPACITYFRESNEL: boolean;
  19468. REFLECTIONFRESNEL: boolean;
  19469. REFRACTIONFRESNEL: boolean;
  19470. EMISSIVEFRESNEL: boolean;
  19471. FRESNEL: boolean;
  19472. NORMAL: boolean;
  19473. UV1: boolean;
  19474. UV2: boolean;
  19475. VERTEXCOLOR: boolean;
  19476. VERTEXALPHA: boolean;
  19477. NUM_BONE_INFLUENCERS: number;
  19478. BonesPerMesh: number;
  19479. BONETEXTURE: boolean;
  19480. BONES_VELOCITY_ENABLED: boolean;
  19481. INSTANCES: boolean;
  19482. THIN_INSTANCES: boolean;
  19483. GLOSSINESS: boolean;
  19484. ROUGHNESS: boolean;
  19485. EMISSIVEASILLUMINATION: boolean;
  19486. LINKEMISSIVEWITHDIFFUSE: boolean;
  19487. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19488. LIGHTMAP: boolean;
  19489. LIGHTMAPDIRECTUV: number;
  19490. OBJECTSPACE_NORMALMAP: boolean;
  19491. USELIGHTMAPASSHADOWMAP: boolean;
  19492. REFLECTIONMAP_3D: boolean;
  19493. REFLECTIONMAP_SPHERICAL: boolean;
  19494. REFLECTIONMAP_PLANAR: boolean;
  19495. REFLECTIONMAP_CUBIC: boolean;
  19496. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19497. REFLECTIONMAP_PROJECTION: boolean;
  19498. REFLECTIONMAP_SKYBOX: boolean;
  19499. REFLECTIONMAP_EXPLICIT: boolean;
  19500. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19501. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19502. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19503. REFLECTIONMAP_OPPOSITEZ: boolean;
  19504. INVERTCUBICMAP: boolean;
  19505. LOGARITHMICDEPTH: boolean;
  19506. REFRACTION: boolean;
  19507. REFRACTIONMAP_3D: boolean;
  19508. REFLECTIONOVERALPHA: boolean;
  19509. TWOSIDEDLIGHTING: boolean;
  19510. SHADOWFLOAT: boolean;
  19511. MORPHTARGETS: boolean;
  19512. MORPHTARGETS_NORMAL: boolean;
  19513. MORPHTARGETS_TANGENT: boolean;
  19514. MORPHTARGETS_UV: boolean;
  19515. NUM_MORPH_INFLUENCERS: number;
  19516. MORPHTARGETS_TEXTURE: boolean;
  19517. NONUNIFORMSCALING: boolean;
  19518. PREMULTIPLYALPHA: boolean;
  19519. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  19520. ALPHABLEND: boolean;
  19521. PREPASS: boolean;
  19522. PREPASS_IRRADIANCE: boolean;
  19523. PREPASS_IRRADIANCE_INDEX: number;
  19524. PREPASS_ALBEDO: boolean;
  19525. PREPASS_ALBEDO_INDEX: number;
  19526. PREPASS_DEPTH: boolean;
  19527. PREPASS_DEPTH_INDEX: number;
  19528. PREPASS_NORMAL: boolean;
  19529. PREPASS_NORMAL_INDEX: number;
  19530. PREPASS_POSITION: boolean;
  19531. PREPASS_POSITION_INDEX: number;
  19532. PREPASS_VELOCITY: boolean;
  19533. PREPASS_VELOCITY_INDEX: number;
  19534. PREPASS_REFLECTIVITY: boolean;
  19535. PREPASS_REFLECTIVITY_INDEX: number;
  19536. SCENE_MRT_COUNT: number;
  19537. RGBDLIGHTMAP: boolean;
  19538. RGBDREFLECTION: boolean;
  19539. RGBDREFRACTION: boolean;
  19540. IMAGEPROCESSING: boolean;
  19541. VIGNETTE: boolean;
  19542. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19543. VIGNETTEBLENDMODEOPAQUE: boolean;
  19544. TONEMAPPING: boolean;
  19545. TONEMAPPING_ACES: boolean;
  19546. CONTRAST: boolean;
  19547. COLORCURVES: boolean;
  19548. COLORGRADING: boolean;
  19549. COLORGRADING3D: boolean;
  19550. SAMPLER3DGREENDEPTH: boolean;
  19551. SAMPLER3DBGRMAP: boolean;
  19552. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19553. MULTIVIEW: boolean;
  19554. /**
  19555. * If the reflection texture on this material is in linear color space
  19556. * @hidden
  19557. */
  19558. IS_REFLECTION_LINEAR: boolean;
  19559. /**
  19560. * If the refraction texture on this material is in linear color space
  19561. * @hidden
  19562. */
  19563. IS_REFRACTION_LINEAR: boolean;
  19564. EXPOSURE: boolean;
  19565. constructor();
  19566. setReflectionMode(modeToEnable: string): void;
  19567. }
  19568. /**
  19569. * This is the default material used in Babylon. It is the best trade off between quality
  19570. * and performances.
  19571. * @see https://doc.babylonjs.com/babylon101/materials
  19572. */
  19573. export class StandardMaterial extends PushMaterial {
  19574. private _diffuseTexture;
  19575. /**
  19576. * The basic texture of the material as viewed under a light.
  19577. */
  19578. diffuseTexture: Nullable<BaseTexture>;
  19579. private _ambientTexture;
  19580. /**
  19581. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19582. */
  19583. ambientTexture: Nullable<BaseTexture>;
  19584. private _opacityTexture;
  19585. /**
  19586. * Define the transparency of the material from a texture.
  19587. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19588. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19589. */
  19590. opacityTexture: Nullable<BaseTexture>;
  19591. private _reflectionTexture;
  19592. /**
  19593. * Define the texture used to display the reflection.
  19594. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19595. */
  19596. reflectionTexture: Nullable<BaseTexture>;
  19597. private _emissiveTexture;
  19598. /**
  19599. * Define texture of the material as if self lit.
  19600. * This will be mixed in the final result even in the absence of light.
  19601. */
  19602. emissiveTexture: Nullable<BaseTexture>;
  19603. private _specularTexture;
  19604. /**
  19605. * Define how the color and intensity of the highlight given by the light in the material.
  19606. */
  19607. specularTexture: Nullable<BaseTexture>;
  19608. private _bumpTexture;
  19609. /**
  19610. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19611. * 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.
  19612. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  19613. */
  19614. bumpTexture: Nullable<BaseTexture>;
  19615. private _lightmapTexture;
  19616. /**
  19617. * Complex lighting can be computationally expensive to compute at runtime.
  19618. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19619. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  19620. */
  19621. lightmapTexture: Nullable<BaseTexture>;
  19622. private _refractionTexture;
  19623. /**
  19624. * Define the texture used to display the refraction.
  19625. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19626. */
  19627. refractionTexture: Nullable<BaseTexture>;
  19628. /**
  19629. * The color of the material lit by the environmental background lighting.
  19630. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19631. */
  19632. ambientColor: Color3;
  19633. /**
  19634. * The basic color of the material as viewed under a light.
  19635. */
  19636. diffuseColor: Color3;
  19637. /**
  19638. * Define how the color and intensity of the highlight given by the light in the material.
  19639. */
  19640. specularColor: Color3;
  19641. /**
  19642. * Define the color of the material as if self lit.
  19643. * This will be mixed in the final result even in the absence of light.
  19644. */
  19645. emissiveColor: Color3;
  19646. /**
  19647. * Defines how sharp are the highlights in the material.
  19648. * The bigger the value the sharper giving a more glossy feeling to the result.
  19649. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19650. */
  19651. specularPower: number;
  19652. private _useAlphaFromDiffuseTexture;
  19653. /**
  19654. * Does the transparency come from the diffuse texture alpha channel.
  19655. */
  19656. useAlphaFromDiffuseTexture: boolean;
  19657. private _useEmissiveAsIllumination;
  19658. /**
  19659. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19660. */
  19661. useEmissiveAsIllumination: boolean;
  19662. private _linkEmissiveWithDiffuse;
  19663. /**
  19664. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19665. * the emissive level when the final color is close to one.
  19666. */
  19667. linkEmissiveWithDiffuse: boolean;
  19668. private _useSpecularOverAlpha;
  19669. /**
  19670. * Specifies that the material will keep the specular highlights over a transparent surface (only the most luminous ones).
  19671. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19672. */
  19673. useSpecularOverAlpha: boolean;
  19674. private _useReflectionOverAlpha;
  19675. /**
  19676. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  19677. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19678. */
  19679. useReflectionOverAlpha: boolean;
  19680. private _disableLighting;
  19681. /**
  19682. * Does lights from the scene impacts this material.
  19683. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19684. */
  19685. disableLighting: boolean;
  19686. private _useObjectSpaceNormalMap;
  19687. /**
  19688. * Allows using an object space normal map (instead of tangent space).
  19689. */
  19690. useObjectSpaceNormalMap: boolean;
  19691. private _useParallax;
  19692. /**
  19693. * Is parallax enabled or not.
  19694. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19695. */
  19696. useParallax: boolean;
  19697. private _useParallaxOcclusion;
  19698. /**
  19699. * Is parallax occlusion enabled or not.
  19700. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19701. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19702. */
  19703. useParallaxOcclusion: boolean;
  19704. /**
  19705. * 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.
  19706. */
  19707. parallaxScaleBias: number;
  19708. private _roughness;
  19709. /**
  19710. * Helps to define how blurry the reflections should appears in the material.
  19711. */
  19712. roughness: number;
  19713. /**
  19714. * In case of refraction, define the value of the index of refraction.
  19715. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19716. */
  19717. indexOfRefraction: number;
  19718. /**
  19719. * Invert the refraction texture alongside the y axis.
  19720. * It can be useful with procedural textures or probe for instance.
  19721. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19722. */
  19723. invertRefractionY: boolean;
  19724. /**
  19725. * Defines the alpha limits in alpha test mode.
  19726. */
  19727. alphaCutOff: number;
  19728. private _useLightmapAsShadowmap;
  19729. /**
  19730. * In case of light mapping, define whether the map contains light or shadow informations.
  19731. */
  19732. useLightmapAsShadowmap: boolean;
  19733. private _diffuseFresnelParameters;
  19734. /**
  19735. * Define the diffuse fresnel parameters of the material.
  19736. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19737. */
  19738. diffuseFresnelParameters: FresnelParameters;
  19739. private _opacityFresnelParameters;
  19740. /**
  19741. * Define the opacity fresnel parameters of the material.
  19742. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19743. */
  19744. opacityFresnelParameters: FresnelParameters;
  19745. private _reflectionFresnelParameters;
  19746. /**
  19747. * Define the reflection fresnel parameters of the material.
  19748. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19749. */
  19750. reflectionFresnelParameters: FresnelParameters;
  19751. private _refractionFresnelParameters;
  19752. /**
  19753. * Define the refraction fresnel parameters of the material.
  19754. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19755. */
  19756. refractionFresnelParameters: FresnelParameters;
  19757. private _emissiveFresnelParameters;
  19758. /**
  19759. * Define the emissive fresnel parameters of the material.
  19760. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19761. */
  19762. emissiveFresnelParameters: FresnelParameters;
  19763. private _useReflectionFresnelFromSpecular;
  19764. /**
  19765. * If true automatically deducts the fresnels values from the material specularity.
  19766. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19767. */
  19768. useReflectionFresnelFromSpecular: boolean;
  19769. private _useGlossinessFromSpecularMapAlpha;
  19770. /**
  19771. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19772. */
  19773. useGlossinessFromSpecularMapAlpha: boolean;
  19774. private _maxSimultaneousLights;
  19775. /**
  19776. * Defines the maximum number of lights that can be used in the material
  19777. */
  19778. maxSimultaneousLights: number;
  19779. private _invertNormalMapX;
  19780. /**
  19781. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19782. */
  19783. invertNormalMapX: boolean;
  19784. private _invertNormalMapY;
  19785. /**
  19786. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19787. */
  19788. invertNormalMapY: boolean;
  19789. private _twoSidedLighting;
  19790. /**
  19791. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19792. */
  19793. twoSidedLighting: boolean;
  19794. /**
  19795. * Default configuration related to image processing available in the standard Material.
  19796. */
  19797. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19798. /**
  19799. * Gets the image processing configuration used either in this material.
  19800. */
  19801. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  19802. /**
  19803. * Sets the Default image processing configuration used either in the this material.
  19804. *
  19805. * If sets to null, the scene one is in use.
  19806. */
  19807. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  19808. /**
  19809. * Keep track of the image processing observer to allow dispose and replace.
  19810. */
  19811. private _imageProcessingObserver;
  19812. /**
  19813. * Attaches a new image processing configuration to the Standard Material.
  19814. * @param configuration
  19815. */
  19816. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19817. /**
  19818. * Defines additional PrePass parameters for the material.
  19819. */
  19820. readonly prePassConfiguration: PrePassConfiguration;
  19821. /**
  19822. * Can this material render to prepass
  19823. */
  19824. get isPrePassCapable(): boolean;
  19825. /**
  19826. * Gets whether the color curves effect is enabled.
  19827. */
  19828. get cameraColorCurvesEnabled(): boolean;
  19829. /**
  19830. * Sets whether the color curves effect is enabled.
  19831. */
  19832. set cameraColorCurvesEnabled(value: boolean);
  19833. /**
  19834. * Gets whether the color grading effect is enabled.
  19835. */
  19836. get cameraColorGradingEnabled(): boolean;
  19837. /**
  19838. * Gets whether the color grading effect is enabled.
  19839. */
  19840. set cameraColorGradingEnabled(value: boolean);
  19841. /**
  19842. * Gets whether tonemapping is enabled or not.
  19843. */
  19844. get cameraToneMappingEnabled(): boolean;
  19845. /**
  19846. * Sets whether tonemapping is enabled or not
  19847. */
  19848. set cameraToneMappingEnabled(value: boolean);
  19849. /**
  19850. * The camera exposure used on this material.
  19851. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19852. * This corresponds to a photographic exposure.
  19853. */
  19854. get cameraExposure(): number;
  19855. /**
  19856. * The camera exposure used on this material.
  19857. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19858. * This corresponds to a photographic exposure.
  19859. */
  19860. set cameraExposure(value: number);
  19861. /**
  19862. * Gets The camera contrast used on this material.
  19863. */
  19864. get cameraContrast(): number;
  19865. /**
  19866. * Sets The camera contrast used on this material.
  19867. */
  19868. set cameraContrast(value: number);
  19869. /**
  19870. * Gets the Color Grading 2D Lookup Texture.
  19871. */
  19872. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  19873. /**
  19874. * Sets the Color Grading 2D Lookup Texture.
  19875. */
  19876. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  19877. /**
  19878. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19879. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19880. * 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;
  19881. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19882. */
  19883. get cameraColorCurves(): Nullable<ColorCurves>;
  19884. /**
  19885. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  19886. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19887. * 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;
  19888. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19889. */
  19890. set cameraColorCurves(value: Nullable<ColorCurves>);
  19891. /**
  19892. * Can this material render to several textures at once
  19893. */
  19894. get canRenderToMRT(): boolean;
  19895. /**
  19896. * Defines the detail map parameters for the material.
  19897. */
  19898. readonly detailMap: DetailMapConfiguration;
  19899. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19900. protected _worldViewProjectionMatrix: Matrix;
  19901. protected _globalAmbientColor: Color3;
  19902. protected _useLogarithmicDepth: boolean;
  19903. protected _rebuildInParallel: boolean;
  19904. /**
  19905. * Instantiates a new standard material.
  19906. * This is the default material used in Babylon. It is the best trade off between quality
  19907. * and performances.
  19908. * @see https://doc.babylonjs.com/babylon101/materials
  19909. * @param name Define the name of the material in the scene
  19910. * @param scene Define the scene the material belong to
  19911. */
  19912. constructor(name: string, scene: Scene);
  19913. /**
  19914. * Gets a boolean indicating that current material needs to register RTT
  19915. */
  19916. get hasRenderTargetTextures(): boolean;
  19917. /**
  19918. * Gets the current class name of the material e.g. "StandardMaterial"
  19919. * Mainly use in serialization.
  19920. * @returns the class name
  19921. */
  19922. getClassName(): string;
  19923. /**
  19924. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19925. * You can try switching to logarithmic depth.
  19926. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19927. */
  19928. get useLogarithmicDepth(): boolean;
  19929. set useLogarithmicDepth(value: boolean);
  19930. /**
  19931. * Specifies if the material will require alpha blending
  19932. * @returns a boolean specifying if alpha blending is needed
  19933. */
  19934. needAlphaBlending(): boolean;
  19935. /**
  19936. * Specifies if this material should be rendered in alpha test mode
  19937. * @returns a boolean specifying if an alpha test is needed.
  19938. */
  19939. needAlphaTesting(): boolean;
  19940. /**
  19941. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  19942. */
  19943. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19944. /**
  19945. * Specifies whether or not there is a usable alpha channel for transparency.
  19946. */
  19947. protected _hasAlphaChannel(): boolean;
  19948. /**
  19949. * Get the texture used for alpha test purpose.
  19950. * @returns the diffuse texture in case of the standard material.
  19951. */
  19952. getAlphaTestTexture(): Nullable<BaseTexture>;
  19953. /**
  19954. * Get if the submesh is ready to be used and all its information available.
  19955. * Child classes can use it to update shaders
  19956. * @param mesh defines the mesh to check
  19957. * @param subMesh defines which submesh to check
  19958. * @param useInstances specifies that instances should be used
  19959. * @returns a boolean indicating that the submesh is ready or not
  19960. */
  19961. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19962. /**
  19963. * Builds the material UBO layouts.
  19964. * Used internally during the effect preparation.
  19965. */
  19966. buildUniformLayout(): void;
  19967. /**
  19968. * Unbinds the material from the mesh
  19969. */
  19970. unbind(): void;
  19971. /**
  19972. * Binds the submesh to this material by preparing the effect and shader to draw
  19973. * @param world defines the world transformation matrix
  19974. * @param mesh defines the mesh containing the submesh
  19975. * @param subMesh defines the submesh to bind the material to
  19976. */
  19977. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19978. /**
  19979. * Get the list of animatables in the material.
  19980. * @returns the list of animatables object used in the material
  19981. */
  19982. getAnimatables(): IAnimatable[];
  19983. /**
  19984. * Gets the active textures from the material
  19985. * @returns an array of textures
  19986. */
  19987. getActiveTextures(): BaseTexture[];
  19988. /**
  19989. * Specifies if the material uses a texture
  19990. * @param texture defines the texture to check against the material
  19991. * @returns a boolean specifying if the material uses the texture
  19992. */
  19993. hasTexture(texture: BaseTexture): boolean;
  19994. /**
  19995. * Disposes the material
  19996. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19997. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19998. */
  19999. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  20000. /**
  20001. * Makes a duplicate of the material, and gives it a new name
  20002. * @param name defines the new name for the duplicated material
  20003. * @returns the cloned material
  20004. */
  20005. clone(name: string): StandardMaterial;
  20006. /**
  20007. * Serializes this material in a JSON representation
  20008. * @returns the serialized material object
  20009. */
  20010. serialize(): any;
  20011. /**
  20012. * Creates a standard material from parsed material data
  20013. * @param source defines the JSON representation of the material
  20014. * @param scene defines the hosting scene
  20015. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20016. * @returns a new standard material
  20017. */
  20018. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  20019. /**
  20020. * Are diffuse textures enabled in the application.
  20021. */
  20022. static get DiffuseTextureEnabled(): boolean;
  20023. static set DiffuseTextureEnabled(value: boolean);
  20024. /**
  20025. * Are detail textures enabled in the application.
  20026. */
  20027. static get DetailTextureEnabled(): boolean;
  20028. static set DetailTextureEnabled(value: boolean);
  20029. /**
  20030. * Are ambient textures enabled in the application.
  20031. */
  20032. static get AmbientTextureEnabled(): boolean;
  20033. static set AmbientTextureEnabled(value: boolean);
  20034. /**
  20035. * Are opacity textures enabled in the application.
  20036. */
  20037. static get OpacityTextureEnabled(): boolean;
  20038. static set OpacityTextureEnabled(value: boolean);
  20039. /**
  20040. * Are reflection textures enabled in the application.
  20041. */
  20042. static get ReflectionTextureEnabled(): boolean;
  20043. static set ReflectionTextureEnabled(value: boolean);
  20044. /**
  20045. * Are emissive textures enabled in the application.
  20046. */
  20047. static get EmissiveTextureEnabled(): boolean;
  20048. static set EmissiveTextureEnabled(value: boolean);
  20049. /**
  20050. * Are specular textures enabled in the application.
  20051. */
  20052. static get SpecularTextureEnabled(): boolean;
  20053. static set SpecularTextureEnabled(value: boolean);
  20054. /**
  20055. * Are bump textures enabled in the application.
  20056. */
  20057. static get BumpTextureEnabled(): boolean;
  20058. static set BumpTextureEnabled(value: boolean);
  20059. /**
  20060. * Are lightmap textures enabled in the application.
  20061. */
  20062. static get LightmapTextureEnabled(): boolean;
  20063. static set LightmapTextureEnabled(value: boolean);
  20064. /**
  20065. * Are refraction textures enabled in the application.
  20066. */
  20067. static get RefractionTextureEnabled(): boolean;
  20068. static set RefractionTextureEnabled(value: boolean);
  20069. /**
  20070. * Are color grading textures enabled in the application.
  20071. */
  20072. static get ColorGradingTextureEnabled(): boolean;
  20073. static set ColorGradingTextureEnabled(value: boolean);
  20074. /**
  20075. * Are fresnels enabled in the application.
  20076. */
  20077. static get FresnelEnabled(): boolean;
  20078. static set FresnelEnabled(value: boolean);
  20079. }
  20080. }
  20081. declare module BABYLON {
  20082. /** @hidden */
  20083. export var rgbdDecodePixelShader: {
  20084. name: string;
  20085. shader: string;
  20086. };
  20087. }
  20088. declare module BABYLON {
  20089. /** @hidden */
  20090. export var passPixelShader: {
  20091. name: string;
  20092. shader: string;
  20093. };
  20094. }
  20095. declare module BABYLON {
  20096. /** @hidden */
  20097. export var passCubePixelShader: {
  20098. name: string;
  20099. shader: string;
  20100. };
  20101. }
  20102. declare module BABYLON {
  20103. /**
  20104. * PassPostProcess which produces an output the same as it's input
  20105. */
  20106. export class PassPostProcess extends PostProcess {
  20107. /**
  20108. * Gets a string identifying the name of the class
  20109. * @returns "PassPostProcess" string
  20110. */
  20111. getClassName(): string;
  20112. /**
  20113. * Creates the PassPostProcess
  20114. * @param name The name of the effect.
  20115. * @param options The required width/height ratio to downsize to before computing the render pass.
  20116. * @param camera The camera to apply the render pass to.
  20117. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20118. * @param engine The engine which the post process will be applied. (default: current engine)
  20119. * @param reusable If the post process can be reused on the same frame. (default: false)
  20120. * @param textureType The type of texture to be used when performing the post processing.
  20121. * @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)
  20122. */
  20123. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20124. /** @hidden */
  20125. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  20126. }
  20127. /**
  20128. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  20129. */
  20130. export class PassCubePostProcess extends PostProcess {
  20131. private _face;
  20132. /**
  20133. * Gets or sets the cube face to display.
  20134. * * 0 is +X
  20135. * * 1 is -X
  20136. * * 2 is +Y
  20137. * * 3 is -Y
  20138. * * 4 is +Z
  20139. * * 5 is -Z
  20140. */
  20141. get face(): number;
  20142. set face(value: number);
  20143. /**
  20144. * Gets a string identifying the name of the class
  20145. * @returns "PassCubePostProcess" string
  20146. */
  20147. getClassName(): string;
  20148. /**
  20149. * Creates the PassCubePostProcess
  20150. * @param name The name of the effect.
  20151. * @param options The required width/height ratio to downsize to before computing the render pass.
  20152. * @param camera The camera to apply the render pass to.
  20153. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20154. * @param engine The engine which the post process will be applied. (default: current engine)
  20155. * @param reusable If the post process can be reused on the same frame. (default: false)
  20156. * @param textureType The type of texture to be used when performing the post processing.
  20157. * @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)
  20158. */
  20159. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20160. /** @hidden */
  20161. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  20162. }
  20163. }
  20164. declare module BABYLON {
  20165. /**
  20166. * Class used to host texture specific utilities
  20167. */
  20168. export class TextureTools {
  20169. /**
  20170. * Uses the GPU to create a copy texture rescaled at a given size
  20171. * @param texture Texture to copy from
  20172. * @param width defines the desired width
  20173. * @param height defines the desired height
  20174. * @param useBilinearMode defines if bilinear mode has to be used
  20175. * @return the generated texture
  20176. */
  20177. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  20178. /**
  20179. * Apply a post process to a texture
  20180. * @param postProcessName name of the fragment post process
  20181. * @param internalTexture the texture to encode
  20182. * @param scene the scene hosting the texture
  20183. * @param type type of the output texture. If not provided, use the one from internalTexture
  20184. * @param samplingMode sampling mode to use to sample the source texture. If not provided, use the one from internalTexture
  20185. * @param format format of the output texture. If not provided, use the one from internalTexture
  20186. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20187. */
  20188. static ApplyPostProcess(postProcessName: string, internalTexture: InternalTexture, scene: Scene, type?: number, samplingMode?: number, format?: number): Promise<InternalTexture>;
  20189. }
  20190. }
  20191. declare module BABYLON {
  20192. /**
  20193. * Class used to host RGBD texture specific utilities
  20194. */
  20195. export class RGBDTextureTools {
  20196. /**
  20197. * Expand the RGBD Texture from RGBD to Half Float if possible.
  20198. * @param texture the texture to expand.
  20199. */
  20200. static ExpandRGBDTexture(texture: Texture): void;
  20201. /**
  20202. * Encode the texture to RGBD if possible.
  20203. * @param internalTexture the texture to encode
  20204. * @param scene the scene hosting the texture
  20205. * @param outputTextureType type of the texture in which the encoding is performed
  20206. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20207. */
  20208. static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType?: number): Promise<InternalTexture>;
  20209. }
  20210. }
  20211. declare module BABYLON {
  20212. /**
  20213. * Class used to host texture specific utilities
  20214. */
  20215. export class BRDFTextureTools {
  20216. /**
  20217. * Prevents texture cache collision
  20218. */
  20219. private static _instanceNumber;
  20220. /**
  20221. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  20222. * @param scene defines the hosting scene
  20223. * @returns the environment BRDF texture
  20224. */
  20225. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  20226. private static _environmentBRDFBase64Texture;
  20227. }
  20228. }
  20229. declare module BABYLON {
  20230. /**
  20231. * @hidden
  20232. */
  20233. export interface IMaterialClearCoatDefines {
  20234. CLEARCOAT: boolean;
  20235. CLEARCOAT_DEFAULTIOR: boolean;
  20236. CLEARCOAT_TEXTURE: boolean;
  20237. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  20238. CLEARCOAT_TEXTUREDIRECTUV: number;
  20239. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  20240. CLEARCOAT_BUMP: boolean;
  20241. CLEARCOAT_BUMPDIRECTUV: number;
  20242. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20243. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20244. CLEARCOAT_REMAP_F0: boolean;
  20245. CLEARCOAT_TINT: boolean;
  20246. CLEARCOAT_TINT_TEXTURE: boolean;
  20247. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  20248. /** @hidden */
  20249. _areTexturesDirty: boolean;
  20250. }
  20251. /**
  20252. * Define the code related to the clear coat parameters of the pbr material.
  20253. */
  20254. export class PBRClearCoatConfiguration {
  20255. /**
  20256. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20257. * The default fits with a polyurethane material.
  20258. * @hidden
  20259. */
  20260. static readonly _DefaultIndexOfRefraction: number;
  20261. private _isEnabled;
  20262. /**
  20263. * Defines if the clear coat is enabled in the material.
  20264. */
  20265. isEnabled: boolean;
  20266. /**
  20267. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  20268. */
  20269. intensity: number;
  20270. /**
  20271. * Defines the clear coat layer roughness.
  20272. */
  20273. roughness: number;
  20274. private _indexOfRefraction;
  20275. /**
  20276. * Defines the index of refraction of the clear coat.
  20277. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20278. * The default fits with a polyurethane material.
  20279. * Changing the default value is more performance intensive.
  20280. */
  20281. indexOfRefraction: number;
  20282. private _texture;
  20283. /**
  20284. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  20285. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  20286. * if textureRoughness is not empty, else no texture roughness is used
  20287. */
  20288. texture: Nullable<BaseTexture>;
  20289. private _useRoughnessFromMainTexture;
  20290. /**
  20291. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  20292. * If false, the green channel from textureRoughness is used for roughness
  20293. */
  20294. useRoughnessFromMainTexture: boolean;
  20295. private _textureRoughness;
  20296. /**
  20297. * Stores the clear coat roughness in a texture (green channel)
  20298. * Not used if useRoughnessFromMainTexture is true
  20299. */
  20300. textureRoughness: Nullable<BaseTexture>;
  20301. private _remapF0OnInterfaceChange;
  20302. /**
  20303. * Defines if the F0 value should be remapped to account for the interface change in the material.
  20304. */
  20305. remapF0OnInterfaceChange: boolean;
  20306. private _bumpTexture;
  20307. /**
  20308. * Define the clear coat specific bump texture.
  20309. */
  20310. bumpTexture: Nullable<BaseTexture>;
  20311. private _isTintEnabled;
  20312. /**
  20313. * Defines if the clear coat tint is enabled in the material.
  20314. */
  20315. isTintEnabled: boolean;
  20316. /**
  20317. * Defines the clear coat tint of the material.
  20318. * This is only use if tint is enabled
  20319. */
  20320. tintColor: Color3;
  20321. /**
  20322. * Defines the distance at which the tint color should be found in the
  20323. * clear coat media.
  20324. * This is only use if tint is enabled
  20325. */
  20326. tintColorAtDistance: number;
  20327. /**
  20328. * Defines the clear coat layer thickness.
  20329. * This is only use if tint is enabled
  20330. */
  20331. tintThickness: number;
  20332. private _tintTexture;
  20333. /**
  20334. * Stores the clear tint values in a texture.
  20335. * rgb is tint
  20336. * a is a thickness factor
  20337. */
  20338. tintTexture: Nullable<BaseTexture>;
  20339. /** @hidden */
  20340. private _internalMarkAllSubMeshesAsTexturesDirty;
  20341. /** @hidden */
  20342. _markAllSubMeshesAsTexturesDirty(): void;
  20343. /**
  20344. * Instantiate a new instance of clear coat configuration.
  20345. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20346. */
  20347. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20348. /**
  20349. * Gets whether the submesh is ready to be used or not.
  20350. * @param defines the list of "defines" to update.
  20351. * @param scene defines the scene the material belongs to.
  20352. * @param engine defines the engine the material belongs to.
  20353. * @param disableBumpMap defines whether the material disables bump or not.
  20354. * @returns - boolean indicating that the submesh is ready or not.
  20355. */
  20356. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  20357. /**
  20358. * Checks to see if a texture is used in the material.
  20359. * @param defines the list of "defines" to update.
  20360. * @param scene defines the scene to the material belongs to.
  20361. */
  20362. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  20363. /**
  20364. * Binds the material data.
  20365. * @param uniformBuffer defines the Uniform buffer to fill in.
  20366. * @param scene defines the scene the material belongs to.
  20367. * @param engine defines the engine the material belongs to.
  20368. * @param disableBumpMap defines whether the material disables bump or not.
  20369. * @param isFrozen defines whether the material is frozen or not.
  20370. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  20371. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  20372. * @param subMesh the submesh to bind data for
  20373. */
  20374. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  20375. /**
  20376. * Checks to see if a texture is used in the material.
  20377. * @param texture - Base texture to use.
  20378. * @returns - Boolean specifying if a texture is used in the material.
  20379. */
  20380. hasTexture(texture: BaseTexture): boolean;
  20381. /**
  20382. * Returns an array of the actively used textures.
  20383. * @param activeTextures Array of BaseTextures
  20384. */
  20385. getActiveTextures(activeTextures: BaseTexture[]): void;
  20386. /**
  20387. * Returns the animatable textures.
  20388. * @param animatables Array of animatable textures.
  20389. */
  20390. getAnimatables(animatables: IAnimatable[]): void;
  20391. /**
  20392. * Disposes the resources of the material.
  20393. * @param forceDisposeTextures - Forces the disposal of all textures.
  20394. */
  20395. dispose(forceDisposeTextures?: boolean): void;
  20396. /**
  20397. * Get the current class name of the texture useful for serialization or dynamic coding.
  20398. * @returns "PBRClearCoatConfiguration"
  20399. */
  20400. getClassName(): string;
  20401. /**
  20402. * Add fallbacks to the effect fallbacks list.
  20403. * @param defines defines the Base texture to use.
  20404. * @param fallbacks defines the current fallback list.
  20405. * @param currentRank defines the current fallback rank.
  20406. * @returns the new fallback rank.
  20407. */
  20408. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20409. /**
  20410. * Add the required uniforms to the current list.
  20411. * @param uniforms defines the current uniform list.
  20412. */
  20413. static AddUniforms(uniforms: string[]): void;
  20414. /**
  20415. * Add the required samplers to the current list.
  20416. * @param samplers defines the current sampler list.
  20417. */
  20418. static AddSamplers(samplers: string[]): void;
  20419. /**
  20420. * Add the required uniforms to the current buffer.
  20421. * @param uniformBuffer defines the current uniform buffer.
  20422. */
  20423. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20424. /**
  20425. * Makes a duplicate of the current configuration into another one.
  20426. * @param clearCoatConfiguration define the config where to copy the info
  20427. */
  20428. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  20429. /**
  20430. * Serializes this clear coat configuration.
  20431. * @returns - An object with the serialized config.
  20432. */
  20433. serialize(): any;
  20434. /**
  20435. * Parses a anisotropy Configuration from a serialized object.
  20436. * @param source - Serialized object.
  20437. * @param scene Defines the scene we are parsing for
  20438. * @param rootUrl Defines the rootUrl to load from
  20439. */
  20440. parse(source: any, scene: Scene, rootUrl: string): void;
  20441. }
  20442. }
  20443. declare module BABYLON {
  20444. /**
  20445. * @hidden
  20446. */
  20447. export interface IMaterialAnisotropicDefines {
  20448. ANISOTROPIC: boolean;
  20449. ANISOTROPIC_TEXTURE: boolean;
  20450. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20451. MAINUV1: boolean;
  20452. _areTexturesDirty: boolean;
  20453. _needUVs: boolean;
  20454. }
  20455. /**
  20456. * Define the code related to the anisotropic parameters of the pbr material.
  20457. */
  20458. export class PBRAnisotropicConfiguration {
  20459. private _isEnabled;
  20460. /**
  20461. * Defines if the anisotropy is enabled in the material.
  20462. */
  20463. isEnabled: boolean;
  20464. /**
  20465. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  20466. */
  20467. intensity: number;
  20468. /**
  20469. * Defines if the effect is along the tangents, bitangents or in between.
  20470. * By default, the effect is "stretching" the highlights along the tangents.
  20471. */
  20472. direction: Vector2;
  20473. private _texture;
  20474. /**
  20475. * Stores the anisotropy values in a texture.
  20476. * rg is direction (like normal from -1 to 1)
  20477. * b is a intensity
  20478. */
  20479. texture: Nullable<BaseTexture>;
  20480. /** @hidden */
  20481. private _internalMarkAllSubMeshesAsTexturesDirty;
  20482. /** @hidden */
  20483. _markAllSubMeshesAsTexturesDirty(): void;
  20484. /**
  20485. * Instantiate a new instance of anisotropy configuration.
  20486. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20487. */
  20488. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20489. /**
  20490. * Specifies that the submesh is ready to be used.
  20491. * @param defines the list of "defines" to update.
  20492. * @param scene defines the scene the material belongs to.
  20493. * @returns - boolean indicating that the submesh is ready or not.
  20494. */
  20495. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  20496. /**
  20497. * Checks to see if a texture is used in the material.
  20498. * @param defines the list of "defines" to update.
  20499. * @param mesh the mesh we are preparing the defines for.
  20500. * @param scene defines the scene the material belongs to.
  20501. */
  20502. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  20503. /**
  20504. * Binds the material data.
  20505. * @param uniformBuffer defines the Uniform buffer to fill in.
  20506. * @param scene defines the scene the material belongs to.
  20507. * @param isFrozen defines whether the material is frozen or not.
  20508. */
  20509. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  20510. /**
  20511. * Checks to see if a texture is used in the material.
  20512. * @param texture - Base texture to use.
  20513. * @returns - Boolean specifying if a texture is used in the material.
  20514. */
  20515. hasTexture(texture: BaseTexture): boolean;
  20516. /**
  20517. * Returns an array of the actively used textures.
  20518. * @param activeTextures Array of BaseTextures
  20519. */
  20520. getActiveTextures(activeTextures: BaseTexture[]): void;
  20521. /**
  20522. * Returns the animatable textures.
  20523. * @param animatables Array of animatable textures.
  20524. */
  20525. getAnimatables(animatables: IAnimatable[]): void;
  20526. /**
  20527. * Disposes the resources of the material.
  20528. * @param forceDisposeTextures - Forces the disposal of all textures.
  20529. */
  20530. dispose(forceDisposeTextures?: boolean): void;
  20531. /**
  20532. * Get the current class name of the texture useful for serialization or dynamic coding.
  20533. * @returns "PBRAnisotropicConfiguration"
  20534. */
  20535. getClassName(): string;
  20536. /**
  20537. * Add fallbacks to the effect fallbacks list.
  20538. * @param defines defines the Base texture to use.
  20539. * @param fallbacks defines the current fallback list.
  20540. * @param currentRank defines the current fallback rank.
  20541. * @returns the new fallback rank.
  20542. */
  20543. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20544. /**
  20545. * Add the required uniforms to the current list.
  20546. * @param uniforms defines the current uniform list.
  20547. */
  20548. static AddUniforms(uniforms: string[]): void;
  20549. /**
  20550. * Add the required uniforms to the current buffer.
  20551. * @param uniformBuffer defines the current uniform buffer.
  20552. */
  20553. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20554. /**
  20555. * Add the required samplers to the current list.
  20556. * @param samplers defines the current sampler list.
  20557. */
  20558. static AddSamplers(samplers: string[]): void;
  20559. /**
  20560. * Makes a duplicate of the current configuration into another one.
  20561. * @param anisotropicConfiguration define the config where to copy the info
  20562. */
  20563. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  20564. /**
  20565. * Serializes this anisotropy configuration.
  20566. * @returns - An object with the serialized config.
  20567. */
  20568. serialize(): any;
  20569. /**
  20570. * Parses a anisotropy Configuration from a serialized object.
  20571. * @param source - Serialized object.
  20572. * @param scene Defines the scene we are parsing for
  20573. * @param rootUrl Defines the rootUrl to load from
  20574. */
  20575. parse(source: any, scene: Scene, rootUrl: string): void;
  20576. }
  20577. }
  20578. declare module BABYLON {
  20579. /**
  20580. * @hidden
  20581. */
  20582. export interface IMaterialBRDFDefines {
  20583. BRDF_V_HEIGHT_CORRELATED: boolean;
  20584. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20585. SPHERICAL_HARMONICS: boolean;
  20586. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20587. /** @hidden */
  20588. _areMiscDirty: boolean;
  20589. }
  20590. /**
  20591. * Define the code related to the BRDF parameters of the pbr material.
  20592. */
  20593. export class PBRBRDFConfiguration {
  20594. /**
  20595. * Default value used for the energy conservation.
  20596. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20597. */
  20598. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  20599. /**
  20600. * Default value used for the Smith Visibility Height Correlated mode.
  20601. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20602. */
  20603. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  20604. /**
  20605. * Default value used for the IBL diffuse part.
  20606. * This can help switching back to the polynomials mode globally which is a tiny bit
  20607. * less GPU intensive at the drawback of a lower quality.
  20608. */
  20609. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  20610. /**
  20611. * Default value used for activating energy conservation for the specular workflow.
  20612. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20613. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20614. */
  20615. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  20616. private _useEnergyConservation;
  20617. /**
  20618. * Defines if the material uses energy conservation.
  20619. */
  20620. useEnergyConservation: boolean;
  20621. private _useSmithVisibilityHeightCorrelated;
  20622. /**
  20623. * LEGACY Mode set to false
  20624. * Defines if the material uses height smith correlated visibility term.
  20625. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  20626. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  20627. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  20628. * Not relying on height correlated will also disable energy conservation.
  20629. */
  20630. useSmithVisibilityHeightCorrelated: boolean;
  20631. private _useSphericalHarmonics;
  20632. /**
  20633. * LEGACY Mode set to false
  20634. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  20635. * diffuse part of the IBL.
  20636. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  20637. * to the ground truth.
  20638. */
  20639. useSphericalHarmonics: boolean;
  20640. private _useSpecularGlossinessInputEnergyConservation;
  20641. /**
  20642. * Defines if the material uses energy conservation, when the specular workflow is active.
  20643. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20644. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20645. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  20646. */
  20647. useSpecularGlossinessInputEnergyConservation: boolean;
  20648. /** @hidden */
  20649. private _internalMarkAllSubMeshesAsMiscDirty;
  20650. /** @hidden */
  20651. _markAllSubMeshesAsMiscDirty(): void;
  20652. /**
  20653. * Instantiate a new instance of clear coat configuration.
  20654. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  20655. */
  20656. constructor(markAllSubMeshesAsMiscDirty: () => void);
  20657. /**
  20658. * Checks to see if a texture is used in the material.
  20659. * @param defines the list of "defines" to update.
  20660. */
  20661. prepareDefines(defines: IMaterialBRDFDefines): void;
  20662. /**
  20663. * Get the current class name of the texture useful for serialization or dynamic coding.
  20664. * @returns "PBRClearCoatConfiguration"
  20665. */
  20666. getClassName(): string;
  20667. /**
  20668. * Makes a duplicate of the current configuration into another one.
  20669. * @param brdfConfiguration define the config where to copy the info
  20670. */
  20671. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  20672. /**
  20673. * Serializes this BRDF configuration.
  20674. * @returns - An object with the serialized config.
  20675. */
  20676. serialize(): any;
  20677. /**
  20678. * Parses a anisotropy Configuration from a serialized object.
  20679. * @param source - Serialized object.
  20680. * @param scene Defines the scene we are parsing for
  20681. * @param rootUrl Defines the rootUrl to load from
  20682. */
  20683. parse(source: any, scene: Scene, rootUrl: string): void;
  20684. }
  20685. }
  20686. declare module BABYLON {
  20687. /**
  20688. * @hidden
  20689. */
  20690. export interface IMaterialSheenDefines {
  20691. SHEEN: boolean;
  20692. SHEEN_TEXTURE: boolean;
  20693. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20694. SHEEN_TEXTUREDIRECTUV: number;
  20695. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20696. SHEEN_LINKWITHALBEDO: boolean;
  20697. SHEEN_ROUGHNESS: boolean;
  20698. SHEEN_ALBEDOSCALING: boolean;
  20699. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20700. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20701. /** @hidden */
  20702. _areTexturesDirty: boolean;
  20703. }
  20704. /**
  20705. * Define the code related to the Sheen parameters of the pbr material.
  20706. */
  20707. export class PBRSheenConfiguration {
  20708. private _isEnabled;
  20709. /**
  20710. * Defines if the material uses sheen.
  20711. */
  20712. isEnabled: boolean;
  20713. private _linkSheenWithAlbedo;
  20714. /**
  20715. * Defines if the sheen is linked to the sheen color.
  20716. */
  20717. linkSheenWithAlbedo: boolean;
  20718. /**
  20719. * Defines the sheen intensity.
  20720. */
  20721. intensity: number;
  20722. /**
  20723. * Defines the sheen color.
  20724. */
  20725. color: Color3;
  20726. private _texture;
  20727. /**
  20728. * Stores the sheen tint values in a texture.
  20729. * rgb is tint
  20730. * 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)
  20731. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  20732. */
  20733. texture: Nullable<BaseTexture>;
  20734. private _useRoughnessFromMainTexture;
  20735. /**
  20736. * Indicates that the alpha channel of the texture property will be used for roughness.
  20737. * Has no effect if the roughness (and texture!) property is not defined
  20738. */
  20739. useRoughnessFromMainTexture: boolean;
  20740. private _roughness;
  20741. /**
  20742. * Defines the sheen roughness.
  20743. * It is not taken into account if linkSheenWithAlbedo is true.
  20744. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  20745. */
  20746. roughness: Nullable<number>;
  20747. private _textureRoughness;
  20748. /**
  20749. * Stores the sheen roughness in a texture.
  20750. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  20751. */
  20752. textureRoughness: Nullable<BaseTexture>;
  20753. private _albedoScaling;
  20754. /**
  20755. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  20756. * It allows the strength of the sheen effect to not depend on the base color of the material,
  20757. * making it easier to setup and tweak the effect
  20758. */
  20759. albedoScaling: boolean;
  20760. /** @hidden */
  20761. private _internalMarkAllSubMeshesAsTexturesDirty;
  20762. /** @hidden */
  20763. _markAllSubMeshesAsTexturesDirty(): void;
  20764. /**
  20765. * Instantiate a new instance of clear coat configuration.
  20766. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20767. */
  20768. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20769. /**
  20770. * Specifies that the submesh is ready to be used.
  20771. * @param defines the list of "defines" to update.
  20772. * @param scene defines the scene the material belongs to.
  20773. * @returns - boolean indicating that the submesh is ready or not.
  20774. */
  20775. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  20776. /**
  20777. * Checks to see if a texture is used in the material.
  20778. * @param defines the list of "defines" to update.
  20779. * @param scene defines the scene the material belongs to.
  20780. */
  20781. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  20782. /**
  20783. * Binds the material data.
  20784. * @param uniformBuffer defines the Uniform buffer to fill in.
  20785. * @param scene defines the scene the material belongs to.
  20786. * @param isFrozen defines whether the material is frozen or not.
  20787. * @param subMesh the submesh to bind data for
  20788. */
  20789. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  20790. /**
  20791. * Checks to see if a texture is used in the material.
  20792. * @param texture - Base texture to use.
  20793. * @returns - Boolean specifying if a texture is used in the material.
  20794. */
  20795. hasTexture(texture: BaseTexture): boolean;
  20796. /**
  20797. * Returns an array of the actively used textures.
  20798. * @param activeTextures Array of BaseTextures
  20799. */
  20800. getActiveTextures(activeTextures: BaseTexture[]): void;
  20801. /**
  20802. * Returns the animatable textures.
  20803. * @param animatables Array of animatable textures.
  20804. */
  20805. getAnimatables(animatables: IAnimatable[]): void;
  20806. /**
  20807. * Disposes the resources of the material.
  20808. * @param forceDisposeTextures - Forces the disposal of all textures.
  20809. */
  20810. dispose(forceDisposeTextures?: boolean): void;
  20811. /**
  20812. * Get the current class name of the texture useful for serialization or dynamic coding.
  20813. * @returns "PBRSheenConfiguration"
  20814. */
  20815. getClassName(): string;
  20816. /**
  20817. * Add fallbacks to the effect fallbacks list.
  20818. * @param defines defines the Base texture to use.
  20819. * @param fallbacks defines the current fallback list.
  20820. * @param currentRank defines the current fallback rank.
  20821. * @returns the new fallback rank.
  20822. */
  20823. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20824. /**
  20825. * Add the required uniforms to the current list.
  20826. * @param uniforms defines the current uniform list.
  20827. */
  20828. static AddUniforms(uniforms: string[]): void;
  20829. /**
  20830. * Add the required uniforms to the current buffer.
  20831. * @param uniformBuffer defines the current uniform buffer.
  20832. */
  20833. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20834. /**
  20835. * Add the required samplers to the current list.
  20836. * @param samplers defines the current sampler list.
  20837. */
  20838. static AddSamplers(samplers: string[]): void;
  20839. /**
  20840. * Makes a duplicate of the current configuration into another one.
  20841. * @param sheenConfiguration define the config where to copy the info
  20842. */
  20843. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  20844. /**
  20845. * Serializes this BRDF configuration.
  20846. * @returns - An object with the serialized config.
  20847. */
  20848. serialize(): any;
  20849. /**
  20850. * Parses a anisotropy Configuration from a serialized object.
  20851. * @param source - Serialized object.
  20852. * @param scene Defines the scene we are parsing for
  20853. * @param rootUrl Defines the rootUrl to load from
  20854. */
  20855. parse(source: any, scene: Scene, rootUrl: string): void;
  20856. }
  20857. }
  20858. declare module BABYLON {
  20859. /**
  20860. * @hidden
  20861. */
  20862. export interface IMaterialSubSurfaceDefines {
  20863. SUBSURFACE: boolean;
  20864. SS_REFRACTION: boolean;
  20865. SS_TRANSLUCENCY: boolean;
  20866. SS_SCATTERING: boolean;
  20867. SS_THICKNESSANDMASK_TEXTURE: boolean;
  20868. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  20869. SS_REFRACTIONMAP_3D: boolean;
  20870. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  20871. SS_LODINREFRACTIONALPHA: boolean;
  20872. SS_GAMMAREFRACTION: boolean;
  20873. SS_RGBDREFRACTION: boolean;
  20874. SS_LINEARSPECULARREFRACTION: boolean;
  20875. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  20876. SS_ALBEDOFORREFRACTIONTINT: boolean;
  20877. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  20878. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  20879. /** @hidden */
  20880. _areTexturesDirty: boolean;
  20881. }
  20882. /**
  20883. * Define the code related to the sub surface parameters of the pbr material.
  20884. */
  20885. export class PBRSubSurfaceConfiguration {
  20886. private _isRefractionEnabled;
  20887. /**
  20888. * Defines if the refraction is enabled in the material.
  20889. */
  20890. isRefractionEnabled: boolean;
  20891. private _isTranslucencyEnabled;
  20892. /**
  20893. * Defines if the translucency is enabled in the material.
  20894. */
  20895. isTranslucencyEnabled: boolean;
  20896. private _isScatteringEnabled;
  20897. /**
  20898. * Defines if the sub surface scattering is enabled in the material.
  20899. */
  20900. isScatteringEnabled: boolean;
  20901. private _scatteringDiffusionProfileIndex;
  20902. /**
  20903. * Diffusion profile for subsurface scattering.
  20904. * Useful for better scattering in the skins or foliages.
  20905. */
  20906. get scatteringDiffusionProfile(): Nullable<Color3>;
  20907. set scatteringDiffusionProfile(c: Nullable<Color3>);
  20908. /**
  20909. * Defines the refraction intensity of the material.
  20910. * The refraction when enabled replaces the Diffuse part of the material.
  20911. * The intensity helps transitioning between diffuse and refraction.
  20912. */
  20913. refractionIntensity: number;
  20914. /**
  20915. * Defines the translucency intensity of the material.
  20916. * When translucency has been enabled, this defines how much of the "translucency"
  20917. * is added to the diffuse part of the material.
  20918. */
  20919. translucencyIntensity: number;
  20920. /**
  20921. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  20922. */
  20923. useAlbedoToTintRefraction: boolean;
  20924. private _thicknessTexture;
  20925. /**
  20926. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  20927. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  20928. * 0 would mean minimumThickness
  20929. * 1 would mean maximumThickness
  20930. * The other channels might be use as a mask to vary the different effects intensity.
  20931. */
  20932. thicknessTexture: Nullable<BaseTexture>;
  20933. private _refractionTexture;
  20934. /**
  20935. * Defines the texture to use for refraction.
  20936. */
  20937. refractionTexture: Nullable<BaseTexture>;
  20938. private _indexOfRefraction;
  20939. /**
  20940. * Index of refraction of the material base layer.
  20941. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20942. *
  20943. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  20944. *
  20945. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  20946. */
  20947. indexOfRefraction: number;
  20948. private _volumeIndexOfRefraction;
  20949. /**
  20950. * Index of refraction of the material's volume.
  20951. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20952. *
  20953. * This ONLY impacts refraction. If not provided or given a non-valid value,
  20954. * the volume will use the same IOR as the surface.
  20955. */
  20956. get volumeIndexOfRefraction(): number;
  20957. set volumeIndexOfRefraction(value: number);
  20958. private _invertRefractionY;
  20959. /**
  20960. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20961. */
  20962. invertRefractionY: boolean;
  20963. private _linkRefractionWithTransparency;
  20964. /**
  20965. * This parameters will make the material used its opacity to control how much it is refracting against not.
  20966. * Materials half opaque for instance using refraction could benefit from this control.
  20967. */
  20968. linkRefractionWithTransparency: boolean;
  20969. /**
  20970. * Defines the minimum thickness stored in the thickness map.
  20971. * If no thickness map is defined, this value will be used to simulate thickness.
  20972. */
  20973. minimumThickness: number;
  20974. /**
  20975. * Defines the maximum thickness stored in the thickness map.
  20976. */
  20977. maximumThickness: number;
  20978. /**
  20979. * Defines the volume tint of the material.
  20980. * This is used for both translucency and scattering.
  20981. */
  20982. tintColor: Color3;
  20983. /**
  20984. * Defines the distance at which the tint color should be found in the media.
  20985. * This is used for refraction only.
  20986. */
  20987. tintColorAtDistance: number;
  20988. /**
  20989. * Defines how far each channel transmit through the media.
  20990. * It is defined as a color to simplify it selection.
  20991. */
  20992. diffusionDistance: Color3;
  20993. private _useMaskFromThicknessTexture;
  20994. /**
  20995. * Stores the intensity of the different subsurface effects in the thickness texture.
  20996. * * the green channel is the translucency intensity.
  20997. * * the blue channel is the scattering intensity.
  20998. * * the alpha channel is the refraction intensity.
  20999. */
  21000. useMaskFromThicknessTexture: boolean;
  21001. private _scene;
  21002. private _useMaskFromThicknessTextureGltf;
  21003. /**
  21004. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  21005. * matches the channel-packing that is used by glTF.
  21006. * * the red channel is the transmission/translucency intensity.
  21007. * * the green channel is the thickness.
  21008. */
  21009. useMaskFromThicknessTextureGltf: boolean;
  21010. /** @hidden */
  21011. private _internalMarkAllSubMeshesAsTexturesDirty;
  21012. private _internalMarkScenePrePassDirty;
  21013. /** @hidden */
  21014. _markAllSubMeshesAsTexturesDirty(): void;
  21015. /** @hidden */
  21016. _markScenePrePassDirty(): void;
  21017. /**
  21018. * Instantiate a new instance of sub surface configuration.
  21019. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  21020. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  21021. * @param scene The scene
  21022. */
  21023. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  21024. /**
  21025. * Gets whether the submesh is ready to be used or not.
  21026. * @param defines the list of "defines" to update.
  21027. * @param scene defines the scene the material belongs to.
  21028. * @returns - boolean indicating that the submesh is ready or not.
  21029. */
  21030. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  21031. /**
  21032. * Checks to see if a texture is used in the material.
  21033. * @param defines the list of "defines" to update.
  21034. * @param scene defines the scene to the material belongs to.
  21035. */
  21036. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  21037. /**
  21038. * Binds the material data.
  21039. * @param uniformBuffer defines the Uniform buffer to fill in.
  21040. * @param scene defines the scene the material belongs to.
  21041. * @param engine defines the engine the material belongs to.
  21042. * @param isFrozen defines whether the material is frozen or not.
  21043. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  21044. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  21045. */
  21046. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  21047. /**
  21048. * Unbinds the material from the mesh.
  21049. * @param activeEffect defines the effect that should be unbound from.
  21050. * @returns true if unbound, otherwise false
  21051. */
  21052. unbind(activeEffect: Effect): boolean;
  21053. /**
  21054. * Returns the texture used for refraction or null if none is used.
  21055. * @param scene defines the scene the material belongs to.
  21056. * @returns - Refraction texture if present. If no refraction texture and refraction
  21057. * is linked with transparency, returns environment texture. Otherwise, returns null.
  21058. */
  21059. private _getRefractionTexture;
  21060. /**
  21061. * Returns true if alpha blending should be disabled.
  21062. */
  21063. get disableAlphaBlending(): boolean;
  21064. /**
  21065. * Fills the list of render target textures.
  21066. * @param renderTargets the list of render targets to update
  21067. */
  21068. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  21069. /**
  21070. * Checks to see if a texture is used in the material.
  21071. * @param texture - Base texture to use.
  21072. * @returns - Boolean specifying if a texture is used in the material.
  21073. */
  21074. hasTexture(texture: BaseTexture): boolean;
  21075. /**
  21076. * Gets a boolean indicating that current material needs to register RTT
  21077. * @returns true if this uses a render target otherwise false.
  21078. */
  21079. hasRenderTargetTextures(): boolean;
  21080. /**
  21081. * Returns an array of the actively used textures.
  21082. * @param activeTextures Array of BaseTextures
  21083. */
  21084. getActiveTextures(activeTextures: BaseTexture[]): void;
  21085. /**
  21086. * Returns the animatable textures.
  21087. * @param animatables Array of animatable textures.
  21088. */
  21089. getAnimatables(animatables: IAnimatable[]): void;
  21090. /**
  21091. * Disposes the resources of the material.
  21092. * @param forceDisposeTextures - Forces the disposal of all textures.
  21093. */
  21094. dispose(forceDisposeTextures?: boolean): void;
  21095. /**
  21096. * Get the current class name of the texture useful for serialization or dynamic coding.
  21097. * @returns "PBRSubSurfaceConfiguration"
  21098. */
  21099. getClassName(): string;
  21100. /**
  21101. * Add fallbacks to the effect fallbacks list.
  21102. * @param defines defines the Base texture to use.
  21103. * @param fallbacks defines the current fallback list.
  21104. * @param currentRank defines the current fallback rank.
  21105. * @returns the new fallback rank.
  21106. */
  21107. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  21108. /**
  21109. * Add the required uniforms to the current list.
  21110. * @param uniforms defines the current uniform list.
  21111. */
  21112. static AddUniforms(uniforms: string[]): void;
  21113. /**
  21114. * Add the required samplers to the current list.
  21115. * @param samplers defines the current sampler list.
  21116. */
  21117. static AddSamplers(samplers: string[]): void;
  21118. /**
  21119. * Add the required uniforms to the current buffer.
  21120. * @param uniformBuffer defines the current uniform buffer.
  21121. */
  21122. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  21123. /**
  21124. * Makes a duplicate of the current configuration into another one.
  21125. * @param configuration define the config where to copy the info
  21126. */
  21127. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  21128. /**
  21129. * Serializes this Sub Surface configuration.
  21130. * @returns - An object with the serialized config.
  21131. */
  21132. serialize(): any;
  21133. /**
  21134. * Parses a anisotropy Configuration from a serialized object.
  21135. * @param source - Serialized object.
  21136. * @param scene Defines the scene we are parsing for
  21137. * @param rootUrl Defines the rootUrl to load from
  21138. */
  21139. parse(source: any, scene: Scene, rootUrl: string): void;
  21140. }
  21141. }
  21142. declare module BABYLON {
  21143. /**
  21144. * Class representing spherical harmonics coefficients to the 3rd degree
  21145. */
  21146. export class SphericalHarmonics {
  21147. /**
  21148. * Defines whether or not the harmonics have been prescaled for rendering.
  21149. */
  21150. preScaled: boolean;
  21151. /**
  21152. * The l0,0 coefficients of the spherical harmonics
  21153. */
  21154. l00: Vector3;
  21155. /**
  21156. * The l1,-1 coefficients of the spherical harmonics
  21157. */
  21158. l1_1: Vector3;
  21159. /**
  21160. * The l1,0 coefficients of the spherical harmonics
  21161. */
  21162. l10: Vector3;
  21163. /**
  21164. * The l1,1 coefficients of the spherical harmonics
  21165. */
  21166. l11: Vector3;
  21167. /**
  21168. * The l2,-2 coefficients of the spherical harmonics
  21169. */
  21170. l2_2: Vector3;
  21171. /**
  21172. * The l2,-1 coefficients of the spherical harmonics
  21173. */
  21174. l2_1: Vector3;
  21175. /**
  21176. * The l2,0 coefficients of the spherical harmonics
  21177. */
  21178. l20: Vector3;
  21179. /**
  21180. * The l2,1 coefficients of the spherical harmonics
  21181. */
  21182. l21: Vector3;
  21183. /**
  21184. * The l2,2 coefficients of the spherical harmonics
  21185. */
  21186. l22: Vector3;
  21187. /**
  21188. * Adds a light to the spherical harmonics
  21189. * @param direction the direction of the light
  21190. * @param color the color of the light
  21191. * @param deltaSolidAngle the delta solid angle of the light
  21192. */
  21193. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  21194. /**
  21195. * Scales the spherical harmonics by the given amount
  21196. * @param scale the amount to scale
  21197. */
  21198. scaleInPlace(scale: number): void;
  21199. /**
  21200. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  21201. *
  21202. * ```
  21203. * E_lm = A_l * L_lm
  21204. * ```
  21205. *
  21206. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  21207. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  21208. * the scaling factors are given in equation 9.
  21209. */
  21210. convertIncidentRadianceToIrradiance(): void;
  21211. /**
  21212. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  21213. *
  21214. * ```
  21215. * L = (1/pi) * E * rho
  21216. * ```
  21217. *
  21218. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  21219. */
  21220. convertIrradianceToLambertianRadiance(): void;
  21221. /**
  21222. * Integrates the reconstruction coefficients directly in to the SH preventing further
  21223. * required operations at run time.
  21224. *
  21225. * This is simply done by scaling back the SH with Ylm constants parameter.
  21226. * The trigonometric part being applied by the shader at run time.
  21227. */
  21228. preScaleForRendering(): void;
  21229. /**
  21230. * Constructs a spherical harmonics from an array.
  21231. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  21232. * @returns the spherical harmonics
  21233. */
  21234. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  21235. /**
  21236. * Gets the spherical harmonics from polynomial
  21237. * @param polynomial the spherical polynomial
  21238. * @returns the spherical harmonics
  21239. */
  21240. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  21241. }
  21242. /**
  21243. * Class representing spherical polynomial coefficients to the 3rd degree
  21244. */
  21245. export class SphericalPolynomial {
  21246. private _harmonics;
  21247. /**
  21248. * The spherical harmonics used to create the polynomials.
  21249. */
  21250. get preScaledHarmonics(): SphericalHarmonics;
  21251. /**
  21252. * The x coefficients of the spherical polynomial
  21253. */
  21254. x: Vector3;
  21255. /**
  21256. * The y coefficients of the spherical polynomial
  21257. */
  21258. y: Vector3;
  21259. /**
  21260. * The z coefficients of the spherical polynomial
  21261. */
  21262. z: Vector3;
  21263. /**
  21264. * The xx coefficients of the spherical polynomial
  21265. */
  21266. xx: Vector3;
  21267. /**
  21268. * The yy coefficients of the spherical polynomial
  21269. */
  21270. yy: Vector3;
  21271. /**
  21272. * The zz coefficients of the spherical polynomial
  21273. */
  21274. zz: Vector3;
  21275. /**
  21276. * The xy coefficients of the spherical polynomial
  21277. */
  21278. xy: Vector3;
  21279. /**
  21280. * The yz coefficients of the spherical polynomial
  21281. */
  21282. yz: Vector3;
  21283. /**
  21284. * The zx coefficients of the spherical polynomial
  21285. */
  21286. zx: Vector3;
  21287. /**
  21288. * Adds an ambient color to the spherical polynomial
  21289. * @param color the color to add
  21290. */
  21291. addAmbient(color: Color3): void;
  21292. /**
  21293. * Scales the spherical polynomial by the given amount
  21294. * @param scale the amount to scale
  21295. */
  21296. scaleInPlace(scale: number): void;
  21297. /**
  21298. * Gets the spherical polynomial from harmonics
  21299. * @param harmonics the spherical harmonics
  21300. * @returns the spherical polynomial
  21301. */
  21302. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  21303. /**
  21304. * Constructs a spherical polynomial from an array.
  21305. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  21306. * @returns the spherical polynomial
  21307. */
  21308. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  21309. }
  21310. }
  21311. declare module BABYLON {
  21312. /**
  21313. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  21314. */
  21315. export interface CubeMapInfo {
  21316. /**
  21317. * The pixel array for the front face.
  21318. * This is stored in format, left to right, up to down format.
  21319. */
  21320. front: Nullable<ArrayBufferView>;
  21321. /**
  21322. * The pixel array for the back face.
  21323. * This is stored in format, left to right, up to down format.
  21324. */
  21325. back: Nullable<ArrayBufferView>;
  21326. /**
  21327. * The pixel array for the left face.
  21328. * This is stored in format, left to right, up to down format.
  21329. */
  21330. left: Nullable<ArrayBufferView>;
  21331. /**
  21332. * The pixel array for the right face.
  21333. * This is stored in format, left to right, up to down format.
  21334. */
  21335. right: Nullable<ArrayBufferView>;
  21336. /**
  21337. * The pixel array for the up face.
  21338. * This is stored in format, left to right, up to down format.
  21339. */
  21340. up: Nullable<ArrayBufferView>;
  21341. /**
  21342. * The pixel array for the down face.
  21343. * This is stored in format, left to right, up to down format.
  21344. */
  21345. down: Nullable<ArrayBufferView>;
  21346. /**
  21347. * The size of the cubemap stored.
  21348. *
  21349. * Each faces will be size * size pixels.
  21350. */
  21351. size: number;
  21352. /**
  21353. * The format of the texture.
  21354. *
  21355. * RGBA, RGB.
  21356. */
  21357. format: number;
  21358. /**
  21359. * The type of the texture data.
  21360. *
  21361. * UNSIGNED_INT, FLOAT.
  21362. */
  21363. type: number;
  21364. /**
  21365. * Specifies whether the texture is in gamma space.
  21366. */
  21367. gammaSpace: boolean;
  21368. }
  21369. /**
  21370. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  21371. */
  21372. export class PanoramaToCubeMapTools {
  21373. private static FACE_LEFT;
  21374. private static FACE_RIGHT;
  21375. private static FACE_FRONT;
  21376. private static FACE_BACK;
  21377. private static FACE_DOWN;
  21378. private static FACE_UP;
  21379. /**
  21380. * Converts a panorama stored in RGB right to left up to down format into a cubemap (6 faces).
  21381. *
  21382. * @param float32Array The source data.
  21383. * @param inputWidth The width of the input panorama.
  21384. * @param inputHeight The height of the input panorama.
  21385. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  21386. * @return The cubemap data
  21387. */
  21388. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  21389. private static CreateCubemapTexture;
  21390. private static CalcProjectionSpherical;
  21391. }
  21392. }
  21393. declare module BABYLON {
  21394. /**
  21395. * Helper class dealing with the extraction of spherical polynomial dataArray
  21396. * from a cube map.
  21397. */
  21398. export class CubeMapToSphericalPolynomialTools {
  21399. private static FileFaces;
  21400. /**
  21401. * Converts a texture to the according Spherical Polynomial data.
  21402. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21403. *
  21404. * @param texture The texture to extract the information from.
  21405. * @return The Spherical Polynomial data.
  21406. */
  21407. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<Promise<SphericalPolynomial>>;
  21408. /**
  21409. * Converts a cubemap to the according Spherical Polynomial data.
  21410. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21411. *
  21412. * @param cubeInfo The Cube map to extract the information from.
  21413. * @return The Spherical Polynomial data.
  21414. */
  21415. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  21416. }
  21417. }
  21418. declare module BABYLON {
  21419. interface BaseTexture {
  21420. /**
  21421. * Get the polynomial representation of the texture data.
  21422. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  21423. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  21424. */
  21425. sphericalPolynomial: Nullable<SphericalPolynomial>;
  21426. }
  21427. }
  21428. declare module BABYLON {
  21429. /** @hidden */
  21430. export var pbrFragmentDeclaration: {
  21431. name: string;
  21432. shader: string;
  21433. };
  21434. }
  21435. declare module BABYLON {
  21436. /** @hidden */
  21437. export var pbrUboDeclaration: {
  21438. name: string;
  21439. shader: string;
  21440. };
  21441. }
  21442. declare module BABYLON {
  21443. /** @hidden */
  21444. export var pbrFragmentExtraDeclaration: {
  21445. name: string;
  21446. shader: string;
  21447. };
  21448. }
  21449. declare module BABYLON {
  21450. /** @hidden */
  21451. export var pbrFragmentSamplersDeclaration: {
  21452. name: string;
  21453. shader: string;
  21454. };
  21455. }
  21456. declare module BABYLON {
  21457. /** @hidden */
  21458. export var subSurfaceScatteringFunctions: {
  21459. name: string;
  21460. shader: string;
  21461. };
  21462. }
  21463. declare module BABYLON {
  21464. /** @hidden */
  21465. export var importanceSampling: {
  21466. name: string;
  21467. shader: string;
  21468. };
  21469. }
  21470. declare module BABYLON {
  21471. /** @hidden */
  21472. export var pbrHelperFunctions: {
  21473. name: string;
  21474. shader: string;
  21475. };
  21476. }
  21477. declare module BABYLON {
  21478. /** @hidden */
  21479. export var harmonicsFunctions: {
  21480. name: string;
  21481. shader: string;
  21482. };
  21483. }
  21484. declare module BABYLON {
  21485. /** @hidden */
  21486. export var pbrDirectLightingSetupFunctions: {
  21487. name: string;
  21488. shader: string;
  21489. };
  21490. }
  21491. declare module BABYLON {
  21492. /** @hidden */
  21493. export var pbrDirectLightingFalloffFunctions: {
  21494. name: string;
  21495. shader: string;
  21496. };
  21497. }
  21498. declare module BABYLON {
  21499. /** @hidden */
  21500. export var pbrBRDFFunctions: {
  21501. name: string;
  21502. shader: string;
  21503. };
  21504. }
  21505. declare module BABYLON {
  21506. /** @hidden */
  21507. export var hdrFilteringFunctions: {
  21508. name: string;
  21509. shader: string;
  21510. };
  21511. }
  21512. declare module BABYLON {
  21513. /** @hidden */
  21514. export var pbrDirectLightingFunctions: {
  21515. name: string;
  21516. shader: string;
  21517. };
  21518. }
  21519. declare module BABYLON {
  21520. /** @hidden */
  21521. export var pbrIBLFunctions: {
  21522. name: string;
  21523. shader: string;
  21524. };
  21525. }
  21526. declare module BABYLON {
  21527. /** @hidden */
  21528. export var pbrBlockAlbedoOpacity: {
  21529. name: string;
  21530. shader: string;
  21531. };
  21532. }
  21533. declare module BABYLON {
  21534. /** @hidden */
  21535. export var pbrBlockReflectivity: {
  21536. name: string;
  21537. shader: string;
  21538. };
  21539. }
  21540. declare module BABYLON {
  21541. /** @hidden */
  21542. export var pbrBlockAmbientOcclusion: {
  21543. name: string;
  21544. shader: string;
  21545. };
  21546. }
  21547. declare module BABYLON {
  21548. /** @hidden */
  21549. export var pbrBlockAlphaFresnel: {
  21550. name: string;
  21551. shader: string;
  21552. };
  21553. }
  21554. declare module BABYLON {
  21555. /** @hidden */
  21556. export var pbrBlockAnisotropic: {
  21557. name: string;
  21558. shader: string;
  21559. };
  21560. }
  21561. declare module BABYLON {
  21562. /** @hidden */
  21563. export var pbrBlockReflection: {
  21564. name: string;
  21565. shader: string;
  21566. };
  21567. }
  21568. declare module BABYLON {
  21569. /** @hidden */
  21570. export var pbrBlockSheen: {
  21571. name: string;
  21572. shader: string;
  21573. };
  21574. }
  21575. declare module BABYLON {
  21576. /** @hidden */
  21577. export var pbrBlockClearcoat: {
  21578. name: string;
  21579. shader: string;
  21580. };
  21581. }
  21582. declare module BABYLON {
  21583. /** @hidden */
  21584. export var pbrBlockSubSurface: {
  21585. name: string;
  21586. shader: string;
  21587. };
  21588. }
  21589. declare module BABYLON {
  21590. /** @hidden */
  21591. export var pbrBlockNormalGeometric: {
  21592. name: string;
  21593. shader: string;
  21594. };
  21595. }
  21596. declare module BABYLON {
  21597. /** @hidden */
  21598. export var pbrBlockNormalFinal: {
  21599. name: string;
  21600. shader: string;
  21601. };
  21602. }
  21603. declare module BABYLON {
  21604. /** @hidden */
  21605. export var pbrBlockLightmapInit: {
  21606. name: string;
  21607. shader: string;
  21608. };
  21609. }
  21610. declare module BABYLON {
  21611. /** @hidden */
  21612. export var pbrBlockGeometryInfo: {
  21613. name: string;
  21614. shader: string;
  21615. };
  21616. }
  21617. declare module BABYLON {
  21618. /** @hidden */
  21619. export var pbrBlockReflectance0: {
  21620. name: string;
  21621. shader: string;
  21622. };
  21623. }
  21624. declare module BABYLON {
  21625. /** @hidden */
  21626. export var pbrBlockReflectance: {
  21627. name: string;
  21628. shader: string;
  21629. };
  21630. }
  21631. declare module BABYLON {
  21632. /** @hidden */
  21633. export var pbrBlockDirectLighting: {
  21634. name: string;
  21635. shader: string;
  21636. };
  21637. }
  21638. declare module BABYLON {
  21639. /** @hidden */
  21640. export var pbrBlockFinalLitComponents: {
  21641. name: string;
  21642. shader: string;
  21643. };
  21644. }
  21645. declare module BABYLON {
  21646. /** @hidden */
  21647. export var pbrBlockFinalUnlitComponents: {
  21648. name: string;
  21649. shader: string;
  21650. };
  21651. }
  21652. declare module BABYLON {
  21653. /** @hidden */
  21654. export var pbrBlockFinalColorComposition: {
  21655. name: string;
  21656. shader: string;
  21657. };
  21658. }
  21659. declare module BABYLON {
  21660. /** @hidden */
  21661. export var pbrBlockImageProcessing: {
  21662. name: string;
  21663. shader: string;
  21664. };
  21665. }
  21666. declare module BABYLON {
  21667. /** @hidden */
  21668. export var pbrDebug: {
  21669. name: string;
  21670. shader: string;
  21671. };
  21672. }
  21673. declare module BABYLON {
  21674. /** @hidden */
  21675. export var pbrPixelShader: {
  21676. name: string;
  21677. shader: string;
  21678. };
  21679. }
  21680. declare module BABYLON {
  21681. /** @hidden */
  21682. export var pbrVertexDeclaration: {
  21683. name: string;
  21684. shader: string;
  21685. };
  21686. }
  21687. declare module BABYLON {
  21688. /** @hidden */
  21689. export var pbrVertexShader: {
  21690. name: string;
  21691. shader: string;
  21692. };
  21693. }
  21694. declare module BABYLON {
  21695. /**
  21696. * Manages the defines for the PBR Material.
  21697. * @hidden
  21698. */
  21699. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  21700. PBR: boolean;
  21701. NUM_SAMPLES: string;
  21702. REALTIME_FILTERING: boolean;
  21703. MAINUV1: boolean;
  21704. MAINUV2: boolean;
  21705. UV1: boolean;
  21706. UV2: boolean;
  21707. ALBEDO: boolean;
  21708. GAMMAALBEDO: boolean;
  21709. ALBEDODIRECTUV: number;
  21710. VERTEXCOLOR: boolean;
  21711. DETAIL: boolean;
  21712. DETAILDIRECTUV: number;
  21713. DETAIL_NORMALBLENDMETHOD: number;
  21714. AMBIENT: boolean;
  21715. AMBIENTDIRECTUV: number;
  21716. AMBIENTINGRAYSCALE: boolean;
  21717. OPACITY: boolean;
  21718. VERTEXALPHA: boolean;
  21719. OPACITYDIRECTUV: number;
  21720. OPACITYRGB: boolean;
  21721. ALPHATEST: boolean;
  21722. DEPTHPREPASS: boolean;
  21723. ALPHABLEND: boolean;
  21724. ALPHAFROMALBEDO: boolean;
  21725. ALPHATESTVALUE: string;
  21726. SPECULAROVERALPHA: boolean;
  21727. RADIANCEOVERALPHA: boolean;
  21728. ALPHAFRESNEL: boolean;
  21729. LINEARALPHAFRESNEL: boolean;
  21730. PREMULTIPLYALPHA: boolean;
  21731. EMISSIVE: boolean;
  21732. EMISSIVEDIRECTUV: number;
  21733. REFLECTIVITY: boolean;
  21734. REFLECTIVITYDIRECTUV: number;
  21735. SPECULARTERM: boolean;
  21736. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  21737. MICROSURFACEAUTOMATIC: boolean;
  21738. LODBASEDMICROSFURACE: boolean;
  21739. MICROSURFACEMAP: boolean;
  21740. MICROSURFACEMAPDIRECTUV: number;
  21741. METALLICWORKFLOW: boolean;
  21742. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  21743. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  21744. METALLNESSSTOREINMETALMAPBLUE: boolean;
  21745. AOSTOREINMETALMAPRED: boolean;
  21746. METALLIC_REFLECTANCE: boolean;
  21747. METALLIC_REFLECTANCEDIRECTUV: number;
  21748. ENVIRONMENTBRDF: boolean;
  21749. ENVIRONMENTBRDF_RGBD: boolean;
  21750. NORMAL: boolean;
  21751. TANGENT: boolean;
  21752. BUMP: boolean;
  21753. BUMPDIRECTUV: number;
  21754. OBJECTSPACE_NORMALMAP: boolean;
  21755. PARALLAX: boolean;
  21756. PARALLAXOCCLUSION: boolean;
  21757. NORMALXYSCALE: boolean;
  21758. LIGHTMAP: boolean;
  21759. LIGHTMAPDIRECTUV: number;
  21760. USELIGHTMAPASSHADOWMAP: boolean;
  21761. GAMMALIGHTMAP: boolean;
  21762. RGBDLIGHTMAP: boolean;
  21763. REFLECTION: boolean;
  21764. REFLECTIONMAP_3D: boolean;
  21765. REFLECTIONMAP_SPHERICAL: boolean;
  21766. REFLECTIONMAP_PLANAR: boolean;
  21767. REFLECTIONMAP_CUBIC: boolean;
  21768. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  21769. REFLECTIONMAP_PROJECTION: boolean;
  21770. REFLECTIONMAP_SKYBOX: boolean;
  21771. REFLECTIONMAP_EXPLICIT: boolean;
  21772. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  21773. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  21774. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  21775. INVERTCUBICMAP: boolean;
  21776. USESPHERICALFROMREFLECTIONMAP: boolean;
  21777. USEIRRADIANCEMAP: boolean;
  21778. SPHERICAL_HARMONICS: boolean;
  21779. USESPHERICALINVERTEX: boolean;
  21780. REFLECTIONMAP_OPPOSITEZ: boolean;
  21781. LODINREFLECTIONALPHA: boolean;
  21782. GAMMAREFLECTION: boolean;
  21783. RGBDREFLECTION: boolean;
  21784. LINEARSPECULARREFLECTION: boolean;
  21785. RADIANCEOCCLUSION: boolean;
  21786. HORIZONOCCLUSION: boolean;
  21787. INSTANCES: boolean;
  21788. THIN_INSTANCES: boolean;
  21789. PREPASS: boolean;
  21790. PREPASS_IRRADIANCE: boolean;
  21791. PREPASS_IRRADIANCE_INDEX: number;
  21792. PREPASS_ALBEDO: boolean;
  21793. PREPASS_ALBEDO_INDEX: number;
  21794. PREPASS_DEPTH: boolean;
  21795. PREPASS_DEPTH_INDEX: number;
  21796. PREPASS_NORMAL: boolean;
  21797. PREPASS_NORMAL_INDEX: number;
  21798. PREPASS_POSITION: boolean;
  21799. PREPASS_POSITION_INDEX: number;
  21800. PREPASS_VELOCITY: boolean;
  21801. PREPASS_VELOCITY_INDEX: number;
  21802. PREPASS_REFLECTIVITY: boolean;
  21803. PREPASS_REFLECTIVITY_INDEX: number;
  21804. SCENE_MRT_COUNT: number;
  21805. NUM_BONE_INFLUENCERS: number;
  21806. BonesPerMesh: number;
  21807. BONETEXTURE: boolean;
  21808. BONES_VELOCITY_ENABLED: boolean;
  21809. NONUNIFORMSCALING: boolean;
  21810. MORPHTARGETS: boolean;
  21811. MORPHTARGETS_NORMAL: boolean;
  21812. MORPHTARGETS_TANGENT: boolean;
  21813. MORPHTARGETS_UV: boolean;
  21814. NUM_MORPH_INFLUENCERS: number;
  21815. MORPHTARGETS_TEXTURE: boolean;
  21816. IMAGEPROCESSING: boolean;
  21817. VIGNETTE: boolean;
  21818. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21819. VIGNETTEBLENDMODEOPAQUE: boolean;
  21820. TONEMAPPING: boolean;
  21821. TONEMAPPING_ACES: boolean;
  21822. CONTRAST: boolean;
  21823. COLORCURVES: boolean;
  21824. COLORGRADING: boolean;
  21825. COLORGRADING3D: boolean;
  21826. SAMPLER3DGREENDEPTH: boolean;
  21827. SAMPLER3DBGRMAP: boolean;
  21828. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21829. EXPOSURE: boolean;
  21830. MULTIVIEW: boolean;
  21831. USEPHYSICALLIGHTFALLOFF: boolean;
  21832. USEGLTFLIGHTFALLOFF: boolean;
  21833. TWOSIDEDLIGHTING: boolean;
  21834. SHADOWFLOAT: boolean;
  21835. CLIPPLANE: boolean;
  21836. CLIPPLANE2: boolean;
  21837. CLIPPLANE3: boolean;
  21838. CLIPPLANE4: boolean;
  21839. CLIPPLANE5: boolean;
  21840. CLIPPLANE6: boolean;
  21841. POINTSIZE: boolean;
  21842. FOG: boolean;
  21843. LOGARITHMICDEPTH: boolean;
  21844. FORCENORMALFORWARD: boolean;
  21845. SPECULARAA: boolean;
  21846. CLEARCOAT: boolean;
  21847. CLEARCOAT_DEFAULTIOR: boolean;
  21848. CLEARCOAT_TEXTURE: boolean;
  21849. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  21850. CLEARCOAT_TEXTUREDIRECTUV: number;
  21851. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  21852. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21853. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21854. CLEARCOAT_BUMP: boolean;
  21855. CLEARCOAT_BUMPDIRECTUV: number;
  21856. CLEARCOAT_REMAP_F0: boolean;
  21857. CLEARCOAT_TINT: boolean;
  21858. CLEARCOAT_TINT_TEXTURE: boolean;
  21859. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  21860. ANISOTROPIC: boolean;
  21861. ANISOTROPIC_TEXTURE: boolean;
  21862. ANISOTROPIC_TEXTUREDIRECTUV: number;
  21863. BRDF_V_HEIGHT_CORRELATED: boolean;
  21864. MS_BRDF_ENERGY_CONSERVATION: boolean;
  21865. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  21866. SHEEN: boolean;
  21867. SHEEN_TEXTURE: boolean;
  21868. SHEEN_TEXTURE_ROUGHNESS: boolean;
  21869. SHEEN_TEXTUREDIRECTUV: number;
  21870. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  21871. SHEEN_LINKWITHALBEDO: boolean;
  21872. SHEEN_ROUGHNESS: boolean;
  21873. SHEEN_ALBEDOSCALING: boolean;
  21874. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21875. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21876. SUBSURFACE: boolean;
  21877. SS_REFRACTION: boolean;
  21878. SS_TRANSLUCENCY: boolean;
  21879. SS_SCATTERING: boolean;
  21880. SS_THICKNESSANDMASK_TEXTURE: boolean;
  21881. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  21882. SS_REFRACTIONMAP_3D: boolean;
  21883. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  21884. SS_LODINREFRACTIONALPHA: boolean;
  21885. SS_GAMMAREFRACTION: boolean;
  21886. SS_RGBDREFRACTION: boolean;
  21887. SS_LINEARSPECULARREFRACTION: boolean;
  21888. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  21889. SS_ALBEDOFORREFRACTIONTINT: boolean;
  21890. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  21891. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  21892. UNLIT: boolean;
  21893. DEBUGMODE: number;
  21894. /**
  21895. * Initializes the PBR Material defines.
  21896. */
  21897. constructor();
  21898. /**
  21899. * Resets the PBR Material defines.
  21900. */
  21901. reset(): void;
  21902. }
  21903. /**
  21904. * The Physically based material base class of BJS.
  21905. *
  21906. * This offers the main features of a standard PBR material.
  21907. * For more information, please refer to the documentation :
  21908. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21909. */
  21910. export abstract class PBRBaseMaterial extends PushMaterial {
  21911. /**
  21912. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21913. */
  21914. static readonly PBRMATERIAL_OPAQUE: number;
  21915. /**
  21916. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21917. */
  21918. static readonly PBRMATERIAL_ALPHATEST: number;
  21919. /**
  21920. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21921. */
  21922. static readonly PBRMATERIAL_ALPHABLEND: number;
  21923. /**
  21924. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21925. * They are also discarded below the alpha cutoff threshold to improve performances.
  21926. */
  21927. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21928. /**
  21929. * Defines the default value of how much AO map is occluding the analytical lights
  21930. * (point spot...).
  21931. */
  21932. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21933. /**
  21934. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  21935. */
  21936. static readonly LIGHTFALLOFF_PHYSICAL: number;
  21937. /**
  21938. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  21939. * to enhance interoperability with other engines.
  21940. */
  21941. static readonly LIGHTFALLOFF_GLTF: number;
  21942. /**
  21943. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  21944. * to enhance interoperability with other materials.
  21945. */
  21946. static readonly LIGHTFALLOFF_STANDARD: number;
  21947. /**
  21948. * Intensity of the direct lights e.g. the four lights available in your scene.
  21949. * This impacts both the direct diffuse and specular highlights.
  21950. */
  21951. protected _directIntensity: number;
  21952. /**
  21953. * Intensity of the emissive part of the material.
  21954. * This helps controlling the emissive effect without modifying the emissive color.
  21955. */
  21956. protected _emissiveIntensity: number;
  21957. /**
  21958. * Intensity of the environment e.g. how much the environment will light the object
  21959. * either through harmonics for rough material or through the reflection for shiny ones.
  21960. */
  21961. protected _environmentIntensity: number;
  21962. /**
  21963. * This is a special control allowing the reduction of the specular highlights coming from the
  21964. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21965. */
  21966. protected _specularIntensity: number;
  21967. /**
  21968. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  21969. */
  21970. private _lightingInfos;
  21971. /**
  21972. * Debug Control allowing disabling the bump map on this material.
  21973. */
  21974. protected _disableBumpMap: boolean;
  21975. /**
  21976. * AKA Diffuse Texture in standard nomenclature.
  21977. */
  21978. protected _albedoTexture: Nullable<BaseTexture>;
  21979. /**
  21980. * AKA Occlusion Texture in other nomenclature.
  21981. */
  21982. protected _ambientTexture: Nullable<BaseTexture>;
  21983. /**
  21984. * AKA Occlusion Texture Intensity in other nomenclature.
  21985. */
  21986. protected _ambientTextureStrength: number;
  21987. /**
  21988. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21989. * 1 means it completely occludes it
  21990. * 0 mean it has no impact
  21991. */
  21992. protected _ambientTextureImpactOnAnalyticalLights: number;
  21993. /**
  21994. * Stores the alpha values in a texture.
  21995. */
  21996. protected _opacityTexture: Nullable<BaseTexture>;
  21997. /**
  21998. * Stores the reflection values in a texture.
  21999. */
  22000. protected _reflectionTexture: Nullable<BaseTexture>;
  22001. /**
  22002. * Stores the emissive values in a texture.
  22003. */
  22004. protected _emissiveTexture: Nullable<BaseTexture>;
  22005. /**
  22006. * AKA Specular texture in other nomenclature.
  22007. */
  22008. protected _reflectivityTexture: Nullable<BaseTexture>;
  22009. /**
  22010. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22011. */
  22012. protected _metallicTexture: Nullable<BaseTexture>;
  22013. /**
  22014. * Specifies the metallic scalar of the metallic/roughness workflow.
  22015. * Can also be used to scale the metalness values of the metallic texture.
  22016. */
  22017. protected _metallic: Nullable<number>;
  22018. /**
  22019. * Specifies the roughness scalar of the metallic/roughness workflow.
  22020. * Can also be used to scale the roughness values of the metallic texture.
  22021. */
  22022. protected _roughness: Nullable<number>;
  22023. /**
  22024. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22025. * By default the indexOfrefraction is used to compute F0;
  22026. *
  22027. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22028. *
  22029. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22030. * F90 = metallicReflectanceColor;
  22031. */
  22032. protected _metallicF0Factor: number;
  22033. /**
  22034. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22035. * By default the F90 is always 1;
  22036. *
  22037. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22038. *
  22039. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22040. * F90 = metallicReflectanceColor;
  22041. */
  22042. protected _metallicReflectanceColor: Color3;
  22043. /**
  22044. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22045. * This is multiply against the scalar values defined in the material.
  22046. */
  22047. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  22048. /**
  22049. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22050. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22051. */
  22052. protected _microSurfaceTexture: Nullable<BaseTexture>;
  22053. /**
  22054. * Stores surface normal data used to displace a mesh in a texture.
  22055. */
  22056. protected _bumpTexture: Nullable<BaseTexture>;
  22057. /**
  22058. * Stores the pre-calculated light information of a mesh in a texture.
  22059. */
  22060. protected _lightmapTexture: Nullable<BaseTexture>;
  22061. /**
  22062. * The color of a material in ambient lighting.
  22063. */
  22064. protected _ambientColor: Color3;
  22065. /**
  22066. * AKA Diffuse Color in other nomenclature.
  22067. */
  22068. protected _albedoColor: Color3;
  22069. /**
  22070. * AKA Specular Color in other nomenclature.
  22071. */
  22072. protected _reflectivityColor: Color3;
  22073. /**
  22074. * The color applied when light is reflected from a material.
  22075. */
  22076. protected _reflectionColor: Color3;
  22077. /**
  22078. * The color applied when light is emitted from a material.
  22079. */
  22080. protected _emissiveColor: Color3;
  22081. /**
  22082. * AKA Glossiness in other nomenclature.
  22083. */
  22084. protected _microSurface: number;
  22085. /**
  22086. * Specifies that the material will use the light map as a show map.
  22087. */
  22088. protected _useLightmapAsShadowmap: boolean;
  22089. /**
  22090. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22091. * makes the reflect vector face the model (under horizon).
  22092. */
  22093. protected _useHorizonOcclusion: boolean;
  22094. /**
  22095. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22096. * too much the area relying on ambient texture to define their ambient occlusion.
  22097. */
  22098. protected _useRadianceOcclusion: boolean;
  22099. /**
  22100. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22101. */
  22102. protected _useAlphaFromAlbedoTexture: boolean;
  22103. /**
  22104. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  22105. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  22106. */
  22107. protected _useSpecularOverAlpha: boolean;
  22108. /**
  22109. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22110. */
  22111. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22112. /**
  22113. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22114. */
  22115. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  22116. /**
  22117. * Specifies if the metallic texture contains the roughness information in its green channel.
  22118. */
  22119. protected _useRoughnessFromMetallicTextureGreen: boolean;
  22120. /**
  22121. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22122. */
  22123. protected _useMetallnessFromMetallicTextureBlue: boolean;
  22124. /**
  22125. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22126. */
  22127. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  22128. /**
  22129. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22130. */
  22131. protected _useAmbientInGrayScale: boolean;
  22132. /**
  22133. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22134. * The material will try to infer what glossiness each pixel should be.
  22135. */
  22136. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  22137. /**
  22138. * Defines the falloff type used in this material.
  22139. * It by default is Physical.
  22140. */
  22141. protected _lightFalloff: number;
  22142. /**
  22143. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  22144. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  22145. */
  22146. protected _useRadianceOverAlpha: boolean;
  22147. /**
  22148. * Allows using an object space normal map (instead of tangent space).
  22149. */
  22150. protected _useObjectSpaceNormalMap: boolean;
  22151. /**
  22152. * Allows using the bump map in parallax mode.
  22153. */
  22154. protected _useParallax: boolean;
  22155. /**
  22156. * Allows using the bump map in parallax occlusion mode.
  22157. */
  22158. protected _useParallaxOcclusion: boolean;
  22159. /**
  22160. * Controls the scale bias of the parallax mode.
  22161. */
  22162. protected _parallaxScaleBias: number;
  22163. /**
  22164. * If sets to true, disables all the lights affecting the material.
  22165. */
  22166. protected _disableLighting: boolean;
  22167. /**
  22168. * Number of Simultaneous lights allowed on the material.
  22169. */
  22170. protected _maxSimultaneousLights: number;
  22171. /**
  22172. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  22173. */
  22174. protected _invertNormalMapX: boolean;
  22175. /**
  22176. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  22177. */
  22178. protected _invertNormalMapY: boolean;
  22179. /**
  22180. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22181. */
  22182. protected _twoSidedLighting: boolean;
  22183. /**
  22184. * Defines the alpha limits in alpha test mode.
  22185. */
  22186. protected _alphaCutOff: number;
  22187. /**
  22188. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22189. */
  22190. protected _forceAlphaTest: boolean;
  22191. /**
  22192. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22193. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22194. */
  22195. protected _useAlphaFresnel: boolean;
  22196. /**
  22197. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22198. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22199. */
  22200. protected _useLinearAlphaFresnel: boolean;
  22201. /**
  22202. * Specifies the environment BRDF texture used to compute the scale and offset roughness values
  22203. * from cos theta and roughness:
  22204. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  22205. */
  22206. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  22207. /**
  22208. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22209. */
  22210. protected _forceIrradianceInFragment: boolean;
  22211. private _realTimeFiltering;
  22212. /**
  22213. * Enables realtime filtering on the texture.
  22214. */
  22215. get realTimeFiltering(): boolean;
  22216. set realTimeFiltering(b: boolean);
  22217. private _realTimeFilteringQuality;
  22218. /**
  22219. * Quality switch for realtime filtering
  22220. */
  22221. get realTimeFilteringQuality(): number;
  22222. set realTimeFilteringQuality(n: number);
  22223. /**
  22224. * Can this material render to several textures at once
  22225. */
  22226. get canRenderToMRT(): boolean;
  22227. /**
  22228. * Force normal to face away from face.
  22229. */
  22230. protected _forceNormalForward: boolean;
  22231. /**
  22232. * Enables specular anti aliasing in the PBR shader.
  22233. * It will both interacts on the Geometry for analytical and IBL lighting.
  22234. * It also prefilter the roughness map based on the bump values.
  22235. */
  22236. protected _enableSpecularAntiAliasing: boolean;
  22237. /**
  22238. * Default configuration related to image processing available in the PBR Material.
  22239. */
  22240. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22241. /**
  22242. * Keep track of the image processing observer to allow dispose and replace.
  22243. */
  22244. private _imageProcessingObserver;
  22245. /**
  22246. * Attaches a new image processing configuration to the PBR Material.
  22247. * @param configuration
  22248. */
  22249. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22250. /**
  22251. * Stores the available render targets.
  22252. */
  22253. private _renderTargets;
  22254. /**
  22255. * Sets the global ambient color for the material used in lighting calculations.
  22256. */
  22257. private _globalAmbientColor;
  22258. /**
  22259. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  22260. */
  22261. private _useLogarithmicDepth;
  22262. /**
  22263. * If set to true, no lighting calculations will be applied.
  22264. */
  22265. private _unlit;
  22266. private _debugMode;
  22267. /**
  22268. * @hidden
  22269. * This is reserved for the inspector.
  22270. * Defines the material debug mode.
  22271. * It helps seeing only some components of the material while troubleshooting.
  22272. */
  22273. debugMode: number;
  22274. /**
  22275. * @hidden
  22276. * This is reserved for the inspector.
  22277. * Specify from where on screen the debug mode should start.
  22278. * The value goes from -1 (full screen) to 1 (not visible)
  22279. * It helps with side by side comparison against the final render
  22280. * This defaults to -1
  22281. */
  22282. private debugLimit;
  22283. /**
  22284. * @hidden
  22285. * This is reserved for the inspector.
  22286. * As the default viewing range might not be enough (if the ambient is really small for instance)
  22287. * You can use the factor to better multiply the final value.
  22288. */
  22289. private debugFactor;
  22290. /**
  22291. * Defines the clear coat layer parameters for the material.
  22292. */
  22293. readonly clearCoat: PBRClearCoatConfiguration;
  22294. /**
  22295. * Defines the anisotropic parameters for the material.
  22296. */
  22297. readonly anisotropy: PBRAnisotropicConfiguration;
  22298. /**
  22299. * Defines the BRDF parameters for the material.
  22300. */
  22301. readonly brdf: PBRBRDFConfiguration;
  22302. /**
  22303. * Defines the Sheen parameters for the material.
  22304. */
  22305. readonly sheen: PBRSheenConfiguration;
  22306. /**
  22307. * Defines the SubSurface parameters for the material.
  22308. */
  22309. readonly subSurface: PBRSubSurfaceConfiguration;
  22310. /**
  22311. * Defines additional PrePass parameters for the material.
  22312. */
  22313. readonly prePassConfiguration: PrePassConfiguration;
  22314. /**
  22315. * Defines the detail map parameters for the material.
  22316. */
  22317. readonly detailMap: DetailMapConfiguration;
  22318. protected _rebuildInParallel: boolean;
  22319. /**
  22320. * Instantiates a new PBRMaterial instance.
  22321. *
  22322. * @param name The material name
  22323. * @param scene The scene the material will be use in.
  22324. */
  22325. constructor(name: string, scene: Scene);
  22326. /**
  22327. * Gets a boolean indicating that current material needs to register RTT
  22328. */
  22329. get hasRenderTargetTextures(): boolean;
  22330. /**
  22331. * Can this material render to prepass
  22332. */
  22333. get isPrePassCapable(): boolean;
  22334. /**
  22335. * Gets the name of the material class.
  22336. */
  22337. getClassName(): string;
  22338. /**
  22339. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22340. */
  22341. get useLogarithmicDepth(): boolean;
  22342. /**
  22343. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22344. */
  22345. set useLogarithmicDepth(value: boolean);
  22346. /**
  22347. * Returns true if alpha blending should be disabled.
  22348. */
  22349. protected get _disableAlphaBlending(): boolean;
  22350. /**
  22351. * Specifies whether or not this material should be rendered in alpha blend mode.
  22352. */
  22353. needAlphaBlending(): boolean;
  22354. /**
  22355. * Specifies whether or not this material should be rendered in alpha test mode.
  22356. */
  22357. needAlphaTesting(): boolean;
  22358. /**
  22359. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  22360. */
  22361. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  22362. /**
  22363. * Specifies whether or not there is a usable alpha channel for transparency.
  22364. */
  22365. protected _hasAlphaChannel(): boolean;
  22366. /**
  22367. * Gets the texture used for the alpha test.
  22368. */
  22369. getAlphaTestTexture(): Nullable<BaseTexture>;
  22370. /**
  22371. * Specifies that the submesh is ready to be used.
  22372. * @param mesh - BJS mesh.
  22373. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  22374. * @param useInstances - Specifies that instances should be used.
  22375. * @returns - boolean indicating that the submesh is ready or not.
  22376. */
  22377. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22378. /**
  22379. * Specifies if the material uses metallic roughness workflow.
  22380. * @returns boolean specifying if the material uses metallic roughness workflow.
  22381. */
  22382. isMetallicWorkflow(): boolean;
  22383. private _prepareEffect;
  22384. private _prepareDefines;
  22385. /**
  22386. * Force shader compilation
  22387. */
  22388. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  22389. /**
  22390. * Initializes the uniform buffer layout for the shader.
  22391. */
  22392. buildUniformLayout(): void;
  22393. /**
  22394. * Unbinds the material from the mesh
  22395. */
  22396. unbind(): void;
  22397. /**
  22398. * Binds the submesh data.
  22399. * @param world - The world matrix.
  22400. * @param mesh - The BJS mesh.
  22401. * @param subMesh - A submesh of the BJS mesh.
  22402. */
  22403. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22404. /**
  22405. * Returns the animatable textures.
  22406. * @returns - Array of animatable textures.
  22407. */
  22408. getAnimatables(): IAnimatable[];
  22409. /**
  22410. * Returns the texture used for reflections.
  22411. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  22412. */
  22413. private _getReflectionTexture;
  22414. /**
  22415. * Returns an array of the actively used textures.
  22416. * @returns - Array of BaseTextures
  22417. */
  22418. getActiveTextures(): BaseTexture[];
  22419. /**
  22420. * Checks to see if a texture is used in the material.
  22421. * @param texture - Base texture to use.
  22422. * @returns - Boolean specifying if a texture is used in the material.
  22423. */
  22424. hasTexture(texture: BaseTexture): boolean;
  22425. /**
  22426. * Sets the required values to the prepass renderer.
  22427. * @param prePassRenderer defines the prepass renderer to setup
  22428. */
  22429. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22430. /**
  22431. * Disposes the resources of the material.
  22432. * @param forceDisposeEffect - Forces the disposal of effects.
  22433. * @param forceDisposeTextures - Forces the disposal of all textures.
  22434. */
  22435. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  22436. }
  22437. }
  22438. declare module BABYLON {
  22439. /**
  22440. * The Physically based material of BJS.
  22441. *
  22442. * This offers the main features of a standard PBR material.
  22443. * For more information, please refer to the documentation :
  22444. * https://doc.babylonjs.com/how_to/physically_based_rendering
  22445. */
  22446. export class PBRMaterial extends PBRBaseMaterial {
  22447. /**
  22448. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  22449. */
  22450. static readonly PBRMATERIAL_OPAQUE: number;
  22451. /**
  22452. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  22453. */
  22454. static readonly PBRMATERIAL_ALPHATEST: number;
  22455. /**
  22456. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22457. */
  22458. static readonly PBRMATERIAL_ALPHABLEND: number;
  22459. /**
  22460. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22461. * They are also discarded below the alpha cutoff threshold to improve performances.
  22462. */
  22463. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  22464. /**
  22465. * Defines the default value of how much AO map is occluding the analytical lights
  22466. * (point spot...).
  22467. */
  22468. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  22469. /**
  22470. * Intensity of the direct lights e.g. the four lights available in your scene.
  22471. * This impacts both the direct diffuse and specular highlights.
  22472. */
  22473. directIntensity: number;
  22474. /**
  22475. * Intensity of the emissive part of the material.
  22476. * This helps controlling the emissive effect without modifying the emissive color.
  22477. */
  22478. emissiveIntensity: number;
  22479. /**
  22480. * Intensity of the environment e.g. how much the environment will light the object
  22481. * either through harmonics for rough material or through the reflection for shiny ones.
  22482. */
  22483. environmentIntensity: number;
  22484. /**
  22485. * This is a special control allowing the reduction of the specular highlights coming from the
  22486. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  22487. */
  22488. specularIntensity: number;
  22489. /**
  22490. * Debug Control allowing disabling the bump map on this material.
  22491. */
  22492. disableBumpMap: boolean;
  22493. /**
  22494. * AKA Diffuse Texture in standard nomenclature.
  22495. */
  22496. albedoTexture: BaseTexture;
  22497. /**
  22498. * AKA Occlusion Texture in other nomenclature.
  22499. */
  22500. ambientTexture: BaseTexture;
  22501. /**
  22502. * AKA Occlusion Texture Intensity in other nomenclature.
  22503. */
  22504. ambientTextureStrength: number;
  22505. /**
  22506. * Defines how much the AO map is occluding the analytical lights (point spot...).
  22507. * 1 means it completely occludes it
  22508. * 0 mean it has no impact
  22509. */
  22510. ambientTextureImpactOnAnalyticalLights: number;
  22511. /**
  22512. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  22513. */
  22514. opacityTexture: BaseTexture;
  22515. /**
  22516. * Stores the reflection values in a texture.
  22517. */
  22518. reflectionTexture: Nullable<BaseTexture>;
  22519. /**
  22520. * Stores the emissive values in a texture.
  22521. */
  22522. emissiveTexture: BaseTexture;
  22523. /**
  22524. * AKA Specular texture in other nomenclature.
  22525. */
  22526. reflectivityTexture: BaseTexture;
  22527. /**
  22528. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22529. */
  22530. metallicTexture: BaseTexture;
  22531. /**
  22532. * Specifies the metallic scalar of the metallic/roughness workflow.
  22533. * Can also be used to scale the metalness values of the metallic texture.
  22534. */
  22535. metallic: Nullable<number>;
  22536. /**
  22537. * Specifies the roughness scalar of the metallic/roughness workflow.
  22538. * Can also be used to scale the roughness values of the metallic texture.
  22539. */
  22540. roughness: Nullable<number>;
  22541. /**
  22542. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22543. * By default the indexOfrefraction is used to compute F0;
  22544. *
  22545. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22546. *
  22547. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22548. * F90 = metallicReflectanceColor;
  22549. */
  22550. metallicF0Factor: number;
  22551. /**
  22552. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22553. * By default the F90 is always 1;
  22554. *
  22555. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22556. *
  22557. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22558. * F90 = metallicReflectanceColor;
  22559. */
  22560. metallicReflectanceColor: Color3;
  22561. /**
  22562. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22563. * This is multiply against the scalar values defined in the material.
  22564. */
  22565. metallicReflectanceTexture: Nullable<BaseTexture>;
  22566. /**
  22567. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22568. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22569. */
  22570. microSurfaceTexture: BaseTexture;
  22571. /**
  22572. * Stores surface normal data used to displace a mesh in a texture.
  22573. */
  22574. bumpTexture: BaseTexture;
  22575. /**
  22576. * Stores the pre-calculated light information of a mesh in a texture.
  22577. */
  22578. lightmapTexture: BaseTexture;
  22579. /**
  22580. * Stores the refracted light information in a texture.
  22581. */
  22582. get refractionTexture(): Nullable<BaseTexture>;
  22583. set refractionTexture(value: Nullable<BaseTexture>);
  22584. /**
  22585. * The color of a material in ambient lighting.
  22586. */
  22587. ambientColor: Color3;
  22588. /**
  22589. * AKA Diffuse Color in other nomenclature.
  22590. */
  22591. albedoColor: Color3;
  22592. /**
  22593. * AKA Specular Color in other nomenclature.
  22594. */
  22595. reflectivityColor: Color3;
  22596. /**
  22597. * The color reflected from the material.
  22598. */
  22599. reflectionColor: Color3;
  22600. /**
  22601. * The color emitted from the material.
  22602. */
  22603. emissiveColor: Color3;
  22604. /**
  22605. * AKA Glossiness in other nomenclature.
  22606. */
  22607. microSurface: number;
  22608. /**
  22609. * Index of refraction of the material base layer.
  22610. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  22611. *
  22612. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  22613. *
  22614. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  22615. */
  22616. get indexOfRefraction(): number;
  22617. set indexOfRefraction(value: number);
  22618. /**
  22619. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  22620. */
  22621. get invertRefractionY(): boolean;
  22622. set invertRefractionY(value: boolean);
  22623. /**
  22624. * This parameters will make the material used its opacity to control how much it is refracting against not.
  22625. * Materials half opaque for instance using refraction could benefit from this control.
  22626. */
  22627. get linkRefractionWithTransparency(): boolean;
  22628. set linkRefractionWithTransparency(value: boolean);
  22629. /**
  22630. * If true, the light map contains occlusion information instead of lighting info.
  22631. */
  22632. useLightmapAsShadowmap: boolean;
  22633. /**
  22634. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22635. */
  22636. useAlphaFromAlbedoTexture: boolean;
  22637. /**
  22638. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22639. */
  22640. forceAlphaTest: boolean;
  22641. /**
  22642. * Defines the alpha limits in alpha test mode.
  22643. */
  22644. alphaCutOff: number;
  22645. /**
  22646. * Specifies that the material will keep the specular highlights over a transparent surface (only the most luminous ones).
  22647. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  22648. */
  22649. useSpecularOverAlpha: boolean;
  22650. /**
  22651. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22652. */
  22653. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22654. /**
  22655. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22656. */
  22657. useRoughnessFromMetallicTextureAlpha: boolean;
  22658. /**
  22659. * Specifies if the metallic texture contains the roughness information in its green channel.
  22660. */
  22661. useRoughnessFromMetallicTextureGreen: boolean;
  22662. /**
  22663. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22664. */
  22665. useMetallnessFromMetallicTextureBlue: boolean;
  22666. /**
  22667. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22668. */
  22669. useAmbientOcclusionFromMetallicTextureRed: boolean;
  22670. /**
  22671. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22672. */
  22673. useAmbientInGrayScale: boolean;
  22674. /**
  22675. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22676. * The material will try to infer what glossiness each pixel should be.
  22677. */
  22678. useAutoMicroSurfaceFromReflectivityMap: boolean;
  22679. /**
  22680. * BJS is using an hardcoded light falloff based on a manually sets up range.
  22681. * In PBR, one way to represents the falloff is to use the inverse squared root algorithm.
  22682. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22683. */
  22684. get usePhysicalLightFalloff(): boolean;
  22685. /**
  22686. * BJS is using an hardcoded light falloff based on a manually sets up range.
  22687. * In PBR, one way to represents the falloff is to use the inverse squared root algorithm.
  22688. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22689. */
  22690. set usePhysicalLightFalloff(value: boolean);
  22691. /**
  22692. * In order to support the falloff compatibility with gltf, a special mode has been added
  22693. * to reproduce the gltf light falloff.
  22694. */
  22695. get useGLTFLightFalloff(): boolean;
  22696. /**
  22697. * In order to support the falloff compatibility with gltf, a special mode has been added
  22698. * to reproduce the gltf light falloff.
  22699. */
  22700. set useGLTFLightFalloff(value: boolean);
  22701. /**
  22702. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  22703. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  22704. */
  22705. useRadianceOverAlpha: boolean;
  22706. /**
  22707. * Allows using an object space normal map (instead of tangent space).
  22708. */
  22709. useObjectSpaceNormalMap: boolean;
  22710. /**
  22711. * Allows using the bump map in parallax mode.
  22712. */
  22713. useParallax: boolean;
  22714. /**
  22715. * Allows using the bump map in parallax occlusion mode.
  22716. */
  22717. useParallaxOcclusion: boolean;
  22718. /**
  22719. * Controls the scale bias of the parallax mode.
  22720. */
  22721. parallaxScaleBias: number;
  22722. /**
  22723. * If sets to true, disables all the lights affecting the material.
  22724. */
  22725. disableLighting: boolean;
  22726. /**
  22727. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22728. */
  22729. forceIrradianceInFragment: boolean;
  22730. /**
  22731. * Number of Simultaneous lights allowed on the material.
  22732. */
  22733. maxSimultaneousLights: number;
  22734. /**
  22735. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  22736. */
  22737. invertNormalMapX: boolean;
  22738. /**
  22739. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  22740. */
  22741. invertNormalMapY: boolean;
  22742. /**
  22743. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22744. */
  22745. twoSidedLighting: boolean;
  22746. /**
  22747. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22748. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22749. */
  22750. useAlphaFresnel: boolean;
  22751. /**
  22752. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22753. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22754. */
  22755. useLinearAlphaFresnel: boolean;
  22756. /**
  22757. * Let user defines the brdf lookup texture used for IBL.
  22758. * A default 8bit version is embedded but you could point at :
  22759. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  22760. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  22761. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  22762. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  22763. */
  22764. environmentBRDFTexture: Nullable<BaseTexture>;
  22765. /**
  22766. * Force normal to face away from face.
  22767. */
  22768. forceNormalForward: boolean;
  22769. /**
  22770. * Enables specular anti aliasing in the PBR shader.
  22771. * It will both interacts on the Geometry for analytical and IBL lighting.
  22772. * It also prefilter the roughness map based on the bump values.
  22773. */
  22774. enableSpecularAntiAliasing: boolean;
  22775. /**
  22776. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22777. * makes the reflect vector face the model (under horizon).
  22778. */
  22779. useHorizonOcclusion: boolean;
  22780. /**
  22781. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22782. * too much the area relying on ambient texture to define their ambient occlusion.
  22783. */
  22784. useRadianceOcclusion: boolean;
  22785. /**
  22786. * If set to true, no lighting calculations will be applied.
  22787. */
  22788. unlit: boolean;
  22789. /**
  22790. * Gets the image processing configuration used either in this material.
  22791. */
  22792. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22793. /**
  22794. * Sets the Default image processing configuration used either in the this material.
  22795. *
  22796. * If sets to null, the scene one is in use.
  22797. */
  22798. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22799. /**
  22800. * Gets whether the color curves effect is enabled.
  22801. */
  22802. get cameraColorCurvesEnabled(): boolean;
  22803. /**
  22804. * Sets whether the color curves effect is enabled.
  22805. */
  22806. set cameraColorCurvesEnabled(value: boolean);
  22807. /**
  22808. * Gets whether the color grading effect is enabled.
  22809. */
  22810. get cameraColorGradingEnabled(): boolean;
  22811. /**
  22812. * Gets whether the color grading effect is enabled.
  22813. */
  22814. set cameraColorGradingEnabled(value: boolean);
  22815. /**
  22816. * Gets whether tonemapping is enabled or not.
  22817. */
  22818. get cameraToneMappingEnabled(): boolean;
  22819. /**
  22820. * Sets whether tonemapping is enabled or not
  22821. */
  22822. set cameraToneMappingEnabled(value: boolean);
  22823. /**
  22824. * The camera exposure used on this material.
  22825. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22826. * This corresponds to a photographic exposure.
  22827. */
  22828. get cameraExposure(): number;
  22829. /**
  22830. * The camera exposure used on this material.
  22831. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22832. * This corresponds to a photographic exposure.
  22833. */
  22834. set cameraExposure(value: number);
  22835. /**
  22836. * Gets The camera contrast used on this material.
  22837. */
  22838. get cameraContrast(): number;
  22839. /**
  22840. * Sets The camera contrast used on this material.
  22841. */
  22842. set cameraContrast(value: number);
  22843. /**
  22844. * Gets the Color Grading 2D Lookup Texture.
  22845. */
  22846. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  22847. /**
  22848. * Sets the Color Grading 2D Lookup Texture.
  22849. */
  22850. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  22851. /**
  22852. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  22853. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22854. * 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;
  22855. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22856. */
  22857. get cameraColorCurves(): Nullable<ColorCurves>;
  22858. /**
  22859. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  22860. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22861. * 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;
  22862. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22863. */
  22864. set cameraColorCurves(value: Nullable<ColorCurves>);
  22865. /**
  22866. * Instantiates a new PBRMaterial instance.
  22867. *
  22868. * @param name The material name
  22869. * @param scene The scene the material will be use in.
  22870. */
  22871. constructor(name: string, scene: Scene);
  22872. /**
  22873. * Returns the name of this material class.
  22874. */
  22875. getClassName(): string;
  22876. /**
  22877. * Makes a duplicate of the current material.
  22878. * @param name - name to use for the new material.
  22879. */
  22880. clone(name: string): PBRMaterial;
  22881. /**
  22882. * Serializes this PBR Material.
  22883. * @returns - An object with the serialized material.
  22884. */
  22885. serialize(): any;
  22886. /**
  22887. * Parses a PBR Material from a serialized object.
  22888. * @param source - Serialized object.
  22889. * @param scene - BJS scene instance.
  22890. * @param rootUrl - url for the scene object
  22891. * @returns - PBRMaterial
  22892. */
  22893. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  22894. }
  22895. }
  22896. declare module BABYLON {
  22897. /** @hidden */
  22898. export var mrtFragmentDeclaration: {
  22899. name: string;
  22900. shader: string;
  22901. };
  22902. }
  22903. declare module BABYLON {
  22904. /** @hidden */
  22905. export var geometryPixelShader: {
  22906. name: string;
  22907. shader: string;
  22908. };
  22909. }
  22910. declare module BABYLON {
  22911. /** @hidden */
  22912. export var instancesDeclaration: {
  22913. name: string;
  22914. shader: string;
  22915. };
  22916. }
  22917. declare module BABYLON {
  22918. /** @hidden */
  22919. export var geometryVertexDeclaration: {
  22920. name: string;
  22921. shader: string;
  22922. };
  22923. }
  22924. declare module BABYLON {
  22925. /** @hidden */
  22926. export var geometryUboDeclaration: {
  22927. name: string;
  22928. shader: string;
  22929. };
  22930. }
  22931. declare module BABYLON {
  22932. /** @hidden */
  22933. export var geometryVertexShader: {
  22934. name: string;
  22935. shader: string;
  22936. };
  22937. }
  22938. declare module BABYLON {
  22939. /** @hidden */
  22940. interface ISavedTransformationMatrix {
  22941. world: Matrix;
  22942. viewProjection: Matrix;
  22943. }
  22944. /**
  22945. * This renderer is helpful to fill one of the render target with a geometry buffer.
  22946. */
  22947. export class GeometryBufferRenderer {
  22948. /**
  22949. * Constant used to retrieve the depth texture index in the G-Buffer textures array
  22950. * using getIndex(GeometryBufferRenderer.DEPTH_TEXTURE_INDEX)
  22951. */
  22952. static readonly DEPTH_TEXTURE_TYPE: number;
  22953. /**
  22954. * Constant used to retrieve the normal texture index in the G-Buffer textures array
  22955. * using getIndex(GeometryBufferRenderer.NORMAL_TEXTURE_INDEX)
  22956. */
  22957. static readonly NORMAL_TEXTURE_TYPE: number;
  22958. /**
  22959. * Constant used to retrieve the position texture index in the G-Buffer textures array
  22960. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  22961. */
  22962. static readonly POSITION_TEXTURE_TYPE: number;
  22963. /**
  22964. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  22965. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  22966. */
  22967. static readonly VELOCITY_TEXTURE_TYPE: number;
  22968. /**
  22969. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  22970. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  22971. */
  22972. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  22973. /**
  22974. * Dictionary used to store the previous transformation matrices of each rendered mesh
  22975. * in order to compute objects velocities when enableVelocity is set to "true"
  22976. * @hidden
  22977. */
  22978. _previousTransformationMatrices: {
  22979. [index: number]: ISavedTransformationMatrix;
  22980. };
  22981. /**
  22982. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  22983. * in order to compute objects velocities when enableVelocity is set to "true"
  22984. * @hidden
  22985. */
  22986. _previousBonesTransformationMatrices: {
  22987. [index: number]: Float32Array;
  22988. };
  22989. /**
  22990. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  22991. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  22992. */
  22993. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  22994. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  22995. renderTransparentMeshes: boolean;
  22996. private _scene;
  22997. private _resizeObserver;
  22998. private _multiRenderTarget;
  22999. private _ratio;
  23000. private _enablePosition;
  23001. private _enableVelocity;
  23002. private _enableReflectivity;
  23003. private _positionIndex;
  23004. private _velocityIndex;
  23005. private _reflectivityIndex;
  23006. private _depthIndex;
  23007. private _normalIndex;
  23008. private _linkedWithPrePass;
  23009. private _prePassRenderer;
  23010. private _attachments;
  23011. private _useUbo;
  23012. protected _effect: Effect;
  23013. protected _cachedDefines: string;
  23014. /**
  23015. * @hidden
  23016. * Sets up internal structures to share outputs with PrePassRenderer
  23017. * This method should only be called by the PrePassRenderer itself
  23018. */
  23019. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  23020. /**
  23021. * @hidden
  23022. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  23023. * This method should only be called by the PrePassRenderer itself
  23024. */
  23025. _unlinkPrePassRenderer(): void;
  23026. /**
  23027. * @hidden
  23028. * Resets the geometry buffer layout
  23029. */
  23030. _resetLayout(): void;
  23031. /**
  23032. * @hidden
  23033. * Replaces a texture in the geometry buffer renderer
  23034. * Useful when linking textures of the prepass renderer
  23035. */
  23036. _forceTextureType(geometryBufferType: number, index: number): void;
  23037. /**
  23038. * @hidden
  23039. * Sets texture attachments
  23040. * Useful when linking textures of the prepass renderer
  23041. */
  23042. _setAttachments(attachments: number[]): void;
  23043. /**
  23044. * @hidden
  23045. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  23046. * Useful when linking textures of the prepass renderer
  23047. */
  23048. _linkInternalTexture(internalTexture: InternalTexture): void;
  23049. /**
  23050. * Gets the render list (meshes to be rendered) used in the G buffer.
  23051. */
  23052. get renderList(): Nullable<AbstractMesh[]>;
  23053. /**
  23054. * Set the render list (meshes to be rendered) used in the G buffer.
  23055. */
  23056. set renderList(meshes: Nullable<AbstractMesh[]>);
  23057. /**
  23058. * Gets whether or not G buffer are supported by the running hardware.
  23059. * This requires draw buffer supports
  23060. */
  23061. get isSupported(): boolean;
  23062. /**
  23063. * Returns the index of the given texture type in the G-Buffer textures array
  23064. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  23065. * @returns the index of the given texture type in the G-Buffer textures array
  23066. */
  23067. getTextureIndex(textureType: number): number;
  23068. /**
  23069. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  23070. */
  23071. get enablePosition(): boolean;
  23072. /**
  23073. * Sets whether or not objects positions are enabled for the G buffer.
  23074. */
  23075. set enablePosition(enable: boolean);
  23076. /**
  23077. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  23078. */
  23079. get enableVelocity(): boolean;
  23080. /**
  23081. * Sets whether or not objects velocities are enabled for the G buffer.
  23082. */
  23083. set enableVelocity(enable: boolean);
  23084. /**
  23085. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  23086. */
  23087. get enableReflectivity(): boolean;
  23088. /**
  23089. * Sets whether or not objects roughness are enabled for the G buffer.
  23090. */
  23091. set enableReflectivity(enable: boolean);
  23092. /**
  23093. * Gets the scene associated with the buffer.
  23094. */
  23095. get scene(): Scene;
  23096. /**
  23097. * Gets the ratio used by the buffer during its creation.
  23098. * How big is the buffer related to the main canvas.
  23099. */
  23100. get ratio(): number;
  23101. /** @hidden */
  23102. static _SceneComponentInitialization: (scene: Scene) => void;
  23103. /**
  23104. * Creates a new G Buffer for the scene
  23105. * @param scene The scene the buffer belongs to
  23106. * @param ratio How big is the buffer related to the main canvas.
  23107. */
  23108. constructor(scene: Scene, ratio?: number);
  23109. /**
  23110. * Checks whether everything is ready to render a submesh to the G buffer.
  23111. * @param subMesh the submesh to check readiness for
  23112. * @param useInstances is the mesh drawn using instance or not
  23113. * @returns true if ready otherwise false
  23114. */
  23115. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  23116. /**
  23117. * Gets the current underlying G Buffer.
  23118. * @returns the buffer
  23119. */
  23120. getGBuffer(): MultiRenderTarget;
  23121. /**
  23122. * Gets the number of samples used to render the buffer (anti aliasing).
  23123. */
  23124. get samples(): number;
  23125. /**
  23126. * Sets the number of samples used to render the buffer (anti aliasing).
  23127. */
  23128. set samples(value: number);
  23129. /**
  23130. * Disposes the renderer and frees up associated resources.
  23131. */
  23132. dispose(): void;
  23133. private _assignRenderTargetIndices;
  23134. protected _createRenderTargets(): void;
  23135. private _copyBonesTransformationMatrices;
  23136. }
  23137. }
  23138. declare module BABYLON {
  23139. /**
  23140. * Renders a pre pass of the scene
  23141. * This means every mesh in the scene will be rendered to a render target texture
  23142. * And then this texture will be composited to the rendering canvas with post processes
  23143. * It is necessary for effects like subsurface scattering or deferred shading
  23144. */
  23145. export class PrePassRenderer {
  23146. /** @hidden */
  23147. static _SceneComponentInitialization: (scene: Scene) => void;
  23148. /**
  23149. * To save performance, we can excluded skinned meshes from the prepass
  23150. */
  23151. excludedSkinnedMesh: AbstractMesh[];
  23152. /**
  23153. * Force material to be excluded from the prepass
  23154. * Can be useful when `useGeometryBufferFallback` is set to `true`
  23155. * and you don't want a material to show in the effect.
  23156. */
  23157. excludedMaterials: Material[];
  23158. private _scene;
  23159. private _engine;
  23160. /**
  23161. * Number of textures in the multi render target texture where the scene is directly rendered
  23162. */
  23163. mrtCount: number;
  23164. private _mrtFormats;
  23165. private _mrtLayout;
  23166. private _textureIndices;
  23167. private _multiRenderAttachments;
  23168. private _defaultAttachments;
  23169. private _clearAttachments;
  23170. /**
  23171. * Returns the index of a texture in the multi render target texture array.
  23172. * @param type Texture type
  23173. * @return The index
  23174. */
  23175. getIndex(type: number): number;
  23176. /**
  23177. * How many samples are used for MSAA of the scene render target
  23178. */
  23179. get samples(): number;
  23180. set samples(n: number);
  23181. private static _textureFormats;
  23182. private _isDirty;
  23183. /**
  23184. * The render target where the scene is directly rendered
  23185. */
  23186. defaultRT: PrePassRenderTarget;
  23187. /**
  23188. * Configuration for prepass effects
  23189. */
  23190. private _effectConfigurations;
  23191. /**
  23192. * @return the prepass render target for the rendering pass.
  23193. * If we are currently rendering a render target, it returns the PrePassRenderTarget
  23194. * associated with that render target. Otherwise, it returns the scene default PrePassRenderTarget
  23195. */
  23196. getRenderTarget(): PrePassRenderTarget;
  23197. /**
  23198. * @hidden
  23199. * Managed by the scene component
  23200. * @param prePassRenderTarget
  23201. */
  23202. _setRenderTarget(prePassRenderTarget: Nullable<PrePassRenderTarget>): void;
  23203. /**
  23204. * Returns true if the currently rendered prePassRenderTarget is the one
  23205. * associated with the scene.
  23206. */
  23207. get currentRTisSceneRT(): boolean;
  23208. private _geometryBuffer;
  23209. /**
  23210. * Prevents the PrePassRenderer from using the GeometryBufferRenderer as a fallback
  23211. */
  23212. doNotUseGeometryRendererFallback: boolean;
  23213. private _refreshGeometryBufferRendererLink;
  23214. private _currentTarget;
  23215. /**
  23216. * All the render targets generated by prepass
  23217. */
  23218. renderTargets: PrePassRenderTarget[];
  23219. private readonly _clearColor;
  23220. private _enabled;
  23221. private _needsCompositionForThisPass;
  23222. private _postProcessesSourceForThisPass;
  23223. /**
  23224. * Indicates if the prepass is enabled
  23225. */
  23226. get enabled(): boolean;
  23227. /**
  23228. * Set to true to disable gamma transform in PrePass.
  23229. * Can be useful in case you already proceed to gamma transform on a material level
  23230. * and your post processes don't need to be in linear color space.
  23231. */
  23232. disableGammaTransform: boolean;
  23233. /**
  23234. * Instanciates a prepass renderer
  23235. * @param scene The scene
  23236. */
  23237. constructor(scene: Scene);
  23238. /**
  23239. * Creates a new PrePassRenderTarget
  23240. * This should be the only way to instanciate a `PrePassRenderTarget`
  23241. * @param name Name of the `PrePassRenderTarget`
  23242. * @param renderTargetTexture RenderTarget the `PrePassRenderTarget` will be attached to.
  23243. * Can be `null` if the created `PrePassRenderTarget` is attached to the scene (default framebuffer).
  23244. * @hidden
  23245. */
  23246. _createRenderTarget(name: string, renderTargetTexture: Nullable<RenderTargetTexture>): PrePassRenderTarget;
  23247. /**
  23248. * Indicates if rendering a prepass is supported
  23249. */
  23250. get isSupported(): boolean;
  23251. /**
  23252. * Sets the proper output textures to draw in the engine.
  23253. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  23254. * @param subMesh Submesh on which the effect is applied
  23255. */
  23256. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  23257. private _reinitializeAttachments;
  23258. private _resetLayout;
  23259. private _updateGeometryBufferLayout;
  23260. /**
  23261. * Restores attachments for single texture draw.
  23262. */
  23263. restoreAttachments(): void;
  23264. /**
  23265. * @hidden
  23266. */
  23267. _beforeDraw(camera?: Camera, faceIndex?: number, layer?: number): void;
  23268. private _prepareFrame;
  23269. private _renderPostProcesses;
  23270. /**
  23271. * @hidden
  23272. */
  23273. _afterDraw(faceIndex?: number, layer?: number): void;
  23274. /**
  23275. * Clears the current prepass render target (in the sense of settings pixels to the scene clear color value)
  23276. * @hidden
  23277. */
  23278. _clear(): void;
  23279. private _bindFrameBuffer;
  23280. private _setEnabled;
  23281. private _setRenderTargetEnabled;
  23282. /**
  23283. * Adds an effect configuration to the prepass render target.
  23284. * If an effect has already been added, it won't add it twice and will return the configuration
  23285. * already present.
  23286. * @param cfg the effect configuration
  23287. * @return the effect configuration now used by the prepass
  23288. */
  23289. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  23290. private _enable;
  23291. private _disable;
  23292. private _getPostProcessesSource;
  23293. private _setupOutputForThisPass;
  23294. private _linkInternalTexture;
  23295. private _needsImageProcessing;
  23296. private _hasImageProcessing;
  23297. /**
  23298. * Internal, gets the first post proces.
  23299. * @returns the first post process to be run on this camera.
  23300. */
  23301. private _getFirstPostProcess;
  23302. /**
  23303. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  23304. */
  23305. markAsDirty(): void;
  23306. /**
  23307. * Enables a texture on the MultiRenderTarget for prepass
  23308. */
  23309. private _enableTextures;
  23310. private _update;
  23311. private _markAllMaterialsAsPrePassDirty;
  23312. /**
  23313. * Disposes the prepass renderer.
  23314. */
  23315. dispose(): void;
  23316. }
  23317. }
  23318. declare module BABYLON {
  23319. /**
  23320. * Size options for a post process
  23321. */
  23322. export type PostProcessOptions = {
  23323. width: number;
  23324. height: number;
  23325. };
  23326. /**
  23327. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23328. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23329. */
  23330. export class PostProcess {
  23331. /**
  23332. * Gets or sets the unique id of the post process
  23333. */
  23334. uniqueId: number;
  23335. /** Name of the PostProcess. */
  23336. name: string;
  23337. /**
  23338. * Width of the texture to apply the post process on
  23339. */
  23340. width: number;
  23341. /**
  23342. * Height of the texture to apply the post process on
  23343. */
  23344. height: number;
  23345. /**
  23346. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23347. */
  23348. nodeMaterialSource: Nullable<NodeMaterial>;
  23349. /**
  23350. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23351. * @hidden
  23352. */
  23353. _outputTexture: Nullable<InternalTexture>;
  23354. /**
  23355. * Sampling mode used by the shader
  23356. * See https://doc.babylonjs.com/classes/3.1/texture
  23357. */
  23358. renderTargetSamplingMode: number;
  23359. /**
  23360. * Clear color to use when screen clearing
  23361. */
  23362. clearColor: Color4;
  23363. /**
  23364. * If the buffer needs to be cleared before applying the post process. (default: true)
  23365. * Should be set to false if shader will overwrite all previous pixels.
  23366. */
  23367. autoClear: boolean;
  23368. /**
  23369. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23370. */
  23371. alphaMode: number;
  23372. /**
  23373. * Sets the setAlphaBlendConstants of the babylon engine
  23374. */
  23375. alphaConstants: Color4;
  23376. /**
  23377. * Animations to be used for the post processing
  23378. */
  23379. animations: Animation[];
  23380. /**
  23381. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23382. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23383. */
  23384. enablePixelPerfectMode: boolean;
  23385. /**
  23386. * Force the postprocess to be applied without taking in account viewport
  23387. */
  23388. forceFullscreenViewport: boolean;
  23389. /**
  23390. * List of inspectable custom properties (used by the Inspector)
  23391. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23392. */
  23393. inspectableCustomProperties: IInspectable[];
  23394. /**
  23395. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23396. *
  23397. * | Value | Type | Description |
  23398. * | ----- | ----------------------------------- | ----------- |
  23399. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23400. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23401. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23402. *
  23403. */
  23404. scaleMode: number;
  23405. /**
  23406. * Force textures to be a power of two (default: false)
  23407. */
  23408. alwaysForcePOT: boolean;
  23409. private _samples;
  23410. /**
  23411. * Number of sample textures (default: 1)
  23412. */
  23413. get samples(): number;
  23414. set samples(n: number);
  23415. /**
  23416. * Modify the scale of the post process to be the same as the viewport (default: false)
  23417. */
  23418. adaptScaleToCurrentViewport: boolean;
  23419. private _camera;
  23420. protected _scene: Scene;
  23421. private _engine;
  23422. private _options;
  23423. private _reusable;
  23424. private _renderId;
  23425. private _textureType;
  23426. private _textureFormat;
  23427. /**
  23428. * Smart array of input and output textures for the post process.
  23429. * @hidden
  23430. */
  23431. _textures: SmartArray<InternalTexture>;
  23432. /**
  23433. * Smart array of input and output textures for the post process.
  23434. * @hidden
  23435. */
  23436. private _textureCache;
  23437. /**
  23438. * The index in _textures that corresponds to the output texture.
  23439. * @hidden
  23440. */
  23441. _currentRenderTextureInd: number;
  23442. private _effect;
  23443. private _samplers;
  23444. private _fragmentUrl;
  23445. private _vertexUrl;
  23446. private _parameters;
  23447. protected _postProcessDefines: Nullable<string>;
  23448. private _scaleRatio;
  23449. protected _indexParameters: any;
  23450. private _shareOutputWithPostProcess;
  23451. private _texelSize;
  23452. /** @hidden */
  23453. _forcedOutputTexture: Nullable<InternalTexture>;
  23454. /**
  23455. * Prepass configuration in case this post process needs a texture from prepass
  23456. * @hidden
  23457. */
  23458. _prePassEffectConfiguration: PrePassEffectConfiguration;
  23459. /**
  23460. * Returns the fragment url or shader name used in the post process.
  23461. * @returns the fragment url or name in the shader store.
  23462. */
  23463. getEffectName(): string;
  23464. /**
  23465. * An event triggered when the postprocess is activated.
  23466. */
  23467. onActivateObservable: Observable<Camera>;
  23468. private _onActivateObserver;
  23469. /**
  23470. * A function that is added to the onActivateObservable
  23471. */
  23472. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23473. /**
  23474. * An event triggered when the postprocess changes its size.
  23475. */
  23476. onSizeChangedObservable: Observable<PostProcess>;
  23477. private _onSizeChangedObserver;
  23478. /**
  23479. * A function that is added to the onSizeChangedObservable
  23480. */
  23481. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23482. /**
  23483. * An event triggered when the postprocess applies its effect.
  23484. */
  23485. onApplyObservable: Observable<Effect>;
  23486. private _onApplyObserver;
  23487. /**
  23488. * A function that is added to the onApplyObservable
  23489. */
  23490. set onApply(callback: (effect: Effect) => void);
  23491. /**
  23492. * An event triggered before rendering the postprocess
  23493. */
  23494. onBeforeRenderObservable: Observable<Effect>;
  23495. private _onBeforeRenderObserver;
  23496. /**
  23497. * A function that is added to the onBeforeRenderObservable
  23498. */
  23499. set onBeforeRender(callback: (effect: Effect) => void);
  23500. /**
  23501. * An event triggered after rendering the postprocess
  23502. */
  23503. onAfterRenderObservable: Observable<Effect>;
  23504. private _onAfterRenderObserver;
  23505. /**
  23506. * A function that is added to the onAfterRenderObservable
  23507. */
  23508. set onAfterRender(callback: (efect: Effect) => void);
  23509. /**
  23510. * 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
  23511. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23512. */
  23513. get inputTexture(): InternalTexture;
  23514. set inputTexture(value: InternalTexture);
  23515. /**
  23516. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23517. * the only way to unset it is to use this function to restore its internal state
  23518. */
  23519. restoreDefaultInputTexture(): void;
  23520. /**
  23521. * Gets the camera which post process is applied to.
  23522. * @returns The camera the post process is applied to.
  23523. */
  23524. getCamera(): Camera;
  23525. /**
  23526. * Gets the texel size of the postprocess.
  23527. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23528. */
  23529. get texelSize(): Vector2;
  23530. /**
  23531. * Creates a new instance PostProcess
  23532. * @param name The name of the PostProcess.
  23533. * @param fragmentUrl The url of the fragment shader to be used.
  23534. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23535. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23536. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23537. * @param camera The camera to apply the render pass to.
  23538. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23539. * @param engine The engine which the post process will be applied. (default: current engine)
  23540. * @param reusable If the post process can be reused on the same frame. (default: false)
  23541. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23542. * @param textureType Type of textures used when performing the post process. (default: 0)
  23543. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23544. * @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
  23545. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23546. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23547. */
  23548. 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);
  23549. /**
  23550. * Gets a string identifying the name of the class
  23551. * @returns "PostProcess" string
  23552. */
  23553. getClassName(): string;
  23554. /**
  23555. * Gets the engine which this post process belongs to.
  23556. * @returns The engine the post process was enabled with.
  23557. */
  23558. getEngine(): Engine;
  23559. /**
  23560. * The effect that is created when initializing the post process.
  23561. * @returns The created effect corresponding the the postprocess.
  23562. */
  23563. getEffect(): Effect;
  23564. /**
  23565. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23566. * @param postProcess The post process to share the output with.
  23567. * @returns This post process.
  23568. */
  23569. shareOutputWith(postProcess: PostProcess): PostProcess;
  23570. /**
  23571. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23572. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23573. */
  23574. useOwnOutput(): void;
  23575. /**
  23576. * Updates the effect with the current post process compile time values and recompiles the shader.
  23577. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23578. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23579. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23580. * @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
  23581. * @param onCompiled Called when the shader has been compiled.
  23582. * @param onError Called if there is an error when compiling a shader.
  23583. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23584. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23585. */
  23586. 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;
  23587. /**
  23588. * The post process is reusable if it can be used multiple times within one frame.
  23589. * @returns If the post process is reusable
  23590. */
  23591. isReusable(): boolean;
  23592. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23593. markTextureDirty(): void;
  23594. private _createRenderTargetTexture;
  23595. private _flushTextureCache;
  23596. private _resize;
  23597. /**
  23598. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23599. * 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.
  23600. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23601. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23602. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23603. * @returns The target texture that was bound to be written to.
  23604. */
  23605. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23606. /**
  23607. * If the post process is supported.
  23608. */
  23609. get isSupported(): boolean;
  23610. /**
  23611. * The aspect ratio of the output texture.
  23612. */
  23613. get aspectRatio(): number;
  23614. /**
  23615. * Get a value indicating if the post-process is ready to be used
  23616. * @returns true if the post-process is ready (shader is compiled)
  23617. */
  23618. isReady(): boolean;
  23619. /**
  23620. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23621. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23622. */
  23623. apply(): Nullable<Effect>;
  23624. private _disposeTextures;
  23625. private _disposeTextureCache;
  23626. /**
  23627. * Sets the required values to the prepass renderer.
  23628. * @param prePassRenderer defines the prepass renderer to setup.
  23629. * @returns true if the pre pass is needed.
  23630. */
  23631. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  23632. /**
  23633. * Disposes the post process.
  23634. * @param camera The camera to dispose the post process on.
  23635. */
  23636. dispose(camera?: Camera): void;
  23637. /**
  23638. * Serializes the particle system to a JSON object
  23639. * @returns the JSON object
  23640. */
  23641. serialize(): any;
  23642. /**
  23643. * Clones this post process
  23644. * @returns a new post process similar to this one
  23645. */
  23646. clone(): Nullable<PostProcess>;
  23647. /**
  23648. * Creates a material from parsed material data
  23649. * @param parsedPostProcess defines parsed post process data
  23650. * @param scene defines the hosting scene
  23651. * @param rootUrl defines the root URL to use to load textures
  23652. * @returns a new post process
  23653. */
  23654. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23655. /** @hidden */
  23656. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23657. }
  23658. }
  23659. declare module BABYLON {
  23660. /** @hidden */
  23661. export var kernelBlurVaryingDeclaration: {
  23662. name: string;
  23663. shader: string;
  23664. };
  23665. }
  23666. declare module BABYLON {
  23667. /** @hidden */
  23668. export var packingFunctions: {
  23669. name: string;
  23670. shader: string;
  23671. };
  23672. }
  23673. declare module BABYLON {
  23674. /** @hidden */
  23675. export var kernelBlurFragment: {
  23676. name: string;
  23677. shader: string;
  23678. };
  23679. }
  23680. declare module BABYLON {
  23681. /** @hidden */
  23682. export var kernelBlurFragment2: {
  23683. name: string;
  23684. shader: string;
  23685. };
  23686. }
  23687. declare module BABYLON {
  23688. /** @hidden */
  23689. export var kernelBlurPixelShader: {
  23690. name: string;
  23691. shader: string;
  23692. };
  23693. }
  23694. declare module BABYLON {
  23695. /** @hidden */
  23696. export var kernelBlurVertex: {
  23697. name: string;
  23698. shader: string;
  23699. };
  23700. }
  23701. declare module BABYLON {
  23702. /** @hidden */
  23703. export var kernelBlurVertexShader: {
  23704. name: string;
  23705. shader: string;
  23706. };
  23707. }
  23708. declare module BABYLON {
  23709. /**
  23710. * The Blur Post Process which blurs an image based on a kernel and direction.
  23711. * Can be used twice in x and y directions to perform a gaussian blur in two passes.
  23712. */
  23713. export class BlurPostProcess extends PostProcess {
  23714. private blockCompilation;
  23715. protected _kernel: number;
  23716. protected _idealKernel: number;
  23717. protected _packedFloat: boolean;
  23718. private _staticDefines;
  23719. /** The direction in which to blur the image. */
  23720. direction: Vector2;
  23721. /**
  23722. * Sets the length in pixels of the blur sample region
  23723. */
  23724. set kernel(v: number);
  23725. /**
  23726. * Gets the length in pixels of the blur sample region
  23727. */
  23728. get kernel(): number;
  23729. /**
  23730. * Sets whether or not the blur needs to unpack/repack floats
  23731. */
  23732. set packedFloat(v: boolean);
  23733. /**
  23734. * Gets whether or not the blur is unpacking/repacking floats
  23735. */
  23736. get packedFloat(): boolean;
  23737. /**
  23738. * Gets a string identifying the name of the class
  23739. * @returns "BlurPostProcess" string
  23740. */
  23741. getClassName(): string;
  23742. /**
  23743. * Creates a new instance BlurPostProcess
  23744. * @param name The name of the effect.
  23745. * @param direction The direction in which to blur the image.
  23746. * @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.
  23747. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23748. * @param camera The camera to apply the render pass to.
  23749. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23750. * @param engine The engine which the post process will be applied. (default: current engine)
  23751. * @param reusable If the post process can be reused on the same frame. (default: false)
  23752. * @param textureType Type of textures used when performing the post process. (default: 0)
  23753. * @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)
  23754. */
  23755. 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);
  23756. /**
  23757. * Updates the effect with the current post process compile time values and recompiles the shader.
  23758. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23759. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23760. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23761. * @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
  23762. * @param onCompiled Called when the shader has been compiled.
  23763. * @param onError Called if there is an error when compiling a shader.
  23764. */
  23765. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23766. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23767. /**
  23768. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23769. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23770. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23771. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23772. * The gaps between physical kernels are compensated for in the weighting of the samples
  23773. * @param idealKernel Ideal blur kernel.
  23774. * @return Nearest best kernel.
  23775. */
  23776. protected _nearestBestKernel(idealKernel: number): number;
  23777. /**
  23778. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23779. * @param x The point on the Gaussian distribution to sample.
  23780. * @return the value of the Gaussian function at x.
  23781. */
  23782. protected _gaussianWeight(x: number): number;
  23783. /**
  23784. * Generates a string that can be used as a floating point number in GLSL.
  23785. * @param x Value to print.
  23786. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23787. * @return GLSL float string.
  23788. */
  23789. protected _glslFloat(x: number, decimalFigures?: number): string;
  23790. /** @hidden */
  23791. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23792. }
  23793. }
  23794. declare module BABYLON {
  23795. /**
  23796. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23797. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23798. * You can then easily use it as a reflectionTexture on a flat surface.
  23799. * In case the surface is not a plane, please consider relying on reflection probes.
  23800. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23801. */
  23802. export class MirrorTexture extends RenderTargetTexture {
  23803. private scene;
  23804. /**
  23805. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23806. * 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.
  23807. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23808. */
  23809. mirrorPlane: Plane;
  23810. /**
  23811. * Define the blur ratio used to blur the reflection if needed.
  23812. */
  23813. set blurRatio(value: number);
  23814. get blurRatio(): number;
  23815. /**
  23816. * Define the adaptive blur kernel used to blur the reflection if needed.
  23817. * This will autocompute the closest best match for the `blurKernel`
  23818. */
  23819. set adaptiveBlurKernel(value: number);
  23820. /**
  23821. * Define the blur kernel used to blur the reflection if needed.
  23822. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23823. */
  23824. set blurKernel(value: number);
  23825. /**
  23826. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23827. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23828. */
  23829. set blurKernelX(value: number);
  23830. get blurKernelX(): number;
  23831. /**
  23832. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23833. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23834. */
  23835. set blurKernelY(value: number);
  23836. get blurKernelY(): number;
  23837. private _autoComputeBlurKernel;
  23838. protected _onRatioRescale(): void;
  23839. private _updateGammaSpace;
  23840. private _imageProcessingConfigChangeObserver;
  23841. private _transformMatrix;
  23842. private _mirrorMatrix;
  23843. private _blurX;
  23844. private _blurY;
  23845. private _adaptiveBlurKernel;
  23846. private _blurKernelX;
  23847. private _blurKernelY;
  23848. private _blurRatio;
  23849. /**
  23850. * Instantiates a Mirror Texture.
  23851. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23852. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23853. * You can then easily use it as a reflectionTexture on a flat surface.
  23854. * In case the surface is not a plane, please consider relying on reflection probes.
  23855. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23856. * @param name
  23857. * @param size
  23858. * @param scene
  23859. * @param generateMipMaps
  23860. * @param type
  23861. * @param samplingMode
  23862. * @param generateDepthBuffer
  23863. */
  23864. constructor(name: string, size: number | {
  23865. width: number;
  23866. height: number;
  23867. } | {
  23868. ratio: number;
  23869. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23870. private _preparePostProcesses;
  23871. /**
  23872. * Clone the mirror texture.
  23873. * @returns the cloned texture
  23874. */
  23875. clone(): MirrorTexture;
  23876. /**
  23877. * Serialize the texture to a JSON representation you could use in Parse later on
  23878. * @returns the serialized JSON representation
  23879. */
  23880. serialize(): any;
  23881. /**
  23882. * Dispose the texture and release its associated resources.
  23883. */
  23884. dispose(): void;
  23885. }
  23886. }
  23887. declare module BABYLON {
  23888. /**
  23889. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23890. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23891. */
  23892. export class Texture extends BaseTexture {
  23893. /**
  23894. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23895. */
  23896. static SerializeBuffers: boolean;
  23897. /**
  23898. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  23899. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  23900. */
  23901. static ForceSerializeBuffers: boolean;
  23902. /** @hidden */
  23903. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23904. /** @hidden */
  23905. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23906. /** @hidden */
  23907. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23908. /** nearest is mag = nearest and min = nearest and mip = linear */
  23909. static readonly NEAREST_SAMPLINGMODE: number;
  23910. /** nearest is mag = nearest and min = nearest and mip = linear */
  23911. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23912. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23913. static readonly BILINEAR_SAMPLINGMODE: number;
  23914. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23915. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23916. /** Trilinear is mag = linear and min = linear and mip = linear */
  23917. static readonly TRILINEAR_SAMPLINGMODE: number;
  23918. /** Trilinear is mag = linear and min = linear and mip = linear */
  23919. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23920. /** mag = nearest and min = nearest and mip = nearest */
  23921. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23922. /** mag = nearest and min = linear and mip = nearest */
  23923. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23924. /** mag = nearest and min = linear and mip = linear */
  23925. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23926. /** mag = nearest and min = linear and mip = none */
  23927. static readonly NEAREST_LINEAR: number;
  23928. /** mag = nearest and min = nearest and mip = none */
  23929. static readonly NEAREST_NEAREST: number;
  23930. /** mag = linear and min = nearest and mip = nearest */
  23931. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23932. /** mag = linear and min = nearest and mip = linear */
  23933. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23934. /** mag = linear and min = linear and mip = none */
  23935. static readonly LINEAR_LINEAR: number;
  23936. /** mag = linear and min = nearest and mip = none */
  23937. static readonly LINEAR_NEAREST: number;
  23938. /** Explicit coordinates mode */
  23939. static readonly EXPLICIT_MODE: number;
  23940. /** Spherical coordinates mode */
  23941. static readonly SPHERICAL_MODE: number;
  23942. /** Planar coordinates mode */
  23943. static readonly PLANAR_MODE: number;
  23944. /** Cubic coordinates mode */
  23945. static readonly CUBIC_MODE: number;
  23946. /** Projection coordinates mode */
  23947. static readonly PROJECTION_MODE: number;
  23948. /** Inverse Cubic coordinates mode */
  23949. static readonly SKYBOX_MODE: number;
  23950. /** Inverse Cubic coordinates mode */
  23951. static readonly INVCUBIC_MODE: number;
  23952. /** Equirectangular coordinates mode */
  23953. static readonly EQUIRECTANGULAR_MODE: number;
  23954. /** Equirectangular Fixed coordinates mode */
  23955. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23956. /** Equirectangular Fixed Mirrored coordinates mode */
  23957. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23958. /** Texture is not repeating outside of 0..1 UVs */
  23959. static readonly CLAMP_ADDRESSMODE: number;
  23960. /** Texture is repeating outside of 0..1 UVs */
  23961. static readonly WRAP_ADDRESSMODE: number;
  23962. /** Texture is repeating and mirrored */
  23963. static readonly MIRROR_ADDRESSMODE: number;
  23964. /**
  23965. * 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
  23966. */
  23967. static UseSerializedUrlIfAny: boolean;
  23968. /**
  23969. * Define the url of the texture.
  23970. */
  23971. url: Nullable<string>;
  23972. /**
  23973. * Define an offset on the texture to offset the u coordinates of the UVs
  23974. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23975. */
  23976. uOffset: number;
  23977. /**
  23978. * Define an offset on the texture to offset the v coordinates of the UVs
  23979. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23980. */
  23981. vOffset: number;
  23982. /**
  23983. * Define an offset on the texture to scale the u coordinates of the UVs
  23984. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23985. */
  23986. uScale: number;
  23987. /**
  23988. * Define an offset on the texture to scale the v coordinates of the UVs
  23989. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23990. */
  23991. vScale: number;
  23992. /**
  23993. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23994. * @see https://doc.babylonjs.com/how_to/more_materials
  23995. */
  23996. uAng: number;
  23997. /**
  23998. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23999. * @see https://doc.babylonjs.com/how_to/more_materials
  24000. */
  24001. vAng: number;
  24002. /**
  24003. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  24004. * @see https://doc.babylonjs.com/how_to/more_materials
  24005. */
  24006. wAng: number;
  24007. /**
  24008. * Defines the center of rotation (U)
  24009. */
  24010. uRotationCenter: number;
  24011. /**
  24012. * Defines the center of rotation (V)
  24013. */
  24014. vRotationCenter: number;
  24015. /**
  24016. * Defines the center of rotation (W)
  24017. */
  24018. wRotationCenter: number;
  24019. /**
  24020. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  24021. */
  24022. homogeneousRotationInUVTransform: boolean;
  24023. /**
  24024. * Are mip maps generated for this texture or not.
  24025. */
  24026. get noMipmap(): boolean;
  24027. /**
  24028. * List of inspectable custom properties (used by the Inspector)
  24029. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24030. */
  24031. inspectableCustomProperties: Nullable<IInspectable[]>;
  24032. private _noMipmap;
  24033. /** @hidden */
  24034. _invertY: boolean;
  24035. private _rowGenerationMatrix;
  24036. private _cachedTextureMatrix;
  24037. private _projectionModeMatrix;
  24038. private _t0;
  24039. private _t1;
  24040. private _t2;
  24041. private _cachedUOffset;
  24042. private _cachedVOffset;
  24043. private _cachedUScale;
  24044. private _cachedVScale;
  24045. private _cachedUAng;
  24046. private _cachedVAng;
  24047. private _cachedWAng;
  24048. private _cachedProjectionMatrixId;
  24049. private _cachedURotationCenter;
  24050. private _cachedVRotationCenter;
  24051. private _cachedWRotationCenter;
  24052. private _cachedHomogeneousRotationInUVTransform;
  24053. private _cachedCoordinatesMode;
  24054. /** @hidden */
  24055. protected _initialSamplingMode: number;
  24056. /** @hidden */
  24057. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24058. private _deleteBuffer;
  24059. protected _format: Nullable<number>;
  24060. private _delayedOnLoad;
  24061. private _delayedOnError;
  24062. private _mimeType?;
  24063. private _loaderOptions?;
  24064. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  24065. get mimeType(): string | undefined;
  24066. /**
  24067. * Observable triggered once the texture has been loaded.
  24068. */
  24069. onLoadObservable: Observable<Texture>;
  24070. protected _isBlocking: boolean;
  24071. /**
  24072. * Is the texture preventing material to render while loading.
  24073. * If false, a default texture will be used instead of the loading one during the preparation step.
  24074. */
  24075. set isBlocking(value: boolean);
  24076. get isBlocking(): boolean;
  24077. /**
  24078. * Get the current sampling mode associated with the texture.
  24079. */
  24080. get samplingMode(): number;
  24081. /**
  24082. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24083. */
  24084. get invertY(): boolean;
  24085. /**
  24086. * Instantiates a new texture.
  24087. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24088. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24089. * @param url defines the url of the picture to load as a texture
  24090. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24091. * @param noMipmap defines if the texture will require mip maps or not
  24092. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24093. * @param samplingMode defines the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
  24094. * @param onLoad defines a callback triggered when the texture has been loaded
  24095. * @param onError defines a callback triggered when an error occurred during the loading session
  24096. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24097. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24098. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24099. * @param mimeType defines an optional mime type information
  24100. * @param loaderOptions options to be passed to the loader
  24101. */
  24102. 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);
  24103. /**
  24104. * Update the url (and optional buffer) of this texture if url was null during construction.
  24105. * @param url the url of the texture
  24106. * @param buffer the buffer of the texture (defaults to null)
  24107. * @param onLoad callback called when the texture is loaded (defaults to null)
  24108. */
  24109. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24110. /**
  24111. * Finish the loading sequence of a texture flagged as delayed load.
  24112. * @hidden
  24113. */
  24114. delayLoad(): void;
  24115. private _prepareRowForTextureGeneration;
  24116. /**
  24117. * Checks if the texture has the same transform matrix than another texture
  24118. * @param texture texture to check against
  24119. * @returns true if the transforms are the same, else false
  24120. */
  24121. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  24122. /**
  24123. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24124. * @returns the transform matrix of the texture.
  24125. */
  24126. getTextureMatrix(uBase?: number): Matrix;
  24127. /**
  24128. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24129. * @returns The reflection texture transform
  24130. */
  24131. getReflectionTextureMatrix(): Matrix;
  24132. /**
  24133. * Clones the texture.
  24134. * @returns the cloned texture
  24135. */
  24136. clone(): Texture;
  24137. /**
  24138. * Serialize the texture to a JSON representation we can easily use in the respective Parse function.
  24139. * @returns The JSON representation of the texture
  24140. */
  24141. serialize(): any;
  24142. /**
  24143. * Get the current class name of the texture useful for serialization or dynamic coding.
  24144. * @returns "Texture"
  24145. */
  24146. getClassName(): string;
  24147. /**
  24148. * Dispose the texture and release its associated resources.
  24149. */
  24150. dispose(): void;
  24151. /**
  24152. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24153. * @param parsedTexture Define the JSON representation of the texture
  24154. * @param scene Define the scene the parsed texture should be instantiated in
  24155. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24156. * @returns The parsed texture if successful
  24157. */
  24158. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24159. /**
  24160. * Creates a texture from its base 64 representation.
  24161. * @param data Define the base64 payload without the data: prefix
  24162. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24163. * @param scene Define the scene the texture should belong to
  24164. * @param noMipmap Forces the texture to not create mip map information if true
  24165. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24166. * @param samplingMode define the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
  24167. * @param onLoad define a callback triggered when the texture has been loaded
  24168. * @param onError define a callback triggered when an error occurred during the loading session
  24169. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24170. * @returns the created texture
  24171. */
  24172. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24173. /**
  24174. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24175. * @param data Define the base64 payload without the data: prefix
  24176. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24177. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24178. * @param scene Define the scene the texture should belong to
  24179. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24180. * @param noMipmap Forces the texture to not create mip map information if true
  24181. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24182. * @param samplingMode define the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
  24183. * @param onLoad define a callback triggered when the texture has been loaded
  24184. * @param onError define a callback triggered when an error occurred during the loading session
  24185. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24186. * @returns the created texture
  24187. */
  24188. 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;
  24189. }
  24190. }
  24191. declare module BABYLON {
  24192. /**
  24193. * ThinSprite Class used to represent a thin sprite
  24194. * This is the base class for sprites but can also directly be used with ThinEngine
  24195. * @see https://doc.babylonjs.com/babylon101/sprites
  24196. */
  24197. export class ThinSprite {
  24198. /** Gets or sets the cell index in the sprite sheet */
  24199. cellIndex: number;
  24200. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  24201. cellRef: string;
  24202. /** Gets or sets the current world position */
  24203. position: IVector3Like;
  24204. /** Gets or sets the main color */
  24205. color: IColor4Like;
  24206. /** Gets or sets the width */
  24207. width: number;
  24208. /** Gets or sets the height */
  24209. height: number;
  24210. /** Gets or sets rotation angle */
  24211. angle: number;
  24212. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  24213. invertU: boolean;
  24214. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  24215. invertV: boolean;
  24216. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  24217. isVisible: boolean;
  24218. /**
  24219. * Returns a boolean indicating if the animation is started
  24220. */
  24221. get animationStarted(): boolean;
  24222. /** Gets the initial key for the animation (setting it will restart the animation) */
  24223. get fromIndex(): number;
  24224. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24225. get toIndex(): number;
  24226. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24227. get loopAnimation(): boolean;
  24228. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24229. get delay(): number;
  24230. /** @hidden */
  24231. _xOffset: number;
  24232. /** @hidden */
  24233. _yOffset: number;
  24234. /** @hidden */
  24235. _xSize: number;
  24236. /** @hidden */
  24237. _ySize: number;
  24238. private _animationStarted;
  24239. protected _loopAnimation: boolean;
  24240. protected _fromIndex: number;
  24241. protected _toIndex: number;
  24242. protected _delay: number;
  24243. private _direction;
  24244. private _time;
  24245. private _onBaseAnimationEnd;
  24246. /**
  24247. * Creates a new Thin Sprite
  24248. */
  24249. constructor();
  24250. /**
  24251. * Starts an animation
  24252. * @param from defines the initial key
  24253. * @param to defines the end key
  24254. * @param loop defines if the animation must loop
  24255. * @param delay defines the start delay (in ms)
  24256. * @param onAnimationEnd defines a callback for when the animation ends
  24257. */
  24258. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  24259. /** Stops current animation (if any) */
  24260. stopAnimation(): void;
  24261. /** @hidden */
  24262. _animate(deltaTime: number): void;
  24263. }
  24264. }
  24265. declare module BABYLON {
  24266. /** @hidden */
  24267. export var imageProcessingCompatibility: {
  24268. name: string;
  24269. shader: string;
  24270. };
  24271. }
  24272. declare module BABYLON {
  24273. /** @hidden */
  24274. export var spritesPixelShader: {
  24275. name: string;
  24276. shader: string;
  24277. };
  24278. }
  24279. declare module BABYLON {
  24280. /** @hidden */
  24281. export var spritesVertexShader: {
  24282. name: string;
  24283. shader: string;
  24284. };
  24285. }
  24286. declare module BABYLON {
  24287. /**
  24288. * Class used to render sprites.
  24289. *
  24290. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  24291. */
  24292. export class SpriteRenderer {
  24293. /**
  24294. * Defines the texture of the spritesheet
  24295. */
  24296. texture: Nullable<ThinTexture>;
  24297. /**
  24298. * Defines the default width of a cell in the spritesheet
  24299. */
  24300. cellWidth: number;
  24301. /**
  24302. * Defines the default height of a cell in the spritesheet
  24303. */
  24304. cellHeight: number;
  24305. /**
  24306. * Blend mode use to render the particle, it can be any of
  24307. * the static Constants.ALPHA_x properties provided in this class.
  24308. * Default value is Constants.ALPHA_COMBINE
  24309. */
  24310. blendMode: number;
  24311. /**
  24312. * Gets or sets a boolean indicating if alpha mode is automatically
  24313. * reset.
  24314. */
  24315. autoResetAlpha: boolean;
  24316. /**
  24317. * Disables writing to the depth buffer when rendering the sprites.
  24318. * It can be handy to disable depth writing when using textures without alpha channel
  24319. * and setting some specific blend modes.
  24320. */
  24321. disableDepthWrite: boolean;
  24322. /**
  24323. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  24324. */
  24325. fogEnabled: boolean;
  24326. /**
  24327. * Gets the capacity of the manager
  24328. */
  24329. get capacity(): number;
  24330. private readonly _engine;
  24331. private readonly _useVAO;
  24332. private readonly _useInstancing;
  24333. private readonly _scene;
  24334. private readonly _capacity;
  24335. private readonly _epsilon;
  24336. private _vertexBufferSize;
  24337. private _vertexData;
  24338. private _buffer;
  24339. private _vertexBuffers;
  24340. private _spriteBuffer;
  24341. private _indexBuffer;
  24342. private _effectBase;
  24343. private _effectFog;
  24344. private _vertexArrayObject;
  24345. /**
  24346. * Creates a new sprite Renderer
  24347. * @param engine defines the engine the renderer works with
  24348. * @param capacity defines the maximum allowed number of sprites
  24349. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24350. * @param scene defines the hosting scene
  24351. */
  24352. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  24353. /**
  24354. * Render all child sprites
  24355. * @param sprites defines the list of sprites to render
  24356. * @param deltaTime defines the time since last frame
  24357. * @param viewMatrix defines the viewMatrix to use to render the sprites
  24358. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  24359. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  24360. */
  24361. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  24362. private _appendSpriteVertex;
  24363. /**
  24364. * Release associated resources
  24365. */
  24366. dispose(): void;
  24367. }
  24368. }
  24369. declare module BABYLON {
  24370. /**
  24371. * Defines the minimum interface to fulfill in order to be a sprite manager.
  24372. */
  24373. export interface ISpriteManager extends IDisposable {
  24374. /**
  24375. * Gets manager's name
  24376. */
  24377. name: string;
  24378. /**
  24379. * Restricts the camera to viewing objects with the same layerMask.
  24380. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  24381. */
  24382. layerMask: number;
  24383. /**
  24384. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24385. */
  24386. isPickable: boolean;
  24387. /**
  24388. * Gets the hosting scene
  24389. */
  24390. scene: Scene;
  24391. /**
  24392. * Specifies the rendering group id for this mesh (0 by default)
  24393. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24394. */
  24395. renderingGroupId: number;
  24396. /**
  24397. * Defines the list of sprites managed by the manager.
  24398. */
  24399. sprites: Array<Sprite>;
  24400. /**
  24401. * Gets or sets the spritesheet texture
  24402. */
  24403. texture: Texture;
  24404. /** Defines the default width of a cell in the spritesheet */
  24405. cellWidth: number;
  24406. /** Defines the default height of a cell in the spritesheet */
  24407. cellHeight: number;
  24408. /**
  24409. * Tests the intersection of a sprite with a specific ray.
  24410. * @param ray The ray we are sending to test the collision
  24411. * @param camera The camera space we are sending rays in
  24412. * @param predicate A predicate allowing excluding sprites from the list of object to test
  24413. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24414. * @returns picking info or null.
  24415. */
  24416. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24417. /**
  24418. * Intersects the sprites with a ray
  24419. * @param ray defines the ray to intersect with
  24420. * @param camera defines the current active camera
  24421. * @param predicate defines a predicate used to select candidate sprites
  24422. * @returns null if no hit or a PickingInfo array
  24423. */
  24424. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24425. /**
  24426. * Renders the list of sprites on screen.
  24427. */
  24428. render(): void;
  24429. }
  24430. /**
  24431. * Class used to manage multiple sprites on the same spritesheet
  24432. * @see https://doc.babylonjs.com/babylon101/sprites
  24433. */
  24434. export class SpriteManager implements ISpriteManager {
  24435. /** defines the manager's name */
  24436. name: string;
  24437. /** Define the Url to load snippets */
  24438. static SnippetUrl: string;
  24439. /** Snippet ID if the manager was created from the snippet server */
  24440. snippetId: string;
  24441. /** Gets the list of sprites */
  24442. sprites: Sprite[];
  24443. /** Gets or sets the rendering group id (0 by default) */
  24444. renderingGroupId: number;
  24445. /** Gets or sets camera layer mask */
  24446. layerMask: number;
  24447. /** Gets or sets a boolean indicating if the sprites are pickable */
  24448. isPickable: boolean;
  24449. /**
  24450. * An event triggered when the manager is disposed.
  24451. */
  24452. onDisposeObservable: Observable<SpriteManager>;
  24453. /**
  24454. * Callback called when the manager is disposed
  24455. */
  24456. set onDispose(callback: () => void);
  24457. /**
  24458. * Gets or sets the unique id of the sprite
  24459. */
  24460. uniqueId: number;
  24461. /**
  24462. * Gets the array of sprites
  24463. */
  24464. get children(): Sprite[];
  24465. /**
  24466. * Gets the hosting scene
  24467. */
  24468. get scene(): Scene;
  24469. /**
  24470. * Gets the capacity of the manager
  24471. */
  24472. get capacity(): number;
  24473. /**
  24474. * Gets or sets the spritesheet texture
  24475. */
  24476. get texture(): Texture;
  24477. set texture(value: Texture);
  24478. /** Defines the default width of a cell in the spritesheet */
  24479. get cellWidth(): number;
  24480. set cellWidth(value: number);
  24481. /** Defines the default height of a cell in the spritesheet */
  24482. get cellHeight(): number;
  24483. set cellHeight(value: number);
  24484. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  24485. get fogEnabled(): boolean;
  24486. set fogEnabled(value: boolean);
  24487. /**
  24488. * Blend mode use to render the particle, it can be any of
  24489. * the static Constants.ALPHA_x properties provided in this class.
  24490. * Default value is Constants.ALPHA_COMBINE
  24491. */
  24492. get blendMode(): number;
  24493. set blendMode(blendMode: number);
  24494. /** Disables writing to the depth buffer when rendering the sprites.
  24495. * It can be handy to disable depth writing when using textures without alpha channel
  24496. * and setting some specific blend modes.
  24497. */
  24498. disableDepthWrite: boolean;
  24499. private _spriteRenderer;
  24500. /** Associative array from JSON sprite data file */
  24501. private _cellData;
  24502. /** Array of sprite names from JSON sprite data file */
  24503. private _spriteMap;
  24504. /** True when packed cell data from JSON file is ready*/
  24505. private _packedAndReady;
  24506. private _textureContent;
  24507. private _onDisposeObserver;
  24508. private _fromPacked;
  24509. private _scene;
  24510. /**
  24511. * Creates a new sprite manager
  24512. * @param name defines the manager's name
  24513. * @param imgUrl defines the sprite sheet url
  24514. * @param capacity defines the maximum allowed number of sprites
  24515. * @param cellSize defines the size of a sprite cell
  24516. * @param scene defines the hosting scene
  24517. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24518. * @param samplingMode defines the sampling mode to use with spritesheet
  24519. * @param fromPacked set to false; do not alter
  24520. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  24521. */
  24522. constructor(
  24523. /** defines the manager's name */
  24524. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  24525. /**
  24526. * Returns the string "SpriteManager"
  24527. * @returns "SpriteManager"
  24528. */
  24529. getClassName(): string;
  24530. private _makePacked;
  24531. private _checkTextureAlpha;
  24532. /**
  24533. * Intersects the sprites with a ray
  24534. * @param ray defines the ray to intersect with
  24535. * @param camera defines the current active camera
  24536. * @param predicate defines a predicate used to select candidate sprites
  24537. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  24538. * @returns null if no hit or a PickingInfo
  24539. */
  24540. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24541. /**
  24542. * Intersects the sprites with a ray
  24543. * @param ray defines the ray to intersect with
  24544. * @param camera defines the current active camera
  24545. * @param predicate defines a predicate used to select candidate sprites
  24546. * @returns null if no hit or a PickingInfo array
  24547. */
  24548. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24549. /**
  24550. * Render all child sprites
  24551. */
  24552. render(): void;
  24553. private _customUpdate;
  24554. /**
  24555. * Release associated resources
  24556. */
  24557. dispose(): void;
  24558. /**
  24559. * Serializes the sprite manager to a JSON object
  24560. * @param serializeTexture defines if the texture must be serialized as well
  24561. * @returns the JSON object
  24562. */
  24563. serialize(serializeTexture?: boolean): any;
  24564. /**
  24565. * Parses a JSON object to create a new sprite manager.
  24566. * @param parsedManager The JSON object to parse
  24567. * @param scene The scene to create the sprite manager
  24568. * @param rootUrl The root url to use to load external dependencies like texture
  24569. * @returns the new sprite manager
  24570. */
  24571. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  24572. /**
  24573. * Creates a sprite manager from a snippet saved in a remote file
  24574. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  24575. * @param url defines the url to load from
  24576. * @param scene defines the hosting scene
  24577. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24578. * @returns a promise that will resolve to the new sprite manager
  24579. */
  24580. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24581. /**
  24582. * Creates a sprite manager from a snippet saved by the sprite editor
  24583. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  24584. * @param scene defines the hosting scene
  24585. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24586. * @returns a promise that will resolve to the new sprite manager
  24587. */
  24588. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24589. }
  24590. }
  24591. declare module BABYLON {
  24592. /**
  24593. * Class used to represent a sprite
  24594. * @see https://doc.babylonjs.com/babylon101/sprites
  24595. */
  24596. export class Sprite extends ThinSprite implements IAnimatable {
  24597. /** defines the name */
  24598. name: string;
  24599. /** Gets or sets the current world position */
  24600. position: Vector3;
  24601. /** Gets or sets the main color */
  24602. color: Color4;
  24603. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  24604. disposeWhenFinishedAnimating: boolean;
  24605. /** Gets the list of attached animations */
  24606. animations: Nullable<Array<Animation>>;
  24607. /** Gets or sets a boolean indicating if the sprite can be picked */
  24608. isPickable: boolean;
  24609. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  24610. useAlphaForPicking: boolean;
  24611. /**
  24612. * Gets or sets the associated action manager
  24613. */
  24614. actionManager: Nullable<ActionManager>;
  24615. /**
  24616. * An event triggered when the control has been disposed
  24617. */
  24618. onDisposeObservable: Observable<Sprite>;
  24619. private _manager;
  24620. private _onAnimationEnd;
  24621. /**
  24622. * Gets or sets the sprite size
  24623. */
  24624. get size(): number;
  24625. set size(value: number);
  24626. /**
  24627. * Gets or sets the unique id of the sprite
  24628. */
  24629. uniqueId: number;
  24630. /**
  24631. * Gets the manager of this sprite
  24632. */
  24633. get manager(): ISpriteManager;
  24634. /**
  24635. * Creates a new Sprite
  24636. * @param name defines the name
  24637. * @param manager defines the manager
  24638. */
  24639. constructor(
  24640. /** defines the name */
  24641. name: string, manager: ISpriteManager);
  24642. /**
  24643. * Returns the string "Sprite"
  24644. * @returns "Sprite"
  24645. */
  24646. getClassName(): string;
  24647. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  24648. get fromIndex(): number;
  24649. set fromIndex(value: number);
  24650. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24651. get toIndex(): number;
  24652. set toIndex(value: number);
  24653. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24654. get loopAnimation(): boolean;
  24655. set loopAnimation(value: boolean);
  24656. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24657. get delay(): number;
  24658. set delay(value: number);
  24659. /**
  24660. * Starts an animation
  24661. * @param from defines the initial key
  24662. * @param to defines the end key
  24663. * @param loop defines if the animation must loop
  24664. * @param delay defines the start delay (in ms)
  24665. * @param onAnimationEnd defines a callback to call when animation ends
  24666. */
  24667. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  24668. private _endAnimation;
  24669. /** Release associated resources */
  24670. dispose(): void;
  24671. /**
  24672. * Serializes the sprite to a JSON object
  24673. * @returns the JSON object
  24674. */
  24675. serialize(): any;
  24676. /**
  24677. * Parses a JSON object to create a new sprite
  24678. * @param parsedSprite The JSON object to parse
  24679. * @param manager defines the hosting manager
  24680. * @returns the new sprite
  24681. */
  24682. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  24683. }
  24684. }
  24685. declare module BABYLON {
  24686. /**
  24687. * Information about the result of picking within a scene
  24688. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24689. */
  24690. export class PickingInfo {
  24691. /** @hidden */
  24692. _pickingUnavailable: boolean;
  24693. /**
  24694. * If the pick collided with an object
  24695. */
  24696. hit: boolean;
  24697. /**
  24698. * Distance away where the pick collided
  24699. */
  24700. distance: number;
  24701. /**
  24702. * The location of pick collision
  24703. */
  24704. pickedPoint: Nullable<Vector3>;
  24705. /**
  24706. * The mesh corresponding the the pick collision
  24707. */
  24708. pickedMesh: Nullable<AbstractMesh>;
  24709. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  24710. bu: number;
  24711. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  24712. bv: number;
  24713. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24714. faceId: number;
  24715. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24716. subMeshFaceId: number;
  24717. /** Id of the the submesh that was picked */
  24718. subMeshId: number;
  24719. /** If a sprite was picked, this will be the sprite the pick collided with */
  24720. pickedSprite: Nullable<Sprite>;
  24721. /** If we are picking a mesh with thin instance, this will give you the picked thin instance */
  24722. thinInstanceIndex: number;
  24723. /**
  24724. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24725. */
  24726. originMesh: Nullable<AbstractMesh>;
  24727. /**
  24728. * The ray that was used to perform the picking.
  24729. */
  24730. ray: Nullable<Ray>;
  24731. /**
  24732. * Gets the normal corresponding to the face the pick collided with
  24733. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  24734. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  24735. * @returns The normal corresponding to the face the pick collided with
  24736. */
  24737. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  24738. /**
  24739. * Gets the texture coordinates of where the pick occurred
  24740. * @returns the vector containing the coordinates of the texture
  24741. */
  24742. getTextureCoordinates(): Nullable<Vector2>;
  24743. }
  24744. }
  24745. declare module BABYLON {
  24746. /**
  24747. * Gather the list of pointer event types as constants.
  24748. */
  24749. export class PointerEventTypes {
  24750. /**
  24751. * 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.
  24752. */
  24753. static readonly POINTERDOWN: number;
  24754. /**
  24755. * The pointerup event is fired when a pointer is no longer active.
  24756. */
  24757. static readonly POINTERUP: number;
  24758. /**
  24759. * The pointermove event is fired when a pointer changes coordinates.
  24760. */
  24761. static readonly POINTERMOVE: number;
  24762. /**
  24763. * The pointerwheel event is fired when a mouse wheel has been rotated.
  24764. */
  24765. static readonly POINTERWHEEL: number;
  24766. /**
  24767. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  24768. */
  24769. static readonly POINTERPICK: number;
  24770. /**
  24771. * The pointertap event is fired when a the object has been touched and released without drag.
  24772. */
  24773. static readonly POINTERTAP: number;
  24774. /**
  24775. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  24776. */
  24777. static readonly POINTERDOUBLETAP: number;
  24778. }
  24779. /**
  24780. * Base class of pointer info types.
  24781. */
  24782. export class PointerInfoBase {
  24783. /**
  24784. * Defines the type of event (PointerEventTypes)
  24785. */
  24786. type: number;
  24787. /**
  24788. * Defines the related dom event
  24789. */
  24790. event: PointerEvent | MouseWheelEvent;
  24791. /**
  24792. * Instantiates the base class of pointers info.
  24793. * @param type Defines the type of event (PointerEventTypes)
  24794. * @param event Defines the related dom event
  24795. */
  24796. constructor(
  24797. /**
  24798. * Defines the type of event (PointerEventTypes)
  24799. */
  24800. type: number,
  24801. /**
  24802. * Defines the related dom event
  24803. */
  24804. event: PointerEvent | MouseWheelEvent);
  24805. }
  24806. /**
  24807. * This class is used to store pointer related info for the onPrePointerObservable event.
  24808. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  24809. */
  24810. export class PointerInfoPre extends PointerInfoBase {
  24811. /**
  24812. * Ray from a pointer if availible (eg. 6dof controller)
  24813. */
  24814. ray: Nullable<Ray>;
  24815. /**
  24816. * Defines the local position of the pointer on the canvas.
  24817. */
  24818. localPosition: Vector2;
  24819. /**
  24820. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  24821. */
  24822. skipOnPointerObservable: boolean;
  24823. /**
  24824. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  24825. * @param type Defines the type of event (PointerEventTypes)
  24826. * @param event Defines the related dom event
  24827. * @param localX Defines the local x coordinates of the pointer when the event occured
  24828. * @param localY Defines the local y coordinates of the pointer when the event occured
  24829. */
  24830. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  24831. }
  24832. /**
  24833. * This type contains all the data related to a pointer event in Babylon.js.
  24834. * 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.
  24835. */
  24836. export class PointerInfo extends PointerInfoBase {
  24837. /**
  24838. * Defines the picking info associated to the info (if any)\
  24839. */
  24840. pickInfo: Nullable<PickingInfo>;
  24841. /**
  24842. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  24843. * @param type Defines the type of event (PointerEventTypes)
  24844. * @param event Defines the related dom event
  24845. * @param pickInfo Defines the picking info associated to the info (if any)\
  24846. */
  24847. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  24848. /**
  24849. * Defines the picking info associated to the info (if any)\
  24850. */
  24851. pickInfo: Nullable<PickingInfo>);
  24852. }
  24853. /**
  24854. * Data relating to a touch event on the screen.
  24855. */
  24856. export interface PointerTouch {
  24857. /**
  24858. * X coordinate of touch.
  24859. */
  24860. x: number;
  24861. /**
  24862. * Y coordinate of touch.
  24863. */
  24864. y: number;
  24865. /**
  24866. * Id of touch. Unique for each finger.
  24867. */
  24868. pointerId: number;
  24869. /**
  24870. * Event type passed from DOM.
  24871. */
  24872. type: any;
  24873. }
  24874. }
  24875. declare module BABYLON {
  24876. /**
  24877. * Manage the mouse inputs to control the movement of a free camera.
  24878. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24879. */
  24880. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  24881. /**
  24882. * Define if touch is enabled in the mouse input
  24883. */
  24884. touchEnabled: boolean;
  24885. /**
  24886. * Defines the camera the input is attached to.
  24887. */
  24888. camera: FreeCamera;
  24889. /**
  24890. * Defines the buttons associated with the input to handle camera move.
  24891. */
  24892. buttons: number[];
  24893. /**
  24894. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  24895. */
  24896. angularSensibility: number;
  24897. private _pointerInput;
  24898. private _onMouseMove;
  24899. private _observer;
  24900. private previousPosition;
  24901. /**
  24902. * Observable for when a pointer move event occurs containing the move offset
  24903. */
  24904. onPointerMovedObservable: Observable<{
  24905. offsetX: number;
  24906. offsetY: number;
  24907. }>;
  24908. /**
  24909. * @hidden
  24910. * If the camera should be rotated automatically based on pointer movement
  24911. */
  24912. _allowCameraRotation: boolean;
  24913. /**
  24914. * Manage the mouse inputs to control the movement of a free camera.
  24915. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24916. * @param touchEnabled Defines if touch is enabled or not
  24917. */
  24918. constructor(
  24919. /**
  24920. * Define if touch is enabled in the mouse input
  24921. */
  24922. touchEnabled?: boolean);
  24923. /**
  24924. * Attach the input controls to a specific dom element to get the input from.
  24925. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24926. */
  24927. attachControl(noPreventDefault?: boolean): void;
  24928. /**
  24929. * Called on JS contextmenu event.
  24930. * Override this method to provide functionality.
  24931. */
  24932. protected onContextMenu(evt: PointerEvent): void;
  24933. /**
  24934. * Detach the current controls from the specified dom element.
  24935. */
  24936. detachControl(): void;
  24937. /**
  24938. * Gets the class name of the current input.
  24939. * @returns the class name
  24940. */
  24941. getClassName(): string;
  24942. /**
  24943. * Get the friendly name associated with the input class.
  24944. * @returns the input friendly name
  24945. */
  24946. getSimpleName(): string;
  24947. }
  24948. }
  24949. declare module BABYLON {
  24950. /**
  24951. * Base class for mouse wheel input..
  24952. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  24953. * for example usage.
  24954. */
  24955. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  24956. /**
  24957. * Defines the camera the input is attached to.
  24958. */
  24959. abstract camera: Camera;
  24960. /**
  24961. * How fast is the camera moves in relation to X axis mouseWheel events.
  24962. * Use negative value to reverse direction.
  24963. */
  24964. wheelPrecisionX: number;
  24965. /**
  24966. * How fast is the camera moves in relation to Y axis mouseWheel events.
  24967. * Use negative value to reverse direction.
  24968. */
  24969. wheelPrecisionY: number;
  24970. /**
  24971. * How fast is the camera moves in relation to Z axis mouseWheel events.
  24972. * Use negative value to reverse direction.
  24973. */
  24974. wheelPrecisionZ: number;
  24975. /**
  24976. * Observable for when a mouse wheel move event occurs.
  24977. */
  24978. onChangedObservable: Observable<{
  24979. wheelDeltaX: number;
  24980. wheelDeltaY: number;
  24981. wheelDeltaZ: number;
  24982. }>;
  24983. private _wheel;
  24984. private _observer;
  24985. /**
  24986. * Attach the input controls to a specific dom element to get the input from.
  24987. * @param noPreventDefault Defines whether event caught by the controls
  24988. * should call preventdefault().
  24989. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24990. */
  24991. attachControl(noPreventDefault?: boolean): void;
  24992. /**
  24993. * Detach the current controls from the specified dom element.
  24994. */
  24995. detachControl(): void;
  24996. /**
  24997. * Called for each rendered frame.
  24998. */
  24999. checkInputs(): void;
  25000. /**
  25001. * Gets the class name of the current input.
  25002. * @returns the class name
  25003. */
  25004. getClassName(): string;
  25005. /**
  25006. * Get the friendly name associated with the input class.
  25007. * @returns the input friendly name
  25008. */
  25009. getSimpleName(): string;
  25010. /**
  25011. * Incremental value of multiple mouse wheel movements of the X axis.
  25012. * Should be zero-ed when read.
  25013. */
  25014. protected _wheelDeltaX: number;
  25015. /**
  25016. * Incremental value of multiple mouse wheel movements of the Y axis.
  25017. * Should be zero-ed when read.
  25018. */
  25019. protected _wheelDeltaY: number;
  25020. /**
  25021. * Incremental value of multiple mouse wheel movements of the Z axis.
  25022. * Should be zero-ed when read.
  25023. */
  25024. protected _wheelDeltaZ: number;
  25025. /**
  25026. * Firefox uses a different scheme to report scroll distances to other
  25027. * browsers. Rather than use complicated methods to calculate the exact
  25028. * multiple we need to apply, let's just cheat and use a constant.
  25029. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  25030. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  25031. */
  25032. private readonly _ffMultiplier;
  25033. /**
  25034. * Different event attributes for wheel data fall into a few set ranges.
  25035. * Some relevant but dated date here:
  25036. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  25037. */
  25038. private readonly _normalize;
  25039. }
  25040. }
  25041. declare module BABYLON {
  25042. /**
  25043. * Manage the mouse wheel inputs to control a free camera.
  25044. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25045. */
  25046. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  25047. /**
  25048. * Defines the camera the input is attached to.
  25049. */
  25050. camera: FreeCamera;
  25051. /**
  25052. * Gets the class name of the current input.
  25053. * @returns the class name
  25054. */
  25055. getClassName(): string;
  25056. /**
  25057. * Set which movement axis (relative to camera's orientation) the mouse
  25058. * wheel's X axis controls.
  25059. * @param axis The axis to be moved. Set null to clear.
  25060. */
  25061. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  25062. /**
  25063. * Get the configured movement axis (relative to camera's orientation) the
  25064. * mouse wheel's X axis controls.
  25065. * @returns The configured axis or null if none.
  25066. */
  25067. get wheelXMoveRelative(): Nullable<Coordinate>;
  25068. /**
  25069. * Set which movement axis (relative to camera's orientation) the mouse
  25070. * wheel's Y axis controls.
  25071. * @param axis The axis to be moved. Set null to clear.
  25072. */
  25073. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  25074. /**
  25075. * Get the configured movement axis (relative to camera's orientation) the
  25076. * mouse wheel's Y axis controls.
  25077. * @returns The configured axis or null if none.
  25078. */
  25079. get wheelYMoveRelative(): Nullable<Coordinate>;
  25080. /**
  25081. * Set which movement axis (relative to camera's orientation) the mouse
  25082. * wheel's Z axis controls.
  25083. * @param axis The axis to be moved. Set null to clear.
  25084. */
  25085. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  25086. /**
  25087. * Get the configured movement axis (relative to camera's orientation) the
  25088. * mouse wheel's Z axis controls.
  25089. * @returns The configured axis or null if none.
  25090. */
  25091. get wheelZMoveRelative(): Nullable<Coordinate>;
  25092. /**
  25093. * Set which rotation axis (relative to camera's orientation) the mouse
  25094. * wheel's X axis controls.
  25095. * @param axis The axis to be moved. Set null to clear.
  25096. */
  25097. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  25098. /**
  25099. * Get the configured rotation axis (relative to camera's orientation) the
  25100. * mouse wheel's X axis controls.
  25101. * @returns The configured axis or null if none.
  25102. */
  25103. get wheelXRotateRelative(): Nullable<Coordinate>;
  25104. /**
  25105. * Set which rotation axis (relative to camera's orientation) the mouse
  25106. * wheel's Y axis controls.
  25107. * @param axis The axis to be moved. Set null to clear.
  25108. */
  25109. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  25110. /**
  25111. * Get the configured rotation axis (relative to camera's orientation) the
  25112. * mouse wheel's Y axis controls.
  25113. * @returns The configured axis or null if none.
  25114. */
  25115. get wheelYRotateRelative(): Nullable<Coordinate>;
  25116. /**
  25117. * Set which rotation axis (relative to camera's orientation) the mouse
  25118. * wheel's Z axis controls.
  25119. * @param axis The axis to be moved. Set null to clear.
  25120. */
  25121. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  25122. /**
  25123. * Get the configured rotation axis (relative to camera's orientation) the
  25124. * mouse wheel's Z axis controls.
  25125. * @returns The configured axis or null if none.
  25126. */
  25127. get wheelZRotateRelative(): Nullable<Coordinate>;
  25128. /**
  25129. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  25130. * controls.
  25131. * @param axis The axis to be moved. Set null to clear.
  25132. */
  25133. set wheelXMoveScene(axis: Nullable<Coordinate>);
  25134. /**
  25135. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25136. * X axis controls.
  25137. * @returns The configured axis or null if none.
  25138. */
  25139. get wheelXMoveScene(): Nullable<Coordinate>;
  25140. /**
  25141. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  25142. * controls.
  25143. * @param axis The axis to be moved. Set null to clear.
  25144. */
  25145. set wheelYMoveScene(axis: Nullable<Coordinate>);
  25146. /**
  25147. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25148. * Y axis controls.
  25149. * @returns The configured axis or null if none.
  25150. */
  25151. get wheelYMoveScene(): Nullable<Coordinate>;
  25152. /**
  25153. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  25154. * controls.
  25155. * @param axis The axis to be moved. Set null to clear.
  25156. */
  25157. set wheelZMoveScene(axis: Nullable<Coordinate>);
  25158. /**
  25159. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25160. * Z axis controls.
  25161. * @returns The configured axis or null if none.
  25162. */
  25163. get wheelZMoveScene(): Nullable<Coordinate>;
  25164. /**
  25165. * Called for each rendered frame.
  25166. */
  25167. checkInputs(): void;
  25168. private _moveRelative;
  25169. private _rotateRelative;
  25170. private _moveScene;
  25171. /**
  25172. * These are set to the desired default behaviour.
  25173. */
  25174. private _wheelXAction;
  25175. private _wheelXActionCoordinate;
  25176. private _wheelYAction;
  25177. private _wheelYActionCoordinate;
  25178. private _wheelZAction;
  25179. private _wheelZActionCoordinate;
  25180. /**
  25181. * Update the camera according to any configured properties for the 3
  25182. * mouse-wheel axis.
  25183. */
  25184. private _updateCamera;
  25185. /**
  25186. * Update one property of the camera.
  25187. */
  25188. private _updateCameraProperty;
  25189. }
  25190. }
  25191. declare module BABYLON {
  25192. /**
  25193. * Manage the touch inputs to control the movement of a free camera.
  25194. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25195. */
  25196. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  25197. /**
  25198. * Define if mouse events can be treated as touch events
  25199. */
  25200. allowMouse: boolean;
  25201. /**
  25202. * Defines the camera the input is attached to.
  25203. */
  25204. camera: FreeCamera;
  25205. /**
  25206. * Defines the touch sensibility for rotation.
  25207. * The higher the faster.
  25208. */
  25209. touchAngularSensibility: number;
  25210. /**
  25211. * Defines the touch sensibility for move.
  25212. * The higher the faster.
  25213. */
  25214. touchMoveSensibility: number;
  25215. private _offsetX;
  25216. private _offsetY;
  25217. private _pointerPressed;
  25218. private _pointerInput?;
  25219. private _observer;
  25220. private _onLostFocus;
  25221. /**
  25222. * Manage the touch inputs to control the movement of a free camera.
  25223. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25224. * @param allowMouse Defines if mouse events can be treated as touch events
  25225. */
  25226. constructor(
  25227. /**
  25228. * Define if mouse events can be treated as touch events
  25229. */
  25230. allowMouse?: boolean);
  25231. /**
  25232. * Attach the input controls to a specific dom element to get the input from.
  25233. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25234. */
  25235. attachControl(noPreventDefault?: boolean): void;
  25236. /**
  25237. * Detach the current controls from the specified dom element.
  25238. */
  25239. detachControl(): void;
  25240. /**
  25241. * Update the current camera state depending on the inputs that have been used this frame.
  25242. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  25243. */
  25244. checkInputs(): void;
  25245. /**
  25246. * Gets the class name of the current input.
  25247. * @returns the class name
  25248. */
  25249. getClassName(): string;
  25250. /**
  25251. * Get the friendly name associated with the input class.
  25252. * @returns the input friendly name
  25253. */
  25254. getSimpleName(): string;
  25255. }
  25256. }
  25257. declare module BABYLON {
  25258. /**
  25259. * Default Inputs manager for the FreeCamera.
  25260. * It groups all the default supported inputs for ease of use.
  25261. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25262. */
  25263. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  25264. /**
  25265. * @hidden
  25266. */
  25267. _mouseInput: Nullable<FreeCameraMouseInput>;
  25268. /**
  25269. * @hidden
  25270. */
  25271. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  25272. /**
  25273. * Instantiates a new FreeCameraInputsManager.
  25274. * @param camera Defines the camera the inputs belong to
  25275. */
  25276. constructor(camera: FreeCamera);
  25277. /**
  25278. * Add keyboard input support to the input manager.
  25279. * @returns the current input manager
  25280. */
  25281. addKeyboard(): FreeCameraInputsManager;
  25282. /**
  25283. * Add mouse input support to the input manager.
  25284. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  25285. * @returns the current input manager
  25286. */
  25287. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  25288. /**
  25289. * Removes the mouse input support from the manager
  25290. * @returns the current input manager
  25291. */
  25292. removeMouse(): FreeCameraInputsManager;
  25293. /**
  25294. * Add mouse wheel input support to the input manager.
  25295. * @returns the current input manager
  25296. */
  25297. addMouseWheel(): FreeCameraInputsManager;
  25298. /**
  25299. * Removes the mouse wheel input support from the manager
  25300. * @returns the current input manager
  25301. */
  25302. removeMouseWheel(): FreeCameraInputsManager;
  25303. /**
  25304. * Add touch input support to the input manager.
  25305. * @returns the current input manager
  25306. */
  25307. addTouch(): FreeCameraInputsManager;
  25308. /**
  25309. * Remove all attached input methods from a camera
  25310. */
  25311. clear(): void;
  25312. }
  25313. }
  25314. declare module BABYLON {
  25315. /**
  25316. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25317. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  25318. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25319. */
  25320. export class FreeCamera extends TargetCamera {
  25321. /**
  25322. * Define the collision ellipsoid of the camera.
  25323. * This is helpful to simulate a camera body like the player body around the camera
  25324. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  25325. */
  25326. ellipsoid: Vector3;
  25327. /**
  25328. * Define an offset for the position of the ellipsoid around the camera.
  25329. * This can be helpful to determine the center of the body near the gravity center of the body
  25330. * instead of its head.
  25331. */
  25332. ellipsoidOffset: Vector3;
  25333. /**
  25334. * Enable or disable collisions of the camera with the rest of the scene objects.
  25335. */
  25336. checkCollisions: boolean;
  25337. /**
  25338. * Enable or disable gravity on the camera.
  25339. */
  25340. applyGravity: boolean;
  25341. /**
  25342. * Define the input manager associated to the camera.
  25343. */
  25344. inputs: FreeCameraInputsManager;
  25345. /**
  25346. * Gets the input sensibility for a mouse input. (default is 2000.0)
  25347. * Higher values reduce sensitivity.
  25348. */
  25349. get angularSensibility(): number;
  25350. /**
  25351. * Sets the input sensibility for a mouse input. (default is 2000.0)
  25352. * Higher values reduce sensitivity.
  25353. */
  25354. set angularSensibility(value: number);
  25355. /**
  25356. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  25357. */
  25358. get keysUp(): number[];
  25359. set keysUp(value: number[]);
  25360. /**
  25361. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  25362. */
  25363. get keysUpward(): number[];
  25364. set keysUpward(value: number[]);
  25365. /**
  25366. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  25367. */
  25368. get keysDown(): number[];
  25369. set keysDown(value: number[]);
  25370. /**
  25371. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  25372. */
  25373. get keysDownward(): number[];
  25374. set keysDownward(value: number[]);
  25375. /**
  25376. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  25377. */
  25378. get keysLeft(): number[];
  25379. set keysLeft(value: number[]);
  25380. /**
  25381. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  25382. */
  25383. get keysRight(): number[];
  25384. set keysRight(value: number[]);
  25385. /**
  25386. * Event raised when the camera collide with a mesh in the scene.
  25387. */
  25388. onCollide: (collidedMesh: AbstractMesh) => void;
  25389. private _collider;
  25390. private _needMoveForGravity;
  25391. private _oldPosition;
  25392. private _diffPosition;
  25393. private _newPosition;
  25394. /** @hidden */
  25395. _localDirection: Vector3;
  25396. /** @hidden */
  25397. _transformedDirection: Vector3;
  25398. /**
  25399. * Instantiates a Free Camera.
  25400. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25401. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  25402. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25403. * @param name Define the name of the camera in the scene
  25404. * @param position Define the start position of the camera in the scene
  25405. * @param scene Define the scene the camera belongs to
  25406. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  25407. */
  25408. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25409. /**
  25410. * Attach the input controls to a specific dom element to get the input from.
  25411. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25412. */
  25413. attachControl(noPreventDefault?: boolean): void;
  25414. /**
  25415. * Attach the input controls to a specific dom element to get the input from.
  25416. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  25417. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25418. * BACK COMPAT SIGNATURE ONLY.
  25419. */
  25420. attachControl(ignored: any, noPreventDefault?: boolean): void;
  25421. /**
  25422. * Detach the current controls from the specified dom element.
  25423. */
  25424. detachControl(): void;
  25425. /**
  25426. * Detach the current controls from the specified dom element.
  25427. * @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
  25428. */
  25429. detachControl(ignored: any): void;
  25430. private _collisionMask;
  25431. /**
  25432. * Define a collision mask to limit the list of object the camera can collide with
  25433. */
  25434. get collisionMask(): number;
  25435. set collisionMask(mask: number);
  25436. /** @hidden */
  25437. _collideWithWorld(displacement: Vector3): void;
  25438. private _onCollisionPositionChange;
  25439. /** @hidden */
  25440. _checkInputs(): void;
  25441. /** @hidden */
  25442. _decideIfNeedsToMove(): boolean;
  25443. /** @hidden */
  25444. _updatePosition(): void;
  25445. /**
  25446. * Destroy the camera and release the current resources hold by it.
  25447. */
  25448. dispose(): void;
  25449. /**
  25450. * Gets the current object class name.
  25451. * @return the class name
  25452. */
  25453. getClassName(): string;
  25454. }
  25455. }
  25456. declare module BABYLON {
  25457. /**
  25458. * Represents a gamepad control stick position
  25459. */
  25460. export class StickValues {
  25461. /**
  25462. * The x component of the control stick
  25463. */
  25464. x: number;
  25465. /**
  25466. * The y component of the control stick
  25467. */
  25468. y: number;
  25469. /**
  25470. * Initializes the gamepad x and y control stick values
  25471. * @param x The x component of the gamepad control stick value
  25472. * @param y The y component of the gamepad control stick value
  25473. */
  25474. constructor(
  25475. /**
  25476. * The x component of the control stick
  25477. */
  25478. x: number,
  25479. /**
  25480. * The y component of the control stick
  25481. */
  25482. y: number);
  25483. }
  25484. /**
  25485. * An interface which manages callbacks for gamepad button changes
  25486. */
  25487. export interface GamepadButtonChanges {
  25488. /**
  25489. * Called when a gamepad has been changed
  25490. */
  25491. changed: boolean;
  25492. /**
  25493. * Called when a gamepad press event has been triggered
  25494. */
  25495. pressChanged: boolean;
  25496. /**
  25497. * Called when a touch event has been triggered
  25498. */
  25499. touchChanged: boolean;
  25500. /**
  25501. * Called when a value has changed
  25502. */
  25503. valueChanged: boolean;
  25504. }
  25505. /**
  25506. * Represents a gamepad
  25507. */
  25508. export class Gamepad {
  25509. /**
  25510. * The id of the gamepad
  25511. */
  25512. id: string;
  25513. /**
  25514. * The index of the gamepad
  25515. */
  25516. index: number;
  25517. /**
  25518. * The browser gamepad
  25519. */
  25520. browserGamepad: any;
  25521. /**
  25522. * Specifies what type of gamepad this represents
  25523. */
  25524. type: number;
  25525. private _leftStick;
  25526. private _rightStick;
  25527. /** @hidden */
  25528. _isConnected: boolean;
  25529. private _leftStickAxisX;
  25530. private _leftStickAxisY;
  25531. private _rightStickAxisX;
  25532. private _rightStickAxisY;
  25533. /**
  25534. * Triggered when the left control stick has been changed
  25535. */
  25536. private _onleftstickchanged;
  25537. /**
  25538. * Triggered when the right control stick has been changed
  25539. */
  25540. private _onrightstickchanged;
  25541. /**
  25542. * Represents a gamepad controller
  25543. */
  25544. static GAMEPAD: number;
  25545. /**
  25546. * Represents a generic controller
  25547. */
  25548. static GENERIC: number;
  25549. /**
  25550. * Represents an XBox controller
  25551. */
  25552. static XBOX: number;
  25553. /**
  25554. * Represents a pose-enabled controller
  25555. */
  25556. static POSE_ENABLED: number;
  25557. /**
  25558. * Represents an Dual Shock controller
  25559. */
  25560. static DUALSHOCK: number;
  25561. /**
  25562. * Specifies whether the left control stick should be Y-inverted
  25563. */
  25564. protected _invertLeftStickY: boolean;
  25565. /**
  25566. * Specifies if the gamepad has been connected
  25567. */
  25568. get isConnected(): boolean;
  25569. /**
  25570. * Initializes the gamepad
  25571. * @param id The id of the gamepad
  25572. * @param index The index of the gamepad
  25573. * @param browserGamepad The browser gamepad
  25574. * @param leftStickX The x component of the left joystick
  25575. * @param leftStickY The y component of the left joystick
  25576. * @param rightStickX The x component of the right joystick
  25577. * @param rightStickY The y component of the right joystick
  25578. */
  25579. constructor(
  25580. /**
  25581. * The id of the gamepad
  25582. */
  25583. id: string,
  25584. /**
  25585. * The index of the gamepad
  25586. */
  25587. index: number,
  25588. /**
  25589. * The browser gamepad
  25590. */
  25591. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  25592. /**
  25593. * Callback triggered when the left joystick has changed
  25594. * @param callback
  25595. */
  25596. onleftstickchanged(callback: (values: StickValues) => void): void;
  25597. /**
  25598. * Callback triggered when the right joystick has changed
  25599. * @param callback
  25600. */
  25601. onrightstickchanged(callback: (values: StickValues) => void): void;
  25602. /**
  25603. * Gets the left joystick
  25604. */
  25605. get leftStick(): StickValues;
  25606. /**
  25607. * Sets the left joystick values
  25608. */
  25609. set leftStick(newValues: StickValues);
  25610. /**
  25611. * Gets the right joystick
  25612. */
  25613. get rightStick(): StickValues;
  25614. /**
  25615. * Sets the right joystick value
  25616. */
  25617. set rightStick(newValues: StickValues);
  25618. /**
  25619. * Updates the gamepad joystick positions
  25620. */
  25621. update(): void;
  25622. /**
  25623. * Disposes the gamepad
  25624. */
  25625. dispose(): void;
  25626. }
  25627. /**
  25628. * Represents a generic gamepad
  25629. */
  25630. export class GenericPad extends Gamepad {
  25631. private _buttons;
  25632. private _onbuttondown;
  25633. private _onbuttonup;
  25634. /**
  25635. * Observable triggered when a button has been pressed
  25636. */
  25637. onButtonDownObservable: Observable<number>;
  25638. /**
  25639. * Observable triggered when a button has been released
  25640. */
  25641. onButtonUpObservable: Observable<number>;
  25642. /**
  25643. * Callback triggered when a button has been pressed
  25644. * @param callback Called when a button has been pressed
  25645. */
  25646. onbuttondown(callback: (buttonPressed: number) => void): void;
  25647. /**
  25648. * Callback triggered when a button has been released
  25649. * @param callback Called when a button has been released
  25650. */
  25651. onbuttonup(callback: (buttonReleased: number) => void): void;
  25652. /**
  25653. * Initializes the generic gamepad
  25654. * @param id The id of the generic gamepad
  25655. * @param index The index of the generic gamepad
  25656. * @param browserGamepad The browser gamepad
  25657. */
  25658. constructor(id: string, index: number, browserGamepad: any);
  25659. private _setButtonValue;
  25660. /**
  25661. * Updates the generic gamepad
  25662. */
  25663. update(): void;
  25664. /**
  25665. * Disposes the generic gamepad
  25666. */
  25667. dispose(): void;
  25668. }
  25669. }
  25670. declare module BABYLON {
  25671. /**
  25672. * Defines a runtime animation
  25673. */
  25674. export class RuntimeAnimation {
  25675. private _events;
  25676. /**
  25677. * The current frame of the runtime animation
  25678. */
  25679. private _currentFrame;
  25680. /**
  25681. * The animation used by the runtime animation
  25682. */
  25683. private _animation;
  25684. /**
  25685. * The target of the runtime animation
  25686. */
  25687. private _target;
  25688. /**
  25689. * The initiating animatable
  25690. */
  25691. private _host;
  25692. /**
  25693. * The original value of the runtime animation
  25694. */
  25695. private _originalValue;
  25696. /**
  25697. * The original blend value of the runtime animation
  25698. */
  25699. private _originalBlendValue;
  25700. /**
  25701. * The offsets cache of the runtime animation
  25702. */
  25703. private _offsetsCache;
  25704. /**
  25705. * The high limits cache of the runtime animation
  25706. */
  25707. private _highLimitsCache;
  25708. /**
  25709. * Specifies if the runtime animation has been stopped
  25710. */
  25711. private _stopped;
  25712. /**
  25713. * The blending factor of the runtime animation
  25714. */
  25715. private _blendingFactor;
  25716. /**
  25717. * The BabylonJS scene
  25718. */
  25719. private _scene;
  25720. /**
  25721. * The current value of the runtime animation
  25722. */
  25723. private _currentValue;
  25724. /** @hidden */
  25725. _animationState: _IAnimationState;
  25726. /**
  25727. * The active target of the runtime animation
  25728. */
  25729. private _activeTargets;
  25730. private _currentActiveTarget;
  25731. private _directTarget;
  25732. /**
  25733. * The target path of the runtime animation
  25734. */
  25735. private _targetPath;
  25736. /**
  25737. * The weight of the runtime animation
  25738. */
  25739. private _weight;
  25740. /**
  25741. * The ratio offset of the runtime animation
  25742. */
  25743. private _ratioOffset;
  25744. /**
  25745. * The previous delay of the runtime animation
  25746. */
  25747. private _previousDelay;
  25748. /**
  25749. * The previous ratio of the runtime animation
  25750. */
  25751. private _previousRatio;
  25752. private _enableBlending;
  25753. private _keys;
  25754. private _minFrame;
  25755. private _maxFrame;
  25756. private _minValue;
  25757. private _maxValue;
  25758. private _targetIsArray;
  25759. /**
  25760. * Gets the current frame of the runtime animation
  25761. */
  25762. get currentFrame(): number;
  25763. /**
  25764. * Gets the weight of the runtime animation
  25765. */
  25766. get weight(): number;
  25767. /**
  25768. * Gets the current value of the runtime animation
  25769. */
  25770. get currentValue(): any;
  25771. /**
  25772. * Gets the target path of the runtime animation
  25773. */
  25774. get targetPath(): string;
  25775. /**
  25776. * Gets the actual target of the runtime animation
  25777. */
  25778. get target(): any;
  25779. /**
  25780. * Gets the additive state of the runtime animation
  25781. */
  25782. get isAdditive(): boolean;
  25783. /** @hidden */
  25784. _onLoop: () => void;
  25785. /**
  25786. * Create a new RuntimeAnimation object
  25787. * @param target defines the target of the animation
  25788. * @param animation defines the source animation object
  25789. * @param scene defines the hosting scene
  25790. * @param host defines the initiating Animatable
  25791. */
  25792. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  25793. private _preparePath;
  25794. /**
  25795. * Gets the animation from the runtime animation
  25796. */
  25797. get animation(): Animation;
  25798. /**
  25799. * Resets the runtime animation to the beginning
  25800. * @param restoreOriginal defines whether to restore the target property to the original value
  25801. */
  25802. reset(restoreOriginal?: boolean): void;
  25803. /**
  25804. * Specifies if the runtime animation is stopped
  25805. * @returns Boolean specifying if the runtime animation is stopped
  25806. */
  25807. isStopped(): boolean;
  25808. /**
  25809. * Disposes of the runtime animation
  25810. */
  25811. dispose(): void;
  25812. /**
  25813. * Apply the interpolated value to the target
  25814. * @param currentValue defines the value computed by the animation
  25815. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  25816. */
  25817. setValue(currentValue: any, weight: number): void;
  25818. private _getOriginalValues;
  25819. private _setValue;
  25820. /**
  25821. * Gets the loop pmode of the runtime animation
  25822. * @returns Loop Mode
  25823. */
  25824. private _getCorrectLoopMode;
  25825. /**
  25826. * Move the current animation to a given frame
  25827. * @param frame defines the frame to move to
  25828. */
  25829. goToFrame(frame: number): void;
  25830. /**
  25831. * @hidden Internal use only
  25832. */
  25833. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  25834. /**
  25835. * Execute the current animation
  25836. * @param delay defines the delay to add to the current frame
  25837. * @param from defines the lower bound of the animation range
  25838. * @param to defines the upper bound of the animation range
  25839. * @param loop defines if the current animation must loop
  25840. * @param speedRatio defines the current speed ratio
  25841. * @param weight defines the weight of the animation (default is -1 so no weight)
  25842. * @param onLoop optional callback called when animation loops
  25843. * @returns a boolean indicating if the animation is running
  25844. */
  25845. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  25846. }
  25847. }
  25848. declare module BABYLON {
  25849. /**
  25850. * Class used to store an actual running animation
  25851. */
  25852. export class Animatable {
  25853. /** defines the target object */
  25854. target: any;
  25855. /** defines the starting frame number (default is 0) */
  25856. fromFrame: number;
  25857. /** defines the ending frame number (default is 100) */
  25858. toFrame: number;
  25859. /** defines if the animation must loop (default is false) */
  25860. loopAnimation: boolean;
  25861. /** defines a callback to call when animation ends if it is not looping */
  25862. onAnimationEnd?: (() => void) | null | undefined;
  25863. /** defines a callback to call when animation loops */
  25864. onAnimationLoop?: (() => void) | null | undefined;
  25865. /** defines whether the animation should be evaluated additively */
  25866. isAdditive: boolean;
  25867. private _localDelayOffset;
  25868. private _pausedDelay;
  25869. private _runtimeAnimations;
  25870. private _paused;
  25871. private _scene;
  25872. private _speedRatio;
  25873. private _weight;
  25874. private _syncRoot;
  25875. /**
  25876. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  25877. * This will only apply for non looping animation (default is true)
  25878. */
  25879. disposeOnEnd: boolean;
  25880. /**
  25881. * Gets a boolean indicating if the animation has started
  25882. */
  25883. animationStarted: boolean;
  25884. /**
  25885. * Observer raised when the animation ends
  25886. */
  25887. onAnimationEndObservable: Observable<Animatable>;
  25888. /**
  25889. * Observer raised when the animation loops
  25890. */
  25891. onAnimationLoopObservable: Observable<Animatable>;
  25892. /**
  25893. * Gets the root Animatable used to synchronize and normalize animations
  25894. */
  25895. get syncRoot(): Nullable<Animatable>;
  25896. /**
  25897. * Gets the current frame of the first RuntimeAnimation
  25898. * Used to synchronize Animatables
  25899. */
  25900. get masterFrame(): number;
  25901. /**
  25902. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  25903. */
  25904. get weight(): number;
  25905. set weight(value: number);
  25906. /**
  25907. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  25908. */
  25909. get speedRatio(): number;
  25910. set speedRatio(value: number);
  25911. /**
  25912. * Creates a new Animatable
  25913. * @param scene defines the hosting scene
  25914. * @param target defines the target object
  25915. * @param fromFrame defines the starting frame number (default is 0)
  25916. * @param toFrame defines the ending frame number (default is 100)
  25917. * @param loopAnimation defines if the animation must loop (default is false)
  25918. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  25919. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  25920. * @param animations defines a group of animation to add to the new Animatable
  25921. * @param onAnimationLoop defines a callback to call when animation loops
  25922. * @param isAdditive defines whether the animation should be evaluated additively
  25923. */
  25924. constructor(scene: Scene,
  25925. /** defines the target object */
  25926. target: any,
  25927. /** defines the starting frame number (default is 0) */
  25928. fromFrame?: number,
  25929. /** defines the ending frame number (default is 100) */
  25930. toFrame?: number,
  25931. /** defines if the animation must loop (default is false) */
  25932. loopAnimation?: boolean, speedRatio?: number,
  25933. /** defines a callback to call when animation ends if it is not looping */
  25934. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  25935. /** defines a callback to call when animation loops */
  25936. onAnimationLoop?: (() => void) | null | undefined,
  25937. /** defines whether the animation should be evaluated additively */
  25938. isAdditive?: boolean);
  25939. /**
  25940. * Synchronize and normalize current Animatable with a source Animatable
  25941. * This is useful when using animation weights and when animations are not of the same length
  25942. * @param root defines the root Animatable to synchronize with
  25943. * @returns the current Animatable
  25944. */
  25945. syncWith(root: Animatable): Animatable;
  25946. /**
  25947. * Gets the list of runtime animations
  25948. * @returns an array of RuntimeAnimation
  25949. */
  25950. getAnimations(): RuntimeAnimation[];
  25951. /**
  25952. * Adds more animations to the current animatable
  25953. * @param target defines the target of the animations
  25954. * @param animations defines the new animations to add
  25955. */
  25956. appendAnimations(target: any, animations: Animation[]): void;
  25957. /**
  25958. * Gets the source animation for a specific property
  25959. * @param property defines the property to look for
  25960. * @returns null or the source animation for the given property
  25961. */
  25962. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  25963. /**
  25964. * Gets the runtime animation for a specific property
  25965. * @param property defines the property to look for
  25966. * @returns null or the runtime animation for the given property
  25967. */
  25968. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  25969. /**
  25970. * Resets the animatable to its original state
  25971. */
  25972. reset(): void;
  25973. /**
  25974. * Allows the animatable to blend with current running animations
  25975. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25976. * @param blendingSpeed defines the blending speed to use
  25977. */
  25978. enableBlending(blendingSpeed: number): void;
  25979. /**
  25980. * Disable animation blending
  25981. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25982. */
  25983. disableBlending(): void;
  25984. /**
  25985. * Jump directly to a given frame
  25986. * @param frame defines the frame to jump to
  25987. */
  25988. goToFrame(frame: number): void;
  25989. /**
  25990. * Pause the animation
  25991. */
  25992. pause(): void;
  25993. /**
  25994. * Restart the animation
  25995. */
  25996. restart(): void;
  25997. private _raiseOnAnimationEnd;
  25998. /**
  25999. * Stop and delete the current animation
  26000. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  26001. * @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)
  26002. */
  26003. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  26004. /**
  26005. * Wait asynchronously for the animation to end
  26006. * @returns a promise which will be fulfilled when the animation ends
  26007. */
  26008. waitAsync(): Promise<Animatable>;
  26009. /** @hidden */
  26010. _animate(delay: number): boolean;
  26011. }
  26012. interface Scene {
  26013. /** @hidden */
  26014. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  26015. /** @hidden */
  26016. _processLateAnimationBindingsForMatrices(holder: {
  26017. totalWeight: number;
  26018. totalAdditiveWeight: number;
  26019. animations: RuntimeAnimation[];
  26020. additiveAnimations: RuntimeAnimation[];
  26021. originalValue: Matrix;
  26022. }): any;
  26023. /** @hidden */
  26024. _processLateAnimationBindingsForQuaternions(holder: {
  26025. totalWeight: number;
  26026. totalAdditiveWeight: number;
  26027. animations: RuntimeAnimation[];
  26028. additiveAnimations: RuntimeAnimation[];
  26029. originalValue: Quaternion;
  26030. }, refQuaternion: Quaternion): Quaternion;
  26031. /** @hidden */
  26032. _processLateAnimationBindings(): void;
  26033. /**
  26034. * Will start the animation sequence of a given target
  26035. * @param target defines the target
  26036. * @param from defines from which frame should animation start
  26037. * @param to defines until which frame should animation run.
  26038. * @param weight defines the weight to apply to the animation (1.0 by default)
  26039. * @param loop defines if the animation loops
  26040. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26041. * @param onAnimationEnd defines the function to be executed when the animation ends
  26042. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26043. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  26044. * @param onAnimationLoop defines the callback to call when an animation loops
  26045. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26046. * @returns the animatable object created for this animation
  26047. */
  26048. 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;
  26049. /**
  26050. * Will start the animation sequence of a given target
  26051. * @param target defines the target
  26052. * @param from defines from which frame should animation start
  26053. * @param to defines until which frame should animation run.
  26054. * @param loop defines if the animation loops
  26055. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26056. * @param onAnimationEnd defines the function to be executed when the animation ends
  26057. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26058. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  26059. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  26060. * @param onAnimationLoop defines the callback to call when an animation loops
  26061. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26062. * @returns the animatable object created for this animation
  26063. */
  26064. 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;
  26065. /**
  26066. * Will start the animation sequence of a given target and its hierarchy
  26067. * @param target defines the target
  26068. * @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.
  26069. * @param from defines from which frame should animation start
  26070. * @param to defines until which frame should animation run.
  26071. * @param loop defines if the animation loops
  26072. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26073. * @param onAnimationEnd defines the function to be executed when the animation ends
  26074. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26075. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  26076. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  26077. * @param onAnimationLoop defines the callback to call when an animation loops
  26078. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26079. * @returns the list of created animatables
  26080. */
  26081. 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[];
  26082. /**
  26083. * Begin a new animation on a given node
  26084. * @param target defines the target where the animation will take place
  26085. * @param animations defines the list of animations to start
  26086. * @param from defines the initial value
  26087. * @param to defines the final value
  26088. * @param loop defines if you want animation to loop (off by default)
  26089. * @param speedRatio defines the speed ratio to apply to all animations
  26090. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26091. * @param onAnimationLoop defines the callback to call when an animation loops
  26092. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26093. * @returns the list of created animatables
  26094. */
  26095. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  26096. /**
  26097. * Begin a new animation on a given node and its hierarchy
  26098. * @param target defines the root node where the animation will take place
  26099. * @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.
  26100. * @param animations defines the list of animations to start
  26101. * @param from defines the initial value
  26102. * @param to defines the final value
  26103. * @param loop defines if you want animation to loop (off by default)
  26104. * @param speedRatio defines the speed ratio to apply to all animations
  26105. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26106. * @param onAnimationLoop defines the callback to call when an animation loops
  26107. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26108. * @returns the list of animatables created for all nodes
  26109. */
  26110. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  26111. /**
  26112. * Gets the animatable associated with a specific target
  26113. * @param target defines the target of the animatable
  26114. * @returns the required animatable if found
  26115. */
  26116. getAnimatableByTarget(target: any): Nullable<Animatable>;
  26117. /**
  26118. * Gets all animatables associated with a given target
  26119. * @param target defines the target to look animatables for
  26120. * @returns an array of Animatables
  26121. */
  26122. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  26123. /**
  26124. * Stops and removes all animations that have been applied to the scene
  26125. */
  26126. stopAllAnimations(): void;
  26127. /**
  26128. * Gets the current delta time used by animation engine
  26129. */
  26130. deltaTime: number;
  26131. }
  26132. interface Bone {
  26133. /**
  26134. * Copy an animation range from another bone
  26135. * @param source defines the source bone
  26136. * @param rangeName defines the range name to copy
  26137. * @param frameOffset defines the frame offset
  26138. * @param rescaleAsRequired defines if rescaling must be applied if required
  26139. * @param skelDimensionsRatio defines the scaling ratio
  26140. * @returns true if operation was successful
  26141. */
  26142. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  26143. }
  26144. }
  26145. declare module BABYLON {
  26146. /**
  26147. * Class used to override all child animations of a given target
  26148. */
  26149. export class AnimationPropertiesOverride {
  26150. /**
  26151. * Gets or sets a value indicating if animation blending must be used
  26152. */
  26153. enableBlending: boolean;
  26154. /**
  26155. * Gets or sets the blending speed to use when enableBlending is true
  26156. */
  26157. blendingSpeed: number;
  26158. /**
  26159. * Gets or sets the default loop mode to use
  26160. */
  26161. loopMode: number;
  26162. }
  26163. }
  26164. declare module BABYLON {
  26165. /**
  26166. * Class used to handle skinning animations
  26167. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26168. */
  26169. export class Skeleton implements IAnimatable {
  26170. /** defines the skeleton name */
  26171. name: string;
  26172. /** defines the skeleton Id */
  26173. id: string;
  26174. /**
  26175. * Defines the list of child bones
  26176. */
  26177. bones: Bone[];
  26178. /**
  26179. * Defines an estimate of the dimension of the skeleton at rest
  26180. */
  26181. dimensionsAtRest: Vector3;
  26182. /**
  26183. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  26184. */
  26185. needInitialSkinMatrix: boolean;
  26186. /**
  26187. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  26188. */
  26189. overrideMesh: Nullable<AbstractMesh>;
  26190. /**
  26191. * Gets the list of animations attached to this skeleton
  26192. */
  26193. animations: Array<Animation>;
  26194. private _scene;
  26195. private _isDirty;
  26196. private _transformMatrices;
  26197. private _transformMatrixTexture;
  26198. private _meshesWithPoseMatrix;
  26199. private _animatables;
  26200. private _identity;
  26201. private _synchronizedWithMesh;
  26202. private _ranges;
  26203. private _lastAbsoluteTransformsUpdateId;
  26204. private _canUseTextureForBones;
  26205. private _uniqueId;
  26206. /** @hidden */
  26207. _numBonesWithLinkedTransformNode: number;
  26208. /** @hidden */
  26209. _hasWaitingData: Nullable<boolean>;
  26210. /** @hidden */
  26211. _waitingOverrideMeshId: Nullable<string>;
  26212. /**
  26213. * Specifies if the skeleton should be serialized
  26214. */
  26215. doNotSerialize: boolean;
  26216. private _useTextureToStoreBoneMatrices;
  26217. /**
  26218. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  26219. * Please note that this option is not available if the hardware does not support it
  26220. */
  26221. get useTextureToStoreBoneMatrices(): boolean;
  26222. set useTextureToStoreBoneMatrices(value: boolean);
  26223. private _animationPropertiesOverride;
  26224. /**
  26225. * Gets or sets the animation properties override
  26226. */
  26227. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26228. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26229. /**
  26230. * List of inspectable custom properties (used by the Inspector)
  26231. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26232. */
  26233. inspectableCustomProperties: IInspectable[];
  26234. /**
  26235. * An observable triggered before computing the skeleton's matrices
  26236. */
  26237. onBeforeComputeObservable: Observable<Skeleton>;
  26238. /**
  26239. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  26240. */
  26241. get isUsingTextureForMatrices(): boolean;
  26242. /**
  26243. * Gets the unique ID of this skeleton
  26244. */
  26245. get uniqueId(): number;
  26246. /**
  26247. * Creates a new skeleton
  26248. * @param name defines the skeleton name
  26249. * @param id defines the skeleton Id
  26250. * @param scene defines the hosting scene
  26251. */
  26252. constructor(
  26253. /** defines the skeleton name */
  26254. name: string,
  26255. /** defines the skeleton Id */
  26256. id: string, scene: Scene);
  26257. /**
  26258. * Gets the current object class name.
  26259. * @return the class name
  26260. */
  26261. getClassName(): string;
  26262. /**
  26263. * Returns an array containing the root bones
  26264. * @returns an array containing the root bones
  26265. */
  26266. getChildren(): Array<Bone>;
  26267. /**
  26268. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  26269. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26270. * @returns a Float32Array containing matrices data
  26271. */
  26272. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  26273. /**
  26274. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  26275. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26276. * @returns a raw texture containing the data
  26277. */
  26278. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  26279. /**
  26280. * Gets the current hosting scene
  26281. * @returns a scene object
  26282. */
  26283. getScene(): Scene;
  26284. /**
  26285. * Gets a string representing the current skeleton data
  26286. * @param fullDetails defines a boolean indicating if we want a verbose version
  26287. * @returns a string representing the current skeleton data
  26288. */
  26289. toString(fullDetails?: boolean): string;
  26290. /**
  26291. * Get bone's index searching by name
  26292. * @param name defines bone's name to search for
  26293. * @return the indice of the bone. Returns -1 if not found
  26294. */
  26295. getBoneIndexByName(name: string): number;
  26296. /**
  26297. * Create a new animation range
  26298. * @param name defines the name of the range
  26299. * @param from defines the start key
  26300. * @param to defines the end key
  26301. */
  26302. createAnimationRange(name: string, from: number, to: number): void;
  26303. /**
  26304. * Delete a specific animation range
  26305. * @param name defines the name of the range
  26306. * @param deleteFrames defines if frames must be removed as well
  26307. */
  26308. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26309. /**
  26310. * Gets a specific animation range
  26311. * @param name defines the name of the range to look for
  26312. * @returns the requested animation range or null if not found
  26313. */
  26314. getAnimationRange(name: string): Nullable<AnimationRange>;
  26315. /**
  26316. * Gets the list of all animation ranges defined on this skeleton
  26317. * @returns an array
  26318. */
  26319. getAnimationRanges(): Nullable<AnimationRange>[];
  26320. /**
  26321. * Copy animation range from a source skeleton.
  26322. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  26323. * @param source defines the source skeleton
  26324. * @param name defines the name of the range to copy
  26325. * @param rescaleAsRequired defines if rescaling must be applied if required
  26326. * @returns true if operation was successful
  26327. */
  26328. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  26329. /**
  26330. * Forces the skeleton to go to rest pose
  26331. */
  26332. returnToRest(): void;
  26333. private _getHighestAnimationFrame;
  26334. /**
  26335. * Begin a specific animation range
  26336. * @param name defines the name of the range to start
  26337. * @param loop defines if looping must be turned on (false by default)
  26338. * @param speedRatio defines the speed ratio to apply (1 by default)
  26339. * @param onAnimationEnd defines a callback which will be called when animation will end
  26340. * @returns a new animatable
  26341. */
  26342. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26343. /**
  26344. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  26345. * @param skeleton defines the Skeleton containing the animation range to convert
  26346. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  26347. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  26348. * @returns the original skeleton
  26349. */
  26350. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  26351. /** @hidden */
  26352. _markAsDirty(): void;
  26353. /** @hidden */
  26354. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26355. /** @hidden */
  26356. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26357. private _computeTransformMatrices;
  26358. /**
  26359. * Build all resources required to render a skeleton
  26360. */
  26361. prepare(): void;
  26362. /**
  26363. * Gets the list of animatables currently running for this skeleton
  26364. * @returns an array of animatables
  26365. */
  26366. getAnimatables(): IAnimatable[];
  26367. /**
  26368. * Clone the current skeleton
  26369. * @param name defines the name of the new skeleton
  26370. * @param id defines the id of the new skeleton
  26371. * @returns the new skeleton
  26372. */
  26373. clone(name: string, id?: string): Skeleton;
  26374. /**
  26375. * Enable animation blending for this skeleton
  26376. * @param blendingSpeed defines the blending speed to apply
  26377. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26378. */
  26379. enableBlending(blendingSpeed?: number): void;
  26380. /**
  26381. * Releases all resources associated with the current skeleton
  26382. */
  26383. dispose(): void;
  26384. /**
  26385. * Serialize the skeleton in a JSON object
  26386. * @returns a JSON object
  26387. */
  26388. serialize(): any;
  26389. /**
  26390. * Creates a new skeleton from serialized data
  26391. * @param parsedSkeleton defines the serialized data
  26392. * @param scene defines the hosting scene
  26393. * @returns a new skeleton
  26394. */
  26395. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  26396. /**
  26397. * Compute all node absolute transforms
  26398. * @param forceUpdate defines if computation must be done even if cache is up to date
  26399. */
  26400. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  26401. /**
  26402. * Gets the root pose matrix
  26403. * @returns a matrix
  26404. */
  26405. getPoseMatrix(): Nullable<Matrix>;
  26406. /**
  26407. * Sorts bones per internal index
  26408. */
  26409. sortBones(): void;
  26410. private _sortBones;
  26411. /**
  26412. * Set the current local matrix as the restPose for all bones in the skeleton.
  26413. */
  26414. setCurrentPoseAsRest(): void;
  26415. }
  26416. }
  26417. declare module BABYLON {
  26418. /**
  26419. * Class used to store bone information
  26420. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26421. */
  26422. export class Bone extends Node {
  26423. /**
  26424. * defines the bone name
  26425. */
  26426. name: string;
  26427. private static _tmpVecs;
  26428. private static _tmpQuat;
  26429. private static _tmpMats;
  26430. /**
  26431. * Gets the list of child bones
  26432. */
  26433. children: Bone[];
  26434. /** Gets the animations associated with this bone */
  26435. animations: Animation[];
  26436. /**
  26437. * Gets or sets bone length
  26438. */
  26439. length: number;
  26440. /**
  26441. * @hidden Internal only
  26442. * Set this value to map this bone to a different index in the transform matrices
  26443. * Set this value to -1 to exclude the bone from the transform matrices
  26444. */
  26445. _index: Nullable<number>;
  26446. private _skeleton;
  26447. private _localMatrix;
  26448. private _restPose;
  26449. private _bindPose;
  26450. private _baseMatrix;
  26451. private _absoluteTransform;
  26452. private _invertedAbsoluteTransform;
  26453. private _parent;
  26454. private _scalingDeterminant;
  26455. private _worldTransform;
  26456. private _localScaling;
  26457. private _localRotation;
  26458. private _localPosition;
  26459. private _needToDecompose;
  26460. private _needToCompose;
  26461. /** @hidden */
  26462. _linkedTransformNode: Nullable<TransformNode>;
  26463. /** @hidden */
  26464. _waitingTransformNodeId: Nullable<string>;
  26465. /** @hidden */
  26466. get _matrix(): Matrix;
  26467. /** @hidden */
  26468. set _matrix(value: Matrix);
  26469. /**
  26470. * Create a new bone
  26471. * @param name defines the bone name
  26472. * @param skeleton defines the parent skeleton
  26473. * @param parentBone defines the parent (can be null if the bone is the root)
  26474. * @param localMatrix defines the local matrix
  26475. * @param restPose defines the rest pose matrix
  26476. * @param baseMatrix defines the base matrix
  26477. * @param index defines index of the bone in the hierarchy
  26478. */
  26479. constructor(
  26480. /**
  26481. * defines the bone name
  26482. */
  26483. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  26484. /**
  26485. * Gets the current object class name.
  26486. * @return the class name
  26487. */
  26488. getClassName(): string;
  26489. /**
  26490. * Gets the parent skeleton
  26491. * @returns a skeleton
  26492. */
  26493. getSkeleton(): Skeleton;
  26494. /**
  26495. * Gets parent bone
  26496. * @returns a bone or null if the bone is the root of the bone hierarchy
  26497. */
  26498. getParent(): Nullable<Bone>;
  26499. /**
  26500. * Returns an array containing the root bones
  26501. * @returns an array containing the root bones
  26502. */
  26503. getChildren(): Array<Bone>;
  26504. /**
  26505. * Gets the node index in matrix array generated for rendering
  26506. * @returns the node index
  26507. */
  26508. getIndex(): number;
  26509. /**
  26510. * Sets the parent bone
  26511. * @param parent defines the parent (can be null if the bone is the root)
  26512. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26513. */
  26514. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  26515. /**
  26516. * Gets the local matrix
  26517. * @returns a matrix
  26518. */
  26519. getLocalMatrix(): Matrix;
  26520. /**
  26521. * Gets the base matrix (initial matrix which remains unchanged)
  26522. * @returns a matrix
  26523. */
  26524. getBaseMatrix(): Matrix;
  26525. /**
  26526. * Gets the rest pose matrix
  26527. * @returns a matrix
  26528. */
  26529. getRestPose(): Matrix;
  26530. /**
  26531. * Sets the rest pose matrix
  26532. * @param matrix the local-space rest pose to set for this bone
  26533. */
  26534. setRestPose(matrix: Matrix): void;
  26535. /**
  26536. * Gets the bind pose matrix
  26537. * @returns the bind pose matrix
  26538. */
  26539. getBindPose(): Matrix;
  26540. /**
  26541. * Sets the bind pose matrix
  26542. * @param matrix the local-space bind pose to set for this bone
  26543. */
  26544. setBindPose(matrix: Matrix): void;
  26545. /**
  26546. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  26547. */
  26548. getWorldMatrix(): Matrix;
  26549. /**
  26550. * Sets the local matrix to rest pose matrix
  26551. */
  26552. returnToRest(): void;
  26553. /**
  26554. * Gets the inverse of the absolute transform matrix.
  26555. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  26556. * @returns a matrix
  26557. */
  26558. getInvertedAbsoluteTransform(): Matrix;
  26559. /**
  26560. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  26561. * @returns a matrix
  26562. */
  26563. getAbsoluteTransform(): Matrix;
  26564. /**
  26565. * Links with the given transform node.
  26566. * The local matrix of this bone is copied from the transform node every frame.
  26567. * @param transformNode defines the transform node to link to
  26568. */
  26569. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  26570. /**
  26571. * Gets the node used to drive the bone's transformation
  26572. * @returns a transform node or null
  26573. */
  26574. getTransformNode(): Nullable<TransformNode>;
  26575. /** Gets or sets current position (in local space) */
  26576. get position(): Vector3;
  26577. set position(newPosition: Vector3);
  26578. /** Gets or sets current rotation (in local space) */
  26579. get rotation(): Vector3;
  26580. set rotation(newRotation: Vector3);
  26581. /** Gets or sets current rotation quaternion (in local space) */
  26582. get rotationQuaternion(): Quaternion;
  26583. set rotationQuaternion(newRotation: Quaternion);
  26584. /** Gets or sets current scaling (in local space) */
  26585. get scaling(): Vector3;
  26586. set scaling(newScaling: Vector3);
  26587. /**
  26588. * Gets the animation properties override
  26589. */
  26590. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26591. private _decompose;
  26592. private _compose;
  26593. /**
  26594. * Update the base and local matrices
  26595. * @param matrix defines the new base or local matrix
  26596. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26597. * @param updateLocalMatrix defines if the local matrix should be updated
  26598. */
  26599. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  26600. /** @hidden */
  26601. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  26602. /**
  26603. * Flag the bone as dirty (Forcing it to update everything)
  26604. */
  26605. markAsDirty(): void;
  26606. /** @hidden */
  26607. _markAsDirtyAndCompose(): void;
  26608. private _markAsDirtyAndDecompose;
  26609. /**
  26610. * Translate the bone in local or world space
  26611. * @param vec The amount to translate the bone
  26612. * @param space The space that the translation is in
  26613. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26614. */
  26615. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26616. /**
  26617. * Set the position of the bone in local or world space
  26618. * @param position The position to set the bone
  26619. * @param space The space that the position is in
  26620. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26621. */
  26622. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26623. /**
  26624. * Set the absolute position of the bone (world space)
  26625. * @param position The position to set the bone
  26626. * @param mesh The mesh that this bone is attached to
  26627. */
  26628. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  26629. /**
  26630. * Scale the bone on the x, y and z axes (in local space)
  26631. * @param x The amount to scale the bone on the x axis
  26632. * @param y The amount to scale the bone on the y axis
  26633. * @param z The amount to scale the bone on the z axis
  26634. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  26635. */
  26636. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  26637. /**
  26638. * Set the bone scaling in local space
  26639. * @param scale defines the scaling vector
  26640. */
  26641. setScale(scale: Vector3): void;
  26642. /**
  26643. * Gets the current scaling in local space
  26644. * @returns the current scaling vector
  26645. */
  26646. getScale(): Vector3;
  26647. /**
  26648. * Gets the current scaling in local space and stores it in a target vector
  26649. * @param result defines the target vector
  26650. */
  26651. getScaleToRef(result: Vector3): void;
  26652. /**
  26653. * Set the yaw, pitch, and roll of the bone in local or world space
  26654. * @param yaw The rotation of the bone on the y axis
  26655. * @param pitch The rotation of the bone on the x axis
  26656. * @param roll The rotation of the bone on the z axis
  26657. * @param space The space that the axes of rotation are in
  26658. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26659. */
  26660. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  26661. /**
  26662. * Add a rotation to the bone on an axis in local or world space
  26663. * @param axis The axis to rotate the bone on
  26664. * @param amount The amount to rotate the bone
  26665. * @param space The space that the axis is in
  26666. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26667. */
  26668. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  26669. /**
  26670. * Set the rotation of the bone to a particular axis angle in local or world space
  26671. * @param axis The axis to rotate the bone on
  26672. * @param angle The angle that the bone should be rotated to
  26673. * @param space The space that the axis is in
  26674. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26675. */
  26676. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  26677. /**
  26678. * Set the euler rotation of the bone in local or world space
  26679. * @param rotation The euler rotation that the bone should be set to
  26680. * @param space The space that the rotation is in
  26681. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26682. */
  26683. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26684. /**
  26685. * Set the quaternion rotation of the bone in local or world space
  26686. * @param quat The quaternion rotation that the bone should be set to
  26687. * @param space The space that the rotation is in
  26688. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26689. */
  26690. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  26691. /**
  26692. * Set the rotation matrix of the bone in local or world space
  26693. * @param rotMat The rotation matrix that the bone should be set to
  26694. * @param space The space that the rotation is in
  26695. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26696. */
  26697. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  26698. private _rotateWithMatrix;
  26699. private _getNegativeRotationToRef;
  26700. /**
  26701. * Get the position of the bone in local or world space
  26702. * @param space The space that the returned position is in
  26703. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26704. * @returns The position of the bone
  26705. */
  26706. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26707. /**
  26708. * Copy the position of the bone to a vector3 in local or world space
  26709. * @param space The space that the returned position is in
  26710. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26711. * @param result The vector3 to copy the position to
  26712. */
  26713. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  26714. /**
  26715. * Get the absolute position of the bone (world space)
  26716. * @param mesh The mesh that this bone is attached to
  26717. * @returns The absolute position of the bone
  26718. */
  26719. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  26720. /**
  26721. * Copy the absolute position of the bone (world space) to the result param
  26722. * @param mesh The mesh that this bone is attached to
  26723. * @param result The vector3 to copy the absolute position to
  26724. */
  26725. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  26726. /**
  26727. * Compute the absolute transforms of this bone and its children
  26728. */
  26729. computeAbsoluteTransforms(): void;
  26730. /**
  26731. * Get the world direction from an axis that is in the local space of the bone
  26732. * @param localAxis The local direction that is used to compute the world direction
  26733. * @param mesh The mesh that this bone is attached to
  26734. * @returns The world direction
  26735. */
  26736. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26737. /**
  26738. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  26739. * @param localAxis The local direction that is used to compute the world direction
  26740. * @param mesh The mesh that this bone is attached to
  26741. * @param result The vector3 that the world direction will be copied to
  26742. */
  26743. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26744. /**
  26745. * Get the euler rotation of the bone in local or world space
  26746. * @param space The space that the rotation should be in
  26747. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26748. * @returns The euler rotation
  26749. */
  26750. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26751. /**
  26752. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  26753. * @param space The space that the rotation should be in
  26754. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26755. * @param result The vector3 that the rotation should be copied to
  26756. */
  26757. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26758. /**
  26759. * Get the quaternion rotation of the bone in either local or world space
  26760. * @param space The space that the rotation should be in
  26761. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26762. * @returns The quaternion rotation
  26763. */
  26764. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  26765. /**
  26766. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  26767. * @param space The space that the rotation should be in
  26768. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26769. * @param result The quaternion that the rotation should be copied to
  26770. */
  26771. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  26772. /**
  26773. * Get the rotation matrix of the bone in local or world space
  26774. * @param space The space that the rotation should be in
  26775. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26776. * @returns The rotation matrix
  26777. */
  26778. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  26779. /**
  26780. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  26781. * @param space The space that the rotation should be in
  26782. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26783. * @param result The quaternion that the rotation should be copied to
  26784. */
  26785. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  26786. /**
  26787. * Get the world position of a point that is in the local space of the bone
  26788. * @param position The local position
  26789. * @param mesh The mesh that this bone is attached to
  26790. * @returns The world position
  26791. */
  26792. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26793. /**
  26794. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  26795. * @param position The local position
  26796. * @param mesh The mesh that this bone is attached to
  26797. * @param result The vector3 that the world position should be copied to
  26798. */
  26799. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26800. /**
  26801. * Get the local position of a point that is in world space
  26802. * @param position The world position
  26803. * @param mesh The mesh that this bone is attached to
  26804. * @returns The local position
  26805. */
  26806. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26807. /**
  26808. * Get the local position of a point that is in world space and copy it to the result param
  26809. * @param position The world position
  26810. * @param mesh The mesh that this bone is attached to
  26811. * @param result The vector3 that the local position should be copied to
  26812. */
  26813. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26814. /**
  26815. * Set the current local matrix as the restPose for this bone.
  26816. */
  26817. setCurrentPoseAsRest(): void;
  26818. }
  26819. }
  26820. declare module BABYLON {
  26821. /**
  26822. * 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.
  26823. * @see https://doc.babylonjs.com/how_to/transformnode
  26824. */
  26825. export class TransformNode extends Node {
  26826. /**
  26827. * Object will not rotate to face the camera
  26828. */
  26829. static BILLBOARDMODE_NONE: number;
  26830. /**
  26831. * Object will rotate to face the camera but only on the x axis
  26832. */
  26833. static BILLBOARDMODE_X: number;
  26834. /**
  26835. * Object will rotate to face the camera but only on the y axis
  26836. */
  26837. static BILLBOARDMODE_Y: number;
  26838. /**
  26839. * Object will rotate to face the camera but only on the z axis
  26840. */
  26841. static BILLBOARDMODE_Z: number;
  26842. /**
  26843. * Object will rotate to face the camera
  26844. */
  26845. static BILLBOARDMODE_ALL: number;
  26846. /**
  26847. * Object will rotate to face the camera's position instead of orientation
  26848. */
  26849. static BILLBOARDMODE_USE_POSITION: number;
  26850. private static _TmpRotation;
  26851. private static _TmpScaling;
  26852. private static _TmpTranslation;
  26853. private _forward;
  26854. private _forwardInverted;
  26855. private _up;
  26856. private _right;
  26857. private _rightInverted;
  26858. private _position;
  26859. private _rotation;
  26860. private _rotationQuaternion;
  26861. protected _scaling: Vector3;
  26862. protected _isDirty: boolean;
  26863. private _transformToBoneReferal;
  26864. private _isAbsoluteSynced;
  26865. private _billboardMode;
  26866. /**
  26867. * Gets or sets the billboard mode. Default is 0.
  26868. *
  26869. * | Value | Type | Description |
  26870. * | --- | --- | --- |
  26871. * | 0 | BILLBOARDMODE_NONE | |
  26872. * | 1 | BILLBOARDMODE_X | |
  26873. * | 2 | BILLBOARDMODE_Y | |
  26874. * | 4 | BILLBOARDMODE_Z | |
  26875. * | 7 | BILLBOARDMODE_ALL | |
  26876. *
  26877. */
  26878. get billboardMode(): number;
  26879. set billboardMode(value: number);
  26880. private _preserveParentRotationForBillboard;
  26881. /**
  26882. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  26883. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  26884. */
  26885. get preserveParentRotationForBillboard(): boolean;
  26886. set preserveParentRotationForBillboard(value: boolean);
  26887. /**
  26888. * 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
  26889. */
  26890. scalingDeterminant: number;
  26891. private _infiniteDistance;
  26892. /**
  26893. * Gets or sets the distance of the object to max, often used by skybox
  26894. */
  26895. get infiniteDistance(): boolean;
  26896. set infiniteDistance(value: boolean);
  26897. /**
  26898. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  26899. * By default the system will update normals to compensate
  26900. */
  26901. ignoreNonUniformScaling: boolean;
  26902. /**
  26903. * 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
  26904. */
  26905. reIntegrateRotationIntoRotationQuaternion: boolean;
  26906. /** @hidden */
  26907. _poseMatrix: Nullable<Matrix>;
  26908. /** @hidden */
  26909. _localMatrix: Matrix;
  26910. private _usePivotMatrix;
  26911. private _absolutePosition;
  26912. private _absoluteScaling;
  26913. private _absoluteRotationQuaternion;
  26914. private _pivotMatrix;
  26915. private _pivotMatrixInverse;
  26916. /** @hidden */
  26917. _postMultiplyPivotMatrix: boolean;
  26918. protected _isWorldMatrixFrozen: boolean;
  26919. /** @hidden */
  26920. _indexInSceneTransformNodesArray: number;
  26921. /**
  26922. * An event triggered after the world matrix is updated
  26923. */
  26924. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  26925. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  26926. /**
  26927. * Gets a string identifying the name of the class
  26928. * @returns "TransformNode" string
  26929. */
  26930. getClassName(): string;
  26931. /**
  26932. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  26933. */
  26934. get position(): Vector3;
  26935. set position(newPosition: Vector3);
  26936. /**
  26937. * 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)).
  26938. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  26939. */
  26940. get rotation(): Vector3;
  26941. set rotation(newRotation: Vector3);
  26942. /**
  26943. * 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)).
  26944. */
  26945. get scaling(): Vector3;
  26946. set scaling(newScaling: Vector3);
  26947. /**
  26948. * 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).
  26949. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  26950. */
  26951. get rotationQuaternion(): Nullable<Quaternion>;
  26952. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  26953. /**
  26954. * The forward direction of that transform in world space.
  26955. */
  26956. get forward(): Vector3;
  26957. /**
  26958. * The up direction of that transform in world space.
  26959. */
  26960. get up(): Vector3;
  26961. /**
  26962. * The right direction of that transform in world space.
  26963. */
  26964. get right(): Vector3;
  26965. /**
  26966. * Copies the parameter passed Matrix into the mesh Pose matrix.
  26967. * @param matrix the matrix to copy the pose from
  26968. * @returns this TransformNode.
  26969. */
  26970. updatePoseMatrix(matrix: Matrix): TransformNode;
  26971. /**
  26972. * Returns the mesh Pose matrix.
  26973. * @returns the pose matrix
  26974. */
  26975. getPoseMatrix(): Matrix;
  26976. /** @hidden */
  26977. _isSynchronized(): boolean;
  26978. /** @hidden */
  26979. _initCache(): void;
  26980. /**
  26981. * Flag the transform node as dirty (Forcing it to update everything)
  26982. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  26983. * @returns this transform node
  26984. */
  26985. markAsDirty(property: string): TransformNode;
  26986. /**
  26987. * Returns the current mesh absolute position.
  26988. * Returns a Vector3.
  26989. */
  26990. get absolutePosition(): Vector3;
  26991. /**
  26992. * Returns the current mesh absolute scaling.
  26993. * Returns a Vector3.
  26994. */
  26995. get absoluteScaling(): Vector3;
  26996. /**
  26997. * Returns the current mesh absolute rotation.
  26998. * Returns a Quaternion.
  26999. */
  27000. get absoluteRotationQuaternion(): Quaternion;
  27001. /**
  27002. * Sets a new matrix to apply before all other transformation
  27003. * @param matrix defines the transform matrix
  27004. * @returns the current TransformNode
  27005. */
  27006. setPreTransformMatrix(matrix: Matrix): TransformNode;
  27007. /**
  27008. * Sets a new pivot matrix to the current node
  27009. * @param matrix defines the new pivot matrix to use
  27010. * @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
  27011. * @returns the current TransformNode
  27012. */
  27013. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  27014. /**
  27015. * Returns the mesh pivot matrix.
  27016. * Default : Identity.
  27017. * @returns the matrix
  27018. */
  27019. getPivotMatrix(): Matrix;
  27020. /**
  27021. * Instantiate (when possible) or clone that node with its hierarchy
  27022. * @param newParent defines the new parent to use for the instance (or clone)
  27023. * @param options defines options to configure how copy is done
  27024. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  27025. * @returns an instance (or a clone) of the current node with its hiearchy
  27026. */
  27027. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27028. doNotInstantiate: boolean;
  27029. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27030. /**
  27031. * Prevents the World matrix to be computed any longer
  27032. * @param newWorldMatrix defines an optional matrix to use as world matrix
  27033. * @returns the TransformNode.
  27034. */
  27035. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  27036. /**
  27037. * Allows back the World matrix computation.
  27038. * @returns the TransformNode.
  27039. */
  27040. unfreezeWorldMatrix(): this;
  27041. /**
  27042. * True if the World matrix has been frozen.
  27043. */
  27044. get isWorldMatrixFrozen(): boolean;
  27045. /**
  27046. * Returns the mesh absolute position in the World.
  27047. * @returns a Vector3.
  27048. */
  27049. getAbsolutePosition(): Vector3;
  27050. /**
  27051. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  27052. * @param absolutePosition the absolute position to set
  27053. * @returns the TransformNode.
  27054. */
  27055. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27056. /**
  27057. * Sets the mesh position in its local space.
  27058. * @param vector3 the position to set in localspace
  27059. * @returns the TransformNode.
  27060. */
  27061. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  27062. /**
  27063. * Returns the mesh position in the local space from the current World matrix values.
  27064. * @returns a new Vector3.
  27065. */
  27066. getPositionExpressedInLocalSpace(): Vector3;
  27067. /**
  27068. * Translates the mesh along the passed Vector3 in its local space.
  27069. * @param vector3 the distance to translate in localspace
  27070. * @returns the TransformNode.
  27071. */
  27072. locallyTranslate(vector3: Vector3): TransformNode;
  27073. private static _lookAtVectorCache;
  27074. /**
  27075. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  27076. * @param targetPoint the position (must be in same space as current mesh) to look at
  27077. * @param yawCor optional yaw (y-axis) correction in radians
  27078. * @param pitchCor optional pitch (x-axis) correction in radians
  27079. * @param rollCor optional roll (z-axis) correction in radians
  27080. * @param space the chosen space of the target
  27081. * @returns the TransformNode.
  27082. */
  27083. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  27084. /**
  27085. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27086. * This Vector3 is expressed in the World space.
  27087. * @param localAxis axis to rotate
  27088. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27089. */
  27090. getDirection(localAxis: Vector3): Vector3;
  27091. /**
  27092. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  27093. * localAxis is expressed in the mesh local space.
  27094. * result is computed in the Wordl space from the mesh World matrix.
  27095. * @param localAxis axis to rotate
  27096. * @param result the resulting transformnode
  27097. * @returns this TransformNode.
  27098. */
  27099. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  27100. /**
  27101. * Sets this transform node rotation to the given local axis.
  27102. * @param localAxis the axis in local space
  27103. * @param yawCor optional yaw (y-axis) correction in radians
  27104. * @param pitchCor optional pitch (x-axis) correction in radians
  27105. * @param rollCor optional roll (z-axis) correction in radians
  27106. * @returns this TransformNode
  27107. */
  27108. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  27109. /**
  27110. * Sets a new pivot point to the current node
  27111. * @param point defines the new pivot point to use
  27112. * @param space defines if the point is in world or local space (local by default)
  27113. * @returns the current TransformNode
  27114. */
  27115. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  27116. /**
  27117. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  27118. * @returns the pivot point
  27119. */
  27120. getPivotPoint(): Vector3;
  27121. /**
  27122. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  27123. * @param result the vector3 to store the result
  27124. * @returns this TransformNode.
  27125. */
  27126. getPivotPointToRef(result: Vector3): TransformNode;
  27127. /**
  27128. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  27129. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  27130. */
  27131. getAbsolutePivotPoint(): Vector3;
  27132. /**
  27133. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  27134. * @param result vector3 to store the result
  27135. * @returns this TransformNode.
  27136. */
  27137. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  27138. /**
  27139. * Defines the passed node as the parent of the current node.
  27140. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  27141. * @see https://doc.babylonjs.com/how_to/parenting
  27142. * @param node the node ot set as the parent
  27143. * @returns this TransformNode.
  27144. */
  27145. setParent(node: Nullable<Node>): TransformNode;
  27146. private _nonUniformScaling;
  27147. /**
  27148. * True if the scaling property of this object is non uniform eg. (1,2,1)
  27149. */
  27150. get nonUniformScaling(): boolean;
  27151. /** @hidden */
  27152. _updateNonUniformScalingState(value: boolean): boolean;
  27153. /**
  27154. * Attach the current TransformNode to another TransformNode associated with a bone
  27155. * @param bone Bone affecting the TransformNode
  27156. * @param affectedTransformNode TransformNode associated with the bone
  27157. * @returns this object
  27158. */
  27159. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  27160. /**
  27161. * Detach the transform node if its associated with a bone
  27162. * @returns this object
  27163. */
  27164. detachFromBone(): TransformNode;
  27165. private static _rotationAxisCache;
  27166. /**
  27167. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  27168. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  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. * @param axis the axis to rotate around
  27172. * @param amount the amount to rotate in radians
  27173. * @param space Space to rotate in (Default: local)
  27174. * @returns the TransformNode.
  27175. */
  27176. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27177. /**
  27178. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  27179. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27180. * The passed axis is also normalized. .
  27181. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  27182. * @param point the point to rotate around
  27183. * @param axis the axis to rotate around
  27184. * @param amount the amount to rotate in radians
  27185. * @returns the TransformNode
  27186. */
  27187. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  27188. /**
  27189. * Translates the mesh along the axis vector for the passed distance in the given space.
  27190. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27191. * @param axis the axis to translate in
  27192. * @param distance the distance to translate
  27193. * @param space Space to rotate in (Default: local)
  27194. * @returns the TransformNode.
  27195. */
  27196. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27197. /**
  27198. * Adds a rotation step to the mesh current rotation.
  27199. * x, y, z are Euler angles expressed in radians.
  27200. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  27201. * This means this rotation is made in the mesh local space only.
  27202. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  27203. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  27204. * ```javascript
  27205. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  27206. * ```
  27207. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  27208. * 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.
  27209. * @param x Rotation to add
  27210. * @param y Rotation to add
  27211. * @param z Rotation to add
  27212. * @returns the TransformNode.
  27213. */
  27214. addRotation(x: number, y: number, z: number): TransformNode;
  27215. /**
  27216. * @hidden
  27217. */
  27218. protected _getEffectiveParent(): Nullable<Node>;
  27219. /**
  27220. * Computes the world matrix of the node
  27221. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27222. * @returns the world matrix
  27223. */
  27224. computeWorldMatrix(force?: boolean): Matrix;
  27225. /**
  27226. * Resets this nodeTransform's local matrix to Matrix.Identity().
  27227. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  27228. */
  27229. resetLocalMatrix(independentOfChildren?: boolean): void;
  27230. protected _afterComputeWorldMatrix(): void;
  27231. /**
  27232. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  27233. * @param func callback function to add
  27234. *
  27235. * @returns the TransformNode.
  27236. */
  27237. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27238. /**
  27239. * Removes a registered callback function.
  27240. * @param func callback function to remove
  27241. * @returns the TransformNode.
  27242. */
  27243. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27244. /**
  27245. * Gets the position of the current mesh in camera space
  27246. * @param camera defines the camera to use
  27247. * @returns a position
  27248. */
  27249. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  27250. /**
  27251. * Returns the distance from the mesh to the active camera
  27252. * @param camera defines the camera to use
  27253. * @returns the distance
  27254. */
  27255. getDistanceToCamera(camera?: Nullable<Camera>): number;
  27256. /**
  27257. * Clone the current transform node
  27258. * @param name Name of the new clone
  27259. * @param newParent New parent for the clone
  27260. * @param doNotCloneChildren Do not clone children hierarchy
  27261. * @returns the new transform node
  27262. */
  27263. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  27264. /**
  27265. * Serializes the objects information.
  27266. * @param currentSerializationObject defines the object to serialize in
  27267. * @returns the serialized object
  27268. */
  27269. serialize(currentSerializationObject?: any): any;
  27270. /**
  27271. * Returns a new TransformNode object parsed from the source provided.
  27272. * @param parsedTransformNode is the source.
  27273. * @param scene the scene the object belongs to
  27274. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  27275. * @returns a new TransformNode object parsed from the source provided.
  27276. */
  27277. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  27278. /**
  27279. * Get all child-transformNodes of this node
  27280. * @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
  27281. * @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
  27282. * @returns an array of TransformNode
  27283. */
  27284. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  27285. /**
  27286. * Releases resources associated with this transform node.
  27287. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27288. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27289. */
  27290. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27291. /**
  27292. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27293. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27294. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27295. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27296. * @returns the current mesh
  27297. */
  27298. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  27299. private _syncAbsoluteScalingAndRotation;
  27300. }
  27301. }
  27302. declare module BABYLON {
  27303. /**
  27304. * Defines the types of pose enabled controllers that are supported
  27305. */
  27306. export enum PoseEnabledControllerType {
  27307. /**
  27308. * HTC Vive
  27309. */
  27310. VIVE = 0,
  27311. /**
  27312. * Oculus Rift
  27313. */
  27314. OCULUS = 1,
  27315. /**
  27316. * Windows mixed reality
  27317. */
  27318. WINDOWS = 2,
  27319. /**
  27320. * Samsung gear VR
  27321. */
  27322. GEAR_VR = 3,
  27323. /**
  27324. * Google Daydream
  27325. */
  27326. DAYDREAM = 4,
  27327. /**
  27328. * Generic
  27329. */
  27330. GENERIC = 5
  27331. }
  27332. /**
  27333. * Defines the MutableGamepadButton interface for the state of a gamepad button
  27334. */
  27335. export interface MutableGamepadButton {
  27336. /**
  27337. * Value of the button/trigger
  27338. */
  27339. value: number;
  27340. /**
  27341. * If the button/trigger is currently touched
  27342. */
  27343. touched: boolean;
  27344. /**
  27345. * If the button/trigger is currently pressed
  27346. */
  27347. pressed: boolean;
  27348. }
  27349. /**
  27350. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  27351. * @hidden
  27352. */
  27353. export interface ExtendedGamepadButton extends GamepadButton {
  27354. /**
  27355. * If the button/trigger is currently pressed
  27356. */
  27357. readonly pressed: boolean;
  27358. /**
  27359. * If the button/trigger is currently touched
  27360. */
  27361. readonly touched: boolean;
  27362. /**
  27363. * Value of the button/trigger
  27364. */
  27365. readonly value: number;
  27366. }
  27367. /** @hidden */
  27368. export interface _GamePadFactory {
  27369. /**
  27370. * Returns whether or not the current gamepad can be created for this type of controller.
  27371. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27372. * @returns true if it can be created, otherwise false
  27373. */
  27374. canCreate(gamepadInfo: any): boolean;
  27375. /**
  27376. * Creates a new instance of the Gamepad.
  27377. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27378. * @returns the new gamepad instance
  27379. */
  27380. create(gamepadInfo: any): Gamepad;
  27381. }
  27382. /**
  27383. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27384. */
  27385. export class PoseEnabledControllerHelper {
  27386. /** @hidden */
  27387. static _ControllerFactories: _GamePadFactory[];
  27388. /** @hidden */
  27389. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  27390. /**
  27391. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27392. * @param vrGamepad the gamepad to initialized
  27393. * @returns a vr controller of the type the gamepad identified as
  27394. */
  27395. static InitiateController(vrGamepad: any): Gamepad;
  27396. }
  27397. /**
  27398. * Defines the PoseEnabledController object that contains state of a vr capable controller
  27399. */
  27400. export class PoseEnabledController extends Gamepad implements PoseControlled {
  27401. /**
  27402. * If the controller is used in a webXR session
  27403. */
  27404. isXR: boolean;
  27405. private _deviceRoomPosition;
  27406. private _deviceRoomRotationQuaternion;
  27407. /**
  27408. * The device position in babylon space
  27409. */
  27410. devicePosition: Vector3;
  27411. /**
  27412. * The device rotation in babylon space
  27413. */
  27414. deviceRotationQuaternion: Quaternion;
  27415. /**
  27416. * The scale factor of the device in babylon space
  27417. */
  27418. deviceScaleFactor: number;
  27419. /**
  27420. * (Likely devicePosition should be used instead) The device position in its room space
  27421. */
  27422. position: Vector3;
  27423. /**
  27424. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  27425. */
  27426. rotationQuaternion: Quaternion;
  27427. /**
  27428. * The type of controller (Eg. Windows mixed reality)
  27429. */
  27430. controllerType: PoseEnabledControllerType;
  27431. protected _calculatedPosition: Vector3;
  27432. private _calculatedRotation;
  27433. /**
  27434. * The raw pose from the device
  27435. */
  27436. rawPose: DevicePose;
  27437. private _trackPosition;
  27438. private _maxRotationDistFromHeadset;
  27439. private _draggedRoomRotation;
  27440. /**
  27441. * @hidden
  27442. */
  27443. _disableTrackPosition(fixedPosition: Vector3): void;
  27444. /**
  27445. * Internal, the mesh attached to the controller
  27446. * @hidden
  27447. */
  27448. _mesh: Nullable<AbstractMesh>;
  27449. private _poseControlledCamera;
  27450. private _leftHandSystemQuaternion;
  27451. /**
  27452. * Internal, matrix used to convert room space to babylon space
  27453. * @hidden
  27454. */
  27455. _deviceToWorld: Matrix;
  27456. /**
  27457. * Node to be used when casting a ray from the controller
  27458. * @hidden
  27459. */
  27460. _pointingPoseNode: Nullable<TransformNode>;
  27461. /**
  27462. * Name of the child mesh that can be used to cast a ray from the controller
  27463. */
  27464. static readonly POINTING_POSE: string;
  27465. /**
  27466. * Creates a new PoseEnabledController from a gamepad
  27467. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  27468. */
  27469. constructor(browserGamepad: any);
  27470. private _workingMatrix;
  27471. /**
  27472. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  27473. */
  27474. update(): void;
  27475. /**
  27476. * Updates only the pose device and mesh without doing any button event checking
  27477. */
  27478. protected _updatePoseAndMesh(): void;
  27479. /**
  27480. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  27481. * @param poseData raw pose fromthe device
  27482. */
  27483. updateFromDevice(poseData: DevicePose): void;
  27484. /**
  27485. * @hidden
  27486. */
  27487. _meshAttachedObservable: Observable<AbstractMesh>;
  27488. /**
  27489. * Attaches a mesh to the controller
  27490. * @param mesh the mesh to be attached
  27491. */
  27492. attachToMesh(mesh: AbstractMesh): void;
  27493. /**
  27494. * Attaches the controllers mesh to a camera
  27495. * @param camera the camera the mesh should be attached to
  27496. */
  27497. attachToPoseControlledCamera(camera: TargetCamera): void;
  27498. /**
  27499. * Disposes of the controller
  27500. */
  27501. dispose(): void;
  27502. /**
  27503. * The mesh that is attached to the controller
  27504. */
  27505. get mesh(): Nullable<AbstractMesh>;
  27506. /**
  27507. * Gets the ray of the controller in the direction the controller is pointing
  27508. * @param length the length the resulting ray should be
  27509. * @returns a ray in the direction the controller is pointing
  27510. */
  27511. getForwardRay(length?: number): Ray;
  27512. }
  27513. }
  27514. declare module BABYLON {
  27515. /**
  27516. * Defines the WebVRController object that represents controllers tracked in 3D space
  27517. */
  27518. export abstract class WebVRController extends PoseEnabledController {
  27519. /**
  27520. * Internal, the default controller model for the controller
  27521. */
  27522. protected _defaultModel: Nullable<AbstractMesh>;
  27523. /**
  27524. * Fired when the trigger state has changed
  27525. */
  27526. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  27527. /**
  27528. * Fired when the main button state has changed
  27529. */
  27530. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27531. /**
  27532. * Fired when the secondary button state has changed
  27533. */
  27534. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27535. /**
  27536. * Fired when the pad state has changed
  27537. */
  27538. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  27539. /**
  27540. * Fired when controllers stick values have changed
  27541. */
  27542. onPadValuesChangedObservable: Observable<StickValues>;
  27543. /**
  27544. * Array of button availible on the controller
  27545. */
  27546. protected _buttons: Array<MutableGamepadButton>;
  27547. private _onButtonStateChange;
  27548. /**
  27549. * Fired when a controller button's state has changed
  27550. * @param callback the callback containing the button that was modified
  27551. */
  27552. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  27553. /**
  27554. * X and Y axis corresponding to the controllers joystick
  27555. */
  27556. pad: StickValues;
  27557. /**
  27558. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  27559. */
  27560. hand: string;
  27561. /**
  27562. * The default controller model for the controller
  27563. */
  27564. get defaultModel(): Nullable<AbstractMesh>;
  27565. /**
  27566. * Creates a new WebVRController from a gamepad
  27567. * @param vrGamepad the gamepad that the WebVRController should be created from
  27568. */
  27569. constructor(vrGamepad: any);
  27570. /**
  27571. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  27572. */
  27573. update(): void;
  27574. /**
  27575. * Function to be called when a button is modified
  27576. */
  27577. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  27578. /**
  27579. * Loads a mesh and attaches it to the controller
  27580. * @param scene the scene the mesh should be added to
  27581. * @param meshLoaded callback for when the mesh has been loaded
  27582. */
  27583. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  27584. private _setButtonValue;
  27585. private _changes;
  27586. private _checkChanges;
  27587. /**
  27588. * Disposes of th webVRCOntroller
  27589. */
  27590. dispose(): void;
  27591. }
  27592. }
  27593. declare module BABYLON {
  27594. /**
  27595. * The HemisphericLight simulates the ambient environment light,
  27596. * so the passed direction is the light reflection direction, not the incoming direction.
  27597. */
  27598. export class HemisphericLight extends Light {
  27599. /**
  27600. * The groundColor is the light in the opposite direction to the one specified during creation.
  27601. * 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.
  27602. */
  27603. groundColor: Color3;
  27604. /**
  27605. * The light reflection direction, not the incoming direction.
  27606. */
  27607. direction: Vector3;
  27608. /**
  27609. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  27610. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  27611. * The HemisphericLight can't cast shadows.
  27612. * Documentation : https://doc.babylonjs.com/babylon101/lights
  27613. * @param name The friendly name of the light
  27614. * @param direction The direction of the light reflection
  27615. * @param scene The scene the light belongs to
  27616. */
  27617. constructor(name: string, direction: Vector3, scene: Scene);
  27618. protected _buildUniformLayout(): void;
  27619. /**
  27620. * Returns the string "HemisphericLight".
  27621. * @return The class name
  27622. */
  27623. getClassName(): string;
  27624. /**
  27625. * Sets the HemisphericLight direction towards the passed target (Vector3).
  27626. * Returns the updated direction.
  27627. * @param target The target the direction should point to
  27628. * @return The computed direction
  27629. */
  27630. setDirectionToTarget(target: Vector3): Vector3;
  27631. /**
  27632. * Returns the shadow generator associated to the light.
  27633. * @returns Always null for hemispheric lights because it does not support shadows.
  27634. */
  27635. getShadowGenerator(): Nullable<IShadowGenerator>;
  27636. /**
  27637. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  27638. * @param effect The effect to update
  27639. * @param lightIndex The index of the light in the effect to update
  27640. * @returns The hemispheric light
  27641. */
  27642. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  27643. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  27644. /**
  27645. * Computes the world matrix of the node
  27646. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27647. * @param useWasUpdatedFlag defines a reserved property
  27648. * @returns the world matrix
  27649. */
  27650. computeWorldMatrix(): Matrix;
  27651. /**
  27652. * Returns the integer 3.
  27653. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  27654. */
  27655. getTypeID(): number;
  27656. /**
  27657. * Prepares the list of defines specific to the light type.
  27658. * @param defines the list of defines
  27659. * @param lightIndex defines the index of the light for the effect
  27660. */
  27661. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  27662. }
  27663. }
  27664. declare module BABYLON {
  27665. /** @hidden */
  27666. export var vrMultiviewToSingleviewPixelShader: {
  27667. name: string;
  27668. shader: string;
  27669. };
  27670. }
  27671. declare module BABYLON {
  27672. /**
  27673. * Renders to multiple views with a single draw call
  27674. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  27675. */
  27676. export class MultiviewRenderTarget extends RenderTargetTexture {
  27677. /**
  27678. * Creates a multiview render target
  27679. * @param scene scene used with the render target
  27680. * @param size the size of the render target (used for each view)
  27681. */
  27682. constructor(scene: Scene, size?: number | {
  27683. width: number;
  27684. height: number;
  27685. } | {
  27686. ratio: number;
  27687. });
  27688. /**
  27689. * @hidden
  27690. * @param faceIndex the face index, if its a cube texture
  27691. */
  27692. _bindFrameBuffer(faceIndex?: number): void;
  27693. /**
  27694. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  27695. * @returns the view count
  27696. */
  27697. getViewCount(): number;
  27698. }
  27699. }
  27700. declare module BABYLON {
  27701. interface Engine {
  27702. /**
  27703. * Creates a new multiview render target
  27704. * @param width defines the width of the texture
  27705. * @param height defines the height of the texture
  27706. * @returns the created multiview texture
  27707. */
  27708. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  27709. /**
  27710. * Binds a multiview framebuffer to be drawn to
  27711. * @param multiviewTexture texture to bind
  27712. */
  27713. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  27714. }
  27715. interface Camera {
  27716. /**
  27717. * @hidden
  27718. * 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)
  27719. */
  27720. _useMultiviewToSingleView: boolean;
  27721. /**
  27722. * @hidden
  27723. * 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)
  27724. */
  27725. _multiviewTexture: Nullable<RenderTargetTexture>;
  27726. /**
  27727. * @hidden
  27728. * ensures the multiview texture of the camera exists and has the specified width/height
  27729. * @param width height to set on the multiview texture
  27730. * @param height width to set on the multiview texture
  27731. */
  27732. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  27733. }
  27734. interface Scene {
  27735. /** @hidden */
  27736. _transformMatrixR: Matrix;
  27737. /** @hidden */
  27738. _multiviewSceneUbo: Nullable<UniformBuffer>;
  27739. /** @hidden */
  27740. _createMultiviewUbo(): void;
  27741. /** @hidden */
  27742. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  27743. /** @hidden */
  27744. _renderMultiviewToSingleView(camera: Camera): void;
  27745. }
  27746. }
  27747. declare module BABYLON {
  27748. /**
  27749. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  27750. * This will not be used for webXR as it supports displaying texture arrays directly
  27751. */
  27752. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  27753. /**
  27754. * Gets a string identifying the name of the class
  27755. * @returns "VRMultiviewToSingleviewPostProcess" string
  27756. */
  27757. getClassName(): string;
  27758. /**
  27759. * Initializes a VRMultiviewToSingleview
  27760. * @param name name of the post process
  27761. * @param camera camera to be applied to
  27762. * @param scaleFactor scaling factor to the size of the output texture
  27763. */
  27764. constructor(name: string, camera: Camera, scaleFactor: number);
  27765. }
  27766. }
  27767. declare module BABYLON {
  27768. /**
  27769. * Interface used to define additional presentation attributes
  27770. */
  27771. export interface IVRPresentationAttributes {
  27772. /**
  27773. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  27774. */
  27775. highRefreshRate: boolean;
  27776. /**
  27777. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  27778. */
  27779. foveationLevel: number;
  27780. }
  27781. interface Engine {
  27782. /** @hidden */
  27783. _vrDisplay: any;
  27784. /** @hidden */
  27785. _vrSupported: boolean;
  27786. /** @hidden */
  27787. _oldSize: Size;
  27788. /** @hidden */
  27789. _oldHardwareScaleFactor: number;
  27790. /** @hidden */
  27791. _vrExclusivePointerMode: boolean;
  27792. /** @hidden */
  27793. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  27794. /** @hidden */
  27795. _onVRDisplayPointerRestricted: () => void;
  27796. /** @hidden */
  27797. _onVRDisplayPointerUnrestricted: () => void;
  27798. /** @hidden */
  27799. _onVrDisplayConnect: Nullable<(display: any) => void>;
  27800. /** @hidden */
  27801. _onVrDisplayDisconnect: Nullable<() => void>;
  27802. /** @hidden */
  27803. _onVrDisplayPresentChange: Nullable<() => void>;
  27804. /**
  27805. * Observable signaled when VR display mode changes
  27806. */
  27807. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27808. /**
  27809. * Observable signaled when VR request present is complete
  27810. */
  27811. onVRRequestPresentComplete: Observable<boolean>;
  27812. /**
  27813. * Observable signaled when VR request present starts
  27814. */
  27815. onVRRequestPresentStart: Observable<Engine>;
  27816. /**
  27817. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27818. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27819. */
  27820. isInVRExclusivePointerMode: boolean;
  27821. /**
  27822. * Gets a boolean indicating if a webVR device was detected
  27823. * @returns true if a webVR device was detected
  27824. */
  27825. isVRDevicePresent(): boolean;
  27826. /**
  27827. * Gets the current webVR device
  27828. * @returns the current webVR device (or null)
  27829. */
  27830. getVRDevice(): any;
  27831. /**
  27832. * Initializes a webVR display and starts listening to display change events
  27833. * The onVRDisplayChangedObservable will be notified upon these changes
  27834. * @returns A promise containing a VRDisplay and if vr is supported
  27835. */
  27836. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27837. /** @hidden */
  27838. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  27839. /**
  27840. * Gets or sets the presentation attributes used to configure VR rendering
  27841. */
  27842. vrPresentationAttributes?: IVRPresentationAttributes;
  27843. /**
  27844. * Call this function to switch to webVR mode
  27845. * Will do nothing if webVR is not supported or if there is no webVR device
  27846. * @param options the webvr options provided to the camera. mainly used for multiview
  27847. * @see https://doc.babylonjs.com/how_to/webvr_camera
  27848. */
  27849. enableVR(options: WebVROptions): void;
  27850. /** @hidden */
  27851. _onVRFullScreenTriggered(): void;
  27852. }
  27853. }
  27854. declare module BABYLON {
  27855. /**
  27856. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  27857. * IMPORTANT!! The data is right-hand data.
  27858. * @export
  27859. * @interface DevicePose
  27860. */
  27861. export interface DevicePose {
  27862. /**
  27863. * The position of the device, values in array are [x,y,z].
  27864. */
  27865. readonly position: Nullable<Float32Array>;
  27866. /**
  27867. * The linearVelocity of the device, values in array are [x,y,z].
  27868. */
  27869. readonly linearVelocity: Nullable<Float32Array>;
  27870. /**
  27871. * The linearAcceleration of the device, values in array are [x,y,z].
  27872. */
  27873. readonly linearAcceleration: Nullable<Float32Array>;
  27874. /**
  27875. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  27876. */
  27877. readonly orientation: Nullable<Float32Array>;
  27878. /**
  27879. * The angularVelocity of the device, values in array are [x,y,z].
  27880. */
  27881. readonly angularVelocity: Nullable<Float32Array>;
  27882. /**
  27883. * The angularAcceleration of the device, values in array are [x,y,z].
  27884. */
  27885. readonly angularAcceleration: Nullable<Float32Array>;
  27886. }
  27887. /**
  27888. * Interface representing a pose controlled object in Babylon.
  27889. * A pose controlled object has both regular pose values as well as pose values
  27890. * from an external device such as a VR head mounted display
  27891. */
  27892. export interface PoseControlled {
  27893. /**
  27894. * The position of the object in babylon space.
  27895. */
  27896. position: Vector3;
  27897. /**
  27898. * The rotation quaternion of the object in babylon space.
  27899. */
  27900. rotationQuaternion: Quaternion;
  27901. /**
  27902. * The position of the device in babylon space.
  27903. */
  27904. devicePosition?: Vector3;
  27905. /**
  27906. * The rotation quaternion of the device in babylon space.
  27907. */
  27908. deviceRotationQuaternion: Quaternion;
  27909. /**
  27910. * The raw pose coming from the device.
  27911. */
  27912. rawPose: Nullable<DevicePose>;
  27913. /**
  27914. * The scale of the device to be used when translating from device space to babylon space.
  27915. */
  27916. deviceScaleFactor: number;
  27917. /**
  27918. * Updates the poseControlled values based on the input device pose.
  27919. * @param poseData the pose data to update the object with
  27920. */
  27921. updateFromDevice(poseData: DevicePose): void;
  27922. }
  27923. /**
  27924. * Set of options to customize the webVRCamera
  27925. */
  27926. export interface WebVROptions {
  27927. /**
  27928. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  27929. */
  27930. trackPosition?: boolean;
  27931. /**
  27932. * Sets the scale of the vrDevice in babylon space. (default: 1)
  27933. */
  27934. positionScale?: number;
  27935. /**
  27936. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  27937. */
  27938. displayName?: string;
  27939. /**
  27940. * Should the native controller meshes be initialized. (default: true)
  27941. */
  27942. controllerMeshes?: boolean;
  27943. /**
  27944. * Creating a default HemiLight only on controllers. (default: true)
  27945. */
  27946. defaultLightingOnControllers?: boolean;
  27947. /**
  27948. * If you don't want to use the default VR button of the helper. (default: false)
  27949. */
  27950. useCustomVRButton?: boolean;
  27951. /**
  27952. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  27953. */
  27954. customVRButton?: HTMLButtonElement;
  27955. /**
  27956. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  27957. */
  27958. rayLength?: number;
  27959. /**
  27960. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  27961. */
  27962. defaultHeight?: number;
  27963. /**
  27964. * If multiview should be used if available (default: false)
  27965. */
  27966. useMultiview?: boolean;
  27967. }
  27968. /**
  27969. * This represents a WebVR camera.
  27970. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  27971. * @example https://doc.babylonjs.com/how_to/webvr_camera
  27972. */
  27973. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  27974. private webVROptions;
  27975. /**
  27976. * @hidden
  27977. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  27978. */
  27979. _vrDevice: any;
  27980. /**
  27981. * The rawPose of the vrDevice.
  27982. */
  27983. rawPose: Nullable<DevicePose>;
  27984. private _onVREnabled;
  27985. private _specsVersion;
  27986. private _attached;
  27987. private _frameData;
  27988. protected _descendants: Array<Node>;
  27989. private _deviceRoomPosition;
  27990. /** @hidden */
  27991. _deviceRoomRotationQuaternion: Quaternion;
  27992. private _standingMatrix;
  27993. /**
  27994. * Represents device position in babylon space.
  27995. */
  27996. devicePosition: Vector3;
  27997. /**
  27998. * Represents device rotation in babylon space.
  27999. */
  28000. deviceRotationQuaternion: Quaternion;
  28001. /**
  28002. * The scale of the device to be used when translating from device space to babylon space.
  28003. */
  28004. deviceScaleFactor: number;
  28005. private _deviceToWorld;
  28006. private _worldToDevice;
  28007. /**
  28008. * References to the webVR controllers for the vrDevice.
  28009. */
  28010. controllers: Array<WebVRController>;
  28011. /**
  28012. * Emits an event when a controller is attached.
  28013. */
  28014. onControllersAttachedObservable: Observable<WebVRController[]>;
  28015. /**
  28016. * Emits an event when a controller's mesh has been loaded;
  28017. */
  28018. onControllerMeshLoadedObservable: Observable<WebVRController>;
  28019. /**
  28020. * Emits an event when the HMD's pose has been updated.
  28021. */
  28022. onPoseUpdatedFromDeviceObservable: Observable<any>;
  28023. private _poseSet;
  28024. /**
  28025. * If the rig cameras be used as parent instead of this camera.
  28026. */
  28027. rigParenting: boolean;
  28028. private _lightOnControllers;
  28029. private _defaultHeight?;
  28030. /**
  28031. * Instantiates a WebVRFreeCamera.
  28032. * @param name The name of the WebVRFreeCamera
  28033. * @param position The starting anchor position for the camera
  28034. * @param scene The scene the camera belongs to
  28035. * @param webVROptions a set of customizable options for the webVRCamera
  28036. */
  28037. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  28038. /**
  28039. * Gets the device distance from the ground in meters.
  28040. * @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.
  28041. */
  28042. deviceDistanceToRoomGround(): number;
  28043. /**
  28044. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28045. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  28046. */
  28047. useStandingMatrix(callback?: (bool: boolean) => void): void;
  28048. /**
  28049. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28050. * @returns A promise with a boolean set to if the standing matrix is supported.
  28051. */
  28052. useStandingMatrixAsync(): Promise<boolean>;
  28053. /**
  28054. * Disposes the camera
  28055. */
  28056. dispose(): void;
  28057. /**
  28058. * Gets a vrController by name.
  28059. * @param name The name of the controller to retreive
  28060. * @returns the controller matching the name specified or null if not found
  28061. */
  28062. getControllerByName(name: string): Nullable<WebVRController>;
  28063. private _leftController;
  28064. /**
  28065. * The controller corresponding to the users left hand.
  28066. */
  28067. get leftController(): Nullable<WebVRController>;
  28068. private _rightController;
  28069. /**
  28070. * The controller corresponding to the users right hand.
  28071. */
  28072. get rightController(): Nullable<WebVRController>;
  28073. /**
  28074. * Casts a ray forward from the vrCamera's gaze.
  28075. * @param length Length of the ray (default: 100)
  28076. * @returns the ray corresponding to the gaze
  28077. */
  28078. getForwardRay(length?: number): Ray;
  28079. /**
  28080. * @hidden
  28081. * Updates the camera based on device's frame data
  28082. */
  28083. _checkInputs(): void;
  28084. /**
  28085. * Updates the poseControlled values based on the input device pose.
  28086. * @param poseData Pose coming from the device
  28087. */
  28088. updateFromDevice(poseData: DevicePose): void;
  28089. private _detachIfAttached;
  28090. /**
  28091. * WebVR's attach control will start broadcasting frames to the device.
  28092. * Note that in certain browsers (chrome for example) this function must be called
  28093. * within a user-interaction callback. Example:
  28094. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  28095. *
  28096. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  28097. */
  28098. attachControl(noPreventDefault?: boolean): void;
  28099. /**
  28100. * Detach the current controls from the specified dom element.
  28101. */
  28102. detachControl(): void;
  28103. /**
  28104. * @returns the name of this class
  28105. */
  28106. getClassName(): string;
  28107. /**
  28108. * Calls resetPose on the vrDisplay
  28109. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  28110. */
  28111. resetToCurrentRotation(): void;
  28112. /**
  28113. * @hidden
  28114. * Updates the rig cameras (left and right eye)
  28115. */
  28116. _updateRigCameras(): void;
  28117. private _workingVector;
  28118. private _oneVector;
  28119. private _workingMatrix;
  28120. private updateCacheCalled;
  28121. private _correctPositionIfNotTrackPosition;
  28122. /**
  28123. * @hidden
  28124. * Updates the cached values of the camera
  28125. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  28126. */
  28127. _updateCache(ignoreParentClass?: boolean): void;
  28128. /**
  28129. * @hidden
  28130. * Get current device position in babylon world
  28131. */
  28132. _computeDevicePosition(): void;
  28133. /**
  28134. * Updates the current device position and rotation in the babylon world
  28135. */
  28136. update(): void;
  28137. /**
  28138. * @hidden
  28139. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  28140. * @returns an identity matrix
  28141. */
  28142. _getViewMatrix(): Matrix;
  28143. private _tmpMatrix;
  28144. /**
  28145. * This function is called by the two RIG cameras.
  28146. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  28147. * @hidden
  28148. */
  28149. _getWebVRViewMatrix(): Matrix;
  28150. /** @hidden */
  28151. _getWebVRProjectionMatrix(): Matrix;
  28152. private _onGamepadConnectedObserver;
  28153. private _onGamepadDisconnectedObserver;
  28154. private _updateCacheWhenTrackingDisabledObserver;
  28155. /**
  28156. * Initializes the controllers and their meshes
  28157. */
  28158. initControllers(): void;
  28159. }
  28160. }
  28161. declare module BABYLON {
  28162. /**
  28163. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  28164. *
  28165. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  28166. *
  28167. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  28168. */
  28169. export class MaterialHelper {
  28170. /**
  28171. * Bind the current view position to an effect.
  28172. * @param effect The effect to be bound
  28173. * @param scene The scene the eyes position is used from
  28174. * @param variableName name of the shader variable that will hold the eye position
  28175. * @param isVector3 true to indicates that variableName is a Vector3 and not a Vector4
  28176. * @return the computed eye position
  28177. */
  28178. static BindEyePosition(effect: Nullable<Effect>, scene: Scene, variableName?: string, isVector3?: boolean): Vector4;
  28179. /**
  28180. * Update the scene ubo before it can be used in rendering processing
  28181. * @param scene the scene to retrieve the ubo from
  28182. * @returns the scene UniformBuffer
  28183. */
  28184. static FinalizeSceneUbo(scene: Scene): UniformBuffer;
  28185. /**
  28186. * Binds the scene's uniform buffer to the effect.
  28187. * @param effect defines the effect to bind to the scene uniform buffer
  28188. * @param sceneUbo defines the uniform buffer storing scene data
  28189. */
  28190. static BindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  28191. /**
  28192. * Helps preparing the defines values about the UVs in used in the effect.
  28193. * UVs are shared as much as we can across channels in the shaders.
  28194. * @param texture The texture we are preparing the UVs for
  28195. * @param defines The defines to update
  28196. * @param key The channel key "diffuse", "specular"... used in the shader
  28197. */
  28198. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  28199. /**
  28200. * Binds a texture matrix value to its corresponding uniform
  28201. * @param texture The texture to bind the matrix for
  28202. * @param uniformBuffer The uniform buffer receiving the data
  28203. * @param key The channel key "diffuse", "specular"... used in the shader
  28204. */
  28205. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  28206. /**
  28207. * Gets the current status of the fog (should it be enabled?)
  28208. * @param mesh defines the mesh to evaluate for fog support
  28209. * @param scene defines the hosting scene
  28210. * @returns true if fog must be enabled
  28211. */
  28212. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  28213. /**
  28214. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  28215. * @param mesh defines the current mesh
  28216. * @param scene defines the current scene
  28217. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  28218. * @param pointsCloud defines if point cloud rendering has to be turned on
  28219. * @param fogEnabled defines if fog has to be turned on
  28220. * @param alphaTest defines if alpha testing has to be turned on
  28221. * @param defines defines the current list of defines
  28222. */
  28223. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  28224. /**
  28225. * Helper used to prepare the list of defines associated with frame values for shader compilation
  28226. * @param scene defines the current scene
  28227. * @param engine defines the current engine
  28228. * @param defines specifies the list of active defines
  28229. * @param useInstances defines if instances have to be turned on
  28230. * @param useClipPlane defines if clip plane have to be turned on
  28231. * @param useInstances defines if instances have to be turned on
  28232. * @param useThinInstances defines if thin instances have to be turned on
  28233. */
  28234. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  28235. /**
  28236. * Prepares the defines for bones
  28237. * @param mesh The mesh containing the geometry data we will draw
  28238. * @param defines The defines to update
  28239. */
  28240. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  28241. /**
  28242. * Prepares the defines for morph targets
  28243. * @param mesh The mesh containing the geometry data we will draw
  28244. * @param defines The defines to update
  28245. */
  28246. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  28247. /**
  28248. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  28249. * @param mesh The mesh containing the geometry data we will draw
  28250. * @param defines The defines to update
  28251. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  28252. * @param useBones Precise whether bones should be used or not (override mesh info)
  28253. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  28254. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  28255. * @returns false if defines are considered not dirty and have not been checked
  28256. */
  28257. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  28258. /**
  28259. * Prepares the defines related to multiview
  28260. * @param scene The scene we are intending to draw
  28261. * @param defines The defines to update
  28262. */
  28263. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  28264. /**
  28265. * Prepares the defines related to the prepass
  28266. * @param scene The scene we are intending to draw
  28267. * @param defines The defines to update
  28268. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  28269. */
  28270. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  28271. /**
  28272. * Prepares the defines related to the light information passed in parameter
  28273. * @param scene The scene we are intending to draw
  28274. * @param mesh The mesh the effect is compiling for
  28275. * @param light The light the effect is compiling for
  28276. * @param lightIndex The index of the light
  28277. * @param defines The defines to update
  28278. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28279. * @param state Defines the current state regarding what is needed (normals, etc...)
  28280. */
  28281. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  28282. needNormals: boolean;
  28283. needRebuild: boolean;
  28284. shadowEnabled: boolean;
  28285. specularEnabled: boolean;
  28286. lightmapMode: boolean;
  28287. }): void;
  28288. /**
  28289. * Prepares the defines related to the light information passed in parameter
  28290. * @param scene The scene we are intending to draw
  28291. * @param mesh The mesh the effect is compiling for
  28292. * @param defines The defines to update
  28293. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28294. * @param maxSimultaneousLights Specifies how manuy lights can be added to the effect at max
  28295. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  28296. * @returns true if normals will be required for the rest of the effect
  28297. */
  28298. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  28299. /**
  28300. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  28301. * @param lightIndex defines the light index
  28302. * @param uniformsList The uniform list
  28303. * @param samplersList The sampler list
  28304. * @param projectedLightTexture defines if projected texture must be used
  28305. * @param uniformBuffersList defines an optional list of uniform buffers
  28306. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  28307. */
  28308. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  28309. /**
  28310. * Prepares the uniforms and samplers list to be used in the effect
  28311. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the list and extra information
  28312. * @param samplersList The sampler list
  28313. * @param defines The defines helping in the list generation
  28314. * @param maxSimultaneousLights The maximum number of simultaneous light allowed in the effect
  28315. */
  28316. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  28317. /**
  28318. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  28319. * @param defines The defines to update while falling back
  28320. * @param fallbacks The authorized effect fallbacks
  28321. * @param maxSimultaneousLights The maximum number of lights allowed
  28322. * @param rank the current rank of the Effect
  28323. * @returns The newly affected rank
  28324. */
  28325. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  28326. private static _TmpMorphInfluencers;
  28327. /**
  28328. * Prepares the list of attributes required for morph targets according to the effect defines.
  28329. * @param attribs The current list of supported attribs
  28330. * @param mesh The mesh to prepare the morph targets attributes for
  28331. * @param influencers The number of influencers
  28332. */
  28333. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  28334. /**
  28335. * Prepares the list of attributes required for morph targets according to the effect defines.
  28336. * @param attribs The current list of supported attribs
  28337. * @param mesh The mesh to prepare the morph targets attributes for
  28338. * @param defines The current Defines of the effect
  28339. */
  28340. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  28341. /**
  28342. * Prepares the list of attributes required for bones according to the effect defines.
  28343. * @param attribs The current list of supported attribs
  28344. * @param mesh The mesh to prepare the bones attributes for
  28345. * @param defines The current Defines of the effect
  28346. * @param fallbacks The current effect fallback strategy
  28347. */
  28348. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  28349. /**
  28350. * Check and prepare the list of attributes required for instances according to the effect defines.
  28351. * @param attribs The current list of supported attribs
  28352. * @param defines The current MaterialDefines of the effect
  28353. */
  28354. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  28355. /**
  28356. * Add the list of attributes required for instances to the attribs array.
  28357. * @param attribs The current list of supported attribs
  28358. */
  28359. static PushAttributesForInstances(attribs: string[]): void;
  28360. /**
  28361. * Binds the light information to the effect.
  28362. * @param light The light containing the generator
  28363. * @param effect The effect we are binding the data to
  28364. * @param lightIndex The light index in the effect used to render
  28365. */
  28366. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  28367. /**
  28368. * Binds the lights information from the scene to the effect for the given mesh.
  28369. * @param light Light to bind
  28370. * @param lightIndex Light index
  28371. * @param scene The scene where the light belongs to
  28372. * @param effect The effect we are binding the data to
  28373. * @param useSpecular Defines if specular is supported
  28374. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28375. */
  28376. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  28377. /**
  28378. * Binds the lights information from the scene to the effect for the given mesh.
  28379. * @param scene The scene the lights belongs to
  28380. * @param mesh The mesh we are binding the information to render
  28381. * @param effect The effect we are binding the data to
  28382. * @param defines The generated defines for the effect
  28383. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  28384. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28385. */
  28386. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  28387. private static _tempFogColor;
  28388. /**
  28389. * Binds the fog information from the scene to the effect for the given mesh.
  28390. * @param scene The scene the lights belongs to
  28391. * @param mesh The mesh we are binding the information to render
  28392. * @param effect The effect we are binding the data to
  28393. * @param linearSpace Defines if the fog effect is applied in linear space
  28394. */
  28395. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  28396. /**
  28397. * Binds the bones information from the mesh to the effect.
  28398. * @param mesh The mesh we are binding the information to render
  28399. * @param effect The effect we are binding the data to
  28400. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  28401. */
  28402. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  28403. private static _CopyBonesTransformationMatrices;
  28404. /**
  28405. * Binds the morph targets information from the mesh to the effect.
  28406. * @param abstractMesh The mesh we are binding the information to render
  28407. * @param effect The effect we are binding the data to
  28408. */
  28409. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  28410. /**
  28411. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  28412. * @param defines The generated defines used in the effect
  28413. * @param effect The effect we are binding the data to
  28414. * @param scene The scene we are willing to render with logarithmic scale for
  28415. */
  28416. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  28417. /**
  28418. * Binds the clip plane information from the scene to the effect.
  28419. * @param scene The scene the clip plane information are extracted from
  28420. * @param effect The effect we are binding the data to
  28421. */
  28422. static BindClipPlane(effect: Effect, scene: Scene): void;
  28423. }
  28424. }
  28425. declare module BABYLON {
  28426. /** @hidden */
  28427. export var bayerDitherFunctions: {
  28428. name: string;
  28429. shader: string;
  28430. };
  28431. }
  28432. declare module BABYLON {
  28433. /** @hidden */
  28434. export var shadowMapFragmentDeclaration: {
  28435. name: string;
  28436. shader: string;
  28437. };
  28438. }
  28439. declare module BABYLON {
  28440. /** @hidden */
  28441. export var shadowMapFragment: {
  28442. name: string;
  28443. shader: string;
  28444. };
  28445. }
  28446. declare module BABYLON {
  28447. /** @hidden */
  28448. export var shadowMapPixelShader: {
  28449. name: string;
  28450. shader: string;
  28451. };
  28452. }
  28453. declare module BABYLON {
  28454. /** @hidden */
  28455. export var shadowMapVertexDeclaration: {
  28456. name: string;
  28457. shader: string;
  28458. };
  28459. }
  28460. declare module BABYLON {
  28461. /** @hidden */
  28462. export var shadowMapVertexNormalBias: {
  28463. name: string;
  28464. shader: string;
  28465. };
  28466. }
  28467. declare module BABYLON {
  28468. /** @hidden */
  28469. export var shadowMapVertexMetric: {
  28470. name: string;
  28471. shader: string;
  28472. };
  28473. }
  28474. declare module BABYLON {
  28475. /** @hidden */
  28476. export var shadowMapVertexShader: {
  28477. name: string;
  28478. shader: string;
  28479. };
  28480. }
  28481. declare module BABYLON {
  28482. /** @hidden */
  28483. export var depthBoxBlurPixelShader: {
  28484. name: string;
  28485. shader: string;
  28486. };
  28487. }
  28488. declare module BABYLON {
  28489. /** @hidden */
  28490. export var shadowMapFragmentSoftTransparentShadow: {
  28491. name: string;
  28492. shader: string;
  28493. };
  28494. }
  28495. declare module BABYLON {
  28496. /**
  28497. * Creates an instance based on a source mesh.
  28498. */
  28499. export class InstancedMesh extends AbstractMesh {
  28500. private _sourceMesh;
  28501. private _currentLOD;
  28502. /** @hidden */
  28503. _indexInSourceMeshInstanceArray: number;
  28504. constructor(name: string, source: Mesh);
  28505. /**
  28506. * Returns the string "InstancedMesh".
  28507. */
  28508. getClassName(): string;
  28509. /** Gets the list of lights affecting that mesh */
  28510. get lightSources(): Light[];
  28511. _resyncLightSources(): void;
  28512. _resyncLightSource(light: Light): void;
  28513. _removeLightSource(light: Light, dispose: boolean): void;
  28514. /**
  28515. * If the source mesh receives shadows
  28516. */
  28517. get receiveShadows(): boolean;
  28518. /**
  28519. * The material of the source mesh
  28520. */
  28521. get material(): Nullable<Material>;
  28522. /**
  28523. * Visibility of the source mesh
  28524. */
  28525. get visibility(): number;
  28526. /**
  28527. * Skeleton of the source mesh
  28528. */
  28529. get skeleton(): Nullable<Skeleton>;
  28530. /**
  28531. * Rendering ground id of the source mesh
  28532. */
  28533. get renderingGroupId(): number;
  28534. set renderingGroupId(value: number);
  28535. /**
  28536. * Returns the total number of vertices (integer).
  28537. */
  28538. getTotalVertices(): number;
  28539. /**
  28540. * Returns a positive integer : the total number of indices in this mesh geometry.
  28541. * @returns the numner of indices or zero if the mesh has no geometry.
  28542. */
  28543. getTotalIndices(): number;
  28544. /**
  28545. * The source mesh of the instance
  28546. */
  28547. get sourceMesh(): Mesh;
  28548. /**
  28549. * Creates a new InstancedMesh object from the mesh model.
  28550. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28551. * @param name defines the name of the new instance
  28552. * @returns a new InstancedMesh
  28553. */
  28554. createInstance(name: string): InstancedMesh;
  28555. /**
  28556. * Is this node ready to be used/rendered
  28557. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28558. * @return {boolean} is it ready
  28559. */
  28560. isReady(completeCheck?: boolean): boolean;
  28561. /**
  28562. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28563. * @param kind kind of verticies to retrieve (eg. positions, normals, uvs, etc.)
  28564. * @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.
  28565. * @returns a float array or a Float32Array of the requested kind of data : positions, normals, uvs, etc.
  28566. */
  28567. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  28568. /**
  28569. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28570. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28571. * The `data` are either a numeric array either a Float32Array.
  28572. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initially none) or updater.
  28573. * 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).
  28574. * Note that a new underlying VertexBuffer object is created each call.
  28575. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28576. *
  28577. * Possible `kind` values :
  28578. * - VertexBuffer.PositionKind
  28579. * - VertexBuffer.UVKind
  28580. * - VertexBuffer.UV2Kind
  28581. * - VertexBuffer.UV3Kind
  28582. * - VertexBuffer.UV4Kind
  28583. * - VertexBuffer.UV5Kind
  28584. * - VertexBuffer.UV6Kind
  28585. * - VertexBuffer.ColorKind
  28586. * - VertexBuffer.MatricesIndicesKind
  28587. * - VertexBuffer.MatricesIndicesExtraKind
  28588. * - VertexBuffer.MatricesWeightsKind
  28589. * - VertexBuffer.MatricesWeightsExtraKind
  28590. *
  28591. * Returns the Mesh.
  28592. */
  28593. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28594. /**
  28595. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28596. * If the mesh has no geometry, it is simply returned as it is.
  28597. * The `data` are either a numeric array either a Float32Array.
  28598. * No new underlying VertexBuffer object is created.
  28599. * 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.
  28600. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  28601. *
  28602. * Possible `kind` values :
  28603. * - VertexBuffer.PositionKind
  28604. * - VertexBuffer.UVKind
  28605. * - VertexBuffer.UV2Kind
  28606. * - VertexBuffer.UV3Kind
  28607. * - VertexBuffer.UV4Kind
  28608. * - VertexBuffer.UV5Kind
  28609. * - VertexBuffer.UV6Kind
  28610. * - VertexBuffer.ColorKind
  28611. * - VertexBuffer.MatricesIndicesKind
  28612. * - VertexBuffer.MatricesIndicesExtraKind
  28613. * - VertexBuffer.MatricesWeightsKind
  28614. * - VertexBuffer.MatricesWeightsExtraKind
  28615. *
  28616. * Returns the Mesh.
  28617. */
  28618. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  28619. /**
  28620. * Sets the mesh indices.
  28621. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  28622. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28623. * This method creates a new index buffer each call.
  28624. * Returns the Mesh.
  28625. */
  28626. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  28627. /**
  28628. * Boolean : True if the mesh owns the requested kind of data.
  28629. */
  28630. isVerticesDataPresent(kind: string): boolean;
  28631. /**
  28632. * Returns an array of indices (IndicesArray).
  28633. */
  28634. getIndices(): Nullable<IndicesArray>;
  28635. get _positions(): Nullable<Vector3[]>;
  28636. /**
  28637. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28638. * This means the mesh underlying bounding box and sphere are recomputed.
  28639. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28640. * @returns the current mesh
  28641. */
  28642. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  28643. /** @hidden */
  28644. _preActivate(): InstancedMesh;
  28645. /** @hidden */
  28646. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28647. /** @hidden */
  28648. _postActivate(): void;
  28649. getWorldMatrix(): Matrix;
  28650. get isAnInstance(): boolean;
  28651. /**
  28652. * Returns the current associated LOD AbstractMesh.
  28653. */
  28654. getLOD(camera: Camera): AbstractMesh;
  28655. /** @hidden */
  28656. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28657. /** @hidden */
  28658. _syncSubMeshes(): InstancedMesh;
  28659. /** @hidden */
  28660. _generatePointsArray(): boolean;
  28661. /** @hidden */
  28662. _updateBoundingInfo(): AbstractMesh;
  28663. /**
  28664. * Creates a new InstancedMesh from the current mesh.
  28665. * - name (string) : the cloned mesh name
  28666. * - newParent (optional Node) : the optional Node to parent the clone to.
  28667. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  28668. *
  28669. * Returns the clone.
  28670. */
  28671. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  28672. /**
  28673. * Disposes the InstancedMesh.
  28674. * Returns nothing.
  28675. */
  28676. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28677. }
  28678. interface Mesh {
  28679. /**
  28680. * Register a custom buffer that will be instanced
  28681. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28682. * @param kind defines the buffer kind
  28683. * @param stride defines the stride in floats
  28684. */
  28685. registerInstancedBuffer(kind: string, stride: number): void;
  28686. /**
  28687. * Invalidate VertexArrayObjects belonging to the mesh (but not to the Geometry of the mesh).
  28688. */
  28689. _invalidateInstanceVertexArrayObject(): void;
  28690. /**
  28691. * true to use the edge renderer for all instances of this mesh
  28692. */
  28693. edgesShareWithInstances: boolean;
  28694. /** @hidden */
  28695. _userInstancedBuffersStorage: {
  28696. data: {
  28697. [key: string]: Float32Array;
  28698. };
  28699. sizes: {
  28700. [key: string]: number;
  28701. };
  28702. vertexBuffers: {
  28703. [key: string]: Nullable<VertexBuffer>;
  28704. };
  28705. strides: {
  28706. [key: string]: number;
  28707. };
  28708. vertexArrayObjects?: {
  28709. [key: string]: WebGLVertexArrayObject;
  28710. };
  28711. };
  28712. }
  28713. interface AbstractMesh {
  28714. /**
  28715. * Object used to store instanced buffers defined by user
  28716. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28717. */
  28718. instancedBuffers: {
  28719. [key: string]: any;
  28720. };
  28721. }
  28722. }
  28723. declare module BABYLON {
  28724. /**
  28725. * Defines the options associated with the creation of a shader material.
  28726. */
  28727. export interface IShaderMaterialOptions {
  28728. /**
  28729. * Does the material work in alpha blend mode
  28730. */
  28731. needAlphaBlending: boolean;
  28732. /**
  28733. * Does the material work in alpha test mode
  28734. */
  28735. needAlphaTesting: boolean;
  28736. /**
  28737. * The list of attribute names used in the shader
  28738. */
  28739. attributes: string[];
  28740. /**
  28741. * The list of uniform names used in the shader
  28742. */
  28743. uniforms: string[];
  28744. /**
  28745. * The list of UBO names used in the shader
  28746. */
  28747. uniformBuffers: string[];
  28748. /**
  28749. * The list of sampler names used in the shader
  28750. */
  28751. samplers: string[];
  28752. /**
  28753. * The list of defines used in the shader
  28754. */
  28755. defines: string[];
  28756. }
  28757. /**
  28758. * 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.
  28759. *
  28760. * This returned material effects how the mesh will look based on the code in the shaders.
  28761. *
  28762. * @see https://doc.babylonjs.com/how_to/shader_material
  28763. */
  28764. export class ShaderMaterial extends Material {
  28765. private _shaderPath;
  28766. private _options;
  28767. private _textures;
  28768. private _textureArrays;
  28769. private _floats;
  28770. private _ints;
  28771. private _floatsArrays;
  28772. private _colors3;
  28773. private _colors3Arrays;
  28774. private _colors4;
  28775. private _colors4Arrays;
  28776. private _vectors2;
  28777. private _vectors3;
  28778. private _vectors4;
  28779. private _matrices;
  28780. private _matrixArrays;
  28781. private _matrices3x3;
  28782. private _matrices2x2;
  28783. private _vectors2Arrays;
  28784. private _vectors3Arrays;
  28785. private _vectors4Arrays;
  28786. private _cachedWorldViewMatrix;
  28787. private _cachedWorldViewProjectionMatrix;
  28788. private _renderId;
  28789. private _multiview;
  28790. private _cachedDefines;
  28791. /** Define the Url to load snippets */
  28792. static SnippetUrl: string;
  28793. /** Snippet ID if the material was created from the snippet server */
  28794. snippetId: string;
  28795. /**
  28796. * Instantiate a new shader material.
  28797. * 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.
  28798. * This returned material effects how the mesh will look based on the code in the shaders.
  28799. * @see https://doc.babylonjs.com/how_to/shader_material
  28800. * @param name Define the name of the material in the scene
  28801. * @param scene Define the scene the material belongs to
  28802. * @param shaderPath Defines the route to the shader code in one of three ways:
  28803. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  28804. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  28805. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  28806. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  28807. * @param options Define the options used to create the shader
  28808. */
  28809. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  28810. /**
  28811. * Gets the shader path used to define the shader code
  28812. * It can be modified to trigger a new compilation
  28813. */
  28814. get shaderPath(): any;
  28815. /**
  28816. * Sets the shader path used to define the shader code
  28817. * It can be modified to trigger a new compilation
  28818. */
  28819. set shaderPath(shaderPath: any);
  28820. /**
  28821. * Gets the options used to compile the shader.
  28822. * They can be modified to trigger a new compilation
  28823. */
  28824. get options(): IShaderMaterialOptions;
  28825. /**
  28826. * Gets the current class name of the material e.g. "ShaderMaterial"
  28827. * Mainly use in serialization.
  28828. * @returns the class name
  28829. */
  28830. getClassName(): string;
  28831. /**
  28832. * Specifies if the material will require alpha blending
  28833. * @returns a boolean specifying if alpha blending is needed
  28834. */
  28835. needAlphaBlending(): boolean;
  28836. /**
  28837. * Specifies if this material should be rendered in alpha test mode
  28838. * @returns a boolean specifying if an alpha test is needed.
  28839. */
  28840. needAlphaTesting(): boolean;
  28841. private _checkUniform;
  28842. /**
  28843. * Set a texture in the shader.
  28844. * @param name Define the name of the uniform samplers as defined in the shader
  28845. * @param texture Define the texture to bind to this sampler
  28846. * @return the material itself allowing "fluent" like uniform updates
  28847. */
  28848. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  28849. /**
  28850. * Set a texture array in the shader.
  28851. * @param name Define the name of the uniform sampler array as defined in the shader
  28852. * @param textures Define the list of textures to bind to this sampler
  28853. * @return the material itself allowing "fluent" like uniform updates
  28854. */
  28855. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  28856. /**
  28857. * Set a float in the shader.
  28858. * @param name Define the name of the uniform as defined in the shader
  28859. * @param value Define the value to give to the uniform
  28860. * @return the material itself allowing "fluent" like uniform updates
  28861. */
  28862. setFloat(name: string, value: number): ShaderMaterial;
  28863. /**
  28864. * Set a int in the shader.
  28865. * @param name Define the name of the uniform as defined in the shader
  28866. * @param value Define the value to give to the uniform
  28867. * @return the material itself allowing "fluent" like uniform updates
  28868. */
  28869. setInt(name: string, value: number): ShaderMaterial;
  28870. /**
  28871. * Set an array of floats in the shader.
  28872. * @param name Define the name of the uniform as defined in the shader
  28873. * @param value Define the value to give to the uniform
  28874. * @return the material itself allowing "fluent" like uniform updates
  28875. */
  28876. setFloats(name: string, value: number[]): ShaderMaterial;
  28877. /**
  28878. * Set a vec3 in the shader from a Color3.
  28879. * @param name Define the name of the uniform as defined in the shader
  28880. * @param value Define the value to give to the uniform
  28881. * @return the material itself allowing "fluent" like uniform updates
  28882. */
  28883. setColor3(name: string, value: Color3): ShaderMaterial;
  28884. /**
  28885. * Set a vec3 array in the shader from a Color3 array.
  28886. * @param name Define the name of the uniform as defined in the shader
  28887. * @param value Define the value to give to the uniform
  28888. * @return the material itself allowing "fluent" like uniform updates
  28889. */
  28890. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  28891. /**
  28892. * Set a vec4 in the shader from a Color4.
  28893. * @param name Define the name of the uniform as defined in the shader
  28894. * @param value Define the value to give to the uniform
  28895. * @return the material itself allowing "fluent" like uniform updates
  28896. */
  28897. setColor4(name: string, value: Color4): ShaderMaterial;
  28898. /**
  28899. * Set a vec4 array in the shader from a Color4 array.
  28900. * @param name Define the name of the uniform as defined in the shader
  28901. * @param value Define the value to give to the uniform
  28902. * @return the material itself allowing "fluent" like uniform updates
  28903. */
  28904. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  28905. /**
  28906. * Set a vec2 in the shader from a Vector2.
  28907. * @param name Define the name of the uniform as defined in the shader
  28908. * @param value Define the value to give to the uniform
  28909. * @return the material itself allowing "fluent" like uniform updates
  28910. */
  28911. setVector2(name: string, value: Vector2): ShaderMaterial;
  28912. /**
  28913. * Set a vec3 in the shader from a Vector3.
  28914. * @param name Define the name of the uniform as defined in the shader
  28915. * @param value Define the value to give to the uniform
  28916. * @return the material itself allowing "fluent" like uniform updates
  28917. */
  28918. setVector3(name: string, value: Vector3): ShaderMaterial;
  28919. /**
  28920. * Set a vec4 in the shader from a Vector4.
  28921. * @param name Define the name of the uniform as defined in the shader
  28922. * @param value Define the value to give to the uniform
  28923. * @return the material itself allowing "fluent" like uniform updates
  28924. */
  28925. setVector4(name: string, value: Vector4): ShaderMaterial;
  28926. /**
  28927. * Set a mat4 in the shader from a Matrix.
  28928. * @param name Define the name of the uniform as defined in the shader
  28929. * @param value Define the value to give to the uniform
  28930. * @return the material itself allowing "fluent" like uniform updates
  28931. */
  28932. setMatrix(name: string, value: Matrix): ShaderMaterial;
  28933. /**
  28934. * Set a float32Array in the shader from a matrix array.
  28935. * @param name Define the name of the uniform as defined in the shader
  28936. * @param value Define the value to give to the uniform
  28937. * @return the material itself allowing "fluent" like uniform updates
  28938. */
  28939. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  28940. /**
  28941. * Set a mat3 in the shader from a Float32Array.
  28942. * @param name Define the name of the uniform as defined in the shader
  28943. * @param value Define the value to give to the uniform
  28944. * @return the material itself allowing "fluent" like uniform updates
  28945. */
  28946. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28947. /**
  28948. * Set a mat2 in the shader from a Float32Array.
  28949. * @param name Define the name of the uniform as defined in the shader
  28950. * @param value Define the value to give to the uniform
  28951. * @return the material itself allowing "fluent" like uniform updates
  28952. */
  28953. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28954. /**
  28955. * Set a vec2 array in the shader from a number array.
  28956. * @param name Define the name of the uniform as defined in the shader
  28957. * @param value Define the value to give to the uniform
  28958. * @return the material itself allowing "fluent" like uniform updates
  28959. */
  28960. setArray2(name: string, value: number[]): ShaderMaterial;
  28961. /**
  28962. * Set a vec3 array in the shader from a number array.
  28963. * @param name Define the name of the uniform as defined in the shader
  28964. * @param value Define the value to give to the uniform
  28965. * @return the material itself allowing "fluent" like uniform updates
  28966. */
  28967. setArray3(name: string, value: number[]): ShaderMaterial;
  28968. /**
  28969. * Set a vec4 array in the shader from a number array.
  28970. * @param name Define the name of the uniform as defined in the shader
  28971. * @param value Define the value to give to the uniform
  28972. * @return the material itself allowing "fluent" like uniform updates
  28973. */
  28974. setArray4(name: string, value: number[]): ShaderMaterial;
  28975. private _checkCache;
  28976. /**
  28977. * Specifies that the submesh is ready to be used
  28978. * @param mesh defines the mesh to check
  28979. * @param subMesh defines which submesh to check
  28980. * @param useInstances specifies that instances should be used
  28981. * @returns a boolean indicating that the submesh is ready or not
  28982. */
  28983. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  28984. /**
  28985. * Checks if the material is ready to render the requested mesh
  28986. * @param mesh Define the mesh to render
  28987. * @param useInstances Define whether or not the material is used with instances
  28988. * @returns true if ready, otherwise false
  28989. */
  28990. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  28991. /**
  28992. * Binds the world matrix to the material
  28993. * @param world defines the world transformation matrix
  28994. * @param effectOverride - If provided, use this effect instead of internal effect
  28995. */
  28996. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  28997. /**
  28998. * Binds the submesh to this material by preparing the effect and shader to draw
  28999. * @param world defines the world transformation matrix
  29000. * @param mesh defines the mesh containing the submesh
  29001. * @param subMesh defines the submesh to bind the material to
  29002. */
  29003. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29004. /**
  29005. * Binds the material to the mesh
  29006. * @param world defines the world transformation matrix
  29007. * @param mesh defines the mesh to bind the material to
  29008. * @param effectOverride - If provided, use this effect instead of internal effect
  29009. */
  29010. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  29011. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  29012. /**
  29013. * Gets the active textures from the material
  29014. * @returns an array of textures
  29015. */
  29016. getActiveTextures(): BaseTexture[];
  29017. /**
  29018. * Specifies if the material uses a texture
  29019. * @param texture defines the texture to check against the material
  29020. * @returns a boolean specifying if the material uses the texture
  29021. */
  29022. hasTexture(texture: BaseTexture): boolean;
  29023. /**
  29024. * Makes a duplicate of the material, and gives it a new name
  29025. * @param name defines the new name for the duplicated material
  29026. * @returns the cloned material
  29027. */
  29028. clone(name: string): ShaderMaterial;
  29029. /**
  29030. * Disposes the material
  29031. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29032. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29033. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29034. */
  29035. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29036. /**
  29037. * Serializes this material in a JSON representation
  29038. * @returns the serialized material object
  29039. */
  29040. serialize(): any;
  29041. /**
  29042. * Creates a shader material from parsed shader material data
  29043. * @param source defines the JSON representation of the material
  29044. * @param scene defines the hosting scene
  29045. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29046. * @returns a new material
  29047. */
  29048. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  29049. /**
  29050. * Creates a new ShaderMaterial from a snippet saved in a remote file
  29051. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  29052. * @param url defines the url to load from
  29053. * @param scene defines the hosting scene
  29054. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29055. * @returns a promise that will resolve to the new ShaderMaterial
  29056. */
  29057. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29058. /**
  29059. * Creates a ShaderMaterial from a snippet saved by the Inspector
  29060. * @param snippetId defines the snippet to load
  29061. * @param scene defines the hosting scene
  29062. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29063. * @returns a promise that will resolve to the new ShaderMaterial
  29064. */
  29065. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29066. }
  29067. }
  29068. declare module BABYLON {
  29069. /** @hidden */
  29070. export var colorPixelShader: {
  29071. name: string;
  29072. shader: string;
  29073. };
  29074. }
  29075. declare module BABYLON {
  29076. /** @hidden */
  29077. export var colorVertexShader: {
  29078. name: string;
  29079. shader: string;
  29080. };
  29081. }
  29082. declare module BABYLON {
  29083. /**
  29084. * Line mesh
  29085. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  29086. */
  29087. export class LinesMesh extends Mesh {
  29088. /**
  29089. * If vertex color should be applied to the mesh
  29090. */
  29091. readonly useVertexColor?: boolean | undefined;
  29092. /**
  29093. * If vertex alpha should be applied to the mesh
  29094. */
  29095. readonly useVertexAlpha?: boolean | undefined;
  29096. /**
  29097. * Color of the line (Default: White)
  29098. */
  29099. color: Color3;
  29100. /**
  29101. * Alpha of the line (Default: 1)
  29102. */
  29103. alpha: number;
  29104. /**
  29105. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29106. * This margin is expressed in world space coordinates, so its value may vary.
  29107. * Default value is 0.1
  29108. */
  29109. intersectionThreshold: number;
  29110. private _colorShader;
  29111. private color4;
  29112. /**
  29113. * Creates a new LinesMesh
  29114. * @param name defines the name
  29115. * @param scene defines the hosting scene
  29116. * @param parent defines the parent mesh if any
  29117. * @param source defines the optional source LinesMesh used to clone data from
  29118. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29119. * When false, achieved by calling a clone(), also passing False.
  29120. * This will make creation of children, recursive.
  29121. * @param useVertexColor defines if this LinesMesh supports vertex color
  29122. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  29123. */
  29124. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  29125. /**
  29126. * If vertex color should be applied to the mesh
  29127. */
  29128. useVertexColor?: boolean | undefined,
  29129. /**
  29130. * If vertex alpha should be applied to the mesh
  29131. */
  29132. useVertexAlpha?: boolean | undefined);
  29133. private _addClipPlaneDefine;
  29134. private _removeClipPlaneDefine;
  29135. isReady(): boolean;
  29136. /**
  29137. * Returns the string "LineMesh"
  29138. */
  29139. getClassName(): string;
  29140. /**
  29141. * @hidden
  29142. */
  29143. get material(): Material;
  29144. /**
  29145. * @hidden
  29146. */
  29147. set material(value: Material);
  29148. /**
  29149. * @hidden
  29150. */
  29151. get checkCollisions(): boolean;
  29152. set checkCollisions(value: boolean);
  29153. /** @hidden */
  29154. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29155. /** @hidden */
  29156. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29157. /**
  29158. * Disposes of the line mesh
  29159. * @param doNotRecurse If children should be disposed
  29160. */
  29161. dispose(doNotRecurse?: boolean): void;
  29162. /**
  29163. * Returns a new LineMesh object cloned from the current one.
  29164. */
  29165. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  29166. /**
  29167. * Creates a new InstancedLinesMesh object from the mesh model.
  29168. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29169. * @param name defines the name of the new instance
  29170. * @returns a new InstancedLinesMesh
  29171. */
  29172. createInstance(name: string): InstancedLinesMesh;
  29173. }
  29174. /**
  29175. * Creates an instance based on a source LinesMesh
  29176. */
  29177. export class InstancedLinesMesh extends InstancedMesh {
  29178. /**
  29179. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29180. * This margin is expressed in world space coordinates, so its value may vary.
  29181. * Initialized with the intersectionThreshold value of the source LinesMesh
  29182. */
  29183. intersectionThreshold: number;
  29184. constructor(name: string, source: LinesMesh);
  29185. /**
  29186. * Returns the string "InstancedLinesMesh".
  29187. */
  29188. getClassName(): string;
  29189. }
  29190. }
  29191. declare module BABYLON {
  29192. /** @hidden */
  29193. export var linePixelShader: {
  29194. name: string;
  29195. shader: string;
  29196. };
  29197. }
  29198. declare module BABYLON {
  29199. /** @hidden */
  29200. export var lineVertexShader: {
  29201. name: string;
  29202. shader: string;
  29203. };
  29204. }
  29205. declare module BABYLON {
  29206. interface Scene {
  29207. /** @hidden */
  29208. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  29209. }
  29210. interface AbstractMesh {
  29211. /**
  29212. * Gets the edgesRenderer associated with the mesh
  29213. */
  29214. edgesRenderer: Nullable<EdgesRenderer>;
  29215. }
  29216. interface LinesMesh {
  29217. /**
  29218. * Enables the edge rendering mode on the mesh.
  29219. * This mode makes the mesh edges visible
  29220. * @param epsilon defines the maximal distance between two angles to detect a face
  29221. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29222. * @returns the currentAbstractMesh
  29223. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29224. */
  29225. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29226. }
  29227. interface InstancedLinesMesh {
  29228. /**
  29229. * Enables the edge rendering mode on the mesh.
  29230. * This mode makes the mesh edges visible
  29231. * @param epsilon defines the maximal distance between two angles to detect a face
  29232. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29233. * @returns the current InstancedLinesMesh
  29234. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29235. */
  29236. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  29237. }
  29238. /**
  29239. * Defines the minimum contract an Edges renderer should follow.
  29240. */
  29241. export interface IEdgesRenderer extends IDisposable {
  29242. /**
  29243. * Gets or sets a boolean indicating if the edgesRenderer is active
  29244. */
  29245. isEnabled: boolean;
  29246. /**
  29247. * Renders the edges of the attached mesh,
  29248. */
  29249. render(): void;
  29250. /**
  29251. * Checks whether or not the edges renderer is ready to render.
  29252. * @return true if ready, otherwise false.
  29253. */
  29254. isReady(): boolean;
  29255. /**
  29256. * List of instances to render in case the source mesh has instances
  29257. */
  29258. customInstances: SmartArray<Matrix>;
  29259. }
  29260. /**
  29261. * Defines the additional options of the edges renderer
  29262. */
  29263. export interface IEdgesRendererOptions {
  29264. /**
  29265. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  29266. * If not defined, the default value is true
  29267. */
  29268. useAlternateEdgeFinder?: boolean;
  29269. /**
  29270. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  29271. * If not defined, the default value is true.
  29272. * 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)
  29273. * This option is used only if useAlternateEdgeFinder = true
  29274. */
  29275. useFastVertexMerger?: boolean;
  29276. /**
  29277. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit within which vertices are considered to be equal.
  29278. * The default value is 1e-6
  29279. * This option is used only if useAlternateEdgeFinder = true
  29280. */
  29281. epsilonVertexMerge?: number;
  29282. /**
  29283. * 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
  29284. * 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.
  29285. * This option is used only if useAlternateEdgeFinder = true
  29286. */
  29287. applyTessellation?: boolean;
  29288. /**
  29289. * 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
  29290. * The default value is 1e-6
  29291. * This option is used only if useAlternateEdgeFinder = true
  29292. */
  29293. epsilonVertexAligned?: number;
  29294. }
  29295. /**
  29296. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  29297. */
  29298. export class EdgesRenderer implements IEdgesRenderer {
  29299. /**
  29300. * Define the size of the edges with an orthographic camera
  29301. */
  29302. edgesWidthScalerForOrthographic: number;
  29303. /**
  29304. * Define the size of the edges with a perspective camera
  29305. */
  29306. edgesWidthScalerForPerspective: number;
  29307. protected _source: AbstractMesh;
  29308. protected _linesPositions: number[];
  29309. protected _linesNormals: number[];
  29310. protected _linesIndices: number[];
  29311. protected _epsilon: number;
  29312. protected _indicesCount: number;
  29313. protected _lineShader: ShaderMaterial;
  29314. protected _ib: DataBuffer;
  29315. protected _buffers: {
  29316. [key: string]: Nullable<VertexBuffer>;
  29317. };
  29318. protected _buffersForInstances: {
  29319. [key: string]: Nullable<VertexBuffer>;
  29320. };
  29321. protected _checkVerticesInsteadOfIndices: boolean;
  29322. protected _options: Nullable<IEdgesRendererOptions>;
  29323. private _meshRebuildObserver;
  29324. private _meshDisposeObserver;
  29325. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  29326. isEnabled: boolean;
  29327. /** Gets the vertices generated by the edge renderer */
  29328. get linesPositions(): Immutable<Array<number>>;
  29329. /** Gets the normals generated by the edge renderer */
  29330. get linesNormals(): Immutable<Array<number>>;
  29331. /** Gets the indices generated by the edge renderer */
  29332. get linesIndices(): Immutable<Array<number>>;
  29333. /**
  29334. * List of instances to render in case the source mesh has instances
  29335. */
  29336. customInstances: SmartArray<Matrix>;
  29337. private static GetShader;
  29338. /**
  29339. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  29340. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  29341. * @param source Mesh used to create edges
  29342. * @param epsilon sum of angles in adjacency to check for edge
  29343. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  29344. * @param generateEdgesLines - should generate Lines or only prepare resources.
  29345. * @param options The options to apply when generating the edges
  29346. */
  29347. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  29348. protected _prepareRessources(): void;
  29349. /** @hidden */
  29350. _rebuild(): void;
  29351. /**
  29352. * Releases the required resources for the edges renderer
  29353. */
  29354. dispose(): void;
  29355. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  29356. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  29357. /**
  29358. * Checks if the pair of p0 and p1 is en edge
  29359. * @param faceIndex
  29360. * @param edge
  29361. * @param faceNormals
  29362. * @param p0
  29363. * @param p1
  29364. * @private
  29365. */
  29366. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  29367. /**
  29368. * push line into the position, normal and index buffer
  29369. * @protected
  29370. */
  29371. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  29372. /**
  29373. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  29374. */
  29375. private _tessellateTriangle;
  29376. private _generateEdgesLinesAlternate;
  29377. /**
  29378. * Generates lines edges from adjacencjes
  29379. * @private
  29380. */
  29381. _generateEdgesLines(): void;
  29382. /**
  29383. * Checks whether or not the edges renderer is ready to render.
  29384. * @return true if ready, otherwise false.
  29385. */
  29386. isReady(): boolean;
  29387. /**
  29388. * Renders the edges of the attached mesh,
  29389. */
  29390. render(): void;
  29391. }
  29392. /**
  29393. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  29394. */
  29395. export class LineEdgesRenderer extends EdgesRenderer {
  29396. /**
  29397. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  29398. * @param source LineMesh used to generate edges
  29399. * @param epsilon not important (specified angle for edge detection)
  29400. * @param checkVerticesInsteadOfIndices not important for LineMesh
  29401. */
  29402. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  29403. /**
  29404. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  29405. */
  29406. _generateEdgesLines(): void;
  29407. }
  29408. }
  29409. declare module BABYLON {
  29410. /**
  29411. * This represents the object necessary to create a rendering group.
  29412. * This is exclusively used and created by the rendering manager.
  29413. * To modify the behavior, you use the available helpers in your scene or meshes.
  29414. * @hidden
  29415. */
  29416. export class RenderingGroup {
  29417. index: number;
  29418. private static _zeroVector;
  29419. private _scene;
  29420. private _opaqueSubMeshes;
  29421. private _transparentSubMeshes;
  29422. private _alphaTestSubMeshes;
  29423. private _depthOnlySubMeshes;
  29424. private _particleSystems;
  29425. private _spriteManagers;
  29426. private _opaqueSortCompareFn;
  29427. private _alphaTestSortCompareFn;
  29428. private _transparentSortCompareFn;
  29429. private _renderOpaque;
  29430. private _renderAlphaTest;
  29431. private _renderTransparent;
  29432. /** @hidden */
  29433. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  29434. onBeforeTransparentRendering: () => void;
  29435. /**
  29436. * Set the opaque sort comparison function.
  29437. * If null the sub meshes will be render in the order they were created
  29438. */
  29439. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29440. /**
  29441. * Set the alpha test sort comparison function.
  29442. * If null the sub meshes will be render in the order they were created
  29443. */
  29444. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29445. /**
  29446. * Set the transparent sort comparison function.
  29447. * If null the sub meshes will be render in the order they were created
  29448. */
  29449. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29450. /**
  29451. * Creates a new rendering group.
  29452. * @param index The rendering group index
  29453. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  29454. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  29455. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  29456. */
  29457. 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>);
  29458. /**
  29459. * Render all the sub meshes contained in the group.
  29460. * @param customRenderFunction Used to override the default render behaviour of the group.
  29461. * @returns true if rendered some submeshes.
  29462. */
  29463. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  29464. /**
  29465. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  29466. * @param subMeshes The submeshes to render
  29467. */
  29468. private renderOpaqueSorted;
  29469. /**
  29470. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  29471. * @param subMeshes The submeshes to render
  29472. */
  29473. private renderAlphaTestSorted;
  29474. /**
  29475. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  29476. * @param subMeshes The submeshes to render
  29477. */
  29478. private renderTransparentSorted;
  29479. /**
  29480. * Renders the submeshes in a specified order.
  29481. * @param subMeshes The submeshes to sort before render
  29482. * @param sortCompareFn The comparison function use to sort
  29483. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  29484. * @param transparent Specifies to activate blending if true
  29485. */
  29486. private static renderSorted;
  29487. /**
  29488. * Renders the submeshes in the order they were dispatched (no sort applied).
  29489. * @param subMeshes The submeshes to render
  29490. */
  29491. private static renderUnsorted;
  29492. /**
  29493. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29494. * are rendered back to front if in the same alpha index.
  29495. *
  29496. * @param a The first submesh
  29497. * @param b The second submesh
  29498. * @returns The result of the comparison
  29499. */
  29500. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  29501. /**
  29502. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29503. * are rendered back to front.
  29504. *
  29505. * @param a The first submesh
  29506. * @param b The second submesh
  29507. * @returns The result of the comparison
  29508. */
  29509. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  29510. /**
  29511. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29512. * are rendered front to back (prevent overdraw).
  29513. *
  29514. * @param a The first submesh
  29515. * @param b The second submesh
  29516. * @returns The result of the comparison
  29517. */
  29518. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  29519. /**
  29520. * Resets the different lists of submeshes to prepare a new frame.
  29521. */
  29522. prepare(): void;
  29523. dispose(): void;
  29524. /**
  29525. * Inserts the submesh in its correct queue depending on its material.
  29526. * @param subMesh The submesh to dispatch
  29527. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29528. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29529. */
  29530. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29531. dispatchSprites(spriteManager: ISpriteManager): void;
  29532. dispatchParticles(particleSystem: IParticleSystem): void;
  29533. private _renderParticles;
  29534. private _renderSprites;
  29535. }
  29536. }
  29537. declare module BABYLON {
  29538. /**
  29539. * Interface describing the different options available in the rendering manager
  29540. * regarding Auto Clear between groups.
  29541. */
  29542. export interface IRenderingManagerAutoClearSetup {
  29543. /**
  29544. * Defines whether or not autoclear is enable.
  29545. */
  29546. autoClear: boolean;
  29547. /**
  29548. * Defines whether or not to autoclear the depth buffer.
  29549. */
  29550. depth: boolean;
  29551. /**
  29552. * Defines whether or not to autoclear the stencil buffer.
  29553. */
  29554. stencil: boolean;
  29555. }
  29556. /**
  29557. * This class is used by the onRenderingGroupObservable
  29558. */
  29559. export class RenderingGroupInfo {
  29560. /**
  29561. * The Scene that being rendered
  29562. */
  29563. scene: Scene;
  29564. /**
  29565. * The camera currently used for the rendering pass
  29566. */
  29567. camera: Nullable<Camera>;
  29568. /**
  29569. * The ID of the renderingGroup being processed
  29570. */
  29571. renderingGroupId: number;
  29572. }
  29573. /**
  29574. * This is the manager responsible of all the rendering for meshes sprites and particles.
  29575. * It is enable to manage the different groups as well as the different necessary sort functions.
  29576. * This should not be used directly aside of the few static configurations
  29577. */
  29578. export class RenderingManager {
  29579. /**
  29580. * The max id used for rendering groups (not included)
  29581. */
  29582. static MAX_RENDERINGGROUPS: number;
  29583. /**
  29584. * The min id used for rendering groups (included)
  29585. */
  29586. static MIN_RENDERINGGROUPS: number;
  29587. /**
  29588. * Used to globally prevent autoclearing scenes.
  29589. */
  29590. static AUTOCLEAR: boolean;
  29591. /**
  29592. * @hidden
  29593. */
  29594. _useSceneAutoClearSetup: boolean;
  29595. private _scene;
  29596. private _renderingGroups;
  29597. private _depthStencilBufferAlreadyCleaned;
  29598. private _autoClearDepthStencil;
  29599. private _customOpaqueSortCompareFn;
  29600. private _customAlphaTestSortCompareFn;
  29601. private _customTransparentSortCompareFn;
  29602. private _renderingGroupInfo;
  29603. /**
  29604. * Instantiates a new rendering group for a particular scene
  29605. * @param scene Defines the scene the groups belongs to
  29606. */
  29607. constructor(scene: Scene);
  29608. private _clearDepthStencilBuffer;
  29609. /**
  29610. * Renders the entire managed groups. This is used by the scene or the different render targets.
  29611. * @hidden
  29612. */
  29613. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  29614. /**
  29615. * Resets the different information of the group to prepare a new frame
  29616. * @hidden
  29617. */
  29618. reset(): void;
  29619. /**
  29620. * Dispose and release the group and its associated resources.
  29621. * @hidden
  29622. */
  29623. dispose(): void;
  29624. /**
  29625. * Clear the info related to rendering groups preventing retention points during dispose.
  29626. */
  29627. freeRenderingGroups(): void;
  29628. private _prepareRenderingGroup;
  29629. /**
  29630. * Add a sprite manager to the rendering manager in order to render it this frame.
  29631. * @param spriteManager Define the sprite manager to render
  29632. */
  29633. dispatchSprites(spriteManager: ISpriteManager): void;
  29634. /**
  29635. * Add a particle system to the rendering manager in order to render it this frame.
  29636. * @param particleSystem Define the particle system to render
  29637. */
  29638. dispatchParticles(particleSystem: IParticleSystem): void;
  29639. /**
  29640. * Add a submesh to the manager in order to render it this frame
  29641. * @param subMesh The submesh to dispatch
  29642. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29643. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29644. */
  29645. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29646. /**
  29647. * Overrides the default sort function applied in the rendering group to prepare the meshes.
  29648. * This allowed control for front to back rendering or reversely depending of the special needs.
  29649. *
  29650. * @param renderingGroupId The rendering group id corresponding to its index
  29651. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29652. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29653. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29654. */
  29655. 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;
  29656. /**
  29657. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29658. *
  29659. * @param renderingGroupId The rendering group id corresponding to its index
  29660. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29661. * @param depth Automatically clears depth between groups if true and autoClear is true.
  29662. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  29663. */
  29664. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  29665. /**
  29666. * Gets the current auto clear configuration for one rendering group of the rendering
  29667. * manager.
  29668. * @param index the rendering group index to get the information for
  29669. * @returns The auto clear setup for the requested rendering group
  29670. */
  29671. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  29672. }
  29673. }
  29674. declare module BABYLON {
  29675. /**
  29676. * Defines the options associated with the creation of a custom shader for a shadow generator.
  29677. */
  29678. export interface ICustomShaderOptions {
  29679. /**
  29680. * Gets or sets the custom shader name to use
  29681. */
  29682. shaderName: string;
  29683. /**
  29684. * The list of attribute names used in the shader
  29685. */
  29686. attributes?: string[];
  29687. /**
  29688. * The list of uniform names used in the shader
  29689. */
  29690. uniforms?: string[];
  29691. /**
  29692. * The list of sampler names used in the shader
  29693. */
  29694. samplers?: string[];
  29695. /**
  29696. * The list of defines used in the shader
  29697. */
  29698. defines?: string[];
  29699. }
  29700. /**
  29701. * Interface to implement to create a shadow generator compatible with BJS.
  29702. */
  29703. export interface IShadowGenerator {
  29704. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29705. id: string;
  29706. /**
  29707. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29708. * @returns The render target texture if present otherwise, null
  29709. */
  29710. getShadowMap(): Nullable<RenderTargetTexture>;
  29711. /**
  29712. * Determine whether the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29713. * @param subMesh The submesh we want to render in the shadow map
  29714. * @param useInstances Defines whether will draw in the map using instances
  29715. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29716. * @returns true if ready otherwise, false
  29717. */
  29718. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29719. /**
  29720. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29721. * @param defines Defines of the material we want to update
  29722. * @param lightIndex Index of the light in the enabled light list of the material
  29723. */
  29724. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  29725. /**
  29726. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29727. * defined in the generator but impacting the effect).
  29728. * It implies the uniforms available on the materials are the standard BJS ones.
  29729. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29730. * @param effect The effect we are binding the information for
  29731. */
  29732. bindShadowLight(lightIndex: string, effect: Effect): void;
  29733. /**
  29734. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29735. * (eq to shadow projection matrix * light transform matrix)
  29736. * @returns The transform matrix used to create the shadow map
  29737. */
  29738. getTransformMatrix(): Matrix;
  29739. /**
  29740. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29741. * Cube and 2D textures for instance.
  29742. */
  29743. recreateShadowMap(): void;
  29744. /**
  29745. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  29746. * @param onCompiled Callback triggered at the and of the effects compilation
  29747. * @param options Sets of optional options forcing the compilation with different modes
  29748. */
  29749. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29750. useInstances: boolean;
  29751. }>): void;
  29752. /**
  29753. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  29754. * @param options Sets of optional options forcing the compilation with different modes
  29755. * @returns A promise that resolves when the compilation completes
  29756. */
  29757. forceCompilationAsync(options?: Partial<{
  29758. useInstances: boolean;
  29759. }>): Promise<void>;
  29760. /**
  29761. * Serializes the shadow generator setup to a json object.
  29762. * @returns The serialized JSON object
  29763. */
  29764. serialize(): any;
  29765. /**
  29766. * Disposes the Shadow map and related Textures and effects.
  29767. */
  29768. dispose(): void;
  29769. }
  29770. /**
  29771. * Default implementation IShadowGenerator.
  29772. * This is the main object responsible of generating shadows in the framework.
  29773. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  29774. */
  29775. export class ShadowGenerator implements IShadowGenerator {
  29776. private static _Counter;
  29777. /**
  29778. * Name of the shadow generator class
  29779. */
  29780. static CLASSNAME: string;
  29781. /**
  29782. * Shadow generator mode None: no filtering applied.
  29783. */
  29784. static readonly FILTER_NONE: number;
  29785. /**
  29786. * Shadow generator mode ESM: Exponential Shadow Mapping.
  29787. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29788. */
  29789. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  29790. /**
  29791. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  29792. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  29793. */
  29794. static readonly FILTER_POISSONSAMPLING: number;
  29795. /**
  29796. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  29797. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29798. */
  29799. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  29800. /**
  29801. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  29802. * edge artifacts on steep falloff.
  29803. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29804. */
  29805. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  29806. /**
  29807. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  29808. * edge artifacts on steep falloff.
  29809. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29810. */
  29811. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  29812. /**
  29813. * Shadow generator mode PCF: Percentage Closer Filtering
  29814. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29815. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  29816. */
  29817. static readonly FILTER_PCF: number;
  29818. /**
  29819. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  29820. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29821. * Contact Hardening
  29822. */
  29823. static readonly FILTER_PCSS: number;
  29824. /**
  29825. * Reserved for PCF and PCSS
  29826. * Highest Quality.
  29827. *
  29828. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  29829. *
  29830. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  29831. */
  29832. static readonly QUALITY_HIGH: number;
  29833. /**
  29834. * Reserved for PCF and PCSS
  29835. * Good tradeoff for quality/perf cross devices
  29836. *
  29837. * Execute PCF on a 3*3 kernel.
  29838. *
  29839. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  29840. */
  29841. static readonly QUALITY_MEDIUM: number;
  29842. /**
  29843. * Reserved for PCF and PCSS
  29844. * The lowest quality but the fastest.
  29845. *
  29846. * Execute PCF on a 1*1 kernel.
  29847. *
  29848. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  29849. */
  29850. static readonly QUALITY_LOW: number;
  29851. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29852. id: string;
  29853. /** Gets or sets the custom shader name to use */
  29854. customShaderOptions: ICustomShaderOptions;
  29855. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  29856. customAllowRendering: (subMesh: SubMesh) => boolean;
  29857. /**
  29858. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  29859. */
  29860. onBeforeShadowMapRenderObservable: Observable<Effect>;
  29861. /**
  29862. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  29863. */
  29864. onAfterShadowMapRenderObservable: Observable<Effect>;
  29865. /**
  29866. * Observable triggered before a mesh is rendered in the shadow map.
  29867. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  29868. */
  29869. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  29870. /**
  29871. * Observable triggered after a mesh is rendered in the shadow map.
  29872. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  29873. */
  29874. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  29875. protected _bias: number;
  29876. /**
  29877. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  29878. */
  29879. get bias(): number;
  29880. /**
  29881. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  29882. */
  29883. set bias(bias: number);
  29884. protected _normalBias: number;
  29885. /**
  29886. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportional to the light/normal angle).
  29887. */
  29888. get normalBias(): number;
  29889. /**
  29890. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportional to the light/normal angle).
  29891. */
  29892. set normalBias(normalBias: number);
  29893. protected _blurBoxOffset: number;
  29894. /**
  29895. * Gets the blur box offset: offset applied during the blur pass.
  29896. * Only useful if useKernelBlur = false
  29897. */
  29898. get blurBoxOffset(): number;
  29899. /**
  29900. * Sets the blur box offset: offset applied during the blur pass.
  29901. * Only useful if useKernelBlur = false
  29902. */
  29903. set blurBoxOffset(value: number);
  29904. protected _blurScale: number;
  29905. /**
  29906. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  29907. * 2 means half of the size.
  29908. */
  29909. get blurScale(): number;
  29910. /**
  29911. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  29912. * 2 means half of the size.
  29913. */
  29914. set blurScale(value: number);
  29915. protected _blurKernel: number;
  29916. /**
  29917. * Gets the blur kernel: kernel size of the blur pass.
  29918. * Only useful if useKernelBlur = true
  29919. */
  29920. get blurKernel(): number;
  29921. /**
  29922. * Sets the blur kernel: kernel size of the blur pass.
  29923. * Only useful if useKernelBlur = true
  29924. */
  29925. set blurKernel(value: number);
  29926. protected _useKernelBlur: boolean;
  29927. /**
  29928. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  29929. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  29930. */
  29931. get useKernelBlur(): boolean;
  29932. /**
  29933. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  29934. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  29935. */
  29936. set useKernelBlur(value: boolean);
  29937. protected _depthScale: number;
  29938. /**
  29939. * Gets the depth scale used in ESM mode.
  29940. */
  29941. get depthScale(): number;
  29942. /**
  29943. * Sets the depth scale used in ESM mode.
  29944. * This can override the scale stored on the light.
  29945. */
  29946. set depthScale(value: number);
  29947. protected _validateFilter(filter: number): number;
  29948. protected _filter: number;
  29949. /**
  29950. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  29951. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29952. */
  29953. get filter(): number;
  29954. /**
  29955. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  29956. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29957. */
  29958. set filter(value: number);
  29959. /**
  29960. * Gets if the current filter is set to Poisson Sampling.
  29961. */
  29962. get usePoissonSampling(): boolean;
  29963. /**
  29964. * Sets the current filter to Poisson Sampling.
  29965. */
  29966. set usePoissonSampling(value: boolean);
  29967. /**
  29968. * Gets if the current filter is set to ESM.
  29969. */
  29970. get useExponentialShadowMap(): boolean;
  29971. /**
  29972. * Sets the current filter is to ESM.
  29973. */
  29974. set useExponentialShadowMap(value: boolean);
  29975. /**
  29976. * Gets if the current filter is set to filtered ESM.
  29977. */
  29978. get useBlurExponentialShadowMap(): boolean;
  29979. /**
  29980. * Gets if the current filter is set to filtered ESM.
  29981. */
  29982. set useBlurExponentialShadowMap(value: boolean);
  29983. /**
  29984. * Gets if the current filter is set to "close ESM" (using the inverse of the
  29985. * exponential to prevent steep falloff artifacts).
  29986. */
  29987. get useCloseExponentialShadowMap(): boolean;
  29988. /**
  29989. * Sets the current filter to "close ESM" (using the inverse of the
  29990. * exponential to prevent steep falloff artifacts).
  29991. */
  29992. set useCloseExponentialShadowMap(value: boolean);
  29993. /**
  29994. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  29995. * exponential to prevent steep falloff artifacts).
  29996. */
  29997. get useBlurCloseExponentialShadowMap(): boolean;
  29998. /**
  29999. * Sets the current filter to filtered "close ESM" (using the inverse of the
  30000. * exponential to prevent steep falloff artifacts).
  30001. */
  30002. set useBlurCloseExponentialShadowMap(value: boolean);
  30003. /**
  30004. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  30005. */
  30006. get usePercentageCloserFiltering(): boolean;
  30007. /**
  30008. * Sets the current filter to "PCF" (percentage closer filtering).
  30009. */
  30010. set usePercentageCloserFiltering(value: boolean);
  30011. protected _filteringQuality: number;
  30012. /**
  30013. * Gets the PCF or PCSS Quality.
  30014. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30015. */
  30016. get filteringQuality(): number;
  30017. /**
  30018. * Sets the PCF or PCSS Quality.
  30019. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30020. */
  30021. set filteringQuality(filteringQuality: number);
  30022. /**
  30023. * Gets if the current filter is set to "PCSS" (contact hardening).
  30024. */
  30025. get useContactHardeningShadow(): boolean;
  30026. /**
  30027. * Sets the current filter to "PCSS" (contact hardening).
  30028. */
  30029. set useContactHardeningShadow(value: boolean);
  30030. protected _contactHardeningLightSizeUVRatio: number;
  30031. /**
  30032. * Gets 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. get contactHardeningLightSizeUVRatio(): number;
  30041. /**
  30042. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30043. * Using a ratio helps keeping shape stability independently of the map size.
  30044. *
  30045. * It does not account for the light projection as it was having too much
  30046. * instability during the light setup or during light position changes.
  30047. *
  30048. * Only valid if useContactHardeningShadow is true.
  30049. */
  30050. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  30051. protected _darkness: number;
  30052. /** Gets or sets the actual darkness of a shadow */
  30053. get darkness(): number;
  30054. set darkness(value: number);
  30055. /**
  30056. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  30057. * 0 means strongest and 1 would means no shadow.
  30058. * @returns the darkness.
  30059. */
  30060. getDarkness(): number;
  30061. /**
  30062. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  30063. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  30064. * @returns the shadow generator allowing fluent coding.
  30065. */
  30066. setDarkness(darkness: number): ShadowGenerator;
  30067. protected _transparencyShadow: boolean;
  30068. /** Gets or sets the ability to have transparent shadow */
  30069. get transparencyShadow(): boolean;
  30070. set transparencyShadow(value: boolean);
  30071. /**
  30072. * Sets the ability to have transparent shadow (boolean).
  30073. * @param transparent True if transparent else False
  30074. * @returns the shadow generator allowing fluent coding
  30075. */
  30076. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  30077. /**
  30078. * Enables or disables shadows with varying strength based on the transparency
  30079. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  30080. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  30081. * mesh.visibility * alphaTexture.a
  30082. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  30083. */
  30084. enableSoftTransparentShadow: boolean;
  30085. protected _shadowMap: Nullable<RenderTargetTexture>;
  30086. protected _shadowMap2: Nullable<RenderTargetTexture>;
  30087. /**
  30088. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30089. * @returns The render target texture if present otherwise, null
  30090. */
  30091. getShadowMap(): Nullable<RenderTargetTexture>;
  30092. /**
  30093. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  30094. * @returns The render target texture if the shadow map is present otherwise, null
  30095. */
  30096. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  30097. /**
  30098. * Gets the class name of that object
  30099. * @returns "ShadowGenerator"
  30100. */
  30101. getClassName(): string;
  30102. /**
  30103. * Helper function to add a mesh and its descendants to the list of shadow casters.
  30104. * @param mesh Mesh to add
  30105. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  30106. * @returns the Shadow Generator itself
  30107. */
  30108. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30109. /**
  30110. * Helper function to remove a mesh and its descendants from the list of shadow casters
  30111. * @param mesh Mesh to remove
  30112. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  30113. * @returns the Shadow Generator itself
  30114. */
  30115. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30116. /**
  30117. * Controls the extent to which the shadows fade out at the edge of the frustum
  30118. */
  30119. frustumEdgeFalloff: number;
  30120. protected _light: IShadowLight;
  30121. /**
  30122. * Returns the associated light object.
  30123. * @returns the light generating the shadow
  30124. */
  30125. getLight(): IShadowLight;
  30126. /**
  30127. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  30128. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  30129. * It might on the other hand introduce peter panning.
  30130. */
  30131. forceBackFacesOnly: boolean;
  30132. protected _scene: Scene;
  30133. protected _lightDirection: Vector3;
  30134. protected _viewMatrix: Matrix;
  30135. protected _projectionMatrix: Matrix;
  30136. protected _transformMatrix: Matrix;
  30137. protected _cachedPosition: Vector3;
  30138. protected _cachedDirection: Vector3;
  30139. protected _cachedDefines: string;
  30140. protected _currentRenderID: number;
  30141. protected _boxBlurPostprocess: Nullable<PostProcess>;
  30142. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  30143. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  30144. protected _blurPostProcesses: PostProcess[];
  30145. protected _mapSize: number;
  30146. protected _currentFaceIndex: number;
  30147. protected _currentFaceIndexCache: number;
  30148. protected _textureType: number;
  30149. protected _defaultTextureMatrix: Matrix;
  30150. protected _storedUniqueId: Nullable<number>;
  30151. protected _nameForCustomEffect: string;
  30152. /** @hidden */
  30153. static _SceneComponentInitialization: (scene: Scene) => void;
  30154. /**
  30155. * Gets or sets the size of the texture what stores the shadows
  30156. */
  30157. get mapSize(): number;
  30158. set mapSize(size: number);
  30159. /**
  30160. * Creates a ShadowGenerator object.
  30161. * A ShadowGenerator is the required tool to use the shadows.
  30162. * Each light casting shadows needs to use its own ShadowGenerator.
  30163. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  30164. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  30165. * @param light The light object generating the shadows.
  30166. * @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.
  30167. */
  30168. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  30169. protected _initializeGenerator(): void;
  30170. protected _createTargetRenderTexture(): void;
  30171. protected _initializeShadowMap(): void;
  30172. protected _initializeBlurRTTAndPostProcesses(): void;
  30173. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  30174. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  30175. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  30176. protected _applyFilterValues(): void;
  30177. /**
  30178. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  30179. * @param onCompiled Callback triggered at the and of the effects compilation
  30180. * @param options Sets of optional options forcing the compilation with different modes
  30181. */
  30182. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  30183. useInstances: boolean;
  30184. }>): void;
  30185. /**
  30186. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  30187. * @param options Sets of optional options forcing the compilation with different modes
  30188. * @returns A promise that resolves when the compilation completes
  30189. */
  30190. forceCompilationAsync(options?: Partial<{
  30191. useInstances: boolean;
  30192. }>): Promise<void>;
  30193. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  30194. private _prepareShadowDefines;
  30195. /**
  30196. * Determine whether the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  30197. * @param subMesh The submesh we want to render in the shadow map
  30198. * @param useInstances Defines whether will draw in the map using instances
  30199. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  30200. * @returns true if ready otherwise, false
  30201. */
  30202. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  30203. /**
  30204. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  30205. * @param defines Defines of the material we want to update
  30206. * @param lightIndex Index of the light in the enabled light list of the material
  30207. */
  30208. prepareDefines(defines: any, lightIndex: number): void;
  30209. /**
  30210. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  30211. * defined in the generator but impacting the effect).
  30212. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  30213. * @param effect The effect we are binding the information for
  30214. */
  30215. bindShadowLight(lightIndex: string, effect: Effect): void;
  30216. /**
  30217. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  30218. * (eq to shadow projection matrix * light transform matrix)
  30219. * @returns The transform matrix used to create the shadow map
  30220. */
  30221. getTransformMatrix(): Matrix;
  30222. /**
  30223. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  30224. * Cube and 2D textures for instance.
  30225. */
  30226. recreateShadowMap(): void;
  30227. protected _disposeBlurPostProcesses(): void;
  30228. protected _disposeRTTandPostProcesses(): void;
  30229. /**
  30230. * Disposes the ShadowGenerator.
  30231. * Returns nothing.
  30232. */
  30233. dispose(): void;
  30234. /**
  30235. * Serializes the shadow generator setup to a json object.
  30236. * @returns The serialized JSON object
  30237. */
  30238. serialize(): any;
  30239. /**
  30240. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  30241. * @param parsedShadowGenerator The JSON object to parse
  30242. * @param scene The scene to create the shadow map for
  30243. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  30244. * @returns The parsed shadow generator
  30245. */
  30246. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  30247. }
  30248. }
  30249. declare module BABYLON {
  30250. /**
  30251. * Options to be used when creating a shadow depth material
  30252. */
  30253. export interface IIOptionShadowDepthMaterial {
  30254. /** Variables in the vertex shader code that need to have their names remapped.
  30255. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  30256. * "var_name" should be either: worldPos or vNormalW
  30257. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  30258. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  30259. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  30260. */
  30261. remappedVariables?: string[];
  30262. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  30263. standalone?: boolean;
  30264. }
  30265. /**
  30266. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  30267. */
  30268. export class ShadowDepthWrapper {
  30269. private _scene;
  30270. private _options?;
  30271. private _baseMaterial;
  30272. private _onEffectCreatedObserver;
  30273. private _subMeshToEffect;
  30274. private _subMeshToDepthEffect;
  30275. private _meshes;
  30276. /** @hidden */
  30277. _matriceNames: any;
  30278. /** Gets the standalone status of the wrapper */
  30279. get standalone(): boolean;
  30280. /** Gets the base material the wrapper is built upon */
  30281. get baseMaterial(): Material;
  30282. /**
  30283. * Instantiate a new shadow depth wrapper.
  30284. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  30285. * generate the shadow depth map. For more information, please refer to the documentation:
  30286. * https://doc.babylonjs.com/babylon101/shadows
  30287. * @param baseMaterial Material to wrap
  30288. * @param scene Define the scene the material belongs to
  30289. * @param options Options used to create the wrapper
  30290. */
  30291. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  30292. /**
  30293. * Gets the effect to use to generate the depth map
  30294. * @param subMesh subMesh to get the effect for
  30295. * @param shadowGenerator shadow generator to get the effect for
  30296. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  30297. */
  30298. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  30299. /**
  30300. * Specifies that the submesh is ready to be used for depth rendering
  30301. * @param subMesh submesh to check
  30302. * @param defines the list of defines to take into account when checking the effect
  30303. * @param shadowGenerator combined with subMesh, it defines the effect to check
  30304. * @param useInstances specifies that instances should be used
  30305. * @returns a boolean indicating that the submesh is ready or not
  30306. */
  30307. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  30308. /**
  30309. * Disposes the resources
  30310. */
  30311. dispose(): void;
  30312. private _makeEffect;
  30313. }
  30314. }
  30315. declare module BABYLON {
  30316. /**
  30317. * Options for compiling materials.
  30318. */
  30319. export interface IMaterialCompilationOptions {
  30320. /**
  30321. * Defines whether clip planes are enabled.
  30322. */
  30323. clipPlane: boolean;
  30324. /**
  30325. * Defines whether instances are enabled.
  30326. */
  30327. useInstances: boolean;
  30328. }
  30329. /**
  30330. * Options passed when calling customShaderNameResolve
  30331. */
  30332. export interface ICustomShaderNameResolveOptions {
  30333. /**
  30334. * 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
  30335. */
  30336. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30337. }
  30338. /**
  30339. * Base class for the main features of a material in Babylon.js
  30340. */
  30341. export class Material implements IAnimatable {
  30342. /**
  30343. * Returns the triangle fill mode
  30344. */
  30345. static readonly TriangleFillMode: number;
  30346. /**
  30347. * Returns the wireframe mode
  30348. */
  30349. static readonly WireFrameFillMode: number;
  30350. /**
  30351. * Returns the point fill mode
  30352. */
  30353. static readonly PointFillMode: number;
  30354. /**
  30355. * Returns the point list draw mode
  30356. */
  30357. static readonly PointListDrawMode: number;
  30358. /**
  30359. * Returns the line list draw mode
  30360. */
  30361. static readonly LineListDrawMode: number;
  30362. /**
  30363. * Returns the line loop draw mode
  30364. */
  30365. static readonly LineLoopDrawMode: number;
  30366. /**
  30367. * Returns the line strip draw mode
  30368. */
  30369. static readonly LineStripDrawMode: number;
  30370. /**
  30371. * Returns the triangle strip draw mode
  30372. */
  30373. static readonly TriangleStripDrawMode: number;
  30374. /**
  30375. * Returns the triangle fan draw mode
  30376. */
  30377. static readonly TriangleFanDrawMode: number;
  30378. /**
  30379. * Stores the clock-wise side orientation
  30380. */
  30381. static readonly ClockWiseSideOrientation: number;
  30382. /**
  30383. * Stores the counter clock-wise side orientation
  30384. */
  30385. static readonly CounterClockWiseSideOrientation: number;
  30386. /**
  30387. * The dirty texture flag value
  30388. */
  30389. static readonly TextureDirtyFlag: number;
  30390. /**
  30391. * The dirty light flag value
  30392. */
  30393. static readonly LightDirtyFlag: number;
  30394. /**
  30395. * The dirty fresnel flag value
  30396. */
  30397. static readonly FresnelDirtyFlag: number;
  30398. /**
  30399. * The dirty attribute flag value
  30400. */
  30401. static readonly AttributesDirtyFlag: number;
  30402. /**
  30403. * The dirty misc flag value
  30404. */
  30405. static readonly MiscDirtyFlag: number;
  30406. /**
  30407. * The dirty prepass flag value
  30408. */
  30409. static readonly PrePassDirtyFlag: number;
  30410. /**
  30411. * The all dirty flag value
  30412. */
  30413. static readonly AllDirtyFlag: number;
  30414. /**
  30415. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30416. */
  30417. static readonly MATERIAL_OPAQUE: number;
  30418. /**
  30419. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30420. */
  30421. static readonly MATERIAL_ALPHATEST: number;
  30422. /**
  30423. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30424. */
  30425. static readonly MATERIAL_ALPHABLEND: number;
  30426. /**
  30427. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30428. * They are also discarded below the alpha cutoff threshold to improve performances.
  30429. */
  30430. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30431. /**
  30432. * The Whiteout method is used to blend normals.
  30433. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30434. */
  30435. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30436. /**
  30437. * The Reoriented Normal Mapping method is used to blend normals.
  30438. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30439. */
  30440. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30441. /**
  30442. * Custom callback helping to override the default shader used in the material.
  30443. */
  30444. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30445. /**
  30446. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30447. */
  30448. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30449. /**
  30450. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30451. * This means that the material can keep using a previous shader while a new one is being compiled.
  30452. * This is mostly used when shader parallel compilation is supported (true by default)
  30453. */
  30454. allowShaderHotSwapping: boolean;
  30455. /**
  30456. * The ID of the material
  30457. */
  30458. id: string;
  30459. /**
  30460. * Gets or sets the unique id of the material
  30461. */
  30462. uniqueId: number;
  30463. /**
  30464. * The name of the material
  30465. */
  30466. name: string;
  30467. /**
  30468. * Gets or sets user defined metadata
  30469. */
  30470. metadata: any;
  30471. /**
  30472. * For internal use only. Please do not use.
  30473. */
  30474. reservedDataStore: any;
  30475. /**
  30476. * Specifies if the ready state should be checked on each call
  30477. */
  30478. checkReadyOnEveryCall: boolean;
  30479. /**
  30480. * Specifies if the ready state should be checked once
  30481. */
  30482. checkReadyOnlyOnce: boolean;
  30483. /**
  30484. * The state of the material
  30485. */
  30486. state: string;
  30487. /**
  30488. * If the material can be rendered to several textures with MRT extension
  30489. */
  30490. get canRenderToMRT(): boolean;
  30491. /**
  30492. * The alpha value of the material
  30493. */
  30494. protected _alpha: number;
  30495. /**
  30496. * List of inspectable custom properties (used by the Inspector)
  30497. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30498. */
  30499. inspectableCustomProperties: IInspectable[];
  30500. /**
  30501. * Sets the alpha value of the material
  30502. */
  30503. set alpha(value: number);
  30504. /**
  30505. * Gets the alpha value of the material
  30506. */
  30507. get alpha(): number;
  30508. /**
  30509. * Specifies if back face culling is enabled
  30510. */
  30511. protected _backFaceCulling: boolean;
  30512. /**
  30513. * Sets the back-face culling state
  30514. */
  30515. set backFaceCulling(value: boolean);
  30516. /**
  30517. * Gets the back-face culling state
  30518. */
  30519. get backFaceCulling(): boolean;
  30520. /**
  30521. * Stores the value for side orientation
  30522. */
  30523. sideOrientation: number;
  30524. /**
  30525. * Callback triggered when the material is compiled
  30526. */
  30527. onCompiled: Nullable<(effect: Effect) => void>;
  30528. /**
  30529. * Callback triggered when an error occurs
  30530. */
  30531. onError: Nullable<(effect: Effect, errors: string) => void>;
  30532. /**
  30533. * Callback triggered to get the render target textures
  30534. */
  30535. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30536. /**
  30537. * Gets a boolean indicating that current material needs to register RTT
  30538. */
  30539. get hasRenderTargetTextures(): boolean;
  30540. /**
  30541. * Specifies if the material should be serialized
  30542. */
  30543. doNotSerialize: boolean;
  30544. /**
  30545. * @hidden
  30546. */
  30547. _storeEffectOnSubMeshes: boolean;
  30548. /**
  30549. * Stores the animations for the material
  30550. */
  30551. animations: Nullable<Array<Animation>>;
  30552. /**
  30553. * An event triggered when the material is disposed
  30554. */
  30555. onDisposeObservable: Observable<Material>;
  30556. /**
  30557. * An observer which watches for dispose events
  30558. */
  30559. private _onDisposeObserver;
  30560. private _onUnBindObservable;
  30561. /**
  30562. * Called during a dispose event
  30563. */
  30564. set onDispose(callback: () => void);
  30565. private _onBindObservable;
  30566. /**
  30567. * An event triggered when the material is bound
  30568. */
  30569. get onBindObservable(): Observable<AbstractMesh>;
  30570. /**
  30571. * An observer which watches for bind events
  30572. */
  30573. private _onBindObserver;
  30574. /**
  30575. * Called during a bind event
  30576. */
  30577. set onBind(callback: (Mesh: AbstractMesh) => void);
  30578. /**
  30579. * An event triggered when the material is unbound
  30580. */
  30581. get onUnBindObservable(): Observable<Material>;
  30582. protected _onEffectCreatedObservable: Nullable<Observable<{
  30583. effect: Effect;
  30584. subMesh: Nullable<SubMesh>;
  30585. }>>;
  30586. /**
  30587. * An event triggered when the effect is (re)created
  30588. */
  30589. get onEffectCreatedObservable(): Observable<{
  30590. effect: Effect;
  30591. subMesh: Nullable<SubMesh>;
  30592. }>;
  30593. /**
  30594. * Stores the value of the alpha mode
  30595. */
  30596. private _alphaMode;
  30597. /**
  30598. * Sets the value of the alpha mode.
  30599. *
  30600. * | Value | Type | Description |
  30601. * | --- | --- | --- |
  30602. * | 0 | ALPHA_DISABLE | |
  30603. * | 1 | ALPHA_ADD | |
  30604. * | 2 | ALPHA_COMBINE | |
  30605. * | 3 | ALPHA_SUBTRACT | |
  30606. * | 4 | ALPHA_MULTIPLY | |
  30607. * | 5 | ALPHA_MAXIMIZED | |
  30608. * | 6 | ALPHA_ONEONE | |
  30609. * | 7 | ALPHA_PREMULTIPLIED | |
  30610. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30611. * | 9 | ALPHA_INTERPOLATE | |
  30612. * | 10 | ALPHA_SCREENMODE | |
  30613. *
  30614. */
  30615. set alphaMode(value: number);
  30616. /**
  30617. * Gets the value of the alpha mode
  30618. */
  30619. get alphaMode(): number;
  30620. /**
  30621. * Stores the state of the need depth pre-pass value
  30622. */
  30623. private _needDepthPrePass;
  30624. /**
  30625. * Sets the need depth pre-pass value
  30626. */
  30627. set needDepthPrePass(value: boolean);
  30628. /**
  30629. * Gets the depth pre-pass value
  30630. */
  30631. get needDepthPrePass(): boolean;
  30632. /**
  30633. * Can this material render to prepass
  30634. */
  30635. get isPrePassCapable(): boolean;
  30636. /**
  30637. * Specifies if depth writing should be disabled
  30638. */
  30639. disableDepthWrite: boolean;
  30640. /**
  30641. * Specifies if color writing should be disabled
  30642. */
  30643. disableColorWrite: boolean;
  30644. /**
  30645. * Specifies if depth writing should be forced
  30646. */
  30647. forceDepthWrite: boolean;
  30648. /**
  30649. * Specifies the depth function that should be used. 0 means the default engine function
  30650. */
  30651. depthFunction: number;
  30652. /**
  30653. * Specifies if there should be a separate pass for culling
  30654. */
  30655. separateCullingPass: boolean;
  30656. /**
  30657. * Stores the state specifying if fog should be enabled
  30658. */
  30659. private _fogEnabled;
  30660. /**
  30661. * Sets the state for enabling fog
  30662. */
  30663. set fogEnabled(value: boolean);
  30664. /**
  30665. * Gets the value of the fog enabled state
  30666. */
  30667. get fogEnabled(): boolean;
  30668. /**
  30669. * Stores the size of points
  30670. */
  30671. pointSize: number;
  30672. /**
  30673. * Stores the z offset value
  30674. */
  30675. zOffset: number;
  30676. get wireframe(): boolean;
  30677. /**
  30678. * Sets the state of wireframe mode
  30679. */
  30680. set wireframe(value: boolean);
  30681. /**
  30682. * Gets the value specifying if point clouds are enabled
  30683. */
  30684. get pointsCloud(): boolean;
  30685. /**
  30686. * Sets the state of point cloud mode
  30687. */
  30688. set pointsCloud(value: boolean);
  30689. /**
  30690. * Gets the material fill mode
  30691. */
  30692. get fillMode(): number;
  30693. /**
  30694. * Sets the material fill mode
  30695. */
  30696. set fillMode(value: number);
  30697. /**
  30698. * @hidden
  30699. * Stores the effects for the material
  30700. */
  30701. _effect: Nullable<Effect>;
  30702. /**
  30703. * Specifies if uniform buffers should be used
  30704. */
  30705. private _useUBO;
  30706. /**
  30707. * Stores a reference to the scene
  30708. */
  30709. private _scene;
  30710. private _needToBindSceneUbo;
  30711. /**
  30712. * Stores the fill mode state
  30713. */
  30714. private _fillMode;
  30715. /**
  30716. * Specifies if the depth write state should be cached
  30717. */
  30718. private _cachedDepthWriteState;
  30719. /**
  30720. * Specifies if the color write state should be cached
  30721. */
  30722. private _cachedColorWriteState;
  30723. /**
  30724. * Specifies if the depth function state should be cached
  30725. */
  30726. private _cachedDepthFunctionState;
  30727. /**
  30728. * Stores the uniform buffer
  30729. */
  30730. protected _uniformBuffer: UniformBuffer;
  30731. /** @hidden */
  30732. _indexInSceneMaterialArray: number;
  30733. /** @hidden */
  30734. meshMap: Nullable<{
  30735. [id: string]: AbstractMesh | undefined;
  30736. }>;
  30737. /**
  30738. * Creates a material instance
  30739. * @param name defines the name of the material
  30740. * @param scene defines the scene to reference
  30741. * @param doNotAdd specifies if the material should be added to the scene
  30742. */
  30743. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30744. /**
  30745. * Returns a string representation of the current material
  30746. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30747. * @returns a string with material information
  30748. */
  30749. toString(fullDetails?: boolean): string;
  30750. /**
  30751. * Gets the class name of the material
  30752. * @returns a string with the class name of the material
  30753. */
  30754. getClassName(): string;
  30755. /**
  30756. * Specifies if updates for the material been locked
  30757. */
  30758. get isFrozen(): boolean;
  30759. /**
  30760. * Locks updates for the material
  30761. */
  30762. freeze(): void;
  30763. /**
  30764. * Unlocks updates for the material
  30765. */
  30766. unfreeze(): void;
  30767. /**
  30768. * Specifies if the material is ready to be used
  30769. * @param mesh defines the mesh to check
  30770. * @param useInstances specifies if instances should be used
  30771. * @returns a boolean indicating if the material is ready to be used
  30772. */
  30773. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30774. /**
  30775. * Specifies that the submesh is ready to be used
  30776. * @param mesh defines the mesh to check
  30777. * @param subMesh defines which submesh to check
  30778. * @param useInstances specifies that instances should be used
  30779. * @returns a boolean indicating that the submesh is ready or not
  30780. */
  30781. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30782. /**
  30783. * Returns the material effect
  30784. * @returns the effect associated with the material
  30785. */
  30786. getEffect(): Nullable<Effect>;
  30787. /**
  30788. * Returns the current scene
  30789. * @returns a Scene
  30790. */
  30791. getScene(): Scene;
  30792. /**
  30793. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30794. */
  30795. protected _forceAlphaTest: boolean;
  30796. /**
  30797. * The transparency mode of the material.
  30798. */
  30799. protected _transparencyMode: Nullable<number>;
  30800. /**
  30801. * Gets the current transparency mode.
  30802. */
  30803. get transparencyMode(): Nullable<number>;
  30804. /**
  30805. * Sets the transparency mode of the material.
  30806. *
  30807. * | Value | Type | Description |
  30808. * | ----- | ----------------------------------- | ----------- |
  30809. * | 0 | OPAQUE | |
  30810. * | 1 | ALPHATEST | |
  30811. * | 2 | ALPHABLEND | |
  30812. * | 3 | ALPHATESTANDBLEND | |
  30813. *
  30814. */
  30815. set transparencyMode(value: Nullable<number>);
  30816. /**
  30817. * Returns true if alpha blending should be disabled.
  30818. */
  30819. protected get _disableAlphaBlending(): boolean;
  30820. /**
  30821. * Specifies whether or not this material should be rendered in alpha blend mode.
  30822. * @returns a boolean specifying if alpha blending is needed
  30823. */
  30824. needAlphaBlending(): boolean;
  30825. /**
  30826. * Specifies if the mesh will require alpha blending
  30827. * @param mesh defines the mesh to check
  30828. * @returns a boolean specifying if alpha blending is needed for the mesh
  30829. */
  30830. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30831. /**
  30832. * Specifies whether or not this material should be rendered in alpha test mode.
  30833. * @returns a boolean specifying if an alpha test is needed.
  30834. */
  30835. needAlphaTesting(): boolean;
  30836. /**
  30837. * Specifies if material alpha testing should be turned on for the mesh
  30838. * @param mesh defines the mesh to check
  30839. */
  30840. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30841. /**
  30842. * Gets the texture used for the alpha test
  30843. * @returns the texture to use for alpha testing
  30844. */
  30845. getAlphaTestTexture(): Nullable<BaseTexture>;
  30846. /**
  30847. * Marks the material to indicate that it needs to be re-calculated
  30848. */
  30849. markDirty(): void;
  30850. /** @hidden */
  30851. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30852. /**
  30853. * Binds the material to the mesh
  30854. * @param world defines the world transformation matrix
  30855. * @param mesh defines the mesh to bind the material to
  30856. */
  30857. bind(world: Matrix, mesh?: Mesh): void;
  30858. /**
  30859. * Binds the submesh to the material
  30860. * @param world defines the world transformation matrix
  30861. * @param mesh defines the mesh containing the submesh
  30862. * @param subMesh defines the submesh to bind the material to
  30863. */
  30864. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30865. /**
  30866. * Binds the world matrix to the material
  30867. * @param world defines the world transformation matrix
  30868. */
  30869. bindOnlyWorldMatrix(world: Matrix): void;
  30870. /**
  30871. * Binds the view matrix to the effect
  30872. * @param effect defines the effect to bind the view matrix to
  30873. */
  30874. bindView(effect: Effect): void;
  30875. /**
  30876. * Binds the view projection and projection matrices to the effect
  30877. * @param effect defines the effect to bind the view projection and projection matrices to
  30878. */
  30879. bindViewProjection(effect: Effect): void;
  30880. /**
  30881. * Binds the view matrix to the effect
  30882. * @param effect defines the effect to bind the view matrix to
  30883. * @param variableName name of the shader variable that will hold the eye position
  30884. */
  30885. bindEyePosition(effect: Effect, variableName?: string): void;
  30886. /**
  30887. * Processes to execute after binding the material to a mesh
  30888. * @param mesh defines the rendered mesh
  30889. */
  30890. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  30891. /**
  30892. * Unbinds the material from the mesh
  30893. */
  30894. unbind(): void;
  30895. /**
  30896. * Gets the active textures from the material
  30897. * @returns an array of textures
  30898. */
  30899. getActiveTextures(): BaseTexture[];
  30900. /**
  30901. * Specifies if the material uses a texture
  30902. * @param texture defines the texture to check against the material
  30903. * @returns a boolean specifying if the material uses the texture
  30904. */
  30905. hasTexture(texture: BaseTexture): boolean;
  30906. /**
  30907. * Makes a duplicate of the material, and gives it a new name
  30908. * @param name defines the new name for the duplicated material
  30909. * @returns the cloned material
  30910. */
  30911. clone(name: string): Nullable<Material>;
  30912. /**
  30913. * Gets the meshes bound to the material
  30914. * @returns an array of meshes bound to the material
  30915. */
  30916. getBindedMeshes(): AbstractMesh[];
  30917. /**
  30918. * Force shader compilation
  30919. * @param mesh defines the mesh associated with this material
  30920. * @param onCompiled defines a function to execute once the material is compiled
  30921. * @param options defines the options to configure the compilation
  30922. * @param onError defines a function to execute if the material fails compiling
  30923. */
  30924. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  30925. /**
  30926. * Force shader compilation
  30927. * @param mesh defines the mesh that will use this material
  30928. * @param options defines additional options for compiling the shaders
  30929. * @returns a promise that resolves when the compilation completes
  30930. */
  30931. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  30932. private static readonly _AllDirtyCallBack;
  30933. private static readonly _ImageProcessingDirtyCallBack;
  30934. private static readonly _TextureDirtyCallBack;
  30935. private static readonly _FresnelDirtyCallBack;
  30936. private static readonly _MiscDirtyCallBack;
  30937. private static readonly _PrePassDirtyCallBack;
  30938. private static readonly _LightsDirtyCallBack;
  30939. private static readonly _AttributeDirtyCallBack;
  30940. private static _FresnelAndMiscDirtyCallBack;
  30941. private static _TextureAndMiscDirtyCallBack;
  30942. private static readonly _DirtyCallbackArray;
  30943. private static readonly _RunDirtyCallBacks;
  30944. /**
  30945. * Marks a define in the material to indicate that it needs to be re-computed
  30946. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  30947. */
  30948. markAsDirty(flag: number): void;
  30949. /**
  30950. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  30951. * @param func defines a function which checks material defines against the submeshes
  30952. */
  30953. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  30954. /**
  30955. * Indicates that the scene should check if the rendering now needs a prepass
  30956. */
  30957. protected _markScenePrePassDirty(): void;
  30958. /**
  30959. * Indicates that we need to re-calculated for all submeshes
  30960. */
  30961. protected _markAllSubMeshesAsAllDirty(): void;
  30962. /**
  30963. * Indicates that image processing needs to be re-calculated for all submeshes
  30964. */
  30965. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  30966. /**
  30967. * Indicates that textures need to be re-calculated for all submeshes
  30968. */
  30969. protected _markAllSubMeshesAsTexturesDirty(): void;
  30970. /**
  30971. * Indicates that fresnel needs to be re-calculated for all submeshes
  30972. */
  30973. protected _markAllSubMeshesAsFresnelDirty(): void;
  30974. /**
  30975. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  30976. */
  30977. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  30978. /**
  30979. * Indicates that lights need to be re-calculated for all submeshes
  30980. */
  30981. protected _markAllSubMeshesAsLightsDirty(): void;
  30982. /**
  30983. * Indicates that attributes need to be re-calculated for all submeshes
  30984. */
  30985. protected _markAllSubMeshesAsAttributesDirty(): void;
  30986. /**
  30987. * Indicates that misc needs to be re-calculated for all submeshes
  30988. */
  30989. protected _markAllSubMeshesAsMiscDirty(): void;
  30990. /**
  30991. * Indicates that prepass needs to be re-calculated for all submeshes
  30992. */
  30993. protected _markAllSubMeshesAsPrePassDirty(): void;
  30994. /**
  30995. * Indicates that textures and misc need to be re-calculated for all submeshes
  30996. */
  30997. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  30998. /**
  30999. * Sets the required values to the prepass renderer.
  31000. * @param prePassRenderer defines the prepass renderer to setup.
  31001. * @returns true if the pre pass is needed.
  31002. */
  31003. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  31004. /**
  31005. * Disposes the material
  31006. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31007. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31008. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  31009. */
  31010. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  31011. /** @hidden */
  31012. private releaseVertexArrayObject;
  31013. /**
  31014. * Serializes this material
  31015. * @returns the serialized material object
  31016. */
  31017. serialize(): any;
  31018. /**
  31019. * Creates a material from parsed material data
  31020. * @param parsedMaterial defines parsed material data
  31021. * @param scene defines the hosting scene
  31022. * @param rootUrl defines the root URL to use to load textures
  31023. * @returns a new material
  31024. */
  31025. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  31026. }
  31027. }
  31028. declare module BABYLON {
  31029. /**
  31030. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31031. * separate meshes. This can be use to improve performances.
  31032. * @see https://doc.babylonjs.com/how_to/multi_materials
  31033. */
  31034. export class MultiMaterial extends Material {
  31035. private _subMaterials;
  31036. /**
  31037. * Gets or Sets the list of Materials used within the multi material.
  31038. * They need to be ordered according to the submeshes order in the associated mesh
  31039. */
  31040. get subMaterials(): Nullable<Material>[];
  31041. set subMaterials(value: Nullable<Material>[]);
  31042. /**
  31043. * Function used to align with Node.getChildren()
  31044. * @returns the list of Materials used within the multi material
  31045. */
  31046. getChildren(): Nullable<Material>[];
  31047. /**
  31048. * Instantiates a new Multi Material
  31049. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31050. * separate meshes. This can be use to improve performances.
  31051. * @see https://doc.babylonjs.com/how_to/multi_materials
  31052. * @param name Define the name in the scene
  31053. * @param scene Define the scene the material belongs to
  31054. */
  31055. constructor(name: string, scene: Scene);
  31056. private _hookArray;
  31057. /**
  31058. * Get one of the submaterial by its index in the submaterials array
  31059. * @param index The index to look the sub material at
  31060. * @returns The Material if the index has been defined
  31061. */
  31062. getSubMaterial(index: number): Nullable<Material>;
  31063. /**
  31064. * Get the list of active textures for the whole sub materials list.
  31065. * @returns All the textures that will be used during the rendering
  31066. */
  31067. getActiveTextures(): BaseTexture[];
  31068. /**
  31069. * Specifies if any sub-materials of this multi-material use a given texture.
  31070. * @param texture Defines the texture to check against this multi-material's sub-materials.
  31071. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  31072. */
  31073. hasTexture(texture: BaseTexture): boolean;
  31074. /**
  31075. * Gets the current class name of the material e.g. "MultiMaterial"
  31076. * Mainly use in serialization.
  31077. * @returns the class name
  31078. */
  31079. getClassName(): string;
  31080. /**
  31081. * Checks if the material is ready to render the requested sub mesh
  31082. * @param mesh Define the mesh the submesh belongs to
  31083. * @param subMesh Define the sub mesh to look readiness for
  31084. * @param useInstances Define whether or not the material is used with instances
  31085. * @returns true if ready, otherwise false
  31086. */
  31087. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31088. /**
  31089. * Clones the current material and its related sub materials
  31090. * @param name Define the name of the newly cloned material
  31091. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  31092. * @returns the cloned material
  31093. */
  31094. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  31095. /**
  31096. * Serializes the materials into a JSON representation.
  31097. * @returns the JSON representation
  31098. */
  31099. serialize(): any;
  31100. /**
  31101. * Dispose the material and release its associated resources
  31102. * @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)
  31103. * @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)
  31104. * @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)
  31105. */
  31106. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  31107. /**
  31108. * Creates a MultiMaterial from parsed MultiMaterial data.
  31109. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  31110. * @param scene defines the hosting scene
  31111. * @returns a new MultiMaterial
  31112. */
  31113. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  31114. }
  31115. }
  31116. declare module BABYLON {
  31117. /** @hidden */
  31118. export interface ICustomEffect {
  31119. effect: Effect;
  31120. defines: string;
  31121. }
  31122. /**
  31123. * Defines a subdivision inside a mesh
  31124. */
  31125. export class SubMesh implements ICullable {
  31126. /** the material index to use */
  31127. materialIndex: number;
  31128. /** vertex index start */
  31129. verticesStart: number;
  31130. /** vertices count */
  31131. verticesCount: number;
  31132. /** index start */
  31133. indexStart: number;
  31134. /** indices count */
  31135. indexCount: number;
  31136. /** @hidden */
  31137. _materialDefines: Nullable<MaterialDefines>;
  31138. /** @hidden */
  31139. _materialEffect: Nullable<Effect>;
  31140. /** @hidden */
  31141. _effectOverride: Nullable<Effect>;
  31142. private _customEffects;
  31143. /**
  31144. * Gets material defines used by the effect associated to the sub mesh
  31145. */
  31146. get materialDefines(): Nullable<MaterialDefines>;
  31147. /**
  31148. * Sets material defines used by the effect associated to the sub mesh
  31149. */
  31150. set materialDefines(defines: Nullable<MaterialDefines>);
  31151. /** @hidden */
  31152. _getCustomEffect(name: string, createIfNotExisting?: boolean): Nullable<ICustomEffect>;
  31153. /** @hidden */
  31154. _removeCustomEffect(name: string): void;
  31155. /**
  31156. * Gets associated effect
  31157. */
  31158. get effect(): Nullable<Effect>;
  31159. /**
  31160. * Sets associated effect (effect used to render this submesh)
  31161. * @param effect defines the effect to associate with
  31162. * @param defines defines the set of defines used to compile this effect
  31163. */
  31164. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  31165. /** @hidden */
  31166. _linesIndexCount: number;
  31167. private _mesh;
  31168. private _renderingMesh;
  31169. private _boundingInfo;
  31170. private _linesIndexBuffer;
  31171. /** @hidden */
  31172. _lastColliderWorldVertices: Nullable<Vector3[]>;
  31173. /** @hidden */
  31174. _trianglePlanes: Plane[];
  31175. /** @hidden */
  31176. _lastColliderTransformMatrix: Nullable<Matrix>;
  31177. /** @hidden */
  31178. _renderId: number;
  31179. /** @hidden */
  31180. _alphaIndex: number;
  31181. /** @hidden */
  31182. _distanceToCamera: number;
  31183. /** @hidden */
  31184. _id: number;
  31185. private _currentMaterial;
  31186. /**
  31187. * Add a new submesh to a mesh
  31188. * @param materialIndex defines the material index to use
  31189. * @param verticesStart defines vertex index start
  31190. * @param verticesCount defines vertices count
  31191. * @param indexStart defines index start
  31192. * @param indexCount defines indices count
  31193. * @param mesh defines the parent mesh
  31194. * @param renderingMesh defines an optional rendering mesh
  31195. * @param createBoundingBox defines if bounding box should be created for this submesh
  31196. * @returns the new submesh
  31197. */
  31198. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  31199. /**
  31200. * Creates a new submesh
  31201. * @param materialIndex defines the material index to use
  31202. * @param verticesStart defines vertex index start
  31203. * @param verticesCount defines vertices count
  31204. * @param indexStart defines index start
  31205. * @param indexCount defines indices count
  31206. * @param mesh defines the parent mesh
  31207. * @param renderingMesh defines an optional rendering mesh
  31208. * @param createBoundingBox defines if bounding box should be created for this submesh
  31209. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  31210. */
  31211. constructor(
  31212. /** the material index to use */
  31213. materialIndex: number,
  31214. /** vertex index start */
  31215. verticesStart: number,
  31216. /** vertices count */
  31217. verticesCount: number,
  31218. /** index start */
  31219. indexStart: number,
  31220. /** indices count */
  31221. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  31222. /**
  31223. * Returns true if this submesh covers the entire parent mesh
  31224. * @ignorenaming
  31225. */
  31226. get IsGlobal(): boolean;
  31227. /**
  31228. * Returns the submesh BoundingInfo object
  31229. * @returns current bounding info (or mesh's one if the submesh is global)
  31230. */
  31231. getBoundingInfo(): BoundingInfo;
  31232. /**
  31233. * Sets the submesh BoundingInfo
  31234. * @param boundingInfo defines the new bounding info to use
  31235. * @returns the SubMesh
  31236. */
  31237. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  31238. /**
  31239. * Returns the mesh of the current submesh
  31240. * @return the parent mesh
  31241. */
  31242. getMesh(): AbstractMesh;
  31243. /**
  31244. * Returns the rendering mesh of the submesh
  31245. * @returns the rendering mesh (could be different from parent mesh)
  31246. */
  31247. getRenderingMesh(): Mesh;
  31248. /**
  31249. * Returns the replacement mesh of the submesh
  31250. * @returns the replacement mesh (could be different from parent mesh)
  31251. */
  31252. getReplacementMesh(): Nullable<AbstractMesh>;
  31253. /**
  31254. * Returns the effective mesh of the submesh
  31255. * @returns the effective mesh (could be different from parent mesh)
  31256. */
  31257. getEffectiveMesh(): AbstractMesh;
  31258. /**
  31259. * Returns the submesh material
  31260. * @returns null or the current material
  31261. */
  31262. getMaterial(): Nullable<Material>;
  31263. private _IsMultiMaterial;
  31264. /**
  31265. * Sets a new updated BoundingInfo object to the submesh
  31266. * @param data defines an optional position array to use to determine the bounding info
  31267. * @returns the SubMesh
  31268. */
  31269. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  31270. /** @hidden */
  31271. _checkCollision(collider: Collider): boolean;
  31272. /**
  31273. * Updates the submesh BoundingInfo
  31274. * @param world defines the world matrix to use to update the bounding info
  31275. * @returns the submesh
  31276. */
  31277. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  31278. /**
  31279. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  31280. * @param frustumPlanes defines the frustum planes
  31281. * @returns true if the submesh is intersecting with the frustum
  31282. */
  31283. isInFrustum(frustumPlanes: Plane[]): boolean;
  31284. /**
  31285. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  31286. * @param frustumPlanes defines the frustum planes
  31287. * @returns true if the submesh is inside the frustum
  31288. */
  31289. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31290. /**
  31291. * Renders the submesh
  31292. * @param enableAlphaMode defines if alpha needs to be used
  31293. * @returns the submesh
  31294. */
  31295. render(enableAlphaMode: boolean): SubMesh;
  31296. /**
  31297. * @hidden
  31298. */
  31299. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  31300. /**
  31301. * Checks if the submesh intersects with a ray
  31302. * @param ray defines the ray to test
  31303. * @returns true is the passed ray intersects the submesh bounding box
  31304. */
  31305. canIntersects(ray: Ray): boolean;
  31306. /**
  31307. * Intersects current submesh with a ray
  31308. * @param ray defines the ray to test
  31309. * @param positions defines mesh's positions array
  31310. * @param indices defines mesh's indices array
  31311. * @param fastCheck defines if the first intersection will be used (and not the closest)
  31312. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31313. * @returns intersection info or null if no intersection
  31314. */
  31315. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  31316. /** @hidden */
  31317. private _intersectLines;
  31318. /** @hidden */
  31319. private _intersectUnIndexedLines;
  31320. /** @hidden */
  31321. private _intersectTriangles;
  31322. /** @hidden */
  31323. private _intersectUnIndexedTriangles;
  31324. /** @hidden */
  31325. _rebuild(): void;
  31326. /**
  31327. * Creates a new submesh from the passed mesh
  31328. * @param newMesh defines the new hosting mesh
  31329. * @param newRenderingMesh defines an optional rendering mesh
  31330. * @returns the new submesh
  31331. */
  31332. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31333. /**
  31334. * Release associated resources
  31335. */
  31336. dispose(): void;
  31337. /**
  31338. * Gets the class name
  31339. * @returns the string "SubMesh".
  31340. */
  31341. getClassName(): string;
  31342. /**
  31343. * Creates a new submesh from indices data
  31344. * @param materialIndex the index of the main mesh material
  31345. * @param startIndex the index where to start the copy in the mesh indices array
  31346. * @param indexCount the number of indices to copy then from the startIndex
  31347. * @param mesh the main mesh to create the submesh from
  31348. * @param renderingMesh the optional rendering mesh
  31349. * @returns a new submesh
  31350. */
  31351. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31352. }
  31353. }
  31354. declare module BABYLON {
  31355. /**
  31356. * Class used to represent data loading progression
  31357. */
  31358. export class SceneLoaderFlags {
  31359. private static _ForceFullSceneLoadingForIncremental;
  31360. private static _ShowLoadingScreen;
  31361. private static _CleanBoneMatrixWeights;
  31362. private static _loggingLevel;
  31363. /**
  31364. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31365. */
  31366. static get ForceFullSceneLoadingForIncremental(): boolean;
  31367. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31368. /**
  31369. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31370. */
  31371. static get ShowLoadingScreen(): boolean;
  31372. static set ShowLoadingScreen(value: boolean);
  31373. /**
  31374. * Defines the current logging level (while loading the scene)
  31375. * @ignorenaming
  31376. */
  31377. static get loggingLevel(): number;
  31378. static set loggingLevel(value: number);
  31379. /**
  31380. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31381. */
  31382. static get CleanBoneMatrixWeights(): boolean;
  31383. static set CleanBoneMatrixWeights(value: boolean);
  31384. }
  31385. }
  31386. declare module BABYLON {
  31387. /**
  31388. * Class used to store geometry data (vertex buffers + index buffer)
  31389. */
  31390. export class Geometry implements IGetSetVerticesData {
  31391. /**
  31392. * Gets or sets the ID of the geometry
  31393. */
  31394. id: string;
  31395. /**
  31396. * Gets or sets the unique ID of the geometry
  31397. */
  31398. uniqueId: number;
  31399. /**
  31400. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31401. */
  31402. delayLoadState: number;
  31403. /**
  31404. * Gets the file containing the data to load when running in delay load state
  31405. */
  31406. delayLoadingFile: Nullable<string>;
  31407. /**
  31408. * Callback called when the geometry is updated
  31409. */
  31410. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31411. private _scene;
  31412. private _engine;
  31413. private _meshes;
  31414. private _totalVertices;
  31415. /** @hidden */
  31416. _indices: IndicesArray;
  31417. /** @hidden */
  31418. _vertexBuffers: {
  31419. [key: string]: VertexBuffer;
  31420. };
  31421. private _isDisposed;
  31422. private _extend;
  31423. private _boundingBias;
  31424. /** @hidden */
  31425. _delayInfo: Array<string>;
  31426. private _indexBuffer;
  31427. private _indexBufferIsUpdatable;
  31428. /** @hidden */
  31429. _boundingInfo: Nullable<BoundingInfo>;
  31430. /** @hidden */
  31431. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31432. /** @hidden */
  31433. _softwareSkinningFrameId: number;
  31434. private _vertexArrayObjects;
  31435. private _updatable;
  31436. /** @hidden */
  31437. _positions: Nullable<Vector3[]>;
  31438. private _positionsCache;
  31439. /**
  31440. * 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
  31441. */
  31442. get boundingBias(): Vector2;
  31443. /**
  31444. * 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
  31445. */
  31446. set boundingBias(value: Vector2);
  31447. /**
  31448. * Static function used to attach a new empty geometry to a mesh
  31449. * @param mesh defines the mesh to attach the geometry to
  31450. * @returns the new Geometry
  31451. */
  31452. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31453. /** Get the list of meshes using this geometry */
  31454. get meshes(): Mesh[];
  31455. /**
  31456. * 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
  31457. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31458. */
  31459. useBoundingInfoFromGeometry: boolean;
  31460. /**
  31461. * Creates a new geometry
  31462. * @param id defines the unique ID
  31463. * @param scene defines the hosting scene
  31464. * @param vertexData defines the VertexData used to get geometry data
  31465. * @param updatable defines if geometry must be updatable (false by default)
  31466. * @param mesh defines the mesh that will be associated with the geometry
  31467. */
  31468. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31469. /**
  31470. * Gets the current extend of the geometry
  31471. */
  31472. get extend(): {
  31473. minimum: Vector3;
  31474. maximum: Vector3;
  31475. };
  31476. /**
  31477. * Gets the hosting scene
  31478. * @returns the hosting Scene
  31479. */
  31480. getScene(): Scene;
  31481. /**
  31482. * Gets the hosting engine
  31483. * @returns the hosting Engine
  31484. */
  31485. getEngine(): Engine;
  31486. /**
  31487. * Defines if the geometry is ready to use
  31488. * @returns true if the geometry is ready to be used
  31489. */
  31490. isReady(): boolean;
  31491. /**
  31492. * Gets a value indicating that the geometry should not be serialized
  31493. */
  31494. get doNotSerialize(): boolean;
  31495. /** @hidden */
  31496. _rebuild(): void;
  31497. /**
  31498. * Affects all geometry data in one call
  31499. * @param vertexData defines the geometry data
  31500. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31501. */
  31502. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31503. /**
  31504. * Set specific vertex data
  31505. * @param kind defines the data kind (Position, normal, etc...)
  31506. * @param data defines the vertex data to use
  31507. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31508. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31509. */
  31510. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31511. /**
  31512. * Removes a specific vertex data
  31513. * @param kind defines the data kind (Position, normal, etc...)
  31514. */
  31515. removeVerticesData(kind: string): void;
  31516. /**
  31517. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31518. * @param buffer defines the vertex buffer to use
  31519. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31520. */
  31521. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31522. /**
  31523. * Update a specific vertex buffer
  31524. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31525. * It will do nothing if the buffer is not updatable
  31526. * @param kind defines the data kind (Position, normal, etc...)
  31527. * @param data defines the data to use
  31528. * @param offset defines the offset in the target buffer where to store the data
  31529. * @param useBytes set to true if the offset is in bytes
  31530. */
  31531. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31532. /**
  31533. * Update a specific vertex buffer
  31534. * This function will create a new buffer if the current one is not updatable
  31535. * @param kind defines the data kind (Position, normal, etc...)
  31536. * @param data defines the data to use
  31537. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31538. */
  31539. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31540. private _updateBoundingInfo;
  31541. /** @hidden */
  31542. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>, overrideVertexBuffers?: {
  31543. [kind: string]: Nullable<VertexBuffer>;
  31544. }, overrideVertexArrayObjects?: {
  31545. [key: string]: WebGLVertexArrayObject;
  31546. }): void;
  31547. /**
  31548. * Gets total number of vertices
  31549. * @returns the total number of vertices
  31550. */
  31551. getTotalVertices(): number;
  31552. /**
  31553. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31554. * @param kind defines the data kind (Position, normal, etc...)
  31555. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31556. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31557. * @returns a float array containing vertex data
  31558. */
  31559. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31560. /**
  31561. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31562. * @param kind defines the data kind (Position, normal, etc...)
  31563. * @returns true if the vertex buffer with the specified kind is updatable
  31564. */
  31565. isVertexBufferUpdatable(kind: string): boolean;
  31566. /**
  31567. * Gets a specific vertex buffer
  31568. * @param kind defines the data kind (Position, normal, etc...)
  31569. * @returns a VertexBuffer
  31570. */
  31571. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31572. /**
  31573. * Returns all vertex buffers
  31574. * @return an object holding all vertex buffers indexed by kind
  31575. */
  31576. getVertexBuffers(): Nullable<{
  31577. [key: string]: VertexBuffer;
  31578. }>;
  31579. /**
  31580. * Gets a boolean indicating if specific vertex buffer is present
  31581. * @param kind defines the data kind (Position, normal, etc...)
  31582. * @returns true if data is present
  31583. */
  31584. isVerticesDataPresent(kind: string): boolean;
  31585. /**
  31586. * Gets a list of all attached data kinds (Position, normal, etc...)
  31587. * @returns a list of string containing all kinds
  31588. */
  31589. getVerticesDataKinds(): string[];
  31590. /**
  31591. * Update index buffer
  31592. * @param indices defines the indices to store in the index buffer
  31593. * @param offset defines the offset in the target buffer where to store the data
  31594. * @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)
  31595. */
  31596. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31597. /**
  31598. * Creates a new index buffer
  31599. * @param indices defines the indices to store in the index buffer
  31600. * @param totalVertices defines the total number of vertices (could be null)
  31601. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31602. */
  31603. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31604. /**
  31605. * Return the total number of indices
  31606. * @returns the total number of indices
  31607. */
  31608. getTotalIndices(): number;
  31609. /**
  31610. * Gets the index buffer array
  31611. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31612. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31613. * @returns the index buffer array
  31614. */
  31615. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31616. /**
  31617. * Gets the index buffer
  31618. * @return the index buffer
  31619. */
  31620. getIndexBuffer(): Nullable<DataBuffer>;
  31621. /** @hidden */
  31622. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31623. /**
  31624. * Release the associated resources for a specific mesh
  31625. * @param mesh defines the source mesh
  31626. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31627. */
  31628. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31629. /**
  31630. * Apply current geometry to a given mesh
  31631. * @param mesh defines the mesh to apply geometry to
  31632. */
  31633. applyToMesh(mesh: Mesh): void;
  31634. private _updateExtend;
  31635. private _applyToMesh;
  31636. private notifyUpdate;
  31637. /**
  31638. * Load the geometry if it was flagged as delay loaded
  31639. * @param scene defines the hosting scene
  31640. * @param onLoaded defines a callback called when the geometry is loaded
  31641. */
  31642. load(scene: Scene, onLoaded?: () => void): void;
  31643. private _queueLoad;
  31644. /**
  31645. * Invert the geometry to move from a right handed system to a left handed one.
  31646. */
  31647. toLeftHanded(): void;
  31648. /** @hidden */
  31649. _resetPointsArrayCache(): void;
  31650. /** @hidden */
  31651. _generatePointsArray(): boolean;
  31652. /**
  31653. * Gets a value indicating if the geometry is disposed
  31654. * @returns true if the geometry was disposed
  31655. */
  31656. isDisposed(): boolean;
  31657. private _disposeVertexArrayObjects;
  31658. /**
  31659. * Free all associated resources
  31660. */
  31661. dispose(): void;
  31662. /**
  31663. * Clone the current geometry into a new geometry
  31664. * @param id defines the unique ID of the new geometry
  31665. * @returns a new geometry object
  31666. */
  31667. copy(id: string): Geometry;
  31668. /**
  31669. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31670. * @return a JSON representation of the current geometry data (without the vertices data)
  31671. */
  31672. serialize(): any;
  31673. private toNumberArray;
  31674. /**
  31675. * Serialize all vertices data into a JSON object
  31676. * @returns a JSON representation of the current geometry data
  31677. */
  31678. serializeVerticeData(): any;
  31679. /**
  31680. * Extracts a clone of a mesh geometry
  31681. * @param mesh defines the source mesh
  31682. * @param id defines the unique ID of the new geometry object
  31683. * @returns the new geometry object
  31684. */
  31685. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31686. /**
  31687. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31688. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31689. * Be aware Math.random() could cause collisions, but:
  31690. * "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"
  31691. * @returns a string containing a new GUID
  31692. */
  31693. static RandomId(): string;
  31694. /** @hidden */
  31695. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31696. private static _CleanMatricesWeights;
  31697. /**
  31698. * Create a new geometry from persisted data (Using .babylon file format)
  31699. * @param parsedVertexData defines the persisted data
  31700. * @param scene defines the hosting scene
  31701. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31702. * @returns the new geometry object
  31703. */
  31704. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31705. }
  31706. }
  31707. declare module BABYLON {
  31708. /**
  31709. * Defines a target to use with MorphTargetManager
  31710. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31711. */
  31712. export class MorphTarget implements IAnimatable {
  31713. /** defines the name of the target */
  31714. name: string;
  31715. /**
  31716. * Gets or sets the list of animations
  31717. */
  31718. animations: Animation[];
  31719. private _scene;
  31720. private _positions;
  31721. private _normals;
  31722. private _tangents;
  31723. private _uvs;
  31724. private _influence;
  31725. private _uniqueId;
  31726. /**
  31727. * Observable raised when the influence changes
  31728. */
  31729. onInfluenceChanged: Observable<boolean>;
  31730. /** @hidden */
  31731. _onDataLayoutChanged: Observable<void>;
  31732. /**
  31733. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  31734. */
  31735. get influence(): number;
  31736. set influence(influence: number);
  31737. /**
  31738. * Gets or sets the id of the morph Target
  31739. */
  31740. id: string;
  31741. private _animationPropertiesOverride;
  31742. /**
  31743. * Gets or sets the animation properties override
  31744. */
  31745. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31746. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31747. /**
  31748. * Creates a new MorphTarget
  31749. * @param name defines the name of the target
  31750. * @param influence defines the influence to use
  31751. * @param scene defines the scene the morphtarget belongs to
  31752. */
  31753. constructor(
  31754. /** defines the name of the target */
  31755. name: string, influence?: number, scene?: Nullable<Scene>);
  31756. /**
  31757. * Gets the unique ID of this manager
  31758. */
  31759. get uniqueId(): number;
  31760. /**
  31761. * Gets a boolean defining if the target contains position data
  31762. */
  31763. get hasPositions(): boolean;
  31764. /**
  31765. * Gets a boolean defining if the target contains normal data
  31766. */
  31767. get hasNormals(): boolean;
  31768. /**
  31769. * Gets a boolean defining if the target contains tangent data
  31770. */
  31771. get hasTangents(): boolean;
  31772. /**
  31773. * Gets a boolean defining if the target contains texture coordinates data
  31774. */
  31775. get hasUVs(): boolean;
  31776. /**
  31777. * Affects position data to this target
  31778. * @param data defines the position data to use
  31779. */
  31780. setPositions(data: Nullable<FloatArray>): void;
  31781. /**
  31782. * Gets the position data stored in this target
  31783. * @returns a FloatArray containing the position data (or null if not present)
  31784. */
  31785. getPositions(): Nullable<FloatArray>;
  31786. /**
  31787. * Affects normal data to this target
  31788. * @param data defines the normal data to use
  31789. */
  31790. setNormals(data: Nullable<FloatArray>): void;
  31791. /**
  31792. * Gets the normal data stored in this target
  31793. * @returns a FloatArray containing the normal data (or null if not present)
  31794. */
  31795. getNormals(): Nullable<FloatArray>;
  31796. /**
  31797. * Affects tangent data to this target
  31798. * @param data defines the tangent data to use
  31799. */
  31800. setTangents(data: Nullable<FloatArray>): void;
  31801. /**
  31802. * Gets the tangent data stored in this target
  31803. * @returns a FloatArray containing the tangent data (or null if not present)
  31804. */
  31805. getTangents(): Nullable<FloatArray>;
  31806. /**
  31807. * Affects texture coordinates data to this target
  31808. * @param data defines the texture coordinates data to use
  31809. */
  31810. setUVs(data: Nullable<FloatArray>): void;
  31811. /**
  31812. * Gets the texture coordinates data stored in this target
  31813. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  31814. */
  31815. getUVs(): Nullable<FloatArray>;
  31816. /**
  31817. * Clone the current target
  31818. * @returns a new MorphTarget
  31819. */
  31820. clone(): MorphTarget;
  31821. /**
  31822. * Serializes the current target into a Serialization object
  31823. * @returns the serialized object
  31824. */
  31825. serialize(): any;
  31826. /**
  31827. * Returns the string "MorphTarget"
  31828. * @returns "MorphTarget"
  31829. */
  31830. getClassName(): string;
  31831. /**
  31832. * Creates a new target from serialized data
  31833. * @param serializationObject defines the serialized data to use
  31834. * @returns a new MorphTarget
  31835. */
  31836. static Parse(serializationObject: any): MorphTarget;
  31837. /**
  31838. * Creates a MorphTarget from mesh data
  31839. * @param mesh defines the source mesh
  31840. * @param name defines the name to use for the new target
  31841. * @param influence defines the influence to attach to the target
  31842. * @returns a new MorphTarget
  31843. */
  31844. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  31845. }
  31846. }
  31847. declare module BABYLON {
  31848. /**
  31849. * Class used to store 2D array textures containing user data
  31850. */
  31851. export class RawTexture2DArray extends Texture {
  31852. /** Gets or sets the texture format to use */
  31853. format: number;
  31854. /**
  31855. * Create a new RawTexture2DArray
  31856. * @param data defines the data of the texture
  31857. * @param width defines the width of the texture
  31858. * @param height defines the height of the texture
  31859. * @param depth defines the number of layers of the texture
  31860. * @param format defines the texture format to use
  31861. * @param scene defines the hosting scene
  31862. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  31863. * @param invertY defines if texture must be stored with Y axis inverted
  31864. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  31865. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  31866. */
  31867. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  31868. /** Gets or sets the texture format to use */
  31869. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  31870. /**
  31871. * Update the texture with new data
  31872. * @param data defines the data to store in the texture
  31873. */
  31874. update(data: ArrayBufferView): void;
  31875. /**
  31876. * Creates a RGBA texture from some data.
  31877. * @param data Define the texture data
  31878. * @param width Define the width of the texture
  31879. * @param height Define the height of the texture
  31880. * @param depth defines the number of layers of the texture
  31881. * @param scene defines the scene the texture will belong to
  31882. * @param generateMipMaps Define whether or not to create mip maps for the texture
  31883. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  31884. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  31885. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  31886. * @returns the RGBA texture
  31887. */
  31888. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, depth: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture2DArray;
  31889. }
  31890. }
  31891. declare module BABYLON {
  31892. /**
  31893. * This class is used to deform meshes using morphing between different targets
  31894. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31895. */
  31896. export class MorphTargetManager implements IDisposable {
  31897. private _targets;
  31898. private _targetInfluenceChangedObservers;
  31899. private _targetDataLayoutChangedObservers;
  31900. private _activeTargets;
  31901. private _scene;
  31902. private _influences;
  31903. private _supportsNormals;
  31904. private _supportsTangents;
  31905. private _supportsUVs;
  31906. private _vertexCount;
  31907. private _textureVertexStride;
  31908. private _textureWidth;
  31909. private _textureHeight;
  31910. private _uniqueId;
  31911. private _tempInfluences;
  31912. private _canUseTextureForTargets;
  31913. /** @hidden */
  31914. _targetStoreTexture: Nullable<RawTexture2DArray>;
  31915. /**
  31916. * Gets or sets a boolean indicating if normals must be morphed
  31917. */
  31918. enableNormalMorphing: boolean;
  31919. /**
  31920. * Gets or sets a boolean indicating if tangents must be morphed
  31921. */
  31922. enableTangentMorphing: boolean;
  31923. /**
  31924. * Gets or sets a boolean indicating if UV must be morphed
  31925. */
  31926. enableUVMorphing: boolean;
  31927. /**
  31928. * Creates a new MorphTargetManager
  31929. * @param scene defines the current scene
  31930. */
  31931. constructor(scene?: Nullable<Scene>);
  31932. /**
  31933. * Gets the unique ID of this manager
  31934. */
  31935. get uniqueId(): number;
  31936. /**
  31937. * Gets the number of vertices handled by this manager
  31938. */
  31939. get vertexCount(): number;
  31940. /**
  31941. * Gets a boolean indicating if this manager supports morphing of normals
  31942. */
  31943. get supportsNormals(): boolean;
  31944. /**
  31945. * Gets a boolean indicating if this manager supports morphing of tangents
  31946. */
  31947. get supportsTangents(): boolean;
  31948. /**
  31949. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  31950. */
  31951. get supportsUVs(): boolean;
  31952. /**
  31953. * Gets the number of targets stored in this manager
  31954. */
  31955. get numTargets(): number;
  31956. /**
  31957. * Gets the number of influencers (ie. the number of targets with influences > 0)
  31958. */
  31959. get numInfluencers(): number;
  31960. /**
  31961. * Gets the list of influences (one per target)
  31962. */
  31963. get influences(): Float32Array;
  31964. private _useTextureToStoreTargets;
  31965. /**
  31966. * Gets or sets a boolean indicating that targets should be stored as a texture instead of using vertex attributes (default is true).
  31967. * Please note that this option is not available if the hardware does not support it
  31968. */
  31969. get useTextureToStoreTargets(): boolean;
  31970. set useTextureToStoreTargets(value: boolean);
  31971. /**
  31972. * Gets a boolean indicating that the targets are stored into a texture (instead of as attributes)
  31973. */
  31974. get isUsingTextureForTargets(): boolean;
  31975. /**
  31976. * Gets the active target at specified index. An active target is a target with an influence > 0
  31977. * @param index defines the index to check
  31978. * @returns the requested target
  31979. */
  31980. getActiveTarget(index: number): MorphTarget;
  31981. /**
  31982. * Gets the target at specified index
  31983. * @param index defines the index to check
  31984. * @returns the requested target
  31985. */
  31986. getTarget(index: number): MorphTarget;
  31987. /**
  31988. * Add a new target to this manager
  31989. * @param target defines the target to add
  31990. */
  31991. addTarget(target: MorphTarget): void;
  31992. /**
  31993. * Removes a target from the manager
  31994. * @param target defines the target to remove
  31995. */
  31996. removeTarget(target: MorphTarget): void;
  31997. /** @hidden */
  31998. _bind(effect: Effect): void;
  31999. /**
  32000. * Clone the current manager
  32001. * @returns a new MorphTargetManager
  32002. */
  32003. clone(): MorphTargetManager;
  32004. /**
  32005. * Serializes the current manager into a Serialization object
  32006. * @returns the serialized object
  32007. */
  32008. serialize(): any;
  32009. private _syncActiveTargets;
  32010. /**
  32011. * Synchronize the targets with all the meshes using this morph target manager
  32012. */
  32013. synchronize(): void;
  32014. /**
  32015. * Release all resources
  32016. */
  32017. dispose(): void;
  32018. /**
  32019. * Creates a new MorphTargetManager from serialized data
  32020. * @param serializationObject defines the serialized data
  32021. * @param scene defines the hosting scene
  32022. * @returns the new MorphTargetManager
  32023. */
  32024. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  32025. }
  32026. }
  32027. declare module BABYLON {
  32028. /**
  32029. * Class used to represent a specific level of detail of a mesh
  32030. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32031. */
  32032. export class MeshLODLevel {
  32033. /** Defines the distance where this level should start being displayed */
  32034. distance: number;
  32035. /** Defines the mesh to use to render this level */
  32036. mesh: Nullable<Mesh>;
  32037. /**
  32038. * Creates a new LOD level
  32039. * @param distance defines the distance where this level should star being displayed
  32040. * @param mesh defines the mesh to use to render this level
  32041. */
  32042. constructor(
  32043. /** Defines the distance where this level should start being displayed */
  32044. distance: number,
  32045. /** Defines the mesh to use to render this level */
  32046. mesh: Nullable<Mesh>);
  32047. }
  32048. }
  32049. declare module BABYLON {
  32050. /**
  32051. * Helper class used to generate a canvas to manipulate images
  32052. */
  32053. export class CanvasGenerator {
  32054. /**
  32055. * Create a new canvas (or offscreen canvas depending on the context)
  32056. * @param width defines the expected width
  32057. * @param height defines the expected height
  32058. * @return a new canvas or offscreen canvas
  32059. */
  32060. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  32061. }
  32062. }
  32063. declare module BABYLON {
  32064. /**
  32065. * Mesh representing the ground
  32066. */
  32067. export class GroundMesh extends Mesh {
  32068. /** If octree should be generated */
  32069. generateOctree: boolean;
  32070. private _heightQuads;
  32071. /** @hidden */
  32072. _subdivisionsX: number;
  32073. /** @hidden */
  32074. _subdivisionsY: number;
  32075. /** @hidden */
  32076. _width: number;
  32077. /** @hidden */
  32078. _height: number;
  32079. /** @hidden */
  32080. _minX: number;
  32081. /** @hidden */
  32082. _maxX: number;
  32083. /** @hidden */
  32084. _minZ: number;
  32085. /** @hidden */
  32086. _maxZ: number;
  32087. constructor(name: string, scene: Scene);
  32088. /**
  32089. * "GroundMesh"
  32090. * @returns "GroundMesh"
  32091. */
  32092. getClassName(): string;
  32093. /**
  32094. * The minimum of x and y subdivisions
  32095. */
  32096. get subdivisions(): number;
  32097. /**
  32098. * X subdivisions
  32099. */
  32100. get subdivisionsX(): number;
  32101. /**
  32102. * Y subdivisions
  32103. */
  32104. get subdivisionsY(): number;
  32105. /**
  32106. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  32107. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  32108. * @param chunksCount the number of subdivisions for x and y
  32109. * @param octreeBlocksSize (Default: 32)
  32110. */
  32111. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  32112. /**
  32113. * Returns a height (y) value in the World system :
  32114. * the ground altitude at the coordinates (x, z) expressed in the World system.
  32115. * @param x x coordinate
  32116. * @param z z coordinate
  32117. * @returns the ground y position if (x, z) are outside the ground surface.
  32118. */
  32119. getHeightAtCoordinates(x: number, z: number): number;
  32120. /**
  32121. * Returns a normalized vector (Vector3) orthogonal to the ground
  32122. * at the ground coordinates (x, z) expressed in the World system.
  32123. * @param x x coordinate
  32124. * @param z z coordinate
  32125. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  32126. */
  32127. getNormalAtCoordinates(x: number, z: number): Vector3;
  32128. /**
  32129. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  32130. * at the ground coordinates (x, z) expressed in the World system.
  32131. * Doesn't update the reference Vector3 if (x, z) are outside the ground surface.
  32132. * @param x x coordinate
  32133. * @param z z coordinate
  32134. * @param ref vector to store the result
  32135. * @returns the GroundMesh.
  32136. */
  32137. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  32138. /**
  32139. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  32140. * if the ground has been updated.
  32141. * This can be used in the render loop.
  32142. * @returns the GroundMesh.
  32143. */
  32144. updateCoordinateHeights(): GroundMesh;
  32145. private _getFacetAt;
  32146. private _initHeightQuads;
  32147. private _computeHeightQuads;
  32148. /**
  32149. * Serializes this ground mesh
  32150. * @param serializationObject object to write serialization to
  32151. */
  32152. serialize(serializationObject: any): void;
  32153. /**
  32154. * Parses a serialized ground mesh
  32155. * @param parsedMesh the serialized mesh
  32156. * @param scene the scene to create the ground mesh in
  32157. * @returns the created ground mesh
  32158. */
  32159. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  32160. }
  32161. }
  32162. declare module BABYLON {
  32163. /**
  32164. * Interface for Physics-Joint data
  32165. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32166. */
  32167. export interface PhysicsJointData {
  32168. /**
  32169. * The main pivot of the joint
  32170. */
  32171. mainPivot?: Vector3;
  32172. /**
  32173. * The connected pivot of the joint
  32174. */
  32175. connectedPivot?: Vector3;
  32176. /**
  32177. * The main axis of the joint
  32178. */
  32179. mainAxis?: Vector3;
  32180. /**
  32181. * The connected axis of the joint
  32182. */
  32183. connectedAxis?: Vector3;
  32184. /**
  32185. * The collision of the joint
  32186. */
  32187. collision?: boolean;
  32188. /**
  32189. * Native Oimo/Cannon/Energy data
  32190. */
  32191. nativeParams?: any;
  32192. }
  32193. /**
  32194. * This is a holder class for the physics joint created by the physics plugin
  32195. * It holds a set of functions to control the underlying joint
  32196. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32197. */
  32198. export class PhysicsJoint {
  32199. /**
  32200. * The type of the physics joint
  32201. */
  32202. type: number;
  32203. /**
  32204. * The data for the physics joint
  32205. */
  32206. jointData: PhysicsJointData;
  32207. private _physicsJoint;
  32208. protected _physicsPlugin: IPhysicsEnginePlugin;
  32209. /**
  32210. * Initializes the physics joint
  32211. * @param type The type of the physics joint
  32212. * @param jointData The data for the physics joint
  32213. */
  32214. constructor(
  32215. /**
  32216. * The type of the physics joint
  32217. */
  32218. type: number,
  32219. /**
  32220. * The data for the physics joint
  32221. */
  32222. jointData: PhysicsJointData);
  32223. /**
  32224. * Gets the physics joint
  32225. */
  32226. get physicsJoint(): any;
  32227. /**
  32228. * Sets the physics joint
  32229. */
  32230. set physicsJoint(newJoint: any);
  32231. /**
  32232. * Sets the physics plugin
  32233. */
  32234. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  32235. /**
  32236. * Execute a function that is physics-plugin specific.
  32237. * @param {Function} func the function that will be executed.
  32238. * It accepts two parameters: the physics world and the physics joint
  32239. */
  32240. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  32241. /**
  32242. * Distance-Joint type
  32243. */
  32244. static DistanceJoint: number;
  32245. /**
  32246. * Hinge-Joint type
  32247. */
  32248. static HingeJoint: number;
  32249. /**
  32250. * Ball-and-Socket joint type
  32251. */
  32252. static BallAndSocketJoint: number;
  32253. /**
  32254. * Wheel-Joint type
  32255. */
  32256. static WheelJoint: number;
  32257. /**
  32258. * Slider-Joint type
  32259. */
  32260. static SliderJoint: number;
  32261. /**
  32262. * Prismatic-Joint type
  32263. */
  32264. static PrismaticJoint: number;
  32265. /**
  32266. * Universal-Joint type
  32267. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  32268. */
  32269. static UniversalJoint: number;
  32270. /**
  32271. * Hinge-Joint 2 type
  32272. */
  32273. static Hinge2Joint: number;
  32274. /**
  32275. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  32276. */
  32277. static PointToPointJoint: number;
  32278. /**
  32279. * Spring-Joint type
  32280. */
  32281. static SpringJoint: number;
  32282. /**
  32283. * Lock-Joint type
  32284. */
  32285. static LockJoint: number;
  32286. }
  32287. /**
  32288. * A class representing a physics distance joint
  32289. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32290. */
  32291. export class DistanceJoint extends PhysicsJoint {
  32292. /**
  32293. *
  32294. * @param jointData The data for the Distance-Joint
  32295. */
  32296. constructor(jointData: DistanceJointData);
  32297. /**
  32298. * Update the predefined distance.
  32299. * @param maxDistance The maximum preferred distance
  32300. * @param minDistance The minimum preferred distance
  32301. */
  32302. updateDistance(maxDistance: number, minDistance?: number): void;
  32303. }
  32304. /**
  32305. * Represents a Motor-Enabled Joint
  32306. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32307. */
  32308. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32309. /**
  32310. * Initializes the Motor-Enabled Joint
  32311. * @param type The type of the joint
  32312. * @param jointData The physical joint data for the joint
  32313. */
  32314. constructor(type: number, jointData: PhysicsJointData);
  32315. /**
  32316. * Set the motor values.
  32317. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32318. * @param force the force to apply
  32319. * @param maxForce max force for this motor.
  32320. */
  32321. setMotor(force?: number, maxForce?: number): void;
  32322. /**
  32323. * Set the motor's limits.
  32324. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32325. * @param upperLimit The upper limit of the motor
  32326. * @param lowerLimit The lower limit of the motor
  32327. */
  32328. setLimit(upperLimit: number, lowerLimit?: number): void;
  32329. }
  32330. /**
  32331. * This class represents a single physics Hinge-Joint
  32332. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32333. */
  32334. export class HingeJoint extends MotorEnabledJoint {
  32335. /**
  32336. * Initializes the Hinge-Joint
  32337. * @param jointData The joint data for the Hinge-Joint
  32338. */
  32339. constructor(jointData: PhysicsJointData);
  32340. /**
  32341. * Set the motor values.
  32342. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32343. * @param {number} force the force to apply
  32344. * @param {number} maxForce max force for this motor.
  32345. */
  32346. setMotor(force?: number, maxForce?: number): void;
  32347. /**
  32348. * Set the motor's limits.
  32349. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32350. * @param upperLimit The upper limit of the motor
  32351. * @param lowerLimit The lower limit of the motor
  32352. */
  32353. setLimit(upperLimit: number, lowerLimit?: number): void;
  32354. }
  32355. /**
  32356. * This class represents a dual hinge physics joint (same as wheel joint)
  32357. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32358. */
  32359. export class Hinge2Joint extends MotorEnabledJoint {
  32360. /**
  32361. * Initializes the Hinge2-Joint
  32362. * @param jointData The joint data for the Hinge2-Joint
  32363. */
  32364. constructor(jointData: PhysicsJointData);
  32365. /**
  32366. * Set the motor values.
  32367. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32368. * @param {number} targetSpeed the speed the motor is to reach
  32369. * @param {number} maxForce max force for this motor.
  32370. * @param {motorIndex} the motor's index, 0 or 1.
  32371. */
  32372. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32373. /**
  32374. * Set the motor limits.
  32375. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32376. * @param {number} upperLimit the upper limit
  32377. * @param {number} lowerLimit lower limit
  32378. * @param {motorIndex} the motor's index, 0 or 1.
  32379. */
  32380. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32381. }
  32382. /**
  32383. * Interface for a motor enabled joint
  32384. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32385. */
  32386. export interface IMotorEnabledJoint {
  32387. /**
  32388. * Physics joint
  32389. */
  32390. physicsJoint: any;
  32391. /**
  32392. * Sets the motor of the motor-enabled joint
  32393. * @param force The force of the motor
  32394. * @param maxForce The maximum force of the motor
  32395. * @param motorIndex The index of the motor
  32396. */
  32397. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32398. /**
  32399. * Sets the limit of the motor
  32400. * @param upperLimit The upper limit of the motor
  32401. * @param lowerLimit The lower limit of the motor
  32402. * @param motorIndex The index of the motor
  32403. */
  32404. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32405. }
  32406. /**
  32407. * Joint data for a Distance-Joint
  32408. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32409. */
  32410. export interface DistanceJointData extends PhysicsJointData {
  32411. /**
  32412. * Max distance the 2 joint objects can be apart
  32413. */
  32414. maxDistance: number;
  32415. }
  32416. /**
  32417. * Joint data from a spring joint
  32418. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32419. */
  32420. export interface SpringJointData extends PhysicsJointData {
  32421. /**
  32422. * Length of the spring
  32423. */
  32424. length: number;
  32425. /**
  32426. * Stiffness of the spring
  32427. */
  32428. stiffness: number;
  32429. /**
  32430. * Damping of the spring
  32431. */
  32432. damping: number;
  32433. /** this callback will be called when applying the force to the impostors. */
  32434. forceApplicationCallback: () => void;
  32435. }
  32436. }
  32437. declare module BABYLON {
  32438. /**
  32439. * Holds the data for the raycast result
  32440. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32441. */
  32442. export class PhysicsRaycastResult {
  32443. private _hasHit;
  32444. private _hitDistance;
  32445. private _hitNormalWorld;
  32446. private _hitPointWorld;
  32447. private _rayFromWorld;
  32448. private _rayToWorld;
  32449. /**
  32450. * Gets if there was a hit
  32451. */
  32452. get hasHit(): boolean;
  32453. /**
  32454. * Gets the distance from the hit
  32455. */
  32456. get hitDistance(): number;
  32457. /**
  32458. * Gets the hit normal/direction in the world
  32459. */
  32460. get hitNormalWorld(): Vector3;
  32461. /**
  32462. * Gets the hit point in the world
  32463. */
  32464. get hitPointWorld(): Vector3;
  32465. /**
  32466. * Gets the ray "start point" of the ray in the world
  32467. */
  32468. get rayFromWorld(): Vector3;
  32469. /**
  32470. * Gets the ray "end point" of the ray in the world
  32471. */
  32472. get rayToWorld(): Vector3;
  32473. /**
  32474. * Sets the hit data (normal & point in world space)
  32475. * @param hitNormalWorld defines the normal in world space
  32476. * @param hitPointWorld defines the point in world space
  32477. */
  32478. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32479. /**
  32480. * Sets the distance from the start point to the hit point
  32481. * @param distance
  32482. */
  32483. setHitDistance(distance: number): void;
  32484. /**
  32485. * Calculates the distance manually
  32486. */
  32487. calculateHitDistance(): void;
  32488. /**
  32489. * Resets all the values to default
  32490. * @param from The from point on world space
  32491. * @param to The to point on world space
  32492. */
  32493. reset(from?: Vector3, to?: Vector3): void;
  32494. }
  32495. /**
  32496. * Interface for the size containing width and height
  32497. */
  32498. interface IXYZ {
  32499. /**
  32500. * X
  32501. */
  32502. x: number;
  32503. /**
  32504. * Y
  32505. */
  32506. y: number;
  32507. /**
  32508. * Z
  32509. */
  32510. z: number;
  32511. }
  32512. }
  32513. declare module BABYLON {
  32514. /**
  32515. * Interface used to describe a physics joint
  32516. */
  32517. export interface PhysicsImpostorJoint {
  32518. /** Defines the main impostor to which the joint is linked */
  32519. mainImpostor: PhysicsImpostor;
  32520. /** Defines the impostor that is connected to the main impostor using this joint */
  32521. connectedImpostor: PhysicsImpostor;
  32522. /** Defines the joint itself */
  32523. joint: PhysicsJoint;
  32524. }
  32525. /** @hidden */
  32526. export interface IPhysicsEnginePlugin {
  32527. world: any;
  32528. name: string;
  32529. setGravity(gravity: Vector3): void;
  32530. setTimeStep(timeStep: number): void;
  32531. getTimeStep(): number;
  32532. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32533. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32534. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32535. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32536. removePhysicsBody(impostor: PhysicsImpostor): void;
  32537. generateJoint(joint: PhysicsImpostorJoint): void;
  32538. removeJoint(joint: PhysicsImpostorJoint): void;
  32539. isSupported(): boolean;
  32540. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32541. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32542. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32543. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32544. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32545. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32546. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32547. getBodyMass(impostor: PhysicsImpostor): number;
  32548. getBodyFriction(impostor: PhysicsImpostor): number;
  32549. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32550. getBodyRestitution(impostor: PhysicsImpostor): number;
  32551. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32552. getBodyPressure?(impostor: PhysicsImpostor): number;
  32553. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32554. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32555. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32556. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32557. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32558. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32559. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32560. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32561. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32562. sleepBody(impostor: PhysicsImpostor): void;
  32563. wakeUpBody(impostor: PhysicsImpostor): void;
  32564. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32565. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32566. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32567. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32568. getRadius(impostor: PhysicsImpostor): number;
  32569. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32570. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32571. dispose(): void;
  32572. }
  32573. /**
  32574. * Interface used to define a physics engine
  32575. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32576. */
  32577. export interface IPhysicsEngine {
  32578. /**
  32579. * Gets the gravity vector used by the simulation
  32580. */
  32581. gravity: Vector3;
  32582. /**
  32583. * Sets the gravity vector used by the simulation
  32584. * @param gravity defines the gravity vector to use
  32585. */
  32586. setGravity(gravity: Vector3): void;
  32587. /**
  32588. * Set the time step of the physics engine.
  32589. * Default is 1/60.
  32590. * To slow it down, enter 1/600 for example.
  32591. * To speed it up, 1/30
  32592. * @param newTimeStep the new timestep to apply to this world.
  32593. */
  32594. setTimeStep(newTimeStep: number): void;
  32595. /**
  32596. * Get the time step of the physics engine.
  32597. * @returns the current time step
  32598. */
  32599. getTimeStep(): number;
  32600. /**
  32601. * Set the sub time step of the physics engine.
  32602. * Default is 0 meaning there is no sub steps
  32603. * To increase physics resolution precision, set a small value (like 1 ms)
  32604. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32605. */
  32606. setSubTimeStep(subTimeStep: number): void;
  32607. /**
  32608. * Get the sub time step of the physics engine.
  32609. * @returns the current sub time step
  32610. */
  32611. getSubTimeStep(): number;
  32612. /**
  32613. * Release all resources
  32614. */
  32615. dispose(): void;
  32616. /**
  32617. * Gets the name of the current physics plugin
  32618. * @returns the name of the plugin
  32619. */
  32620. getPhysicsPluginName(): string;
  32621. /**
  32622. * Adding a new impostor for the impostor tracking.
  32623. * This will be done by the impostor itself.
  32624. * @param impostor the impostor to add
  32625. */
  32626. addImpostor(impostor: PhysicsImpostor): void;
  32627. /**
  32628. * Remove an impostor from the engine.
  32629. * This impostor and its mesh will not longer be updated by the physics engine.
  32630. * @param impostor the impostor to remove
  32631. */
  32632. removeImpostor(impostor: PhysicsImpostor): void;
  32633. /**
  32634. * Add a joint to the physics engine
  32635. * @param mainImpostor defines the main impostor to which the joint is added.
  32636. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32637. * @param joint defines the joint that will connect both impostors.
  32638. */
  32639. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32640. /**
  32641. * Removes a joint from the simulation
  32642. * @param mainImpostor defines the impostor used with the joint
  32643. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32644. * @param joint defines the joint to remove
  32645. */
  32646. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32647. /**
  32648. * Gets the current plugin used to run the simulation
  32649. * @returns current plugin
  32650. */
  32651. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32652. /**
  32653. * Gets the list of physic impostors
  32654. * @returns an array of PhysicsImpostor
  32655. */
  32656. getImpostors(): Array<PhysicsImpostor>;
  32657. /**
  32658. * Gets the impostor for a physics enabled object
  32659. * @param object defines the object impersonated by the impostor
  32660. * @returns the PhysicsImpostor or null if not found
  32661. */
  32662. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32663. /**
  32664. * Gets the impostor for a physics body object
  32665. * @param body defines physics body used by the impostor
  32666. * @returns the PhysicsImpostor or null if not found
  32667. */
  32668. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32669. /**
  32670. * Does a raycast in the physics world
  32671. * @param from when should the ray start?
  32672. * @param to when should the ray end?
  32673. * @returns PhysicsRaycastResult
  32674. */
  32675. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32676. /**
  32677. * Called by the scene. No need to call it.
  32678. * @param delta defines the timespan between frames
  32679. */
  32680. _step(delta: number): void;
  32681. }
  32682. }
  32683. declare module BABYLON {
  32684. /**
  32685. * The interface for the physics imposter parameters
  32686. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32687. */
  32688. export interface PhysicsImpostorParameters {
  32689. /**
  32690. * The mass of the physics imposter
  32691. */
  32692. mass: number;
  32693. /**
  32694. * The friction of the physics imposter
  32695. */
  32696. friction?: number;
  32697. /**
  32698. * The coefficient of restitution of the physics imposter
  32699. */
  32700. restitution?: number;
  32701. /**
  32702. * The native options of the physics imposter
  32703. */
  32704. nativeOptions?: any;
  32705. /**
  32706. * Specifies if the parent should be ignored
  32707. */
  32708. ignoreParent?: boolean;
  32709. /**
  32710. * Specifies if bi-directional transformations should be disabled
  32711. */
  32712. disableBidirectionalTransformation?: boolean;
  32713. /**
  32714. * The pressure inside the physics imposter, soft object only
  32715. */
  32716. pressure?: number;
  32717. /**
  32718. * The stiffness the physics imposter, soft object only
  32719. */
  32720. stiffness?: number;
  32721. /**
  32722. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32723. */
  32724. velocityIterations?: number;
  32725. /**
  32726. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32727. */
  32728. positionIterations?: number;
  32729. /**
  32730. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32731. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32732. * Add to fix multiple points
  32733. */
  32734. fixedPoints?: number;
  32735. /**
  32736. * The collision margin around a soft object
  32737. */
  32738. margin?: number;
  32739. /**
  32740. * The collision margin around a soft object
  32741. */
  32742. damping?: number;
  32743. /**
  32744. * The path for a rope based on an extrusion
  32745. */
  32746. path?: any;
  32747. /**
  32748. * The shape of an extrusion used for a rope based on an extrusion
  32749. */
  32750. shape?: any;
  32751. }
  32752. /**
  32753. * Interface for a physics-enabled object
  32754. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32755. */
  32756. export interface IPhysicsEnabledObject {
  32757. /**
  32758. * The position of the physics-enabled object
  32759. */
  32760. position: Vector3;
  32761. /**
  32762. * The rotation of the physics-enabled object
  32763. */
  32764. rotationQuaternion: Nullable<Quaternion>;
  32765. /**
  32766. * The scale of the physics-enabled object
  32767. */
  32768. scaling: Vector3;
  32769. /**
  32770. * The rotation of the physics-enabled object
  32771. */
  32772. rotation?: Vector3;
  32773. /**
  32774. * The parent of the physics-enabled object
  32775. */
  32776. parent?: any;
  32777. /**
  32778. * The bounding info of the physics-enabled object
  32779. * @returns The bounding info of the physics-enabled object
  32780. */
  32781. getBoundingInfo(): BoundingInfo;
  32782. /**
  32783. * Computes the world matrix
  32784. * @param force Specifies if the world matrix should be computed by force
  32785. * @returns A world matrix
  32786. */
  32787. computeWorldMatrix(force: boolean): Matrix;
  32788. /**
  32789. * Gets the world matrix
  32790. * @returns A world matrix
  32791. */
  32792. getWorldMatrix?(): Matrix;
  32793. /**
  32794. * Gets the child meshes
  32795. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32796. * @returns An array of abstract meshes
  32797. */
  32798. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32799. /**
  32800. * Gets the vertex data
  32801. * @param kind The type of vertex data
  32802. * @returns A nullable array of numbers, or a float32 array
  32803. */
  32804. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32805. /**
  32806. * Gets the indices from the mesh
  32807. * @returns A nullable array of index arrays
  32808. */
  32809. getIndices?(): Nullable<IndicesArray>;
  32810. /**
  32811. * Gets the scene from the mesh
  32812. * @returns the indices array or null
  32813. */
  32814. getScene?(): Scene;
  32815. /**
  32816. * Gets the absolute position from the mesh
  32817. * @returns the absolute position
  32818. */
  32819. getAbsolutePosition(): Vector3;
  32820. /**
  32821. * Gets the absolute pivot point from the mesh
  32822. * @returns the absolute pivot point
  32823. */
  32824. getAbsolutePivotPoint(): Vector3;
  32825. /**
  32826. * Rotates the mesh
  32827. * @param axis The axis of rotation
  32828. * @param amount The amount of rotation
  32829. * @param space The space of the rotation
  32830. * @returns The rotation transform node
  32831. */
  32832. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32833. /**
  32834. * Translates the mesh
  32835. * @param axis The axis of translation
  32836. * @param distance The distance of translation
  32837. * @param space The space of the translation
  32838. * @returns The transform node
  32839. */
  32840. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32841. /**
  32842. * Sets the absolute position of the mesh
  32843. * @param absolutePosition The absolute position of the mesh
  32844. * @returns The transform node
  32845. */
  32846. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  32847. /**
  32848. * Gets the class name of the mesh
  32849. * @returns The class name
  32850. */
  32851. getClassName(): string;
  32852. }
  32853. /**
  32854. * Represents a physics imposter
  32855. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32856. */
  32857. export class PhysicsImpostor {
  32858. /**
  32859. * The physics-enabled object used as the physics imposter
  32860. */
  32861. object: IPhysicsEnabledObject;
  32862. /**
  32863. * The type of the physics imposter
  32864. */
  32865. type: number;
  32866. private _options;
  32867. private _scene?;
  32868. /**
  32869. * The default object size of the imposter
  32870. */
  32871. static DEFAULT_OBJECT_SIZE: Vector3;
  32872. /**
  32873. * The identity quaternion of the imposter
  32874. */
  32875. static IDENTITY_QUATERNION: Quaternion;
  32876. /** @hidden */
  32877. _pluginData: any;
  32878. private _physicsEngine;
  32879. private _physicsBody;
  32880. private _bodyUpdateRequired;
  32881. private _onBeforePhysicsStepCallbacks;
  32882. private _onAfterPhysicsStepCallbacks;
  32883. /** @hidden */
  32884. _onPhysicsCollideCallbacks: Array<{
  32885. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  32886. otherImpostors: Array<PhysicsImpostor>;
  32887. }>;
  32888. private _deltaPosition;
  32889. private _deltaRotation;
  32890. private _deltaRotationConjugated;
  32891. /** @hidden */
  32892. _isFromLine: boolean;
  32893. private _parent;
  32894. private _isDisposed;
  32895. private static _tmpVecs;
  32896. private static _tmpQuat;
  32897. /**
  32898. * Specifies if the physics imposter is disposed
  32899. */
  32900. get isDisposed(): boolean;
  32901. /**
  32902. * Gets the mass of the physics imposter
  32903. */
  32904. get mass(): number;
  32905. set mass(value: number);
  32906. /**
  32907. * Gets the coefficient of friction
  32908. */
  32909. get friction(): number;
  32910. /**
  32911. * Sets the coefficient of friction
  32912. */
  32913. set friction(value: number);
  32914. /**
  32915. * Gets the coefficient of restitution
  32916. */
  32917. get restitution(): number;
  32918. /**
  32919. * Sets the coefficient of restitution
  32920. */
  32921. set restitution(value: number);
  32922. /**
  32923. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  32924. */
  32925. get pressure(): number;
  32926. /**
  32927. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  32928. */
  32929. set pressure(value: number);
  32930. /**
  32931. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32932. */
  32933. get stiffness(): number;
  32934. /**
  32935. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32936. */
  32937. set stiffness(value: number);
  32938. /**
  32939. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32940. */
  32941. get velocityIterations(): number;
  32942. /**
  32943. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32944. */
  32945. set velocityIterations(value: number);
  32946. /**
  32947. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32948. */
  32949. get positionIterations(): number;
  32950. /**
  32951. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32952. */
  32953. set positionIterations(value: number);
  32954. /**
  32955. * The unique id of the physics imposter
  32956. * set by the physics engine when adding this impostor to the array
  32957. */
  32958. uniqueId: number;
  32959. /**
  32960. * @hidden
  32961. */
  32962. soft: boolean;
  32963. /**
  32964. * @hidden
  32965. */
  32966. segments: number;
  32967. private _joints;
  32968. /**
  32969. * Initializes the physics imposter
  32970. * @param object The physics-enabled object used as the physics imposter
  32971. * @param type The type of the physics imposter
  32972. * @param _options The options for the physics imposter
  32973. * @param _scene The Babylon scene
  32974. */
  32975. constructor(
  32976. /**
  32977. * The physics-enabled object used as the physics imposter
  32978. */
  32979. object: IPhysicsEnabledObject,
  32980. /**
  32981. * The type of the physics imposter
  32982. */
  32983. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  32984. /**
  32985. * This function will completely initialize this impostor.
  32986. * It will create a new body - but only if this mesh has no parent.
  32987. * If it has, this impostor will not be used other than to define the impostor
  32988. * of the child mesh.
  32989. * @hidden
  32990. */
  32991. _init(): void;
  32992. private _getPhysicsParent;
  32993. /**
  32994. * Should a new body be generated.
  32995. * @returns boolean specifying if body initialization is required
  32996. */
  32997. isBodyInitRequired(): boolean;
  32998. /**
  32999. * Sets the updated scaling
  33000. * @param updated Specifies if the scaling is updated
  33001. */
  33002. setScalingUpdated(): void;
  33003. /**
  33004. * Force a regeneration of this or the parent's impostor's body.
  33005. * Use under cautious - This will remove all joints already implemented.
  33006. */
  33007. forceUpdate(): void;
  33008. /**
  33009. * Gets the body that holds this impostor. Either its own, or its parent.
  33010. */
  33011. get physicsBody(): any;
  33012. /**
  33013. * Get the parent of the physics imposter
  33014. * @returns Physics imposter or null
  33015. */
  33016. get parent(): Nullable<PhysicsImpostor>;
  33017. /**
  33018. * Sets the parent of the physics imposter
  33019. */
  33020. set parent(value: Nullable<PhysicsImpostor>);
  33021. /**
  33022. * Set the physics body. Used mainly by the physics engine/plugin
  33023. */
  33024. set physicsBody(physicsBody: any);
  33025. /**
  33026. * Resets the update flags
  33027. */
  33028. resetUpdateFlags(): void;
  33029. /**
  33030. * Gets the object extend size
  33031. * @returns the object extend size
  33032. */
  33033. getObjectExtendSize(): Vector3;
  33034. /**
  33035. * Gets the object center
  33036. * @returns The object center
  33037. */
  33038. getObjectCenter(): Vector3;
  33039. /**
  33040. * Get a specific parameter from the options parameters
  33041. * @param paramName The object parameter name
  33042. * @returns The object parameter
  33043. */
  33044. getParam(paramName: string): any;
  33045. /**
  33046. * Sets a specific parameter in the options given to the physics plugin
  33047. * @param paramName The parameter name
  33048. * @param value The value of the parameter
  33049. */
  33050. setParam(paramName: string, value: number): void;
  33051. /**
  33052. * Specifically change the body's mass option. Won't recreate the physics body object
  33053. * @param mass The mass of the physics imposter
  33054. */
  33055. setMass(mass: number): void;
  33056. /**
  33057. * Gets the linear velocity
  33058. * @returns linear velocity or null
  33059. */
  33060. getLinearVelocity(): Nullable<Vector3>;
  33061. /**
  33062. * Sets the linear velocity
  33063. * @param velocity linear velocity or null
  33064. */
  33065. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33066. /**
  33067. * Gets the angular velocity
  33068. * @returns angular velocity or null
  33069. */
  33070. getAngularVelocity(): Nullable<Vector3>;
  33071. /**
  33072. * Sets the angular velocity
  33073. * @param velocity The velocity or null
  33074. */
  33075. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33076. /**
  33077. * Execute a function with the physics plugin native code
  33078. * Provide a function the will have two variables - the world object and the physics body object
  33079. * @param func The function to execute with the physics plugin native code
  33080. */
  33081. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33082. /**
  33083. * Register a function that will be executed before the physics world is stepping forward
  33084. * @param func The function to execute before the physics world is stepped forward
  33085. */
  33086. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33087. /**
  33088. * Unregister a function that will be executed before the physics world is stepping forward
  33089. * @param func The function to execute before the physics world is stepped forward
  33090. */
  33091. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33092. /**
  33093. * Register a function that will be executed after the physics step
  33094. * @param func The function to execute after physics step
  33095. */
  33096. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33097. /**
  33098. * Unregisters a function that will be executed after the physics step
  33099. * @param func The function to execute after physics step
  33100. */
  33101. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33102. /**
  33103. * register a function that will be executed when this impostor collides against a different body
  33104. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33105. * @param func Callback that is executed on collision
  33106. */
  33107. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33108. /**
  33109. * Unregisters the physics imposter on contact
  33110. * @param collideAgainst The physics object to collide against
  33111. * @param func Callback to execute on collision
  33112. */
  33113. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33114. private _tmpQuat;
  33115. private _tmpQuat2;
  33116. /**
  33117. * Get the parent rotation
  33118. * @returns The parent rotation
  33119. */
  33120. getParentsRotation(): Quaternion;
  33121. /**
  33122. * this function is executed by the physics engine.
  33123. */
  33124. beforeStep: () => void;
  33125. /**
  33126. * this function is executed by the physics engine
  33127. */
  33128. afterStep: () => void;
  33129. /**
  33130. * Legacy collision detection event support
  33131. */
  33132. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33133. /**
  33134. * event and body object due to cannon's event-based architecture.
  33135. */
  33136. onCollide: (e: {
  33137. body: any;
  33138. point: Nullable<Vector3>;
  33139. }) => void;
  33140. /**
  33141. * Apply a force
  33142. * @param force The force to apply
  33143. * @param contactPoint The contact point for the force
  33144. * @returns The physics imposter
  33145. */
  33146. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33147. /**
  33148. * Apply an impulse
  33149. * @param force The impulse force
  33150. * @param contactPoint The contact point for the impulse force
  33151. * @returns The physics imposter
  33152. */
  33153. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33154. /**
  33155. * A help function to create a joint
  33156. * @param otherImpostor A physics imposter used to create a joint
  33157. * @param jointType The type of joint
  33158. * @param jointData The data for the joint
  33159. * @returns The physics imposter
  33160. */
  33161. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33162. /**
  33163. * Add a joint to this impostor with a different impostor
  33164. * @param otherImpostor A physics imposter used to add a joint
  33165. * @param joint The joint to add
  33166. * @returns The physics imposter
  33167. */
  33168. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33169. /**
  33170. * Add an anchor to a cloth impostor
  33171. * @param otherImpostor rigid impostor to anchor to
  33172. * @param width ratio across width from 0 to 1
  33173. * @param height ratio up height from 0 to 1
  33174. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little stretch
  33175. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  33176. * @returns impostor the soft imposter
  33177. */
  33178. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33179. /**
  33180. * Add a hook to a rope impostor
  33181. * @param otherImpostor rigid impostor to anchor to
  33182. * @param length ratio across rope from 0 to 1
  33183. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little stretch
  33184. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  33185. * @returns impostor the rope imposter
  33186. */
  33187. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33188. /**
  33189. * Will keep this body still, in a sleep mode.
  33190. * @returns the physics imposter
  33191. */
  33192. sleep(): PhysicsImpostor;
  33193. /**
  33194. * Wake the body up.
  33195. * @returns The physics imposter
  33196. */
  33197. wakeUp(): PhysicsImpostor;
  33198. /**
  33199. * Clones the physics imposter
  33200. * @param newObject The physics imposter clones to this physics-enabled object
  33201. * @returns A nullable physics imposter
  33202. */
  33203. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33204. /**
  33205. * Disposes the physics imposter
  33206. */
  33207. dispose(): void;
  33208. /**
  33209. * Sets the delta position
  33210. * @param position The delta position amount
  33211. */
  33212. setDeltaPosition(position: Vector3): void;
  33213. /**
  33214. * Sets the delta rotation
  33215. * @param rotation The delta rotation amount
  33216. */
  33217. setDeltaRotation(rotation: Quaternion): void;
  33218. /**
  33219. * Gets the box size of the physics imposter and stores the result in the input parameter
  33220. * @param result Stores the box size
  33221. * @returns The physics imposter
  33222. */
  33223. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33224. /**
  33225. * Gets the radius of the physics imposter
  33226. * @returns Radius of the physics imposter
  33227. */
  33228. getRadius(): number;
  33229. /**
  33230. * Sync a bone with this impostor
  33231. * @param bone The bone to sync to the impostor.
  33232. * @param boneMesh The mesh that the bone is influencing.
  33233. * @param jointPivot The pivot of the joint / bone in local space.
  33234. * @param distToJoint Optional distance from the impostor to the joint.
  33235. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33236. */
  33237. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33238. /**
  33239. * Sync impostor to a bone
  33240. * @param bone The bone that the impostor will be synced to.
  33241. * @param boneMesh The mesh that the bone is influencing.
  33242. * @param jointPivot The pivot of the joint / bone in local space.
  33243. * @param distToJoint Optional distance from the impostor to the joint.
  33244. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33245. * @param boneAxis Optional vector3 axis the bone is aligned with
  33246. */
  33247. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33248. /**
  33249. * No-Imposter type
  33250. */
  33251. static NoImpostor: number;
  33252. /**
  33253. * Sphere-Imposter type
  33254. */
  33255. static SphereImpostor: number;
  33256. /**
  33257. * Box-Imposter type
  33258. */
  33259. static BoxImpostor: number;
  33260. /**
  33261. * Plane-Imposter type
  33262. */
  33263. static PlaneImpostor: number;
  33264. /**
  33265. * Mesh-imposter type
  33266. */
  33267. static MeshImpostor: number;
  33268. /**
  33269. * Capsule-Impostor type (Ammo.js plugin only)
  33270. */
  33271. static CapsuleImpostor: number;
  33272. /**
  33273. * Cylinder-Imposter type
  33274. */
  33275. static CylinderImpostor: number;
  33276. /**
  33277. * Particle-Imposter type
  33278. */
  33279. static ParticleImpostor: number;
  33280. /**
  33281. * Heightmap-Imposter type
  33282. */
  33283. static HeightmapImpostor: number;
  33284. /**
  33285. * ConvexHull-Impostor type (Ammo.js plugin only)
  33286. */
  33287. static ConvexHullImpostor: number;
  33288. /**
  33289. * Custom-Imposter type (Ammo.js plugin only)
  33290. */
  33291. static CustomImpostor: number;
  33292. /**
  33293. * Rope-Imposter type
  33294. */
  33295. static RopeImpostor: number;
  33296. /**
  33297. * Cloth-Imposter type
  33298. */
  33299. static ClothImpostor: number;
  33300. /**
  33301. * Softbody-Imposter type
  33302. */
  33303. static SoftbodyImpostor: number;
  33304. }
  33305. }
  33306. declare module BABYLON {
  33307. /**
  33308. * @hidden
  33309. **/
  33310. export class _CreationDataStorage {
  33311. closePath?: boolean;
  33312. closeArray?: boolean;
  33313. idx: number[];
  33314. dashSize: number;
  33315. gapSize: number;
  33316. path3D: Path3D;
  33317. pathArray: Vector3[][];
  33318. arc: number;
  33319. radius: number;
  33320. cap: number;
  33321. tessellation: number;
  33322. }
  33323. /**
  33324. * @hidden
  33325. **/
  33326. class _InstanceDataStorage {
  33327. visibleInstances: any;
  33328. batchCache: _InstancesBatch;
  33329. instancesBufferSize: number;
  33330. instancesBuffer: Nullable<Buffer>;
  33331. instancesData: Float32Array;
  33332. overridenInstanceCount: number;
  33333. isFrozen: boolean;
  33334. previousBatch: Nullable<_InstancesBatch>;
  33335. hardwareInstancedRendering: boolean;
  33336. sideOrientation: number;
  33337. manualUpdate: boolean;
  33338. previousRenderId: number;
  33339. }
  33340. /**
  33341. * @hidden
  33342. **/
  33343. export class _InstancesBatch {
  33344. mustReturn: boolean;
  33345. visibleInstances: Nullable<InstancedMesh[]>[];
  33346. renderSelf: boolean[];
  33347. hardwareInstancedRendering: boolean[];
  33348. }
  33349. /**
  33350. * @hidden
  33351. **/
  33352. class _ThinInstanceDataStorage {
  33353. instancesCount: number;
  33354. matrixBuffer: Nullable<Buffer>;
  33355. matrixBufferSize: number;
  33356. matrixData: Nullable<Float32Array>;
  33357. boundingVectors: Array<Vector3>;
  33358. worldMatrices: Nullable<Matrix[]>;
  33359. }
  33360. /**
  33361. * Class used to represent renderable models
  33362. */
  33363. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  33364. /**
  33365. * Mesh side orientation : usually the external or front surface
  33366. */
  33367. static readonly FRONTSIDE: number;
  33368. /**
  33369. * Mesh side orientation : usually the internal or back surface
  33370. */
  33371. static readonly BACKSIDE: number;
  33372. /**
  33373. * Mesh side orientation : both internal and external or front and back surfaces
  33374. */
  33375. static readonly DOUBLESIDE: number;
  33376. /**
  33377. * Mesh side orientation : by default, `FRONTSIDE`
  33378. */
  33379. static readonly DEFAULTSIDE: number;
  33380. /**
  33381. * Mesh cap setting : no cap
  33382. */
  33383. static readonly NO_CAP: number;
  33384. /**
  33385. * Mesh cap setting : one cap at the beginning of the mesh
  33386. */
  33387. static readonly CAP_START: number;
  33388. /**
  33389. * Mesh cap setting : one cap at the end of the mesh
  33390. */
  33391. static readonly CAP_END: number;
  33392. /**
  33393. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33394. */
  33395. static readonly CAP_ALL: number;
  33396. /**
  33397. * Mesh pattern setting : no flip or rotate
  33398. */
  33399. static readonly NO_FLIP: number;
  33400. /**
  33401. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33402. */
  33403. static readonly FLIP_TILE: number;
  33404. /**
  33405. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33406. */
  33407. static readonly ROTATE_TILE: number;
  33408. /**
  33409. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33410. */
  33411. static readonly FLIP_ROW: number;
  33412. /**
  33413. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33414. */
  33415. static readonly ROTATE_ROW: number;
  33416. /**
  33417. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33418. */
  33419. static readonly FLIP_N_ROTATE_TILE: number;
  33420. /**
  33421. * Mesh pattern setting : rotate pattern and rotate
  33422. */
  33423. static readonly FLIP_N_ROTATE_ROW: number;
  33424. /**
  33425. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33426. */
  33427. static readonly CENTER: number;
  33428. /**
  33429. * Mesh tile positioning : part tiles on left
  33430. */
  33431. static readonly LEFT: number;
  33432. /**
  33433. * Mesh tile positioning : part tiles on right
  33434. */
  33435. static readonly RIGHT: number;
  33436. /**
  33437. * Mesh tile positioning : part tiles on top
  33438. */
  33439. static readonly TOP: number;
  33440. /**
  33441. * Mesh tile positioning : part tiles on bottom
  33442. */
  33443. static readonly BOTTOM: number;
  33444. /**
  33445. * Gets the default side orientation.
  33446. * @param orientation the orientation to value to attempt to get
  33447. * @returns the default orientation
  33448. * @hidden
  33449. */
  33450. static _GetDefaultSideOrientation(orientation?: number): number;
  33451. private _internalMeshDataInfo;
  33452. get computeBonesUsingShaders(): boolean;
  33453. set computeBonesUsingShaders(value: boolean);
  33454. /**
  33455. * An event triggered before rendering the mesh
  33456. */
  33457. get onBeforeRenderObservable(): Observable<Mesh>;
  33458. /**
  33459. * An event triggered before binding the mesh
  33460. */
  33461. get onBeforeBindObservable(): Observable<Mesh>;
  33462. /**
  33463. * An event triggered after rendering the mesh
  33464. */
  33465. get onAfterRenderObservable(): Observable<Mesh>;
  33466. /**
  33467. * An event triggered before drawing the mesh
  33468. */
  33469. get onBeforeDrawObservable(): Observable<Mesh>;
  33470. private _onBeforeDrawObserver;
  33471. /**
  33472. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33473. */
  33474. set onBeforeDraw(callback: () => void);
  33475. get hasInstances(): boolean;
  33476. get hasThinInstances(): boolean;
  33477. /**
  33478. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33479. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33480. */
  33481. delayLoadState: number;
  33482. /**
  33483. * Gets the list of instances created from this mesh
  33484. * it is not supposed to be modified manually.
  33485. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33486. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33487. */
  33488. instances: InstancedMesh[];
  33489. /**
  33490. * Gets the file containing delay loading data for this mesh
  33491. */
  33492. delayLoadingFile: string;
  33493. /** @hidden */
  33494. _binaryInfo: any;
  33495. /**
  33496. * User defined function used to change how LOD level selection is done
  33497. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33498. */
  33499. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33500. /**
  33501. * Gets or sets the morph target manager
  33502. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33503. */
  33504. get morphTargetManager(): Nullable<MorphTargetManager>;
  33505. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33506. /** @hidden */
  33507. _creationDataStorage: Nullable<_CreationDataStorage>;
  33508. /** @hidden */
  33509. _geometry: Nullable<Geometry>;
  33510. /** @hidden */
  33511. _delayInfo: Array<string>;
  33512. /** @hidden */
  33513. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33514. /** @hidden */
  33515. _instanceDataStorage: _InstanceDataStorage;
  33516. /** @hidden */
  33517. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33518. private _effectiveMaterial;
  33519. /** @hidden */
  33520. _shouldGenerateFlatShading: boolean;
  33521. /** @hidden */
  33522. _originalBuilderSideOrientation: number;
  33523. /**
  33524. * Use this property to change the original side orientation defined at construction time
  33525. */
  33526. overrideMaterialSideOrientation: Nullable<number>;
  33527. /**
  33528. * Gets or sets a boolean indicating whether to render ignoring the active camera's max z setting. (false by default)
  33529. * Note this will reduce performance when set to true.
  33530. */
  33531. ignoreCameraMaxZ: boolean;
  33532. /**
  33533. * Gets the source mesh (the one used to clone this one from)
  33534. */
  33535. get source(): Nullable<Mesh>;
  33536. /**
  33537. * Gets the list of clones of this mesh
  33538. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33539. * Note that useClonedMeshMap=true is the default setting
  33540. */
  33541. get cloneMeshMap(): Nullable<{
  33542. [id: string]: Mesh | undefined;
  33543. }>;
  33544. /**
  33545. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33546. */
  33547. get isUnIndexed(): boolean;
  33548. set isUnIndexed(value: boolean);
  33549. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33550. get worldMatrixInstancedBuffer(): Float32Array;
  33551. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33552. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33553. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33554. /**
  33555. * @constructor
  33556. * @param name The value used by scene.getMeshByName() to do a lookup.
  33557. * @param scene The scene to add this mesh to.
  33558. * @param parent The parent of this mesh, if it has one
  33559. * @param source An optional Mesh from which geometry is shared, cloned.
  33560. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33561. * When false, achieved by calling a clone(), also passing False.
  33562. * This will make creation of children, recursive.
  33563. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33564. */
  33565. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33566. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33567. doNotInstantiate: boolean;
  33568. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33569. /**
  33570. * Gets the class name
  33571. * @returns the string "Mesh".
  33572. */
  33573. getClassName(): string;
  33574. /** @hidden */
  33575. get _isMesh(): boolean;
  33576. /**
  33577. * Returns a description of this mesh
  33578. * @param fullDetails define if full details about this mesh must be used
  33579. * @returns a descriptive string representing this mesh
  33580. */
  33581. toString(fullDetails?: boolean): string;
  33582. /** @hidden */
  33583. _unBindEffect(): void;
  33584. /**
  33585. * Gets a boolean indicating if this mesh has LOD
  33586. */
  33587. get hasLODLevels(): boolean;
  33588. /**
  33589. * Gets the list of MeshLODLevel associated with the current mesh
  33590. * @returns an array of MeshLODLevel
  33591. */
  33592. getLODLevels(): MeshLODLevel[];
  33593. private _sortLODLevels;
  33594. /**
  33595. * Add a mesh as LOD level triggered at the given distance.
  33596. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33597. * @param distance The distance from the center of the object to show this level
  33598. * @param mesh The mesh to be added as LOD level (can be null)
  33599. * @return This mesh (for chaining)
  33600. */
  33601. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33602. /**
  33603. * Returns the LOD level mesh at the passed distance or null if not found.
  33604. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33605. * @param distance The distance from the center of the object to show this level
  33606. * @returns a Mesh or `null`
  33607. */
  33608. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33609. /**
  33610. * Remove a mesh from the LOD array
  33611. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33612. * @param mesh defines the mesh to be removed
  33613. * @return This mesh (for chaining)
  33614. */
  33615. removeLODLevel(mesh: Mesh): Mesh;
  33616. /**
  33617. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33618. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33619. * @param camera defines the camera to use to compute distance
  33620. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33621. * @return This mesh (for chaining)
  33622. */
  33623. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33624. /**
  33625. * Gets the mesh internal Geometry object
  33626. */
  33627. get geometry(): Nullable<Geometry>;
  33628. /**
  33629. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33630. * @returns the total number of vertices
  33631. */
  33632. getTotalVertices(): number;
  33633. /**
  33634. * Returns the content of an associated vertex buffer
  33635. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33636. * - VertexBuffer.PositionKind
  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. * @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
  33649. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33650. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33651. */
  33652. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33653. /**
  33654. * Returns the mesh VertexBuffer object from the requested `kind`
  33655. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33656. * - VertexBuffer.PositionKind
  33657. * - VertexBuffer.NormalKind
  33658. * - VertexBuffer.UVKind
  33659. * - VertexBuffer.UV2Kind
  33660. * - VertexBuffer.UV3Kind
  33661. * - VertexBuffer.UV4Kind
  33662. * - VertexBuffer.UV5Kind
  33663. * - VertexBuffer.UV6Kind
  33664. * - VertexBuffer.ColorKind
  33665. * - VertexBuffer.MatricesIndicesKind
  33666. * - VertexBuffer.MatricesIndicesExtraKind
  33667. * - VertexBuffer.MatricesWeightsKind
  33668. * - VertexBuffer.MatricesWeightsExtraKind
  33669. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33670. */
  33671. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33672. /**
  33673. * Tests if a specific vertex buffer is associated with this mesh
  33674. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33675. * - VertexBuffer.PositionKind
  33676. * - VertexBuffer.NormalKind
  33677. * - VertexBuffer.UVKind
  33678. * - VertexBuffer.UV2Kind
  33679. * - VertexBuffer.UV3Kind
  33680. * - VertexBuffer.UV4Kind
  33681. * - VertexBuffer.UV5Kind
  33682. * - VertexBuffer.UV6Kind
  33683. * - VertexBuffer.ColorKind
  33684. * - VertexBuffer.MatricesIndicesKind
  33685. * - VertexBuffer.MatricesIndicesExtraKind
  33686. * - VertexBuffer.MatricesWeightsKind
  33687. * - VertexBuffer.MatricesWeightsExtraKind
  33688. * @returns a boolean
  33689. */
  33690. isVerticesDataPresent(kind: string): boolean;
  33691. /**
  33692. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33693. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33694. * - VertexBuffer.PositionKind
  33695. * - VertexBuffer.UVKind
  33696. * - VertexBuffer.UV2Kind
  33697. * - VertexBuffer.UV3Kind
  33698. * - VertexBuffer.UV4Kind
  33699. * - VertexBuffer.UV5Kind
  33700. * - VertexBuffer.UV6Kind
  33701. * - VertexBuffer.ColorKind
  33702. * - VertexBuffer.MatricesIndicesKind
  33703. * - VertexBuffer.MatricesIndicesExtraKind
  33704. * - VertexBuffer.MatricesWeightsKind
  33705. * - VertexBuffer.MatricesWeightsExtraKind
  33706. * @returns a boolean
  33707. */
  33708. isVertexBufferUpdatable(kind: string): boolean;
  33709. /**
  33710. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33711. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33712. * - VertexBuffer.PositionKind
  33713. * - VertexBuffer.NormalKind
  33714. * - VertexBuffer.UVKind
  33715. * - VertexBuffer.UV2Kind
  33716. * - VertexBuffer.UV3Kind
  33717. * - VertexBuffer.UV4Kind
  33718. * - VertexBuffer.UV5Kind
  33719. * - VertexBuffer.UV6Kind
  33720. * - VertexBuffer.ColorKind
  33721. * - VertexBuffer.MatricesIndicesKind
  33722. * - VertexBuffer.MatricesIndicesExtraKind
  33723. * - VertexBuffer.MatricesWeightsKind
  33724. * - VertexBuffer.MatricesWeightsExtraKind
  33725. * @returns an array of strings
  33726. */
  33727. getVerticesDataKinds(): string[];
  33728. /**
  33729. * Returns a positive integer : the total number of indices in this mesh geometry.
  33730. * @returns the numner of indices or zero if the mesh has no geometry.
  33731. */
  33732. getTotalIndices(): number;
  33733. /**
  33734. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33735. * @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.
  33736. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33737. * @returns the indices array or an empty array if the mesh has no geometry
  33738. */
  33739. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33740. get isBlocked(): boolean;
  33741. /**
  33742. * Determine if the current mesh is ready to be rendered
  33743. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33744. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  33745. * @returns true if all associated assets are ready (material, textures, shaders)
  33746. */
  33747. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  33748. /**
  33749. * 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.
  33750. */
  33751. get areNormalsFrozen(): boolean;
  33752. /**
  33753. * 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.
  33754. * @returns the current mesh
  33755. */
  33756. freezeNormals(): Mesh;
  33757. /**
  33758. * 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
  33759. * @returns the current mesh
  33760. */
  33761. unfreezeNormals(): Mesh;
  33762. /**
  33763. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  33764. */
  33765. set overridenInstanceCount(count: number);
  33766. /** @hidden */
  33767. _preActivate(): Mesh;
  33768. /** @hidden */
  33769. _preActivateForIntermediateRendering(renderId: number): Mesh;
  33770. /** @hidden */
  33771. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  33772. protected _afterComputeWorldMatrix(): void;
  33773. /** @hidden */
  33774. _postActivate(): void;
  33775. /**
  33776. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33777. * This means the mesh underlying bounding box and sphere are recomputed.
  33778. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33779. * @returns the current mesh
  33780. */
  33781. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  33782. /** @hidden */
  33783. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  33784. /**
  33785. * This function will subdivide the mesh into multiple submeshes
  33786. * @param count defines the expected number of submeshes
  33787. */
  33788. subdivide(count: number): void;
  33789. /**
  33790. * Copy a FloatArray into a specific associated vertex buffer
  33791. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33792. * - VertexBuffer.PositionKind
  33793. * - VertexBuffer.UVKind
  33794. * - VertexBuffer.UV2Kind
  33795. * - VertexBuffer.UV3Kind
  33796. * - VertexBuffer.UV4Kind
  33797. * - VertexBuffer.UV5Kind
  33798. * - VertexBuffer.UV6Kind
  33799. * - VertexBuffer.ColorKind
  33800. * - VertexBuffer.MatricesIndicesKind
  33801. * - VertexBuffer.MatricesIndicesExtraKind
  33802. * - VertexBuffer.MatricesWeightsKind
  33803. * - VertexBuffer.MatricesWeightsExtraKind
  33804. * @param data defines the data source
  33805. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33806. * @param stride defines the data stride size (can be null)
  33807. * @returns the current mesh
  33808. */
  33809. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33810. /**
  33811. * Delete a vertex buffer associated with this mesh
  33812. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  33813. * - VertexBuffer.PositionKind
  33814. * - VertexBuffer.UVKind
  33815. * - VertexBuffer.UV2Kind
  33816. * - VertexBuffer.UV3Kind
  33817. * - VertexBuffer.UV4Kind
  33818. * - VertexBuffer.UV5Kind
  33819. * - VertexBuffer.UV6Kind
  33820. * - VertexBuffer.ColorKind
  33821. * - VertexBuffer.MatricesIndicesKind
  33822. * - VertexBuffer.MatricesIndicesExtraKind
  33823. * - VertexBuffer.MatricesWeightsKind
  33824. * - VertexBuffer.MatricesWeightsExtraKind
  33825. */
  33826. removeVerticesData(kind: string): void;
  33827. /**
  33828. * Flags an associated vertex buffer as updatable
  33829. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  33830. * - VertexBuffer.PositionKind
  33831. * - VertexBuffer.UVKind
  33832. * - VertexBuffer.UV2Kind
  33833. * - VertexBuffer.UV3Kind
  33834. * - VertexBuffer.UV4Kind
  33835. * - VertexBuffer.UV5Kind
  33836. * - VertexBuffer.UV6Kind
  33837. * - VertexBuffer.ColorKind
  33838. * - VertexBuffer.MatricesIndicesKind
  33839. * - VertexBuffer.MatricesIndicesExtraKind
  33840. * - VertexBuffer.MatricesWeightsKind
  33841. * - VertexBuffer.MatricesWeightsExtraKind
  33842. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33843. */
  33844. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  33845. /**
  33846. * Sets the mesh global Vertex Buffer
  33847. * @param buffer defines the buffer to use
  33848. * @returns the current mesh
  33849. */
  33850. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  33851. /**
  33852. * Update a specific associated vertex buffer
  33853. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33854. * - VertexBuffer.PositionKind
  33855. * - VertexBuffer.UVKind
  33856. * - VertexBuffer.UV2Kind
  33857. * - VertexBuffer.UV3Kind
  33858. * - VertexBuffer.UV4Kind
  33859. * - VertexBuffer.UV5Kind
  33860. * - VertexBuffer.UV6Kind
  33861. * - VertexBuffer.ColorKind
  33862. * - VertexBuffer.MatricesIndicesKind
  33863. * - VertexBuffer.MatricesIndicesExtraKind
  33864. * - VertexBuffer.MatricesWeightsKind
  33865. * - VertexBuffer.MatricesWeightsExtraKind
  33866. * @param data defines the data source
  33867. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33868. * @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)
  33869. * @returns the current mesh
  33870. */
  33871. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33872. /**
  33873. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  33874. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  33875. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  33876. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  33877. * @returns the current mesh
  33878. */
  33879. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  33880. /**
  33881. * Creates a un-shared specific occurence of the geometry for the mesh.
  33882. * @returns the current mesh
  33883. */
  33884. makeGeometryUnique(): Mesh;
  33885. /**
  33886. * Set the index buffer of this mesh
  33887. * @param indices defines the source data
  33888. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  33889. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  33890. * @returns the current mesh
  33891. */
  33892. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  33893. /**
  33894. * Update the current index buffer
  33895. * @param indices defines the source data
  33896. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33897. * @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)
  33898. * @returns the current mesh
  33899. */
  33900. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33901. /**
  33902. * Invert the geometry to move from a right handed system to a left handed one.
  33903. * @returns the current mesh
  33904. */
  33905. toLeftHanded(): Mesh;
  33906. /** @hidden */
  33907. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  33908. /** @hidden */
  33909. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  33910. /**
  33911. * Registers for this mesh a javascript function called just before the rendering process
  33912. * @param func defines the function to call before rendering this mesh
  33913. * @returns the current mesh
  33914. */
  33915. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33916. /**
  33917. * Disposes a previously registered javascript function called before the rendering
  33918. * @param func defines the function to remove
  33919. * @returns the current mesh
  33920. */
  33921. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33922. /**
  33923. * Registers for this mesh a javascript function called just after the rendering is complete
  33924. * @param func defines the function to call after rendering this mesh
  33925. * @returns the current mesh
  33926. */
  33927. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33928. /**
  33929. * Disposes a previously registered javascript function called after the rendering.
  33930. * @param func defines the function to remove
  33931. * @returns the current mesh
  33932. */
  33933. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33934. /** @hidden */
  33935. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  33936. /** @hidden */
  33937. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  33938. /** @hidden */
  33939. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  33940. /** @hidden */
  33941. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  33942. /** @hidden */
  33943. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  33944. /** @hidden */
  33945. _rebuild(): void;
  33946. /** @hidden */
  33947. _freeze(): void;
  33948. /** @hidden */
  33949. _unFreeze(): void;
  33950. /**
  33951. * 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
  33952. * @param subMesh defines the subMesh to render
  33953. * @param enableAlphaMode defines if alpha mode can be changed
  33954. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  33955. * @returns the current mesh
  33956. */
  33957. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  33958. private _onBeforeDraw;
  33959. /**
  33960. * Renormalize the mesh and patch it up if there are no weights
  33961. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  33962. * However in the case of zero weights then we set just a single influence to 1.
  33963. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  33964. */
  33965. cleanMatrixWeights(): void;
  33966. private normalizeSkinFourWeights;
  33967. private normalizeSkinWeightsAndExtra;
  33968. /**
  33969. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  33970. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  33971. * the user know there was an issue with importing the mesh
  33972. * @returns a validation object with skinned, valid and report string
  33973. */
  33974. validateSkinning(): {
  33975. skinned: boolean;
  33976. valid: boolean;
  33977. report: string;
  33978. };
  33979. /** @hidden */
  33980. _checkDelayState(): Mesh;
  33981. private _queueLoad;
  33982. /**
  33983. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33984. * A mesh is in the frustum if its bounding box intersects the frustum
  33985. * @param frustumPlanes defines the frustum to test
  33986. * @returns true if the mesh is in the frustum planes
  33987. */
  33988. isInFrustum(frustumPlanes: Plane[]): boolean;
  33989. /**
  33990. * Sets the mesh material by the material or multiMaterial `id` property
  33991. * @param id is a string identifying the material or the multiMaterial
  33992. * @returns the current mesh
  33993. */
  33994. setMaterialByID(id: string): Mesh;
  33995. /**
  33996. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  33997. * @returns an array of IAnimatable
  33998. */
  33999. getAnimatables(): IAnimatable[];
  34000. /**
  34001. * Modifies the mesh geometry according to the passed transformation matrix.
  34002. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  34003. * The mesh normals are modified using the same transformation.
  34004. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34005. * @param transform defines the transform matrix to use
  34006. * @see https://doc.babylonjs.com/resources/baking_transformations
  34007. * @returns the current mesh
  34008. */
  34009. bakeTransformIntoVertices(transform: Matrix): Mesh;
  34010. /**
  34011. * Modifies the mesh geometry according to its own current World Matrix.
  34012. * The mesh World Matrix is then reset.
  34013. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  34014. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34015. * @see https://doc.babylonjs.com/resources/baking_transformations
  34016. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  34017. * @returns the current mesh
  34018. */
  34019. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  34020. /** @hidden */
  34021. get _positions(): Nullable<Vector3[]>;
  34022. /** @hidden */
  34023. _resetPointsArrayCache(): Mesh;
  34024. /** @hidden */
  34025. _generatePointsArray(): boolean;
  34026. /**
  34027. * Returns a new Mesh object generated from the current mesh properties.
  34028. * This method must not get confused with createInstance()
  34029. * @param name is a string, the name given to the new mesh
  34030. * @param newParent can be any Node object (default `null`)
  34031. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  34032. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  34033. * @returns a new mesh
  34034. */
  34035. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  34036. /**
  34037. * Releases resources associated with this mesh.
  34038. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34039. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34040. */
  34041. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34042. /** @hidden */
  34043. _disposeInstanceSpecificData(): void;
  34044. /** @hidden */
  34045. _disposeThinInstanceSpecificData(): void;
  34046. /**
  34047. * Modifies the mesh geometry according to a displacement map.
  34048. * 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.
  34049. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34050. * @param url is a string, the URL from the image file is to be downloaded.
  34051. * @param minHeight is the lower limit of the displacement.
  34052. * @param maxHeight is the upper limit of the displacement.
  34053. * @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.
  34054. * @param uvOffset is an optional vector2 used to offset UV.
  34055. * @param uvScale is an optional vector2 used to scale UV.
  34056. * @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.
  34057. * @returns the Mesh.
  34058. */
  34059. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34060. /**
  34061. * Modifies the mesh geometry according to a displacementMap buffer.
  34062. * 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.
  34063. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34064. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  34065. * @param heightMapWidth is the width of the buffer image.
  34066. * @param heightMapHeight is the height of the buffer image.
  34067. * @param minHeight is the lower limit of the displacement.
  34068. * @param maxHeight is the upper limit of the displacement.
  34069. * @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.
  34070. * @param uvOffset is an optional vector2 used to offset UV.
  34071. * @param uvScale is an optional vector2 used to scale UV.
  34072. * @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.
  34073. * @returns the Mesh.
  34074. */
  34075. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34076. /**
  34077. * Modify the mesh to get a flat shading rendering.
  34078. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  34079. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  34080. * @returns current mesh
  34081. */
  34082. convertToFlatShadedMesh(): Mesh;
  34083. /**
  34084. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  34085. * In other words, more vertices, no more indices and a single bigger VBO.
  34086. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  34087. * @returns current mesh
  34088. */
  34089. convertToUnIndexedMesh(): Mesh;
  34090. /**
  34091. * Inverses facet orientations.
  34092. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34093. * @param flipNormals will also inverts the normals
  34094. * @returns current mesh
  34095. */
  34096. flipFaces(flipNormals?: boolean): Mesh;
  34097. /**
  34098. * Increase the number of facets and hence vertices in a mesh
  34099. * Vertex normals are interpolated from existing vertex normals
  34100. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34101. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  34102. */
  34103. increaseVertices(numberPerEdge: number): void;
  34104. /**
  34105. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  34106. * This will undo any application of covertToFlatShadedMesh
  34107. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34108. */
  34109. forceSharedVertices(): void;
  34110. /** @hidden */
  34111. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  34112. /** @hidden */
  34113. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  34114. /**
  34115. * Creates a new InstancedMesh object from the mesh model.
  34116. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34117. * @param name defines the name of the new instance
  34118. * @returns a new InstancedMesh
  34119. */
  34120. createInstance(name: string): InstancedMesh;
  34121. /**
  34122. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  34123. * After this call, all the mesh instances have the same submeshes than the current mesh.
  34124. * @returns the current mesh
  34125. */
  34126. synchronizeInstances(): Mesh;
  34127. /**
  34128. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  34129. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  34130. * This should be used together with the simplification to avoid disappearing triangles.
  34131. * @param successCallback an optional success callback to be called after the optimization finished.
  34132. * @returns the current mesh
  34133. */
  34134. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  34135. /**
  34136. * Serialize current mesh
  34137. * @param serializationObject defines the object which will receive the serialization data
  34138. */
  34139. serialize(serializationObject: any): void;
  34140. /** @hidden */
  34141. _syncGeometryWithMorphTargetManager(): void;
  34142. /** @hidden */
  34143. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  34144. /**
  34145. * Returns a new Mesh object parsed from the source provided.
  34146. * @param parsedMesh is the source
  34147. * @param scene defines the hosting scene
  34148. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  34149. * @returns a new Mesh
  34150. */
  34151. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  34152. /**
  34153. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  34154. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34155. * @param name defines the name of the mesh to create
  34156. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  34157. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  34158. * @param closePath creates a seam between the first and the last points of each path of the path array
  34159. * @param offset is taken in account only if the `pathArray` is containing a single path
  34160. * @param scene defines the hosting scene
  34161. * @param updatable defines if the mesh must be flagged as updatable
  34162. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34163. * @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)
  34164. * @returns a new Mesh
  34165. */
  34166. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34167. /**
  34168. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  34169. * @param name defines the name of the mesh to create
  34170. * @param radius sets the radius size (float) of the polygon (default 0.5)
  34171. * @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
  34172. * @param scene defines the hosting scene
  34173. * @param updatable defines if the mesh must be flagged as updatable
  34174. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34175. * @returns a new Mesh
  34176. */
  34177. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34178. /**
  34179. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  34180. * @param name defines the name of the mesh to create
  34181. * @param size sets the size (float) of each box side (default 1)
  34182. * @param scene defines the hosting scene
  34183. * @param updatable defines if the mesh must be flagged as updatable
  34184. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34185. * @returns a new Mesh
  34186. */
  34187. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34188. /**
  34189. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  34190. * @param name defines the name of the mesh to create
  34191. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34192. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34193. * @param scene defines the hosting scene
  34194. * @param updatable defines if the mesh must be flagged as updatable
  34195. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34196. * @returns a new Mesh
  34197. */
  34198. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34199. /**
  34200. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  34201. * @param name defines the name of the mesh to create
  34202. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34203. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34204. * @param scene defines the hosting scene
  34205. * @returns a new Mesh
  34206. */
  34207. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  34208. /**
  34209. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  34210. * @param name defines the name of the mesh to create
  34211. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  34212. * @param diameterTop set the top cap diameter (floats, default 1)
  34213. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  34214. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  34215. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  34216. * @param scene defines the hosting scene
  34217. * @param updatable defines if the mesh must be flagged as updatable
  34218. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34219. * @returns a new Mesh
  34220. */
  34221. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  34222. /**
  34223. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  34224. * @param name defines the name of the mesh to create
  34225. * @param diameter sets the diameter size (float) of the torus (default 1)
  34226. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  34227. * @param tessellation sets the number of torus sides (positive integer, default 16)
  34228. * @param scene defines the hosting scene
  34229. * @param updatable defines if the mesh must be flagged as updatable
  34230. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34231. * @returns a new Mesh
  34232. */
  34233. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34234. /**
  34235. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  34236. * @param name defines the name of the mesh to create
  34237. * @param radius sets the global radius size (float) of the torus knot (default 2)
  34238. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  34239. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  34240. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  34241. * @param p the number of windings on X axis (positive integers, default 2)
  34242. * @param q the number of windings on Y axis (positive integers, default 3)
  34243. * @param scene defines the hosting scene
  34244. * @param updatable defines if the mesh must be flagged as updatable
  34245. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34246. * @returns a new Mesh
  34247. */
  34248. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34249. /**
  34250. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  34251. * @param name defines the name of the mesh to create
  34252. * @param points is an array successive Vector3
  34253. * @param scene defines the hosting scene
  34254. * @param updatable defines if the mesh must be flagged as updatable
  34255. * @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).
  34256. * @returns a new Mesh
  34257. */
  34258. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  34259. /**
  34260. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  34261. * @param name defines the name of the mesh to create
  34262. * @param points is an array successive Vector3
  34263. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  34264. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  34265. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  34266. * @param scene defines the hosting scene
  34267. * @param updatable defines if the mesh must be flagged as updatable
  34268. * @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)
  34269. * @returns a new Mesh
  34270. */
  34271. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  34272. /**
  34273. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  34274. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  34275. * 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.
  34276. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34277. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  34278. * Remember you can only change the shape positions, not their number when updating a polygon.
  34279. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  34280. * @param name defines the name of the mesh to create
  34281. * @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
  34282. * @param scene defines the hosting scene
  34283. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34284. * @param updatable defines if the mesh must be flagged as updatable
  34285. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34286. * @param earcutInjection can be used to inject your own earcut reference
  34287. * @returns a new Mesh
  34288. */
  34289. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34290. /**
  34291. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  34292. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  34293. * @param name defines the name of the mesh to create
  34294. * @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
  34295. * @param depth defines the height of extrusion
  34296. * @param scene defines the hosting scene
  34297. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34298. * @param updatable defines if the mesh must be flagged as updatable
  34299. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34300. * @param earcutInjection can be used to inject your own earcut reference
  34301. * @returns a new Mesh
  34302. */
  34303. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34304. /**
  34305. * Creates an extruded shape mesh.
  34306. * 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
  34307. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34308. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34309. * @param name defines the name of the mesh to create
  34310. * @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
  34311. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34312. * @param scale is the value to scale the shape
  34313. * @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
  34314. * @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
  34315. * @param scene defines the hosting scene
  34316. * @param updatable defines if the mesh must be flagged as updatable
  34317. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34318. * @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)
  34319. * @returns a new Mesh
  34320. */
  34321. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34322. /**
  34323. * Creates an custom extruded shape mesh.
  34324. * The custom extrusion is a parametric shape.
  34325. * It has no predefined shape. Its final shape will depend on the input parameters.
  34326. * Please consider using the same method from the MeshBuilder class instead
  34327. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34328. * @param name defines the name of the mesh to create
  34329. * @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
  34330. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34331. * @param scaleFunction is a custom Javascript function called on each path point
  34332. * @param rotationFunction is a custom Javascript function called on each path point
  34333. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34334. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34335. * @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
  34336. * @param scene defines the hosting scene
  34337. * @param updatable defines if the mesh must be flagged as updatable
  34338. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34339. * @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)
  34340. * @returns a new Mesh
  34341. */
  34342. 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;
  34343. /**
  34344. * Creates lathe mesh.
  34345. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34346. * Please consider using the same method from the MeshBuilder class instead
  34347. * @param name defines the name of the mesh to create
  34348. * @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
  34349. * @param radius is the radius value of the lathe
  34350. * @param tessellation is the side number of the lathe.
  34351. * @param scene defines the hosting scene
  34352. * @param updatable defines if the mesh must be flagged as updatable
  34353. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34354. * @returns a new Mesh
  34355. */
  34356. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34357. /**
  34358. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  34359. * @param name defines the name of the mesh to create
  34360. * @param size sets the size (float) of both sides of the plane at once (default 1)
  34361. * @param scene defines the hosting scene
  34362. * @param updatable defines if the mesh must be flagged as updatable
  34363. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34364. * @returns a new Mesh
  34365. */
  34366. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34367. /**
  34368. * Creates a ground mesh.
  34369. * Please consider using the same method from the MeshBuilder class instead
  34370. * @param name defines the name of the mesh to create
  34371. * @param width set the width of the ground
  34372. * @param height set the height of the ground
  34373. * @param subdivisions sets the number of subdivisions per side
  34374. * @param scene defines the hosting scene
  34375. * @param updatable defines if the mesh must be flagged as updatable
  34376. * @returns a new Mesh
  34377. */
  34378. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  34379. /**
  34380. * Creates a tiled ground mesh.
  34381. * Please consider using the same method from the MeshBuilder class instead
  34382. * @param name defines the name of the mesh to create
  34383. * @param xmin set the ground minimum X coordinate
  34384. * @param zmin set the ground minimum Y coordinate
  34385. * @param xmax set the ground maximum X coordinate
  34386. * @param zmax set the ground maximum Z coordinate
  34387. * @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
  34388. * @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
  34389. * @param scene defines the hosting scene
  34390. * @param updatable defines if the mesh must be flagged as updatable
  34391. * @returns a new Mesh
  34392. */
  34393. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34394. w: number;
  34395. h: number;
  34396. }, precision: {
  34397. w: number;
  34398. h: number;
  34399. }, scene: Scene, updatable?: boolean): Mesh;
  34400. /**
  34401. * Creates a ground mesh from a height map.
  34402. * Please consider using the same method from the MeshBuilder class instead
  34403. * @see https://doc.babylonjs.com/babylon101/height_map
  34404. * @param name defines the name of the mesh to create
  34405. * @param url sets the URL of the height map image resource
  34406. * @param width set the ground width size
  34407. * @param height set the ground height size
  34408. * @param subdivisions sets the number of subdivision per side
  34409. * @param minHeight is the minimum altitude on the ground
  34410. * @param maxHeight is the maximum altitude on the ground
  34411. * @param scene defines the hosting scene
  34412. * @param updatable defines if the mesh must be flagged as updatable
  34413. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34414. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34415. * @returns a new Mesh
  34416. */
  34417. 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;
  34418. /**
  34419. * Creates a tube mesh.
  34420. * The tube is a parametric shape.
  34421. * It has no predefined shape. Its final shape will depend on the input parameters.
  34422. * Please consider using the same method from the MeshBuilder class instead
  34423. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34424. * @param name defines the name of the mesh to create
  34425. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34426. * @param radius sets the tube radius size
  34427. * @param tessellation is the number of sides on the tubular surface
  34428. * @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
  34429. * @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
  34430. * @param scene defines the hosting scene
  34431. * @param updatable defines if the mesh must be flagged as updatable
  34432. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34433. * @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)
  34434. * @returns a new Mesh
  34435. */
  34436. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34437. (i: number, distance: number): number;
  34438. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34439. /**
  34440. * Creates a polyhedron mesh.
  34441. * Please consider using the same method from the MeshBuilder class instead.
  34442. * * 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
  34443. * * The parameter `size` (positive float, default 1) sets the polygon size
  34444. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34445. * * 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`
  34446. * * 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
  34447. * * 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)`)
  34448. * * 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
  34449. * * 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
  34450. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34451. * * 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
  34452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34453. * @param name defines the name of the mesh to create
  34454. * @param options defines the options used to create the mesh
  34455. * @param scene defines the hosting scene
  34456. * @returns a new Mesh
  34457. */
  34458. static CreatePolyhedron(name: string, options: {
  34459. type?: number;
  34460. size?: number;
  34461. sizeX?: number;
  34462. sizeY?: number;
  34463. sizeZ?: number;
  34464. custom?: any;
  34465. faceUV?: Vector4[];
  34466. faceColors?: Color4[];
  34467. updatable?: boolean;
  34468. sideOrientation?: number;
  34469. }, scene: Scene): Mesh;
  34470. /**
  34471. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34472. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34473. * * 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`)
  34474. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34475. * * 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
  34476. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34477. * * 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
  34478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34479. * @param name defines the name of the mesh
  34480. * @param options defines the options used to create the mesh
  34481. * @param scene defines the hosting scene
  34482. * @returns a new Mesh
  34483. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34484. */
  34485. static CreateIcoSphere(name: string, options: {
  34486. radius?: number;
  34487. flat?: boolean;
  34488. subdivisions?: number;
  34489. sideOrientation?: number;
  34490. updatable?: boolean;
  34491. }, scene: Scene): Mesh;
  34492. /**
  34493. * Creates a decal mesh.
  34494. * Please consider using the same method from the MeshBuilder class instead.
  34495. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34496. * @param name defines the name of the mesh
  34497. * @param sourceMesh defines the mesh receiving the decal
  34498. * @param position sets the position of the decal in world coordinates
  34499. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34500. * @param size sets the decal scaling
  34501. * @param angle sets the angle to rotate the decal
  34502. * @returns a new Mesh
  34503. */
  34504. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34505. /** Creates a Capsule Mesh
  34506. * @param name defines the name of the mesh.
  34507. * @param options the constructors options used to shape the mesh.
  34508. * @param scene defines the scene the mesh is scoped to.
  34509. * @returns the capsule mesh
  34510. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34511. */
  34512. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34513. /**
  34514. * Prepare internal position array for software CPU skinning
  34515. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34516. */
  34517. setPositionsForCPUSkinning(): Float32Array;
  34518. /**
  34519. * Prepare internal normal array for software CPU skinning
  34520. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34521. */
  34522. setNormalsForCPUSkinning(): Float32Array;
  34523. /**
  34524. * Updates the vertex buffer by applying transformation from the bones
  34525. * @param skeleton defines the skeleton to apply to current mesh
  34526. * @returns the current mesh
  34527. */
  34528. applySkeleton(skeleton: Skeleton): Mesh;
  34529. /**
  34530. * 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
  34531. * @param meshes defines the list of meshes to scan
  34532. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34533. */
  34534. static MinMax(meshes: AbstractMesh[]): {
  34535. min: Vector3;
  34536. max: Vector3;
  34537. };
  34538. /**
  34539. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34540. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34541. * @returns a vector3
  34542. */
  34543. static Center(meshesOrMinMaxVector: {
  34544. min: Vector3;
  34545. max: Vector3;
  34546. } | AbstractMesh[]): Vector3;
  34547. /**
  34548. * Merge the array of meshes into a single mesh for performance reasons.
  34549. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34550. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34551. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34552. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34553. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34554. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34555. * @returns a new mesh
  34556. */
  34557. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34558. /** @hidden */
  34559. addInstance(instance: InstancedMesh): void;
  34560. /** @hidden */
  34561. removeInstance(instance: InstancedMesh): void;
  34562. }
  34563. }
  34564. declare module BABYLON {
  34565. /**
  34566. * The options Interface for creating a Capsule Mesh
  34567. */
  34568. export interface ICreateCapsuleOptions {
  34569. /** The Orientation of the capsule. Default : Vector3.Up() */
  34570. orientation?: Vector3;
  34571. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  34572. subdivisions: number;
  34573. /** Number of cylindrical segments on the capsule. */
  34574. tessellation: number;
  34575. /** Height or Length of the capsule. */
  34576. height: number;
  34577. /** Radius of the capsule. */
  34578. radius: number;
  34579. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  34580. capSubdivisions: number;
  34581. /** Overwrite for the top radius. */
  34582. radiusTop?: number;
  34583. /** Overwrite for the bottom radius. */
  34584. radiusBottom?: number;
  34585. /** Overwrite for the top capSubdivisions. */
  34586. topCapSubdivisions?: number;
  34587. /** Overwrite for the bottom capSubdivisions. */
  34588. bottomCapSubdivisions?: number;
  34589. /** Internal geometry is supposed to change once created. */
  34590. updatable?: boolean;
  34591. }
  34592. /**
  34593. * Class containing static functions to help procedurally build meshes
  34594. */
  34595. export class CapsuleBuilder {
  34596. /**
  34597. * Creates a capsule or a pill mesh
  34598. * @param name defines the name of the mesh
  34599. * @param options The constructors options.
  34600. * @param scene The scene the mesh is scoped to.
  34601. * @returns Capsule Mesh
  34602. */
  34603. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  34604. }
  34605. }
  34606. declare module BABYLON {
  34607. /**
  34608. * Define an interface for all classes that will get and set the data on vertices
  34609. */
  34610. export interface IGetSetVerticesData {
  34611. /**
  34612. * Gets a boolean indicating if specific vertex data is present
  34613. * @param kind defines the vertex data kind to use
  34614. * @returns true is data kind is present
  34615. */
  34616. isVerticesDataPresent(kind: string): boolean;
  34617. /**
  34618. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  34619. * @param kind defines the data kind (Position, normal, etc...)
  34620. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  34621. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34622. * @returns a float array containing vertex data
  34623. */
  34624. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34625. /**
  34626. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34627. * @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.
  34628. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34629. * @returns the indices array or an empty array if the mesh has no geometry
  34630. */
  34631. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34632. /**
  34633. * Set specific vertex data
  34634. * @param kind defines the data kind (Position, normal, etc...)
  34635. * @param data defines the vertex data to use
  34636. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  34637. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  34638. */
  34639. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  34640. /**
  34641. * Update a specific associated vertex buffer
  34642. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34643. * - VertexBuffer.PositionKind
  34644. * - VertexBuffer.UVKind
  34645. * - VertexBuffer.UV2Kind
  34646. * - VertexBuffer.UV3Kind
  34647. * - VertexBuffer.UV4Kind
  34648. * - VertexBuffer.UV5Kind
  34649. * - VertexBuffer.UV6Kind
  34650. * - VertexBuffer.ColorKind
  34651. * - VertexBuffer.MatricesIndicesKind
  34652. * - VertexBuffer.MatricesIndicesExtraKind
  34653. * - VertexBuffer.MatricesWeightsKind
  34654. * - VertexBuffer.MatricesWeightsExtraKind
  34655. * @param data defines the data source
  34656. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34657. * @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)
  34658. */
  34659. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  34660. /**
  34661. * Creates a new index buffer
  34662. * @param indices defines the indices to store in the index buffer
  34663. * @param totalVertices defines the total number of vertices (could be null)
  34664. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  34665. */
  34666. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  34667. }
  34668. /**
  34669. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  34670. */
  34671. export class VertexData {
  34672. /**
  34673. * Mesh side orientation : usually the external or front surface
  34674. */
  34675. static readonly FRONTSIDE: number;
  34676. /**
  34677. * Mesh side orientation : usually the internal or back surface
  34678. */
  34679. static readonly BACKSIDE: number;
  34680. /**
  34681. * Mesh side orientation : both internal and external or front and back surfaces
  34682. */
  34683. static readonly DOUBLESIDE: number;
  34684. /**
  34685. * Mesh side orientation : by default, `FRONTSIDE`
  34686. */
  34687. static readonly DEFAULTSIDE: number;
  34688. /**
  34689. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  34690. */
  34691. positions: Nullable<FloatArray>;
  34692. /**
  34693. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  34694. */
  34695. normals: Nullable<FloatArray>;
  34696. /**
  34697. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  34698. */
  34699. tangents: Nullable<FloatArray>;
  34700. /**
  34701. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34702. */
  34703. uvs: Nullable<FloatArray>;
  34704. /**
  34705. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34706. */
  34707. uvs2: Nullable<FloatArray>;
  34708. /**
  34709. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34710. */
  34711. uvs3: Nullable<FloatArray>;
  34712. /**
  34713. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34714. */
  34715. uvs4: Nullable<FloatArray>;
  34716. /**
  34717. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34718. */
  34719. uvs5: Nullable<FloatArray>;
  34720. /**
  34721. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34722. */
  34723. uvs6: Nullable<FloatArray>;
  34724. /**
  34725. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  34726. */
  34727. colors: Nullable<FloatArray>;
  34728. /**
  34729. * 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).
  34730. */
  34731. matricesIndices: Nullable<FloatArray>;
  34732. /**
  34733. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  34734. */
  34735. matricesWeights: Nullable<FloatArray>;
  34736. /**
  34737. * An array extending the number of possible indices
  34738. */
  34739. matricesIndicesExtra: Nullable<FloatArray>;
  34740. /**
  34741. * An array extending the number of possible weights when the number of indices is extended
  34742. */
  34743. matricesWeightsExtra: Nullable<FloatArray>;
  34744. /**
  34745. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  34746. */
  34747. indices: Nullable<IndicesArray>;
  34748. /**
  34749. * Uses the passed data array to set the set the values for the specified kind of data
  34750. * @param data a linear array of floating numbers
  34751. * @param kind the type of data that is being set, eg positions, colors etc
  34752. */
  34753. set(data: FloatArray, kind: string): void;
  34754. /**
  34755. * Associates the vertexData to the passed Mesh.
  34756. * Sets it as updatable or not (default `false`)
  34757. * @param mesh the mesh the vertexData is applied to
  34758. * @param updatable when used and having the value true allows new data to update the vertexData
  34759. * @returns the VertexData
  34760. */
  34761. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  34762. /**
  34763. * Associates the vertexData to the passed Geometry.
  34764. * Sets it as updatable or not (default `false`)
  34765. * @param geometry the geometry the vertexData is applied to
  34766. * @param updatable when used and having the value true allows new data to update the vertexData
  34767. * @returns VertexData
  34768. */
  34769. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  34770. /**
  34771. * Updates the associated mesh
  34772. * @param mesh the mesh to be updated
  34773. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34774. * @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
  34775. * @returns VertexData
  34776. */
  34777. updateMesh(mesh: Mesh): VertexData;
  34778. /**
  34779. * Updates the associated geometry
  34780. * @param geometry the geometry to be updated
  34781. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34782. * @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
  34783. * @returns VertexData.
  34784. */
  34785. updateGeometry(geometry: Geometry): VertexData;
  34786. private _applyTo;
  34787. private _update;
  34788. /**
  34789. * Transforms each position and each normal of the vertexData according to the passed Matrix
  34790. * @param matrix the transforming matrix
  34791. * @returns the VertexData
  34792. */
  34793. transform(matrix: Matrix): VertexData;
  34794. /**
  34795. * Merges the passed VertexData into the current one
  34796. * @param other the VertexData to be merged into the current one
  34797. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  34798. * @returns the modified VertexData
  34799. */
  34800. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  34801. private _mergeElement;
  34802. private _validate;
  34803. /**
  34804. * Serializes the VertexData
  34805. * @returns a serialized object
  34806. */
  34807. serialize(): any;
  34808. /**
  34809. * Extracts the vertexData from a mesh
  34810. * @param mesh the mesh from which to extract the VertexData
  34811. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  34812. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34813. * @returns the object VertexData associated to the passed mesh
  34814. */
  34815. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34816. /**
  34817. * Extracts the vertexData from the geometry
  34818. * @param geometry the geometry from which to extract the VertexData
  34819. * @param copyWhenShared defines if the VertexData must be cloned when the geometry is shared between multiple meshes, optional, default false
  34820. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34821. * @returns the object VertexData associated to the passed mesh
  34822. */
  34823. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34824. private static _ExtractFrom;
  34825. /**
  34826. * Creates the VertexData for a Ribbon
  34827. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  34828. * * pathArray array of paths, each of which an array of successive Vector3
  34829. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  34830. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  34831. * * 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
  34832. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34833. * * 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)
  34834. * * 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)
  34835. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  34836. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  34837. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  34838. * @returns the VertexData of the ribbon
  34839. */
  34840. static CreateRibbon(options: {
  34841. pathArray: Vector3[][];
  34842. closeArray?: boolean;
  34843. closePath?: boolean;
  34844. offset?: number;
  34845. sideOrientation?: number;
  34846. frontUVs?: Vector4;
  34847. backUVs?: Vector4;
  34848. invertUV?: boolean;
  34849. uvs?: Vector2[];
  34850. colors?: Color4[];
  34851. }): VertexData;
  34852. /**
  34853. * Creates the VertexData for a box
  34854. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34855. * * size sets the width, height and depth of the box to the value of size, optional default 1
  34856. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  34857. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  34858. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  34859. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34860. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34861. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34862. * * 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)
  34863. * * 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)
  34864. * @returns the VertexData of the box
  34865. */
  34866. static CreateBox(options: {
  34867. size?: number;
  34868. width?: number;
  34869. height?: number;
  34870. depth?: number;
  34871. faceUV?: Vector4[];
  34872. faceColors?: Color4[];
  34873. sideOrientation?: number;
  34874. frontUVs?: Vector4;
  34875. backUVs?: Vector4;
  34876. }): VertexData;
  34877. /**
  34878. * Creates the VertexData for a tiled box
  34879. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34880. * * faceTiles sets the pattern, tile size and number of tiles for a face
  34881. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34882. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34883. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34884. * @returns the VertexData of the box
  34885. */
  34886. static CreateTiledBox(options: {
  34887. pattern?: number;
  34888. width?: number;
  34889. height?: number;
  34890. depth?: number;
  34891. tileSize?: number;
  34892. tileWidth?: number;
  34893. tileHeight?: number;
  34894. alignHorizontal?: number;
  34895. alignVertical?: number;
  34896. faceUV?: Vector4[];
  34897. faceColors?: Color4[];
  34898. sideOrientation?: number;
  34899. }): VertexData;
  34900. /**
  34901. * Creates the VertexData for a tiled plane
  34902. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34903. * * pattern a limited pattern arrangement depending on the number
  34904. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  34905. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  34906. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  34907. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34908. * * 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)
  34909. * * 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)
  34910. * @returns the VertexData of the tiled plane
  34911. */
  34912. static CreateTiledPlane(options: {
  34913. pattern?: number;
  34914. tileSize?: number;
  34915. tileWidth?: number;
  34916. tileHeight?: number;
  34917. size?: number;
  34918. width?: number;
  34919. height?: number;
  34920. alignHorizontal?: number;
  34921. alignVertical?: number;
  34922. sideOrientation?: number;
  34923. frontUVs?: Vector4;
  34924. backUVs?: Vector4;
  34925. }): VertexData;
  34926. /**
  34927. * Creates the VertexData for an ellipsoid, defaults to a sphere
  34928. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34929. * * segments sets the number of horizontal strips optional, default 32
  34930. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  34931. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  34932. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  34933. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  34934. * * 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
  34935. * * 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
  34936. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34937. * * 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)
  34938. * * 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)
  34939. * @returns the VertexData of the ellipsoid
  34940. */
  34941. static CreateSphere(options: {
  34942. segments?: number;
  34943. diameter?: number;
  34944. diameterX?: number;
  34945. diameterY?: number;
  34946. diameterZ?: number;
  34947. arc?: number;
  34948. slice?: number;
  34949. sideOrientation?: number;
  34950. frontUVs?: Vector4;
  34951. backUVs?: Vector4;
  34952. }): VertexData;
  34953. /**
  34954. * Creates the VertexData for a cylinder, cone or prism
  34955. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34956. * * height sets the height (y direction) of the cylinder, optional, default 2
  34957. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  34958. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  34959. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  34960. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  34961. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  34962. * * 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
  34963. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34964. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34965. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  34966. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  34967. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34968. * * 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)
  34969. * * 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)
  34970. * @returns the VertexData of the cylinder, cone or prism
  34971. */
  34972. static CreateCylinder(options: {
  34973. height?: number;
  34974. diameterTop?: number;
  34975. diameterBottom?: number;
  34976. diameter?: number;
  34977. tessellation?: number;
  34978. subdivisions?: number;
  34979. arc?: number;
  34980. faceColors?: Color4[];
  34981. faceUV?: Vector4[];
  34982. hasRings?: boolean;
  34983. enclose?: boolean;
  34984. sideOrientation?: number;
  34985. frontUVs?: Vector4;
  34986. backUVs?: Vector4;
  34987. }): VertexData;
  34988. /**
  34989. * Creates the VertexData for a torus
  34990. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34991. * * diameter the diameter of the torus, optional default 1
  34992. * * thickness the diameter of the tube forming the torus, optional default 0.5
  34993. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  34994. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34995. * * 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)
  34996. * * 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)
  34997. * @returns the VertexData of the torus
  34998. */
  34999. static CreateTorus(options: {
  35000. diameter?: number;
  35001. thickness?: number;
  35002. tessellation?: number;
  35003. sideOrientation?: number;
  35004. frontUVs?: Vector4;
  35005. backUVs?: Vector4;
  35006. }): VertexData;
  35007. /**
  35008. * Creates the VertexData of the LineSystem
  35009. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  35010. * - lines an array of lines, each line being an array of successive Vector3
  35011. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  35012. * @returns the VertexData of the LineSystem
  35013. */
  35014. static CreateLineSystem(options: {
  35015. lines: Vector3[][];
  35016. colors?: Nullable<Color4[][]>;
  35017. }): VertexData;
  35018. /**
  35019. * Create the VertexData for a DashedLines
  35020. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  35021. * - points an array successive Vector3
  35022. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  35023. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  35024. * - dashNb the intended total number of dashes, optional, default 200
  35025. * @returns the VertexData for the DashedLines
  35026. */
  35027. static CreateDashedLines(options: {
  35028. points: Vector3[];
  35029. dashSize?: number;
  35030. gapSize?: number;
  35031. dashNb?: number;
  35032. }): VertexData;
  35033. /**
  35034. * Creates the VertexData for a Ground
  35035. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  35036. * - width the width (x direction) of the ground, optional, default 1
  35037. * - height the height (z direction) of the ground, optional, default 1
  35038. * - subdivisions the number of subdivisions per side, optional, default 1
  35039. * @returns the VertexData of the Ground
  35040. */
  35041. static CreateGround(options: {
  35042. width?: number;
  35043. height?: number;
  35044. subdivisions?: number;
  35045. subdivisionsX?: number;
  35046. subdivisionsY?: number;
  35047. }): VertexData;
  35048. /**
  35049. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  35050. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  35051. * * xmin the ground minimum X coordinate, optional, default -1
  35052. * * zmin the ground minimum Z coordinate, optional, default -1
  35053. * * xmax the ground maximum X coordinate, optional, default 1
  35054. * * zmax the ground maximum Z coordinate, optional, default 1
  35055. * * 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}
  35056. * * 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}
  35057. * @returns the VertexData of the TiledGround
  35058. */
  35059. static CreateTiledGround(options: {
  35060. xmin: number;
  35061. zmin: number;
  35062. xmax: number;
  35063. zmax: number;
  35064. subdivisions?: {
  35065. w: number;
  35066. h: number;
  35067. };
  35068. precision?: {
  35069. w: number;
  35070. h: number;
  35071. };
  35072. }): VertexData;
  35073. /**
  35074. * Creates the VertexData of the Ground designed from a heightmap
  35075. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  35076. * * width the width (x direction) of the ground
  35077. * * height the height (z direction) of the ground
  35078. * * subdivisions the number of subdivisions per side
  35079. * * minHeight the minimum altitude on the ground, optional, default 0
  35080. * * maxHeight the maximum altitude on the ground, optional default 1
  35081. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  35082. * * buffer the array holding the image color data
  35083. * * bufferWidth the width of image
  35084. * * bufferHeight the height of image
  35085. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  35086. * @returns the VertexData of the Ground designed from a heightmap
  35087. */
  35088. static CreateGroundFromHeightMap(options: {
  35089. width: number;
  35090. height: number;
  35091. subdivisions: number;
  35092. minHeight: number;
  35093. maxHeight: number;
  35094. colorFilter: Color3;
  35095. buffer: Uint8Array;
  35096. bufferWidth: number;
  35097. bufferHeight: number;
  35098. alphaFilter: number;
  35099. }): VertexData;
  35100. /**
  35101. * Creates the VertexData for a Plane
  35102. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  35103. * * size sets the width and height of the plane to the value of size, optional default 1
  35104. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  35105. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  35106. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35107. * * 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)
  35108. * * 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)
  35109. * @returns the VertexData of the box
  35110. */
  35111. static CreatePlane(options: {
  35112. size?: number;
  35113. width?: number;
  35114. height?: number;
  35115. sideOrientation?: number;
  35116. frontUVs?: Vector4;
  35117. backUVs?: Vector4;
  35118. }): VertexData;
  35119. /**
  35120. * Creates the VertexData of the Disc or regular Polygon
  35121. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  35122. * * radius the radius of the disc, optional default 0.5
  35123. * * tessellation the number of polygon sides, optional, default 64
  35124. * * 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
  35125. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35126. * * 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)
  35127. * * 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)
  35128. * @returns the VertexData of the box
  35129. */
  35130. static CreateDisc(options: {
  35131. radius?: number;
  35132. tessellation?: number;
  35133. arc?: number;
  35134. sideOrientation?: number;
  35135. frontUVs?: Vector4;
  35136. backUVs?: Vector4;
  35137. }): VertexData;
  35138. /**
  35139. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  35140. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  35141. * @param polygon a mesh built from polygonTriangulation.build()
  35142. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35143. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35144. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35145. * @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)
  35146. * @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)
  35147. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  35148. * @returns the VertexData of the Polygon
  35149. */
  35150. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  35151. /**
  35152. * Creates the VertexData of the IcoSphere
  35153. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  35154. * * radius the radius of the IcoSphere, optional default 1
  35155. * * radiusX allows stretching in the x direction, optional, default radius
  35156. * * radiusY allows stretching in the y direction, optional, default radius
  35157. * * radiusZ allows stretching in the z direction, optional, default radius
  35158. * * flat when true creates a flat shaded mesh, optional, default true
  35159. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  35160. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35161. * * 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)
  35162. * * 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)
  35163. * @returns the VertexData of the IcoSphere
  35164. */
  35165. static CreateIcoSphere(options: {
  35166. radius?: number;
  35167. radiusX?: number;
  35168. radiusY?: number;
  35169. radiusZ?: number;
  35170. flat?: boolean;
  35171. subdivisions?: number;
  35172. sideOrientation?: number;
  35173. frontUVs?: Vector4;
  35174. backUVs?: Vector4;
  35175. }): VertexData;
  35176. /**
  35177. * Creates the VertexData for a Polyhedron
  35178. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  35179. * * type provided types are:
  35180. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  35181. * * 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)
  35182. * * size the size of the IcoSphere, optional default 1
  35183. * * sizeX allows stretching in the x direction, optional, default size
  35184. * * sizeY allows stretching in the y direction, optional, default size
  35185. * * sizeZ allows stretching in the z direction, optional, default size
  35186. * * 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
  35187. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35188. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35189. * * flat when true creates a flat shaded mesh, optional, default true
  35190. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  35191. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35192. * * 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)
  35193. * * 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)
  35194. * @returns the VertexData of the Polyhedron
  35195. */
  35196. static CreatePolyhedron(options: {
  35197. type?: number;
  35198. size?: number;
  35199. sizeX?: number;
  35200. sizeY?: number;
  35201. sizeZ?: number;
  35202. custom?: any;
  35203. faceUV?: Vector4[];
  35204. faceColors?: Color4[];
  35205. flat?: boolean;
  35206. sideOrientation?: number;
  35207. frontUVs?: Vector4;
  35208. backUVs?: Vector4;
  35209. }): VertexData;
  35210. /**
  35211. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  35212. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  35213. * @returns the VertexData of the Capsule
  35214. */
  35215. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  35216. /**
  35217. * Creates the VertexData for a TorusKnot
  35218. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  35219. * * radius the radius of the torus knot, optional, default 2
  35220. * * tube the thickness of the tube, optional, default 0.5
  35221. * * radialSegments the number of sides on each tube segments, optional, default 32
  35222. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  35223. * * p the number of windings around the z axis, optional, default 2
  35224. * * q the number of windings around the x axis, optional, default 3
  35225. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35226. * * 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)
  35227. * * 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)
  35228. * @returns the VertexData of the Torus Knot
  35229. */
  35230. static CreateTorusKnot(options: {
  35231. radius?: number;
  35232. tube?: number;
  35233. radialSegments?: number;
  35234. tubularSegments?: number;
  35235. p?: number;
  35236. q?: number;
  35237. sideOrientation?: number;
  35238. frontUVs?: Vector4;
  35239. backUVs?: Vector4;
  35240. }): VertexData;
  35241. /**
  35242. * Compute normals for given positions and indices
  35243. * @param positions an array of vertex positions, [...., x, y, z, ......]
  35244. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  35245. * @param normals an array of vertex normals, [...., x, y, z, ......]
  35246. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  35247. * * facetNormals : optional array of facet normals (vector3)
  35248. * * facetPositions : optional array of facet positions (vector3)
  35249. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  35250. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  35251. * * bInfo : optional bounding info, required for facetPartitioning computation
  35252. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  35253. * * subDiv : optional partitioning data about subdivisions on each axis (int), required for facetPartitioning computation
  35254. * * useRightHandedSystem: optional boolean to for right handed system computation
  35255. * * depthSort : optional boolean to enable the facet depth sort computation
  35256. * * distanceTo : optional Vector3 to compute the facet depth from this location
  35257. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  35258. */
  35259. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  35260. facetNormals?: any;
  35261. facetPositions?: any;
  35262. facetPartitioning?: any;
  35263. ratio?: number;
  35264. bInfo?: any;
  35265. bbSize?: Vector3;
  35266. subDiv?: any;
  35267. useRightHandedSystem?: boolean;
  35268. depthSort?: boolean;
  35269. distanceTo?: Vector3;
  35270. depthSortedFacets?: any;
  35271. }): void;
  35272. /** @hidden */
  35273. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  35274. /**
  35275. * Applies VertexData created from the imported parameters to the geometry
  35276. * @param parsedVertexData the parsed data from an imported file
  35277. * @param geometry the geometry to apply the VertexData to
  35278. */
  35279. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  35280. }
  35281. }
  35282. declare module BABYLON {
  35283. /**
  35284. * Class containing static functions to help procedurally build meshes
  35285. */
  35286. export class DiscBuilder {
  35287. /**
  35288. * Creates a plane polygonal mesh. By default, this is a disc
  35289. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  35290. * * 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
  35291. * * 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
  35292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35293. * * 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
  35294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35295. * @param name defines the name of the mesh
  35296. * @param options defines the options used to create the mesh
  35297. * @param scene defines the hosting scene
  35298. * @returns the plane polygonal mesh
  35299. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  35300. */
  35301. static CreateDisc(name: string, options: {
  35302. radius?: number;
  35303. tessellation?: number;
  35304. arc?: number;
  35305. updatable?: boolean;
  35306. sideOrientation?: number;
  35307. frontUVs?: Vector4;
  35308. backUVs?: Vector4;
  35309. }, scene?: Nullable<Scene>): Mesh;
  35310. }
  35311. }
  35312. declare module BABYLON {
  35313. /**
  35314. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  35315. *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.
  35316. * The SPS is also a particle system. It provides some methods to manage the particles.
  35317. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  35318. *
  35319. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  35320. */
  35321. export class SolidParticleSystem implements IDisposable {
  35322. /**
  35323. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  35324. * Example : var p = SPS.particles[i];
  35325. */
  35326. particles: SolidParticle[];
  35327. /**
  35328. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  35329. */
  35330. nbParticles: number;
  35331. /**
  35332. * If the particles must ever face the camera (default false). Useful for planar particles.
  35333. */
  35334. billboard: boolean;
  35335. /**
  35336. * Recompute normals when adding a shape
  35337. */
  35338. recomputeNormals: boolean;
  35339. /**
  35340. * This a counter ofr your own usage. It's not set by any SPS functions.
  35341. */
  35342. counter: number;
  35343. /**
  35344. * The SPS name. This name is also given to the underlying mesh.
  35345. */
  35346. name: string;
  35347. /**
  35348. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are available.
  35349. */
  35350. mesh: Mesh;
  35351. /**
  35352. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35353. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35354. */
  35355. vars: any;
  35356. /**
  35357. * This array is populated when the SPS is set as 'pickable'.
  35358. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35359. * Each element of this array is an object `{idx: int, faceId: int}`.
  35360. * `idx` is the picked particle index in the `SPS.particles` array
  35361. * `faceId` is the picked face index counted within this particle.
  35362. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35363. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35364. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35365. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35366. */
  35367. pickedParticles: {
  35368. idx: number;
  35369. faceId: number;
  35370. }[];
  35371. /**
  35372. * This array is populated when the SPS is set as 'pickable'
  35373. * Each key of this array is a submesh index.
  35374. * Each element of this array is a second array defined like this :
  35375. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35376. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35377. * `idx` is the picked particle index in the `SPS.particles` array
  35378. * `faceId` is the picked face index counted within this particle.
  35379. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35380. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35381. */
  35382. pickedBySubMesh: {
  35383. idx: number;
  35384. faceId: number;
  35385. }[][];
  35386. /**
  35387. * This array is populated when `enableDepthSort` is set to true.
  35388. * Each element of this array is an instance of the class DepthSortedParticle.
  35389. */
  35390. depthSortedParticles: DepthSortedParticle[];
  35391. /**
  35392. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35393. * @hidden
  35394. */
  35395. _bSphereOnly: boolean;
  35396. /**
  35397. * A number to multiply the bounding sphere radius by in order to reduce it for instance. (Internal use only)
  35398. * @hidden
  35399. */
  35400. _bSphereRadiusFactor: number;
  35401. private _scene;
  35402. private _positions;
  35403. private _indices;
  35404. private _normals;
  35405. private _colors;
  35406. private _uvs;
  35407. private _indices32;
  35408. private _positions32;
  35409. private _normals32;
  35410. private _fixedNormal32;
  35411. private _colors32;
  35412. private _uvs32;
  35413. private _index;
  35414. private _updatable;
  35415. private _pickable;
  35416. private _isVisibilityBoxLocked;
  35417. private _alwaysVisible;
  35418. private _depthSort;
  35419. private _expandable;
  35420. private _shapeCounter;
  35421. private _copy;
  35422. private _color;
  35423. private _computeParticleColor;
  35424. private _computeParticleTexture;
  35425. private _computeParticleRotation;
  35426. private _computeParticleVertex;
  35427. private _computeBoundingBox;
  35428. private _depthSortParticles;
  35429. private _camera;
  35430. private _mustUnrotateFixedNormals;
  35431. private _particlesIntersect;
  35432. private _needs32Bits;
  35433. private _isNotBuilt;
  35434. private _lastParticleId;
  35435. private _idxOfId;
  35436. private _multimaterialEnabled;
  35437. private _useModelMaterial;
  35438. private _indicesByMaterial;
  35439. private _materialIndexes;
  35440. private _depthSortFunction;
  35441. private _materialSortFunction;
  35442. private _materials;
  35443. private _multimaterial;
  35444. private _materialIndexesById;
  35445. private _defaultMaterial;
  35446. private _autoUpdateSubMeshes;
  35447. private _tmpVertex;
  35448. /**
  35449. * Creates a SPS (Solid Particle System) object.
  35450. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35451. * @param scene (Scene) is the scene in which the SPS is added.
  35452. * @param options defines the options of the sps e.g.
  35453. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35454. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35455. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35456. * * 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.
  35457. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35458. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35459. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35460. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35461. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the bounding sphere radius by in order to reduce it for instance.
  35462. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35463. */
  35464. constructor(name: string, scene: Scene, options?: {
  35465. updatable?: boolean;
  35466. isPickable?: boolean;
  35467. enableDepthSort?: boolean;
  35468. particleIntersection?: boolean;
  35469. boundingSphereOnly?: boolean;
  35470. bSphereRadiusFactor?: number;
  35471. expandable?: boolean;
  35472. useModelMaterial?: boolean;
  35473. enableMultiMaterial?: boolean;
  35474. });
  35475. /**
  35476. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35477. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35478. * @returns the created mesh
  35479. */
  35480. buildMesh(): Mesh;
  35481. /**
  35482. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35483. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35484. * Thus the particles generated from `digest()` have their property `position` set yet.
  35485. * @param mesh ( Mesh ) is the mesh to be digested
  35486. * @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
  35487. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35488. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35489. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35490. * @returns the current SPS
  35491. */
  35492. digest(mesh: Mesh, options?: {
  35493. facetNb?: number;
  35494. number?: number;
  35495. delta?: number;
  35496. storage?: [];
  35497. }): SolidParticleSystem;
  35498. /**
  35499. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35500. * @hidden
  35501. */
  35502. private _unrotateFixedNormals;
  35503. /**
  35504. * Resets the temporary working copy particle
  35505. * @hidden
  35506. */
  35507. private _resetCopy;
  35508. /**
  35509. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35510. * @param p the current index in the positions array to be updated
  35511. * @param ind the current index in the indices array
  35512. * @param shape a Vector3 array, the shape geometry
  35513. * @param positions the positions array to be updated
  35514. * @param meshInd the shape indices array
  35515. * @param indices the indices array to be updated
  35516. * @param meshUV the shape uv array
  35517. * @param uvs the uv array to be updated
  35518. * @param meshCol the shape color array
  35519. * @param colors the color array to be updated
  35520. * @param meshNor the shape normals array
  35521. * @param normals the normals array to be updated
  35522. * @param idx the particle index
  35523. * @param idxInShape the particle index in its shape
  35524. * @param options the addShape() method passed options
  35525. * @model the particle model
  35526. * @hidden
  35527. */
  35528. private _meshBuilder;
  35529. /**
  35530. * Returns a shape Vector3 array from positions float array
  35531. * @param positions float array
  35532. * @returns a vector3 array
  35533. * @hidden
  35534. */
  35535. private _posToShape;
  35536. /**
  35537. * Returns a shapeUV array from a float uvs (array deep copy)
  35538. * @param uvs as a float array
  35539. * @returns a shapeUV array
  35540. * @hidden
  35541. */
  35542. private _uvsToShapeUV;
  35543. /**
  35544. * Adds a new particle object in the particles array
  35545. * @param idx particle index in particles array
  35546. * @param id particle id
  35547. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35548. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35549. * @param model particle ModelShape object
  35550. * @param shapeId model shape identifier
  35551. * @param idxInShape index of the particle in the current model
  35552. * @param bInfo model bounding info object
  35553. * @param storage target storage array, if any
  35554. * @hidden
  35555. */
  35556. private _addParticle;
  35557. /**
  35558. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35559. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35560. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35561. * @param nb (positive integer) the number of particles to be created from this model
  35562. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35563. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35564. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35565. * @returns the number of shapes in the system
  35566. */
  35567. addShape(mesh: Mesh, nb: number, options?: {
  35568. positionFunction?: any;
  35569. vertexFunction?: any;
  35570. storage?: [];
  35571. }): number;
  35572. /**
  35573. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35574. * @hidden
  35575. */
  35576. private _rebuildParticle;
  35577. /**
  35578. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35579. * @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.
  35580. * @returns the SPS.
  35581. */
  35582. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35583. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35584. * Returns an array with the removed particles.
  35585. * 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.
  35586. * The SPS can't be empty so at least one particle needs to remain in place.
  35587. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35588. * @param start index of the first particle to remove
  35589. * @param end index of the last particle to remove (included)
  35590. * @returns an array populated with the removed particles
  35591. */
  35592. removeParticles(start: number, end: number): SolidParticle[];
  35593. /**
  35594. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35595. * @param solidParticleArray an array populated with Solid Particles objects
  35596. * @returns the SPS
  35597. */
  35598. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35599. /**
  35600. * Creates a new particle and modifies the SPS mesh geometry :
  35601. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35602. * - calls _addParticle() to populate the particle array
  35603. * factorized code from addShape() and insertParticlesFromArray()
  35604. * @param idx particle index in the particles array
  35605. * @param i particle index in its shape
  35606. * @param modelShape particle ModelShape object
  35607. * @param shape shape vertex array
  35608. * @param meshInd shape indices array
  35609. * @param meshUV shape uv array
  35610. * @param meshCol shape color array
  35611. * @param meshNor shape normals array
  35612. * @param bbInfo shape bounding info
  35613. * @param storage target particle storage
  35614. * @options addShape() passed options
  35615. * @hidden
  35616. */
  35617. private _insertNewParticle;
  35618. /**
  35619. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35620. * This method calls `updateParticle()` for each particle of the SPS.
  35621. * For an animated SPS, it is usually called within the render loop.
  35622. * 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.
  35623. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35624. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35625. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35626. * @returns the SPS.
  35627. */
  35628. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35629. /**
  35630. * Disposes the SPS.
  35631. */
  35632. dispose(): void;
  35633. /** Returns an object {idx: number faceId: number} for the picked particle from the passed pickingInfo object.
  35634. * idx is the particle index in the SPS
  35635. * faceId is the picked face index counted within this particle.
  35636. * Returns null if the pickInfo can't identify a picked particle.
  35637. * @param pickingInfo (PickingInfo object)
  35638. * @returns {idx: number, faceId: number} or null
  35639. */
  35640. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35641. idx: number;
  35642. faceId: number;
  35643. }>;
  35644. /**
  35645. * Returns a SolidParticle object from its identifier : particle.id
  35646. * @param id (integer) the particle Id
  35647. * @returns the searched particle or null if not found in the SPS.
  35648. */
  35649. getParticleById(id: number): Nullable<SolidParticle>;
  35650. /**
  35651. * Returns a new array populated with the particles having the passed shapeId.
  35652. * @param shapeId (integer) the shape identifier
  35653. * @returns a new solid particle array
  35654. */
  35655. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35656. /**
  35657. * Populates the passed array "ref" with the particles having the passed shapeId.
  35658. * @param shapeId the shape identifier
  35659. * @returns the SPS
  35660. * @param ref
  35661. */
  35662. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35663. /**
  35664. * Computes the required SubMeshes according the materials assigned to the particles.
  35665. * @returns the solid particle system.
  35666. * Does nothing if called before the SPS mesh is built.
  35667. */
  35668. computeSubMeshes(): SolidParticleSystem;
  35669. /**
  35670. * Sorts the solid particles by material when MultiMaterial is enabled.
  35671. * Updates the indices32 array.
  35672. * Updates the indicesByMaterial array.
  35673. * Updates the mesh indices array.
  35674. * @returns the SPS
  35675. * @hidden
  35676. */
  35677. private _sortParticlesByMaterial;
  35678. /**
  35679. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35680. * @hidden
  35681. */
  35682. private _setMaterialIndexesById;
  35683. /**
  35684. * Returns an array with unique values of Materials from the passed array
  35685. * @param array the material array to be checked and filtered
  35686. * @hidden
  35687. */
  35688. private _filterUniqueMaterialId;
  35689. /**
  35690. * Sets a new Standard Material as _defaultMaterial if not already set.
  35691. * @hidden
  35692. */
  35693. private _setDefaultMaterial;
  35694. /**
  35695. * Visibility helper : Recomputes the visible size according to the mesh bounding box
  35696. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35697. * @returns the SPS.
  35698. */
  35699. refreshVisibleSize(): SolidParticleSystem;
  35700. /**
  35701. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35702. * @param size the size (float) of the visibility box
  35703. * note : this doesn't lock the SPS mesh bounding box.
  35704. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35705. */
  35706. setVisibilityBox(size: number): void;
  35707. /**
  35708. * Gets whether the SPS as always visible or not
  35709. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35710. */
  35711. get isAlwaysVisible(): boolean;
  35712. /**
  35713. * Sets the SPS as always visible or not
  35714. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35715. */
  35716. set isAlwaysVisible(val: boolean);
  35717. /**
  35718. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35719. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35720. */
  35721. set isVisibilityBoxLocked(val: boolean);
  35722. /**
  35723. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35724. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35725. */
  35726. get isVisibilityBoxLocked(): boolean;
  35727. /**
  35728. * Tells to `setParticles()` to compute the particle rotations or not.
  35729. * Default value : true. The SPS is faster when it's set to false.
  35730. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35731. */
  35732. set computeParticleRotation(val: boolean);
  35733. /**
  35734. * Tells to `setParticles()` to compute the particle colors or not.
  35735. * Default value : true. The SPS is faster when it's set to false.
  35736. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35737. */
  35738. set computeParticleColor(val: boolean);
  35739. set computeParticleTexture(val: boolean);
  35740. /**
  35741. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  35742. * Default value : false. The SPS is faster when it's set to false.
  35743. * Note : the particle custom vertex positions aren't stored values.
  35744. */
  35745. set computeParticleVertex(val: boolean);
  35746. /**
  35747. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  35748. */
  35749. set computeBoundingBox(val: boolean);
  35750. /**
  35751. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  35752. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35753. * Default : `true`
  35754. */
  35755. set depthSortParticles(val: boolean);
  35756. /**
  35757. * Gets if `setParticles()` computes the particle rotations or not.
  35758. * Default value : true. The SPS is faster when it's set to false.
  35759. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35760. */
  35761. get computeParticleRotation(): boolean;
  35762. /**
  35763. * Gets if `setParticles()` computes the particle colors or not.
  35764. * Default value : true. The SPS is faster when it's set to false.
  35765. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35766. */
  35767. get computeParticleColor(): boolean;
  35768. /**
  35769. * Gets if `setParticles()` computes the particle textures or not.
  35770. * Default value : true. The SPS is faster when it's set to false.
  35771. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  35772. */
  35773. get computeParticleTexture(): boolean;
  35774. /**
  35775. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  35776. * Default value : false. The SPS is faster when it's set to false.
  35777. * Note : the particle custom vertex positions aren't stored values.
  35778. */
  35779. get computeParticleVertex(): boolean;
  35780. /**
  35781. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  35782. */
  35783. get computeBoundingBox(): boolean;
  35784. /**
  35785. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  35786. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35787. * Default : `true`
  35788. */
  35789. get depthSortParticles(): boolean;
  35790. /**
  35791. * Gets if the SPS is created as expandable at construction time.
  35792. * Default : `false`
  35793. */
  35794. get expandable(): boolean;
  35795. /**
  35796. * Gets if the SPS supports the Multi Materials
  35797. */
  35798. get multimaterialEnabled(): boolean;
  35799. /**
  35800. * Gets if the SPS uses the model materials for its own multimaterial.
  35801. */
  35802. get useModelMaterial(): boolean;
  35803. /**
  35804. * The SPS used material array.
  35805. */
  35806. get materials(): Material[];
  35807. /**
  35808. * Sets the SPS MultiMaterial from the passed materials.
  35809. * Note : the passed array is internally copied and not used then by reference.
  35810. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  35811. */
  35812. setMultiMaterial(materials: Material[]): void;
  35813. /**
  35814. * The SPS computed multimaterial object
  35815. */
  35816. get multimaterial(): MultiMaterial;
  35817. set multimaterial(mm: MultiMaterial);
  35818. /**
  35819. * If the subMeshes must be updated on the next call to setParticles()
  35820. */
  35821. get autoUpdateSubMeshes(): boolean;
  35822. set autoUpdateSubMeshes(val: boolean);
  35823. /**
  35824. * This function does nothing. It may be overwritten to set all the particle first values.
  35825. * The SPS doesn't call this function, you may have to call it by your own.
  35826. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35827. */
  35828. initParticles(): void;
  35829. /**
  35830. * This function does nothing. It may be overwritten to recycle a particle.
  35831. * The SPS doesn't call this function, you may have to call it by your own.
  35832. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35833. * @param particle The particle to recycle
  35834. * @returns the recycled particle
  35835. */
  35836. recycleParticle(particle: SolidParticle): SolidParticle;
  35837. /**
  35838. * Updates a particle : this function should be overwritten by the user.
  35839. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  35840. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35841. * @example : just set a particle position or velocity and recycle conditions
  35842. * @param particle The particle to update
  35843. * @returns the updated particle
  35844. */
  35845. updateParticle(particle: SolidParticle): SolidParticle;
  35846. /**
  35847. * Updates a vertex of a particle : it can be overwritten by the user.
  35848. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  35849. * @param particle the current particle
  35850. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  35851. * @param pt the index of the current vertex in the particle shape
  35852. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  35853. * @example : just set a vertex particle position or color
  35854. * @returns the sps
  35855. */
  35856. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  35857. /**
  35858. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  35859. * This does nothing and may be overwritten by the user.
  35860. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35861. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35862. * @param update the boolean update value actually passed to setParticles()
  35863. */
  35864. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35865. /**
  35866. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  35867. * This will be passed three parameters.
  35868. * This does nothing and may be overwritten by the user.
  35869. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35870. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35871. * @param update the boolean update value actually passed to setParticles()
  35872. */
  35873. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35874. }
  35875. }
  35876. declare module BABYLON {
  35877. /**
  35878. * Represents one particle of a solid particle system.
  35879. */
  35880. export class SolidParticle {
  35881. /**
  35882. * particle global index
  35883. */
  35884. idx: number;
  35885. /**
  35886. * particle identifier
  35887. */
  35888. id: number;
  35889. /**
  35890. * The color of the particle
  35891. */
  35892. color: Nullable<Color4>;
  35893. /**
  35894. * The world space position of the particle.
  35895. */
  35896. position: Vector3;
  35897. /**
  35898. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  35899. */
  35900. rotation: Vector3;
  35901. /**
  35902. * The world space rotation quaternion of the particle.
  35903. */
  35904. rotationQuaternion: Nullable<Quaternion>;
  35905. /**
  35906. * The scaling of the particle.
  35907. */
  35908. scaling: Vector3;
  35909. /**
  35910. * The uvs of the particle.
  35911. */
  35912. uvs: Vector4;
  35913. /**
  35914. * The current speed of the particle.
  35915. */
  35916. velocity: Vector3;
  35917. /**
  35918. * The pivot point in the particle local space.
  35919. */
  35920. pivot: Vector3;
  35921. /**
  35922. * Must the particle be translated from its pivot point in its local space ?
  35923. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  35924. * Default : false
  35925. */
  35926. translateFromPivot: boolean;
  35927. /**
  35928. * Is the particle active or not ?
  35929. */
  35930. alive: boolean;
  35931. /**
  35932. * Is the particle visible or not ?
  35933. */
  35934. isVisible: boolean;
  35935. /**
  35936. * Index of this particle in the global "positions" array (Internal use)
  35937. * @hidden
  35938. */
  35939. _pos: number;
  35940. /**
  35941. * @hidden Index of this particle in the global "indices" array (Internal use)
  35942. */
  35943. _ind: number;
  35944. /**
  35945. * @hidden ModelShape of this particle (Internal use)
  35946. */
  35947. _model: ModelShape;
  35948. /**
  35949. * ModelShape id of this particle
  35950. */
  35951. shapeId: number;
  35952. /**
  35953. * Index of the particle in its shape id
  35954. */
  35955. idxInShape: number;
  35956. /**
  35957. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  35958. */
  35959. _modelBoundingInfo: BoundingInfo;
  35960. /**
  35961. * @hidden Particle BoundingInfo object (Internal use)
  35962. */
  35963. _boundingInfo: BoundingInfo;
  35964. /**
  35965. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  35966. */
  35967. _sps: SolidParticleSystem;
  35968. /**
  35969. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  35970. */
  35971. _stillInvisible: boolean;
  35972. /**
  35973. * @hidden Last computed particle rotation matrix
  35974. */
  35975. _rotationMatrix: number[];
  35976. /**
  35977. * Parent particle Id, if any.
  35978. * Default null.
  35979. */
  35980. parentId: Nullable<number>;
  35981. /**
  35982. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  35983. */
  35984. materialIndex: Nullable<number>;
  35985. /**
  35986. * Custom object or properties.
  35987. */
  35988. props: Nullable<any>;
  35989. /**
  35990. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  35991. * The possible values are :
  35992. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35993. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35994. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35995. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35996. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35997. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  35998. * */
  35999. cullingStrategy: number;
  36000. /**
  36001. * @hidden Internal global position in the SPS.
  36002. */
  36003. _globalPosition: Vector3;
  36004. /**
  36005. * Creates a Solid Particle object.
  36006. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  36007. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  36008. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  36009. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  36010. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  36011. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  36012. * @param shapeId (integer) is the model shape identifier in the SPS.
  36013. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  36014. * @param sps defines the sps it is associated to
  36015. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  36016. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  36017. */
  36018. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  36019. /**
  36020. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  36021. * @param target the particle target
  36022. * @returns the current particle
  36023. */
  36024. copyToRef(target: SolidParticle): SolidParticle;
  36025. /**
  36026. * Legacy support, changed scale to scaling
  36027. */
  36028. get scale(): Vector3;
  36029. /**
  36030. * Legacy support, changed scale to scaling
  36031. */
  36032. set scale(scale: Vector3);
  36033. /**
  36034. * Legacy support, changed quaternion to rotationQuaternion
  36035. */
  36036. get quaternion(): Nullable<Quaternion>;
  36037. /**
  36038. * Legacy support, changed quaternion to rotationQuaternion
  36039. */
  36040. set quaternion(q: Nullable<Quaternion>);
  36041. /**
  36042. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  36043. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  36044. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  36045. * @returns true if it intersects
  36046. */
  36047. intersectsMesh(target: Mesh | SolidParticle): boolean;
  36048. /**
  36049. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  36050. * A particle is in the frustum if its bounding box intersects the frustum
  36051. * @param frustumPlanes defines the frustum to test
  36052. * @returns true if the particle is in the frustum planes
  36053. */
  36054. isInFrustum(frustumPlanes: Plane[]): boolean;
  36055. /**
  36056. * get the rotation matrix of the particle
  36057. * @hidden
  36058. */
  36059. getRotationMatrix(m: Matrix): void;
  36060. }
  36061. /**
  36062. * Represents the shape of the model used by one particle of a solid particle system.
  36063. * SPS internal tool, don't use it manually.
  36064. */
  36065. export class ModelShape {
  36066. /**
  36067. * The shape id
  36068. * @hidden
  36069. */
  36070. shapeID: number;
  36071. /**
  36072. * flat array of model positions (internal use)
  36073. * @hidden
  36074. */
  36075. _shape: Vector3[];
  36076. /**
  36077. * flat array of model UVs (internal use)
  36078. * @hidden
  36079. */
  36080. _shapeUV: number[];
  36081. /**
  36082. * color array of the model
  36083. * @hidden
  36084. */
  36085. _shapeColors: number[];
  36086. /**
  36087. * indices array of the model
  36088. * @hidden
  36089. */
  36090. _indices: number[];
  36091. /**
  36092. * normals array of the model
  36093. * @hidden
  36094. */
  36095. _normals: number[];
  36096. /**
  36097. * length of the shape in the model indices array (internal use)
  36098. * @hidden
  36099. */
  36100. _indicesLength: number;
  36101. /**
  36102. * Custom position function (internal use)
  36103. * @hidden
  36104. */
  36105. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  36106. /**
  36107. * Custom vertex function (internal use)
  36108. * @hidden
  36109. */
  36110. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  36111. /**
  36112. * Model material (internal use)
  36113. * @hidden
  36114. */
  36115. _material: Nullable<Material>;
  36116. /**
  36117. * 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.
  36118. * SPS internal tool, don't use it manually.
  36119. * @hidden
  36120. */
  36121. 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>);
  36122. }
  36123. /**
  36124. * Represents a Depth Sorted Particle in the solid particle system.
  36125. * @hidden
  36126. */
  36127. export class DepthSortedParticle {
  36128. /**
  36129. * Particle index
  36130. */
  36131. idx: number;
  36132. /**
  36133. * Index of the particle in the "indices" array
  36134. */
  36135. ind: number;
  36136. /**
  36137. * Length of the particle shape in the "indices" array
  36138. */
  36139. indicesLength: number;
  36140. /**
  36141. * Squared distance from the particle to the camera
  36142. */
  36143. sqDistance: number;
  36144. /**
  36145. * Material index when used with MultiMaterials
  36146. */
  36147. materialIndex: number;
  36148. /**
  36149. * Creates a new sorted particle
  36150. * @param materialIndex
  36151. */
  36152. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  36153. }
  36154. /**
  36155. * Represents a solid particle vertex
  36156. */
  36157. export class SolidParticleVertex {
  36158. /**
  36159. * Vertex position
  36160. */
  36161. position: Vector3;
  36162. /**
  36163. * Vertex color
  36164. */
  36165. color: Color4;
  36166. /**
  36167. * Vertex UV
  36168. */
  36169. uv: Vector2;
  36170. /**
  36171. * Creates a new solid particle vertex
  36172. */
  36173. constructor();
  36174. /** Vertex x coordinate */
  36175. get x(): number;
  36176. set x(val: number);
  36177. /** Vertex y coordinate */
  36178. get y(): number;
  36179. set y(val: number);
  36180. /** Vertex z coordinate */
  36181. get z(): number;
  36182. set z(val: number);
  36183. }
  36184. }
  36185. declare module BABYLON {
  36186. /**
  36187. * @hidden
  36188. */
  36189. export class _MeshCollisionData {
  36190. _checkCollisions: boolean;
  36191. _collisionMask: number;
  36192. _collisionGroup: number;
  36193. _surroundingMeshes: Nullable<AbstractMesh[]>;
  36194. _collider: Nullable<Collider>;
  36195. _oldPositionForCollisions: Vector3;
  36196. _diffPositionForCollisions: Vector3;
  36197. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  36198. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  36199. _collisionResponse: boolean;
  36200. }
  36201. }
  36202. declare module BABYLON {
  36203. /** @hidden */
  36204. class _FacetDataStorage {
  36205. facetPositions: Vector3[];
  36206. facetNormals: Vector3[];
  36207. facetPartitioning: number[][];
  36208. facetNb: number;
  36209. partitioningSubdivisions: number;
  36210. partitioningBBoxRatio: number;
  36211. facetDataEnabled: boolean;
  36212. facetParameters: any;
  36213. bbSize: Vector3;
  36214. subDiv: {
  36215. max: number;
  36216. X: number;
  36217. Y: number;
  36218. Z: number;
  36219. };
  36220. facetDepthSort: boolean;
  36221. facetDepthSortEnabled: boolean;
  36222. depthSortedIndices: IndicesArray;
  36223. depthSortedFacets: {
  36224. ind: number;
  36225. sqDistance: number;
  36226. }[];
  36227. facetDepthSortFunction: (f1: {
  36228. ind: number;
  36229. sqDistance: number;
  36230. }, f2: {
  36231. ind: number;
  36232. sqDistance: number;
  36233. }) => number;
  36234. facetDepthSortFrom: Vector3;
  36235. facetDepthSortOrigin: Vector3;
  36236. invertedMatrix: Matrix;
  36237. }
  36238. /**
  36239. * @hidden
  36240. **/
  36241. class _InternalAbstractMeshDataInfo {
  36242. _hasVertexAlpha: boolean;
  36243. _useVertexColors: boolean;
  36244. _numBoneInfluencers: number;
  36245. _applyFog: boolean;
  36246. _receiveShadows: boolean;
  36247. _facetData: _FacetDataStorage;
  36248. _visibility: number;
  36249. _skeleton: Nullable<Skeleton>;
  36250. _layerMask: number;
  36251. _computeBonesUsingShaders: boolean;
  36252. _isActive: boolean;
  36253. _onlyForInstances: boolean;
  36254. _isActiveIntermediate: boolean;
  36255. _onlyForInstancesIntermediate: boolean;
  36256. _actAsRegularMesh: boolean;
  36257. _currentLOD: Nullable<AbstractMesh>;
  36258. _currentLODIsUpToDate: boolean;
  36259. }
  36260. /**
  36261. * Class used to store all common mesh properties
  36262. */
  36263. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  36264. /** No occlusion */
  36265. static OCCLUSION_TYPE_NONE: number;
  36266. /** Occlusion set to optimistic */
  36267. static OCCLUSION_TYPE_OPTIMISTIC: number;
  36268. /** Occlusion set to strict */
  36269. static OCCLUSION_TYPE_STRICT: number;
  36270. /** Use an accurate occlusion algorithm */
  36271. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  36272. /** Use a conservative occlusion algorithm */
  36273. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  36274. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  36275. * Test order :
  36276. * Is the bounding sphere outside the frustum ?
  36277. * If not, are the bounding box vertices outside the frustum ?
  36278. * It not, then the cullable object is in the frustum.
  36279. */
  36280. static readonly CULLINGSTRATEGY_STANDARD: number;
  36281. /** Culling strategy : Bounding Sphere Only.
  36282. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  36283. * It's also less accurate than the standard because some not visible objects can still be selected.
  36284. * Test : is the bounding sphere outside the frustum ?
  36285. * If not, then the cullable object is in the frustum.
  36286. */
  36287. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  36288. /** Culling strategy : Optimistic Inclusion.
  36289. * This in an inclusion test first, then the standard exclusion test.
  36290. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  36291. * 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.
  36292. * Anyway, it's as accurate as the standard strategy.
  36293. * Test :
  36294. * Is the cullable object bounding sphere center in the frustum ?
  36295. * If not, apply the default culling strategy.
  36296. */
  36297. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  36298. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  36299. * This in an inclusion test first, then the bounding sphere only exclusion test.
  36300. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  36301. * 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.
  36302. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  36303. * Test :
  36304. * Is the cullable object bounding sphere center in the frustum ?
  36305. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  36306. */
  36307. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  36308. /**
  36309. * No billboard
  36310. */
  36311. static get BILLBOARDMODE_NONE(): number;
  36312. /** Billboard on X axis */
  36313. static get BILLBOARDMODE_X(): number;
  36314. /** Billboard on Y axis */
  36315. static get BILLBOARDMODE_Y(): number;
  36316. /** Billboard on Z axis */
  36317. static get BILLBOARDMODE_Z(): number;
  36318. /** Billboard on all axes */
  36319. static get BILLBOARDMODE_ALL(): number;
  36320. /** Billboard on using position instead of orientation */
  36321. static get BILLBOARDMODE_USE_POSITION(): number;
  36322. /** @hidden */
  36323. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  36324. /**
  36325. * The culling strategy to use to check whether the mesh must be rendered or not.
  36326. * This value can be changed at any time and will be used on the next render mesh selection.
  36327. * The possible values are :
  36328. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36329. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36330. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36331. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36332. * Please read each static variable documentation to get details about the culling process.
  36333. * */
  36334. cullingStrategy: number;
  36335. /**
  36336. * Gets the number of facets in the mesh
  36337. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36338. */
  36339. get facetNb(): number;
  36340. /**
  36341. * Gets or set the number (integer) of subdivisions per axis in the partitioning space
  36342. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36343. */
  36344. get partitioningSubdivisions(): number;
  36345. set partitioningSubdivisions(nb: number);
  36346. /**
  36347. * The ratio (float) to apply to the bounding box size to set to the partitioning space.
  36348. * Ex : 1.01 (default) the partitioning space is 1% bigger than the bounding box
  36349. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36350. */
  36351. get partitioningBBoxRatio(): number;
  36352. set partitioningBBoxRatio(ratio: number);
  36353. /**
  36354. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36355. * Works only for updatable meshes.
  36356. * Doesn't work with multi-materials
  36357. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36358. */
  36359. get mustDepthSortFacets(): boolean;
  36360. set mustDepthSortFacets(sort: boolean);
  36361. /**
  36362. * The location (Vector3) where the facet depth sort must be computed from.
  36363. * By default, the active camera position.
  36364. * Used only when facet depth sort is enabled
  36365. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36366. */
  36367. get facetDepthSortFrom(): Vector3;
  36368. set facetDepthSortFrom(location: Vector3);
  36369. /**
  36370. * gets a boolean indicating if facetData is enabled
  36371. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36372. */
  36373. get isFacetDataEnabled(): boolean;
  36374. /** @hidden */
  36375. _updateNonUniformScalingState(value: boolean): boolean;
  36376. /**
  36377. * An event triggered when this mesh collides with another one
  36378. */
  36379. onCollideObservable: Observable<AbstractMesh>;
  36380. /** Set a function to call when this mesh collides with another one */
  36381. set onCollide(callback: () => void);
  36382. /**
  36383. * An event triggered when the collision's position changes
  36384. */
  36385. onCollisionPositionChangeObservable: Observable<Vector3>;
  36386. /** Set a function to call when the collision's position changes */
  36387. set onCollisionPositionChange(callback: () => void);
  36388. /**
  36389. * An event triggered when material is changed
  36390. */
  36391. onMaterialChangedObservable: Observable<AbstractMesh>;
  36392. /**
  36393. * Gets or sets the orientation for POV movement & rotation
  36394. */
  36395. definedFacingForward: boolean;
  36396. /** @hidden */
  36397. _occlusionQuery: Nullable<WebGLQuery>;
  36398. /** @hidden */
  36399. _renderingGroup: Nullable<RenderingGroup>;
  36400. /**
  36401. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36402. */
  36403. get visibility(): number;
  36404. /**
  36405. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36406. */
  36407. set visibility(value: number);
  36408. /** Gets or sets the alpha index used to sort transparent meshes
  36409. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36410. */
  36411. alphaIndex: number;
  36412. /**
  36413. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36414. */
  36415. isVisible: boolean;
  36416. /**
  36417. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36418. */
  36419. isPickable: boolean;
  36420. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36421. showSubMeshesBoundingBox: boolean;
  36422. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36423. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36424. */
  36425. isBlocker: boolean;
  36426. /**
  36427. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36428. */
  36429. enablePointerMoveEvents: boolean;
  36430. private _renderingGroupId;
  36431. /**
  36432. * Specifies the rendering group id for this mesh (0 by default)
  36433. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36434. */
  36435. get renderingGroupId(): number;
  36436. set renderingGroupId(value: number);
  36437. private _material;
  36438. /** Gets or sets current material */
  36439. get material(): Nullable<Material>;
  36440. set material(value: Nullable<Material>);
  36441. /**
  36442. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36443. * @see https://doc.babylonjs.com/babylon101/shadows
  36444. */
  36445. get receiveShadows(): boolean;
  36446. set receiveShadows(value: boolean);
  36447. /** Defines color to use when rendering outline */
  36448. outlineColor: Color3;
  36449. /** Define width to use when rendering outline */
  36450. outlineWidth: number;
  36451. /** Defines color to use when rendering overlay */
  36452. overlayColor: Color3;
  36453. /** Defines alpha to use when rendering overlay */
  36454. overlayAlpha: number;
  36455. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36456. get hasVertexAlpha(): boolean;
  36457. set hasVertexAlpha(value: boolean);
  36458. /** 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) */
  36459. get useVertexColors(): boolean;
  36460. set useVertexColors(value: boolean);
  36461. /**
  36462. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36463. */
  36464. get computeBonesUsingShaders(): boolean;
  36465. set computeBonesUsingShaders(value: boolean);
  36466. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36467. get numBoneInfluencers(): number;
  36468. set numBoneInfluencers(value: number);
  36469. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36470. get applyFog(): boolean;
  36471. set applyFog(value: boolean);
  36472. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36473. useOctreeForRenderingSelection: boolean;
  36474. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36475. useOctreeForPicking: boolean;
  36476. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36477. useOctreeForCollisions: boolean;
  36478. /**
  36479. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36480. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36481. */
  36482. get layerMask(): number;
  36483. set layerMask(value: number);
  36484. /**
  36485. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36486. */
  36487. alwaysSelectAsActiveMesh: boolean;
  36488. /**
  36489. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36490. */
  36491. doNotSyncBoundingInfo: boolean;
  36492. /**
  36493. * Gets or sets the current action manager
  36494. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36495. */
  36496. actionManager: Nullable<AbstractActionManager>;
  36497. private _meshCollisionData;
  36498. /**
  36499. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36500. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36501. */
  36502. ellipsoid: Vector3;
  36503. /**
  36504. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36505. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36506. */
  36507. ellipsoidOffset: Vector3;
  36508. /**
  36509. * Gets or sets a collision mask used to mask collisions (default is -1).
  36510. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36511. */
  36512. get collisionMask(): number;
  36513. set collisionMask(mask: number);
  36514. /**
  36515. * Gets or sets a collision response flag (default is true).
  36516. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36517. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36518. * to respond to the collision.
  36519. */
  36520. get collisionResponse(): boolean;
  36521. set collisionResponse(response: boolean);
  36522. /**
  36523. * Gets or sets the current collision group mask (-1 by default).
  36524. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36525. */
  36526. get collisionGroup(): number;
  36527. set collisionGroup(mask: number);
  36528. /**
  36529. * Gets or sets current surrounding meshes (null by default).
  36530. *
  36531. * By default collision detection is tested against every mesh in the scene.
  36532. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36533. * meshes will be tested for the collision.
  36534. *
  36535. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36536. */
  36537. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36538. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36539. /**
  36540. * Defines edge width used when edgesRenderer is enabled
  36541. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36542. */
  36543. edgesWidth: number;
  36544. /**
  36545. * Defines edge color used when edgesRenderer is enabled
  36546. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36547. */
  36548. edgesColor: Color4;
  36549. /** @hidden */
  36550. _edgesRenderer: Nullable<IEdgesRenderer>;
  36551. /** @hidden */
  36552. _masterMesh: Nullable<AbstractMesh>;
  36553. /** @hidden */
  36554. _boundingInfo: Nullable<BoundingInfo>;
  36555. /** @hidden */
  36556. _renderId: number;
  36557. /**
  36558. * Gets or sets the list of subMeshes
  36559. * @see https://doc.babylonjs.com/how_to/multi_materials
  36560. */
  36561. subMeshes: SubMesh[];
  36562. /** @hidden */
  36563. _intersectionsInProgress: AbstractMesh[];
  36564. /** @hidden */
  36565. _unIndexed: boolean;
  36566. /** @hidden */
  36567. _lightSources: Light[];
  36568. /** Gets the list of lights affecting that mesh */
  36569. get lightSources(): Light[];
  36570. /** @hidden */
  36571. get _positions(): Nullable<Vector3[]>;
  36572. /** @hidden */
  36573. _waitingData: {
  36574. lods: Nullable<any>;
  36575. actions: Nullable<any>;
  36576. freezeWorldMatrix: Nullable<boolean>;
  36577. };
  36578. /** @hidden */
  36579. _bonesTransformMatrices: Nullable<Float32Array>;
  36580. /** @hidden */
  36581. _transformMatrixTexture: Nullable<RawTexture>;
  36582. /**
  36583. * Gets or sets a skeleton to apply skinning transformations
  36584. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36585. */
  36586. set skeleton(value: Nullable<Skeleton>);
  36587. get skeleton(): Nullable<Skeleton>;
  36588. /**
  36589. * An event triggered when the mesh is rebuilt.
  36590. */
  36591. onRebuildObservable: Observable<AbstractMesh>;
  36592. /**
  36593. * The current mesh uniform buffer.
  36594. * @hidden Internal use only.
  36595. */
  36596. _uniformBuffer: UniformBuffer;
  36597. /**
  36598. * Creates a new AbstractMesh
  36599. * @param name defines the name of the mesh
  36600. * @param scene defines the hosting scene
  36601. */
  36602. constructor(name: string, scene?: Nullable<Scene>);
  36603. protected _buildUniformLayout(): void;
  36604. /**
  36605. * Transfer the mesh values to its UBO.
  36606. * @param world The world matrix associated with the mesh
  36607. */
  36608. transferToEffect(world: Matrix): void;
  36609. /**
  36610. * Gets the mesh uniform buffer.
  36611. * @return the uniform buffer of the mesh.
  36612. */
  36613. getMeshUniformBuffer(): UniformBuffer;
  36614. /**
  36615. * Returns the string "AbstractMesh"
  36616. * @returns "AbstractMesh"
  36617. */
  36618. getClassName(): string;
  36619. /**
  36620. * Gets a string representation of the current mesh
  36621. * @param fullDetails defines a boolean indicating if full details must be included
  36622. * @returns a string representation of the current mesh
  36623. */
  36624. toString(fullDetails?: boolean): string;
  36625. /**
  36626. * @hidden
  36627. */
  36628. protected _getEffectiveParent(): Nullable<Node>;
  36629. /** @hidden */
  36630. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36631. /** @hidden */
  36632. _rebuild(): void;
  36633. /** @hidden */
  36634. _resyncLightSources(): void;
  36635. /** @hidden */
  36636. _resyncLightSource(light: Light): void;
  36637. /** @hidden */
  36638. _unBindEffect(): void;
  36639. /** @hidden */
  36640. _removeLightSource(light: Light, dispose: boolean): void;
  36641. private _markSubMeshesAsDirty;
  36642. /** @hidden */
  36643. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36644. /** @hidden */
  36645. _markSubMeshesAsAttributesDirty(): void;
  36646. /** @hidden */
  36647. _markSubMeshesAsMiscDirty(): void;
  36648. /**
  36649. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36650. */
  36651. get scaling(): Vector3;
  36652. set scaling(newScaling: Vector3);
  36653. /**
  36654. * Returns true if the mesh is blocked. Implemented by child classes
  36655. */
  36656. get isBlocked(): boolean;
  36657. /**
  36658. * Returns the mesh itself by default. Implemented by child classes
  36659. * @param camera defines the camera to use to pick the right LOD level
  36660. * @returns the currentAbstractMesh
  36661. */
  36662. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36663. /**
  36664. * Returns 0 by default. Implemented by child classes
  36665. * @returns an integer
  36666. */
  36667. getTotalVertices(): number;
  36668. /**
  36669. * Returns a positive integer : the total number of indices in this mesh geometry.
  36670. * @returns the number of indices or zero if the mesh has no geometry.
  36671. */
  36672. getTotalIndices(): number;
  36673. /**
  36674. * Returns null by default. Implemented by child classes
  36675. * @returns null
  36676. */
  36677. getIndices(): Nullable<IndicesArray>;
  36678. /**
  36679. * Returns the array of the requested vertex data kind. Implemented by child classes
  36680. * @param kind defines the vertex data kind to use
  36681. * @returns null
  36682. */
  36683. getVerticesData(kind: string): Nullable<FloatArray>;
  36684. /**
  36685. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36686. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36687. * Note that a new underlying VertexBuffer object is created each call.
  36688. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36689. * @param kind defines vertex data kind:
  36690. * * VertexBuffer.PositionKind
  36691. * * VertexBuffer.UVKind
  36692. * * VertexBuffer.UV2Kind
  36693. * * VertexBuffer.UV3Kind
  36694. * * VertexBuffer.UV4Kind
  36695. * * VertexBuffer.UV5Kind
  36696. * * VertexBuffer.UV6Kind
  36697. * * VertexBuffer.ColorKind
  36698. * * VertexBuffer.MatricesIndicesKind
  36699. * * VertexBuffer.MatricesIndicesExtraKind
  36700. * * VertexBuffer.MatricesWeightsKind
  36701. * * VertexBuffer.MatricesWeightsExtraKind
  36702. * @param data defines the data source
  36703. * @param updatable defines if the data must be flagged as updatable (or static)
  36704. * @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
  36705. * @returns the current mesh
  36706. */
  36707. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36708. /**
  36709. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36710. * If the mesh has no geometry, it is simply returned as it is.
  36711. * @param kind defines vertex data kind:
  36712. * * VertexBuffer.PositionKind
  36713. * * VertexBuffer.UVKind
  36714. * * VertexBuffer.UV2Kind
  36715. * * VertexBuffer.UV3Kind
  36716. * * VertexBuffer.UV4Kind
  36717. * * VertexBuffer.UV5Kind
  36718. * * VertexBuffer.UV6Kind
  36719. * * VertexBuffer.ColorKind
  36720. * * VertexBuffer.MatricesIndicesKind
  36721. * * VertexBuffer.MatricesIndicesExtraKind
  36722. * * VertexBuffer.MatricesWeightsKind
  36723. * * VertexBuffer.MatricesWeightsExtraKind
  36724. * @param data defines the data source
  36725. * @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
  36726. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  36727. * @returns the current mesh
  36728. */
  36729. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  36730. /**
  36731. * Sets the mesh indices,
  36732. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  36733. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  36734. * @param totalVertices Defines the total number of vertices
  36735. * @returns the current mesh
  36736. */
  36737. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  36738. /**
  36739. * Gets a boolean indicating if specific vertex data is present
  36740. * @param kind defines the vertex data kind to use
  36741. * @returns true is data kind is present
  36742. */
  36743. isVerticesDataPresent(kind: string): boolean;
  36744. /**
  36745. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  36746. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  36747. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  36748. * @returns a BoundingInfo
  36749. */
  36750. getBoundingInfo(): BoundingInfo;
  36751. /**
  36752. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  36753. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  36754. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  36755. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  36756. * @returns the current mesh
  36757. */
  36758. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  36759. /**
  36760. * Overwrite the current bounding info
  36761. * @param boundingInfo defines the new bounding info
  36762. * @returns the current mesh
  36763. */
  36764. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  36765. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  36766. get useBones(): boolean;
  36767. /** @hidden */
  36768. _preActivate(): void;
  36769. /** @hidden */
  36770. _preActivateForIntermediateRendering(renderId: number): void;
  36771. /** @hidden */
  36772. _activate(renderId: number, intermediateRendering: boolean): boolean;
  36773. /** @hidden */
  36774. _postActivate(): void;
  36775. /** @hidden */
  36776. _freeze(): void;
  36777. /** @hidden */
  36778. _unFreeze(): void;
  36779. /**
  36780. * Gets the current world matrix
  36781. * @returns a Matrix
  36782. */
  36783. getWorldMatrix(): Matrix;
  36784. /** @hidden */
  36785. _getWorldMatrixDeterminant(): number;
  36786. /**
  36787. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  36788. */
  36789. get isAnInstance(): boolean;
  36790. /**
  36791. * Gets a boolean indicating if this mesh has instances
  36792. */
  36793. get hasInstances(): boolean;
  36794. /**
  36795. * Gets a boolean indicating if this mesh has thin instances
  36796. */
  36797. get hasThinInstances(): boolean;
  36798. /**
  36799. * Perform relative position change from the point of view of behind the front of the mesh.
  36800. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36801. * Supports definition of mesh facing forward or backward
  36802. * @param amountRight defines the distance on the right axis
  36803. * @param amountUp defines the distance on the up axis
  36804. * @param amountForward defines the distance on the forward axis
  36805. * @returns the current mesh
  36806. */
  36807. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  36808. /**
  36809. * Calculate relative position change from the point of view of behind the front of the mesh.
  36810. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36811. * Supports definition of mesh facing forward or backward
  36812. * @param amountRight defines the distance on the right axis
  36813. * @param amountUp defines the distance on the up axis
  36814. * @param amountForward defines the distance on the forward axis
  36815. * @returns the new displacement vector
  36816. */
  36817. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  36818. /**
  36819. * Perform relative rotation change from the point of view of behind the front of the mesh.
  36820. * Supports definition of mesh facing forward or backward
  36821. * @param flipBack defines the flip
  36822. * @param twirlClockwise defines the twirl
  36823. * @param tiltRight defines the tilt
  36824. * @returns the current mesh
  36825. */
  36826. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  36827. /**
  36828. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  36829. * Supports definition of mesh facing forward or backward.
  36830. * @param flipBack defines the flip
  36831. * @param twirlClockwise defines the twirl
  36832. * @param tiltRight defines the tilt
  36833. * @returns the new rotation vector
  36834. */
  36835. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  36836. /**
  36837. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  36838. * This means the mesh underlying bounding box and sphere are recomputed.
  36839. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  36840. * @returns the current mesh
  36841. */
  36842. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  36843. /** @hidden */
  36844. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  36845. /** @hidden */
  36846. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  36847. /** @hidden */
  36848. _updateBoundingInfo(): AbstractMesh;
  36849. /** @hidden */
  36850. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  36851. /** @hidden */
  36852. protected _afterComputeWorldMatrix(): void;
  36853. /** @hidden */
  36854. get _effectiveMesh(): AbstractMesh;
  36855. /**
  36856. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  36857. * A mesh is in the frustum if its bounding box intersects the frustum
  36858. * @param frustumPlanes defines the frustum to test
  36859. * @returns true if the mesh is in the frustum planes
  36860. */
  36861. isInFrustum(frustumPlanes: Plane[]): boolean;
  36862. /**
  36863. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  36864. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  36865. * @param frustumPlanes defines the frustum to test
  36866. * @returns true if the mesh is completely in the frustum planes
  36867. */
  36868. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  36869. /**
  36870. * True if the mesh intersects another mesh or a SolidParticle object
  36871. * @param mesh defines a target mesh or SolidParticle to test
  36872. * @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)
  36873. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  36874. * @returns true if there is an intersection
  36875. */
  36876. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  36877. /**
  36878. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  36879. * @param point defines the point to test
  36880. * @returns true if there is an intersection
  36881. */
  36882. intersectsPoint(point: Vector3): boolean;
  36883. /**
  36884. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  36885. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36886. */
  36887. get checkCollisions(): boolean;
  36888. set checkCollisions(collisionEnabled: boolean);
  36889. /**
  36890. * Gets Collider object used to compute collisions (not physics)
  36891. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36892. */
  36893. get collider(): Nullable<Collider>;
  36894. /**
  36895. * Move the mesh using collision engine
  36896. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36897. * @param displacement defines the requested displacement vector
  36898. * @returns the current mesh
  36899. */
  36900. moveWithCollisions(displacement: Vector3): AbstractMesh;
  36901. private _onCollisionPositionChange;
  36902. /** @hidden */
  36903. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  36904. /** @hidden */
  36905. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  36906. /** @hidden */
  36907. _checkCollision(collider: Collider): AbstractMesh;
  36908. /** @hidden */
  36909. _generatePointsArray(): boolean;
  36910. /**
  36911. * Checks if the passed Ray intersects with the mesh
  36912. * @param ray defines the ray to use
  36913. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  36914. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36915. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  36916. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  36917. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  36918. * @returns the picking info
  36919. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  36920. */
  36921. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  36922. /**
  36923. * Clones the current mesh
  36924. * @param name defines the mesh name
  36925. * @param newParent defines the new mesh parent
  36926. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  36927. * @returns the new mesh
  36928. */
  36929. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  36930. /**
  36931. * Disposes all the submeshes of the current meshnp
  36932. * @returns the current mesh
  36933. */
  36934. releaseSubMeshes(): AbstractMesh;
  36935. /**
  36936. * Releases resources associated with this abstract mesh.
  36937. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36938. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36939. */
  36940. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36941. /**
  36942. * Adds the passed mesh as a child to the current mesh
  36943. * @param mesh defines the child mesh
  36944. * @returns the current mesh
  36945. */
  36946. addChild(mesh: AbstractMesh): AbstractMesh;
  36947. /**
  36948. * Removes the passed mesh from the current mesh children list
  36949. * @param mesh defines the child mesh
  36950. * @returns the current mesh
  36951. */
  36952. removeChild(mesh: AbstractMesh): AbstractMesh;
  36953. /** @hidden */
  36954. private _initFacetData;
  36955. /**
  36956. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  36957. * This method can be called within the render loop.
  36958. * 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
  36959. * @returns the current mesh
  36960. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36961. */
  36962. updateFacetData(): AbstractMesh;
  36963. /**
  36964. * Returns the facetLocalNormals array.
  36965. * The normals are expressed in the mesh local spac
  36966. * @returns an array of Vector3
  36967. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36968. */
  36969. getFacetLocalNormals(): Vector3[];
  36970. /**
  36971. * Returns the facetLocalPositions array.
  36972. * The facet positions are expressed in the mesh local space
  36973. * @returns an array of Vector3
  36974. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36975. */
  36976. getFacetLocalPositions(): Vector3[];
  36977. /**
  36978. * Returns the facetLocalPartitioning array
  36979. * @returns an array of array of numbers
  36980. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36981. */
  36982. getFacetLocalPartitioning(): number[][];
  36983. /**
  36984. * Returns the i-th facet position in the world system.
  36985. * This method allocates a new Vector3 per call
  36986. * @param i defines the facet index
  36987. * @returns a new Vector3
  36988. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36989. */
  36990. getFacetPosition(i: number): Vector3;
  36991. /**
  36992. * Sets the reference Vector3 with the i-th facet position in the world system
  36993. * @param i defines the facet index
  36994. * @param ref defines the target vector
  36995. * @returns the current mesh
  36996. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36997. */
  36998. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  36999. /**
  37000. * Returns the i-th facet normal in the world system.
  37001. * This method allocates a new Vector3 per call
  37002. * @param i defines the facet index
  37003. * @returns a new Vector3
  37004. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37005. */
  37006. getFacetNormal(i: number): Vector3;
  37007. /**
  37008. * Sets the reference Vector3 with the i-th facet normal in the world system
  37009. * @param i defines the facet index
  37010. * @param ref defines the target vector
  37011. * @returns the current mesh
  37012. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37013. */
  37014. getFacetNormalToRef(i: number, ref: Vector3): this;
  37015. /**
  37016. * 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)
  37017. * @param x defines x coordinate
  37018. * @param y defines y coordinate
  37019. * @param z defines z coordinate
  37020. * @returns the array of facet indexes
  37021. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37022. */
  37023. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  37024. /**
  37025. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  37026. * @param projected sets as the (x,y,z) world projection on the facet
  37027. * @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
  37028. * @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
  37029. * @param x defines x coordinate
  37030. * @param y defines y coordinate
  37031. * @param z defines z coordinate
  37032. * @returns the face index if found (or null instead)
  37033. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37034. */
  37035. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37036. /**
  37037. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  37038. * @param projected sets as the (x,y,z) local projection on the facet
  37039. * @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
  37040. * @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
  37041. * @param x defines x coordinate
  37042. * @param y defines y coordinate
  37043. * @param z defines z coordinate
  37044. * @returns the face index if found (or null instead)
  37045. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37046. */
  37047. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37048. /**
  37049. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  37050. * @returns the parameters
  37051. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37052. */
  37053. getFacetDataParameters(): any;
  37054. /**
  37055. * Disables the feature FacetData and frees the related memory
  37056. * @returns the current mesh
  37057. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37058. */
  37059. disableFacetData(): AbstractMesh;
  37060. /**
  37061. * Updates the AbstractMesh indices array
  37062. * @param indices defines the data source
  37063. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  37064. * @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)
  37065. * @returns the current mesh
  37066. */
  37067. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  37068. /**
  37069. * Creates new normals data for the mesh
  37070. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  37071. * @returns the current mesh
  37072. */
  37073. createNormals(updatable: boolean): AbstractMesh;
  37074. /**
  37075. * Align the mesh with a normal
  37076. * @param normal defines the normal to use
  37077. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  37078. * @returns the current mesh
  37079. */
  37080. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  37081. /** @hidden */
  37082. _checkOcclusionQuery(): boolean;
  37083. /**
  37084. * Disables the mesh edge rendering mode
  37085. * @returns the currentAbstractMesh
  37086. */
  37087. disableEdgesRendering(): AbstractMesh;
  37088. /**
  37089. * Enables the edge rendering mode on the mesh.
  37090. * This mode makes the mesh edges visible
  37091. * @param epsilon defines the maximal distance between two angles to detect a face
  37092. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  37093. * @param options options to the edge renderer
  37094. * @returns the currentAbstractMesh
  37095. * @see https://www.babylonjs-playground.com/#19O9TU#0
  37096. */
  37097. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  37098. /**
  37099. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  37100. * @returns an array of particle systems in the scene that use the mesh as an emitter
  37101. */
  37102. getConnectedParticleSystems(): IParticleSystem[];
  37103. }
  37104. }
  37105. declare module BABYLON {
  37106. /**
  37107. * Interface used to define ActionEvent
  37108. */
  37109. export interface IActionEvent {
  37110. /** The mesh or sprite that triggered the action */
  37111. source: any;
  37112. /** The X mouse cursor position at the time of the event */
  37113. pointerX: number;
  37114. /** The Y mouse cursor position at the time of the event */
  37115. pointerY: number;
  37116. /** The mesh that is currently pointed at (can be null) */
  37117. meshUnderPointer: Nullable<AbstractMesh>;
  37118. /** the original (browser) event that triggered the ActionEvent */
  37119. sourceEvent?: any;
  37120. /** additional data for the event */
  37121. additionalData?: any;
  37122. }
  37123. /**
  37124. * ActionEvent is the event being sent when an action is triggered.
  37125. */
  37126. export class ActionEvent implements IActionEvent {
  37127. /** The mesh or sprite that triggered the action */
  37128. source: any;
  37129. /** The X mouse cursor position at the time of the event */
  37130. pointerX: number;
  37131. /** The Y mouse cursor position at the time of the event */
  37132. pointerY: number;
  37133. /** The mesh that is currently pointed at (can be null) */
  37134. meshUnderPointer: Nullable<AbstractMesh>;
  37135. /** the original (browser) event that triggered the ActionEvent */
  37136. sourceEvent?: any;
  37137. /** additional data for the event */
  37138. additionalData?: any;
  37139. /**
  37140. * Creates a new ActionEvent
  37141. * @param source The mesh or sprite that triggered the action
  37142. * @param pointerX The X mouse cursor position at the time of the event
  37143. * @param pointerY The Y mouse cursor position at the time of the event
  37144. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  37145. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  37146. * @param additionalData additional data for the event
  37147. */
  37148. constructor(
  37149. /** The mesh or sprite that triggered the action */
  37150. source: any,
  37151. /** The X mouse cursor position at the time of the event */
  37152. pointerX: number,
  37153. /** The Y mouse cursor position at the time of the event */
  37154. pointerY: number,
  37155. /** The mesh that is currently pointed at (can be null) */
  37156. meshUnderPointer: Nullable<AbstractMesh>,
  37157. /** the original (browser) event that triggered the ActionEvent */
  37158. sourceEvent?: any,
  37159. /** additional data for the event */
  37160. additionalData?: any);
  37161. /**
  37162. * Helper function to auto-create an ActionEvent from a source mesh.
  37163. * @param source The source mesh that triggered the event
  37164. * @param evt The original (browser) event
  37165. * @param additionalData additional data for the event
  37166. * @returns the new ActionEvent
  37167. */
  37168. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  37169. /**
  37170. * Helper function to auto-create an ActionEvent from a source sprite
  37171. * @param source The source sprite that triggered the event
  37172. * @param scene Scene associated with the sprite
  37173. * @param evt The original (browser) event
  37174. * @param additionalData additional data for the event
  37175. * @returns the new ActionEvent
  37176. */
  37177. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  37178. /**
  37179. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  37180. * @param scene the scene where the event occurred
  37181. * @param evt The original (browser) event
  37182. * @returns the new ActionEvent
  37183. */
  37184. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  37185. /**
  37186. * Helper function to auto-create an ActionEvent from a primitive
  37187. * @param prim defines the target primitive
  37188. * @param pointerPos defines the pointer position
  37189. * @param evt The original (browser) event
  37190. * @param additionalData additional data for the event
  37191. * @returns the new ActionEvent
  37192. */
  37193. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  37194. }
  37195. }
  37196. declare module BABYLON {
  37197. /**
  37198. * Abstract class used to decouple action Manager from scene and meshes.
  37199. * Do not instantiate.
  37200. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37201. */
  37202. export abstract class AbstractActionManager implements IDisposable {
  37203. /** Gets the list of active triggers */
  37204. static Triggers: {
  37205. [key: string]: number;
  37206. };
  37207. /** Gets the cursor to use when hovering items */
  37208. hoverCursor: string;
  37209. /** Gets the list of actions */
  37210. actions: IAction[];
  37211. /**
  37212. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  37213. */
  37214. isRecursive: boolean;
  37215. /**
  37216. * Releases all associated resources
  37217. */
  37218. abstract dispose(): void;
  37219. /**
  37220. * Does this action manager has pointer triggers
  37221. */
  37222. abstract get hasPointerTriggers(): boolean;
  37223. /**
  37224. * Does this action manager has pick triggers
  37225. */
  37226. abstract get hasPickTriggers(): boolean;
  37227. /**
  37228. * Process a specific trigger
  37229. * @param trigger defines the trigger to process
  37230. * @param evt defines the event details to be processed
  37231. */
  37232. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  37233. /**
  37234. * Does this action manager handles actions of any of the given triggers
  37235. * @param triggers defines the triggers to be tested
  37236. * @return a boolean indicating whether one (or more) of the triggers is handled
  37237. */
  37238. abstract hasSpecificTriggers(triggers: number[]): boolean;
  37239. /**
  37240. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  37241. * speed.
  37242. * @param triggerA defines the trigger to be tested
  37243. * @param triggerB defines the trigger to be tested
  37244. * @return a boolean indicating whether one (or more) of the triggers is handled
  37245. */
  37246. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  37247. /**
  37248. * Does this action manager handles actions of a given trigger
  37249. * @param trigger defines the trigger to be tested
  37250. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  37251. * @return whether the trigger is handled
  37252. */
  37253. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  37254. /**
  37255. * Serialize this manager to a JSON object
  37256. * @param name defines the property name to store this manager
  37257. * @returns a JSON representation of this manager
  37258. */
  37259. abstract serialize(name: string): any;
  37260. /**
  37261. * Registers an action to this action manager
  37262. * @param action defines the action to be registered
  37263. * @return the action amended (prepared) after registration
  37264. */
  37265. abstract registerAction(action: IAction): Nullable<IAction>;
  37266. /**
  37267. * Unregisters an action to this action manager
  37268. * @param action defines the action to be unregistered
  37269. * @return a boolean indicating whether the action has been unregistered
  37270. */
  37271. abstract unregisterAction(action: IAction): Boolean;
  37272. /**
  37273. * Does exist one action manager with at least one trigger
  37274. **/
  37275. static get HasTriggers(): boolean;
  37276. /**
  37277. * Does exist one action manager with at least one pick trigger
  37278. **/
  37279. static get HasPickTriggers(): boolean;
  37280. /**
  37281. * Does exist one action manager that handles actions of a given trigger
  37282. * @param trigger defines the trigger to be tested
  37283. * @return a boolean indicating whether the trigger is handled by at least one action manager
  37284. **/
  37285. static HasSpecificTrigger(trigger: number): boolean;
  37286. }
  37287. }
  37288. declare module BABYLON {
  37289. /**
  37290. * Defines how a node can be built from a string name.
  37291. */
  37292. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  37293. /**
  37294. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  37295. */
  37296. export class Node implements IBehaviorAware<Node> {
  37297. /** @hidden */
  37298. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  37299. private static _NodeConstructors;
  37300. /**
  37301. * Add a new node constructor
  37302. * @param type defines the type name of the node to construct
  37303. * @param constructorFunc defines the constructor function
  37304. */
  37305. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  37306. /**
  37307. * Returns a node constructor based on type name
  37308. * @param type defines the type name
  37309. * @param name defines the new node name
  37310. * @param scene defines the hosting scene
  37311. * @param options defines optional options to transmit to constructors
  37312. * @returns the new constructor or null
  37313. */
  37314. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  37315. /**
  37316. * Gets or sets the name of the node
  37317. */
  37318. name: string;
  37319. /**
  37320. * Gets or sets the id of the node
  37321. */
  37322. id: string;
  37323. /**
  37324. * Gets or sets the unique id of the node
  37325. */
  37326. uniqueId: number;
  37327. /**
  37328. * Gets or sets a string used to store user defined state for the node
  37329. */
  37330. state: string;
  37331. /**
  37332. * Gets or sets an object used to store user defined information for the node
  37333. */
  37334. metadata: any;
  37335. /**
  37336. * For internal use only. Please do not use.
  37337. */
  37338. reservedDataStore: any;
  37339. /**
  37340. * List of inspectable custom properties (used by the Inspector)
  37341. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37342. */
  37343. inspectableCustomProperties: IInspectable[];
  37344. private _doNotSerialize;
  37345. /**
  37346. * Gets or sets a boolean used to define if the node must be serialized
  37347. */
  37348. get doNotSerialize(): boolean;
  37349. set doNotSerialize(value: boolean);
  37350. /** @hidden */
  37351. _isDisposed: boolean;
  37352. /**
  37353. * Gets a list of Animations associated with the node
  37354. */
  37355. animations: Animation[];
  37356. protected _ranges: {
  37357. [name: string]: Nullable<AnimationRange>;
  37358. };
  37359. /**
  37360. * Callback raised when the node is ready to be used
  37361. */
  37362. onReady: Nullable<(node: Node) => void>;
  37363. private _isEnabled;
  37364. private _isParentEnabled;
  37365. private _isReady;
  37366. /** @hidden */
  37367. _currentRenderId: number;
  37368. private _parentUpdateId;
  37369. /** @hidden */
  37370. _childUpdateId: number;
  37371. /** @hidden */
  37372. _waitingParentId: Nullable<string>;
  37373. /** @hidden */
  37374. _scene: Scene;
  37375. /** @hidden */
  37376. _cache: any;
  37377. private _parentNode;
  37378. private _children;
  37379. /** @hidden */
  37380. _worldMatrix: Matrix;
  37381. /** @hidden */
  37382. _worldMatrixDeterminant: number;
  37383. /** @hidden */
  37384. _worldMatrixDeterminantIsDirty: boolean;
  37385. /** @hidden */
  37386. private _sceneRootNodesIndex;
  37387. /**
  37388. * Gets a boolean indicating if the node has been disposed
  37389. * @returns true if the node was disposed
  37390. */
  37391. isDisposed(): boolean;
  37392. /**
  37393. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37394. * @see https://doc.babylonjs.com/how_to/parenting
  37395. */
  37396. set parent(parent: Nullable<Node>);
  37397. get parent(): Nullable<Node>;
  37398. /** @hidden */
  37399. _addToSceneRootNodes(): void;
  37400. /** @hidden */
  37401. _removeFromSceneRootNodes(): void;
  37402. private _animationPropertiesOverride;
  37403. /**
  37404. * Gets or sets the animation properties override
  37405. */
  37406. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37407. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37408. /**
  37409. * Gets a string identifying the name of the class
  37410. * @returns "Node" string
  37411. */
  37412. getClassName(): string;
  37413. /** @hidden */
  37414. readonly _isNode: boolean;
  37415. /**
  37416. * An event triggered when the mesh is disposed
  37417. */
  37418. onDisposeObservable: Observable<Node>;
  37419. private _onDisposeObserver;
  37420. /**
  37421. * Sets a callback that will be raised when the node will be disposed
  37422. */
  37423. set onDispose(callback: () => void);
  37424. /**
  37425. * Creates a new Node
  37426. * @param name the name and id to be given to this node
  37427. * @param scene the scene this node will be added to
  37428. */
  37429. constructor(name: string, scene?: Nullable<Scene>);
  37430. /**
  37431. * Gets the scene of the node
  37432. * @returns a scene
  37433. */
  37434. getScene(): Scene;
  37435. /**
  37436. * Gets the engine of the node
  37437. * @returns a Engine
  37438. */
  37439. getEngine(): Engine;
  37440. private _behaviors;
  37441. /**
  37442. * Attach a behavior to the node
  37443. * @see https://doc.babylonjs.com/features/behaviour
  37444. * @param behavior defines the behavior to attach
  37445. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37446. * @returns the current Node
  37447. */
  37448. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37449. /**
  37450. * Remove an attached behavior
  37451. * @see https://doc.babylonjs.com/features/behaviour
  37452. * @param behavior defines the behavior to attach
  37453. * @returns the current Node
  37454. */
  37455. removeBehavior(behavior: Behavior<Node>): Node;
  37456. /**
  37457. * Gets the list of attached behaviors
  37458. * @see https://doc.babylonjs.com/features/behaviour
  37459. */
  37460. get behaviors(): Behavior<Node>[];
  37461. /**
  37462. * Gets an attached behavior by name
  37463. * @param name defines the name of the behavior to look for
  37464. * @see https://doc.babylonjs.com/features/behaviour
  37465. * @returns null if behavior was not found else the requested behavior
  37466. */
  37467. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37468. /**
  37469. * Returns the latest update of the World matrix
  37470. * @returns a Matrix
  37471. */
  37472. getWorldMatrix(): Matrix;
  37473. /** @hidden */
  37474. _getWorldMatrixDeterminant(): number;
  37475. /**
  37476. * Returns directly the latest state of the mesh World matrix.
  37477. * A Matrix is returned.
  37478. */
  37479. get worldMatrixFromCache(): Matrix;
  37480. /** @hidden */
  37481. _initCache(): void;
  37482. /** @hidden */
  37483. updateCache(force?: boolean): void;
  37484. /** @hidden */
  37485. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37486. /** @hidden */
  37487. _updateCache(ignoreParentClass?: boolean): void;
  37488. /** @hidden */
  37489. _isSynchronized(): boolean;
  37490. /** @hidden */
  37491. _markSyncedWithParent(): void;
  37492. /** @hidden */
  37493. isSynchronizedWithParent(): boolean;
  37494. /** @hidden */
  37495. isSynchronized(): boolean;
  37496. /**
  37497. * Is this node ready to be used/rendered
  37498. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37499. * @return true if the node is ready
  37500. */
  37501. isReady(completeCheck?: boolean): boolean;
  37502. /**
  37503. * Is this node enabled?
  37504. * 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
  37505. * @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
  37506. * @return whether this node (and its parent) is enabled
  37507. */
  37508. isEnabled(checkAncestors?: boolean): boolean;
  37509. /** @hidden */
  37510. protected _syncParentEnabledState(): void;
  37511. /**
  37512. * Set the enabled state of this node
  37513. * @param value defines the new enabled state
  37514. */
  37515. setEnabled(value: boolean): void;
  37516. /**
  37517. * Is this node a descendant of the given node?
  37518. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37519. * @param ancestor defines the parent node to inspect
  37520. * @returns a boolean indicating if this node is a descendant of the given node
  37521. */
  37522. isDescendantOf(ancestor: Node): boolean;
  37523. /** @hidden */
  37524. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37525. /**
  37526. * Will return all nodes that have this node as ascendant
  37527. * @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
  37528. * @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
  37529. * @return all children nodes of all types
  37530. */
  37531. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37532. /**
  37533. * Get all child-meshes of this node
  37534. * @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)
  37535. * @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
  37536. * @returns an array of AbstractMesh
  37537. */
  37538. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37539. /**
  37540. * Get all direct children of this node
  37541. * @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
  37542. * @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)
  37543. * @returns an array of Node
  37544. */
  37545. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37546. /** @hidden */
  37547. _setReady(state: boolean): void;
  37548. /**
  37549. * Get an animation by name
  37550. * @param name defines the name of the animation to look for
  37551. * @returns null if not found else the requested animation
  37552. */
  37553. getAnimationByName(name: string): Nullable<Animation>;
  37554. /**
  37555. * Creates an animation range for this node
  37556. * @param name defines the name of the range
  37557. * @param from defines the starting key
  37558. * @param to defines the end key
  37559. */
  37560. createAnimationRange(name: string, from: number, to: number): void;
  37561. /**
  37562. * Delete a specific animation range
  37563. * @param name defines the name of the range to delete
  37564. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37565. */
  37566. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37567. /**
  37568. * Get an animation range by name
  37569. * @param name defines the name of the animation range to look for
  37570. * @returns null if not found else the requested animation range
  37571. */
  37572. getAnimationRange(name: string): Nullable<AnimationRange>;
  37573. /**
  37574. * Gets the list of all animation ranges defined on this node
  37575. * @returns an array
  37576. */
  37577. getAnimationRanges(): Nullable<AnimationRange>[];
  37578. /**
  37579. * Will start the animation sequence
  37580. * @param name defines the range frames for animation sequence
  37581. * @param loop defines if the animation should loop (false by default)
  37582. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37583. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37584. * @returns the object created for this animation. If range does not exist, it will return null
  37585. */
  37586. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37587. /**
  37588. * Serialize animation ranges into a JSON compatible object
  37589. * @returns serialization object
  37590. */
  37591. serializeAnimationRanges(): any;
  37592. /**
  37593. * Computes the world matrix of the node
  37594. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37595. * @returns the world matrix
  37596. */
  37597. computeWorldMatrix(force?: boolean): Matrix;
  37598. /**
  37599. * Releases resources associated with this node.
  37600. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37601. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37602. */
  37603. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37604. /**
  37605. * Parse animation range data from a serialization object and store them into a given node
  37606. * @param node defines where to store the animation ranges
  37607. * @param parsedNode defines the serialization object to read data from
  37608. * @param scene defines the hosting scene
  37609. */
  37610. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37611. /**
  37612. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37613. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37614. * @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
  37615. * @returns the new bounding vectors
  37616. */
  37617. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37618. min: Vector3;
  37619. max: Vector3;
  37620. };
  37621. }
  37622. }
  37623. declare module BABYLON {
  37624. /**
  37625. * @hidden
  37626. */
  37627. export class _IAnimationState {
  37628. key: number;
  37629. repeatCount: number;
  37630. workValue?: any;
  37631. loopMode?: number;
  37632. offsetValue?: any;
  37633. highLimitValue?: any;
  37634. }
  37635. /**
  37636. * Class used to store any kind of animation
  37637. */
  37638. export class Animation {
  37639. /**Name of the animation */
  37640. name: string;
  37641. /**Property to animate */
  37642. targetProperty: string;
  37643. /**The frames per second of the animation */
  37644. framePerSecond: number;
  37645. /**The data type of the animation */
  37646. dataType: number;
  37647. /**The loop mode of the animation */
  37648. loopMode?: number | undefined;
  37649. /**Specifies if blending should be enabled */
  37650. enableBlending?: boolean | undefined;
  37651. /**
  37652. * Use matrix interpolation instead of using direct key value when animating matrices
  37653. */
  37654. static AllowMatricesInterpolation: boolean;
  37655. /**
  37656. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37657. */
  37658. static AllowMatrixDecomposeForInterpolation: boolean;
  37659. /** Define the Url to load snippets */
  37660. static SnippetUrl: string;
  37661. /** Snippet ID if the animation was created from the snippet server */
  37662. snippetId: string;
  37663. /**
  37664. * Stores the key frames of the animation
  37665. */
  37666. private _keys;
  37667. /**
  37668. * Stores the easing function of the animation
  37669. */
  37670. private _easingFunction;
  37671. /**
  37672. * @hidden Internal use only
  37673. */
  37674. _runtimeAnimations: RuntimeAnimation[];
  37675. /**
  37676. * The set of event that will be linked to this animation
  37677. */
  37678. private _events;
  37679. /**
  37680. * Stores an array of target property paths
  37681. */
  37682. targetPropertyPath: string[];
  37683. /**
  37684. * Stores the blending speed of the animation
  37685. */
  37686. blendingSpeed: number;
  37687. /**
  37688. * Stores the animation ranges for the animation
  37689. */
  37690. private _ranges;
  37691. /**
  37692. * @hidden Internal use
  37693. */
  37694. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37695. /**
  37696. * Sets up an animation
  37697. * @param property The property to animate
  37698. * @param animationType The animation type to apply
  37699. * @param framePerSecond The frames per second of the animation
  37700. * @param easingFunction The easing function used in the animation
  37701. * @returns The created animation
  37702. */
  37703. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37704. /**
  37705. * Create and start an animation on a node
  37706. * @param name defines the name of the global animation that will be run on all nodes
  37707. * @param node defines the root node where the animation will take place
  37708. * @param targetProperty defines property to animate
  37709. * @param framePerSecond defines the number of frame per second yo use
  37710. * @param totalFrame defines the number of frames in total
  37711. * @param from defines the initial value
  37712. * @param to defines the final value
  37713. * @param loopMode defines which loop mode you want to use (off by default)
  37714. * @param easingFunction defines the easing function to use (linear by default)
  37715. * @param onAnimationEnd defines the callback to call when animation end
  37716. * @returns the animatable created for this animation
  37717. */
  37718. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37719. /**
  37720. * Create and start an animation on a node and its descendants
  37721. * @param name defines the name of the global animation that will be run on all nodes
  37722. * @param node defines the root node where the animation will take place
  37723. * @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
  37724. * @param targetProperty defines property to animate
  37725. * @param framePerSecond defines the number of frame per second to use
  37726. * @param totalFrame defines the number of frames in total
  37727. * @param from defines the initial value
  37728. * @param to defines the final value
  37729. * @param loopMode defines which loop mode you want to use (off by default)
  37730. * @param easingFunction defines the easing function to use (linear by default)
  37731. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  37732. * @returns the list of animatables created for all nodes
  37733. * @example https://www.babylonjs-playground.com/#MH0VLI
  37734. */
  37735. 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[]>;
  37736. /**
  37737. * Creates a new animation, merges it with the existing animations and starts it
  37738. * @param name Name of the animation
  37739. * @param node Node which contains the scene that begins the animations
  37740. * @param targetProperty Specifies which property to animate
  37741. * @param framePerSecond The frames per second of the animation
  37742. * @param totalFrame The total number of frames
  37743. * @param from The frame at the beginning of the animation
  37744. * @param to The frame at the end of the animation
  37745. * @param loopMode Specifies the loop mode of the animation
  37746. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  37747. * @param onAnimationEnd Callback to run once the animation is complete
  37748. * @returns Nullable animation
  37749. */
  37750. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37751. /**
  37752. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  37753. * @param sourceAnimation defines the Animation containing keyframes to convert
  37754. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  37755. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  37756. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  37757. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  37758. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  37759. */
  37760. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  37761. /**
  37762. * Transition property of an host to the target Value
  37763. * @param property The property to transition
  37764. * @param targetValue The target Value of the property
  37765. * @param host The object where the property to animate belongs
  37766. * @param scene Scene used to run the animation
  37767. * @param frameRate Framerate (in frame/s) to use
  37768. * @param transition The transition type we want to use
  37769. * @param duration The duration of the animation, in milliseconds
  37770. * @param onAnimationEnd Callback trigger at the end of the animation
  37771. * @returns Nullable animation
  37772. */
  37773. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  37774. /**
  37775. * Return the array of runtime animations currently using this animation
  37776. */
  37777. get runtimeAnimations(): RuntimeAnimation[];
  37778. /**
  37779. * Specifies if any of the runtime animations are currently running
  37780. */
  37781. get hasRunningRuntimeAnimations(): boolean;
  37782. /**
  37783. * Initializes the animation
  37784. * @param name Name of the animation
  37785. * @param targetProperty Property to animate
  37786. * @param framePerSecond The frames per second of the animation
  37787. * @param dataType The data type of the animation
  37788. * @param loopMode The loop mode of the animation
  37789. * @param enableBlending Specifies if blending should be enabled
  37790. */
  37791. constructor(
  37792. /**Name of the animation */
  37793. name: string,
  37794. /**Property to animate */
  37795. targetProperty: string,
  37796. /**The frames per second of the animation */
  37797. framePerSecond: number,
  37798. /**The data type of the animation */
  37799. dataType: number,
  37800. /**The loop mode of the animation */
  37801. loopMode?: number | undefined,
  37802. /**Specifies if blending should be enabled */
  37803. enableBlending?: boolean | undefined);
  37804. /**
  37805. * Converts the animation to a string
  37806. * @param fullDetails support for multiple levels of logging within scene loading
  37807. * @returns String form of the animation
  37808. */
  37809. toString(fullDetails?: boolean): string;
  37810. /**
  37811. * Add an event to this animation
  37812. * @param event Event to add
  37813. */
  37814. addEvent(event: AnimationEvent): void;
  37815. /**
  37816. * Remove all events found at the given frame
  37817. * @param frame The frame to remove events from
  37818. */
  37819. removeEvents(frame: number): void;
  37820. /**
  37821. * Retrieves all the events from the animation
  37822. * @returns Events from the animation
  37823. */
  37824. getEvents(): AnimationEvent[];
  37825. /**
  37826. * Creates an animation range
  37827. * @param name Name of the animation range
  37828. * @param from Starting frame of the animation range
  37829. * @param to Ending frame of the animation
  37830. */
  37831. createRange(name: string, from: number, to: number): void;
  37832. /**
  37833. * Deletes an animation range by name
  37834. * @param name Name of the animation range to delete
  37835. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  37836. */
  37837. deleteRange(name: string, deleteFrames?: boolean): void;
  37838. /**
  37839. * Gets the animation range by name, or null if not defined
  37840. * @param name Name of the animation range
  37841. * @returns Nullable animation range
  37842. */
  37843. getRange(name: string): Nullable<AnimationRange>;
  37844. /**
  37845. * Gets the key frames from the animation
  37846. * @returns The key frames of the animation
  37847. */
  37848. getKeys(): Array<IAnimationKey>;
  37849. /**
  37850. * Gets the highest frame rate of the animation
  37851. * @returns Highest frame rate of the animation
  37852. */
  37853. getHighestFrame(): number;
  37854. /**
  37855. * Gets the easing function of the animation
  37856. * @returns Easing function of the animation
  37857. */
  37858. getEasingFunction(): IEasingFunction;
  37859. /**
  37860. * Sets the easing function of the animation
  37861. * @param easingFunction A custom mathematical formula for animation
  37862. */
  37863. setEasingFunction(easingFunction: EasingFunction): void;
  37864. /**
  37865. * Interpolates a scalar linearly
  37866. * @param startValue Start value of the animation curve
  37867. * @param endValue End value of the animation curve
  37868. * @param gradient Scalar amount to interpolate
  37869. * @returns Interpolated scalar value
  37870. */
  37871. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  37872. /**
  37873. * Interpolates a scalar cubically
  37874. * @param startValue Start value of the animation curve
  37875. * @param outTangent End tangent of the animation
  37876. * @param endValue End value of the animation curve
  37877. * @param inTangent Start tangent of the animation curve
  37878. * @param gradient Scalar amount to interpolate
  37879. * @returns Interpolated scalar value
  37880. */
  37881. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  37882. /**
  37883. * Interpolates a quaternion using a spherical linear interpolation
  37884. * @param startValue Start value of the animation curve
  37885. * @param endValue End value of the animation curve
  37886. * @param gradient Scalar amount to interpolate
  37887. * @returns Interpolated quaternion value
  37888. */
  37889. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  37890. /**
  37891. * Interpolates a quaternion cubically
  37892. * @param startValue Start value of the animation curve
  37893. * @param outTangent End tangent of the animation curve
  37894. * @param endValue End value of the animation curve
  37895. * @param inTangent Start tangent of the animation curve
  37896. * @param gradient Scalar amount to interpolate
  37897. * @returns Interpolated quaternion value
  37898. */
  37899. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  37900. /**
  37901. * Interpolates a Vector3 linearly
  37902. * @param startValue Start value of the animation curve
  37903. * @param endValue End value of the animation curve
  37904. * @param gradient Scalar amount to interpolate
  37905. * @returns Interpolated scalar value
  37906. */
  37907. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  37908. /**
  37909. * Interpolates a Vector3 cubically
  37910. * @param startValue Start value of the animation curve
  37911. * @param outTangent End tangent of the animation
  37912. * @param endValue End value of the animation curve
  37913. * @param inTangent Start tangent of the animation curve
  37914. * @param gradient Scalar amount to interpolate
  37915. * @returns InterpolatedVector3 value
  37916. */
  37917. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  37918. /**
  37919. * Interpolates a Vector2 linearly
  37920. * @param startValue Start value of the animation curve
  37921. * @param endValue End value of the animation curve
  37922. * @param gradient Scalar amount to interpolate
  37923. * @returns Interpolated Vector2 value
  37924. */
  37925. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  37926. /**
  37927. * Interpolates a Vector2 cubically
  37928. * @param startValue Start value of the animation curve
  37929. * @param outTangent End tangent of the animation
  37930. * @param endValue End value of the animation curve
  37931. * @param inTangent Start tangent of the animation curve
  37932. * @param gradient Scalar amount to interpolate
  37933. * @returns Interpolated Vector2 value
  37934. */
  37935. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  37936. /**
  37937. * Interpolates a size linearly
  37938. * @param startValue Start value of the animation curve
  37939. * @param endValue End value of the animation curve
  37940. * @param gradient Scalar amount to interpolate
  37941. * @returns Interpolated Size value
  37942. */
  37943. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  37944. /**
  37945. * Interpolates a Color3 linearly
  37946. * @param startValue Start value of the animation curve
  37947. * @param endValue End value of the animation curve
  37948. * @param gradient Scalar amount to interpolate
  37949. * @returns Interpolated Color3 value
  37950. */
  37951. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  37952. /**
  37953. * Interpolates a Color4 linearly
  37954. * @param startValue Start value of the animation curve
  37955. * @param endValue End value of the animation curve
  37956. * @param gradient Scalar amount to interpolate
  37957. * @returns Interpolated Color3 value
  37958. */
  37959. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  37960. /**
  37961. * @hidden Internal use only
  37962. */
  37963. _getKeyValue(value: any): any;
  37964. /**
  37965. * @hidden Internal use only
  37966. */
  37967. _interpolate(currentFrame: number, state: _IAnimationState): any;
  37968. /**
  37969. * Defines the function to use to interpolate matrices
  37970. * @param startValue defines the start matrix
  37971. * @param endValue defines the end matrix
  37972. * @param gradient defines the gradient between both matrices
  37973. * @param result defines an optional target matrix where to store the interpolation
  37974. * @returns the interpolated matrix
  37975. */
  37976. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  37977. /**
  37978. * Makes a copy of the animation
  37979. * @returns Cloned animation
  37980. */
  37981. clone(): Animation;
  37982. /**
  37983. * Sets the key frames of the animation
  37984. * @param values The animation key frames to set
  37985. */
  37986. setKeys(values: Array<IAnimationKey>): void;
  37987. /**
  37988. * Serializes the animation to an object
  37989. * @returns Serialized object
  37990. */
  37991. serialize(): any;
  37992. /**
  37993. * Float animation type
  37994. */
  37995. static readonly ANIMATIONTYPE_FLOAT: number;
  37996. /**
  37997. * Vector3 animation type
  37998. */
  37999. static readonly ANIMATIONTYPE_VECTOR3: number;
  38000. /**
  38001. * Quaternion animation type
  38002. */
  38003. static readonly ANIMATIONTYPE_QUATERNION: number;
  38004. /**
  38005. * Matrix animation type
  38006. */
  38007. static readonly ANIMATIONTYPE_MATRIX: number;
  38008. /**
  38009. * Color3 animation type
  38010. */
  38011. static readonly ANIMATIONTYPE_COLOR3: number;
  38012. /**
  38013. * Color3 animation type
  38014. */
  38015. static readonly ANIMATIONTYPE_COLOR4: number;
  38016. /**
  38017. * Vector2 animation type
  38018. */
  38019. static readonly ANIMATIONTYPE_VECTOR2: number;
  38020. /**
  38021. * Size animation type
  38022. */
  38023. static readonly ANIMATIONTYPE_SIZE: number;
  38024. /**
  38025. * Relative Loop Mode
  38026. */
  38027. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  38028. /**
  38029. * Cycle Loop Mode
  38030. */
  38031. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  38032. /**
  38033. * Constant Loop Mode
  38034. */
  38035. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  38036. /** @hidden */
  38037. static _UniversalLerp(left: any, right: any, amount: number): any;
  38038. /**
  38039. * Parses an animation object and creates an animation
  38040. * @param parsedAnimation Parsed animation object
  38041. * @returns Animation object
  38042. */
  38043. static Parse(parsedAnimation: any): Animation;
  38044. /**
  38045. * Appends the serialized animations from the source animations
  38046. * @param source Source containing the animations
  38047. * @param destination Target to store the animations
  38048. */
  38049. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38050. /**
  38051. * Creates a new animation or an array of animations from a snippet saved in a remote file
  38052. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  38053. * @param url defines the url to load from
  38054. * @returns a promise that will resolve to the new animation or an array of animations
  38055. */
  38056. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  38057. /**
  38058. * Creates an animation or an array of animations from a snippet saved by the Inspector
  38059. * @param snippetId defines the snippet to load
  38060. * @returns a promise that will resolve to the new animation or a new array of animations
  38061. */
  38062. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  38063. }
  38064. }
  38065. declare module BABYLON {
  38066. /**
  38067. * Interface containing an array of animations
  38068. */
  38069. export interface IAnimatable {
  38070. /**
  38071. * Array of animations
  38072. */
  38073. animations: Nullable<Array<Animation>>;
  38074. }
  38075. }
  38076. declare module BABYLON {
  38077. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38078. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38079. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38080. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38081. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38082. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38083. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38084. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38085. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38086. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38087. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38088. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38089. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38090. /**
  38091. * Decorator used to define property that can be serialized as reference to a camera
  38092. * @param sourceName defines the name of the property to decorate
  38093. */
  38094. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38095. /**
  38096. * Class used to help serialization objects
  38097. */
  38098. export class SerializationHelper {
  38099. /** @hidden */
  38100. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  38101. /** @hidden */
  38102. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  38103. /** @hidden */
  38104. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  38105. /** @hidden */
  38106. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  38107. /**
  38108. * Appends the serialized animations from the source animations
  38109. * @param source Source containing the animations
  38110. * @param destination Target to store the animations
  38111. */
  38112. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38113. /**
  38114. * Static function used to serialized a specific entity
  38115. * @param entity defines the entity to serialize
  38116. * @param serializationObject defines the optional target object where serialization data will be stored
  38117. * @returns a JSON compatible object representing the serialization of the entity
  38118. */
  38119. static Serialize<T>(entity: T, serializationObject?: any): any;
  38120. /**
  38121. * Creates a new entity from a serialization data object
  38122. * @param creationFunction defines a function used to instanciated the new entity
  38123. * @param source defines the source serialization data
  38124. * @param scene defines the hosting scene
  38125. * @param rootUrl defines the root url for resources
  38126. * @returns a new entity
  38127. */
  38128. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38129. /**
  38130. * Clones an object
  38131. * @param creationFunction defines the function used to instanciate the new object
  38132. * @param source defines the source object
  38133. * @returns the cloned object
  38134. */
  38135. static Clone<T>(creationFunction: () => T, source: T): T;
  38136. /**
  38137. * Instanciates a new object based on a source one (some data will be shared between both object)
  38138. * @param creationFunction defines the function used to instanciate the new object
  38139. * @param source defines the source object
  38140. * @returns the new object
  38141. */
  38142. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38143. }
  38144. }
  38145. declare module BABYLON {
  38146. /**
  38147. * This is the base class of all the camera used in the application.
  38148. * @see https://doc.babylonjs.com/features/cameras
  38149. */
  38150. export class Camera extends Node {
  38151. /** @hidden */
  38152. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  38153. /**
  38154. * This is the default projection mode used by the cameras.
  38155. * It helps recreating a feeling of perspective and better appreciate depth.
  38156. * This is the best way to simulate real life cameras.
  38157. */
  38158. static readonly PERSPECTIVE_CAMERA: number;
  38159. /**
  38160. * This helps creating camera with an orthographic mode.
  38161. * 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.
  38162. */
  38163. static readonly ORTHOGRAPHIC_CAMERA: number;
  38164. /**
  38165. * This is the default FOV mode for perspective cameras.
  38166. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  38167. */
  38168. static readonly FOVMODE_VERTICAL_FIXED: number;
  38169. /**
  38170. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  38171. */
  38172. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  38173. /**
  38174. * This specifies there is no need for a camera rig.
  38175. * Basically only one eye is rendered corresponding to the camera.
  38176. */
  38177. static readonly RIG_MODE_NONE: number;
  38178. /**
  38179. * Simulates a camera Rig with one blue eye and one red eye.
  38180. * This can be use with 3d blue and red glasses.
  38181. */
  38182. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  38183. /**
  38184. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  38185. */
  38186. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  38187. /**
  38188. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  38189. */
  38190. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  38191. /**
  38192. * Defines that both eyes of the camera will be rendered over under each other.
  38193. */
  38194. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  38195. /**
  38196. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  38197. */
  38198. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  38199. /**
  38200. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  38201. */
  38202. static readonly RIG_MODE_VR: number;
  38203. /**
  38204. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  38205. */
  38206. static readonly RIG_MODE_WEBVR: number;
  38207. /**
  38208. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  38209. */
  38210. static readonly RIG_MODE_CUSTOM: number;
  38211. /**
  38212. * Defines if by default attaching controls should prevent the default javascript event to continue.
  38213. */
  38214. static ForceAttachControlToAlwaysPreventDefault: boolean;
  38215. /**
  38216. * Define the input manager associated with the camera.
  38217. */
  38218. inputs: CameraInputsManager<Camera>;
  38219. /** @hidden */
  38220. _position: Vector3;
  38221. /**
  38222. * Define the current local position of the camera in the scene
  38223. */
  38224. get position(): Vector3;
  38225. set position(newPosition: Vector3);
  38226. protected _upVector: Vector3;
  38227. /**
  38228. * The vector the camera should consider as up.
  38229. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  38230. */
  38231. set upVector(vec: Vector3);
  38232. get upVector(): Vector3;
  38233. /**
  38234. * Define the current limit on the left side for an orthographic camera
  38235. * In scene unit
  38236. */
  38237. orthoLeft: Nullable<number>;
  38238. /**
  38239. * Define the current limit on the right side for an orthographic camera
  38240. * In scene unit
  38241. */
  38242. orthoRight: Nullable<number>;
  38243. /**
  38244. * Define the current limit on the bottom side for an orthographic camera
  38245. * In scene unit
  38246. */
  38247. orthoBottom: Nullable<number>;
  38248. /**
  38249. * Define the current limit on the top side for an orthographic camera
  38250. * In scene unit
  38251. */
  38252. orthoTop: Nullable<number>;
  38253. /**
  38254. * Field Of View is set in Radians. (default is 0.8)
  38255. */
  38256. fov: number;
  38257. /**
  38258. * Define the minimum distance the camera can see from.
  38259. * This is important to note that the depth buffer are not infinite and the closer it starts
  38260. * the more your scene might encounter depth fighting issue.
  38261. */
  38262. minZ: number;
  38263. /**
  38264. * Define the maximum distance the camera can see to.
  38265. * This is important to note that the depth buffer are not infinite and the further it end
  38266. * the more your scene might encounter depth fighting issue.
  38267. */
  38268. maxZ: number;
  38269. /**
  38270. * Define the default inertia of the camera.
  38271. * This helps giving a smooth feeling to the camera movement.
  38272. */
  38273. inertia: number;
  38274. /**
  38275. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  38276. */
  38277. mode: number;
  38278. /**
  38279. * Define whether the camera is intermediate.
  38280. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  38281. */
  38282. isIntermediate: boolean;
  38283. /**
  38284. * Define the viewport of the camera.
  38285. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  38286. */
  38287. viewport: Viewport;
  38288. /**
  38289. * Restricts the camera to viewing objects with the same layerMask.
  38290. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  38291. */
  38292. layerMask: number;
  38293. /**
  38294. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  38295. */
  38296. fovMode: number;
  38297. /**
  38298. * Rig mode of the camera.
  38299. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  38300. * This is normally controlled byt the camera themselves as internal use.
  38301. */
  38302. cameraRigMode: number;
  38303. /**
  38304. * Defines the distance between both "eyes" in case of a RIG
  38305. */
  38306. interaxialDistance: number;
  38307. /**
  38308. * Defines if stereoscopic rendering is done side by side or over under.
  38309. */
  38310. isStereoscopicSideBySide: boolean;
  38311. /**
  38312. * 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
  38313. * This is pretty helpful if you wish to make a camera render to a texture you could reuse somewhere
  38314. * else in the scene. (Eg. security camera)
  38315. *
  38316. * 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)
  38317. */
  38318. customRenderTargets: RenderTargetTexture[];
  38319. /**
  38320. * When set, the camera will render to this render target instead of the default canvas
  38321. *
  38322. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  38323. */
  38324. outputRenderTarget: Nullable<RenderTargetTexture>;
  38325. /**
  38326. * Observable triggered when the camera view matrix has changed.
  38327. */
  38328. onViewMatrixChangedObservable: Observable<Camera>;
  38329. /**
  38330. * Observable triggered when the camera Projection matrix has changed.
  38331. */
  38332. onProjectionMatrixChangedObservable: Observable<Camera>;
  38333. /**
  38334. * Observable triggered when the inputs have been processed.
  38335. */
  38336. onAfterCheckInputsObservable: Observable<Camera>;
  38337. /**
  38338. * Observable triggered when reset has been called and applied to the camera.
  38339. */
  38340. onRestoreStateObservable: Observable<Camera>;
  38341. /**
  38342. * Is this camera a part of a rig system?
  38343. */
  38344. isRigCamera: boolean;
  38345. /**
  38346. * If isRigCamera set to true this will be set with the parent camera.
  38347. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  38348. */
  38349. rigParent?: Camera;
  38350. /** @hidden */
  38351. _cameraRigParams: any;
  38352. /** @hidden */
  38353. _rigCameras: Camera[];
  38354. /** @hidden */
  38355. _rigPostProcess: Nullable<PostProcess>;
  38356. protected _webvrViewMatrix: Matrix;
  38357. /** @hidden */
  38358. _skipRendering: boolean;
  38359. /** @hidden */
  38360. _projectionMatrix: Matrix;
  38361. /** @hidden */
  38362. _postProcesses: Nullable<PostProcess>[];
  38363. /** @hidden */
  38364. _activeMeshes: SmartArray<AbstractMesh>;
  38365. protected _globalPosition: Vector3;
  38366. /** @hidden */
  38367. _computedViewMatrix: Matrix;
  38368. private _doNotComputeProjectionMatrix;
  38369. private _transformMatrix;
  38370. private _frustumPlanes;
  38371. private _refreshFrustumPlanes;
  38372. private _storedFov;
  38373. private _stateStored;
  38374. /**
  38375. * Instantiates a new camera object.
  38376. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  38377. * @see https://doc.babylonjs.com/features/cameras
  38378. * @param name Defines the name of the camera in the scene
  38379. * @param position Defines the position of the camera
  38380. * @param scene Defines the scene the camera belongs too
  38381. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  38382. */
  38383. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38384. /**
  38385. * Store current camera state (fov, position, etc..)
  38386. * @returns the camera
  38387. */
  38388. storeState(): Camera;
  38389. /**
  38390. * Restores the camera state values if it has been stored. You must call storeState() first
  38391. */
  38392. protected _restoreStateValues(): boolean;
  38393. /**
  38394. * Restored camera state. You must call storeState() first.
  38395. * @returns true if restored and false otherwise
  38396. */
  38397. restoreState(): boolean;
  38398. /**
  38399. * Gets the class name of the camera.
  38400. * @returns the class name
  38401. */
  38402. getClassName(): string;
  38403. /** @hidden */
  38404. readonly _isCamera: boolean;
  38405. /**
  38406. * Gets a string representation of the camera useful for debug purpose.
  38407. * @param fullDetails Defines that a more verboe level of logging is required
  38408. * @returns the string representation
  38409. */
  38410. toString(fullDetails?: boolean): string;
  38411. /**
  38412. * Gets the current world space position of the camera.
  38413. */
  38414. get globalPosition(): Vector3;
  38415. /**
  38416. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  38417. * @returns the active meshe list
  38418. */
  38419. getActiveMeshes(): SmartArray<AbstractMesh>;
  38420. /**
  38421. * Check whether a mesh is part of the current active mesh list of the camera
  38422. * @param mesh Defines the mesh to check
  38423. * @returns true if active, false otherwise
  38424. */
  38425. isActiveMesh(mesh: Mesh): boolean;
  38426. /**
  38427. * Is this camera ready to be used/rendered
  38428. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  38429. * @return true if the camera is ready
  38430. */
  38431. isReady(completeCheck?: boolean): boolean;
  38432. /** @hidden */
  38433. _initCache(): void;
  38434. /** @hidden */
  38435. _updateCache(ignoreParentClass?: boolean): void;
  38436. /** @hidden */
  38437. _isSynchronized(): boolean;
  38438. /** @hidden */
  38439. _isSynchronizedViewMatrix(): boolean;
  38440. /** @hidden */
  38441. _isSynchronizedProjectionMatrix(): boolean;
  38442. /**
  38443. * Attach the input controls to a specific dom element to get the input from.
  38444. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38445. */
  38446. attachControl(noPreventDefault?: boolean): void;
  38447. /**
  38448. * Attach the input controls to a specific dom element to get the input from.
  38449. * @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
  38450. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38451. * BACK COMPAT SIGNATURE ONLY.
  38452. */
  38453. attachControl(ignored: any, noPreventDefault?: boolean): void;
  38454. /**
  38455. * Detach the current controls from the specified dom element.
  38456. */
  38457. detachControl(): void;
  38458. /**
  38459. * Detach the current controls from the specified dom element.
  38460. * @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
  38461. */
  38462. detachControl(ignored: any): void;
  38463. /**
  38464. * Update the camera state according to the different inputs gathered during the frame.
  38465. */
  38466. update(): void;
  38467. /** @hidden */
  38468. _checkInputs(): void;
  38469. /** @hidden */
  38470. get rigCameras(): Camera[];
  38471. /**
  38472. * Gets the post process used by the rig cameras
  38473. */
  38474. get rigPostProcess(): Nullable<PostProcess>;
  38475. /**
  38476. * Internal, gets the first post process.
  38477. * @returns the first post process to be run on this camera.
  38478. */
  38479. _getFirstPostProcess(): Nullable<PostProcess>;
  38480. private _cascadePostProcessesToRigCams;
  38481. /**
  38482. * Attach a post process to the camera.
  38483. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38484. * @param postProcess The post process to attach to the camera
  38485. * @param insertAt The position of the post process in case several of them are in use in the scene
  38486. * @returns the position the post process has been inserted at
  38487. */
  38488. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  38489. /**
  38490. * Detach a post process to the camera.
  38491. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38492. * @param postProcess The post process to detach from the camera
  38493. */
  38494. detachPostProcess(postProcess: PostProcess): void;
  38495. /**
  38496. * Gets the current world matrix of the camera
  38497. */
  38498. getWorldMatrix(): Matrix;
  38499. /** @hidden */
  38500. _getViewMatrix(): Matrix;
  38501. /**
  38502. * Gets the current view matrix of the camera.
  38503. * @param force forces the camera to recompute the matrix without looking at the cached state
  38504. * @returns the view matrix
  38505. */
  38506. getViewMatrix(force?: boolean): Matrix;
  38507. /**
  38508. * Freeze the projection matrix.
  38509. * It will prevent the cache check of the camera projection compute and can speed up perf
  38510. * if no parameter of the camera are meant to change
  38511. * @param projection Defines manually a projection if necessary
  38512. */
  38513. freezeProjectionMatrix(projection?: Matrix): void;
  38514. /**
  38515. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  38516. */
  38517. unfreezeProjectionMatrix(): void;
  38518. /**
  38519. * Gets the current projection matrix of the camera.
  38520. * @param force forces the camera to recompute the matrix without looking at the cached state
  38521. * @returns the projection matrix
  38522. */
  38523. getProjectionMatrix(force?: boolean): Matrix;
  38524. /**
  38525. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  38526. * @returns a Matrix
  38527. */
  38528. getTransformationMatrix(): Matrix;
  38529. private _updateFrustumPlanes;
  38530. /**
  38531. * Checks if a cullable object (mesh...) is in the camera frustum
  38532. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  38533. * @param target The object to check
  38534. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  38535. * @returns true if the object is in frustum otherwise false
  38536. */
  38537. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  38538. /**
  38539. * Checks if a cullable object (mesh...) is in the camera frustum
  38540. * Unlike isInFrustum this checks the full bounding box
  38541. * @param target The object to check
  38542. * @returns true if the object is in frustum otherwise false
  38543. */
  38544. isCompletelyInFrustum(target: ICullable): boolean;
  38545. /**
  38546. * Gets a ray in the forward direction from the camera.
  38547. * @param length Defines the length of the ray to create
  38548. * @param transform Defines the transform to apply to the ray, by default the world matrix is used to create a workd space ray
  38549. * @param origin Defines the start point of the ray which defaults to the camera position
  38550. * @returns the forward ray
  38551. */
  38552. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38553. /**
  38554. * Gets a ray in the forward direction from the camera.
  38555. * @param refRay the ray to (re)use when setting the values
  38556. * @param length Defines the length of the ray to create
  38557. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38558. * @param origin Defines the start point of the ray which defaults to the camera position
  38559. * @returns the forward ray
  38560. */
  38561. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38562. /**
  38563. * Releases resources associated with this node.
  38564. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38565. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38566. */
  38567. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38568. /** @hidden */
  38569. _isLeftCamera: boolean;
  38570. /**
  38571. * Gets the left camera of a rig setup in case of Rigged Camera
  38572. */
  38573. get isLeftCamera(): boolean;
  38574. /** @hidden */
  38575. _isRightCamera: boolean;
  38576. /**
  38577. * Gets the right camera of a rig setup in case of Rigged Camera
  38578. */
  38579. get isRightCamera(): boolean;
  38580. /**
  38581. * Gets the left camera of a rig setup in case of Rigged Camera
  38582. */
  38583. get leftCamera(): Nullable<FreeCamera>;
  38584. /**
  38585. * Gets the right camera of a rig setup in case of Rigged Camera
  38586. */
  38587. get rightCamera(): Nullable<FreeCamera>;
  38588. /**
  38589. * Gets the left camera target of a rig setup in case of Rigged Camera
  38590. * @returns the target position
  38591. */
  38592. getLeftTarget(): Nullable<Vector3>;
  38593. /**
  38594. * Gets the right camera target of a rig setup in case of Rigged Camera
  38595. * @returns the target position
  38596. */
  38597. getRightTarget(): Nullable<Vector3>;
  38598. /**
  38599. * @hidden
  38600. */
  38601. setCameraRigMode(mode: number, rigParams: any): void;
  38602. /** @hidden */
  38603. static _setStereoscopicRigMode(camera: Camera): void;
  38604. /** @hidden */
  38605. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  38606. /** @hidden */
  38607. static _setVRRigMode(camera: Camera, rigParams: any): void;
  38608. /** @hidden */
  38609. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  38610. /** @hidden */
  38611. _getVRProjectionMatrix(): Matrix;
  38612. protected _updateCameraRotationMatrix(): void;
  38613. protected _updateWebVRCameraRotationMatrix(): void;
  38614. /**
  38615. * This function MUST be overwritten by the different WebVR cameras available.
  38616. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38617. * @hidden
  38618. */
  38619. _getWebVRProjectionMatrix(): Matrix;
  38620. /**
  38621. * This function MUST be overwritten by the different WebVR cameras available.
  38622. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38623. * @hidden
  38624. */
  38625. _getWebVRViewMatrix(): Matrix;
  38626. /** @hidden */
  38627. setCameraRigParameter(name: string, value: any): void;
  38628. /**
  38629. * needs to be overridden by children so sub has required properties to be copied
  38630. * @hidden
  38631. */
  38632. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  38633. /**
  38634. * May need to be overridden by children
  38635. * @hidden
  38636. */
  38637. _updateRigCameras(): void;
  38638. /** @hidden */
  38639. _setupInputs(): void;
  38640. /**
  38641. * Serialiaze the camera setup to a json representation
  38642. * @returns the JSON representation
  38643. */
  38644. serialize(): any;
  38645. /**
  38646. * Clones the current camera.
  38647. * @param name The cloned camera name
  38648. * @returns the cloned camera
  38649. */
  38650. clone(name: string): Camera;
  38651. /**
  38652. * Gets the direction of the camera relative to a given local axis.
  38653. * @param localAxis Defines the reference axis to provide a relative direction.
  38654. * @return the direction
  38655. */
  38656. getDirection(localAxis: Vector3): Vector3;
  38657. /**
  38658. * Returns the current camera absolute rotation
  38659. */
  38660. get absoluteRotation(): Quaternion;
  38661. /**
  38662. * Gets the direction of the camera relative to a given local axis into a passed vector.
  38663. * @param localAxis Defines the reference axis to provide a relative direction.
  38664. * @param result Defines the vector to store the result in
  38665. */
  38666. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  38667. /**
  38668. * Gets a camera constructor for a given camera type
  38669. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  38670. * @param name The name of the camera the result will be able to instantiate
  38671. * @param scene The scene the result will construct the camera in
  38672. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  38673. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  38674. * @returns a factory method to construct the camera
  38675. */
  38676. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  38677. /**
  38678. * Compute the world matrix of the camera.
  38679. * @returns the camera world matrix
  38680. */
  38681. computeWorldMatrix(): Matrix;
  38682. /**
  38683. * Parse a JSON and creates the camera from the parsed information
  38684. * @param parsedCamera The JSON to parse
  38685. * @param scene The scene to instantiate the camera in
  38686. * @returns the newly constructed camera
  38687. */
  38688. static Parse(parsedCamera: any, scene: Scene): Camera;
  38689. }
  38690. }
  38691. declare module BABYLON {
  38692. /**
  38693. * PostProcessManager is used to manage one or more post processes or post process pipelines
  38694. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  38695. */
  38696. export class PostProcessManager {
  38697. private _scene;
  38698. private _indexBuffer;
  38699. private _vertexBuffers;
  38700. /**
  38701. * Creates a new instance PostProcess
  38702. * @param scene The scene that the post process is associated with.
  38703. */
  38704. constructor(scene: Scene);
  38705. private _prepareBuffers;
  38706. private _buildIndexBuffer;
  38707. /**
  38708. * Rebuilds the vertex buffers of the manager.
  38709. * @hidden
  38710. */
  38711. _rebuild(): void;
  38712. /**
  38713. * Prepares a frame to be run through a post process.
  38714. * @param sourceTexture The input texture to the post processes. (default: null)
  38715. * @param postProcesses An array of post processes to be run. (default: null)
  38716. * @returns True if the post processes were able to be run.
  38717. * @hidden
  38718. */
  38719. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  38720. /**
  38721. * Manually render a set of post processes to a texture.
  38722. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  38723. * @param postProcesses An array of post processes to be run.
  38724. * @param targetTexture The target texture to render to.
  38725. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  38726. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  38727. * @param lodLevel defines which lod of the texture to render to
  38728. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  38729. */
  38730. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  38731. /**
  38732. * Finalize the result of the output of the postprocesses.
  38733. * @param doNotPresent If true the result will not be displayed to the screen.
  38734. * @param targetTexture The target texture to render to.
  38735. * @param faceIndex The index of the face to bind the target texture to.
  38736. * @param postProcesses The array of post processes to render.
  38737. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  38738. * @hidden
  38739. */
  38740. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  38741. /**
  38742. * Disposes of the post process manager.
  38743. */
  38744. dispose(): void;
  38745. }
  38746. }
  38747. declare module BABYLON {
  38748. /**
  38749. * This Helps creating a texture that will be created from a camera in your scene.
  38750. * It is basically a dynamic texture that could be used to create special effects for instance.
  38751. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  38752. */
  38753. export class RenderTargetTexture extends Texture {
  38754. /**
  38755. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  38756. */
  38757. static readonly REFRESHRATE_RENDER_ONCE: number;
  38758. /**
  38759. * The texture will only be rendered rendered every frame and is recommended for dynamic contents.
  38760. */
  38761. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  38762. /**
  38763. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  38764. * the central point of your effect and can save a lot of performances.
  38765. */
  38766. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  38767. /**
  38768. * Use this predicate to dynamically define the list of mesh you want to render.
  38769. * If set, the renderList property will be overwritten.
  38770. */
  38771. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  38772. private _renderList;
  38773. /**
  38774. * Use this list to define the list of mesh you want to render.
  38775. */
  38776. get renderList(): Nullable<Array<AbstractMesh>>;
  38777. set renderList(value: Nullable<Array<AbstractMesh>>);
  38778. /**
  38779. * Use this function to overload the renderList array at rendering time.
  38780. * Return null to render with the current renderList, else return the list of meshes to use for rendering.
  38781. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  38782. * the cube (if the RTT is a cube, else layerOrFace=0).
  38783. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  38784. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  38785. * hold dummy elements!
  38786. */
  38787. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  38788. private _hookArray;
  38789. /**
  38790. * Define if particles should be rendered in your texture.
  38791. */
  38792. renderParticles: boolean;
  38793. /**
  38794. * Define if sprites should be rendered in your texture.
  38795. */
  38796. renderSprites: boolean;
  38797. /**
  38798. * Define the camera used to render the texture.
  38799. */
  38800. activeCamera: Nullable<Camera>;
  38801. /**
  38802. * Override the mesh isReady function with your own one.
  38803. */
  38804. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  38805. /**
  38806. * Override the render function of the texture with your own one.
  38807. */
  38808. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  38809. /**
  38810. * Define if camera post processes should be use while rendering the texture.
  38811. */
  38812. useCameraPostProcesses: boolean;
  38813. /**
  38814. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  38815. */
  38816. ignoreCameraViewport: boolean;
  38817. private _postProcessManager;
  38818. /**
  38819. * Post-processes for this render target
  38820. */
  38821. get postProcesses(): PostProcess[];
  38822. private _postProcesses;
  38823. private _resizeObserver;
  38824. private get _prePassEnabled();
  38825. /**
  38826. * An event triggered when the texture is unbind.
  38827. */
  38828. onBeforeBindObservable: Observable<RenderTargetTexture>;
  38829. /**
  38830. * An event triggered when the texture is unbind.
  38831. */
  38832. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  38833. private _onAfterUnbindObserver;
  38834. /**
  38835. * Set a after unbind callback in the texture.
  38836. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  38837. */
  38838. set onAfterUnbind(callback: () => void);
  38839. /**
  38840. * An event triggered before rendering the texture
  38841. */
  38842. onBeforeRenderObservable: Observable<number>;
  38843. private _onBeforeRenderObserver;
  38844. /**
  38845. * Set a before render callback in the texture.
  38846. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  38847. */
  38848. set onBeforeRender(callback: (faceIndex: number) => void);
  38849. /**
  38850. * An event triggered after rendering the texture
  38851. */
  38852. onAfterRenderObservable: Observable<number>;
  38853. private _onAfterRenderObserver;
  38854. /**
  38855. * Set a after render callback in the texture.
  38856. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  38857. */
  38858. set onAfterRender(callback: (faceIndex: number) => void);
  38859. /**
  38860. * An event triggered after the texture clear
  38861. */
  38862. onClearObservable: Observable<Engine>;
  38863. private _onClearObserver;
  38864. /**
  38865. * Set a clear callback in the texture.
  38866. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  38867. */
  38868. set onClear(callback: (Engine: Engine) => void);
  38869. /**
  38870. * An event triggered when the texture is resized.
  38871. */
  38872. onResizeObservable: Observable<RenderTargetTexture>;
  38873. /**
  38874. * Define the clear color of the Render Target if it should be different from the scene.
  38875. */
  38876. clearColor: Color4;
  38877. protected _size: number | {
  38878. width: number;
  38879. height: number;
  38880. layers?: number;
  38881. };
  38882. protected _initialSizeParameter: number | {
  38883. width: number;
  38884. height: number;
  38885. } | {
  38886. ratio: number;
  38887. };
  38888. protected _sizeRatio: Nullable<number>;
  38889. /** @hidden */
  38890. _generateMipMaps: boolean;
  38891. protected _renderingManager: RenderingManager;
  38892. /** @hidden */
  38893. _waitingRenderList?: string[];
  38894. protected _doNotChangeAspectRatio: boolean;
  38895. protected _currentRefreshId: number;
  38896. protected _refreshRate: number;
  38897. protected _textureMatrix: Matrix;
  38898. protected _samples: number;
  38899. protected _renderTargetOptions: RenderTargetCreationOptions;
  38900. /**
  38901. * Gets render target creation options that were used.
  38902. */
  38903. get renderTargetOptions(): RenderTargetCreationOptions;
  38904. protected _onRatioRescale(): void;
  38905. /**
  38906. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  38907. * It must define where the camera used to render the texture is set
  38908. */
  38909. boundingBoxPosition: Vector3;
  38910. private _boundingBoxSize;
  38911. /**
  38912. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  38913. * When defined, the cubemap will switch to local mode
  38914. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  38915. * @example https://www.babylonjs-playground.com/#RNASML
  38916. */
  38917. set boundingBoxSize(value: Vector3);
  38918. get boundingBoxSize(): Vector3;
  38919. /**
  38920. * In case the RTT has been created with a depth texture, get the associated
  38921. * depth texture.
  38922. * Otherwise, return null.
  38923. */
  38924. get depthStencilTexture(): Nullable<InternalTexture>;
  38925. /**
  38926. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post process
  38927. * or used a shadow, depth texture...
  38928. * @param name The friendly name of the texture
  38929. * @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)
  38930. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  38931. * @param generateMipMaps True if mip maps need to be generated after render.
  38932. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  38933. * @param type The type of the buffer in the RTT (int, half float, float...)
  38934. * @param isCube True if a cube texture needs to be created
  38935. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  38936. * @param generateDepthBuffer True to generate a depth buffer
  38937. * @param generateStencilBuffer True to generate a stencil buffer
  38938. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  38939. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  38940. * @param delayAllocation if the texture allocation should be delayed (default: false)
  38941. * @param samples sample count to use when creating the RTT
  38942. */
  38943. constructor(name: string, size: number | {
  38944. width: number;
  38945. height: number;
  38946. layers?: number;
  38947. } | {
  38948. ratio: number;
  38949. }, 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);
  38950. /**
  38951. * Creates a depth stencil texture.
  38952. * This is only available in WebGL 2 or with the depth texture extension available.
  38953. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  38954. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  38955. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  38956. * @param samples sample count of the depth/stencil texture
  38957. */
  38958. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number): void;
  38959. private _processSizeParameter;
  38960. /**
  38961. * Define the number of samples to use in case of MSAA.
  38962. * It defaults to one meaning no MSAA has been enabled.
  38963. */
  38964. get samples(): number;
  38965. set samples(value: number);
  38966. /**
  38967. * Resets the refresh counter of the texture and start bak from scratch.
  38968. * Could be useful to regenerate the texture if it is setup to render only once.
  38969. */
  38970. resetRefreshCounter(): void;
  38971. /**
  38972. * Define the refresh rate of the texture or the rendering frequency.
  38973. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  38974. */
  38975. get refreshRate(): number;
  38976. set refreshRate(value: number);
  38977. /**
  38978. * Adds a post process to the render target rendering passes.
  38979. * @param postProcess define the post process to add
  38980. */
  38981. addPostProcess(postProcess: PostProcess): void;
  38982. /**
  38983. * Clear all the post processes attached to the render target
  38984. * @param dispose define if the cleared post processes should also be disposed (false by default)
  38985. */
  38986. clearPostProcesses(dispose?: boolean): void;
  38987. /**
  38988. * Remove one of the post process from the list of attached post processes to the texture
  38989. * @param postProcess define the post process to remove from the list
  38990. */
  38991. removePostProcess(postProcess: PostProcess): void;
  38992. /** @hidden */
  38993. _shouldRender(): boolean;
  38994. /**
  38995. * Gets the actual render size of the texture.
  38996. * @returns the width of the render size
  38997. */
  38998. getRenderSize(): number;
  38999. /**
  39000. * Gets the actual render width of the texture.
  39001. * @returns the width of the render size
  39002. */
  39003. getRenderWidth(): number;
  39004. /**
  39005. * Gets the actual render height of the texture.
  39006. * @returns the height of the render size
  39007. */
  39008. getRenderHeight(): number;
  39009. /**
  39010. * Gets the actual number of layers of the texture.
  39011. * @returns the number of layers
  39012. */
  39013. getRenderLayers(): number;
  39014. /**
  39015. * Get if the texture can be rescaled or not.
  39016. */
  39017. get canRescale(): boolean;
  39018. /**
  39019. * Resize the texture using a ratio.
  39020. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  39021. */
  39022. scale(ratio: number): void;
  39023. /**
  39024. * Get the texture reflection matrix used to rotate/transform the reflection.
  39025. * @returns the reflection matrix
  39026. */
  39027. getReflectionTextureMatrix(): Matrix;
  39028. /**
  39029. * Resize the texture to a new desired size.
  39030. * Be careful as it will recreate all the data in the new texture.
  39031. * @param size Define the new size. It can be:
  39032. * - a number for squared texture,
  39033. * - an object containing { width: number, height: number }
  39034. * - or an object containing a ratio { ratio: number }
  39035. */
  39036. resize(size: number | {
  39037. width: number;
  39038. height: number;
  39039. } | {
  39040. ratio: number;
  39041. }): void;
  39042. private _defaultRenderListPrepared;
  39043. /**
  39044. * Renders all the objects from the render list into the texture.
  39045. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  39046. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  39047. */
  39048. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  39049. private _bestReflectionRenderTargetDimension;
  39050. private _prepareRenderingManager;
  39051. /**
  39052. * @hidden
  39053. * @param faceIndex face index to bind to if this is a cubetexture
  39054. * @param layer defines the index of the texture to bind in the array
  39055. */
  39056. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  39057. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  39058. /**
  39059. * @hidden
  39060. */
  39061. _prepareFrame(scene: Scene, faceIndex?: number, layer?: number, useCameraPostProcess?: boolean): void;
  39062. private renderToTarget;
  39063. /**
  39064. * Overrides the default sort function applied in the rendering group to prepare the meshes.
  39065. * This allowed control for front to back rendering or reversely depending of the special needs.
  39066. *
  39067. * @param renderingGroupId The rendering group id corresponding to its index
  39068. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  39069. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  39070. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  39071. */
  39072. 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;
  39073. /**
  39074. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  39075. *
  39076. * @param renderingGroupId The rendering group id corresponding to its index
  39077. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  39078. */
  39079. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  39080. /**
  39081. * Clones the texture.
  39082. * @returns the cloned texture
  39083. */
  39084. clone(): RenderTargetTexture;
  39085. /**
  39086. * Serialize the texture to a JSON representation we can easily use in the respective Parse function.
  39087. * @returns The JSON representation of the texture
  39088. */
  39089. serialize(): any;
  39090. /**
  39091. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  39092. */
  39093. disposeFramebufferObjects(): void;
  39094. /**
  39095. * Dispose the texture and release its associated resources.
  39096. */
  39097. dispose(): void;
  39098. /** @hidden */
  39099. _rebuild(): void;
  39100. /**
  39101. * Clear the info related to rendering groups preventing retention point in material dispose.
  39102. */
  39103. freeRenderingGroups(): void;
  39104. /**
  39105. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  39106. * @returns the view count
  39107. */
  39108. getViewCount(): number;
  39109. }
  39110. }
  39111. declare module BABYLON {
  39112. /**
  39113. * Options to be used when creating an effect.
  39114. */
  39115. export interface IEffectCreationOptions {
  39116. /**
  39117. * Attributes that will be used in the shader.
  39118. */
  39119. attributes: string[];
  39120. /**
  39121. * Uniform variable names that will be set in the shader.
  39122. */
  39123. uniformsNames: string[];
  39124. /**
  39125. * Uniform buffer variable names that will be set in the shader.
  39126. */
  39127. uniformBuffersNames: string[];
  39128. /**
  39129. * Sampler texture variable names that will be set in the shader.
  39130. */
  39131. samplers: string[];
  39132. /**
  39133. * Define statements that will be set in the shader.
  39134. */
  39135. defines: any;
  39136. /**
  39137. * Possible fallbacks for this effect to improve performance when needed.
  39138. */
  39139. fallbacks: Nullable<IEffectFallbacks>;
  39140. /**
  39141. * Callback that will be called when the shader is compiled.
  39142. */
  39143. onCompiled: Nullable<(effect: Effect) => void>;
  39144. /**
  39145. * Callback that will be called if an error occurs during shader compilation.
  39146. */
  39147. onError: Nullable<(effect: Effect, errors: string) => void>;
  39148. /**
  39149. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39150. */
  39151. indexParameters?: any;
  39152. /**
  39153. * Max number of lights that can be used in the shader.
  39154. */
  39155. maxSimultaneousLights?: number;
  39156. /**
  39157. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  39158. */
  39159. transformFeedbackVaryings?: Nullable<string[]>;
  39160. /**
  39161. * 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
  39162. */
  39163. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  39164. /**
  39165. * Is this effect rendering to several color attachments ?
  39166. */
  39167. multiTarget?: boolean;
  39168. }
  39169. /**
  39170. * Effect containing vertex and fragment shader that can be executed on an object.
  39171. */
  39172. export class Effect implements IDisposable {
  39173. /**
  39174. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39175. */
  39176. static ShadersRepository: string;
  39177. /**
  39178. * Enable logging of the shader code when a compilation error occurs
  39179. */
  39180. static LogShaderCodeOnCompilationError: boolean;
  39181. /**
  39182. * Name of the effect.
  39183. */
  39184. name: any;
  39185. /**
  39186. * String container all the define statements that should be set on the shader.
  39187. */
  39188. defines: string;
  39189. /**
  39190. * Callback that will be called when the shader is compiled.
  39191. */
  39192. onCompiled: Nullable<(effect: Effect) => void>;
  39193. /**
  39194. * Callback that will be called if an error occurs during shader compilation.
  39195. */
  39196. onError: Nullable<(effect: Effect, errors: string) => void>;
  39197. /**
  39198. * Callback that will be called when effect is bound.
  39199. */
  39200. onBind: Nullable<(effect: Effect) => void>;
  39201. /**
  39202. * Unique ID of the effect.
  39203. */
  39204. uniqueId: number;
  39205. /**
  39206. * Observable that will be called when the shader is compiled.
  39207. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  39208. */
  39209. onCompileObservable: Observable<Effect>;
  39210. /**
  39211. * Observable that will be called if an error occurs during shader compilation.
  39212. */
  39213. onErrorObservable: Observable<Effect>;
  39214. /** @hidden */
  39215. _onBindObservable: Nullable<Observable<Effect>>;
  39216. /**
  39217. * @hidden
  39218. * Specifies if the effect was previously ready
  39219. */
  39220. _wasPreviouslyReady: boolean;
  39221. /**
  39222. * Observable that will be called when effect is bound.
  39223. */
  39224. get onBindObservable(): Observable<Effect>;
  39225. /** @hidden */
  39226. _bonesComputationForcedToCPU: boolean;
  39227. /** @hidden */
  39228. _uniformBuffersNames: {
  39229. [key: string]: number;
  39230. };
  39231. /** @hidden */
  39232. _samplerList: string[];
  39233. /** @hidden */
  39234. _multiTarget: boolean;
  39235. private static _uniqueIdSeed;
  39236. private _engine;
  39237. private _uniformBuffersNamesList;
  39238. private _uniformsNames;
  39239. private _samplers;
  39240. private _isReady;
  39241. private _compilationError;
  39242. private _allFallbacksProcessed;
  39243. private _attributesNames;
  39244. private _attributes;
  39245. private _attributeLocationByName;
  39246. private _uniforms;
  39247. /**
  39248. * Key for the effect.
  39249. * @hidden
  39250. */
  39251. _key: string;
  39252. private _indexParameters;
  39253. private _fallbacks;
  39254. private _vertexSourceCodeOverride;
  39255. private _fragmentSourceCodeOverride;
  39256. private _transformFeedbackVaryings;
  39257. /**
  39258. * Compiled shader to webGL program.
  39259. * @hidden
  39260. */
  39261. _pipelineContext: Nullable<IPipelineContext>;
  39262. /** @hidden */
  39263. _vertexSourceCode: string;
  39264. /** @hidden */
  39265. _fragmentSourceCode: string;
  39266. /** @hidden */
  39267. private _rawVertexSourceCode;
  39268. /** @hidden */
  39269. private _rawFragmentSourceCode;
  39270. private static _baseCache;
  39271. private _processingContext;
  39272. /**
  39273. * Instantiates an effect.
  39274. * An effect can be used to create/manage/execute vertex and fragment shaders.
  39275. * @param baseName Name of the effect.
  39276. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  39277. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  39278. * @param samplers List of sampler variables that will be passed to the shader.
  39279. * @param engine Engine to be used to render the effect
  39280. * @param defines Define statements to be added to the shader.
  39281. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  39282. * @param onCompiled Callback that will be called when the shader is compiled.
  39283. * @param onError Callback that will be called if an error occurs during shader compilation.
  39284. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39285. * @param key Effect Key identifying uniquely compiled shader variants
  39286. */
  39287. 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);
  39288. private _useFinalCode;
  39289. /**
  39290. * Unique key for this effect
  39291. */
  39292. get key(): string;
  39293. /**
  39294. * If the effect has been compiled and prepared.
  39295. * @returns if the effect is compiled and prepared.
  39296. */
  39297. isReady(): boolean;
  39298. private _isReadyInternal;
  39299. /**
  39300. * The engine the effect was initialized with.
  39301. * @returns the engine.
  39302. */
  39303. getEngine(): Engine;
  39304. /**
  39305. * The pipeline context for this effect
  39306. * @returns the associated pipeline context
  39307. */
  39308. getPipelineContext(): Nullable<IPipelineContext>;
  39309. /**
  39310. * The set of names of attribute variables for the shader.
  39311. * @returns An array of attribute names.
  39312. */
  39313. getAttributesNames(): string[];
  39314. /**
  39315. * Returns the attribute at the given index.
  39316. * @param index The index of the attribute.
  39317. * @returns The location of the attribute.
  39318. */
  39319. getAttributeLocation(index: number): number;
  39320. /**
  39321. * Returns the attribute based on the name of the variable.
  39322. * @param name of the attribute to look up.
  39323. * @returns the attribute location.
  39324. */
  39325. getAttributeLocationByName(name: string): number;
  39326. /**
  39327. * The number of attributes.
  39328. * @returns the number of attributes.
  39329. */
  39330. getAttributesCount(): number;
  39331. /**
  39332. * Gets the index of a uniform variable.
  39333. * @param uniformName of the uniform to look up.
  39334. * @returns the index.
  39335. */
  39336. getUniformIndex(uniformName: string): number;
  39337. /**
  39338. * Returns the attribute based on the name of the variable.
  39339. * @param uniformName of the uniform to look up.
  39340. * @returns the location of the uniform.
  39341. */
  39342. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  39343. /**
  39344. * Returns an array of sampler variable names
  39345. * @returns The array of sampler variable names.
  39346. */
  39347. getSamplers(): string[];
  39348. /**
  39349. * Returns an array of uniform variable names
  39350. * @returns The array of uniform variable names.
  39351. */
  39352. getUniformNames(): string[];
  39353. /**
  39354. * Returns an array of uniform buffer variable names
  39355. * @returns The array of uniform buffer variable names.
  39356. */
  39357. getUniformBuffersNames(): string[];
  39358. /**
  39359. * Returns the index parameters used to create the effect
  39360. * @returns The index parameters object
  39361. */
  39362. getIndexParameters(): any;
  39363. /**
  39364. * The error from the last compilation.
  39365. * @returns the error string.
  39366. */
  39367. getCompilationError(): string;
  39368. /**
  39369. * Gets a boolean indicating that all fallbacks were used during compilation
  39370. * @returns true if all fallbacks were used
  39371. */
  39372. allFallbacksProcessed(): boolean;
  39373. /**
  39374. * Adds a callback to the onCompiled observable and call the callback immediately if already ready.
  39375. * @param func The callback to be used.
  39376. */
  39377. executeWhenCompiled(func: (effect: Effect) => void): void;
  39378. private _checkIsReady;
  39379. private _loadShader;
  39380. /**
  39381. * Gets the vertex shader source code of this effect
  39382. */
  39383. get vertexSourceCode(): string;
  39384. /**
  39385. * Gets the fragment shader source code of this effect
  39386. */
  39387. get fragmentSourceCode(): string;
  39388. /**
  39389. * Gets the vertex shader source code before it has been processed by the preprocessor
  39390. */
  39391. get rawVertexSourceCode(): string;
  39392. /**
  39393. * Gets the fragment shader source code before it has been processed by the preprocessor
  39394. */
  39395. get rawFragmentSourceCode(): string;
  39396. /**
  39397. * Recompiles the webGL program
  39398. * @param vertexSourceCode The source code for the vertex shader.
  39399. * @param fragmentSourceCode The source code for the fragment shader.
  39400. * @param onCompiled Callback called when completed.
  39401. * @param onError Callback called on error.
  39402. * @hidden
  39403. */
  39404. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39405. /**
  39406. * Prepares the effect
  39407. * @hidden
  39408. */
  39409. _prepareEffect(): void;
  39410. private _getShaderCodeAndErrorLine;
  39411. private _processCompilationErrors;
  39412. /**
  39413. * Checks if the effect is supported. (Must be called after compilation)
  39414. */
  39415. get isSupported(): boolean;
  39416. /**
  39417. * Binds a texture to the engine to be used as output of the shader.
  39418. * @param channel Name of the output variable.
  39419. * @param texture Texture to bind.
  39420. * @hidden
  39421. */
  39422. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39423. /**
  39424. * Sets a texture on the engine to be used in the shader.
  39425. * @param channel Name of the sampler variable.
  39426. * @param texture Texture to set.
  39427. */
  39428. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  39429. /**
  39430. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39431. * @param channel Name of the sampler variable.
  39432. * @param texture Texture to set.
  39433. */
  39434. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39435. /**
  39436. * Sets an array of textures on the engine to be used in the shader.
  39437. * @param channel Name of the variable.
  39438. * @param textures Textures to set.
  39439. */
  39440. setTextureArray(channel: string, textures: ThinTexture[]): void;
  39441. /**
  39442. * 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)
  39443. * @param channel Name of the sampler variable.
  39444. * @param postProcess Post process to get the input texture from.
  39445. */
  39446. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39447. /**
  39448. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39449. * 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)
  39450. * @param channel Name of the sampler variable.
  39451. * @param postProcess Post process to get the output texture from.
  39452. */
  39453. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39454. /**
  39455. * Binds a buffer to a uniform.
  39456. * @param buffer Buffer to bind.
  39457. * @param name Name of the uniform variable to bind to.
  39458. */
  39459. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39460. /**
  39461. * Binds block to a uniform.
  39462. * @param blockName Name of the block to bind.
  39463. * @param index Index to bind.
  39464. */
  39465. bindUniformBlock(blockName: string, index: number): void;
  39466. /**
  39467. * Sets an integer value on a uniform variable.
  39468. * @param uniformName Name of the variable.
  39469. * @param value Value to be set.
  39470. * @returns this effect.
  39471. */
  39472. setInt(uniformName: string, value: number): Effect;
  39473. /**
  39474. * Sets an int2 value on a uniform variable.
  39475. * @param uniformName Name of the variable.
  39476. * @param x First int in int2.
  39477. * @param y Second int in int2.
  39478. * @returns this effect.
  39479. */
  39480. setInt2(uniformName: string, x: number, y: number): Effect;
  39481. /**
  39482. * Sets an int3 value on a uniform variable.
  39483. * @param uniformName Name of the variable.
  39484. * @param x First int in int3.
  39485. * @param y Second int in int3.
  39486. * @param z Third int in int3.
  39487. * @returns this effect.
  39488. */
  39489. setInt3(uniformName: string, x: number, y: number, z: number): Effect;
  39490. /**
  39491. * Sets an int4 value on a uniform variable.
  39492. * @param uniformName Name of the variable.
  39493. * @param x First int in int4.
  39494. * @param y Second int in int4.
  39495. * @param z Third int in int4.
  39496. * @param w Fourth int in int4.
  39497. * @returns this effect.
  39498. */
  39499. setInt4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39500. /**
  39501. * Sets an int array on a uniform variable.
  39502. * @param uniformName Name of the variable.
  39503. * @param array array to be set.
  39504. * @returns this effect.
  39505. */
  39506. setIntArray(uniformName: string, array: Int32Array): Effect;
  39507. /**
  39508. * 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)
  39509. * @param uniformName Name of the variable.
  39510. * @param array array to be set.
  39511. * @returns this effect.
  39512. */
  39513. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39514. /**
  39515. * 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)
  39516. * @param uniformName Name of the variable.
  39517. * @param array array to be set.
  39518. * @returns this effect.
  39519. */
  39520. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39521. /**
  39522. * 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)
  39523. * @param uniformName Name of the variable.
  39524. * @param array array to be set.
  39525. * @returns this effect.
  39526. */
  39527. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39528. /**
  39529. * Sets an float array on a uniform variable.
  39530. * @param uniformName Name of the variable.
  39531. * @param array array to be set.
  39532. * @returns this effect.
  39533. */
  39534. setFloatArray(uniformName: string, array: FloatArray): Effect;
  39535. /**
  39536. * 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)
  39537. * @param uniformName Name of the variable.
  39538. * @param array array to be set.
  39539. * @returns this effect.
  39540. */
  39541. setFloatArray2(uniformName: string, array: FloatArray): Effect;
  39542. /**
  39543. * 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)
  39544. * @param uniformName Name of the variable.
  39545. * @param array array to be set.
  39546. * @returns this effect.
  39547. */
  39548. setFloatArray3(uniformName: string, array: FloatArray): Effect;
  39549. /**
  39550. * 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)
  39551. * @param uniformName Name of the variable.
  39552. * @param array array to be set.
  39553. * @returns this effect.
  39554. */
  39555. setFloatArray4(uniformName: string, array: FloatArray): Effect;
  39556. /**
  39557. * Sets an array on a uniform variable.
  39558. * @param uniformName Name of the variable.
  39559. * @param array array to be set.
  39560. * @returns this effect.
  39561. */
  39562. setArray(uniformName: string, array: number[]): Effect;
  39563. /**
  39564. * 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)
  39565. * @param uniformName Name of the variable.
  39566. * @param array array to be set.
  39567. * @returns this effect.
  39568. */
  39569. setArray2(uniformName: string, array: number[]): Effect;
  39570. /**
  39571. * 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)
  39572. * @param uniformName Name of the variable.
  39573. * @param array array to be set.
  39574. * @returns this effect.
  39575. */
  39576. setArray3(uniformName: string, array: number[]): Effect;
  39577. /**
  39578. * 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)
  39579. * @param uniformName Name of the variable.
  39580. * @param array array to be set.
  39581. * @returns this effect.
  39582. */
  39583. setArray4(uniformName: string, array: number[]): Effect;
  39584. /**
  39585. * Sets matrices on a uniform variable.
  39586. * @param uniformName Name of the variable.
  39587. * @param matrices matrices to be set.
  39588. * @returns this effect.
  39589. */
  39590. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39591. /**
  39592. * Sets matrix on a uniform variable.
  39593. * @param uniformName Name of the variable.
  39594. * @param matrix matrix to be set.
  39595. * @returns this effect.
  39596. */
  39597. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39598. /**
  39599. * 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)
  39600. * @param uniformName Name of the variable.
  39601. * @param matrix matrix to be set.
  39602. * @returns this effect.
  39603. */
  39604. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39605. /**
  39606. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39607. * @param uniformName Name of the variable.
  39608. * @param matrix matrix to be set.
  39609. * @returns this effect.
  39610. */
  39611. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39612. /**
  39613. * Sets a float on a uniform variable.
  39614. * @param uniformName Name of the variable.
  39615. * @param value value to be set.
  39616. * @returns this effect.
  39617. */
  39618. setFloat(uniformName: string, value: number): Effect;
  39619. /**
  39620. * Sets a boolean on a uniform variable.
  39621. * @param uniformName Name of the variable.
  39622. * @param bool value to be set.
  39623. * @returns this effect.
  39624. */
  39625. setBool(uniformName: string, bool: boolean): Effect;
  39626. /**
  39627. * Sets a Vector2 on a uniform variable.
  39628. * @param uniformName Name of the variable.
  39629. * @param vector2 vector2 to be set.
  39630. * @returns this effect.
  39631. */
  39632. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39633. /**
  39634. * Sets a float2 on a uniform variable.
  39635. * @param uniformName Name of the variable.
  39636. * @param x First float in float2.
  39637. * @param y Second float in float2.
  39638. * @returns this effect.
  39639. */
  39640. setFloat2(uniformName: string, x: number, y: number): Effect;
  39641. /**
  39642. * Sets a Vector3 on a uniform variable.
  39643. * @param uniformName Name of the variable.
  39644. * @param vector3 Value to be set.
  39645. * @returns this effect.
  39646. */
  39647. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39648. /**
  39649. * Sets a float3 on a uniform variable.
  39650. * @param uniformName Name of the variable.
  39651. * @param x First float in float3.
  39652. * @param y Second float in float3.
  39653. * @param z Third float in float3.
  39654. * @returns this effect.
  39655. */
  39656. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39657. /**
  39658. * Sets a Vector4 on a uniform variable.
  39659. * @param uniformName Name of the variable.
  39660. * @param vector4 Value to be set.
  39661. * @returns this effect.
  39662. */
  39663. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39664. /**
  39665. * Sets a float4 on a uniform variable.
  39666. * @param uniformName Name of the variable.
  39667. * @param x First float in float4.
  39668. * @param y Second float in float4.
  39669. * @param z Third float in float4.
  39670. * @param w Fourth float in float4.
  39671. * @returns this effect.
  39672. */
  39673. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39674. /**
  39675. * Sets a Color3 on a uniform variable.
  39676. * @param uniformName Name of the variable.
  39677. * @param color3 Value to be set.
  39678. * @returns this effect.
  39679. */
  39680. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39681. /**
  39682. * Sets a Color4 on a uniform variable.
  39683. * @param uniformName Name of the variable.
  39684. * @param color3 Value to be set.
  39685. * @param alpha Alpha value to be set.
  39686. * @returns this effect.
  39687. */
  39688. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39689. /**
  39690. * Sets a Color4 on a uniform variable
  39691. * @param uniformName defines the name of the variable
  39692. * @param color4 defines the value to be set
  39693. * @returns this effect.
  39694. */
  39695. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39696. /**
  39697. * Release all associated resources.
  39698. **/
  39699. dispose(): void;
  39700. /**
  39701. * This function will add a new shader to the shader store
  39702. * @param name the name of the shader
  39703. * @param pixelShader optional pixel shader content
  39704. * @param vertexShader optional vertex shader content
  39705. */
  39706. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39707. /**
  39708. * Store of each shader (The can be looked up using effect.key)
  39709. */
  39710. static ShadersStore: {
  39711. [key: string]: string;
  39712. };
  39713. /**
  39714. * Store of each included file for a shader (The can be looked up using effect.key)
  39715. */
  39716. static IncludesShadersStore: {
  39717. [key: string]: string;
  39718. };
  39719. /**
  39720. * Resets the cache of effects.
  39721. */
  39722. static ResetCache(): void;
  39723. }
  39724. }
  39725. declare module BABYLON {
  39726. /**
  39727. * Interface used to describe the capabilities of the engine relatively to the current browser
  39728. */
  39729. export interface EngineCapabilities {
  39730. /** Maximum textures units per fragment shader */
  39731. maxTexturesImageUnits: number;
  39732. /** Maximum texture units per vertex shader */
  39733. maxVertexTextureImageUnits: number;
  39734. /** Maximum textures units in the entire pipeline */
  39735. maxCombinedTexturesImageUnits: number;
  39736. /** Maximum texture size */
  39737. maxTextureSize: number;
  39738. /** Maximum texture samples */
  39739. maxSamples?: number;
  39740. /** Maximum cube texture size */
  39741. maxCubemapTextureSize: number;
  39742. /** Maximum render texture size */
  39743. maxRenderTextureSize: number;
  39744. /** Maximum number of vertex attributes */
  39745. maxVertexAttribs: number;
  39746. /** Maximum number of varyings */
  39747. maxVaryingVectors: number;
  39748. /** Maximum number of uniforms per vertex shader */
  39749. maxVertexUniformVectors: number;
  39750. /** Maximum number of uniforms per fragment shader */
  39751. maxFragmentUniformVectors: number;
  39752. /** Defines if standard derivatives (dx/dy) are supported */
  39753. standardDerivatives: boolean;
  39754. /** Defines if s3tc texture compression is supported */
  39755. s3tc?: WEBGL_compressed_texture_s3tc;
  39756. /** Defines if pvrtc texture compression is supported */
  39757. pvrtc: any;
  39758. /** Defines if etc1 texture compression is supported */
  39759. etc1: any;
  39760. /** Defines if etc2 texture compression is supported */
  39761. etc2: any;
  39762. /** Defines if astc texture compression is supported */
  39763. astc: any;
  39764. /** Defines if bptc texture compression is supported */
  39765. bptc: any;
  39766. /** Defines if float textures are supported */
  39767. textureFloat: boolean;
  39768. /** Defines if vertex array objects are supported */
  39769. vertexArrayObject: boolean;
  39770. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  39771. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  39772. /** Gets the maximum level of anisotropy supported */
  39773. maxAnisotropy: number;
  39774. /** Defines if instancing is supported */
  39775. instancedArrays: boolean;
  39776. /** Defines if 32 bits indices are supported */
  39777. uintIndices: boolean;
  39778. /** Defines if high precision shaders are supported */
  39779. highPrecisionShaderSupported: boolean;
  39780. /** Defines if depth reading in the fragment shader is supported */
  39781. fragmentDepthSupported: boolean;
  39782. /** Defines if float texture linear filtering is supported*/
  39783. textureFloatLinearFiltering: boolean;
  39784. /** Defines if rendering to float textures is supported */
  39785. textureFloatRender: boolean;
  39786. /** Defines if half float textures are supported*/
  39787. textureHalfFloat: boolean;
  39788. /** Defines if half float texture linear filtering is supported*/
  39789. textureHalfFloatLinearFiltering: boolean;
  39790. /** Defines if rendering to half float textures is supported */
  39791. textureHalfFloatRender: boolean;
  39792. /** Defines if textureLOD shader command is supported */
  39793. textureLOD: boolean;
  39794. /** Defines if draw buffers extension is supported */
  39795. drawBuffersExtension: boolean;
  39796. /** Defines if depth textures are supported */
  39797. depthTextureExtension: boolean;
  39798. /** Defines if float color buffer are supported */
  39799. colorBufferFloat: boolean;
  39800. /** Gets disjoint timer query extension (null if not supported) */
  39801. timerQuery?: EXT_disjoint_timer_query;
  39802. /** Defines if timestamp can be used with timer query */
  39803. canUseTimestampForTimerQuery: boolean;
  39804. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  39805. multiview?: any;
  39806. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  39807. oculusMultiview?: any;
  39808. /** Function used to let the system compiles shaders in background */
  39809. parallelShaderCompile?: {
  39810. COMPLETION_STATUS_KHR: number;
  39811. };
  39812. /** Max number of texture samples for MSAA */
  39813. maxMSAASamples: number;
  39814. /** Defines if the blend min max extension is supported */
  39815. blendMinMax: boolean;
  39816. /** 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 */
  39817. canUseGLInstanceID: boolean;
  39818. /** Defines if gl_vertexID is available */
  39819. canUseGLVertexID: boolean;
  39820. }
  39821. }
  39822. declare module BABYLON {
  39823. /**
  39824. * @hidden
  39825. **/
  39826. export class DepthCullingState {
  39827. protected _isDepthTestDirty: boolean;
  39828. protected _isDepthMaskDirty: boolean;
  39829. protected _isDepthFuncDirty: boolean;
  39830. protected _isCullFaceDirty: boolean;
  39831. protected _isCullDirty: boolean;
  39832. protected _isZOffsetDirty: boolean;
  39833. protected _isFrontFaceDirty: boolean;
  39834. protected _depthTest: boolean;
  39835. protected _depthMask: boolean;
  39836. protected _depthFunc: Nullable<number>;
  39837. protected _cull: Nullable<boolean>;
  39838. protected _cullFace: Nullable<number>;
  39839. protected _zOffset: number;
  39840. protected _frontFace: Nullable<number>;
  39841. /**
  39842. * Initializes the state.
  39843. */
  39844. constructor(reset?: boolean);
  39845. get isDirty(): boolean;
  39846. get zOffset(): number;
  39847. set zOffset(value: number);
  39848. get cullFace(): Nullable<number>;
  39849. set cullFace(value: Nullable<number>);
  39850. get cull(): Nullable<boolean>;
  39851. set cull(value: Nullable<boolean>);
  39852. get depthFunc(): Nullable<number>;
  39853. set depthFunc(value: Nullable<number>);
  39854. get depthMask(): boolean;
  39855. set depthMask(value: boolean);
  39856. get depthTest(): boolean;
  39857. set depthTest(value: boolean);
  39858. get frontFace(): Nullable<number>;
  39859. set frontFace(value: Nullable<number>);
  39860. reset(): void;
  39861. apply(gl: WebGLRenderingContext): void;
  39862. }
  39863. }
  39864. declare module BABYLON {
  39865. /**
  39866. * @hidden
  39867. **/
  39868. export class StencilState {
  39869. /** 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 */
  39870. static readonly ALWAYS: number;
  39871. /** Passed to stencilOperation to specify that stencil value must be kept */
  39872. static readonly KEEP: number;
  39873. /** Passed to stencilOperation to specify that stencil value must be replaced */
  39874. static readonly REPLACE: number;
  39875. protected _isStencilTestDirty: boolean;
  39876. protected _isStencilMaskDirty: boolean;
  39877. protected _isStencilFuncDirty: boolean;
  39878. protected _isStencilOpDirty: boolean;
  39879. protected _stencilTest: boolean;
  39880. protected _stencilMask: number;
  39881. protected _stencilFunc: number;
  39882. protected _stencilFuncRef: number;
  39883. protected _stencilFuncMask: number;
  39884. protected _stencilOpStencilFail: number;
  39885. protected _stencilOpDepthFail: number;
  39886. protected _stencilOpStencilDepthPass: number;
  39887. get isDirty(): boolean;
  39888. get stencilFunc(): number;
  39889. set stencilFunc(value: number);
  39890. get stencilFuncRef(): number;
  39891. set stencilFuncRef(value: number);
  39892. get stencilFuncMask(): number;
  39893. set stencilFuncMask(value: number);
  39894. get stencilOpStencilFail(): number;
  39895. set stencilOpStencilFail(value: number);
  39896. get stencilOpDepthFail(): number;
  39897. set stencilOpDepthFail(value: number);
  39898. get stencilOpStencilDepthPass(): number;
  39899. set stencilOpStencilDepthPass(value: number);
  39900. get stencilMask(): number;
  39901. set stencilMask(value: number);
  39902. get stencilTest(): boolean;
  39903. set stencilTest(value: boolean);
  39904. constructor(reset?: boolean);
  39905. reset(): void;
  39906. apply(gl: WebGLRenderingContext): void;
  39907. }
  39908. }
  39909. declare module BABYLON {
  39910. /**
  39911. * @hidden
  39912. **/
  39913. export class AlphaState {
  39914. _blendFunctionParameters: Nullable<number>[];
  39915. _blendEquationParameters: Nullable<number>[];
  39916. _blendConstants: Nullable<number>[];
  39917. _isBlendConstantsDirty: boolean;
  39918. private _alphaBlend;
  39919. private _isAlphaBlendDirty;
  39920. private _isBlendFunctionParametersDirty;
  39921. private _isBlendEquationParametersDirty;
  39922. /**
  39923. * Initializes the state.
  39924. */
  39925. constructor();
  39926. get isDirty(): boolean;
  39927. get alphaBlend(): boolean;
  39928. set alphaBlend(value: boolean);
  39929. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  39930. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  39931. setAlphaEquationParameters(rgb: number, alpha: number): void;
  39932. reset(): void;
  39933. apply(gl: WebGLRenderingContext): void;
  39934. }
  39935. }
  39936. declare module BABYLON {
  39937. /** @hidden */
  39938. export class WebGLShaderProcessor implements IShaderProcessor {
  39939. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  39940. }
  39941. }
  39942. declare module BABYLON {
  39943. /** @hidden */
  39944. export class WebGL2ShaderProcessor implements IShaderProcessor {
  39945. attributeProcessor(attribute: string): string;
  39946. varyingProcessor(varying: string, isFragment: boolean): string;
  39947. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  39948. }
  39949. }
  39950. declare module BABYLON {
  39951. /**
  39952. * Interface for attribute information associated with buffer instantiation
  39953. */
  39954. export interface InstancingAttributeInfo {
  39955. /**
  39956. * Name of the GLSL attribute
  39957. * if attribute index is not specified, this is used to retrieve the index from the effect
  39958. */
  39959. attributeName: string;
  39960. /**
  39961. * Index/offset of the attribute in the vertex shader
  39962. * if not specified, this will be computes from the name.
  39963. */
  39964. index?: number;
  39965. /**
  39966. * size of the attribute, 1, 2, 3 or 4
  39967. */
  39968. attributeSize: number;
  39969. /**
  39970. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  39971. */
  39972. offset: number;
  39973. /**
  39974. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  39975. * default to 1
  39976. */
  39977. divisor?: number;
  39978. /**
  39979. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  39980. * default is FLOAT
  39981. */
  39982. attributeType?: number;
  39983. /**
  39984. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  39985. */
  39986. normalized?: boolean;
  39987. }
  39988. }
  39989. declare module BABYLON {
  39990. /** @hidden */
  39991. export interface EngineFeatures {
  39992. /** Force using Bitmap when Bitmap or HTMLImageElement can be used */
  39993. forceBitmapOverHTMLImageElement: boolean;
  39994. /** Indicates that the engine support rendering to as well as copying to lod float textures */
  39995. supportRenderAndCopyToLodForFloatTextures: boolean;
  39996. /** Indicates that the engine support handling depth/stencil textures */
  39997. supportDepthStencilTexture: boolean;
  39998. /** Indicates that the engine support shadow samplers */
  39999. supportShadowSamplers: boolean;
  40000. /** 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 */
  40001. uniformBufferHardCheckMatrix: boolean;
  40002. /** Indicates that prefiltered mipmaps can be generated in some processes (for eg when loading an HDR cube texture) */
  40003. allowTexturePrefiltering: boolean;
  40004. /** Indicates to track the usage of ubos and to create new ones as necessary during a frame duration */
  40005. trackUbosInFrame: boolean;
  40006. /** Indicates that the Cascaded Shadow Map technic is supported */
  40007. supportCSM: boolean;
  40008. /** Indicates that the textures transcoded by the basis transcoder must have power of 2 width and height */
  40009. basisNeedsPOT: boolean;
  40010. /** Indicates that the engine supports 3D textures */
  40011. support3DTextures: boolean;
  40012. /** Indicates that constants need a type suffix in shaders (used by realtime filtering...) */
  40013. needTypeSuffixInShaderConstants: boolean;
  40014. /** Indicates that MSAA is supported */
  40015. supportMSAA: boolean;
  40016. /** Indicates that SSAO2 is supported */
  40017. supportSSAO2: boolean;
  40018. /** Indicates that some additional texture formats are supported (like TEXTUREFORMAT_R for eg) */
  40019. supportExtendedTextureFormats: boolean;
  40020. /** Indicates that the switch/case construct is supported in shaders */
  40021. supportSwitchCaseInShader: boolean;
  40022. /** Indicates that synchronous texture reading is supported */
  40023. supportSyncTextureRead: boolean;
  40024. /** @hidden */
  40025. _collectUbosUpdatedInFrame: boolean;
  40026. }
  40027. }
  40028. declare module BABYLON {
  40029. /** @hidden */
  40030. export class WebGLHardwareTexture implements HardwareTextureWrapper {
  40031. private _webGLTexture;
  40032. private _context;
  40033. get underlyingResource(): Nullable<WebGLTexture>;
  40034. constructor(existingTexture: WebGLTexture | null | undefined, context: WebGLRenderingContext);
  40035. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  40036. set(hardwareTexture: WebGLTexture): void;
  40037. reset(): void;
  40038. release(): void;
  40039. }
  40040. }
  40041. declare module BABYLON {
  40042. interface ThinEngine {
  40043. /**
  40044. * Update a video texture
  40045. * @param texture defines the texture to update
  40046. * @param video defines the video element to use
  40047. * @param invertY defines if data must be stored with Y axis inverted
  40048. */
  40049. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  40050. }
  40051. }
  40052. declare module BABYLON {
  40053. interface ThinEngine {
  40054. /**
  40055. * Creates a dynamic texture
  40056. * @param width defines the width of the texture
  40057. * @param height defines the height of the texture
  40058. * @param generateMipMaps defines if the engine should generate the mip levels
  40059. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  40060. * @returns the dynamic texture inside an InternalTexture
  40061. */
  40062. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  40063. /**
  40064. * Update the content of a dynamic texture
  40065. * @param texture defines the texture to update
  40066. * @param source defines the source containing the data
  40067. * @param invertY defines if data must be stored with Y axis inverted
  40068. * @param premulAlpha defines if alpha is stored as premultiplied
  40069. * @param format defines the format of the data
  40070. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  40071. */
  40072. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  40073. }
  40074. }
  40075. declare module BABYLON {
  40076. /**
  40077. * Settings for finer control over video usage
  40078. */
  40079. export interface VideoTextureSettings {
  40080. /**
  40081. * Applies `autoplay` to video, if specified
  40082. */
  40083. autoPlay?: boolean;
  40084. /**
  40085. * Applies `muted` to video, if specified
  40086. */
  40087. muted?: boolean;
  40088. /**
  40089. * Applies `loop` to video, if specified
  40090. */
  40091. loop?: boolean;
  40092. /**
  40093. * Automatically updates internal texture from video at every frame in the render loop
  40094. */
  40095. autoUpdateTexture: boolean;
  40096. /**
  40097. * Image src displayed during the video loading or until the user interacts with the video.
  40098. */
  40099. poster?: string;
  40100. }
  40101. /**
  40102. * If you want to display a video in your scene, this is the special texture for that.
  40103. * This special texture works similar to other textures, with the exception of a few parameters.
  40104. * @see https://doc.babylonjs.com/how_to/video_texture
  40105. */
  40106. export class VideoTexture extends Texture {
  40107. /**
  40108. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  40109. */
  40110. readonly autoUpdateTexture: boolean;
  40111. /**
  40112. * The video instance used by the texture internally
  40113. */
  40114. readonly video: HTMLVideoElement;
  40115. private _onUserActionRequestedObservable;
  40116. /**
  40117. * Event triggered when a dom action is required by the user to play the video.
  40118. * This happens due to recent changes in browser policies preventing video to auto start.
  40119. */
  40120. get onUserActionRequestedObservable(): Observable<Texture>;
  40121. private _generateMipMaps;
  40122. private _stillImageCaptured;
  40123. private _displayingPosterTexture;
  40124. private _settings;
  40125. private _createInternalTextureOnEvent;
  40126. private _frameId;
  40127. private _currentSrc;
  40128. /**
  40129. * Creates a video texture.
  40130. * If you want to display a video in your scene, this is the special texture for that.
  40131. * This special texture works similar to other textures, with the exception of a few parameters.
  40132. * @see https://doc.babylonjs.com/how_to/video_texture
  40133. * @param name optional name, will detect from video source, if not defined
  40134. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  40135. * @param scene is obviously the current scene.
  40136. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  40137. * @param invertY is false by default but can be used to invert video on Y axis
  40138. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  40139. * @param settings allows finer control over video usage
  40140. */
  40141. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  40142. private _getName;
  40143. private _getVideo;
  40144. private _createInternalTexture;
  40145. private reset;
  40146. /**
  40147. * @hidden Internal method to initiate `update`.
  40148. */
  40149. _rebuild(): void;
  40150. /**
  40151. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  40152. */
  40153. update(): void;
  40154. /**
  40155. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  40156. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or otherwise.
  40157. */
  40158. updateTexture(isVisible: boolean): void;
  40159. protected _updateInternalTexture: () => void;
  40160. /**
  40161. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  40162. * @param url New url.
  40163. */
  40164. updateURL(url: string): void;
  40165. /**
  40166. * Clones the texture.
  40167. * @returns the cloned texture
  40168. */
  40169. clone(): VideoTexture;
  40170. /**
  40171. * Dispose the texture and release its associated resources.
  40172. */
  40173. dispose(): void;
  40174. /**
  40175. * Creates a video texture straight from a stream.
  40176. * @param scene Define the scene the texture should be created in
  40177. * @param stream Define the stream the texture should be created from
  40178. * @returns The created video texture as a promise
  40179. */
  40180. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  40181. /**
  40182. * Creates a video texture straight from your WebCam video feed.
  40183. * @param scene Define the scene the texture should be created in
  40184. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40185. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40186. * @returns The created video texture as a promise
  40187. */
  40188. static CreateFromWebCamAsync(scene: Scene, constraints: {
  40189. minWidth: number;
  40190. maxWidth: number;
  40191. minHeight: number;
  40192. maxHeight: number;
  40193. deviceId: string;
  40194. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  40195. /**
  40196. * Creates a video texture straight from your WebCam video feed.
  40197. * @param scene Define the scene the texture should be created in
  40198. * @param onReady Define a callback to triggered once the texture will be ready
  40199. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40200. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40201. */
  40202. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  40203. minWidth: number;
  40204. maxWidth: number;
  40205. minHeight: number;
  40206. maxHeight: number;
  40207. deviceId: string;
  40208. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  40209. }
  40210. }
  40211. declare module BABYLON {
  40212. /**
  40213. * Defines the interface used by objects working like Scene
  40214. * @hidden
  40215. */
  40216. export interface ISceneLike {
  40217. _addPendingData(data: any): void;
  40218. _removePendingData(data: any): void;
  40219. offlineProvider: IOfflineProvider;
  40220. }
  40221. /**
  40222. * Information about the current host
  40223. */
  40224. export interface HostInformation {
  40225. /**
  40226. * Defines if the current host is a mobile
  40227. */
  40228. isMobile: boolean;
  40229. }
  40230. /** Interface defining initialization parameters for Engine class */
  40231. export interface EngineOptions extends WebGLContextAttributes {
  40232. /**
  40233. * Defines if the engine should no exceed a specified device ratio
  40234. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  40235. */
  40236. limitDeviceRatio?: number;
  40237. /**
  40238. * Defines if webvr should be enabled automatically
  40239. * @see https://doc.babylonjs.com/how_to/webvr_camera
  40240. */
  40241. autoEnableWebVR?: boolean;
  40242. /**
  40243. * Defines if webgl2 should be turned off even if supported
  40244. * @see https://doc.babylonjs.com/features/webgl2
  40245. */
  40246. disableWebGL2Support?: boolean;
  40247. /**
  40248. * Defines if webaudio should be initialized as well
  40249. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40250. */
  40251. audioEngine?: boolean;
  40252. /**
  40253. * Defines if animations should run using a deterministic lock step
  40254. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40255. */
  40256. deterministicLockstep?: boolean;
  40257. /** Defines the maximum steps to use with deterministic lock step mode */
  40258. lockstepMaxSteps?: number;
  40259. /** Defines the seconds between each deterministic lock step */
  40260. timeStep?: number;
  40261. /**
  40262. * Defines that engine should ignore context lost events
  40263. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  40264. */
  40265. doNotHandleContextLost?: boolean;
  40266. /**
  40267. * Defines that engine should ignore modifying touch action attribute and style
  40268. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  40269. */
  40270. doNotHandleTouchAction?: boolean;
  40271. /**
  40272. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  40273. */
  40274. useHighPrecisionFloats?: boolean;
  40275. /**
  40276. * Make the canvas XR Compatible for XR sessions
  40277. */
  40278. xrCompatible?: boolean;
  40279. /**
  40280. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  40281. */
  40282. useHighPrecisionMatrix?: boolean;
  40283. /**
  40284. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  40285. */
  40286. failIfMajorPerformanceCaveat?: boolean;
  40287. /**
  40288. * Defines whether to adapt to the device's viewport characteristics (default: false)
  40289. */
  40290. adaptToDeviceRatio?: boolean;
  40291. }
  40292. /**
  40293. * The base engine class (root of all engines)
  40294. */
  40295. export class ThinEngine {
  40296. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  40297. static ExceptionList: ({
  40298. key: string;
  40299. capture: string;
  40300. captureConstraint: number;
  40301. targets: string[];
  40302. } | {
  40303. key: string;
  40304. capture: null;
  40305. captureConstraint: null;
  40306. targets: string[];
  40307. })[];
  40308. /** @hidden */
  40309. static _TextureLoaders: IInternalTextureLoader[];
  40310. /**
  40311. * Returns the current npm package of the sdk
  40312. */
  40313. static get NpmPackage(): string;
  40314. /**
  40315. * Returns the current version of the framework
  40316. */
  40317. static get Version(): string;
  40318. /**
  40319. * Returns a string describing the current engine
  40320. */
  40321. get description(): string;
  40322. /**
  40323. * Returns the name of the engine
  40324. */
  40325. get name(): string;
  40326. /**
  40327. * Returns the version of the engine
  40328. */
  40329. get version(): number;
  40330. /**
  40331. * Gets or sets the epsilon value used by collision engine
  40332. */
  40333. static CollisionsEpsilon: number;
  40334. /**
  40335. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  40336. */
  40337. static get ShadersRepository(): string;
  40338. static set ShadersRepository(value: string);
  40339. /** @hidden */
  40340. _shaderProcessor: Nullable<IShaderProcessor>;
  40341. /**
  40342. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  40343. */
  40344. forcePOTTextures: boolean;
  40345. /**
  40346. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  40347. */
  40348. isFullscreen: boolean;
  40349. /**
  40350. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  40351. */
  40352. cullBackFaces: boolean;
  40353. /**
  40354. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  40355. */
  40356. renderEvenInBackground: boolean;
  40357. /**
  40358. * Gets or sets a boolean indicating that cache can be kept between frames
  40359. */
  40360. preventCacheWipeBetweenFrames: boolean;
  40361. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  40362. validateShaderPrograms: boolean;
  40363. /**
  40364. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  40365. * This can provide greater z depth for distant objects.
  40366. */
  40367. useReverseDepthBuffer: boolean;
  40368. /**
  40369. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  40370. */
  40371. disableUniformBuffers: boolean;
  40372. private _frameId;
  40373. /**
  40374. * Gets the current frame id
  40375. */
  40376. get frameId(): number;
  40377. /** @hidden */
  40378. _uniformBuffers: UniformBuffer[];
  40379. /**
  40380. * Gets a boolean indicating that the engine supports uniform buffers
  40381. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  40382. */
  40383. get supportsUniformBuffers(): boolean;
  40384. /** @hidden */
  40385. _gl: WebGLRenderingContext;
  40386. /** @hidden */
  40387. _webGLVersion: number;
  40388. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  40389. protected _windowIsBackground: boolean;
  40390. protected _creationOptions: EngineOptions;
  40391. protected _highPrecisionShadersAllowed: boolean;
  40392. /** @hidden */
  40393. get _shouldUseHighPrecisionShader(): boolean;
  40394. /**
  40395. * Gets a boolean indicating that only power of 2 textures are supported
  40396. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  40397. */
  40398. get needPOTTextures(): boolean;
  40399. /** @hidden */
  40400. _badOS: boolean;
  40401. /** @hidden */
  40402. _badDesktopOS: boolean;
  40403. protected _hardwareScalingLevel: number;
  40404. /** @hidden */
  40405. _caps: EngineCapabilities;
  40406. /** @hidden */
  40407. _features: EngineFeatures;
  40408. protected _isStencilEnable: boolean;
  40409. private _glVersion;
  40410. private _glRenderer;
  40411. private _glVendor;
  40412. /** @hidden */
  40413. _videoTextureSupported: boolean;
  40414. protected _renderingQueueLaunched: boolean;
  40415. protected _activeRenderLoops: (() => void)[];
  40416. /**
  40417. * Observable signaled when a context lost event is raised
  40418. */
  40419. onContextLostObservable: Observable<ThinEngine>;
  40420. /**
  40421. * Observable signaled when a context restored event is raised
  40422. */
  40423. onContextRestoredObservable: Observable<ThinEngine>;
  40424. private _onContextLost;
  40425. private _onContextRestored;
  40426. protected _contextWasLost: boolean;
  40427. /** @hidden */
  40428. _doNotHandleContextLost: boolean;
  40429. /**
  40430. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40431. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40432. */
  40433. get doNotHandleContextLost(): boolean;
  40434. set doNotHandleContextLost(value: boolean);
  40435. /**
  40436. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40437. */
  40438. disableVertexArrayObjects: boolean;
  40439. /** @hidden */
  40440. protected _colorWrite: boolean;
  40441. /** @hidden */
  40442. protected _colorWriteChanged: boolean;
  40443. /** @hidden */
  40444. protected _depthCullingState: DepthCullingState;
  40445. /** @hidden */
  40446. protected _stencilState: StencilState;
  40447. /** @hidden */
  40448. _alphaState: AlphaState;
  40449. /** @hidden */
  40450. _alphaMode: number;
  40451. /** @hidden */
  40452. _alphaEquation: number;
  40453. /** @hidden */
  40454. _internalTexturesCache: InternalTexture[];
  40455. /** @hidden */
  40456. protected _activeChannel: number;
  40457. private _currentTextureChannel;
  40458. /** @hidden */
  40459. protected _boundTexturesCache: {
  40460. [key: string]: Nullable<InternalTexture>;
  40461. };
  40462. /** @hidden */
  40463. protected _currentEffect: Nullable<Effect>;
  40464. /** @hidden */
  40465. protected _currentProgram: Nullable<WebGLProgram>;
  40466. protected _compiledEffects: {
  40467. [key: string]: Effect;
  40468. };
  40469. private _vertexAttribArraysEnabled;
  40470. /** @hidden */
  40471. protected _cachedViewport: Nullable<IViewportLike>;
  40472. private _cachedVertexArrayObject;
  40473. /** @hidden */
  40474. protected _cachedVertexBuffers: any;
  40475. /** @hidden */
  40476. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40477. /** @hidden */
  40478. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40479. /** @hidden */
  40480. _currentRenderTarget: Nullable<InternalTexture>;
  40481. private _uintIndicesCurrentlySet;
  40482. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40483. /** @hidden */
  40484. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40485. /** @hidden */
  40486. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40487. private _currentBufferPointers;
  40488. private _currentInstanceLocations;
  40489. private _currentInstanceBuffers;
  40490. private _textureUnits;
  40491. /** @hidden */
  40492. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40493. /** @hidden */
  40494. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40495. /** @hidden */
  40496. _boundRenderFunction: any;
  40497. private _vaoRecordInProgress;
  40498. private _mustWipeVertexAttributes;
  40499. private _emptyTexture;
  40500. private _emptyCubeTexture;
  40501. private _emptyTexture3D;
  40502. private _emptyTexture2DArray;
  40503. /** @hidden */
  40504. _frameHandler: number;
  40505. private _nextFreeTextureSlots;
  40506. private _maxSimultaneousTextures;
  40507. private _activeRequests;
  40508. /** @hidden */
  40509. _transformTextureUrl: Nullable<(url: string) => string>;
  40510. /**
  40511. * Gets information about the current host
  40512. */
  40513. hostInformation: HostInformation;
  40514. protected get _supportsHardwareTextureRescaling(): boolean;
  40515. private _framebufferDimensionsObject;
  40516. /**
  40517. * sets the object from which width and height will be taken from when getting render width and height
  40518. * Will fallback to the gl object
  40519. * @param dimensions the framebuffer width and height that will be used.
  40520. */
  40521. set framebufferDimensionsObject(dimensions: Nullable<{
  40522. framebufferWidth: number;
  40523. framebufferHeight: number;
  40524. }>);
  40525. /**
  40526. * Gets the current viewport
  40527. */
  40528. get currentViewport(): Nullable<IViewportLike>;
  40529. /**
  40530. * Gets the default empty texture
  40531. */
  40532. get emptyTexture(): InternalTexture;
  40533. /**
  40534. * Gets the default empty 3D texture
  40535. */
  40536. get emptyTexture3D(): InternalTexture;
  40537. /**
  40538. * Gets the default empty 2D array texture
  40539. */
  40540. get emptyTexture2DArray(): InternalTexture;
  40541. /**
  40542. * Gets the default empty cube texture
  40543. */
  40544. get emptyCubeTexture(): InternalTexture;
  40545. /**
  40546. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40547. */
  40548. premultipliedAlpha: boolean;
  40549. /**
  40550. * Observable event triggered before each texture is initialized
  40551. */
  40552. onBeforeTextureInitObservable: Observable<Texture>;
  40553. /** @hidden */
  40554. protected _isWebGPU: boolean;
  40555. /**
  40556. * Gets a boolean indicating if the engine runs in WebGPU or not.
  40557. */
  40558. get isWebGPU(): boolean;
  40559. /** @hidden */
  40560. protected _shaderPlatformName: string;
  40561. /**
  40562. * Gets the shader platfrom name used by the effects.
  40563. */
  40564. get shaderPlatformName(): string;
  40565. /**
  40566. * Creates a new engine
  40567. * @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
  40568. * @param antialias defines enable antialiasing (default: false)
  40569. * @param options defines further options to be sent to the getContext() function
  40570. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40571. */
  40572. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40573. /**
  40574. * @hidden
  40575. */
  40576. _debugPushGroup(groupName: string, targetObject?: number): void;
  40577. /**
  40578. * @hidden
  40579. */
  40580. _debugPopGroup(targetObject?: number): void;
  40581. /**
  40582. * @hidden
  40583. */
  40584. _debugInsertMarker(text: string, targetObject?: number): void;
  40585. /**
  40586. * Shared initialization across engines types.
  40587. * @param canvas The canvas associated with this instance of the engine.
  40588. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  40589. * @param audioEngine Defines if an audio engine should be created by default
  40590. */
  40591. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  40592. /**
  40593. * Gets a shader processor implementation fitting with the current engine type.
  40594. * @returns The shader processor implementation.
  40595. */
  40596. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  40597. /** @hidden */
  40598. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  40599. private _rebuildInternalTextures;
  40600. private _rebuildEffects;
  40601. /**
  40602. * Gets a boolean indicating if all created effects are ready
  40603. * @returns true if all effects are ready
  40604. */
  40605. areAllEffectsReady(): boolean;
  40606. protected _rebuildBuffers(): void;
  40607. protected _initGLContext(): void;
  40608. protected _initFeatures(): void;
  40609. /**
  40610. * Gets version of the current webGL context
  40611. * Keep it for back compat - use version instead
  40612. */
  40613. get webGLVersion(): number;
  40614. /**
  40615. * Gets a string identifying the name of the class
  40616. * @returns "Engine" string
  40617. */
  40618. getClassName(): string;
  40619. /**
  40620. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40621. */
  40622. get isStencilEnable(): boolean;
  40623. /** @hidden */
  40624. _prepareWorkingCanvas(): void;
  40625. /**
  40626. * Reset the texture cache to empty state
  40627. */
  40628. resetTextureCache(): void;
  40629. /**
  40630. * Gets an object containing information about the current webGL context
  40631. * @returns an object containing the vendor, the renderer and the version of the current webGL context
  40632. */
  40633. getGlInfo(): {
  40634. vendor: string;
  40635. renderer: string;
  40636. version: string;
  40637. };
  40638. /**
  40639. * Defines the hardware scaling level.
  40640. * By default the hardware scaling level is computed from the window device ratio.
  40641. * 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.
  40642. * @param level defines the level to use
  40643. */
  40644. setHardwareScalingLevel(level: number): void;
  40645. /**
  40646. * Gets the current hardware scaling level.
  40647. * By default the hardware scaling level is computed from the window device ratio.
  40648. * 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.
  40649. * @returns a number indicating the current hardware scaling level
  40650. */
  40651. getHardwareScalingLevel(): number;
  40652. /**
  40653. * Gets the list of loaded textures
  40654. * @returns an array containing all loaded textures
  40655. */
  40656. getLoadedTexturesCache(): InternalTexture[];
  40657. /**
  40658. * Gets the object containing all engine capabilities
  40659. * @returns the EngineCapabilities object
  40660. */
  40661. getCaps(): EngineCapabilities;
  40662. /**
  40663. * stop executing a render loop function and remove it from the execution array
  40664. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40665. */
  40666. stopRenderLoop(renderFunction?: () => void): void;
  40667. /** @hidden */
  40668. _renderLoop(): void;
  40669. /**
  40670. * Gets the HTML canvas attached with the current webGL context
  40671. * @returns a HTML canvas
  40672. */
  40673. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40674. /**
  40675. * Gets host window
  40676. * @returns the host window object
  40677. */
  40678. getHostWindow(): Nullable<Window>;
  40679. /**
  40680. * Gets the current render width
  40681. * @param useScreen defines if screen size must be used (or the current render target if any)
  40682. * @returns a number defining the current render width
  40683. */
  40684. getRenderWidth(useScreen?: boolean): number;
  40685. /**
  40686. * Gets the current render height
  40687. * @param useScreen defines if screen size must be used (or the current render target if any)
  40688. * @returns a number defining the current render height
  40689. */
  40690. getRenderHeight(useScreen?: boolean): number;
  40691. /**
  40692. * Can be used to override the current requestAnimationFrame requester.
  40693. * @hidden
  40694. */
  40695. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40696. /**
  40697. * Register and execute a render loop. The engine can have more than one render function
  40698. * @param renderFunction defines the function to continuously execute
  40699. */
  40700. runRenderLoop(renderFunction: () => void): void;
  40701. /**
  40702. * Clear the current render buffer or the current render target (if any is set up)
  40703. * @param color defines the color to use
  40704. * @param backBuffer defines if the back buffer must be cleared
  40705. * @param depth defines if the depth buffer must be cleared
  40706. * @param stencil defines if the stencil buffer must be cleared
  40707. */
  40708. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40709. protected _viewportCached: {
  40710. x: number;
  40711. y: number;
  40712. z: number;
  40713. w: number;
  40714. };
  40715. /** @hidden */
  40716. _viewport(x: number, y: number, width: number, height: number): void;
  40717. /**
  40718. * Set the WebGL's viewport
  40719. * @param viewport defines the viewport element to be used
  40720. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40721. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40722. */
  40723. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40724. /**
  40725. * Begin a new frame
  40726. */
  40727. beginFrame(): void;
  40728. /**
  40729. * Enf the current frame
  40730. */
  40731. endFrame(): void;
  40732. /**
  40733. * Resize the view according to the canvas' size
  40734. * @param forceSetSize true to force setting the sizes of the underlying canvas
  40735. */
  40736. resize(forceSetSize?: boolean): void;
  40737. /**
  40738. * Force a specific size of the canvas
  40739. * @param width defines the new canvas' width
  40740. * @param height defines the new canvas' height
  40741. * @param forceSetSize true to force setting the sizes of the underlying canvas
  40742. * @returns true if the size was changed
  40743. */
  40744. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  40745. /**
  40746. * Binds the frame buffer to the specified texture.
  40747. * @param texture The texture to render to or null for the default canvas
  40748. * @param faceIndex The face of the texture to render to in case of cube texture
  40749. * @param requiredWidth The width of the target to render to
  40750. * @param requiredHeight The height of the target to render to
  40751. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40752. * @param lodLevel defines the lod level to bind to the frame buffer
  40753. * @param layer defines the 2d array index to bind to frame buffer to
  40754. */
  40755. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40756. /** @hidden */
  40757. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40758. /**
  40759. * Unbind the current render target texture from the webGL context
  40760. * @param texture defines the render target texture to unbind
  40761. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40762. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40763. */
  40764. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40765. /**
  40766. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40767. */
  40768. flushFramebuffer(): void;
  40769. /**
  40770. * Unbind the current render target and bind the default framebuffer
  40771. */
  40772. restoreDefaultFramebuffer(): void;
  40773. /** @hidden */
  40774. protected _resetVertexBufferBinding(): void;
  40775. /**
  40776. * Creates a vertex buffer
  40777. * @param data the data for the vertex buffer
  40778. * @returns the new WebGL static buffer
  40779. */
  40780. createVertexBuffer(data: DataArray): DataBuffer;
  40781. private _createVertexBuffer;
  40782. /**
  40783. * Creates a dynamic vertex buffer
  40784. * @param data the data for the dynamic vertex buffer
  40785. * @returns the new WebGL dynamic buffer
  40786. */
  40787. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40788. protected _resetIndexBufferBinding(): void;
  40789. /**
  40790. * Creates a new index buffer
  40791. * @param indices defines the content of the index buffer
  40792. * @param updatable defines if the index buffer must be updatable
  40793. * @returns a new webGL buffer
  40794. */
  40795. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40796. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40797. /**
  40798. * Bind a webGL buffer to the webGL context
  40799. * @param buffer defines the buffer to bind
  40800. */
  40801. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40802. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40803. private bindBuffer;
  40804. /**
  40805. * update the bound buffer with the given data
  40806. * @param data defines the data to update
  40807. */
  40808. updateArrayBuffer(data: Float32Array): void;
  40809. private _vertexAttribPointer;
  40810. /** @hidden */
  40811. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40812. private _bindVertexBuffersAttributes;
  40813. /**
  40814. * Records a vertex array object
  40815. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40816. * @param vertexBuffers defines the list of vertex buffers to store
  40817. * @param indexBuffer defines the index buffer to store
  40818. * @param effect defines the effect to store
  40819. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  40820. * @returns the new vertex array object
  40821. */
  40822. recordVertexArrayObject(vertexBuffers: {
  40823. [key: string]: VertexBuffer;
  40824. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  40825. [kind: string]: Nullable<VertexBuffer>;
  40826. }): WebGLVertexArrayObject;
  40827. /**
  40828. * Bind a specific vertex array object
  40829. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40830. * @param vertexArrayObject defines the vertex array object to bind
  40831. * @param indexBuffer defines the index buffer to bind
  40832. */
  40833. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40834. /**
  40835. * Bind webGl buffers directly to the webGL context
  40836. * @param vertexBuffer defines the vertex buffer to bind
  40837. * @param indexBuffer defines the index buffer to bind
  40838. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40839. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40840. * @param effect defines the effect associated with the vertex buffer
  40841. */
  40842. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40843. private _unbindVertexArrayObject;
  40844. /**
  40845. * Bind a list of vertex buffers to the webGL context
  40846. * @param vertexBuffers defines the list of vertex buffers to bind
  40847. * @param indexBuffer defines the index buffer to bind
  40848. * @param effect defines the effect associated with the vertex buffers
  40849. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  40850. */
  40851. bindBuffers(vertexBuffers: {
  40852. [key: string]: Nullable<VertexBuffer>;
  40853. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  40854. [kind: string]: Nullable<VertexBuffer>;
  40855. }): void;
  40856. /**
  40857. * Unbind all instance attributes
  40858. */
  40859. unbindInstanceAttributes(): void;
  40860. /**
  40861. * Release and free the memory of a vertex array object
  40862. * @param vao defines the vertex array object to delete
  40863. */
  40864. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  40865. /** @hidden */
  40866. _releaseBuffer(buffer: DataBuffer): boolean;
  40867. protected _deleteBuffer(buffer: DataBuffer): void;
  40868. /**
  40869. * Update the content of a webGL buffer used with instantiation and bind it to the webGL context
  40870. * @param instancesBuffer defines the webGL buffer to update and bind
  40871. * @param data defines the data to store in the buffer
  40872. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  40873. */
  40874. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  40875. /**
  40876. * Bind the content of a webGL buffer used with instantiation
  40877. * @param instancesBuffer defines the webGL buffer to bind
  40878. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  40879. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  40880. */
  40881. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  40882. /**
  40883. * Disable the instance attribute corresponding to the name in parameter
  40884. * @param name defines the name of the attribute to disable
  40885. */
  40886. disableInstanceAttributeByName(name: string): void;
  40887. /**
  40888. * Disable the instance attribute corresponding to the location in parameter
  40889. * @param attributeLocation defines the attribute location of the attribute to disable
  40890. */
  40891. disableInstanceAttribute(attributeLocation: number): void;
  40892. /**
  40893. * Disable the attribute corresponding to the location in parameter
  40894. * @param attributeLocation defines the attribute location of the attribute to disable
  40895. */
  40896. disableAttributeByIndex(attributeLocation: number): void;
  40897. /**
  40898. * Send a draw order
  40899. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40900. * @param indexStart defines the starting index
  40901. * @param indexCount defines the number of index to draw
  40902. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  40903. */
  40904. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40905. /**
  40906. * Draw a list of points
  40907. * @param verticesStart defines the index of first vertex to draw
  40908. * @param verticesCount defines the count of vertices to draw
  40909. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  40910. */
  40911. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40912. /**
  40913. * Draw a list of unindexed primitives
  40914. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40915. * @param verticesStart defines the index of first vertex to draw
  40916. * @param verticesCount defines the count of vertices to draw
  40917. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  40918. */
  40919. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40920. /**
  40921. * Draw a list of indexed primitives
  40922. * @param fillMode defines the primitive to use
  40923. * @param indexStart defines the starting index
  40924. * @param indexCount defines the number of index to draw
  40925. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  40926. */
  40927. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40928. /**
  40929. * Draw a list of unindexed primitives
  40930. * @param fillMode defines the primitive to use
  40931. * @param verticesStart defines the index of first vertex to draw
  40932. * @param verticesCount defines the count of vertices to draw
  40933. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  40934. */
  40935. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40936. private _drawMode;
  40937. /** @hidden */
  40938. protected _reportDrawCall(): void;
  40939. /** @hidden */
  40940. _releaseEffect(effect: Effect): void;
  40941. /** @hidden */
  40942. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  40943. /**
  40944. * Create a new effect (used to store vertex/fragment shaders)
  40945. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  40946. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  40947. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  40948. * @param samplers defines an array of string used to represent textures
  40949. * @param defines defines the string containing the defines to use to compile the shaders
  40950. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  40951. * @param onCompiled defines a function to call when the effect creation is successful
  40952. * @param onError defines a function to call when the effect creation has failed
  40953. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  40954. * @returns the new Effect
  40955. */
  40956. 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;
  40957. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  40958. private _compileShader;
  40959. private _compileRawShader;
  40960. /** @hidden */
  40961. _getShaderSource(shader: WebGLShader): Nullable<string>;
  40962. /**
  40963. * Directly creates a webGL program
  40964. * @param pipelineContext defines the pipeline context to attach to
  40965. * @param vertexCode defines the vertex shader code to use
  40966. * @param fragmentCode defines the fragment shader code to use
  40967. * @param context defines the webGL context to use (if not set, the current one will be used)
  40968. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40969. * @returns the new webGL program
  40970. */
  40971. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40972. /**
  40973. * Creates a webGL program
  40974. * @param pipelineContext defines the pipeline context to attach to
  40975. * @param vertexCode defines the vertex shader code to use
  40976. * @param fragmentCode defines the fragment shader code to use
  40977. * @param defines defines the string containing the defines to use to compile the shaders
  40978. * @param context defines the webGL context to use (if not set, the current one will be used)
  40979. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40980. * @returns the new webGL program
  40981. */
  40982. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40983. /**
  40984. * Creates a new pipeline context
  40985. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  40986. * @returns the new pipeline
  40987. */
  40988. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  40989. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40990. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  40991. /** @hidden */
  40992. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  40993. /** @hidden */
  40994. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  40995. /** @hidden */
  40996. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  40997. /**
  40998. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  40999. * @param pipelineContext defines the pipeline context to use
  41000. * @param uniformsNames defines the list of uniform names
  41001. * @returns an array of webGL uniform locations
  41002. */
  41003. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41004. /**
  41005. * Gets the list of active attributes for a given webGL program
  41006. * @param pipelineContext defines the pipeline context to use
  41007. * @param attributesNames defines the list of attribute names to get
  41008. * @returns an array of indices indicating the offset of each attribute
  41009. */
  41010. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41011. /**
  41012. * Activates an effect, making it the current one (ie. the one used for rendering)
  41013. * @param effect defines the effect to activate
  41014. */
  41015. enableEffect(effect: Nullable<Effect>): void;
  41016. /**
  41017. * Set the value of an uniform to a number (int)
  41018. * @param uniform defines the webGL uniform location where to store the value
  41019. * @param value defines the int number to store
  41020. * @returns true if the value was set
  41021. */
  41022. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  41023. /**
  41024. * Set the value of an uniform to a int2
  41025. * @param uniform defines the webGL uniform location where to store the value
  41026. * @param x defines the 1st component of the value
  41027. * @param y defines the 2nd component of the value
  41028. * @returns true if the value was set
  41029. */
  41030. setInt2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  41031. /**
  41032. * Set the value of an uniform to a int3
  41033. * @param uniform defines the webGL uniform location where to store the value
  41034. * @param x defines the 1st component of the value
  41035. * @param y defines the 2nd component of the value
  41036. * @param z defines the 3rd component of the value
  41037. * @returns true if the value was set
  41038. */
  41039. setInt3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  41040. /**
  41041. * Set the value of an uniform to a int4
  41042. * @param uniform defines the webGL uniform location where to store the value
  41043. * @param x defines the 1st component of the value
  41044. * @param y defines the 2nd component of the value
  41045. * @param z defines the 3rd component of the value
  41046. * @param w defines the 4th component of the value
  41047. * @returns true if the value was set
  41048. */
  41049. setInt4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  41050. /**
  41051. * Set the value of an uniform to an array of int32
  41052. * @param uniform defines the webGL uniform location where to store the value
  41053. * @param array defines the array of int32 to store
  41054. * @returns true if the value was set
  41055. */
  41056. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41057. /**
  41058. * Set the value of an uniform to an array of int32 (stored as vec2)
  41059. * @param uniform defines the webGL uniform location where to store the value
  41060. * @param array defines the array of int32 to store
  41061. * @returns true if the value was set
  41062. */
  41063. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41064. /**
  41065. * Set the value of an uniform to an array of int32 (stored as vec3)
  41066. * @param uniform defines the webGL uniform location where to store the value
  41067. * @param array defines the array of int32 to store
  41068. * @returns true if the value was set
  41069. */
  41070. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41071. /**
  41072. * Set the value of an uniform to an array of int32 (stored as vec4)
  41073. * @param uniform defines the webGL uniform location where to store the value
  41074. * @param array defines the array of int32 to store
  41075. * @returns true if the value was set
  41076. */
  41077. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41078. /**
  41079. * Set the value of an uniform to an array of number
  41080. * @param uniform defines the webGL uniform location where to store the value
  41081. * @param array defines the array of number to store
  41082. * @returns true if the value was set
  41083. */
  41084. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41085. /**
  41086. * Set the value of an uniform to an array of number (stored as vec2)
  41087. * @param uniform defines the webGL uniform location where to store the value
  41088. * @param array defines the array of number to store
  41089. * @returns true if the value was set
  41090. */
  41091. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41092. /**
  41093. * Set the value of an uniform to an array of number (stored as vec3)
  41094. * @param uniform defines the webGL uniform location where to store the value
  41095. * @param array defines the array of number to store
  41096. * @returns true if the value was set
  41097. */
  41098. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41099. /**
  41100. * Set the value of an uniform to an array of number (stored as vec4)
  41101. * @param uniform defines the webGL uniform location where to store the value
  41102. * @param array defines the array of number to store
  41103. * @returns true if the value was set
  41104. */
  41105. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41106. /**
  41107. * Set the value of an uniform to an array of float32 (stored as matrices)
  41108. * @param uniform defines the webGL uniform location where to store the value
  41109. * @param matrices defines the array of float32 to store
  41110. * @returns true if the value was set
  41111. */
  41112. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  41113. /**
  41114. * Set the value of an uniform to a matrix (3x3)
  41115. * @param uniform defines the webGL uniform location where to store the value
  41116. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  41117. * @returns true if the value was set
  41118. */
  41119. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  41120. /**
  41121. * Set the value of an uniform to a matrix (2x2)
  41122. * @param uniform defines the webGL uniform location where to store the value
  41123. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  41124. * @returns true if the value was set
  41125. */
  41126. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  41127. /**
  41128. * Set the value of an uniform to a number (float)
  41129. * @param uniform defines the webGL uniform location where to store the value
  41130. * @param value defines the float number to store
  41131. * @returns true if the value was transferred
  41132. */
  41133. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  41134. /**
  41135. * Set the value of an uniform to a vec2
  41136. * @param uniform defines the webGL uniform location where to store the value
  41137. * @param x defines the 1st component of the value
  41138. * @param y defines the 2nd component of the value
  41139. * @returns true if the value was set
  41140. */
  41141. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  41142. /**
  41143. * Set the value of an uniform to a vec3
  41144. * @param uniform defines the webGL uniform location where to store the value
  41145. * @param x defines the 1st component of the value
  41146. * @param y defines the 2nd component of the value
  41147. * @param z defines the 3rd component of the value
  41148. * @returns true if the value was set
  41149. */
  41150. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  41151. /**
  41152. * Set the value of an uniform to a vec4
  41153. * @param uniform defines the webGL uniform location where to store the value
  41154. * @param x defines the 1st component of the value
  41155. * @param y defines the 2nd component of the value
  41156. * @param z defines the 3rd component of the value
  41157. * @param w defines the 4th component of the value
  41158. * @returns true if the value was set
  41159. */
  41160. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  41161. /**
  41162. * Apply all cached states (depth, culling, stencil and alpha)
  41163. */
  41164. applyStates(): void;
  41165. /**
  41166. * Enable or disable color writing
  41167. * @param enable defines the state to set
  41168. */
  41169. setColorWrite(enable: boolean): void;
  41170. /**
  41171. * Gets a boolean indicating if color writing is enabled
  41172. * @returns the current color writing state
  41173. */
  41174. getColorWrite(): boolean;
  41175. /**
  41176. * Gets the depth culling state manager
  41177. */
  41178. get depthCullingState(): DepthCullingState;
  41179. /**
  41180. * Gets the alpha state manager
  41181. */
  41182. get alphaState(): AlphaState;
  41183. /**
  41184. * Gets the stencil state manager
  41185. */
  41186. get stencilState(): StencilState;
  41187. /**
  41188. * Clears the list of texture accessible through engine.
  41189. * This can help preventing texture load conflict due to name collision.
  41190. */
  41191. clearInternalTexturesCache(): void;
  41192. /**
  41193. * Force the entire cache to be cleared
  41194. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  41195. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  41196. */
  41197. wipeCaches(bruteForce?: boolean): void;
  41198. /** @hidden */
  41199. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  41200. min: number;
  41201. mag: number;
  41202. };
  41203. /** @hidden */
  41204. protected _createTexture(): WebGLTexture;
  41205. /** @hidden */
  41206. _createHardwareTexture(): HardwareTextureWrapper;
  41207. 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 | {
  41208. width: number;
  41209. height: number;
  41210. }, invertY: boolean, noMipmap: boolean, isCompressed: boolean, processFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  41211. width: number;
  41212. height: number;
  41213. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, samplingMode: number) => void, prepareTextureProcessFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  41214. width: number;
  41215. height: number;
  41216. }, 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;
  41217. /**
  41218. * Usually called from Texture.ts.
  41219. * Passed information to create a WebGLTexture
  41220. * @param url defines a value which contains one of the following:
  41221. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  41222. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  41223. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  41224. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  41225. * @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)
  41226. * @param scene needed for loading to the correct scene
  41227. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  41228. * @param onLoad optional callback to be called upon successful completion
  41229. * @param onError optional callback to be called upon failure
  41230. * @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
  41231. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  41232. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  41233. * @param forcedExtension defines the extension to use to pick the right loader
  41234. * @param mimeType defines an optional mime type
  41235. * @param loaderOptions options to be passed to the loader
  41236. * @returns a InternalTexture for assignment back into BABYLON.Texture
  41237. */
  41238. 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;
  41239. /**
  41240. * Loads an image as an HTMLImageElement.
  41241. * @param input url string, ArrayBuffer, or Blob to load
  41242. * @param onLoad callback called when the image successfully loads
  41243. * @param onError callback called when the image fails to load
  41244. * @param offlineProvider offline provider for caching
  41245. * @param mimeType optional mime type
  41246. * @returns the HTMLImageElement of the loaded image
  41247. * @hidden
  41248. */
  41249. 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>;
  41250. /**
  41251. * @hidden
  41252. */
  41253. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41254. private _unpackFlipYCached;
  41255. /**
  41256. * In case you are sharing the context with other applications, it might
  41257. * be interested to not cache the unpack flip y state to ensure a consistent
  41258. * value would be set.
  41259. */
  41260. enableUnpackFlipYCached: boolean;
  41261. /** @hidden */
  41262. _unpackFlipY(value: boolean): void;
  41263. /** @hidden */
  41264. _getUnpackAlignement(): number;
  41265. private _getTextureTarget;
  41266. /**
  41267. * Update the sampling mode of a given texture
  41268. * @param samplingMode defines the required sampling mode
  41269. * @param texture defines the texture to update
  41270. * @param generateMipMaps defines whether to generate mipmaps for the texture
  41271. */
  41272. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  41273. /**
  41274. * Update the dimensions of a texture
  41275. * @param texture texture to update
  41276. * @param width new width of the texture
  41277. * @param height new height of the texture
  41278. * @param depth new depth of the texture
  41279. */
  41280. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  41281. /**
  41282. * Update the sampling mode of a given texture
  41283. * @param texture defines the texture to update
  41284. * @param wrapU defines the texture wrap mode of the u coordinates
  41285. * @param wrapV defines the texture wrap mode of the v coordinates
  41286. * @param wrapR defines the texture wrap mode of the r coordinates
  41287. */
  41288. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  41289. /** @hidden */
  41290. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  41291. width: number;
  41292. height: number;
  41293. layers?: number;
  41294. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  41295. /** @hidden */
  41296. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41297. /** @hidden */
  41298. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  41299. /**
  41300. * Update a portion of an internal texture
  41301. * @param texture defines the texture to update
  41302. * @param imageData defines the data to store into the texture
  41303. * @param xOffset defines the x coordinates of the update rectangle
  41304. * @param yOffset defines the y coordinates of the update rectangle
  41305. * @param width defines the width of the update rectangle
  41306. * @param height defines the height of the update rectangle
  41307. * @param faceIndex defines the face index if texture is a cube (0 by default)
  41308. * @param lod defines the lod level to update (0 by default)
  41309. */
  41310. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  41311. /** @hidden */
  41312. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41313. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  41314. private _prepareWebGLTexture;
  41315. /** @hidden */
  41316. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  41317. private _getDepthStencilBuffer;
  41318. /** @hidden */
  41319. _releaseFramebufferObjects(texture: InternalTexture): void;
  41320. /** @hidden */
  41321. _releaseTexture(texture: InternalTexture): void;
  41322. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  41323. protected _setProgram(program: WebGLProgram): void;
  41324. protected _boundUniforms: {
  41325. [key: number]: WebGLUniformLocation;
  41326. };
  41327. /**
  41328. * Binds an effect to the webGL context
  41329. * @param effect defines the effect to bind
  41330. */
  41331. bindSamplers(effect: Effect): void;
  41332. private _activateCurrentTexture;
  41333. /** @hidden */
  41334. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  41335. /** @hidden */
  41336. _bindTexture(channel: number, texture: Nullable<InternalTexture>, name: string): void;
  41337. /**
  41338. * Unbind all textures from the webGL context
  41339. */
  41340. unbindAllTextures(): void;
  41341. /**
  41342. * Sets a texture to the according uniform.
  41343. * @param channel The texture channel
  41344. * @param uniform The uniform to set
  41345. * @param texture The texture to apply
  41346. * @param name The name of the uniform in the effect
  41347. */
  41348. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>, name: string): void;
  41349. private _bindSamplerUniformToChannel;
  41350. private _getTextureWrapMode;
  41351. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string): boolean;
  41352. /**
  41353. * Sets an array of texture to the webGL context
  41354. * @param channel defines the channel where the texture array must be set
  41355. * @param uniform defines the associated uniform location
  41356. * @param textures defines the array of textures to bind
  41357. * @param name name of the channel
  41358. */
  41359. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[], name: string): void;
  41360. /** @hidden */
  41361. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  41362. private _setTextureParameterFloat;
  41363. private _setTextureParameterInteger;
  41364. /**
  41365. * Unbind all vertex attributes from the webGL context
  41366. */
  41367. unbindAllAttributes(): void;
  41368. /**
  41369. * 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
  41370. */
  41371. releaseEffects(): void;
  41372. /**
  41373. * Dispose and release all associated resources
  41374. */
  41375. dispose(): void;
  41376. /**
  41377. * Attach a new callback raised when context lost event is fired
  41378. * @param callback defines the callback to call
  41379. */
  41380. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41381. /**
  41382. * Attach a new callback raised when context restored event is fired
  41383. * @param callback defines the callback to call
  41384. */
  41385. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41386. /**
  41387. * Get the current error code of the webGL context
  41388. * @returns the error code
  41389. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41390. */
  41391. getError(): number;
  41392. private _canRenderToFloatFramebuffer;
  41393. private _canRenderToHalfFloatFramebuffer;
  41394. private _canRenderToFramebuffer;
  41395. /** @hidden */
  41396. _getWebGLTextureType(type: number): number;
  41397. /** @hidden */
  41398. _getInternalFormat(format: number): number;
  41399. /** @hidden */
  41400. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  41401. /** @hidden */
  41402. _getRGBAMultiSampleBufferFormat(type: number): number;
  41403. /** @hidden */
  41404. _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;
  41405. /**
  41406. * Loads a file from a url
  41407. * @param url url to load
  41408. * @param onSuccess callback called when the file successfully loads
  41409. * @param onProgress callback called while file is loading (if the server supports this mode)
  41410. * @param offlineProvider defines the offline provider for caching
  41411. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41412. * @param onError callback called when the file fails to load
  41413. * @returns a file request object
  41414. * @hidden
  41415. */
  41416. 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;
  41417. /**
  41418. * Reads pixels from the current frame buffer. Please note that this function can be slow
  41419. * @param x defines the x coordinate of the rectangle where pixels must be read
  41420. * @param y defines the y coordinate of the rectangle where pixels must be read
  41421. * @param width defines the width of the rectangle where pixels must be read
  41422. * @param height defines the height of the rectangle where pixels must be read
  41423. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  41424. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  41425. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  41426. */
  41427. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  41428. private static _IsSupported;
  41429. private static _HasMajorPerformanceCaveat;
  41430. /**
  41431. * Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)
  41432. */
  41433. static get IsSupported(): boolean;
  41434. /**
  41435. * Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)
  41436. * @returns true if the engine can be created
  41437. * @ignorenaming
  41438. */
  41439. static isSupported(): boolean;
  41440. /**
  41441. * 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)
  41442. */
  41443. static get HasMajorPerformanceCaveat(): boolean;
  41444. /**
  41445. * Find the next highest power of two.
  41446. * @param x Number to start search from.
  41447. * @return Next highest power of two.
  41448. */
  41449. static CeilingPOT(x: number): number;
  41450. /**
  41451. * Find the next lowest power of two.
  41452. * @param x Number to start search from.
  41453. * @return Next lowest power of two.
  41454. */
  41455. static FloorPOT(x: number): number;
  41456. /**
  41457. * Find the nearest power of two.
  41458. * @param x Number to start search from.
  41459. * @return Next nearest power of two.
  41460. */
  41461. static NearestPOT(x: number): number;
  41462. /**
  41463. * Get the closest exponent of two
  41464. * @param value defines the value to approximate
  41465. * @param max defines the maximum value to return
  41466. * @param mode defines how to define the closest value
  41467. * @returns closest exponent of two of the given value
  41468. */
  41469. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  41470. /**
  41471. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  41472. * @param func - the function to be called
  41473. * @param requester - the object that will request the next frame. Falls back to window.
  41474. * @returns frame number
  41475. */
  41476. static QueueNewFrame(func: () => void, requester?: any): number;
  41477. /**
  41478. * Gets host document
  41479. * @returns the host document object
  41480. */
  41481. getHostDocument(): Nullable<Document>;
  41482. }
  41483. }
  41484. declare module BABYLON {
  41485. /**
  41486. * Defines the source of the internal texture
  41487. */
  41488. export enum InternalTextureSource {
  41489. /**
  41490. * The source of the texture data is unknown
  41491. */
  41492. Unknown = 0,
  41493. /**
  41494. * Texture data comes from an URL
  41495. */
  41496. Url = 1,
  41497. /**
  41498. * Texture data is only used for temporary storage
  41499. */
  41500. Temp = 2,
  41501. /**
  41502. * Texture data comes from raw data (ArrayBuffer)
  41503. */
  41504. Raw = 3,
  41505. /**
  41506. * Texture content is dynamic (video or dynamic texture)
  41507. */
  41508. Dynamic = 4,
  41509. /**
  41510. * Texture content is generated by rendering to it
  41511. */
  41512. RenderTarget = 5,
  41513. /**
  41514. * Texture content is part of a multi render target process
  41515. */
  41516. MultiRenderTarget = 6,
  41517. /**
  41518. * Texture data comes from a cube data file
  41519. */
  41520. Cube = 7,
  41521. /**
  41522. * Texture data comes from a raw cube data
  41523. */
  41524. CubeRaw = 8,
  41525. /**
  41526. * Texture data come from a prefiltered cube data file
  41527. */
  41528. CubePrefiltered = 9,
  41529. /**
  41530. * Texture content is raw 3D data
  41531. */
  41532. Raw3D = 10,
  41533. /**
  41534. * Texture content is raw 2D array data
  41535. */
  41536. Raw2DArray = 11,
  41537. /**
  41538. * Texture content is a depth texture
  41539. */
  41540. Depth = 12,
  41541. /**
  41542. * Texture data comes from a raw cube data encoded with RGBD
  41543. */
  41544. CubeRawRGBD = 13
  41545. }
  41546. /**
  41547. * Class used to store data associated with WebGL texture data for the engine
  41548. * This class should not be used directly
  41549. */
  41550. export class InternalTexture {
  41551. /** @hidden */
  41552. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41553. /**
  41554. * Defines if the texture is ready
  41555. */
  41556. isReady: boolean;
  41557. /**
  41558. * Defines if the texture is a cube texture
  41559. */
  41560. isCube: boolean;
  41561. /**
  41562. * Defines if the texture contains 3D data
  41563. */
  41564. is3D: boolean;
  41565. /**
  41566. * Defines if the texture contains 2D array data
  41567. */
  41568. is2DArray: boolean;
  41569. /**
  41570. * Defines if the texture contains multiview data
  41571. */
  41572. isMultiview: boolean;
  41573. /**
  41574. * Gets the URL used to load this texture
  41575. */
  41576. url: string;
  41577. /** @hidden */
  41578. _originalUrl: string;
  41579. /**
  41580. * Gets the sampling mode of the texture
  41581. */
  41582. samplingMode: number;
  41583. /**
  41584. * Gets a boolean indicating if the texture needs mipmaps generation
  41585. */
  41586. generateMipMaps: boolean;
  41587. /**
  41588. * Gets the number of samples used by the texture (WebGL2+ only)
  41589. */
  41590. samples: number;
  41591. /**
  41592. * Gets the type of the texture (int, float...)
  41593. */
  41594. type: number;
  41595. /**
  41596. * Gets the format of the texture (RGB, RGBA...)
  41597. */
  41598. format: number;
  41599. /**
  41600. * Observable called when the texture is loaded
  41601. */
  41602. onLoadedObservable: Observable<InternalTexture>;
  41603. /**
  41604. * Gets the width of the texture
  41605. */
  41606. width: number;
  41607. /**
  41608. * Gets the height of the texture
  41609. */
  41610. height: number;
  41611. /**
  41612. * Gets the depth of the texture
  41613. */
  41614. depth: number;
  41615. /**
  41616. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41617. */
  41618. baseWidth: number;
  41619. /**
  41620. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41621. */
  41622. baseHeight: number;
  41623. /**
  41624. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41625. */
  41626. baseDepth: number;
  41627. /**
  41628. * Gets a boolean indicating if the texture is inverted on Y axis
  41629. */
  41630. invertY: boolean;
  41631. /** @hidden */
  41632. _invertVScale: boolean;
  41633. /** @hidden */
  41634. _associatedChannel: number;
  41635. /** @hidden */
  41636. _source: InternalTextureSource;
  41637. /** @hidden */
  41638. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41639. /** @hidden */
  41640. _bufferView: Nullable<ArrayBufferView>;
  41641. /** @hidden */
  41642. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41643. /** @hidden */
  41644. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41645. /** @hidden */
  41646. _size: number;
  41647. /** @hidden */
  41648. _extension: string;
  41649. /** @hidden */
  41650. _files: Nullable<string[]>;
  41651. /** @hidden */
  41652. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41653. /** @hidden */
  41654. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41655. /** @hidden */
  41656. _framebuffer: Nullable<WebGLFramebuffer>;
  41657. /** @hidden */
  41658. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41659. /** @hidden */
  41660. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41661. /** @hidden */
  41662. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41663. /** @hidden */
  41664. _attachments: Nullable<number[]>;
  41665. /** @hidden */
  41666. _textureArray: Nullable<InternalTexture[]>;
  41667. /** @hidden */
  41668. _cachedCoordinatesMode: Nullable<number>;
  41669. /** @hidden */
  41670. _cachedWrapU: Nullable<number>;
  41671. /** @hidden */
  41672. _cachedWrapV: Nullable<number>;
  41673. /** @hidden */
  41674. _cachedWrapR: Nullable<number>;
  41675. /** @hidden */
  41676. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41677. /** @hidden */
  41678. _isDisabled: boolean;
  41679. /** @hidden */
  41680. _compression: Nullable<string>;
  41681. /** @hidden */
  41682. _generateStencilBuffer: boolean;
  41683. /** @hidden */
  41684. _generateDepthBuffer: boolean;
  41685. /** @hidden */
  41686. _comparisonFunction: number;
  41687. /** @hidden */
  41688. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41689. /** @hidden */
  41690. _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>>;
  41691. /** @hidden */
  41692. _sphericalPolynomialComputed: boolean;
  41693. /** @hidden */
  41694. _lodGenerationScale: number;
  41695. /** @hidden */
  41696. _lodGenerationOffset: number;
  41697. /** @hidden */
  41698. _depthStencilTexture: Nullable<InternalTexture>;
  41699. /** @hidden */
  41700. _colorTextureArray: Nullable<WebGLTexture>;
  41701. /** @hidden */
  41702. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41703. /** @hidden */
  41704. _lodTextureHigh: Nullable<BaseTexture>;
  41705. /** @hidden */
  41706. _lodTextureMid: Nullable<BaseTexture>;
  41707. /** @hidden */
  41708. _lodTextureLow: Nullable<BaseTexture>;
  41709. /** @hidden */
  41710. _isRGBD: boolean;
  41711. /** @hidden */
  41712. _linearSpecularLOD: boolean;
  41713. /** @hidden */
  41714. _irradianceTexture: Nullable<BaseTexture>;
  41715. /** @hidden */
  41716. _hardwareTexture: Nullable<HardwareTextureWrapper>;
  41717. /** @hidden */
  41718. _references: number;
  41719. /** @hidden */
  41720. _gammaSpace: Nullable<boolean>;
  41721. private _engine;
  41722. private _uniqueId;
  41723. private static _Counter;
  41724. /** Gets the unique id of the internal texture */
  41725. get uniqueId(): number;
  41726. /**
  41727. * Gets the Engine the texture belongs to.
  41728. * @returns The babylon engine
  41729. */
  41730. getEngine(): ThinEngine;
  41731. /**
  41732. * Gets the data source type of the texture
  41733. */
  41734. get source(): InternalTextureSource;
  41735. /**
  41736. * Creates a new InternalTexture
  41737. * @param engine defines the engine to use
  41738. * @param source defines the type of data that will be used
  41739. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41740. */
  41741. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41742. /**
  41743. * Increments the number of references (ie. the number of Texture that point to it)
  41744. */
  41745. incrementReferences(): void;
  41746. /**
  41747. * Change the size of the texture (not the size of the content)
  41748. * @param width defines the new width
  41749. * @param height defines the new height
  41750. * @param depth defines the new depth (1 by default)
  41751. */
  41752. updateSize(width: int, height: int, depth?: int): void;
  41753. /** @hidden */
  41754. _rebuild(): void;
  41755. /** @hidden */
  41756. _swapAndDie(target: InternalTexture): void;
  41757. /**
  41758. * Dispose the current allocated resources
  41759. */
  41760. dispose(): void;
  41761. }
  41762. }
  41763. declare module BABYLON {
  41764. /**
  41765. * Interface used to present a loading screen while loading a scene
  41766. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41767. */
  41768. export interface ILoadingScreen {
  41769. /**
  41770. * Function called to display the loading screen
  41771. */
  41772. displayLoadingUI: () => void;
  41773. /**
  41774. * Function called to hide the loading screen
  41775. */
  41776. hideLoadingUI: () => void;
  41777. /**
  41778. * Gets or sets the color to use for the background
  41779. */
  41780. loadingUIBackgroundColor: string;
  41781. /**
  41782. * Gets or sets the text to display while loading
  41783. */
  41784. loadingUIText: string;
  41785. }
  41786. /**
  41787. * Class used for the default loading screen
  41788. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41789. */
  41790. export class DefaultLoadingScreen implements ILoadingScreen {
  41791. private _renderingCanvas;
  41792. private _loadingText;
  41793. private _loadingDivBackgroundColor;
  41794. private _loadingDiv;
  41795. private _loadingTextDiv;
  41796. /** Gets or sets the logo url to use for the default loading screen */
  41797. static DefaultLogoUrl: string;
  41798. /** Gets or sets the spinner url to use for the default loading screen */
  41799. static DefaultSpinnerUrl: string;
  41800. /**
  41801. * Creates a new default loading screen
  41802. * @param _renderingCanvas defines the canvas used to render the scene
  41803. * @param _loadingText defines the default text to display
  41804. * @param _loadingDivBackgroundColor defines the default background color
  41805. */
  41806. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41807. /**
  41808. * Function called to display the loading screen
  41809. */
  41810. displayLoadingUI(): void;
  41811. /**
  41812. * Function called to hide the loading screen
  41813. */
  41814. hideLoadingUI(): void;
  41815. /**
  41816. * Gets or sets the text to display while loading
  41817. */
  41818. set loadingUIText(text: string);
  41819. get loadingUIText(): string;
  41820. /**
  41821. * Gets or sets the color to use for the background
  41822. */
  41823. get loadingUIBackgroundColor(): string;
  41824. set loadingUIBackgroundColor(color: string);
  41825. private _resizeLoadingUI;
  41826. }
  41827. }
  41828. declare module BABYLON {
  41829. /**
  41830. * Interface for any object that can request an animation frame
  41831. */
  41832. export interface ICustomAnimationFrameRequester {
  41833. /**
  41834. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41835. */
  41836. renderFunction?: Function;
  41837. /**
  41838. * Called to request the next frame to render to
  41839. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41840. */
  41841. requestAnimationFrame: Function;
  41842. /**
  41843. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41844. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41845. */
  41846. requestID?: number;
  41847. }
  41848. }
  41849. declare module BABYLON {
  41850. /**
  41851. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41852. */
  41853. export class PerformanceMonitor {
  41854. private _enabled;
  41855. private _rollingFrameTime;
  41856. private _lastFrameTimeMs;
  41857. /**
  41858. * constructor
  41859. * @param frameSampleSize The number of samples required to saturate the sliding window
  41860. */
  41861. constructor(frameSampleSize?: number);
  41862. /**
  41863. * Samples current frame
  41864. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41865. */
  41866. sampleFrame(timeMs?: number): void;
  41867. /**
  41868. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41869. */
  41870. get averageFrameTime(): number;
  41871. /**
  41872. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41873. */
  41874. get averageFrameTimeVariance(): number;
  41875. /**
  41876. * Returns the frame time of the most recent frame
  41877. */
  41878. get instantaneousFrameTime(): number;
  41879. /**
  41880. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41881. */
  41882. get averageFPS(): number;
  41883. /**
  41884. * Returns the average framerate in frames per second using the most recent frame time
  41885. */
  41886. get instantaneousFPS(): number;
  41887. /**
  41888. * Returns true if enough samples have been taken to completely fill the sliding window
  41889. */
  41890. get isSaturated(): boolean;
  41891. /**
  41892. * Enables contributions to the sliding window sample set
  41893. */
  41894. enable(): void;
  41895. /**
  41896. * Disables contributions to the sliding window sample set
  41897. * Samples will not be interpolated over the disabled period
  41898. */
  41899. disable(): void;
  41900. /**
  41901. * Returns true if sampling is enabled
  41902. */
  41903. get isEnabled(): boolean;
  41904. /**
  41905. * Resets performance monitor
  41906. */
  41907. reset(): void;
  41908. }
  41909. /**
  41910. * RollingAverage
  41911. *
  41912. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  41913. */
  41914. export class RollingAverage {
  41915. /**
  41916. * Current average
  41917. */
  41918. average: number;
  41919. /**
  41920. * Current variance
  41921. */
  41922. variance: number;
  41923. protected _samples: Array<number>;
  41924. protected _sampleCount: number;
  41925. protected _pos: number;
  41926. protected _m2: number;
  41927. /**
  41928. * constructor
  41929. * @param length The number of samples required to saturate the sliding window
  41930. */
  41931. constructor(length: number);
  41932. /**
  41933. * Adds a sample to the sample set
  41934. * @param v The sample value
  41935. */
  41936. add(v: number): void;
  41937. /**
  41938. * Returns previously added values or null if outside of history or outside the sliding window domain
  41939. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  41940. * @return Value previously recorded with add() or null if outside of range
  41941. */
  41942. history(i: number): number;
  41943. /**
  41944. * Returns true if enough samples have been taken to completely fill the sliding window
  41945. * @return true if sample-set saturated
  41946. */
  41947. isSaturated(): boolean;
  41948. /**
  41949. * Resets the rolling average (equivalent to 0 samples taken so far)
  41950. */
  41951. reset(): void;
  41952. /**
  41953. * Wraps a value around the sample range boundaries
  41954. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  41955. * @return Wrapped position in sample range
  41956. */
  41957. protected _wrapPosition(i: number): number;
  41958. }
  41959. }
  41960. declare module BABYLON {
  41961. /**
  41962. * This class is used to track a performance counter which is number based.
  41963. * The user has access to many properties which give statistics of different nature.
  41964. *
  41965. * The implementer can track two kinds of Performance Counter: time and count.
  41966. * 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.
  41967. * 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.
  41968. */
  41969. export class PerfCounter {
  41970. /**
  41971. * Gets or sets a global boolean to turn on and off all the counters
  41972. */
  41973. static Enabled: boolean;
  41974. /**
  41975. * Returns the smallest value ever
  41976. */
  41977. get min(): number;
  41978. /**
  41979. * Returns the biggest value ever
  41980. */
  41981. get max(): number;
  41982. /**
  41983. * Returns the average value since the performance counter is running
  41984. */
  41985. get average(): number;
  41986. /**
  41987. * Returns the average value of the last second the counter was monitored
  41988. */
  41989. get lastSecAverage(): number;
  41990. /**
  41991. * Returns the current value
  41992. */
  41993. get current(): number;
  41994. /**
  41995. * Gets the accumulated total
  41996. */
  41997. get total(): number;
  41998. /**
  41999. * Gets the total value count
  42000. */
  42001. get count(): number;
  42002. /**
  42003. * Creates a new counter
  42004. */
  42005. constructor();
  42006. /**
  42007. * Call this method to start monitoring a new frame.
  42008. * 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.
  42009. */
  42010. fetchNewFrame(): void;
  42011. /**
  42012. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  42013. * @param newCount the count value to add to the monitored count
  42014. * @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.
  42015. */
  42016. addCount(newCount: number, fetchResult: boolean): void;
  42017. /**
  42018. * Start monitoring this performance counter
  42019. */
  42020. beginMonitoring(): void;
  42021. /**
  42022. * Compute the time lapsed since the previous beginMonitoring() call.
  42023. * @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
  42024. */
  42025. endMonitoring(newFrame?: boolean): void;
  42026. private _fetchResult;
  42027. private _startMonitoringTime;
  42028. private _min;
  42029. private _max;
  42030. private _average;
  42031. private _current;
  42032. private _totalValueCount;
  42033. private _totalAccumulated;
  42034. private _lastSecAverage;
  42035. private _lastSecAccumulated;
  42036. private _lastSecTime;
  42037. private _lastSecValueCount;
  42038. }
  42039. }
  42040. declare module BABYLON {
  42041. interface ThinEngine {
  42042. /** @hidden */
  42043. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  42044. /** @hidden */
  42045. _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): ArrayBufferView;
  42046. }
  42047. }
  42048. declare module BABYLON {
  42049. /**
  42050. * Class used to work with sound analyzer using fast fourier transform (FFT)
  42051. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42052. */
  42053. export class Analyser {
  42054. /**
  42055. * Gets or sets the smoothing
  42056. * @ignorenaming
  42057. */
  42058. SMOOTHING: number;
  42059. /**
  42060. * Gets or sets the FFT table size
  42061. * @ignorenaming
  42062. */
  42063. FFT_SIZE: number;
  42064. /**
  42065. * Gets or sets the bar graph amplitude
  42066. * @ignorenaming
  42067. */
  42068. BARGRAPHAMPLITUDE: number;
  42069. /**
  42070. * Gets or sets the position of the debug canvas
  42071. * @ignorenaming
  42072. */
  42073. DEBUGCANVASPOS: {
  42074. x: number;
  42075. y: number;
  42076. };
  42077. /**
  42078. * Gets or sets the debug canvas size
  42079. * @ignorenaming
  42080. */
  42081. DEBUGCANVASSIZE: {
  42082. width: number;
  42083. height: number;
  42084. };
  42085. private _byteFreqs;
  42086. private _byteTime;
  42087. private _floatFreqs;
  42088. private _webAudioAnalyser;
  42089. private _debugCanvas;
  42090. private _debugCanvasContext;
  42091. private _scene;
  42092. private _registerFunc;
  42093. private _audioEngine;
  42094. /**
  42095. * Creates a new analyser
  42096. * @param scene defines hosting scene
  42097. */
  42098. constructor(scene: Scene);
  42099. /**
  42100. * Get the number of data values you will have to play with for the visualization
  42101. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  42102. * @returns a number
  42103. */
  42104. getFrequencyBinCount(): number;
  42105. /**
  42106. * Gets the current frequency data as a byte array
  42107. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  42108. * @returns a Uint8Array
  42109. */
  42110. getByteFrequencyData(): Uint8Array;
  42111. /**
  42112. * Gets the current waveform as a byte array
  42113. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  42114. * @returns a Uint8Array
  42115. */
  42116. getByteTimeDomainData(): Uint8Array;
  42117. /**
  42118. * Gets the current frequency data as a float array
  42119. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  42120. * @returns a Float32Array
  42121. */
  42122. getFloatFrequencyData(): Float32Array;
  42123. /**
  42124. * Renders the debug canvas
  42125. */
  42126. drawDebugCanvas(): void;
  42127. /**
  42128. * Stops rendering the debug canvas and removes it
  42129. */
  42130. stopDebugCanvas(): void;
  42131. /**
  42132. * Connects two audio nodes
  42133. * @param inputAudioNode defines first node to connect
  42134. * @param outputAudioNode defines second node to connect
  42135. */
  42136. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  42137. /**
  42138. * Releases all associated resources
  42139. */
  42140. dispose(): void;
  42141. }
  42142. }
  42143. declare module BABYLON {
  42144. /**
  42145. * This represents an audio engine and it is responsible
  42146. * to play, synchronize and analyse sounds throughout the application.
  42147. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42148. */
  42149. export interface IAudioEngine extends IDisposable {
  42150. /**
  42151. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  42152. */
  42153. readonly canUseWebAudio: boolean;
  42154. /**
  42155. * Gets the current AudioContext if available.
  42156. */
  42157. readonly audioContext: Nullable<AudioContext>;
  42158. /**
  42159. * The master gain node defines the global audio volume of your audio engine.
  42160. */
  42161. readonly masterGain: GainNode;
  42162. /**
  42163. * Gets whether or not mp3 are supported by your browser.
  42164. */
  42165. readonly isMP3supported: boolean;
  42166. /**
  42167. * Gets whether or not ogg are supported by your browser.
  42168. */
  42169. readonly isOGGsupported: boolean;
  42170. /**
  42171. * Defines if Babylon should emit a warning if WebAudio is not supported.
  42172. * @ignoreNaming
  42173. */
  42174. WarnedWebAudioUnsupported: boolean;
  42175. /**
  42176. * Defines if the audio engine relies on a custom unlocked button.
  42177. * In this case, the embedded button will not be displayed.
  42178. */
  42179. useCustomUnlockedButton: boolean;
  42180. /**
  42181. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  42182. */
  42183. readonly unlocked: boolean;
  42184. /**
  42185. * Event raised when audio has been unlocked on the browser.
  42186. */
  42187. onAudioUnlockedObservable: Observable<IAudioEngine>;
  42188. /**
  42189. * Event raised when audio has been locked on the browser.
  42190. */
  42191. onAudioLockedObservable: Observable<IAudioEngine>;
  42192. /**
  42193. * Flags the audio engine in Locked state.
  42194. * This happens due to new browser policies preventing audio to autoplay.
  42195. */
  42196. lock(): void;
  42197. /**
  42198. * Unlocks the audio engine once a user action has been done on the dom.
  42199. * This is helpful to resume play once browser policies have been satisfied.
  42200. */
  42201. unlock(): void;
  42202. /**
  42203. * Gets the global volume sets on the master gain.
  42204. * @returns the global volume if set or -1 otherwise
  42205. */
  42206. getGlobalVolume(): number;
  42207. /**
  42208. * Sets the global volume of your experience (sets on the master gain).
  42209. * @param newVolume Defines the new global volume of the application
  42210. */
  42211. setGlobalVolume(newVolume: number): void;
  42212. /**
  42213. * Connect the audio engine to an audio analyser allowing some amazing
  42214. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  42215. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42216. * @param analyser The analyser to connect to the engine
  42217. */
  42218. connectToAnalyser(analyser: Analyser): void;
  42219. }
  42220. }
  42221. declare module BABYLON {
  42222. /**
  42223. * Defines the interface used by display changed events
  42224. */
  42225. export interface IDisplayChangedEventArgs {
  42226. /** Gets the vrDisplay object (if any) */
  42227. vrDisplay: Nullable<any>;
  42228. /** Gets a boolean indicating if webVR is supported */
  42229. vrSupported: boolean;
  42230. }
  42231. /**
  42232. * Defines the interface used by objects containing a viewport (like a camera)
  42233. */
  42234. interface IViewportOwnerLike {
  42235. /**
  42236. * Gets or sets the viewport
  42237. */
  42238. viewport: IViewportLike;
  42239. }
  42240. /**
  42241. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  42242. */
  42243. export class Engine extends ThinEngine {
  42244. /** Defines that alpha blending is disabled */
  42245. static readonly ALPHA_DISABLE: number;
  42246. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  42247. static readonly ALPHA_ADD: number;
  42248. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  42249. static readonly ALPHA_COMBINE: number;
  42250. /** Defines that alpha blending to DEST - SRC * DEST */
  42251. static readonly ALPHA_SUBTRACT: number;
  42252. /** Defines that alpha blending to SRC * DEST */
  42253. static readonly ALPHA_MULTIPLY: number;
  42254. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  42255. static readonly ALPHA_MAXIMIZED: number;
  42256. /** Defines that alpha blending to SRC + DEST */
  42257. static readonly ALPHA_ONEONE: number;
  42258. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  42259. static readonly ALPHA_PREMULTIPLIED: number;
  42260. /**
  42261. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  42262. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  42263. */
  42264. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  42265. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  42266. static readonly ALPHA_INTERPOLATE: number;
  42267. /**
  42268. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  42269. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  42270. */
  42271. static readonly ALPHA_SCREENMODE: number;
  42272. /** Defines that the resource is not delayed*/
  42273. static readonly DELAYLOADSTATE_NONE: number;
  42274. /** Defines that the resource was successfully delay loaded */
  42275. static readonly DELAYLOADSTATE_LOADED: number;
  42276. /** Defines that the resource is currently delay loading */
  42277. static readonly DELAYLOADSTATE_LOADING: number;
  42278. /** Defines that the resource is delayed and has not started loading */
  42279. static readonly DELAYLOADSTATE_NOTLOADED: number;
  42280. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  42281. static readonly NEVER: number;
  42282. /** 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 */
  42283. static readonly ALWAYS: number;
  42284. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  42285. static readonly LESS: number;
  42286. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  42287. static readonly EQUAL: number;
  42288. /** 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 */
  42289. static readonly LEQUAL: number;
  42290. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  42291. static readonly GREATER: number;
  42292. /** 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 */
  42293. static readonly GEQUAL: number;
  42294. /** 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 */
  42295. static readonly NOTEQUAL: number;
  42296. /** Passed to stencilOperation to specify that stencil value must be kept */
  42297. static readonly KEEP: number;
  42298. /** Passed to stencilOperation to specify that stencil value must be replaced */
  42299. static readonly REPLACE: number;
  42300. /** Passed to stencilOperation to specify that stencil value must be incremented */
  42301. static readonly INCR: number;
  42302. /** Passed to stencilOperation to specify that stencil value must be decremented */
  42303. static readonly DECR: number;
  42304. /** Passed to stencilOperation to specify that stencil value must be inverted */
  42305. static readonly INVERT: number;
  42306. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  42307. static readonly INCR_WRAP: number;
  42308. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  42309. static readonly DECR_WRAP: number;
  42310. /** Texture is not repeating outside of 0..1 UVs */
  42311. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  42312. /** Texture is repeating outside of 0..1 UVs */
  42313. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  42314. /** Texture is repeating and mirrored */
  42315. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  42316. /** ALPHA */
  42317. static readonly TEXTUREFORMAT_ALPHA: number;
  42318. /** LUMINANCE */
  42319. static readonly TEXTUREFORMAT_LUMINANCE: number;
  42320. /** LUMINANCE_ALPHA */
  42321. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  42322. /** RGB */
  42323. static readonly TEXTUREFORMAT_RGB: number;
  42324. /** RGBA */
  42325. static readonly TEXTUREFORMAT_RGBA: number;
  42326. /** RED */
  42327. static readonly TEXTUREFORMAT_RED: number;
  42328. /** RED (2nd reference) */
  42329. static readonly TEXTUREFORMAT_R: number;
  42330. /** RG */
  42331. static readonly TEXTUREFORMAT_RG: number;
  42332. /** RED_INTEGER */
  42333. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  42334. /** RED_INTEGER (2nd reference) */
  42335. static readonly TEXTUREFORMAT_R_INTEGER: number;
  42336. /** RG_INTEGER */
  42337. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  42338. /** RGB_INTEGER */
  42339. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  42340. /** RGBA_INTEGER */
  42341. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  42342. /** UNSIGNED_BYTE */
  42343. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  42344. /** UNSIGNED_BYTE (2nd reference) */
  42345. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  42346. /** FLOAT */
  42347. static readonly TEXTURETYPE_FLOAT: number;
  42348. /** HALF_FLOAT */
  42349. static readonly TEXTURETYPE_HALF_FLOAT: number;
  42350. /** BYTE */
  42351. static readonly TEXTURETYPE_BYTE: number;
  42352. /** SHORT */
  42353. static readonly TEXTURETYPE_SHORT: number;
  42354. /** UNSIGNED_SHORT */
  42355. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  42356. /** INT */
  42357. static readonly TEXTURETYPE_INT: number;
  42358. /** UNSIGNED_INT */
  42359. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  42360. /** UNSIGNED_SHORT_4_4_4_4 */
  42361. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  42362. /** UNSIGNED_SHORT_5_5_5_1 */
  42363. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  42364. /** UNSIGNED_SHORT_5_6_5 */
  42365. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  42366. /** UNSIGNED_INT_2_10_10_10_REV */
  42367. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  42368. /** UNSIGNED_INT_24_8 */
  42369. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  42370. /** UNSIGNED_INT_10F_11F_11F_REV */
  42371. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  42372. /** UNSIGNED_INT_5_9_9_9_REV */
  42373. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  42374. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  42375. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  42376. /** nearest is mag = nearest and min = nearest and mip = none */
  42377. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  42378. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42379. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  42380. /** Trilinear is mag = linear and min = linear and mip = linear */
  42381. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  42382. /** nearest is mag = nearest and min = nearest and mip = linear */
  42383. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  42384. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42385. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  42386. /** Trilinear is mag = linear and min = linear and mip = linear */
  42387. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  42388. /** mag = nearest and min = nearest and mip = nearest */
  42389. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  42390. /** mag = nearest and min = linear and mip = nearest */
  42391. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  42392. /** mag = nearest and min = linear and mip = linear */
  42393. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  42394. /** mag = nearest and min = linear and mip = none */
  42395. static readonly TEXTURE_NEAREST_LINEAR: number;
  42396. /** mag = nearest and min = nearest and mip = none */
  42397. static readonly TEXTURE_NEAREST_NEAREST: number;
  42398. /** mag = linear and min = nearest and mip = nearest */
  42399. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42400. /** mag = linear and min = nearest and mip = linear */
  42401. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42402. /** mag = linear and min = linear and mip = none */
  42403. static readonly TEXTURE_LINEAR_LINEAR: number;
  42404. /** mag = linear and min = nearest and mip = none */
  42405. static readonly TEXTURE_LINEAR_NEAREST: number;
  42406. /** Explicit coordinates mode */
  42407. static readonly TEXTURE_EXPLICIT_MODE: number;
  42408. /** Spherical coordinates mode */
  42409. static readonly TEXTURE_SPHERICAL_MODE: number;
  42410. /** Planar coordinates mode */
  42411. static readonly TEXTURE_PLANAR_MODE: number;
  42412. /** Cubic coordinates mode */
  42413. static readonly TEXTURE_CUBIC_MODE: number;
  42414. /** Projection coordinates mode */
  42415. static readonly TEXTURE_PROJECTION_MODE: number;
  42416. /** Skybox coordinates mode */
  42417. static readonly TEXTURE_SKYBOX_MODE: number;
  42418. /** Inverse Cubic coordinates mode */
  42419. static readonly TEXTURE_INVCUBIC_MODE: number;
  42420. /** Equirectangular coordinates mode */
  42421. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42422. /** Equirectangular Fixed coordinates mode */
  42423. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42424. /** Equirectangular Fixed Mirrored coordinates mode */
  42425. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42426. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42427. static readonly SCALEMODE_FLOOR: number;
  42428. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42429. static readonly SCALEMODE_NEAREST: number;
  42430. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42431. static readonly SCALEMODE_CEILING: number;
  42432. /**
  42433. * Returns the current npm package of the sdk
  42434. */
  42435. static get NpmPackage(): string;
  42436. /**
  42437. * Returns the current version of the framework
  42438. */
  42439. static get Version(): string;
  42440. /** Gets the list of created engines */
  42441. static get Instances(): Engine[];
  42442. /**
  42443. * Gets the latest created engine
  42444. */
  42445. static get LastCreatedEngine(): Nullable<Engine>;
  42446. /**
  42447. * Gets the latest created scene
  42448. */
  42449. static get LastCreatedScene(): Nullable<Scene>;
  42450. /**
  42451. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42452. * @param flag defines which part of the materials must be marked as dirty
  42453. * @param predicate defines a predicate used to filter which materials should be affected
  42454. */
  42455. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42456. /**
  42457. * Method called to create the default loading screen.
  42458. * This can be overridden in your own app.
  42459. * @param canvas The rendering canvas element
  42460. * @returns The loading screen
  42461. */
  42462. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42463. /**
  42464. * Method called to create the default rescale post process on each engine.
  42465. */
  42466. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42467. /**
  42468. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42469. **/
  42470. enableOfflineSupport: boolean;
  42471. /**
  42472. * 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)
  42473. **/
  42474. disableManifestCheck: boolean;
  42475. /**
  42476. * Gets the list of created scenes
  42477. */
  42478. scenes: Scene[];
  42479. /**
  42480. * Event raised when a new scene is created
  42481. */
  42482. onNewSceneAddedObservable: Observable<Scene>;
  42483. /**
  42484. * Gets the list of created postprocesses
  42485. */
  42486. postProcesses: PostProcess[];
  42487. /**
  42488. * Gets a boolean indicating if the pointer is currently locked
  42489. */
  42490. isPointerLock: boolean;
  42491. /**
  42492. * Observable event triggered each time the rendering canvas is resized
  42493. */
  42494. onResizeObservable: Observable<Engine>;
  42495. /**
  42496. * Observable event triggered each time the canvas loses focus
  42497. */
  42498. onCanvasBlurObservable: Observable<Engine>;
  42499. /**
  42500. * Observable event triggered each time the canvas gains focus
  42501. */
  42502. onCanvasFocusObservable: Observable<Engine>;
  42503. /**
  42504. * Observable event triggered each time the canvas receives pointerout event
  42505. */
  42506. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42507. /**
  42508. * Observable raised when the engine begins a new frame
  42509. */
  42510. onBeginFrameObservable: Observable<Engine>;
  42511. /**
  42512. * If set, will be used to request the next animation frame for the render loop
  42513. */
  42514. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42515. /**
  42516. * Observable raised when the engine ends the current frame
  42517. */
  42518. onEndFrameObservable: Observable<Engine>;
  42519. /**
  42520. * Observable raised when the engine is about to compile a shader
  42521. */
  42522. onBeforeShaderCompilationObservable: Observable<Engine>;
  42523. /**
  42524. * Observable raised when the engine has just compiled a shader
  42525. */
  42526. onAfterShaderCompilationObservable: Observable<Engine>;
  42527. /**
  42528. * Gets the audio engine
  42529. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42530. * @ignorenaming
  42531. */
  42532. static audioEngine: IAudioEngine;
  42533. /**
  42534. * Default AudioEngine factory responsible of creating the Audio Engine.
  42535. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42536. */
  42537. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42538. /**
  42539. * Default offline support factory responsible of creating a tool used to store data locally.
  42540. * By default, this will create a Database object if the workload has been embedded.
  42541. */
  42542. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42543. private _loadingScreen;
  42544. private _pointerLockRequested;
  42545. private _rescalePostProcess;
  42546. protected _deterministicLockstep: boolean;
  42547. protected _lockstepMaxSteps: number;
  42548. protected _timeStep: number;
  42549. protected get _supportsHardwareTextureRescaling(): boolean;
  42550. private _fps;
  42551. private _deltaTime;
  42552. /** @hidden */
  42553. _drawCalls: PerfCounter;
  42554. /** 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 */
  42555. canvasTabIndex: number;
  42556. /**
  42557. * Turn this value on if you want to pause FPS computation when in background
  42558. */
  42559. disablePerformanceMonitorInBackground: boolean;
  42560. private _performanceMonitor;
  42561. /**
  42562. * Gets the performance monitor attached to this engine
  42563. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42564. */
  42565. get performanceMonitor(): PerformanceMonitor;
  42566. private _onFocus;
  42567. private _onBlur;
  42568. private _onCanvasPointerOut;
  42569. private _onCanvasBlur;
  42570. private _onCanvasFocus;
  42571. private _onFullscreenChange;
  42572. private _onPointerLockChange;
  42573. /**
  42574. * Gets the HTML element used to attach event listeners
  42575. * @returns a HTML element
  42576. */
  42577. getInputElement(): Nullable<HTMLElement>;
  42578. /**
  42579. * Creates a new engine
  42580. * @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
  42581. * @param antialias defines enable antialiasing (default: false)
  42582. * @param options defines further options to be sent to the getContext() function
  42583. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42584. */
  42585. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42586. /**
  42587. * Shared initialization across engines types.
  42588. * @param canvas The canvas associated with this instance of the engine.
  42589. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  42590. * @param audioEngine Defines if an audio engine should be created by default
  42591. */
  42592. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  42593. /**
  42594. * Gets current aspect ratio
  42595. * @param viewportOwner defines the camera to use to get the aspect ratio
  42596. * @param useScreen defines if screen size must be used (or the current render target if any)
  42597. * @returns a number defining the aspect ratio
  42598. */
  42599. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42600. /**
  42601. * Gets current screen aspect ratio
  42602. * @returns a number defining the aspect ratio
  42603. */
  42604. getScreenAspectRatio(): number;
  42605. /**
  42606. * Gets the client rect of the HTML canvas attached with the current webGL context
  42607. * @returns a client rectangle
  42608. */
  42609. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42610. /**
  42611. * Gets the client rect of the HTML element used for events
  42612. * @returns a client rectangle
  42613. */
  42614. getInputElementClientRect(): Nullable<ClientRect>;
  42615. /**
  42616. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42617. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42618. * @returns true if engine is in deterministic lock step mode
  42619. */
  42620. isDeterministicLockStep(): boolean;
  42621. /**
  42622. * Gets the max steps when engine is running in deterministic lock step
  42623. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42624. * @returns the max steps
  42625. */
  42626. getLockstepMaxSteps(): number;
  42627. /**
  42628. * Returns the time in ms between steps when using deterministic lock step.
  42629. * @returns time step in (ms)
  42630. */
  42631. getTimeStep(): number;
  42632. /**
  42633. * Force the mipmap generation for the given render target texture
  42634. * @param texture defines the render target texture to use
  42635. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42636. */
  42637. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42638. /** States */
  42639. /**
  42640. * Set various states to the webGL context
  42641. * @param culling defines backface culling state
  42642. * @param zOffset defines the value to apply to zOffset (0 by default)
  42643. * @param force defines if states must be applied even if cache is up to date
  42644. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42645. */
  42646. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42647. /**
  42648. * Set the z offset to apply to current rendering
  42649. * @param value defines the offset to apply
  42650. */
  42651. setZOffset(value: number): void;
  42652. /**
  42653. * Gets the current value of the zOffset
  42654. * @returns the current zOffset state
  42655. */
  42656. getZOffset(): number;
  42657. /**
  42658. * Gets a boolean indicating if depth testing is enabled
  42659. * @returns the current state
  42660. */
  42661. getDepthBuffer(): boolean;
  42662. /**
  42663. * Enable or disable depth buffering
  42664. * @param enable defines the state to set
  42665. */
  42666. setDepthBuffer(enable: boolean): void;
  42667. /**
  42668. * Gets a boolean indicating if depth writing is enabled
  42669. * @returns the current depth writing state
  42670. */
  42671. getDepthWrite(): boolean;
  42672. /**
  42673. * Enable or disable depth writing
  42674. * @param enable defines the state to set
  42675. */
  42676. setDepthWrite(enable: boolean): void;
  42677. /**
  42678. * Gets a boolean indicating if stencil buffer is enabled
  42679. * @returns the current stencil buffer state
  42680. */
  42681. getStencilBuffer(): boolean;
  42682. /**
  42683. * Enable or disable the stencil buffer
  42684. * @param enable defines if the stencil buffer must be enabled or disabled
  42685. */
  42686. setStencilBuffer(enable: boolean): void;
  42687. /**
  42688. * Gets the current stencil mask
  42689. * @returns a number defining the new stencil mask to use
  42690. */
  42691. getStencilMask(): number;
  42692. /**
  42693. * Sets the current stencil mask
  42694. * @param mask defines the new stencil mask to use
  42695. */
  42696. setStencilMask(mask: number): void;
  42697. /**
  42698. * Gets the current stencil function
  42699. * @returns a number defining the stencil function to use
  42700. */
  42701. getStencilFunction(): number;
  42702. /**
  42703. * Gets the current stencil reference value
  42704. * @returns a number defining the stencil reference value to use
  42705. */
  42706. getStencilFunctionReference(): number;
  42707. /**
  42708. * Gets the current stencil mask
  42709. * @returns a number defining the stencil mask to use
  42710. */
  42711. getStencilFunctionMask(): number;
  42712. /**
  42713. * Sets the current stencil function
  42714. * @param stencilFunc defines the new stencil function to use
  42715. */
  42716. setStencilFunction(stencilFunc: number): void;
  42717. /**
  42718. * Sets the current stencil reference
  42719. * @param reference defines the new stencil reference to use
  42720. */
  42721. setStencilFunctionReference(reference: number): void;
  42722. /**
  42723. * Sets the current stencil mask
  42724. * @param mask defines the new stencil mask to use
  42725. */
  42726. setStencilFunctionMask(mask: number): void;
  42727. /**
  42728. * Gets the current stencil operation when stencil fails
  42729. * @returns a number defining stencil operation to use when stencil fails
  42730. */
  42731. getStencilOperationFail(): number;
  42732. /**
  42733. * Gets the current stencil operation when depth fails
  42734. * @returns a number defining stencil operation to use when depth fails
  42735. */
  42736. getStencilOperationDepthFail(): number;
  42737. /**
  42738. * Gets the current stencil operation when stencil passes
  42739. * @returns a number defining stencil operation to use when stencil passes
  42740. */
  42741. getStencilOperationPass(): number;
  42742. /**
  42743. * Sets the stencil operation to use when stencil fails
  42744. * @param operation defines the stencil operation to use when stencil fails
  42745. */
  42746. setStencilOperationFail(operation: number): void;
  42747. /**
  42748. * Sets the stencil operation to use when depth fails
  42749. * @param operation defines the stencil operation to use when depth fails
  42750. */
  42751. setStencilOperationDepthFail(operation: number): void;
  42752. /**
  42753. * Sets the stencil operation to use when stencil passes
  42754. * @param operation defines the stencil operation to use when stencil passes
  42755. */
  42756. setStencilOperationPass(operation: number): void;
  42757. /**
  42758. * Sets a boolean indicating if the dithering state is enabled or disabled
  42759. * @param value defines the dithering state
  42760. */
  42761. setDitheringState(value: boolean): void;
  42762. /**
  42763. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42764. * @param value defines the rasterizer state
  42765. */
  42766. setRasterizerState(value: boolean): void;
  42767. /**
  42768. * Gets the current depth function
  42769. * @returns a number defining the depth function
  42770. */
  42771. getDepthFunction(): Nullable<number>;
  42772. /**
  42773. * Sets the current depth function
  42774. * @param depthFunc defines the function to use
  42775. */
  42776. setDepthFunction(depthFunc: number): void;
  42777. /**
  42778. * Sets the current depth function to GREATER
  42779. */
  42780. setDepthFunctionToGreater(): void;
  42781. /**
  42782. * Sets the current depth function to GEQUAL
  42783. */
  42784. setDepthFunctionToGreaterOrEqual(): void;
  42785. /**
  42786. * Sets the current depth function to LESS
  42787. */
  42788. setDepthFunctionToLess(): void;
  42789. /**
  42790. * Sets the current depth function to LEQUAL
  42791. */
  42792. setDepthFunctionToLessOrEqual(): void;
  42793. private _cachedStencilBuffer;
  42794. private _cachedStencilFunction;
  42795. private _cachedStencilMask;
  42796. private _cachedStencilOperationPass;
  42797. private _cachedStencilOperationFail;
  42798. private _cachedStencilOperationDepthFail;
  42799. private _cachedStencilReference;
  42800. /**
  42801. * Caches the the state of the stencil buffer
  42802. */
  42803. cacheStencilState(): void;
  42804. /**
  42805. * Restores the state of the stencil buffer
  42806. */
  42807. restoreStencilState(): void;
  42808. /**
  42809. * Directly set the WebGL Viewport
  42810. * @param x defines the x coordinate of the viewport (in screen space)
  42811. * @param y defines the y coordinate of the viewport (in screen space)
  42812. * @param width defines the width of the viewport (in screen space)
  42813. * @param height defines the height of the viewport (in screen space)
  42814. * @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
  42815. */
  42816. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42817. /**
  42818. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42819. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42820. * @param y defines the y-coordinate of the corner of the clear rectangle
  42821. * @param width defines the width of the clear rectangle
  42822. * @param height defines the height of the clear rectangle
  42823. * @param clearColor defines the clear color
  42824. */
  42825. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42826. /**
  42827. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42828. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42829. * @param y defines the y-coordinate of the corner of the clear rectangle
  42830. * @param width defines the width of the clear rectangle
  42831. * @param height defines the height of the clear rectangle
  42832. */
  42833. enableScissor(x: number, y: number, width: number, height: number): void;
  42834. /**
  42835. * Disable previously set scissor test rectangle
  42836. */
  42837. disableScissor(): void;
  42838. protected _reportDrawCall(): void;
  42839. /**
  42840. * Initializes a webVR display and starts listening to display change events
  42841. * The onVRDisplayChangedObservable will be notified upon these changes
  42842. * @returns The onVRDisplayChangedObservable
  42843. */
  42844. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42845. /** @hidden */
  42846. _prepareVRComponent(): void;
  42847. /** @hidden */
  42848. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42849. /** @hidden */
  42850. _submitVRFrame(): void;
  42851. /**
  42852. * Call this function to leave webVR mode
  42853. * Will do nothing if webVR is not supported or if there is no webVR device
  42854. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42855. */
  42856. disableVR(): void;
  42857. /**
  42858. * Gets a boolean indicating that the system is in VR mode and is presenting
  42859. * @returns true if VR mode is engaged
  42860. */
  42861. isVRPresenting(): boolean;
  42862. /** @hidden */
  42863. _requestVRFrame(): void;
  42864. /** @hidden */
  42865. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42866. /**
  42867. * Gets the source code of the vertex shader associated with a specific webGL program
  42868. * @param program defines the program to use
  42869. * @returns a string containing the source code of the vertex shader associated with the program
  42870. */
  42871. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42872. /**
  42873. * Gets the source code of the fragment shader associated with a specific webGL program
  42874. * @param program defines the program to use
  42875. * @returns a string containing the source code of the fragment shader associated with the program
  42876. */
  42877. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42878. /**
  42879. * Sets a depth stencil texture from a render target to the according uniform.
  42880. * @param channel The texture channel
  42881. * @param uniform The uniform to set
  42882. * @param texture The render target texture containing the depth stencil texture to apply
  42883. * @param name The texture name
  42884. */
  42885. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>, name?: string): void;
  42886. /**
  42887. * Sets a texture to the webGL context from a postprocess
  42888. * @param channel defines the channel to use
  42889. * @param postProcess defines the source postprocess
  42890. * @param name name of the channel
  42891. */
  42892. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  42893. /**
  42894. * Binds the output of the passed in post process to the texture channel specified
  42895. * @param channel The channel the texture should be bound to
  42896. * @param postProcess The post process which's output should be bound
  42897. * @param name name of the channel
  42898. */
  42899. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  42900. protected _rebuildBuffers(): void;
  42901. /** @hidden */
  42902. _renderFrame(): void;
  42903. _renderLoop(): void;
  42904. /** @hidden */
  42905. _renderViews(): boolean;
  42906. /**
  42907. * Toggle full screen mode
  42908. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42909. */
  42910. switchFullscreen(requestPointerLock: boolean): void;
  42911. /**
  42912. * Enters full screen mode
  42913. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42914. */
  42915. enterFullscreen(requestPointerLock: boolean): void;
  42916. /**
  42917. * Exits full screen mode
  42918. */
  42919. exitFullscreen(): void;
  42920. /**
  42921. * Enters Pointerlock mode
  42922. */
  42923. enterPointerlock(): void;
  42924. /**
  42925. * Exits Pointerlock mode
  42926. */
  42927. exitPointerlock(): void;
  42928. /**
  42929. * Begin a new frame
  42930. */
  42931. beginFrame(): void;
  42932. /**
  42933. * End the current frame
  42934. */
  42935. endFrame(): void;
  42936. /**
  42937. * Resize the view according to the canvas' size
  42938. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42939. */
  42940. resize(forceSetSize?: boolean): void;
  42941. /**
  42942. * Force a specific size of the canvas
  42943. * @param width defines the new canvas' width
  42944. * @param height defines the new canvas' height
  42945. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42946. * @returns true if the size was changed
  42947. */
  42948. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  42949. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42950. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42951. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42952. _releaseTexture(texture: InternalTexture): void;
  42953. /**
  42954. * @hidden
  42955. * Rescales a texture
  42956. * @param source input texture
  42957. * @param destination destination texture
  42958. * @param scene scene to use to render the resize
  42959. * @param internalFormat format to use when resizing
  42960. * @param onComplete callback to be called when resize has completed
  42961. */
  42962. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42963. /**
  42964. * Gets the current framerate
  42965. * @returns a number representing the framerate
  42966. */
  42967. getFps(): number;
  42968. /**
  42969. * Gets the time spent between current and previous frame
  42970. * @returns a number representing the delta time in ms
  42971. */
  42972. getDeltaTime(): number;
  42973. private _measureFps;
  42974. /** @hidden */
  42975. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  42976. /**
  42977. * Updates the sample count of a render target texture
  42978. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42979. * @param texture defines the texture to update
  42980. * @param samples defines the sample count to set
  42981. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42982. */
  42983. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  42984. /**
  42985. * Updates a depth texture Comparison Mode and Function.
  42986. * If the comparison Function is equal to 0, the mode will be set to none.
  42987. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  42988. * @param texture The texture to set the comparison function for
  42989. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  42990. */
  42991. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  42992. /**
  42993. * Creates a webGL buffer to use with instantiation
  42994. * @param capacity defines the size of the buffer
  42995. * @returns the webGL buffer
  42996. */
  42997. createInstancesBuffer(capacity: number): DataBuffer;
  42998. /**
  42999. * Delete a webGL buffer used with instantiation
  43000. * @param buffer defines the webGL buffer to delete
  43001. */
  43002. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  43003. private _clientWaitAsync;
  43004. /** @hidden */
  43005. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;
  43006. dispose(): void;
  43007. private _disableTouchAction;
  43008. /**
  43009. * Display the loading screen
  43010. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43011. */
  43012. displayLoadingUI(): void;
  43013. /**
  43014. * Hide the loading screen
  43015. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43016. */
  43017. hideLoadingUI(): void;
  43018. /**
  43019. * Gets the current loading screen object
  43020. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43021. */
  43022. get loadingScreen(): ILoadingScreen;
  43023. /**
  43024. * Sets the current loading screen object
  43025. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43026. */
  43027. set loadingScreen(loadingScreen: ILoadingScreen);
  43028. /**
  43029. * Sets the current loading screen text
  43030. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43031. */
  43032. set loadingUIText(text: string);
  43033. /**
  43034. * Sets the current loading screen background color
  43035. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43036. */
  43037. set loadingUIBackgroundColor(color: string);
  43038. /** Pointerlock and fullscreen */
  43039. /**
  43040. * Ask the browser to promote the current element to pointerlock mode
  43041. * @param element defines the DOM element to promote
  43042. */
  43043. static _RequestPointerlock(element: HTMLElement): void;
  43044. /**
  43045. * Asks the browser to exit pointerlock mode
  43046. */
  43047. static _ExitPointerlock(): void;
  43048. /**
  43049. * Ask the browser to promote the current element to fullscreen rendering mode
  43050. * @param element defines the DOM element to promote
  43051. */
  43052. static _RequestFullscreen(element: HTMLElement): void;
  43053. /**
  43054. * Asks the browser to exit fullscreen mode
  43055. */
  43056. static _ExitFullscreen(): void;
  43057. }
  43058. }
  43059. declare module BABYLON {
  43060. /**
  43061. * The engine store class is responsible to hold all the instances of Engine and Scene created
  43062. * during the life time of the application.
  43063. */
  43064. export class EngineStore {
  43065. /** Gets the list of created engines */
  43066. static Instances: Engine[];
  43067. /** @hidden */
  43068. static _LastCreatedScene: Nullable<Scene>;
  43069. /**
  43070. * Gets the latest created engine
  43071. */
  43072. static get LastCreatedEngine(): Nullable<Engine>;
  43073. /**
  43074. * Gets the latest created scene
  43075. */
  43076. static get LastCreatedScene(): Nullable<Scene>;
  43077. /**
  43078. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  43079. * @ignorenaming
  43080. */
  43081. static UseFallbackTexture: boolean;
  43082. /**
  43083. * Texture content used if a texture cannot loaded
  43084. * @ignorenaming
  43085. */
  43086. static FallbackTexture: string;
  43087. }
  43088. }
  43089. declare module BABYLON {
  43090. /**
  43091. * Helper class that provides a small promise polyfill
  43092. */
  43093. export class PromisePolyfill {
  43094. /**
  43095. * Static function used to check if the polyfill is required
  43096. * If this is the case then the function will inject the polyfill to window.Promise
  43097. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  43098. */
  43099. static Apply(force?: boolean): void;
  43100. }
  43101. }
  43102. declare module BABYLON {
  43103. /**
  43104. * Interface for screenshot methods with describe argument called `size` as object with options
  43105. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  43106. */
  43107. export interface IScreenshotSize {
  43108. /**
  43109. * number in pixels for canvas height
  43110. */
  43111. height?: number;
  43112. /**
  43113. * multiplier allowing render at a higher or lower resolution
  43114. * If value is defined then height and width will be ignored and taken from camera
  43115. */
  43116. precision?: number;
  43117. /**
  43118. * number in pixels for canvas width
  43119. */
  43120. width?: number;
  43121. }
  43122. }
  43123. declare module BABYLON {
  43124. interface IColor4Like {
  43125. r: float;
  43126. g: float;
  43127. b: float;
  43128. a: float;
  43129. }
  43130. /**
  43131. * Class containing a set of static utilities functions
  43132. */
  43133. export class Tools {
  43134. /**
  43135. * Gets or sets the base URL to use to load assets
  43136. */
  43137. static get BaseUrl(): string;
  43138. static set BaseUrl(value: string);
  43139. /**
  43140. * Enable/Disable Custom HTTP Request Headers globally.
  43141. * default = false
  43142. * @see CustomRequestHeaders
  43143. */
  43144. static UseCustomRequestHeaders: boolean;
  43145. /**
  43146. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  43147. * i.e. when loading files, where the server/service expects an Authorization header
  43148. */
  43149. static CustomRequestHeaders: {
  43150. [key: string]: string;
  43151. };
  43152. /**
  43153. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  43154. */
  43155. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  43156. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  43157. /**
  43158. * Default behaviour for cors in the application.
  43159. * It can be a string if the expected behavior is identical in the entire app.
  43160. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  43161. */
  43162. static get CorsBehavior(): string | ((url: string | string[]) => string);
  43163. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  43164. /**
  43165. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  43166. * @ignorenaming
  43167. */
  43168. static get UseFallbackTexture(): boolean;
  43169. static set UseFallbackTexture(value: boolean);
  43170. /**
  43171. * Use this object to register external classes like custom textures or material
  43172. * to allow the loaders to instantiate them
  43173. */
  43174. static get RegisteredExternalClasses(): {
  43175. [key: string]: Object;
  43176. };
  43177. static set RegisteredExternalClasses(classes: {
  43178. [key: string]: Object;
  43179. });
  43180. /**
  43181. * Texture content used if a texture cannot loaded
  43182. * @ignorenaming
  43183. */
  43184. static get fallbackTexture(): string;
  43185. static set fallbackTexture(value: string);
  43186. /**
  43187. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  43188. * @param u defines the coordinate on X axis
  43189. * @param v defines the coordinate on Y axis
  43190. * @param width defines the width of the source data
  43191. * @param height defines the height of the source data
  43192. * @param pixels defines the source byte array
  43193. * @param color defines the output color
  43194. */
  43195. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  43196. /**
  43197. * Interpolates between a and b via alpha
  43198. * @param a The lower value (returned when alpha = 0)
  43199. * @param b The upper value (returned when alpha = 1)
  43200. * @param alpha The interpolation-factor
  43201. * @return The mixed value
  43202. */
  43203. static Mix(a: number, b: number, alpha: number): number;
  43204. /**
  43205. * Tries to instantiate a new object from a given class name
  43206. * @param className defines the class name to instantiate
  43207. * @returns the new object or null if the system was not able to do the instantiation
  43208. */
  43209. static Instantiate(className: string): any;
  43210. /**
  43211. * Provides a slice function that will work even on IE
  43212. * @param data defines the array to slice
  43213. * @param start defines the start of the data (optional)
  43214. * @param end defines the end of the data (optional)
  43215. * @returns the new sliced array
  43216. */
  43217. static Slice<T>(data: T, start?: number, end?: number): T;
  43218. /**
  43219. * Provides a slice function that will work even on IE
  43220. * The difference between this and Slice is that this will force-convert to array
  43221. * @param data defines the array to slice
  43222. * @param start defines the start of the data (optional)
  43223. * @param end defines the end of the data (optional)
  43224. * @returns the new sliced array
  43225. */
  43226. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  43227. /**
  43228. * Polyfill for setImmediate
  43229. * @param action defines the action to execute after the current execution block
  43230. */
  43231. static SetImmediate(action: () => void): void;
  43232. /**
  43233. * Function indicating if a number is an exponent of 2
  43234. * @param value defines the value to test
  43235. * @returns true if the value is an exponent of 2
  43236. */
  43237. static IsExponentOfTwo(value: number): boolean;
  43238. private static _tmpFloatArray;
  43239. /**
  43240. * Returns the nearest 32-bit single precision float representation of a Number
  43241. * @param value A Number. If the parameter is of a different type, it will get converted
  43242. * to a number or to NaN if it cannot be converted
  43243. * @returns number
  43244. */
  43245. static FloatRound(value: number): number;
  43246. /**
  43247. * Extracts the filename from a path
  43248. * @param path defines the path to use
  43249. * @returns the filename
  43250. */
  43251. static GetFilename(path: string): string;
  43252. /**
  43253. * Extracts the "folder" part of a path (everything before the filename).
  43254. * @param uri The URI to extract the info from
  43255. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  43256. * @returns The "folder" part of the path
  43257. */
  43258. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  43259. /**
  43260. * Extracts text content from a DOM element hierarchy
  43261. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  43262. */
  43263. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  43264. /**
  43265. * Convert an angle in radians to degrees
  43266. * @param angle defines the angle to convert
  43267. * @returns the angle in degrees
  43268. */
  43269. static ToDegrees(angle: number): number;
  43270. /**
  43271. * Convert an angle in degrees to radians
  43272. * @param angle defines the angle to convert
  43273. * @returns the angle in radians
  43274. */
  43275. static ToRadians(angle: number): number;
  43276. /**
  43277. * Returns an array if obj is not an array
  43278. * @param obj defines the object to evaluate as an array
  43279. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  43280. * @returns either obj directly if obj is an array or a new array containing obj
  43281. */
  43282. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  43283. /**
  43284. * Gets the pointer prefix to use
  43285. * @param engine defines the engine we are finding the prefix for
  43286. * @returns "pointer" if touch is enabled. Else returns "mouse"
  43287. */
  43288. static GetPointerPrefix(engine: Engine): string;
  43289. /**
  43290. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  43291. * @param url define the url we are trying
  43292. * @param element define the dom element where to configure the cors policy
  43293. */
  43294. static SetCorsBehavior(url: string | string[], element: {
  43295. crossOrigin: string | null;
  43296. }): void;
  43297. /**
  43298. * Removes unwanted characters from an url
  43299. * @param url defines the url to clean
  43300. * @returns the cleaned url
  43301. */
  43302. static CleanUrl(url: string): string;
  43303. /**
  43304. * Gets or sets a function used to pre-process url before using them to load assets
  43305. */
  43306. static get PreprocessUrl(): (url: string) => string;
  43307. static set PreprocessUrl(processor: (url: string) => string);
  43308. /**
  43309. * Loads an image as an HTMLImageElement.
  43310. * @param input url string, ArrayBuffer, or Blob to load
  43311. * @param onLoad callback called when the image successfully loads
  43312. * @param onError callback called when the image fails to load
  43313. * @param offlineProvider offline provider for caching
  43314. * @param mimeType optional mime type
  43315. * @returns the HTMLImageElement of the loaded image
  43316. */
  43317. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  43318. /**
  43319. * Loads a file from a url
  43320. * @param url url string, ArrayBuffer, or Blob to load
  43321. * @param onSuccess callback called when the file successfully loads
  43322. * @param onProgress callback called while file is loading (if the server supports this mode)
  43323. * @param offlineProvider defines the offline provider for caching
  43324. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43325. * @param onError callback called when the file fails to load
  43326. * @returns a file request object
  43327. */
  43328. 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;
  43329. /**
  43330. * Loads a file from a url
  43331. * @param url the file url to load
  43332. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43333. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  43334. */
  43335. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  43336. /**
  43337. * Load a script (identified by an url). When the url returns, the
  43338. * content of this file is added into a new script element, attached to the DOM (body element)
  43339. * @param scriptUrl defines the url of the script to laod
  43340. * @param onSuccess defines the callback called when the script is loaded
  43341. * @param onError defines the callback to call if an error occurs
  43342. * @param scriptId defines the id of the script element
  43343. */
  43344. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  43345. /**
  43346. * Load an asynchronous script (identified by an url). When the url returns, the
  43347. * content of this file is added into a new script element, attached to the DOM (body element)
  43348. * @param scriptUrl defines the url of the script to laod
  43349. * @param scriptId defines the id of the script element
  43350. * @returns a promise request object
  43351. */
  43352. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  43353. /**
  43354. * Loads a file from a blob
  43355. * @param fileToLoad defines the blob to use
  43356. * @param callback defines the callback to call when data is loaded
  43357. * @param progressCallback defines the callback to call during loading process
  43358. * @returns a file request object
  43359. */
  43360. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  43361. /**
  43362. * Reads a file from a File object
  43363. * @param file defines the file to load
  43364. * @param onSuccess defines the callback to call when data is loaded
  43365. * @param onProgress defines the callback to call during loading process
  43366. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43367. * @param onError defines the callback to call when an error occurs
  43368. * @returns a file request object
  43369. */
  43370. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  43371. /**
  43372. * Creates a data url from a given string content
  43373. * @param content defines the content to convert
  43374. * @returns the new data url link
  43375. */
  43376. static FileAsURL(content: string): string;
  43377. /**
  43378. * Format the given number to a specific decimal format
  43379. * @param value defines the number to format
  43380. * @param decimals defines the number of decimals to use
  43381. * @returns the formatted string
  43382. */
  43383. static Format(value: number, decimals?: number): string;
  43384. /**
  43385. * Tries to copy an object by duplicating every property
  43386. * @param source defines the source object
  43387. * @param destination defines the target object
  43388. * @param doNotCopyList defines a list of properties to avoid
  43389. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  43390. */
  43391. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  43392. /**
  43393. * Gets a boolean indicating if the given object has no own property
  43394. * @param obj defines the object to test
  43395. * @returns true if object has no own property
  43396. */
  43397. static IsEmpty(obj: any): boolean;
  43398. /**
  43399. * Function used to register events at window level
  43400. * @param windowElement defines the Window object to use
  43401. * @param events defines the events to register
  43402. */
  43403. static RegisterTopRootEvents(windowElement: Window, events: {
  43404. name: string;
  43405. handler: Nullable<(e: FocusEvent) => any>;
  43406. }[]): void;
  43407. /**
  43408. * Function used to unregister events from window level
  43409. * @param windowElement defines the Window object to use
  43410. * @param events defines the events to unregister
  43411. */
  43412. static UnregisterTopRootEvents(windowElement: Window, events: {
  43413. name: string;
  43414. handler: Nullable<(e: FocusEvent) => any>;
  43415. }[]): void;
  43416. /**
  43417. * @ignore
  43418. */
  43419. static _ScreenshotCanvas: HTMLCanvasElement;
  43420. /**
  43421. * Dumps the current bound framebuffer
  43422. * @param width defines the rendering width
  43423. * @param height defines the rendering height
  43424. * @param engine defines the hosting engine
  43425. * @param successCallback defines the callback triggered once the data are available
  43426. * @param mimeType defines the mime type of the result
  43427. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43428. * @return a void promise
  43429. */
  43430. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): Promise<void>;
  43431. /**
  43432. * Dumps an array buffer
  43433. * @param width defines the rendering width
  43434. * @param height defines the rendering height
  43435. * @param data the data array
  43436. * @param successCallback defines the callback triggered once the data are available
  43437. * @param mimeType defines the mime type of the result
  43438. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43439. * @param invertY true to invert the picture in the Y dimension
  43440. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43441. */
  43442. static DumpData(width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): void;
  43443. /**
  43444. * Dumps an array buffer
  43445. * @param width defines the rendering width
  43446. * @param height defines the rendering height
  43447. * @param data the data array
  43448. * @param successCallback defines the callback triggered once the data are available
  43449. * @param mimeType defines the mime type of the result
  43450. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43451. * @param invertY true to invert the picture in the Y dimension
  43452. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43453. * @return a promise that resolve to the final data
  43454. */
  43455. static DumpDataAsync(width: number, height: number, data: ArrayBufferView, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  43456. /**
  43457. * Converts the canvas data to blob.
  43458. * This acts as a polyfill for browsers not supporting the to blob function.
  43459. * @param canvas Defines the canvas to extract the data from
  43460. * @param successCallback Defines the callback triggered once the data are available
  43461. * @param mimeType Defines the mime type of the result
  43462. */
  43463. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43464. /**
  43465. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43466. * @param successCallback defines the callback triggered once the data are available
  43467. * @param mimeType defines the mime type of the result
  43468. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43469. * @param canvas canvas to get the data from. If not provided, use the default screenshot canvas
  43470. */
  43471. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string, canvas?: HTMLCanvasElement): void;
  43472. /**
  43473. * Downloads a blob in the browser
  43474. * @param blob defines the blob to download
  43475. * @param fileName defines the name of the downloaded file
  43476. */
  43477. static Download(blob: Blob, fileName: string): void;
  43478. /**
  43479. * Will return the right value of the noPreventDefault variable
  43480. * Needed to keep backwards compatibility to the old API.
  43481. *
  43482. * @param args arguments passed to the attachControl function
  43483. * @returns the correct value for noPreventDefault
  43484. */
  43485. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  43486. /**
  43487. * Captures a screenshot of the current rendering
  43488. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43489. * @param engine defines the rendering engine
  43490. * @param camera defines the source camera
  43491. * @param size This parameter can be set to a single number or to an object with the
  43492. * following (optional) properties: precision, width, height. If a single number is passed,
  43493. * it will be used for both width and height. If an object is passed, the screenshot size
  43494. * will be derived from the parameters. The precision property is a multiplier allowing
  43495. * rendering at a higher or lower resolution
  43496. * @param successCallback defines the callback receives a single parameter which contains the
  43497. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43498. * src parameter of an <img> to display it
  43499. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43500. * Check your browser for supported MIME types
  43501. */
  43502. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43503. /**
  43504. * Captures a screenshot of the current rendering
  43505. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43506. * @param engine defines the rendering engine
  43507. * @param camera defines the source camera
  43508. * @param size This parameter can be set to a single number or to an object with the
  43509. * following (optional) properties: precision, width, height. If a single number is passed,
  43510. * it will be used for both width and height. If an object is passed, the screenshot size
  43511. * will be derived from the parameters. The precision property is a multiplier allowing
  43512. * rendering at a higher or lower resolution
  43513. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43514. * Check your browser for supported MIME types
  43515. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43516. * to the src parameter of an <img> to display it
  43517. */
  43518. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43519. /**
  43520. * Generates an image screenshot from the specified camera.
  43521. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43522. * @param engine The engine to use for rendering
  43523. * @param camera The camera to use for rendering
  43524. * @param size This parameter can be set to a single number or to an object with the
  43525. * following (optional) properties: precision, width, height. If a single number is passed,
  43526. * it will be used for both width and height. If an object is passed, the screenshot size
  43527. * will be derived from the parameters. The precision property is a multiplier allowing
  43528. * rendering at a higher or lower resolution
  43529. * @param successCallback The callback receives a single parameter which contains the
  43530. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43531. * src parameter of an <img> to display it
  43532. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43533. * Check your browser for supported MIME types
  43534. * @param samples Texture samples (default: 1)
  43535. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43536. * @param fileName A name for for the downloaded file.
  43537. */
  43538. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43539. /**
  43540. * Generates an image screenshot from the specified camera.
  43541. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43542. * @param engine The engine to use for rendering
  43543. * @param camera The camera to use for rendering
  43544. * @param size This parameter can be set to a single number or to an object with the
  43545. * following (optional) properties: precision, width, height. If a single number is passed,
  43546. * it will be used for both width and height. If an object is passed, the screenshot size
  43547. * will be derived from the parameters. The precision property is a multiplier allowing
  43548. * rendering at a higher or lower resolution
  43549. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43550. * Check your browser for supported MIME types
  43551. * @param samples Texture samples (default: 1)
  43552. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43553. * @param fileName A name for for the downloaded file.
  43554. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43555. * to the src parameter of an <img> to display it
  43556. */
  43557. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43558. /**
  43559. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43560. * Be aware Math.random() could cause collisions, but:
  43561. * "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"
  43562. * @returns a pseudo random id
  43563. */
  43564. static RandomId(): string;
  43565. /**
  43566. * Test if the given uri is a base64 string
  43567. * @param uri The uri to test
  43568. * @return True if the uri is a base64 string or false otherwise
  43569. */
  43570. static IsBase64(uri: string): boolean;
  43571. /**
  43572. * Decode the given base64 uri.
  43573. * @param uri The uri to decode
  43574. * @return The decoded base64 data.
  43575. */
  43576. static DecodeBase64(uri: string): ArrayBuffer;
  43577. /**
  43578. * Gets the absolute url.
  43579. * @param url the input url
  43580. * @return the absolute url
  43581. */
  43582. static GetAbsoluteUrl(url: string): string;
  43583. /**
  43584. * No log
  43585. */
  43586. static readonly NoneLogLevel: number;
  43587. /**
  43588. * Only message logs
  43589. */
  43590. static readonly MessageLogLevel: number;
  43591. /**
  43592. * Only warning logs
  43593. */
  43594. static readonly WarningLogLevel: number;
  43595. /**
  43596. * Only error logs
  43597. */
  43598. static readonly ErrorLogLevel: number;
  43599. /**
  43600. * All logs
  43601. */
  43602. static readonly AllLogLevel: number;
  43603. /**
  43604. * Gets a value indicating the number of loading errors
  43605. * @ignorenaming
  43606. */
  43607. static get errorsCount(): number;
  43608. /**
  43609. * Callback called when a new log is added
  43610. */
  43611. static OnNewCacheEntry: (entry: string) => void;
  43612. /**
  43613. * Log a message to the console
  43614. * @param message defines the message to log
  43615. */
  43616. static Log(message: string): void;
  43617. /**
  43618. * Write a warning message to the console
  43619. * @param message defines the message to log
  43620. */
  43621. static Warn(message: string): void;
  43622. /**
  43623. * Write an error message to the console
  43624. * @param message defines the message to log
  43625. */
  43626. static Error(message: string): void;
  43627. /**
  43628. * Gets current log cache (list of logs)
  43629. */
  43630. static get LogCache(): string;
  43631. /**
  43632. * Clears the log cache
  43633. */
  43634. static ClearLogCache(): void;
  43635. /**
  43636. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43637. */
  43638. static set LogLevels(level: number);
  43639. /**
  43640. * Checks if the window object exists
  43641. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43642. */
  43643. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43644. /**
  43645. * No performance log
  43646. */
  43647. static readonly PerformanceNoneLogLevel: number;
  43648. /**
  43649. * Use user marks to log performance
  43650. */
  43651. static readonly PerformanceUserMarkLogLevel: number;
  43652. /**
  43653. * Log performance to the console
  43654. */
  43655. static readonly PerformanceConsoleLogLevel: number;
  43656. private static _performance;
  43657. /**
  43658. * Sets the current performance log level
  43659. */
  43660. static set PerformanceLogLevel(level: number);
  43661. private static _StartPerformanceCounterDisabled;
  43662. private static _EndPerformanceCounterDisabled;
  43663. private static _StartUserMark;
  43664. private static _EndUserMark;
  43665. private static _StartPerformanceConsole;
  43666. private static _EndPerformanceConsole;
  43667. /**
  43668. * Starts a performance counter
  43669. */
  43670. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43671. /**
  43672. * Ends a specific performance counter
  43673. */
  43674. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43675. /**
  43676. * Gets either window.performance.now() if supported or Date.now() else
  43677. */
  43678. static get Now(): number;
  43679. /**
  43680. * This method will return the name of the class used to create the instance of the given object.
  43681. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43682. * @param object the object to get the class name from
  43683. * @param isType defines if the object is actually a type
  43684. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43685. */
  43686. static GetClassName(object: any, isType?: boolean): string;
  43687. /**
  43688. * Gets the first element of an array satisfying a given predicate
  43689. * @param array defines the array to browse
  43690. * @param predicate defines the predicate to use
  43691. * @returns null if not found or the element
  43692. */
  43693. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43694. /**
  43695. * This method will return the name of the full name of the class, including its owning module (if any).
  43696. * 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).
  43697. * @param object the object to get the class name from
  43698. * @param isType defines if the object is actually a type
  43699. * @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.
  43700. * @ignorenaming
  43701. */
  43702. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43703. /**
  43704. * Returns a promise that resolves after the given amount of time.
  43705. * @param delay Number of milliseconds to delay
  43706. * @returns Promise that resolves after the given amount of time
  43707. */
  43708. static DelayAsync(delay: number): Promise<void>;
  43709. /**
  43710. * Utility function to detect if the current user agent is Safari
  43711. * @returns whether or not the current user agent is safari
  43712. */
  43713. static IsSafari(): boolean;
  43714. }
  43715. /**
  43716. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43717. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43718. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43719. * @param name The name of the class, case should be preserved
  43720. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43721. */
  43722. export function className(name: string, module?: string): (target: Object) => void;
  43723. /**
  43724. * An implementation of a loop for asynchronous functions.
  43725. */
  43726. export class AsyncLoop {
  43727. /**
  43728. * Defines the number of iterations for the loop
  43729. */
  43730. iterations: number;
  43731. /**
  43732. * Defines the current index of the loop.
  43733. */
  43734. index: number;
  43735. private _done;
  43736. private _fn;
  43737. private _successCallback;
  43738. /**
  43739. * Constructor.
  43740. * @param iterations the number of iterations.
  43741. * @param func the function to run each iteration
  43742. * @param successCallback the callback that will be called upon successful execution
  43743. * @param offset starting offset.
  43744. */
  43745. constructor(
  43746. /**
  43747. * Defines the number of iterations for the loop
  43748. */
  43749. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43750. /**
  43751. * Execute the next iteration. Must be called after the last iteration was finished.
  43752. */
  43753. executeNext(): void;
  43754. /**
  43755. * Break the loop and run the success callback.
  43756. */
  43757. breakLoop(): void;
  43758. /**
  43759. * Create and run an async loop.
  43760. * @param iterations the number of iterations.
  43761. * @param fn the function to run each iteration
  43762. * @param successCallback the callback that will be called upon successful execution
  43763. * @param offset starting offset.
  43764. * @returns the created async loop object
  43765. */
  43766. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43767. /**
  43768. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43769. * @param iterations total number of iterations
  43770. * @param syncedIterations number of synchronous iterations in each async iteration.
  43771. * @param fn the function to call each iteration.
  43772. * @param callback a success call back that will be called when iterating stops.
  43773. * @param breakFunction a break condition (optional)
  43774. * @param timeout timeout settings for the setTimeout function. default - 0.
  43775. * @returns the created async loop object
  43776. */
  43777. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43778. }
  43779. }
  43780. declare module BABYLON {
  43781. /**
  43782. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43783. * The underlying implementation relies on an associative array to ensure the best performances.
  43784. * The value can be anything including 'null' but except 'undefined'
  43785. */
  43786. export class StringDictionary<T> {
  43787. /**
  43788. * This will clear this dictionary and copy the content from the 'source' one.
  43789. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43790. * @param source the dictionary to take the content from and copy to this dictionary
  43791. */
  43792. copyFrom(source: StringDictionary<T>): void;
  43793. /**
  43794. * Get a value based from its key
  43795. * @param key the given key to get the matching value from
  43796. * @return the value if found, otherwise undefined is returned
  43797. */
  43798. get(key: string): T | undefined;
  43799. /**
  43800. * Get a value from its key or add it if it doesn't exist.
  43801. * This method will ensure you that a given key/data will be present in the dictionary.
  43802. * @param key the given key to get the matching value from
  43803. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43804. * The factory will only be invoked if there's no data for the given key.
  43805. * @return the value corresponding to the key.
  43806. */
  43807. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43808. /**
  43809. * Get a value from its key if present in the dictionary otherwise add it
  43810. * @param key the key to get the value from
  43811. * @param val if there's no such key/value pair in the dictionary add it with this value
  43812. * @return the value corresponding to the key
  43813. */
  43814. getOrAdd(key: string, val: T): T;
  43815. /**
  43816. * Check if there's a given key in the dictionary
  43817. * @param key the key to check for
  43818. * @return true if the key is present, false otherwise
  43819. */
  43820. contains(key: string): boolean;
  43821. /**
  43822. * Add a new key and its corresponding value
  43823. * @param key the key to add
  43824. * @param value the value corresponding to the key
  43825. * @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
  43826. */
  43827. add(key: string, value: T): boolean;
  43828. /**
  43829. * Update a specific value associated to a key
  43830. * @param key defines the key to use
  43831. * @param value defines the value to store
  43832. * @returns true if the value was updated (or false if the key was not found)
  43833. */
  43834. set(key: string, value: T): boolean;
  43835. /**
  43836. * Get the element of the given key and remove it from the dictionary
  43837. * @param key defines the key to search
  43838. * @returns the value associated with the key or null if not found
  43839. */
  43840. getAndRemove(key: string): Nullable<T>;
  43841. /**
  43842. * Remove a key/value from the dictionary.
  43843. * @param key the key to remove
  43844. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43845. */
  43846. remove(key: string): boolean;
  43847. /**
  43848. * Clear the whole content of the dictionary
  43849. */
  43850. clear(): void;
  43851. /**
  43852. * Gets the current count
  43853. */
  43854. get count(): number;
  43855. /**
  43856. * Execute a callback on each key/val of the dictionary.
  43857. * Note that you can remove any element in this dictionary in the callback implementation
  43858. * @param callback the callback to execute on a given key/value pair
  43859. */
  43860. forEach(callback: (key: string, val: T) => void): void;
  43861. /**
  43862. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43863. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43864. * Note that you can remove any element in this dictionary in the callback implementation
  43865. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43866. * @returns the first item
  43867. */
  43868. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43869. private _count;
  43870. private _data;
  43871. }
  43872. }
  43873. declare module BABYLON {
  43874. /** @hidden */
  43875. export interface ICollisionCoordinator {
  43876. createCollider(): Collider;
  43877. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43878. init(scene: Scene): void;
  43879. }
  43880. /** @hidden */
  43881. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43882. private _scene;
  43883. private _scaledPosition;
  43884. private _scaledVelocity;
  43885. private _finalPosition;
  43886. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43887. createCollider(): Collider;
  43888. init(scene: Scene): void;
  43889. private _collideWithWorld;
  43890. }
  43891. }
  43892. declare module BABYLON {
  43893. /**
  43894. * Class used to manage all inputs for the scene.
  43895. */
  43896. export class InputManager {
  43897. /** The distance in pixel that you have to move to prevent some events */
  43898. static DragMovementThreshold: number;
  43899. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43900. static LongPressDelay: number;
  43901. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43902. static DoubleClickDelay: number;
  43903. /** If you need to check double click without raising a single click at first click, enable this flag */
  43904. static ExclusiveDoubleClickMode: boolean;
  43905. /** 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. */
  43906. private _alreadyAttached;
  43907. private _alreadyAttachedTo;
  43908. private _wheelEventName;
  43909. private _onPointerMove;
  43910. private _onPointerDown;
  43911. private _onPointerUp;
  43912. private _initClickEvent;
  43913. private _initActionManager;
  43914. private _delayedSimpleClick;
  43915. private _delayedSimpleClickTimeout;
  43916. private _previousDelayedSimpleClickTimeout;
  43917. private _meshPickProceed;
  43918. private _previousButtonPressed;
  43919. private _currentPickResult;
  43920. private _previousPickResult;
  43921. private _totalPointersPressed;
  43922. private _doubleClickOccured;
  43923. private _pointerOverMesh;
  43924. private _pickedDownMesh;
  43925. private _pickedUpMesh;
  43926. private _pointerX;
  43927. private _pointerY;
  43928. private _unTranslatedPointerX;
  43929. private _unTranslatedPointerY;
  43930. private _startingPointerPosition;
  43931. private _previousStartingPointerPosition;
  43932. private _startingPointerTime;
  43933. private _previousStartingPointerTime;
  43934. private _pointerCaptures;
  43935. private _meshUnderPointerId;
  43936. private _onKeyDown;
  43937. private _onKeyUp;
  43938. private _keyboardIsAttached;
  43939. private _onCanvasFocusObserver;
  43940. private _onCanvasBlurObserver;
  43941. private _scene;
  43942. /**
  43943. * Creates a new InputManager
  43944. * @param scene defines the hosting scene
  43945. */
  43946. constructor(scene: Scene);
  43947. /**
  43948. * Gets the mesh that is currently under the pointer
  43949. */
  43950. get meshUnderPointer(): Nullable<AbstractMesh>;
  43951. /**
  43952. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  43953. * @param pointerId the pointer id to use
  43954. * @returns The mesh under this pointer id or null if not found
  43955. */
  43956. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  43957. /**
  43958. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  43959. */
  43960. get unTranslatedPointer(): Vector2;
  43961. /**
  43962. * Gets or sets the current on-screen X position of the pointer
  43963. */
  43964. get pointerX(): number;
  43965. set pointerX(value: number);
  43966. /**
  43967. * Gets or sets the current on-screen Y position of the pointer
  43968. */
  43969. get pointerY(): number;
  43970. set pointerY(value: number);
  43971. private _updatePointerPosition;
  43972. private _processPointerMove;
  43973. private _setRayOnPointerInfo;
  43974. private _checkPrePointerObservable;
  43975. /**
  43976. * Use this method to simulate a pointer move on a mesh
  43977. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43978. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43979. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43980. */
  43981. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43982. /**
  43983. * Use this method to simulate a pointer down on a mesh
  43984. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43985. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43986. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43987. */
  43988. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43989. private _processPointerDown;
  43990. /** @hidden */
  43991. _isPointerSwiping(): boolean;
  43992. /**
  43993. * Use this method to simulate a pointer up on a mesh
  43994. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43995. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43996. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43997. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43998. */
  43999. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  44000. private _processPointerUp;
  44001. /**
  44002. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  44003. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  44004. * @returns true if the pointer was captured
  44005. */
  44006. isPointerCaptured(pointerId?: number): boolean;
  44007. /**
  44008. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  44009. * @param attachUp defines if you want to attach events to pointerup
  44010. * @param attachDown defines if you want to attach events to pointerdown
  44011. * @param attachMove defines if you want to attach events to pointermove
  44012. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  44013. */
  44014. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  44015. /**
  44016. * Detaches all event handlers
  44017. */
  44018. detachControl(): void;
  44019. /**
  44020. * Force the value of meshUnderPointer
  44021. * @param mesh defines the mesh to use
  44022. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  44023. */
  44024. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44025. /**
  44026. * Gets the mesh under the pointer
  44027. * @returns a Mesh or null if no mesh is under the pointer
  44028. */
  44029. getPointerOverMesh(): Nullable<AbstractMesh>;
  44030. }
  44031. }
  44032. declare module BABYLON {
  44033. /**
  44034. * This class defines the direct association between an animation and a target
  44035. */
  44036. export class TargetedAnimation {
  44037. /**
  44038. * Animation to perform
  44039. */
  44040. animation: Animation;
  44041. /**
  44042. * Target to animate
  44043. */
  44044. target: any;
  44045. /**
  44046. * Returns the string "TargetedAnimation"
  44047. * @returns "TargetedAnimation"
  44048. */
  44049. getClassName(): string;
  44050. /**
  44051. * Serialize the object
  44052. * @returns the JSON object representing the current entity
  44053. */
  44054. serialize(): any;
  44055. }
  44056. /**
  44057. * Use this class to create coordinated animations on multiple targets
  44058. */
  44059. export class AnimationGroup implements IDisposable {
  44060. /** The name of the animation group */
  44061. name: string;
  44062. private _scene;
  44063. private _targetedAnimations;
  44064. private _animatables;
  44065. private _from;
  44066. private _to;
  44067. private _isStarted;
  44068. private _isPaused;
  44069. private _speedRatio;
  44070. private _loopAnimation;
  44071. private _isAdditive;
  44072. /**
  44073. * Gets or sets the unique id of the node
  44074. */
  44075. uniqueId: number;
  44076. /**
  44077. * This observable will notify when one animation have ended
  44078. */
  44079. onAnimationEndObservable: Observable<TargetedAnimation>;
  44080. /**
  44081. * Observer raised when one animation loops
  44082. */
  44083. onAnimationLoopObservable: Observable<TargetedAnimation>;
  44084. /**
  44085. * Observer raised when all animations have looped
  44086. */
  44087. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  44088. /**
  44089. * This observable will notify when all animations have ended.
  44090. */
  44091. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  44092. /**
  44093. * This observable will notify when all animations have paused.
  44094. */
  44095. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  44096. /**
  44097. * This observable will notify when all animations are playing.
  44098. */
  44099. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  44100. /**
  44101. * Gets the first frame
  44102. */
  44103. get from(): number;
  44104. /**
  44105. * Gets the last frame
  44106. */
  44107. get to(): number;
  44108. /**
  44109. * Define if the animations are started
  44110. */
  44111. get isStarted(): boolean;
  44112. /**
  44113. * Gets a value indicating that the current group is playing
  44114. */
  44115. get isPlaying(): boolean;
  44116. /**
  44117. * Gets or sets the speed ratio to use for all animations
  44118. */
  44119. get speedRatio(): number;
  44120. /**
  44121. * Gets or sets the speed ratio to use for all animations
  44122. */
  44123. set speedRatio(value: number);
  44124. /**
  44125. * Gets or sets if all animations should loop or not
  44126. */
  44127. get loopAnimation(): boolean;
  44128. set loopAnimation(value: boolean);
  44129. /**
  44130. * Gets or sets if all animations should be evaluated additively
  44131. */
  44132. get isAdditive(): boolean;
  44133. set isAdditive(value: boolean);
  44134. /**
  44135. * Gets the targeted animations for this animation group
  44136. */
  44137. get targetedAnimations(): Array<TargetedAnimation>;
  44138. /**
  44139. * returning the list of animatables controlled by this animation group.
  44140. */
  44141. get animatables(): Array<Animatable>;
  44142. /**
  44143. * Gets the list of target animations
  44144. */
  44145. get children(): TargetedAnimation[];
  44146. /**
  44147. * Instantiates a new Animation Group.
  44148. * This helps managing several animations at once.
  44149. * @see https://doc.babylonjs.com/how_to/group
  44150. * @param name Defines the name of the group
  44151. * @param scene Defines the scene the group belongs to
  44152. */
  44153. constructor(
  44154. /** The name of the animation group */
  44155. name: string, scene?: Nullable<Scene>);
  44156. /**
  44157. * Add an animation (with its target) in the group
  44158. * @param animation defines the animation we want to add
  44159. * @param target defines the target of the animation
  44160. * @returns the TargetedAnimation object
  44161. */
  44162. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  44163. /**
  44164. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  44165. * It can add constant keys at begin or end
  44166. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  44167. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  44168. * @returns the animation group
  44169. */
  44170. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  44171. private _animationLoopCount;
  44172. private _animationLoopFlags;
  44173. private _processLoop;
  44174. /**
  44175. * Start all animations on given targets
  44176. * @param loop defines if animations must loop
  44177. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  44178. * @param from defines the from key (optional)
  44179. * @param to defines the to key (optional)
  44180. * @param isAdditive defines the additive state for the resulting animatables (optional)
  44181. * @returns the current animation group
  44182. */
  44183. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  44184. /**
  44185. * Pause all animations
  44186. * @returns the animation group
  44187. */
  44188. pause(): AnimationGroup;
  44189. /**
  44190. * Play all animations to initial state
  44191. * This function will start() the animations if they were not started or will restart() them if they were paused
  44192. * @param loop defines if animations must loop
  44193. * @returns the animation group
  44194. */
  44195. play(loop?: boolean): AnimationGroup;
  44196. /**
  44197. * Reset all animations to initial state
  44198. * @returns the animation group
  44199. */
  44200. reset(): AnimationGroup;
  44201. /**
  44202. * Restart animations from key 0
  44203. * @returns the animation group
  44204. */
  44205. restart(): AnimationGroup;
  44206. /**
  44207. * Stop all animations
  44208. * @returns the animation group
  44209. */
  44210. stop(): AnimationGroup;
  44211. /**
  44212. * Set animation weight for all animatables
  44213. * @param weight defines the weight to use
  44214. * @return the animationGroup
  44215. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44216. */
  44217. setWeightForAllAnimatables(weight: number): AnimationGroup;
  44218. /**
  44219. * Synchronize and normalize all animatables with a source animatable
  44220. * @param root defines the root animatable to synchronize with
  44221. * @return the animationGroup
  44222. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44223. */
  44224. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  44225. /**
  44226. * Goes to a specific frame in this animation group
  44227. * @param frame the frame number to go to
  44228. * @return the animationGroup
  44229. */
  44230. goToFrame(frame: number): AnimationGroup;
  44231. /**
  44232. * Dispose all associated resources
  44233. */
  44234. dispose(): void;
  44235. private _checkAnimationGroupEnded;
  44236. /**
  44237. * Clone the current animation group and returns a copy
  44238. * @param newName defines the name of the new group
  44239. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  44240. * @returns the new animation group
  44241. */
  44242. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  44243. /**
  44244. * Serializes the animationGroup to an object
  44245. * @returns Serialized object
  44246. */
  44247. serialize(): any;
  44248. /**
  44249. * Returns a new AnimationGroup object parsed from the source provided.
  44250. * @param parsedAnimationGroup defines the source
  44251. * @param scene defines the scene that will receive the animationGroup
  44252. * @returns a new AnimationGroup
  44253. */
  44254. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  44255. /**
  44256. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  44257. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  44258. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  44259. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  44260. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  44261. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  44262. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  44263. */
  44264. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  44265. /**
  44266. * Returns the string "AnimationGroup"
  44267. * @returns "AnimationGroup"
  44268. */
  44269. getClassName(): string;
  44270. /**
  44271. * Creates a detailed string about the object
  44272. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  44273. * @returns a string representing the object
  44274. */
  44275. toString(fullDetails?: boolean): string;
  44276. }
  44277. }
  44278. declare module BABYLON {
  44279. /**
  44280. * @hidden
  44281. **/
  44282. export class _TimeToken {
  44283. _startTimeQuery: Nullable<WebGLQuery>;
  44284. _endTimeQuery: Nullable<WebGLQuery>;
  44285. _timeElapsedQuery: Nullable<WebGLQuery>;
  44286. _timeElapsedQueryEnded: boolean;
  44287. }
  44288. }
  44289. declare module BABYLON {
  44290. /** @hidden */
  44291. export enum ExtensionName {
  44292. DepthClamping = "depth-clamping",
  44293. Depth24UnormStencil8 = "depth24unorm-stencil8",
  44294. Depth32FloatStencil8 = "depth32float-stencil8",
  44295. PipelineStatisticsQuery = "pipeline-statistics-query",
  44296. TextureCompressionBC = "texture-compression-bc",
  44297. TimestampQuery = "timestamp-query"
  44298. }
  44299. /** @hidden */
  44300. export enum AddressMode {
  44301. ClampToEdge = "clamp-to-edge",
  44302. Repeat = "repeat",
  44303. MirrorRepeat = "mirror-repeat"
  44304. }
  44305. /** @hidden */
  44306. export enum BindingType {
  44307. UniformBuffer = "uniform-buffer",
  44308. StorageBuffer = "storage-buffer",
  44309. ReadonlyStorageBuffer = "readonly-storage-buffer",
  44310. Sampler = "sampler",
  44311. ComparisonSampler = "comparison-sampler",
  44312. SampledTexture = "sampled-texture",
  44313. ReadonlyStorageTexture = "readonly-storage-texture",
  44314. WriteonlyStorageTexture = "writeonly-storage-texture"
  44315. }
  44316. /** @hidden */
  44317. export enum BlendFactor {
  44318. Zero = "zero",
  44319. One = "one",
  44320. SrcColor = "src-color",
  44321. OneMinusSrcColor = "one-minus-src-color",
  44322. SrcAlpha = "src-alpha",
  44323. OneMinusSrcAlpha = "one-minus-src-alpha",
  44324. DstColor = "dst-color",
  44325. OneMinusDstColor = "one-minus-dst-color",
  44326. DstAlpha = "dst-alpha",
  44327. OneMinusDstAlpha = "one-minus-dst-alpha",
  44328. SrcAlphaSaturated = "src-alpha-saturated",
  44329. BlendColor = "blend-color",
  44330. OneMinusBlendColor = "one-minus-blend-color"
  44331. }
  44332. /** @hidden */
  44333. export enum BlendOperation {
  44334. Add = "add",
  44335. Subtract = "subtract",
  44336. ReverseSubtract = "reverse-subtract",
  44337. Min = "min",
  44338. Max = "max"
  44339. }
  44340. /** @hidden */
  44341. export enum CompareFunction {
  44342. Never = "never",
  44343. Less = "less",
  44344. Equal = "equal",
  44345. LessEqual = "less-equal",
  44346. Greater = "greater",
  44347. NotEqual = "not-equal",
  44348. GreaterEqual = "greater-equal",
  44349. Always = "always"
  44350. }
  44351. /** @hidden */
  44352. export enum CullMode {
  44353. None = "none",
  44354. Front = "front",
  44355. Back = "back"
  44356. }
  44357. /** @hidden */
  44358. export enum FilterMode {
  44359. Nearest = "nearest",
  44360. Linear = "linear"
  44361. }
  44362. /** @hidden */
  44363. export enum FrontFace {
  44364. CCW = "ccw",
  44365. CW = "cw"
  44366. }
  44367. /** @hidden */
  44368. export enum IndexFormat {
  44369. Uint16 = "uint16",
  44370. Uint32 = "uint32"
  44371. }
  44372. /** @hidden */
  44373. export enum InputStepMode {
  44374. Vertex = "vertex",
  44375. Instance = "instance"
  44376. }
  44377. /** @hidden */
  44378. export enum LoadOp {
  44379. Load = "load"
  44380. }
  44381. /** @hidden */
  44382. export enum PrimitiveTopology {
  44383. PointList = "point-list",
  44384. LineList = "line-list",
  44385. LineStrip = "line-strip",
  44386. TriangleList = "triangle-list",
  44387. TriangleStrip = "triangle-strip"
  44388. }
  44389. /** @hidden */
  44390. export enum StencilOperation {
  44391. Keep = "keep",
  44392. Zero = "zero",
  44393. Replace = "replace",
  44394. Invert = "invert",
  44395. IncrementClamp = "increment-clamp",
  44396. DecrementClamp = "decrement-clamp",
  44397. IncrementWrap = "increment-wrap",
  44398. DecrementWrap = "decrement-wrap"
  44399. }
  44400. /** @hidden */
  44401. export enum StoreOp {
  44402. Store = "store",
  44403. Clear = "clear"
  44404. }
  44405. /** @hidden */
  44406. export enum TextureDimension {
  44407. E1d = "1d",
  44408. E2d = "2d",
  44409. E3d = "3d"
  44410. }
  44411. /** @hidden */
  44412. export enum TextureFormat {
  44413. R8Unorm = "r8unorm",
  44414. R8Snorm = "r8snorm",
  44415. R8Uint = "r8uint",
  44416. R8Sint = "r8sint",
  44417. R16Uint = "r16uint",
  44418. R16Sint = "r16sint",
  44419. R16Float = "r16float",
  44420. RG8Unorm = "rg8unorm",
  44421. RG8Snorm = "rg8snorm",
  44422. RG8Uint = "rg8uint",
  44423. RG8Sint = "rg8sint",
  44424. R32Uint = "r32uint",
  44425. R32Sint = "r32sint",
  44426. R32Float = "r32float",
  44427. RG16Uint = "rg16uint",
  44428. RG16Sint = "rg16sint",
  44429. RG16Float = "rg16float",
  44430. RGBA8Unorm = "rgba8unorm",
  44431. RGBA8UnormSRGB = "rgba8unorm-srgb",
  44432. RGBA8Snorm = "rgba8snorm",
  44433. RGBA8Uint = "rgba8uint",
  44434. RGBA8Sint = "rgba8sint",
  44435. BGRA8Unorm = "bgra8unorm",
  44436. BGRA8UnormSRGB = "bgra8unorm-srgb",
  44437. RGB9E5UFloat = "rgb9e5ufloat",
  44438. RGB10A2Unorm = "rgb10a2unorm",
  44439. RG11B10UFloat = "rg11b10ufloat",
  44440. RG32Uint = "rg32uint",
  44441. RG32Sint = "rg32sint",
  44442. RG32Float = "rg32float",
  44443. RGBA16Uint = "rgba16uint",
  44444. RGBA16Sint = "rgba16sint",
  44445. RGBA16Float = "rgba16float",
  44446. RGBA32Uint = "rgba32uint",
  44447. RGBA32Sint = "rgba32sint",
  44448. RGBA32Float = "rgba32float",
  44449. Stencil8 = "stencil8",
  44450. Depth16Unorm = "depth16unorm",
  44451. Depth24Plus = "depth24plus",
  44452. Depth24PlusStencil8 = "depth24plus-stencil8",
  44453. Depth32Float = "depth32float",
  44454. BC1RGBAUNorm = "bc1-rgba-unorm",
  44455. BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
  44456. BC2RGBAUnorm = "bc2-rgba-unorm",
  44457. BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
  44458. BC3RGBAUnorm = "bc3-rgba-unorm",
  44459. BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
  44460. BC4RUnorm = "bc4-r-unorm",
  44461. BC4RSnorm = "bc4-r-snorm",
  44462. BC5RGUnorm = "bc5-rg-unorm",
  44463. BC5RGSnorm = "bc5-rg-snorm",
  44464. BC6HRGBUFloat = "bc6h-rgb-ufloat",
  44465. BC6HRGBFloat = "bc6h-rgb-float",
  44466. BC7RGBAUnorm = "bc7-rgba-unorm",
  44467. BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
  44468. Depth24UnormStencil8 = "depth24unorm-stencil8",
  44469. Depth32FloatStencil8 = "depth32float-stencil8"
  44470. }
  44471. /** @hidden */
  44472. export enum TextureComponentType {
  44473. Float = "float",
  44474. Sint = "sint",
  44475. Uint = "uint",
  44476. DepthComparison = "depth-comparison"
  44477. }
  44478. /** @hidden */
  44479. export enum TextureViewDimension {
  44480. E1d = "1d",
  44481. E2d = "2d",
  44482. E2dArray = "2d-array",
  44483. Cube = "cube",
  44484. CubeArray = "cube-array",
  44485. E3d = "3d"
  44486. }
  44487. /** @hidden */
  44488. export enum VertexFormat {
  44489. Uchar2 = "uchar2",
  44490. Uchar4 = "uchar4",
  44491. Char2 = "char2",
  44492. Char4 = "char4",
  44493. Uchar2Norm = "uchar2norm",
  44494. Uchar4Norm = "uchar4norm",
  44495. Char2Norm = "char2norm",
  44496. Char4Norm = "char4norm",
  44497. Ushort2 = "ushort2",
  44498. Ushort4 = "ushort4",
  44499. Short2 = "short2",
  44500. Short4 = "short4",
  44501. Ushort2Norm = "ushort2norm",
  44502. Ushort4Norm = "ushort4norm",
  44503. Short2Norm = "short2norm",
  44504. Short4Norm = "short4norm",
  44505. Half2 = "half2",
  44506. Half4 = "half4",
  44507. Float = "float",
  44508. Float2 = "float2",
  44509. Float3 = "float3",
  44510. Float4 = "float4",
  44511. Uint = "uint",
  44512. Uint2 = "uint2",
  44513. Uint3 = "uint3",
  44514. Uint4 = "uint4",
  44515. Int = "int",
  44516. Int2 = "int2",
  44517. Int3 = "int3",
  44518. Int4 = "int4"
  44519. }
  44520. /** @hidden */
  44521. export enum TextureAspect {
  44522. All = "all",
  44523. StencilOnly = "stencil-only",
  44524. DepthOnly = "depth-only"
  44525. }
  44526. /** @hidden */
  44527. export enum CompilationMessageType {
  44528. Error = "error",
  44529. Warning = "warning",
  44530. Info = "info"
  44531. }
  44532. /** @hidden */
  44533. export enum QueryType {
  44534. Occlusion = "occlusion"
  44535. }
  44536. /** @hidden */
  44537. export enum BufferUsage {
  44538. MapRead = 1,
  44539. MapWrite = 2,
  44540. CopySrc = 4,
  44541. CopyDst = 8,
  44542. Index = 16,
  44543. Vertex = 32,
  44544. Uniform = 64,
  44545. Storage = 128,
  44546. Indirect = 256,
  44547. QueryResolve = 512
  44548. }
  44549. /** @hidden */
  44550. export enum ColorWrite {
  44551. Red = 1,
  44552. Green = 2,
  44553. Blue = 4,
  44554. Alpha = 8,
  44555. All = 15
  44556. }
  44557. /** @hidden */
  44558. export enum ShaderStage {
  44559. Vertex = 1,
  44560. Fragment = 2,
  44561. Compute = 4
  44562. }
  44563. /** @hidden */
  44564. export enum TextureUsage {
  44565. CopySrc = 1,
  44566. CopyDst = 2,
  44567. Sampled = 4,
  44568. Storage = 8,
  44569. OutputAttachment = 16
  44570. }
  44571. /** @hidden */
  44572. export enum MapMode {
  44573. Read = 1,
  44574. Write = 2
  44575. }
  44576. }
  44577. declare module BABYLON {
  44578. /** @hidden */
  44579. export interface WebGPUBindingInfo {
  44580. setIndex: number;
  44581. bindingIndex: number;
  44582. }
  44583. /** @hidden */
  44584. export interface WebGPUTextureSamplerBindingDescription {
  44585. sampler: WebGPUBindingInfo;
  44586. isTextureArray: boolean;
  44587. textures: Array<WebGPUBindingInfo>;
  44588. }
  44589. /** @hidden
  44590. * If the binding is a UBO, isSampler=isTexture=false
  44591. */
  44592. export interface WebGPUBindingDescription {
  44593. name: string;
  44594. usedInVertex: boolean;
  44595. usedInFragment: boolean;
  44596. isSampler: boolean;
  44597. isComparisonSampler?: boolean;
  44598. isTexture: boolean;
  44599. componentType?: GPUTextureComponentType;
  44600. textureDimension?: GPUTextureViewDimension;
  44601. }
  44602. /**
  44603. * @hidden
  44604. */
  44605. export class WebGPUShaderProcessingContext implements ShaderProcessingContext {
  44606. uboNextBindingIndex: number;
  44607. freeSetIndex: number;
  44608. freeBindingIndex: number;
  44609. availableVaryings: {
  44610. [key: string]: number;
  44611. };
  44612. availableAttributes: {
  44613. [key: string]: number;
  44614. };
  44615. availableUBOs: {
  44616. [key: string]: {
  44617. setIndex: number;
  44618. bindingIndex: number;
  44619. };
  44620. };
  44621. availableSamplers: {
  44622. [key: string]: WebGPUTextureSamplerBindingDescription;
  44623. };
  44624. leftOverUniforms: {
  44625. name: string;
  44626. type: string;
  44627. length: number;
  44628. }[];
  44629. orderedAttributes: string[];
  44630. orderedUBOsAndSamplers: WebGPUBindingDescription[][];
  44631. uniformBufferNames: string[];
  44632. attributeNamesFromEffect: string[];
  44633. attributeLocationsFromEffect: number[];
  44634. private _attributeNextLocation;
  44635. private _varyingNextLocation;
  44636. constructor();
  44637. getAttributeNextLocation(dataType: string, arrayLength?: number): number;
  44638. getVaryingNextLocation(dataType: string, arrayLength?: number): number;
  44639. getNextFreeUBOBinding(): {
  44640. setIndex: number;
  44641. bindingIndex: number;
  44642. };
  44643. private _getNextFreeBinding;
  44644. }
  44645. }
  44646. declare module BABYLON {
  44647. /** @hidden */
  44648. export interface IWebGPUPipelineContextSamplerCache {
  44649. samplerBinding: number;
  44650. firstTextureName: string;
  44651. }
  44652. /** @hidden */
  44653. export interface IWebGPUPipelineContextTextureCache {
  44654. textureBinding: number;
  44655. texture: InternalTexture;
  44656. }
  44657. /** @hidden */
  44658. export interface IWebGPUPipelineContextVertexInputsCache {
  44659. indexBuffer: Nullable<GPUBuffer>;
  44660. indexOffset: number;
  44661. vertexStartSlot: number;
  44662. vertexBuffers: GPUBuffer[];
  44663. vertexOffsets: number[];
  44664. }
  44665. /** @hidden */
  44666. export interface IWebGPURenderPipelineStageDescriptor {
  44667. vertexStage: GPUProgrammableStageDescriptor;
  44668. fragmentStage?: GPUProgrammableStageDescriptor;
  44669. }
  44670. /** @hidden */
  44671. export class WebGPUBindGroupCacheNode {
  44672. values: {
  44673. [id: number]: WebGPUBindGroupCacheNode;
  44674. };
  44675. bindGroups: GPUBindGroup[];
  44676. constructor();
  44677. }
  44678. /** @hidden */
  44679. export class WebGPUPipelineContext implements IPipelineContext {
  44680. engine: WebGPUEngine;
  44681. shaderProcessingContext: WebGPUShaderProcessingContext;
  44682. leftOverUniformsByName: {
  44683. [name: string]: string;
  44684. };
  44685. sources: {
  44686. vertex: string;
  44687. fragment: string;
  44688. rawVertex: string;
  44689. rawFragment: string;
  44690. };
  44691. stages: Nullable<IWebGPURenderPipelineStageDescriptor>;
  44692. samplers: {
  44693. [name: string]: Nullable<IWebGPUPipelineContextSamplerCache>;
  44694. };
  44695. textures: {
  44696. [name: string]: Nullable<IWebGPUPipelineContextTextureCache>;
  44697. };
  44698. bindGroupLayouts: GPUBindGroupLayout[];
  44699. bindGroupsCache: WebGPUBindGroupCacheNode;
  44700. /**
  44701. * Stores the uniform buffer
  44702. */
  44703. uniformBuffer: Nullable<UniformBuffer>;
  44704. onCompiled?: () => void;
  44705. get isAsync(): boolean;
  44706. get isReady(): boolean;
  44707. /** @hidden */
  44708. _name: string;
  44709. constructor(shaderProcessingContext: WebGPUShaderProcessingContext, engine: WebGPUEngine);
  44710. _handlesSpectorRebuildCallback(onCompiled: (program: any) => void): void;
  44711. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  44712. [key: string]: number;
  44713. }, uniformsNames: string[], uniforms: {
  44714. [key: string]: Nullable<WebGLUniformLocation>;
  44715. }, samplerList: string[], samplers: {
  44716. [key: string]: number;
  44717. }, attributesNames: string[], attributes: number[]): void;
  44718. /** @hidden */
  44719. /**
  44720. * Build the uniform buffer used in the material.
  44721. */
  44722. buildUniformLayout(): void;
  44723. /**
  44724. * Release all associated resources.
  44725. **/
  44726. dispose(): void;
  44727. /**
  44728. * Sets an integer value on a uniform variable.
  44729. * @param uniformName Name of the variable.
  44730. * @param value Value to be set.
  44731. */
  44732. setInt(uniformName: string, value: number): void;
  44733. /**
  44734. * Sets an int2 value on a uniform variable.
  44735. * @param uniformName Name of the variable.
  44736. * @param x First int in int2.
  44737. * @param y Second int in int2.
  44738. */
  44739. setInt2(uniformName: string, x: number, y: number): void;
  44740. /**
  44741. * Sets an int3 value on a uniform variable.
  44742. * @param uniformName Name of the variable.
  44743. * @param x First int in int3.
  44744. * @param y Second int in int3.
  44745. * @param z Third int in int3.
  44746. */
  44747. setInt3(uniformName: string, x: number, y: number, z: number): void;
  44748. /**
  44749. * Sets an int4 value on a uniform variable.
  44750. * @param uniformName Name of the variable.
  44751. * @param x First int in int4.
  44752. * @param y Second int in int4.
  44753. * @param z Third int in int4.
  44754. * @param w Fourth int in int4.
  44755. */
  44756. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44757. /**
  44758. * Sets an int array on a uniform variable.
  44759. * @param uniformName Name of the variable.
  44760. * @param array array to be set.
  44761. */
  44762. setIntArray(uniformName: string, array: Int32Array): void;
  44763. /**
  44764. * 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)
  44765. * @param uniformName Name of the variable.
  44766. * @param array array to be set.
  44767. */
  44768. setIntArray2(uniformName: string, array: Int32Array): void;
  44769. /**
  44770. * 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)
  44771. * @param uniformName Name of the variable.
  44772. * @param array array to be set.
  44773. */
  44774. setIntArray3(uniformName: string, array: Int32Array): void;
  44775. /**
  44776. * 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)
  44777. * @param uniformName Name of the variable.
  44778. * @param array array to be set.
  44779. */
  44780. setIntArray4(uniformName: string, array: Int32Array): void;
  44781. /**
  44782. * Sets an array on a uniform variable.
  44783. * @param uniformName Name of the variable.
  44784. * @param array array to be set.
  44785. */
  44786. setArray(uniformName: string, array: number[]): void;
  44787. /**
  44788. * 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)
  44789. * @param uniformName Name of the variable.
  44790. * @param array array to be set.
  44791. */
  44792. setArray2(uniformName: string, array: number[]): void;
  44793. /**
  44794. * 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)
  44795. * @param uniformName Name of the variable.
  44796. * @param array array to be set.
  44797. * @returns this effect.
  44798. */
  44799. setArray3(uniformName: string, array: number[]): void;
  44800. /**
  44801. * 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)
  44802. * @param uniformName Name of the variable.
  44803. * @param array array to be set.
  44804. */
  44805. setArray4(uniformName: string, array: number[]): void;
  44806. /**
  44807. * Sets matrices on a uniform variable.
  44808. * @param uniformName Name of the variable.
  44809. * @param matrices matrices to be set.
  44810. */
  44811. setMatrices(uniformName: string, matrices: Float32Array): void;
  44812. /**
  44813. * Sets matrix on a uniform variable.
  44814. * @param uniformName Name of the variable.
  44815. * @param matrix matrix to be set.
  44816. */
  44817. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  44818. /**
  44819. * 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)
  44820. * @param uniformName Name of the variable.
  44821. * @param matrix matrix to be set.
  44822. */
  44823. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  44824. /**
  44825. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  44826. * @param uniformName Name of the variable.
  44827. * @param matrix matrix to be set.
  44828. */
  44829. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  44830. /**
  44831. * Sets a float on a uniform variable.
  44832. * @param uniformName Name of the variable.
  44833. * @param value value to be set.
  44834. * @returns this effect.
  44835. */
  44836. setFloat(uniformName: string, value: number): void;
  44837. /**
  44838. * Sets a Vector2 on a uniform variable.
  44839. * @param uniformName Name of the variable.
  44840. * @param vector2 vector2 to be set.
  44841. */
  44842. setVector2(uniformName: string, vector2: IVector2Like): void;
  44843. /**
  44844. * Sets a float2 on a uniform variable.
  44845. * @param uniformName Name of the variable.
  44846. * @param x First float in float2.
  44847. * @param y Second float in float2.
  44848. */
  44849. setFloat2(uniformName: string, x: number, y: number): void;
  44850. /**
  44851. * Sets a Vector3 on a uniform variable.
  44852. * @param uniformName Name of the variable.
  44853. * @param vector3 Value to be set.
  44854. */
  44855. setVector3(uniformName: string, vector3: IVector3Like): void;
  44856. /**
  44857. * Sets a float3 on a uniform variable.
  44858. * @param uniformName Name of the variable.
  44859. * @param x First float in float3.
  44860. * @param y Second float in float3.
  44861. * @param z Third float in float3.
  44862. */
  44863. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  44864. /**
  44865. * Sets a Vector4 on a uniform variable.
  44866. * @param uniformName Name of the variable.
  44867. * @param vector4 Value to be set.
  44868. */
  44869. setVector4(uniformName: string, vector4: IVector4Like): void;
  44870. /**
  44871. * Sets a float4 on a uniform variable.
  44872. * @param uniformName Name of the variable.
  44873. * @param x First float in float4.
  44874. * @param y Second float in float4.
  44875. * @param z Third float in float4.
  44876. * @param w Fourth float in float4.
  44877. * @returns this effect.
  44878. */
  44879. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44880. /**
  44881. * Sets a Color3 on a uniform variable.
  44882. * @param uniformName Name of the variable.
  44883. * @param color3 Value to be set.
  44884. */
  44885. setColor3(uniformName: string, color3: IColor3Like): void;
  44886. /**
  44887. * Sets a Color4 on a uniform variable.
  44888. * @param uniformName Name of the variable.
  44889. * @param color3 Value to be set.
  44890. * @param alpha Alpha value to be set.
  44891. */
  44892. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  44893. /**
  44894. * Sets a Color4 on a uniform variable
  44895. * @param uniformName defines the name of the variable
  44896. * @param color4 defines the value to be set
  44897. */
  44898. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  44899. _getVertexShaderCode(): string | null;
  44900. _getFragmentShaderCode(): string | null;
  44901. }
  44902. }
  44903. declare module BABYLON {
  44904. /** @hidden */
  44905. export class WebGPUDataBuffer extends DataBuffer {
  44906. private _buffer;
  44907. constructor(resource: GPUBuffer);
  44908. get underlyingResource(): any;
  44909. }
  44910. }
  44911. declare module BABYLON {
  44912. /**
  44913. * Class used to inline functions in shader code
  44914. */
  44915. export class ShaderCodeInliner {
  44916. private static readonly _RegexpFindFunctionNameAndType;
  44917. private _sourceCode;
  44918. private _functionDescr;
  44919. private _numMaxIterations;
  44920. /** Gets or sets the token used to mark the functions to inline */
  44921. inlineToken: string;
  44922. /** Gets or sets the debug mode */
  44923. debug: boolean;
  44924. /** Gets the code after the inlining process */
  44925. get code(): string;
  44926. /**
  44927. * Initializes the inliner
  44928. * @param sourceCode shader code source to inline
  44929. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  44930. */
  44931. constructor(sourceCode: string, numMaxIterations?: number);
  44932. /**
  44933. * Start the processing of the shader code
  44934. */
  44935. processCode(): void;
  44936. private _collectFunctions;
  44937. private _processInlining;
  44938. private _extractBetweenMarkers;
  44939. private _skipWhitespaces;
  44940. private _isIdentifierChar;
  44941. private _removeComments;
  44942. private _replaceFunctionCallsByCode;
  44943. private _findBackward;
  44944. private _escapeRegExp;
  44945. private _replaceNames;
  44946. }
  44947. }
  44948. declare module BABYLON {
  44949. /** @hidden */
  44950. export class WebGPUShaderProcessor implements IShaderProcessor {
  44951. protected _missingVaryings: Array<string>;
  44952. protected _textureArrayProcessing: Array<string>;
  44953. protected _preProcessors: {
  44954. [key: string]: string;
  44955. };
  44956. private _getArraySize;
  44957. initializeShaders(processingContext: Nullable<ShaderProcessingContext>): void;
  44958. varyingProcessor(varying: string, isFragment: boolean, preProcessors: {
  44959. [key: string]: string;
  44960. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44961. attributeProcessor(attribute: string, preProcessors: {
  44962. [key: string]: string;
  44963. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44964. uniformProcessor(uniform: string, isFragment: boolean, preProcessors: {
  44965. [key: string]: string;
  44966. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44967. uniformBufferProcessor(uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44968. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44969. private _applyTextureArrayProcessing;
  44970. finalizeShaders(vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>): {
  44971. vertexCode: string;
  44972. fragmentCode: string;
  44973. };
  44974. }
  44975. }
  44976. declare module BABYLON {
  44977. /** @hidden */
  44978. export class WebGPUBufferManager {
  44979. private _device;
  44980. private _deferredReleaseBuffers;
  44981. private static _IsGPUBuffer;
  44982. constructor(device: GPUDevice);
  44983. createRawBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags, mappedAtCreation?: boolean): GPUBuffer;
  44984. createBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags): DataBuffer;
  44985. setSubData(dataBuffer: WebGPUDataBuffer, dstByteOffset: number, src: ArrayBufferView, srcByteOffset?: number, byteLength?: number): void;
  44986. private _FromHalfFloat;
  44987. private _GetHalfFloatAsFloatRGBAArrayBuffer;
  44988. readDataFromBuffer(gpuBuffer: GPUBuffer, size: number, width: number, height: number, bytesPerRow: number, bytesPerRowAligned: number, floatFormat?: number, offset?: number, buffer?: Nullable<ArrayBufferView>, destroyBuffer?: boolean): Promise<ArrayBufferView>;
  44989. releaseBuffer(buffer: DataBuffer | GPUBuffer): boolean;
  44990. destroyDeferredBuffers(): void;
  44991. }
  44992. }
  44993. declare module BABYLON {
  44994. /** @hidden */
  44995. export class WebGPUHardwareTexture implements HardwareTextureWrapper {
  44996. private _webgpuTexture;
  44997. private _webgpuMSAATexture;
  44998. get underlyingResource(): Nullable<GPUTexture>;
  44999. get msaaTexture(): Nullable<GPUTexture>;
  45000. set msaaTexture(texture: Nullable<GPUTexture>);
  45001. view: Nullable<GPUTextureView>;
  45002. format: GPUTextureFormat;
  45003. textureUsages: number;
  45004. constructor(existingTexture?: Nullable<GPUTexture>);
  45005. set(hardwareTexture: GPUTexture): void;
  45006. setMSAATexture(hardwareTexture: GPUTexture): void;
  45007. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  45008. createView(descriptor?: GPUTextureViewDescriptor): void;
  45009. reset(): void;
  45010. release(): void;
  45011. }
  45012. }
  45013. declare module BABYLON {
  45014. /** @hidden */
  45015. export class WebGPUTextureHelper {
  45016. private _device;
  45017. private _glslang;
  45018. private _bufferManager;
  45019. private _mipmapSampler;
  45020. private _invertYPreMultiplyAlphaSampler;
  45021. private _pipelines;
  45022. private _compiledShaders;
  45023. private _deferredReleaseTextures;
  45024. private _commandEncoderForCreation;
  45025. static ComputeNumMipmapLevels(width: number, height: number): number;
  45026. constructor(device: GPUDevice, glslang: any, bufferManager: WebGPUBufferManager);
  45027. private _getPipeline;
  45028. private static _GetTextureTypeFromFormat;
  45029. private static _GetBlockInformationFromFormat;
  45030. private static _IsHardwareTexture;
  45031. private static _IsInternalTexture;
  45032. static GetCompareFunction(compareFunction: Nullable<number>): GPUCompareFunction;
  45033. static IsImageBitmap(imageBitmap: ImageBitmap | {
  45034. width: number;
  45035. height: number;
  45036. }): imageBitmap is ImageBitmap;
  45037. static IsImageBitmapArray(imageBitmap: ImageBitmap[] | {
  45038. width: number;
  45039. height: number;
  45040. }): imageBitmap is ImageBitmap[];
  45041. setCommandEncoder(encoder: GPUCommandEncoder): void;
  45042. static IsCompressedFormat(format: GPUTextureFormat): boolean;
  45043. static GetWebGPUTextureFormat(type: number, format: number): GPUTextureFormat;
  45044. invertYPreMultiplyAlpha(gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  45045. clear(format: GPUTextureFormat, color: IColor4Like, passEncoder: GPURenderPassEncoder): void;
  45046. createTexture(imageBitmap: ImageBitmap | {
  45047. width: number;
  45048. height: number;
  45049. layers: number;
  45050. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, is3D?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  45051. createCubeTexture(imageBitmaps: ImageBitmap[] | {
  45052. width: number;
  45053. height: number;
  45054. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  45055. generateCubeMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, commandEncoder?: GPUCommandEncoder): void;
  45056. generateMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  45057. createGPUTextureForInternalTexture(texture: InternalTexture, width?: number, height?: number, depth?: number): WebGPUHardwareTexture;
  45058. createMSAATexture(texture: InternalTexture, samples: number): void;
  45059. updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  45060. 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;
  45061. readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>): Promise<ArrayBufferView>;
  45062. releaseTexture(texture: InternalTexture | GPUTexture): void;
  45063. destroyDeferredTextures(): void;
  45064. }
  45065. }
  45066. declare module BABYLON {
  45067. /** @hidden */
  45068. export class WebGPURenderPassWrapper {
  45069. renderPassDescriptor: Nullable<GPURenderPassDescriptor>;
  45070. renderPass: Nullable<GPURenderPassEncoder>;
  45071. colorAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  45072. depthAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  45073. colorAttachmentGPUTextures: WebGPUHardwareTexture[];
  45074. depthTextureFormat: GPUTextureFormat | undefined;
  45075. constructor();
  45076. reset(fullReset?: boolean): void;
  45077. }
  45078. }
  45079. declare module BABYLON {
  45080. /** @hidden */
  45081. export class WebGPUCacheSampler {
  45082. private _samplers;
  45083. private _device;
  45084. disabled: boolean;
  45085. constructor(device: GPUDevice);
  45086. private static _GetSamplerHashCode;
  45087. private static _GetSamplerFilterDescriptor;
  45088. private static _GetWrappingMode;
  45089. private static _GetSamplerWrappingDescriptor;
  45090. private static _GetSamplerDescriptor;
  45091. getSampler(internalTexture: InternalTexture, bypassCache?: boolean): GPUSampler;
  45092. }
  45093. }
  45094. declare module BABYLON {
  45095. /** @hidden */
  45096. export class WebGPUShaderManager {
  45097. private _shaders;
  45098. private _device;
  45099. constructor(device: GPUDevice);
  45100. getCompiledShaders(name: string): IWebGPURenderPipelineStageDescriptor;
  45101. }
  45102. }
  45103. declare module BABYLON {
  45104. /** @hidden */
  45105. export abstract class WebGPUCacheRenderPipeline {
  45106. static NumCacheHitWithoutHash: number;
  45107. static NumCacheHitWithHash: number;
  45108. static NumCacheMiss: number;
  45109. static NumPipelineCreationLastFrame: number;
  45110. disabled: boolean;
  45111. private static _NumPipelineCreationCurrentFrame;
  45112. protected _states: number[];
  45113. protected _stateDirtyLowestIndex: number;
  45114. lastStateDirtyLowestIndex: number;
  45115. private _device;
  45116. private _isDirty;
  45117. private _emptyVertexBuffer;
  45118. private _parameter;
  45119. private _shaderId;
  45120. private _alphaToCoverageEnabled;
  45121. private _frontFace;
  45122. private _cullEnabled;
  45123. private _cullFace;
  45124. private _clampDepth;
  45125. private _rasterizationState;
  45126. private _depthBias;
  45127. private _depthBiasClamp;
  45128. private _depthBiasSlopeScale;
  45129. private _colorFormat;
  45130. private _webgpuColorFormat;
  45131. private _mrtAttachments1;
  45132. private _mrtAttachments2;
  45133. private _mrtFormats;
  45134. private _alphaBlendEnabled;
  45135. private _alphaBlendFuncParams;
  45136. private _alphaBlendEqParams;
  45137. private _writeMask;
  45138. private _colorStates;
  45139. private _depthStencilFormat;
  45140. private _webgpuDepthStencilFormat;
  45141. private _depthTestEnabled;
  45142. private _depthWriteEnabled;
  45143. private _depthCompare;
  45144. private _stencilEnabled;
  45145. private _stencilFrontCompare;
  45146. private _stencilFrontDepthFailOp;
  45147. private _stencilFrontPassOp;
  45148. private _stencilFrontFailOp;
  45149. private _stencilReadMask;
  45150. private _stencilWriteMask;
  45151. private _depthStencilState;
  45152. private _vertexBuffers;
  45153. private _overrideVertexBuffers;
  45154. private _indexBuffer;
  45155. constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer);
  45156. reset(): void;
  45157. protected abstract _getRenderPipeline(param: {
  45158. token: any;
  45159. pipeline: Nullable<GPURenderPipeline>;
  45160. }): void;
  45161. protected abstract _setRenderPipeline(param: {
  45162. token: any;
  45163. pipeline: Nullable<GPURenderPipeline>;
  45164. }): void;
  45165. getRenderPipeline(fillMode: number, effect: Effect, sampleCount: number): GPURenderPipeline;
  45166. endFrame(): void;
  45167. setAlphaToCoverage(enabled: boolean): void;
  45168. setFrontFace(frontFace: number): void;
  45169. setCullEnabled(enabled: boolean): void;
  45170. setCullFace(cullFace: number): void;
  45171. setClampDepth(clampDepth: boolean): void;
  45172. resetDepthCullingState(): void;
  45173. setDepthCullingState(cullEnabled: boolean, frontFace: number, cullFace: number, zOffset: number, depthTestEnabled: boolean, depthWriteEnabled: boolean, depthCompare: Nullable<number>): void;
  45174. setDepthBiasSlopeScale(depthBiasSlopeScale: number): void;
  45175. setColorFormat(format: GPUTextureFormat): void;
  45176. setMRTAttachments(attachments: number[], textureArray: InternalTexture[]): void;
  45177. setAlphaBlendEnabled(enabled: boolean): void;
  45178. setAlphaBlendFactors(factors: Array<Nullable<number>>, operations: Array<Nullable<number>>): void;
  45179. setWriteMask(mask: number): void;
  45180. setDepthStencilFormat(format: GPUTextureFormat | undefined): void;
  45181. setDepthTestEnabled(enabled: boolean): void;
  45182. setDepthWriteEnabled(enabled: boolean): void;
  45183. setDepthCompare(func: Nullable<number>): void;
  45184. setStencilEnabled(enabled: boolean): void;
  45185. setStencilCompare(func: Nullable<number>): void;
  45186. setStencilDepthFailOp(op: Nullable<number>): void;
  45187. setStencilPassOp(op: Nullable<number>): void;
  45188. setStencilFailOp(op: Nullable<number>): void;
  45189. setStencilReadMask(mask: number): void;
  45190. setStencilWriteMask(mask: number): void;
  45191. resetStencilState(): void;
  45192. setStencilState(stencilEnabled: boolean, compare: Nullable<number>, depthFailOp: Nullable<number>, passOp: Nullable<number>, failOp: Nullable<number>, readMask: number, writeMask: number): void;
  45193. setBuffers(vertexBuffers: Nullable<{
  45194. [key: string]: Nullable<VertexBuffer>;
  45195. }>, indexBuffer: Nullable<DataBuffer>, overrideVertexBuffers: Nullable<{
  45196. [key: string]: Nullable<VertexBuffer>;
  45197. }>): void;
  45198. private static _GetTopology;
  45199. private static _GetAphaBlendOperation;
  45200. private static _GetAphaBlendFactor;
  45201. private static _GetCompareFunction;
  45202. private static _GetStencilOpFunction;
  45203. private static _GetVertexInputDescriptorFormat;
  45204. private _getAphaBlendState;
  45205. private _getColorBlendState;
  45206. private _setShaderStage;
  45207. private _setRasterizationState;
  45208. private _setColorStates;
  45209. private _setDepthStencilState;
  45210. private _setVertexState;
  45211. private _createPipelineLayout;
  45212. private _getVertexInputDescriptor;
  45213. private _createRenderPipeline;
  45214. }
  45215. }
  45216. declare module BABYLON {
  45217. /** @hidden */
  45218. class NodeState {
  45219. values: {
  45220. [name: number]: NodeState;
  45221. };
  45222. pipeline: GPURenderPipeline;
  45223. constructor();
  45224. count(): [number, number];
  45225. }
  45226. /** @hidden */
  45227. export class WebGPUCacheRenderPipelineTree extends WebGPUCacheRenderPipeline {
  45228. private static _Cache;
  45229. private _nodeStack;
  45230. static GetNodeCounts(): {
  45231. nodeCount: number;
  45232. pipelineCount: number;
  45233. };
  45234. constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer);
  45235. protected _getRenderPipeline(param: {
  45236. token: any;
  45237. pipeline: Nullable<GPURenderPipeline>;
  45238. }): void;
  45239. protected _setRenderPipeline(param: {
  45240. token: NodeState;
  45241. pipeline: Nullable<GPURenderPipeline>;
  45242. }): void;
  45243. }
  45244. }
  45245. declare module BABYLON {
  45246. /**
  45247. * @hidden
  45248. **/
  45249. export class WebGPUStencilState extends StencilState {
  45250. private _cache;
  45251. constructor(cache: WebGPUCacheRenderPipeline);
  45252. get stencilFunc(): number;
  45253. set stencilFunc(value: number);
  45254. get stencilFuncRef(): number;
  45255. set stencilFuncRef(value: number);
  45256. get stencilFuncMask(): number;
  45257. set stencilFuncMask(value: number);
  45258. get stencilOpStencilFail(): number;
  45259. set stencilOpStencilFail(value: number);
  45260. get stencilOpDepthFail(): number;
  45261. set stencilOpDepthFail(value: number);
  45262. get stencilOpStencilDepthPass(): number;
  45263. set stencilOpStencilDepthPass(value: number);
  45264. get stencilMask(): number;
  45265. set stencilMask(value: number);
  45266. get stencilTest(): boolean;
  45267. set stencilTest(value: boolean);
  45268. reset(): void;
  45269. apply(gl: WebGLRenderingContext): void;
  45270. }
  45271. }
  45272. declare module BABYLON {
  45273. /**
  45274. * @hidden
  45275. **/
  45276. export class WebGPUDepthCullingState extends DepthCullingState {
  45277. private _cache;
  45278. /**
  45279. * Initializes the state.
  45280. */
  45281. constructor(cache: WebGPUCacheRenderPipeline);
  45282. get zOffset(): number;
  45283. set zOffset(value: number);
  45284. get cullFace(): Nullable<number>;
  45285. set cullFace(value: Nullable<number>);
  45286. get cull(): Nullable<boolean>;
  45287. set cull(value: Nullable<boolean>);
  45288. get depthFunc(): Nullable<number>;
  45289. set depthFunc(value: Nullable<number>);
  45290. get depthMask(): boolean;
  45291. set depthMask(value: boolean);
  45292. get depthTest(): boolean;
  45293. set depthTest(value: boolean);
  45294. get frontFace(): Nullable<number>;
  45295. set frontFace(value: Nullable<number>);
  45296. reset(): void;
  45297. apply(gl: WebGLRenderingContext): void;
  45298. }
  45299. }
  45300. declare module BABYLON {
  45301. /** @hidden */
  45302. export var clearQuadVertexShader: {
  45303. name: string;
  45304. shader: string;
  45305. };
  45306. }
  45307. declare module BABYLON {
  45308. /** @hidden */
  45309. export var clearQuadPixelShader: {
  45310. name: string;
  45311. shader: string;
  45312. };
  45313. }
  45314. declare module BABYLON {
  45315. /**
  45316. * Options to load the associated Glslang library
  45317. */
  45318. export interface GlslangOptions {
  45319. /**
  45320. * Defines an existing instance of Glslang (useful in modules who do not access the global instance).
  45321. */
  45322. glslang?: any;
  45323. /**
  45324. * Defines the URL of the glslang JS File.
  45325. */
  45326. jsPath?: string;
  45327. /**
  45328. * Defines the URL of the glslang WASM File.
  45329. */
  45330. wasmPath?: string;
  45331. }
  45332. /**
  45333. * Options to create the WebGPU engine
  45334. */
  45335. export interface WebGPUEngineOptions extends GPURequestAdapterOptions {
  45336. /**
  45337. * If delta time between frames should be constant
  45338. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45339. */
  45340. deterministicLockstep?: boolean;
  45341. /**
  45342. * Maximum about of steps between frames (Default: 4)
  45343. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45344. */
  45345. lockstepMaxSteps?: number;
  45346. /**
  45347. * Defines the seconds between each deterministic lock step
  45348. */
  45349. timeStep?: number;
  45350. /**
  45351. * Defines that engine should ignore modifying touch action attribute and style
  45352. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  45353. */
  45354. doNotHandleTouchAction?: boolean;
  45355. /**
  45356. * Defines if webaudio should be initialized as well
  45357. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  45358. */
  45359. audioEngine?: boolean;
  45360. /**
  45361. * Defines the category of adapter to use.
  45362. * Is it the discrete or integrated device.
  45363. */
  45364. powerPreference?: GPUPowerPreference;
  45365. /**
  45366. * Defines the device descriptor used to create a device.
  45367. */
  45368. deviceDescriptor?: GPUDeviceDescriptor;
  45369. /**
  45370. * Defines the requested Swap Chain Format.
  45371. */
  45372. swapChainFormat?: GPUTextureFormat;
  45373. /**
  45374. * Defines whether MSAA is enabled on the canvas.
  45375. */
  45376. antialiasing?: boolean;
  45377. /**
  45378. * Defines whether the stencil buffer should be enabled.
  45379. */
  45380. stencil?: boolean;
  45381. /**
  45382. * Defines whether we should generate debug markers in the gpu command lists (can be seen with PIX for eg)
  45383. */
  45384. enableGPUDebugMarkers?: boolean;
  45385. /**
  45386. * Options to load the associated Glslang library
  45387. */
  45388. glslangOptions?: GlslangOptions;
  45389. }
  45390. /**
  45391. * The web GPU engine class provides support for WebGPU version of babylon.js.
  45392. */
  45393. export class WebGPUEngine extends Engine {
  45394. private static readonly _glslangDefaultOptions;
  45395. private readonly _uploadEncoderDescriptor;
  45396. private readonly _renderEncoderDescriptor;
  45397. private readonly _renderTargetEncoderDescriptor;
  45398. private readonly _clearDepthValue;
  45399. private readonly _clearReverseDepthValue;
  45400. private readonly _clearStencilValue;
  45401. private readonly _defaultSampleCount;
  45402. private _canvas;
  45403. private _options;
  45404. private _glslang;
  45405. private _adapter;
  45406. private _adapterSupportedExtensions;
  45407. private _device;
  45408. private _deviceEnabledExtensions;
  45409. private _context;
  45410. private _swapChain;
  45411. private _swapChainTexture;
  45412. private _mainPassSampleCount;
  45413. private _textureHelper;
  45414. private _bufferManager;
  45415. private _shaderManager;
  45416. private _cacheSampler;
  45417. private _cacheRenderPipeline;
  45418. private _emptyVertexBuffer;
  45419. private _lastCachedWrapU;
  45420. private _lastCachedWrapV;
  45421. private _lastCachedWrapR;
  45422. private _mrtAttachments;
  45423. private _counters;
  45424. private _mainTexture;
  45425. private _depthTexture;
  45426. private _mainTextureExtends;
  45427. private _depthTextureFormat;
  45428. private _colorFormat;
  45429. private _uploadEncoder;
  45430. private _renderEncoder;
  45431. private _renderTargetEncoder;
  45432. private _commandBuffers;
  45433. private _currentRenderPass;
  45434. private _mainRenderPassWrapper;
  45435. private _rttRenderPassWrapper;
  45436. private _pendingDebugCommands;
  45437. private _currentVertexBuffers;
  45438. private _currentOverrideVertexBuffers;
  45439. private _currentIndexBuffer;
  45440. private __colorWrite;
  45441. private _uniformsBuffers;
  45442. private _forceEnableEffect;
  45443. /** @hidden */
  45444. dbgShowShaderCode: boolean;
  45445. /** @hidden */
  45446. dbgSanityChecks: boolean;
  45447. /** @hidden */
  45448. dbgGenerateLogs: boolean;
  45449. /** @hidden */
  45450. dbgVerboseLogsForFirstFrames: boolean;
  45451. /** @hidden */
  45452. dbgVerboseLogsNumFrames: number;
  45453. /** @hidden */
  45454. dbgShowWarningsNotImplemented: boolean;
  45455. /**
  45456. * Sets this to true to disable the cache for the samplers. You should do it only for testing purpose!
  45457. */
  45458. get disableCacheSamplers(): boolean;
  45459. set disableCacheSamplers(disable: boolean);
  45460. /**
  45461. * Sets this to true to disable the cache for the render pipelines. You should do it only for testing purpose!
  45462. */
  45463. get disableCacheRenderPipelines(): boolean;
  45464. set disableCacheRenderPipelines(disable: boolean);
  45465. /**
  45466. * Gets a boolean indicating if the engine can be instantiated (ie. if a WebGPU context can be found)
  45467. * @returns true if the engine can be created
  45468. */
  45469. static get IsSupported(): boolean;
  45470. /**
  45471. * Gets a boolean indicating that the engine supports uniform buffers
  45472. */
  45473. get supportsUniformBuffers(): boolean;
  45474. /** Gets the supported extensions by the WebGPU adapter */
  45475. get supportedExtensions(): Immutable<GPUExtensionName[]>;
  45476. /** Gets the currently enabled extensions on the WebGPU device */
  45477. get enabledExtensions(): Immutable<GPUExtensionName[]>;
  45478. /**
  45479. * Returns the name of the engine
  45480. */
  45481. get name(): string;
  45482. /**
  45483. * Returns a string describing the current engine
  45484. */
  45485. get description(): string;
  45486. /**
  45487. * Returns the version of the engine
  45488. */
  45489. get version(): number;
  45490. /**
  45491. * Create a new instance of the gpu engine asynchronously
  45492. * @param canvas Defines the canvas to use to display the result
  45493. * @param options Defines the options passed to the engine to create the GPU context dependencies
  45494. * @returns a promise that resolves with the created engine
  45495. */
  45496. static CreateAsync(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions): Promise<WebGPUEngine>;
  45497. /**
  45498. * Create a new instance of the gpu engine.
  45499. * @param canvas Defines the canvas to use to display the result
  45500. * @param options Defines the options passed to the engine to create the GPU context dependencies
  45501. */
  45502. constructor(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions);
  45503. /**
  45504. * Initializes the WebGPU context and dependencies.
  45505. * @param glslangOptions Defines the GLSLang compiler options if necessary
  45506. * @returns a promise notifying the readiness of the engine.
  45507. */
  45508. initAsync(glslangOptions?: GlslangOptions): Promise<void>;
  45509. private _initGlslang;
  45510. private _initializeLimits;
  45511. private _initializeContextAndSwapChain;
  45512. private _initializeMainAttachments;
  45513. /**
  45514. * Force a specific size of the canvas
  45515. * @param width defines the new canvas' width
  45516. * @param height defines the new canvas' height
  45517. * @param forceSetSize true to force setting the sizes of the underlying canvas
  45518. * @returns true if the size was changed
  45519. */
  45520. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  45521. /**
  45522. * Gets a shader processor implementation fitting with the current engine type.
  45523. * @returns The shader processor implementation.
  45524. */
  45525. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  45526. /** @hidden */
  45527. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  45528. /**
  45529. * Force the entire cache to be cleared
  45530. * You should not have to use this function unless your engine needs to share the WebGPU context with another engine
  45531. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45532. */
  45533. wipeCaches(bruteForce?: boolean): void;
  45534. /**
  45535. * Enable or disable color writing
  45536. * @param enable defines the state to set
  45537. */
  45538. setColorWrite(enable: boolean): void;
  45539. /**
  45540. * Gets a boolean indicating if color writing is enabled
  45541. * @returns the current color writing state
  45542. */
  45543. getColorWrite(): boolean;
  45544. private _viewportsCurrent;
  45545. private _resetCurrentViewport;
  45546. private _applyViewport;
  45547. /** @hidden */
  45548. _viewport(x: number, y: number, width: number, height: number): void;
  45549. private _scissorsCurrent;
  45550. protected _scissorCached: {
  45551. x: number;
  45552. y: number;
  45553. z: number;
  45554. w: number;
  45555. };
  45556. private _resetCurrentScissor;
  45557. private _applyScissor;
  45558. private _scissorIsActive;
  45559. enableScissor(x: number, y: number, width: number, height: number): void;
  45560. disableScissor(): void;
  45561. /**
  45562. * Clear the current render buffer or the current render target (if any is set up)
  45563. * @param color defines the color to use
  45564. * @param backBuffer defines if the back buffer must be cleared
  45565. * @param depth defines if the depth buffer must be cleared
  45566. * @param stencil defines if the stencil buffer must be cleared
  45567. */
  45568. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45569. /**
  45570. * Clears a list of attachments
  45571. * @param attachments list of the attachments
  45572. * @param colorMain clear color for the main attachment (the first one)
  45573. * @param colorOthers clear color for the other attachments
  45574. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  45575. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  45576. */
  45577. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  45578. /**
  45579. * Creates a vertex buffer
  45580. * @param data the data for the vertex buffer
  45581. * @returns the new buffer
  45582. */
  45583. createVertexBuffer(data: DataArray): DataBuffer;
  45584. /**
  45585. * Creates a vertex buffer
  45586. * @param data the data for the dynamic vertex buffer
  45587. * @returns the new buffer
  45588. */
  45589. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  45590. /**
  45591. * Updates a vertex buffer.
  45592. * @param vertexBuffer the vertex buffer to update
  45593. * @param data the data used to update the vertex buffer
  45594. * @param byteOffset the byte offset of the data
  45595. * @param byteLength the byte length of the data
  45596. */
  45597. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  45598. /**
  45599. * Creates a new index buffer
  45600. * @param indices defines the content of the index buffer
  45601. * @param updatable defines if the index buffer must be updatable - not used in WebGPU
  45602. * @returns a new buffer
  45603. */
  45604. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  45605. /**
  45606. * Update an index buffer
  45607. * @param indexBuffer defines the target index buffer
  45608. * @param indices defines the data to update
  45609. * @param offset defines the offset in the target index buffer where update should start
  45610. */
  45611. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  45612. /** @hidden */
  45613. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  45614. /** @hidden */
  45615. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  45616. /**
  45617. * Bind a list of vertex buffers with the engine
  45618. * @param vertexBuffers defines the list of vertex buffers to bind
  45619. * @param indexBuffer defines the index buffer to bind
  45620. * @param effect defines the effect associated with the vertex buffers
  45621. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  45622. */
  45623. bindBuffers(vertexBuffers: {
  45624. [key: string]: Nullable<VertexBuffer>;
  45625. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  45626. [kind: string]: Nullable<VertexBuffer>;
  45627. }): void;
  45628. /** @hidden */
  45629. _releaseBuffer(buffer: DataBuffer): boolean;
  45630. createUniformBuffer(elements: FloatArray): DataBuffer;
  45631. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  45632. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  45633. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  45634. /**
  45635. * Create a new effect (used to store vertex/fragment shaders)
  45636. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  45637. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  45638. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  45639. * @param samplers defines an array of string used to represent textures
  45640. * @param defines defines the string containing the defines to use to compile the shaders
  45641. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  45642. * @param onCompiled defines a function to call when the effect creation is successful
  45643. * @param onError defines a function to call when the effect creation has failed
  45644. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  45645. * @returns the new Effect
  45646. */
  45647. 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;
  45648. private _compileRawShaderToSpirV;
  45649. private _compileShaderToSpirV;
  45650. private _createPipelineStageDescriptor;
  45651. private _compileRawPipelineStageDescriptor;
  45652. private _compilePipelineStageDescriptor;
  45653. /** @hidden */
  45654. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  45655. /** @hidden */
  45656. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  45657. /**
  45658. * Creates a new pipeline context
  45659. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  45660. * @returns the new pipeline
  45661. */
  45662. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  45663. /** @hidden */
  45664. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  45665. /**
  45666. * Gets the list of active attributes for a given WebGPU program
  45667. * @param pipelineContext defines the pipeline context to use
  45668. * @param attributesNames defines the list of attribute names to get
  45669. * @returns an array of indices indicating the offset of each attribute
  45670. */
  45671. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45672. /**
  45673. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45674. * @param effect defines the effect to activate
  45675. */
  45676. enableEffect(effect: Nullable<Effect>): void;
  45677. /** @hidden */
  45678. _releaseEffect(effect: Effect): void;
  45679. /**
  45680. * 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
  45681. */
  45682. releaseEffects(): void;
  45683. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45684. /**
  45685. * Gets a boolean indicating that only power of 2 textures are supported
  45686. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  45687. */
  45688. get needPOTTextures(): boolean;
  45689. /** @hidden */
  45690. _createHardwareTexture(): HardwareTextureWrapper;
  45691. /** @hidden */
  45692. _releaseTexture(texture: InternalTexture): void;
  45693. /** @hidden */
  45694. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  45695. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  45696. /**
  45697. * Usually called from Texture.ts.
  45698. * Passed information to create a hardware texture
  45699. * @param url defines a value which contains one of the following:
  45700. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45701. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45702. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45703. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45704. * @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)
  45705. * @param scene needed for loading to the correct scene
  45706. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45707. * @param onLoad optional callback to be called upon successful completion
  45708. * @param onError optional callback to be called upon failure
  45709. * @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
  45710. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45711. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45712. * @param forcedExtension defines the extension to use to pick the right loader
  45713. * @param mimeType defines an optional mime type
  45714. * @param loaderOptions options to be passed to the loader
  45715. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45716. */
  45717. 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;
  45718. /** @hidden */
  45719. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  45720. /**
  45721. * Creates a cube texture
  45722. * @param rootUrl defines the url where the files to load is located
  45723. * @param scene defines the current scene
  45724. * @param files defines the list of files to load (1 per face)
  45725. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45726. * @param onLoad defines an optional callback raised when the texture is loaded
  45727. * @param onError defines an optional callback raised if there is an issue to load the texture
  45728. * @param format defines the format of the data
  45729. * @param forcedExtension defines the extension to use to pick the right loader
  45730. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45731. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45732. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45733. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45734. * @param loaderOptions options to be passed to the loader
  45735. * @returns the cube texture as an InternalTexture
  45736. */
  45737. 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;
  45738. /**
  45739. * Creates a raw texture
  45740. * @param data defines the data to store in the texture
  45741. * @param width defines the width of the texture
  45742. * @param height defines the height of the texture
  45743. * @param format defines the format of the data
  45744. * @param generateMipMaps defines if the engine should generate the mip levels
  45745. * @param invertY defines if data must be stored with Y axis inverted
  45746. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  45747. * @param compression defines the compression used (null by default)
  45748. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45749. * @returns the raw texture inside an InternalTexture
  45750. */
  45751. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  45752. /**
  45753. * Creates a new raw cube texture
  45754. * @param data defines the array of data to use to create each face
  45755. * @param size defines the size of the textures
  45756. * @param format defines the format of the data
  45757. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45758. * @param generateMipMaps defines if the engine should generate the mip levels
  45759. * @param invertY defines if data must be stored with Y axis inverted
  45760. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45761. * @param compression defines the compression used (null by default)
  45762. * @returns the cube texture as an InternalTexture
  45763. */
  45764. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  45765. /**
  45766. * Creates a new raw cube texture from a specified url
  45767. * @param url defines the url where the data is located
  45768. * @param scene defines the current scene
  45769. * @param size defines the size of the textures
  45770. * @param format defines the format of the data
  45771. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45772. * @param noMipmap defines if the engine should avoid generating the mip levels
  45773. * @param callback defines a callback used to extract texture data from loaded data
  45774. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  45775. * @param onLoad defines a callback called when texture is loaded
  45776. * @param onError defines a callback called if there is an error
  45777. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45778. * @param invertY defines if data must be stored with Y axis inverted
  45779. * @returns the cube texture as an InternalTexture
  45780. */
  45781. 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;
  45782. /**
  45783. * Creates a new raw 2D array texture
  45784. * @param data defines the data used to create the texture
  45785. * @param width defines the width of the texture
  45786. * @param height defines the height of the texture
  45787. * @param depth defines the number of layers of the texture
  45788. * @param format defines the format of the texture
  45789. * @param generateMipMaps defines if the engine must generate mip levels
  45790. * @param invertY defines if data must be stored with Y axis inverted
  45791. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45792. * @param compression defines the compressed used (can be null)
  45793. * @param textureType defines the compressed used (can be null)
  45794. * @returns a new raw 2D array texture (stored in an InternalTexture)
  45795. */
  45796. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  45797. /**
  45798. * Creates a new raw 3D texture
  45799. * @param data defines the data used to create the texture
  45800. * @param width defines the width of the texture
  45801. * @param height defines the height of the texture
  45802. * @param depth defines the depth of the texture
  45803. * @param format defines the format of the texture
  45804. * @param generateMipMaps defines if the engine must generate mip levels
  45805. * @param invertY defines if data must be stored with Y axis inverted
  45806. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45807. * @param compression defines the compressed used (can be null)
  45808. * @param textureType defines the compressed used (can be null)
  45809. * @returns a new raw 3D texture (stored in an InternalTexture)
  45810. */
  45811. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  45812. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  45813. /**
  45814. * Update the sampling mode of a given texture
  45815. * @param samplingMode defines the required sampling mode
  45816. * @param texture defines the texture to update
  45817. * @param generateMipMaps defines whether to generate mipmaps for the texture
  45818. */
  45819. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  45820. /**
  45821. * Update the sampling mode of a given texture
  45822. * @param texture defines the texture to update
  45823. * @param wrapU defines the texture wrap mode of the u coordinates
  45824. * @param wrapV defines the texture wrap mode of the v coordinates
  45825. * @param wrapR defines the texture wrap mode of the r coordinates
  45826. */
  45827. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  45828. /**
  45829. * Update the dimensions of a texture
  45830. * @param texture texture to update
  45831. * @param width new width of the texture
  45832. * @param height new height of the texture
  45833. * @param depth new depth of the texture
  45834. */
  45835. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  45836. private _setInternalTexture;
  45837. /**
  45838. * Sets a texture to the according uniform.
  45839. * @param channel The texture channel
  45840. * @param unused unused parameter
  45841. * @param texture The texture to apply
  45842. * @param name The name of the uniform in the effect
  45843. */
  45844. setTexture(channel: number, unused: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  45845. /**
  45846. * Sets an array of texture to the WebGPU context
  45847. * @param channel defines the channel where the texture array must be set
  45848. * @param unused unused parameter
  45849. * @param textures defines the array of textures to bind
  45850. * @param name name of the channel
  45851. */
  45852. setTextureArray(channel: number, unused: Nullable<WebGLUniformLocation>, textures: BaseTexture[], name: string): void;
  45853. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string, baseName?: string, textureIndex?: number): boolean;
  45854. /** @hidden */
  45855. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  45856. /** @hidden */
  45857. _bindTexture(channel: number, texture: InternalTexture, name: string): void;
  45858. private _generateMipmaps;
  45859. /**
  45860. * Update the content of a texture
  45861. * @param texture defines the texture to update
  45862. * @param canvas defines the source containing the data
  45863. * @param invertY defines if data must be stored with Y axis inverted
  45864. * @param premulAlpha defines if alpha is stored as premultiplied
  45865. * @param format defines the format of the data
  45866. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45867. */
  45868. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  45869. /**
  45870. * Update a portion of an internal texture
  45871. * @param texture defines the texture to update
  45872. * @param imageData defines the data to store into the texture
  45873. * @param xOffset defines the x coordinates of the update rectangle
  45874. * @param yOffset defines the y coordinates of the update rectangle
  45875. * @param width defines the width of the update rectangle
  45876. * @param height defines the height of the update rectangle
  45877. * @param faceIndex defines the face index if texture is a cube (0 by default)
  45878. * @param lod defines the lod level to update (0 by default)
  45879. */
  45880. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  45881. /**
  45882. * Update a video texture
  45883. * @param texture defines the texture to update
  45884. * @param video defines the video element to use
  45885. * @param invertY defines if data must be stored with Y axis inverted
  45886. */
  45887. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  45888. /** @hidden */
  45889. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45890. /** @hidden */
  45891. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  45892. /** @hidden */
  45893. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45894. /** @hidden */
  45895. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  45896. /**
  45897. * Update a raw texture
  45898. * @param texture defines the texture to update
  45899. * @param bufferView defines the data to store in the texture
  45900. * @param format defines the format of the data
  45901. * @param invertY defines if data must be stored with Y axis inverted
  45902. * @param compression defines the compression used (null by default)
  45903. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45904. */
  45905. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  45906. /**
  45907. * Update a raw cube texture
  45908. * @param texture defines the texture to update
  45909. * @param bufferView defines the data to store
  45910. * @param format defines the data format
  45911. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45912. * @param invertY defines if data must be stored with Y axis inverted
  45913. * @param compression defines the compression used (null by default)
  45914. * @param level defines which level of the texture to update
  45915. */
  45916. updateRawCubeTexture(texture: InternalTexture, bufferView: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  45917. /**
  45918. * Update a raw 2D array texture
  45919. * @param texture defines the texture to update
  45920. * @param bufferView defines the data to store
  45921. * @param format defines the data format
  45922. * @param invertY defines if data must be stored with Y axis inverted
  45923. * @param compression defines the used compression (can be null)
  45924. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45925. */
  45926. updateRawTexture2DArray(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  45927. /**
  45928. * Update a raw 3D texture
  45929. * @param texture defines the texture to update
  45930. * @param bufferView defines the data to store
  45931. * @param format defines the data format
  45932. * @param invertY defines if data must be stored with Y axis inverted
  45933. * @param compression defines the used compression (can be null)
  45934. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45935. */
  45936. updateRawTexture3D(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  45937. /**
  45938. * Reads pixels from the current frame buffer. Please note that this function can be slow
  45939. * @param x defines the x coordinate of the rectangle where pixels must be read
  45940. * @param y defines the y coordinate of the rectangle where pixels must be read
  45941. * @param width defines the width of the rectangle where pixels must be read
  45942. * @param height defines the height of the rectangle where pixels must be read
  45943. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  45944. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  45945. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  45946. */
  45947. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  45948. /** @hidden */
  45949. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  45950. /** @hidden */
  45951. _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): ArrayBufferView;
  45952. /**
  45953. * Creates a new render target texture
  45954. * @param size defines the size of the texture
  45955. * @param options defines the options used to create the texture
  45956. * @returns a new render target texture stored in an InternalTexture
  45957. */
  45958. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45959. /**
  45960. * Create a multi render target texture
  45961. * @param size defines the size of the texture
  45962. * @param options defines the creation options
  45963. * @returns the cube texture as an InternalTexture
  45964. */
  45965. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45966. /**
  45967. * Creates a new render target cube texture
  45968. * @param size defines the size of the texture
  45969. * @param options defines the options used to create the texture
  45970. * @returns a new render target cube texture stored in an InternalTexture
  45971. */
  45972. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  45973. /** @hidden */
  45974. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  45975. width: number;
  45976. height: number;
  45977. layers?: number;
  45978. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  45979. /** @hidden */
  45980. _createDepthStencilTexture(size: number | {
  45981. width: number;
  45982. height: number;
  45983. layers?: number;
  45984. }, options: DepthTextureCreationOptions): InternalTexture;
  45985. /** @hidden */
  45986. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  45987. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  45988. /**
  45989. * Update the sample count for a given multiple render target texture
  45990. * @param textures defines the textures to update
  45991. * @param samples defines the sample count to set
  45992. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45993. */
  45994. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45995. /**
  45996. * Begin a new frame
  45997. */
  45998. beginFrame(): void;
  45999. /**
  46000. * End the current frame
  46001. */
  46002. endFrame(): void;
  46003. /**
  46004. * Force a WebGPU flush (ie. a flush of all waiting commands)
  46005. */
  46006. flushFramebuffer(): void;
  46007. private _startRenderTargetRenderPass;
  46008. private _endRenderTargetRenderPass;
  46009. private _getCurrentRenderPass;
  46010. private _startMainRenderPass;
  46011. private _endMainRenderPass;
  46012. /**
  46013. * Restores the WebGPU state to only draw on the main color attachment
  46014. */
  46015. restoreSingleAttachment(): void;
  46016. /**
  46017. * Creates a layout object to draw/clear on specific textures in a MRT
  46018. * @param textureStatus textureStatus[i] indicates if the i-th is active
  46019. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  46020. */
  46021. buildTextureLayout(textureStatus: boolean[]): number[];
  46022. /**
  46023. * Select a subsets of attachments to draw to.
  46024. * @param attachments index of attachments
  46025. */
  46026. bindAttachments(attachments: number[]): void;
  46027. /**
  46028. * Binds the frame buffer to the specified texture.
  46029. * @param texture The texture to render to or null for the default canvas
  46030. * @param faceIndex The face of the texture to render to in case of cube texture
  46031. * @param requiredWidth The width of the target to render to
  46032. * @param requiredHeight The height of the target to render to
  46033. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46034. * @param lodLevel defines the lod level to bind to the frame buffer
  46035. * @param layer defines the 2d array index to bind to frame buffer to
  46036. */
  46037. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  46038. /**
  46039. * Unbind the current render target texture from the WebGPU context
  46040. * @param texture defines the render target texture to unbind
  46041. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46042. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46043. */
  46044. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46045. /**
  46046. * Unbind a list of render target textures from the WebGPU context
  46047. * @param textures defines the render target textures to unbind
  46048. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46049. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46050. */
  46051. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46052. /**
  46053. * Unbind the current render target and bind the default framebuffer
  46054. */
  46055. restoreDefaultFramebuffer(): void;
  46056. private _setColorFormat;
  46057. private _setDepthTextureFormat;
  46058. setDitheringState(value: boolean): void;
  46059. setRasterizerState(value: boolean): void;
  46060. /**
  46061. * Set various states to the context
  46062. * @param culling defines backface culling state
  46063. * @param zOffset defines the value to apply to zOffset (0 by default)
  46064. * @param force defines if states must be applied even if cache is up to date
  46065. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46066. */
  46067. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46068. /**
  46069. * Sets the current alpha mode
  46070. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46071. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46072. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46073. */
  46074. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46075. /**
  46076. * Sets the current alpha equation
  46077. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  46078. */
  46079. setAlphaEquation(equation: number): void;
  46080. private _getBindGroupsToRender;
  46081. private _bindVertexInputs;
  46082. private _setRenderBindGroups;
  46083. private _setRenderPipeline;
  46084. /**
  46085. * Draw a list of indexed primitives
  46086. * @param fillMode defines the primitive to use
  46087. * @param indexStart defines the starting index
  46088. * @param indexCount defines the number of index to draw
  46089. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  46090. */
  46091. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46092. /**
  46093. * Draw a list of unindexed primitives
  46094. * @param fillMode defines the primitive to use
  46095. * @param verticesStart defines the index of first vertex to draw
  46096. * @param verticesCount defines the count of vertices to draw
  46097. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  46098. */
  46099. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46100. private _bundleEncoder;
  46101. /**
  46102. * Start recording all the gpu calls into a bundle.
  46103. */
  46104. startRecordBundle(): void;
  46105. /**
  46106. * Stops recording the bundle.
  46107. * @returns the recorded bundle
  46108. */
  46109. stopRecordBundle(): GPURenderBundle;
  46110. /**
  46111. * Execute the previously recorded bundle.
  46112. * @param bundles defines the bundle to replay
  46113. */
  46114. executeBundles(bundles: GPURenderBundle[]): void;
  46115. /**
  46116. * Dispose and release all associated resources
  46117. */
  46118. dispose(): void;
  46119. /**
  46120. * Gets the current render width
  46121. * @param useScreen defines if screen size must be used (or the current render target if any)
  46122. * @returns a number defining the current render width
  46123. */
  46124. getRenderWidth(useScreen?: boolean): number;
  46125. /**
  46126. * Gets the current render height
  46127. * @param useScreen defines if screen size must be used (or the current render target if any)
  46128. * @returns a number defining the current render height
  46129. */
  46130. getRenderHeight(useScreen?: boolean): number;
  46131. /**
  46132. * Gets the HTML canvas attached with the current WebGPU context
  46133. * @returns a HTML canvas
  46134. */
  46135. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  46136. /** @hidden */
  46137. _debugPushGroup(groupName: string, targetObject?: number): void;
  46138. /** @hidden */
  46139. _debugPopGroup(targetObject?: number): void;
  46140. /** @hidden */
  46141. _debugInsertMarker(text: string, targetObject?: number): void;
  46142. private _debugFlushPendingCommands;
  46143. /**
  46144. * Get the current error code of the WebGPU context
  46145. * @returns the error code
  46146. */
  46147. getError(): number;
  46148. /** @hidden */
  46149. bindSamplers(effect: Effect): void;
  46150. /** @hidden */
  46151. _bindTextureDirectly(target: number, texture: InternalTexture, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  46152. /** @hidden */
  46153. _releaseFramebufferObjects(texture: InternalTexture): void;
  46154. /** @hidden */
  46155. applyStates(): void;
  46156. /**
  46157. * Gets a boolean indicating if all created effects are ready
  46158. * @returns always true - No parallel shader compilation
  46159. */
  46160. areAllEffectsReady(): boolean;
  46161. /** @hidden */
  46162. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46163. /** @hidden */
  46164. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46165. /** @hidden */
  46166. _getUnpackAlignement(): number;
  46167. /** @hidden */
  46168. _unpackFlipY(value: boolean): void;
  46169. /** @hidden */
  46170. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  46171. min: number;
  46172. mag: number;
  46173. };
  46174. /** @hidden */
  46175. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46176. /** @hidden */
  46177. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46178. /** @hidden */
  46179. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46180. /** @hidden */
  46181. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46182. /** @hidden */
  46183. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46184. /** @hidden */
  46185. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46186. /** @hidden */
  46187. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  46188. /** @hidden */
  46189. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  46190. /** @hidden */
  46191. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  46192. /** @hidden */
  46193. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  46194. /** @hidden */
  46195. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  46196. /** @hidden */
  46197. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  46198. /** @hidden */
  46199. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  46200. /** @hidden */
  46201. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  46202. /** @hidden */
  46203. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  46204. /** @hidden */
  46205. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  46206. /** @hidden */
  46207. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  46208. }
  46209. }
  46210. declare module BABYLON {
  46211. /**
  46212. * Define an interface for all classes that will hold resources
  46213. */
  46214. export interface IDisposable {
  46215. /**
  46216. * Releases all held resources
  46217. */
  46218. dispose(): void;
  46219. }
  46220. /** Interface defining initialization parameters for Scene class */
  46221. export interface SceneOptions {
  46222. /**
  46223. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  46224. * It will improve performance when the number of geometries becomes important.
  46225. */
  46226. useGeometryUniqueIdsMap?: boolean;
  46227. /**
  46228. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  46229. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  46230. */
  46231. useMaterialMeshMap?: boolean;
  46232. /**
  46233. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  46234. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  46235. */
  46236. useClonedMeshMap?: boolean;
  46237. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  46238. virtual?: boolean;
  46239. }
  46240. /**
  46241. * Represents a scene to be rendered by the engine.
  46242. * @see https://doc.babylonjs.com/features/scene
  46243. */
  46244. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  46245. /** The fog is deactivated */
  46246. static readonly FOGMODE_NONE: number;
  46247. /** The fog density is following an exponential function */
  46248. static readonly FOGMODE_EXP: number;
  46249. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  46250. static readonly FOGMODE_EXP2: number;
  46251. /** The fog density is following a linear function. */
  46252. static readonly FOGMODE_LINEAR: number;
  46253. /**
  46254. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  46255. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46256. */
  46257. static MinDeltaTime: number;
  46258. /**
  46259. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  46260. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46261. */
  46262. static MaxDeltaTime: number;
  46263. /**
  46264. * Factory used to create the default material.
  46265. * @param name The name of the material to create
  46266. * @param scene The scene to create the material for
  46267. * @returns The default material
  46268. */
  46269. static DefaultMaterialFactory(scene: Scene): Material;
  46270. /**
  46271. * Factory used to create the a collision coordinator.
  46272. * @returns The collision coordinator
  46273. */
  46274. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  46275. /** @hidden */
  46276. _inputManager: InputManager;
  46277. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  46278. cameraToUseForPointers: Nullable<Camera>;
  46279. /** @hidden */
  46280. readonly _isScene: boolean;
  46281. /** @hidden */
  46282. _blockEntityCollection: boolean;
  46283. /**
  46284. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  46285. */
  46286. autoClear: boolean;
  46287. /**
  46288. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  46289. */
  46290. autoClearDepthAndStencil: boolean;
  46291. /**
  46292. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  46293. */
  46294. clearColor: Color4;
  46295. /**
  46296. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  46297. */
  46298. ambientColor: Color3;
  46299. /**
  46300. * This is use to store the default BRDF lookup for PBR materials in your scene.
  46301. * It should only be one of the following (if not the default embedded one):
  46302. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46303. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  46304. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46305. * The material properties need to be setup according to the type of texture in use.
  46306. */
  46307. environmentBRDFTexture: BaseTexture;
  46308. /**
  46309. * Texture used in all pbr material as the reflection texture.
  46310. * As in the majority of the scene they are the same (exception for multi room and so on),
  46311. * this is easier to reference from here than from all the materials.
  46312. */
  46313. get environmentTexture(): Nullable<BaseTexture>;
  46314. /**
  46315. * Texture used in all pbr material as the reflection texture.
  46316. * As in the majority of the scene they are the same (exception for multi room and so on),
  46317. * this is easier to set here than in all the materials.
  46318. */
  46319. set environmentTexture(value: Nullable<BaseTexture>);
  46320. /** @hidden */
  46321. protected _environmentIntensity: number;
  46322. /**
  46323. * Intensity of the environment in all pbr material.
  46324. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  46325. * As in the majority of the scene they are the same (exception for multi room and so on),
  46326. * this is easier to reference from here than from all the materials.
  46327. */
  46328. get environmentIntensity(): number;
  46329. /**
  46330. * Intensity of the environment in all pbr material.
  46331. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  46332. * As in the majority of the scene they are the same (exception for multi room and so on),
  46333. * this is easier to set here than in all the materials.
  46334. */
  46335. set environmentIntensity(value: number);
  46336. /** @hidden */
  46337. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46338. /**
  46339. * Default image processing configuration used either in the rendering
  46340. * Forward main pass or through the imageProcessingPostProcess if present.
  46341. * As in the majority of the scene they are the same (exception for multi camera),
  46342. * this is easier to reference from here than from all the materials and post process.
  46343. *
  46344. * No setter as we it is a shared configuration, you can set the values instead.
  46345. */
  46346. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  46347. private _forceWireframe;
  46348. /**
  46349. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  46350. */
  46351. set forceWireframe(value: boolean);
  46352. get forceWireframe(): boolean;
  46353. private _skipFrustumClipping;
  46354. /**
  46355. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  46356. */
  46357. set skipFrustumClipping(value: boolean);
  46358. get skipFrustumClipping(): boolean;
  46359. private _forcePointsCloud;
  46360. /**
  46361. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  46362. */
  46363. set forcePointsCloud(value: boolean);
  46364. get forcePointsCloud(): boolean;
  46365. /**
  46366. * Gets or sets the active clipplane 1
  46367. */
  46368. clipPlane: Nullable<Plane>;
  46369. /**
  46370. * Gets or sets the active clipplane 2
  46371. */
  46372. clipPlane2: Nullable<Plane>;
  46373. /**
  46374. * Gets or sets the active clipplane 3
  46375. */
  46376. clipPlane3: Nullable<Plane>;
  46377. /**
  46378. * Gets or sets the active clipplane 4
  46379. */
  46380. clipPlane4: Nullable<Plane>;
  46381. /**
  46382. * Gets or sets the active clipplane 5
  46383. */
  46384. clipPlane5: Nullable<Plane>;
  46385. /**
  46386. * Gets or sets the active clipplane 6
  46387. */
  46388. clipPlane6: Nullable<Plane>;
  46389. /**
  46390. * Gets or sets a boolean indicating if animations are enabled
  46391. */
  46392. animationsEnabled: boolean;
  46393. private _animationPropertiesOverride;
  46394. /**
  46395. * Gets or sets the animation properties override
  46396. */
  46397. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  46398. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  46399. /**
  46400. * Gets or sets a boolean indicating if a constant deltatime has to be used
  46401. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  46402. */
  46403. useConstantAnimationDeltaTime: boolean;
  46404. /**
  46405. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  46406. * Please note that it requires to run a ray cast through the scene on every frame
  46407. */
  46408. constantlyUpdateMeshUnderPointer: boolean;
  46409. /**
  46410. * Defines the HTML cursor to use when hovering over interactive elements
  46411. */
  46412. hoverCursor: string;
  46413. /**
  46414. * Defines the HTML default cursor to use (empty by default)
  46415. */
  46416. defaultCursor: string;
  46417. /**
  46418. * Defines whether cursors are handled by the scene.
  46419. */
  46420. doNotHandleCursors: boolean;
  46421. /**
  46422. * This is used to call preventDefault() on pointer down
  46423. * in order to block unwanted artifacts like system double clicks
  46424. */
  46425. preventDefaultOnPointerDown: boolean;
  46426. /**
  46427. * This is used to call preventDefault() on pointer up
  46428. * in order to block unwanted artifacts like system double clicks
  46429. */
  46430. preventDefaultOnPointerUp: boolean;
  46431. /**
  46432. * Gets or sets user defined metadata
  46433. */
  46434. metadata: any;
  46435. /**
  46436. * For internal use only. Please do not use.
  46437. */
  46438. reservedDataStore: any;
  46439. /**
  46440. * Gets the name of the plugin used to load this scene (null by default)
  46441. */
  46442. loadingPluginName: string;
  46443. /**
  46444. * Use this array to add regular expressions used to disable offline support for specific urls
  46445. */
  46446. disableOfflineSupportExceptionRules: RegExp[];
  46447. /**
  46448. * An event triggered when the scene is disposed.
  46449. */
  46450. onDisposeObservable: Observable<Scene>;
  46451. private _onDisposeObserver;
  46452. /** Sets a function to be executed when this scene is disposed. */
  46453. set onDispose(callback: () => void);
  46454. /**
  46455. * An event triggered before rendering the scene (right after animations and physics)
  46456. */
  46457. onBeforeRenderObservable: Observable<Scene>;
  46458. private _onBeforeRenderObserver;
  46459. /** Sets a function to be executed before rendering this scene */
  46460. set beforeRender(callback: Nullable<() => void>);
  46461. /**
  46462. * An event triggered after rendering the scene
  46463. */
  46464. onAfterRenderObservable: Observable<Scene>;
  46465. /**
  46466. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  46467. */
  46468. onAfterRenderCameraObservable: Observable<Camera>;
  46469. private _onAfterRenderObserver;
  46470. /** Sets a function to be executed after rendering this scene */
  46471. set afterRender(callback: Nullable<() => void>);
  46472. /**
  46473. * An event triggered before animating the scene
  46474. */
  46475. onBeforeAnimationsObservable: Observable<Scene>;
  46476. /**
  46477. * An event triggered after animations processing
  46478. */
  46479. onAfterAnimationsObservable: Observable<Scene>;
  46480. /**
  46481. * An event triggered before draw calls are ready to be sent
  46482. */
  46483. onBeforeDrawPhaseObservable: Observable<Scene>;
  46484. /**
  46485. * An event triggered after draw calls have been sent
  46486. */
  46487. onAfterDrawPhaseObservable: Observable<Scene>;
  46488. /**
  46489. * An event triggered when the scene is ready
  46490. */
  46491. onReadyObservable: Observable<Scene>;
  46492. /**
  46493. * An event triggered before rendering a camera
  46494. */
  46495. onBeforeCameraRenderObservable: Observable<Camera>;
  46496. private _onBeforeCameraRenderObserver;
  46497. /** Sets a function to be executed before rendering a camera*/
  46498. set beforeCameraRender(callback: () => void);
  46499. /**
  46500. * An event triggered after rendering a camera
  46501. */
  46502. onAfterCameraRenderObservable: Observable<Camera>;
  46503. private _onAfterCameraRenderObserver;
  46504. /** Sets a function to be executed after rendering a camera*/
  46505. set afterCameraRender(callback: () => void);
  46506. /**
  46507. * An event triggered when active meshes evaluation is about to start
  46508. */
  46509. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  46510. /**
  46511. * An event triggered when active meshes evaluation is done
  46512. */
  46513. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  46514. /**
  46515. * An event triggered when particles rendering is about to start
  46516. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  46517. */
  46518. onBeforeParticlesRenderingObservable: Observable<Scene>;
  46519. /**
  46520. * An event triggered when particles rendering is done
  46521. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  46522. */
  46523. onAfterParticlesRenderingObservable: Observable<Scene>;
  46524. /**
  46525. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  46526. */
  46527. onDataLoadedObservable: Observable<Scene>;
  46528. /**
  46529. * An event triggered when a camera is created
  46530. */
  46531. onNewCameraAddedObservable: Observable<Camera>;
  46532. /**
  46533. * An event triggered when a camera is removed
  46534. */
  46535. onCameraRemovedObservable: Observable<Camera>;
  46536. /**
  46537. * An event triggered when a light is created
  46538. */
  46539. onNewLightAddedObservable: Observable<Light>;
  46540. /**
  46541. * An event triggered when a light is removed
  46542. */
  46543. onLightRemovedObservable: Observable<Light>;
  46544. /**
  46545. * An event triggered when a geometry is created
  46546. */
  46547. onNewGeometryAddedObservable: Observable<Geometry>;
  46548. /**
  46549. * An event triggered when a geometry is removed
  46550. */
  46551. onGeometryRemovedObservable: Observable<Geometry>;
  46552. /**
  46553. * An event triggered when a transform node is created
  46554. */
  46555. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  46556. /**
  46557. * An event triggered when a transform node is removed
  46558. */
  46559. onTransformNodeRemovedObservable: Observable<TransformNode>;
  46560. /**
  46561. * An event triggered when a mesh is created
  46562. */
  46563. onNewMeshAddedObservable: Observable<AbstractMesh>;
  46564. /**
  46565. * An event triggered when a mesh is removed
  46566. */
  46567. onMeshRemovedObservable: Observable<AbstractMesh>;
  46568. /**
  46569. * An event triggered when a skeleton is created
  46570. */
  46571. onNewSkeletonAddedObservable: Observable<Skeleton>;
  46572. /**
  46573. * An event triggered when a skeleton is removed
  46574. */
  46575. onSkeletonRemovedObservable: Observable<Skeleton>;
  46576. /**
  46577. * An event triggered when a material is created
  46578. */
  46579. onNewMaterialAddedObservable: Observable<Material>;
  46580. /**
  46581. * An event triggered when a multi material is created
  46582. */
  46583. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  46584. /**
  46585. * An event triggered when a material is removed
  46586. */
  46587. onMaterialRemovedObservable: Observable<Material>;
  46588. /**
  46589. * An event triggered when a multi material is removed
  46590. */
  46591. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  46592. /**
  46593. * An event triggered when a texture is created
  46594. */
  46595. onNewTextureAddedObservable: Observable<BaseTexture>;
  46596. /**
  46597. * An event triggered when a texture is removed
  46598. */
  46599. onTextureRemovedObservable: Observable<BaseTexture>;
  46600. /**
  46601. * An event triggered when render targets are about to be rendered
  46602. * Can happen multiple times per frame.
  46603. */
  46604. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  46605. /**
  46606. * An event triggered when render targets were rendered.
  46607. * Can happen multiple times per frame.
  46608. */
  46609. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  46610. /**
  46611. * An event triggered before calculating deterministic simulation step
  46612. */
  46613. onBeforeStepObservable: Observable<Scene>;
  46614. /**
  46615. * An event triggered after calculating deterministic simulation step
  46616. */
  46617. onAfterStepObservable: Observable<Scene>;
  46618. /**
  46619. * An event triggered when the activeCamera property is updated
  46620. */
  46621. onActiveCameraChanged: Observable<Scene>;
  46622. /**
  46623. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  46624. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  46625. * 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)
  46626. */
  46627. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  46628. /**
  46629. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  46630. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  46631. * 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)
  46632. */
  46633. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  46634. /**
  46635. * This Observable will when a mesh has been imported into the scene.
  46636. */
  46637. onMeshImportedObservable: Observable<AbstractMesh>;
  46638. /**
  46639. * This Observable will when an animation file has been imported into the scene.
  46640. */
  46641. onAnimationFileImportedObservable: Observable<Scene>;
  46642. /**
  46643. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  46644. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  46645. */
  46646. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  46647. /** @hidden */
  46648. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  46649. /**
  46650. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  46651. */
  46652. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  46653. /**
  46654. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  46655. */
  46656. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  46657. /**
  46658. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  46659. */
  46660. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  46661. /** Callback called when a pointer move is detected */
  46662. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  46663. /** Callback called when a pointer down is detected */
  46664. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  46665. /** Callback called when a pointer up is detected */
  46666. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  46667. /** Callback called when a pointer pick is detected */
  46668. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  46669. /**
  46670. * 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).
  46671. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  46672. */
  46673. onPrePointerObservable: Observable<PointerInfoPre>;
  46674. /**
  46675. * Observable event triggered each time an input event is received from the rendering canvas
  46676. */
  46677. onPointerObservable: Observable<PointerInfo>;
  46678. /**
  46679. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  46680. */
  46681. get unTranslatedPointer(): Vector2;
  46682. /**
  46683. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  46684. */
  46685. static get DragMovementThreshold(): number;
  46686. static set DragMovementThreshold(value: number);
  46687. /**
  46688. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  46689. */
  46690. static get LongPressDelay(): number;
  46691. static set LongPressDelay(value: number);
  46692. /**
  46693. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  46694. */
  46695. static get DoubleClickDelay(): number;
  46696. static set DoubleClickDelay(value: number);
  46697. /** If you need to check double click without raising a single click at first click, enable this flag */
  46698. static get ExclusiveDoubleClickMode(): boolean;
  46699. static set ExclusiveDoubleClickMode(value: boolean);
  46700. /** @hidden */
  46701. _mirroredCameraPosition: Nullable<Vector3>;
  46702. /**
  46703. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  46704. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  46705. */
  46706. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  46707. /**
  46708. * Observable event triggered each time an keyboard event is received from the hosting window
  46709. */
  46710. onKeyboardObservable: Observable<KeyboardInfo>;
  46711. private _useRightHandedSystem;
  46712. /**
  46713. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  46714. */
  46715. set useRightHandedSystem(value: boolean);
  46716. get useRightHandedSystem(): boolean;
  46717. private _timeAccumulator;
  46718. private _currentStepId;
  46719. private _currentInternalStep;
  46720. /**
  46721. * Sets the step Id used by deterministic lock step
  46722. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46723. * @param newStepId defines the step Id
  46724. */
  46725. setStepId(newStepId: number): void;
  46726. /**
  46727. * Gets the step Id used by deterministic lock step
  46728. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46729. * @returns the step Id
  46730. */
  46731. getStepId(): number;
  46732. /**
  46733. * Gets the internal step used by deterministic lock step
  46734. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46735. * @returns the internal step
  46736. */
  46737. getInternalStep(): number;
  46738. private _fogEnabled;
  46739. /**
  46740. * Gets or sets a boolean indicating if fog is enabled on this scene
  46741. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46742. * (Default is true)
  46743. */
  46744. set fogEnabled(value: boolean);
  46745. get fogEnabled(): boolean;
  46746. private _fogMode;
  46747. /**
  46748. * Gets or sets the fog mode to use
  46749. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46750. * | mode | value |
  46751. * | --- | --- |
  46752. * | FOGMODE_NONE | 0 |
  46753. * | FOGMODE_EXP | 1 |
  46754. * | FOGMODE_EXP2 | 2 |
  46755. * | FOGMODE_LINEAR | 3 |
  46756. */
  46757. set fogMode(value: number);
  46758. get fogMode(): number;
  46759. /**
  46760. * Gets or sets the fog color to use
  46761. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46762. * (Default is Color3(0.2, 0.2, 0.3))
  46763. */
  46764. fogColor: Color3;
  46765. /**
  46766. * Gets or sets the fog density to use
  46767. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46768. * (Default is 0.1)
  46769. */
  46770. fogDensity: number;
  46771. /**
  46772. * Gets or sets the fog start distance to use
  46773. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46774. * (Default is 0)
  46775. */
  46776. fogStart: number;
  46777. /**
  46778. * Gets or sets the fog end distance to use
  46779. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46780. * (Default is 1000)
  46781. */
  46782. fogEnd: number;
  46783. /**
  46784. * Flag indicating that the frame buffer binding is handled by another component
  46785. */
  46786. get prePass(): boolean;
  46787. private _shadowsEnabled;
  46788. /**
  46789. * Gets or sets a boolean indicating if shadows are enabled on this scene
  46790. */
  46791. set shadowsEnabled(value: boolean);
  46792. get shadowsEnabled(): boolean;
  46793. private _lightsEnabled;
  46794. /**
  46795. * Gets or sets a boolean indicating if lights are enabled on this scene
  46796. */
  46797. set lightsEnabled(value: boolean);
  46798. get lightsEnabled(): boolean;
  46799. /** All of the active cameras added to this scene. */
  46800. activeCameras: Nullable<Camera[]>;
  46801. /** @hidden */
  46802. _activeCamera: Nullable<Camera>;
  46803. /** Gets or sets the current active camera */
  46804. get activeCamera(): Nullable<Camera>;
  46805. set activeCamera(value: Nullable<Camera>);
  46806. private _defaultMaterial;
  46807. /** The default material used on meshes when no material is affected */
  46808. get defaultMaterial(): Material;
  46809. /** The default material used on meshes when no material is affected */
  46810. set defaultMaterial(value: Material);
  46811. private _texturesEnabled;
  46812. /**
  46813. * Gets or sets a boolean indicating if textures are enabled on this scene
  46814. */
  46815. set texturesEnabled(value: boolean);
  46816. get texturesEnabled(): boolean;
  46817. /**
  46818. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  46819. */
  46820. physicsEnabled: boolean;
  46821. /**
  46822. * Gets or sets a boolean indicating if particles are enabled on this scene
  46823. */
  46824. particlesEnabled: boolean;
  46825. /**
  46826. * Gets or sets a boolean indicating if sprites are enabled on this scene
  46827. */
  46828. spritesEnabled: boolean;
  46829. private _skeletonsEnabled;
  46830. /**
  46831. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  46832. */
  46833. set skeletonsEnabled(value: boolean);
  46834. get skeletonsEnabled(): boolean;
  46835. /**
  46836. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  46837. */
  46838. lensFlaresEnabled: boolean;
  46839. /**
  46840. * Gets or sets a boolean indicating if collisions are enabled on this scene
  46841. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  46842. */
  46843. collisionsEnabled: boolean;
  46844. private _collisionCoordinator;
  46845. /** @hidden */
  46846. get collisionCoordinator(): ICollisionCoordinator;
  46847. /**
  46848. * Defines the gravity applied to this scene (used only for collisions)
  46849. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  46850. */
  46851. gravity: Vector3;
  46852. /**
  46853. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  46854. */
  46855. postProcessesEnabled: boolean;
  46856. /**
  46857. * Gets the current postprocess manager
  46858. */
  46859. postProcessManager: PostProcessManager;
  46860. /**
  46861. * Gets or sets a boolean indicating if render targets are enabled on this scene
  46862. */
  46863. renderTargetsEnabled: boolean;
  46864. /**
  46865. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  46866. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  46867. */
  46868. dumpNextRenderTargets: boolean;
  46869. /**
  46870. * The list of user defined render targets added to the scene
  46871. */
  46872. customRenderTargets: RenderTargetTexture[];
  46873. /**
  46874. * Defines if texture loading must be delayed
  46875. * If true, textures will only be loaded when they need to be rendered
  46876. */
  46877. useDelayedTextureLoading: boolean;
  46878. /**
  46879. * Gets the list of meshes imported to the scene through SceneLoader
  46880. */
  46881. importedMeshesFiles: String[];
  46882. /**
  46883. * Gets or sets a boolean indicating if probes are enabled on this scene
  46884. */
  46885. probesEnabled: boolean;
  46886. /**
  46887. * Gets or sets the current offline provider to use to store scene data
  46888. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  46889. */
  46890. offlineProvider: IOfflineProvider;
  46891. /**
  46892. * Gets or sets the action manager associated with the scene
  46893. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  46894. */
  46895. actionManager: AbstractActionManager;
  46896. private _meshesForIntersections;
  46897. /**
  46898. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  46899. */
  46900. proceduralTexturesEnabled: boolean;
  46901. private _engine;
  46902. private _totalVertices;
  46903. /** @hidden */
  46904. _activeIndices: PerfCounter;
  46905. /** @hidden */
  46906. _activeParticles: PerfCounter;
  46907. /** @hidden */
  46908. _activeBones: PerfCounter;
  46909. private _animationRatio;
  46910. /** @hidden */
  46911. _animationTimeLast: number;
  46912. /** @hidden */
  46913. _animationTime: number;
  46914. /**
  46915. * Gets or sets a general scale for animation speed
  46916. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  46917. */
  46918. animationTimeScale: number;
  46919. /** @hidden */
  46920. _cachedMaterial: Nullable<Material>;
  46921. /** @hidden */
  46922. _cachedEffect: Nullable<Effect>;
  46923. /** @hidden */
  46924. _cachedVisibility: Nullable<number>;
  46925. private _renderId;
  46926. private _frameId;
  46927. private _executeWhenReadyTimeoutId;
  46928. private _intermediateRendering;
  46929. private _viewUpdateFlag;
  46930. private _projectionUpdateFlag;
  46931. /** @hidden */
  46932. _toBeDisposed: Nullable<IDisposable>[];
  46933. private _activeRequests;
  46934. /** @hidden */
  46935. _pendingData: any[];
  46936. private _isDisposed;
  46937. /**
  46938. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  46939. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  46940. */
  46941. dispatchAllSubMeshesOfActiveMeshes: boolean;
  46942. private _activeMeshes;
  46943. private _processedMaterials;
  46944. private _renderTargets;
  46945. /** @hidden */
  46946. _activeParticleSystems: SmartArray<IParticleSystem>;
  46947. private _activeSkeletons;
  46948. private _softwareSkinnedMeshes;
  46949. private _renderingManager;
  46950. /** @hidden */
  46951. _activeAnimatables: Animatable[];
  46952. private _transformMatrix;
  46953. private _sceneUbo;
  46954. /** @hidden */
  46955. _viewMatrix: Matrix;
  46956. /** @hidden */
  46957. _projectionMatrix: Matrix;
  46958. /** @hidden */
  46959. _forcedViewPosition: Nullable<Vector3>;
  46960. /** @hidden */
  46961. _frustumPlanes: Plane[];
  46962. /**
  46963. * Gets the list of frustum planes (built from the active camera)
  46964. */
  46965. get frustumPlanes(): Plane[];
  46966. /**
  46967. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  46968. * This is useful if there are more lights that the maximum simulteanous authorized
  46969. */
  46970. requireLightSorting: boolean;
  46971. /** @hidden */
  46972. readonly useMaterialMeshMap: boolean;
  46973. /** @hidden */
  46974. readonly useClonedMeshMap: boolean;
  46975. private _externalData;
  46976. private _uid;
  46977. /**
  46978. * @hidden
  46979. * Backing store of defined scene components.
  46980. */
  46981. _components: ISceneComponent[];
  46982. /**
  46983. * @hidden
  46984. * Backing store of defined scene components.
  46985. */
  46986. _serializableComponents: ISceneSerializableComponent[];
  46987. /**
  46988. * List of components to register on the next registration step.
  46989. */
  46990. private _transientComponents;
  46991. /**
  46992. * Registers the transient components if needed.
  46993. */
  46994. private _registerTransientComponents;
  46995. /**
  46996. * @hidden
  46997. * Add a component to the scene.
  46998. * Note that the ccomponent could be registered on th next frame if this is called after
  46999. * the register component stage.
  47000. * @param component Defines the component to add to the scene
  47001. */
  47002. _addComponent(component: ISceneComponent): void;
  47003. /**
  47004. * @hidden
  47005. * Gets a component from the scene.
  47006. * @param name defines the name of the component to retrieve
  47007. * @returns the component or null if not present
  47008. */
  47009. _getComponent(name: string): Nullable<ISceneComponent>;
  47010. /**
  47011. * @hidden
  47012. * Defines the actions happening before camera updates.
  47013. */
  47014. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  47015. /**
  47016. * @hidden
  47017. * Defines the actions happening before clear the canvas.
  47018. */
  47019. _beforeClearStage: Stage<SimpleStageAction>;
  47020. /**
  47021. * @hidden
  47022. * Defines the actions happening before clear the canvas.
  47023. */
  47024. _beforeRenderTargetClearStage: Stage<RenderTargetStageAction>;
  47025. /**
  47026. * @hidden
  47027. * Defines the actions when collecting render targets for the frame.
  47028. */
  47029. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  47030. /**
  47031. * @hidden
  47032. * Defines the actions happening for one camera in the frame.
  47033. */
  47034. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  47035. /**
  47036. * @hidden
  47037. * Defines the actions happening during the per mesh ready checks.
  47038. */
  47039. _isReadyForMeshStage: Stage<MeshStageAction>;
  47040. /**
  47041. * @hidden
  47042. * Defines the actions happening before evaluate active mesh checks.
  47043. */
  47044. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  47045. /**
  47046. * @hidden
  47047. * Defines the actions happening during the evaluate sub mesh checks.
  47048. */
  47049. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  47050. /**
  47051. * @hidden
  47052. * Defines the actions happening during the active mesh stage.
  47053. */
  47054. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  47055. /**
  47056. * @hidden
  47057. * Defines the actions happening during the per camera render target step.
  47058. */
  47059. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  47060. /**
  47061. * @hidden
  47062. * Defines the actions happening just before the active camera is drawing.
  47063. */
  47064. _beforeCameraDrawStage: Stage<CameraStageAction>;
  47065. /**
  47066. * @hidden
  47067. * Defines the actions happening just before a render target is drawing.
  47068. */
  47069. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  47070. /**
  47071. * @hidden
  47072. * Defines the actions happening just before a rendering group is drawing.
  47073. */
  47074. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  47075. /**
  47076. * @hidden
  47077. * Defines the actions happening just before a mesh is drawing.
  47078. */
  47079. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  47080. /**
  47081. * @hidden
  47082. * Defines the actions happening just after a mesh has been drawn.
  47083. */
  47084. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  47085. /**
  47086. * @hidden
  47087. * Defines the actions happening just after a rendering group has been drawn.
  47088. */
  47089. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  47090. /**
  47091. * @hidden
  47092. * Defines the actions happening just after the active camera has been drawn.
  47093. */
  47094. _afterCameraDrawStage: Stage<CameraStageAction>;
  47095. /**
  47096. * @hidden
  47097. * Defines the actions happening just after a render target has been drawn.
  47098. */
  47099. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  47100. /**
  47101. * @hidden
  47102. * Defines the actions happening just after rendering all cameras and computing intersections.
  47103. */
  47104. _afterRenderStage: Stage<SimpleStageAction>;
  47105. /**
  47106. * @hidden
  47107. * Defines the actions happening when a pointer move event happens.
  47108. */
  47109. _pointerMoveStage: Stage<PointerMoveStageAction>;
  47110. /**
  47111. * @hidden
  47112. * Defines the actions happening when a pointer down event happens.
  47113. */
  47114. _pointerDownStage: Stage<PointerUpDownStageAction>;
  47115. /**
  47116. * @hidden
  47117. * Defines the actions happening when a pointer up event happens.
  47118. */
  47119. _pointerUpStage: Stage<PointerUpDownStageAction>;
  47120. /**
  47121. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  47122. */
  47123. private geometriesByUniqueId;
  47124. private _renderBundles;
  47125. /**
  47126. * Creates a new Scene
  47127. * @param engine defines the engine to use to render this scene
  47128. * @param options defines the scene options
  47129. */
  47130. constructor(engine: Engine, options?: SceneOptions);
  47131. /**
  47132. * Gets a string identifying the name of the class
  47133. * @returns "Scene" string
  47134. */
  47135. getClassName(): string;
  47136. private _defaultMeshCandidates;
  47137. /**
  47138. * @hidden
  47139. */
  47140. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47141. private _defaultSubMeshCandidates;
  47142. /**
  47143. * @hidden
  47144. */
  47145. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47146. /**
  47147. * Sets the default candidate providers for the scene.
  47148. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  47149. * and getCollidingSubMeshCandidates to their default function
  47150. */
  47151. setDefaultCandidateProviders(): void;
  47152. /**
  47153. * Gets the mesh that is currently under the pointer
  47154. */
  47155. get meshUnderPointer(): Nullable<AbstractMesh>;
  47156. /**
  47157. * Gets or sets the current on-screen X position of the pointer
  47158. */
  47159. get pointerX(): number;
  47160. set pointerX(value: number);
  47161. /**
  47162. * Gets or sets the current on-screen Y position of the pointer
  47163. */
  47164. get pointerY(): number;
  47165. set pointerY(value: number);
  47166. /**
  47167. * Gets the cached material (ie. the latest rendered one)
  47168. * @returns the cached material
  47169. */
  47170. getCachedMaterial(): Nullable<Material>;
  47171. /**
  47172. * Gets the cached effect (ie. the latest rendered one)
  47173. * @returns the cached effect
  47174. */
  47175. getCachedEffect(): Nullable<Effect>;
  47176. /**
  47177. * Gets the cached visibility state (ie. the latest rendered one)
  47178. * @returns the cached visibility state
  47179. */
  47180. getCachedVisibility(): Nullable<number>;
  47181. /**
  47182. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  47183. * @param material defines the current material
  47184. * @param effect defines the current effect
  47185. * @param visibility defines the current visibility state
  47186. * @returns true if one parameter is not cached
  47187. */
  47188. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  47189. /**
  47190. * Gets the engine associated with the scene
  47191. * @returns an Engine
  47192. */
  47193. getEngine(): Engine;
  47194. /**
  47195. * Gets the total number of vertices rendered per frame
  47196. * @returns the total number of vertices rendered per frame
  47197. */
  47198. getTotalVertices(): number;
  47199. /**
  47200. * Gets the performance counter for total vertices
  47201. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47202. */
  47203. get totalVerticesPerfCounter(): PerfCounter;
  47204. /**
  47205. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  47206. * @returns the total number of active indices rendered per frame
  47207. */
  47208. getActiveIndices(): number;
  47209. /**
  47210. * Gets the performance counter for active indices
  47211. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47212. */
  47213. get totalActiveIndicesPerfCounter(): PerfCounter;
  47214. /**
  47215. * Gets the total number of active particles rendered per frame
  47216. * @returns the total number of active particles rendered per frame
  47217. */
  47218. getActiveParticles(): number;
  47219. /**
  47220. * Gets the performance counter for active particles
  47221. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47222. */
  47223. get activeParticlesPerfCounter(): PerfCounter;
  47224. /**
  47225. * Gets the total number of active bones rendered per frame
  47226. * @returns the total number of active bones rendered per frame
  47227. */
  47228. getActiveBones(): number;
  47229. /**
  47230. * Gets the performance counter for active bones
  47231. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47232. */
  47233. get activeBonesPerfCounter(): PerfCounter;
  47234. /**
  47235. * Gets the array of active meshes
  47236. * @returns an array of AbstractMesh
  47237. */
  47238. getActiveMeshes(): SmartArray<AbstractMesh>;
  47239. /**
  47240. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  47241. * @returns a number
  47242. */
  47243. getAnimationRatio(): number;
  47244. /**
  47245. * Gets an unique Id for the current render phase
  47246. * @returns a number
  47247. */
  47248. getRenderId(): number;
  47249. /**
  47250. * Gets an unique Id for the current frame
  47251. * @returns a number
  47252. */
  47253. getFrameId(): number;
  47254. /** Call this function if you want to manually increment the render Id*/
  47255. incrementRenderId(): void;
  47256. private _createUbo;
  47257. /**
  47258. * Use this method to simulate a pointer move on a mesh
  47259. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  47260. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  47261. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  47262. * @returns the current scene
  47263. */
  47264. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  47265. /**
  47266. * Use this method to simulate a pointer down on a mesh
  47267. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  47268. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  47269. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  47270. * @returns the current scene
  47271. */
  47272. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  47273. /**
  47274. * Use this method to simulate a pointer up on a mesh
  47275. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  47276. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  47277. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  47278. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  47279. * @returns the current scene
  47280. */
  47281. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  47282. /**
  47283. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  47284. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  47285. * @returns true if the pointer was captured
  47286. */
  47287. isPointerCaptured(pointerId?: number): boolean;
  47288. /**
  47289. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  47290. * @param attachUp defines if you want to attach events to pointerup
  47291. * @param attachDown defines if you want to attach events to pointerdown
  47292. * @param attachMove defines if you want to attach events to pointermove
  47293. */
  47294. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  47295. /** Detaches all event handlers*/
  47296. detachControl(): void;
  47297. /**
  47298. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  47299. * Delay loaded resources are not taking in account
  47300. * @return true if all required resources are ready
  47301. */
  47302. isReady(): boolean;
  47303. /** Resets all cached information relative to material (including effect and visibility) */
  47304. resetCachedMaterial(): void;
  47305. /**
  47306. * Registers a function to be called before every frame render
  47307. * @param func defines the function to register
  47308. */
  47309. registerBeforeRender(func: () => void): void;
  47310. /**
  47311. * Unregisters a function called before every frame render
  47312. * @param func defines the function to unregister
  47313. */
  47314. unregisterBeforeRender(func: () => void): void;
  47315. /**
  47316. * Registers a function to be called after every frame render
  47317. * @param func defines the function to register
  47318. */
  47319. registerAfterRender(func: () => void): void;
  47320. /**
  47321. * Unregisters a function called after every frame render
  47322. * @param func defines the function to unregister
  47323. */
  47324. unregisterAfterRender(func: () => void): void;
  47325. private _executeOnceBeforeRender;
  47326. /**
  47327. * The provided function will run before render once and will be disposed afterwards.
  47328. * A timeout delay can be provided so that the function will be executed in N ms.
  47329. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  47330. * @param func The function to be executed.
  47331. * @param timeout optional delay in ms
  47332. */
  47333. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  47334. /** @hidden */
  47335. _addPendingData(data: any): void;
  47336. /** @hidden */
  47337. _removePendingData(data: any): void;
  47338. /**
  47339. * Returns the number of items waiting to be loaded
  47340. * @returns the number of items waiting to be loaded
  47341. */
  47342. getWaitingItemsCount(): number;
  47343. /**
  47344. * Returns a boolean indicating if the scene is still loading data
  47345. */
  47346. get isLoading(): boolean;
  47347. /**
  47348. * Registers a function to be executed when the scene is ready
  47349. * @param {Function} func - the function to be executed
  47350. */
  47351. executeWhenReady(func: () => void): void;
  47352. /**
  47353. * Returns a promise that resolves when the scene is ready
  47354. * @returns A promise that resolves when the scene is ready
  47355. */
  47356. whenReadyAsync(): Promise<void>;
  47357. /** @hidden */
  47358. _checkIsReady(): void;
  47359. /**
  47360. * Gets all animatable attached to the scene
  47361. */
  47362. get animatables(): Animatable[];
  47363. /**
  47364. * Resets the last animation time frame.
  47365. * Useful to override when animations start running when loading a scene for the first time.
  47366. */
  47367. resetLastAnimationTimeFrame(): void;
  47368. /**
  47369. * Gets the current view matrix
  47370. * @returns a Matrix
  47371. */
  47372. getViewMatrix(): Matrix;
  47373. /**
  47374. * Gets the current projection matrix
  47375. * @returns a Matrix
  47376. */
  47377. getProjectionMatrix(): Matrix;
  47378. /**
  47379. * Gets the current transform matrix
  47380. * @returns a Matrix made of View * Projection
  47381. */
  47382. getTransformMatrix(): Matrix;
  47383. /**
  47384. * Sets the current transform matrix
  47385. * @param viewL defines the View matrix to use
  47386. * @param projectionL defines the Projection matrix to use
  47387. * @param viewR defines the right View matrix to use (if provided)
  47388. * @param projectionR defines the right Projection matrix to use (if provided)
  47389. */
  47390. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  47391. /**
  47392. * Gets the uniform buffer used to store scene data
  47393. * @returns a UniformBuffer
  47394. */
  47395. getSceneUniformBuffer(): UniformBuffer;
  47396. /**
  47397. * Gets an unique (relatively to the current scene) Id
  47398. * @returns an unique number for the scene
  47399. */
  47400. getUniqueId(): number;
  47401. /**
  47402. * Add a mesh to the list of scene's meshes
  47403. * @param newMesh defines the mesh to add
  47404. * @param recursive if all child meshes should also be added to the scene
  47405. */
  47406. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  47407. /**
  47408. * Remove a mesh for the list of scene's meshes
  47409. * @param toRemove defines the mesh to remove
  47410. * @param recursive if all child meshes should also be removed from the scene
  47411. * @returns the index where the mesh was in the mesh list
  47412. */
  47413. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  47414. /**
  47415. * Add a transform node to the list of scene's transform nodes
  47416. * @param newTransformNode defines the transform node to add
  47417. */
  47418. addTransformNode(newTransformNode: TransformNode): void;
  47419. /**
  47420. * Remove a transform node for the list of scene's transform nodes
  47421. * @param toRemove defines the transform node to remove
  47422. * @returns the index where the transform node was in the transform node list
  47423. */
  47424. removeTransformNode(toRemove: TransformNode): number;
  47425. /**
  47426. * Remove a skeleton for the list of scene's skeletons
  47427. * @param toRemove defines the skeleton to remove
  47428. * @returns the index where the skeleton was in the skeleton list
  47429. */
  47430. removeSkeleton(toRemove: Skeleton): number;
  47431. /**
  47432. * Remove a morph target for the list of scene's morph targets
  47433. * @param toRemove defines the morph target to remove
  47434. * @returns the index where the morph target was in the morph target list
  47435. */
  47436. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  47437. /**
  47438. * Remove a light for the list of scene's lights
  47439. * @param toRemove defines the light to remove
  47440. * @returns the index where the light was in the light list
  47441. */
  47442. removeLight(toRemove: Light): number;
  47443. /**
  47444. * Remove a camera for the list of scene's cameras
  47445. * @param toRemove defines the camera to remove
  47446. * @returns the index where the camera was in the camera list
  47447. */
  47448. removeCamera(toRemove: Camera): number;
  47449. /**
  47450. * Remove a particle system for the list of scene's particle systems
  47451. * @param toRemove defines the particle system to remove
  47452. * @returns the index where the particle system was in the particle system list
  47453. */
  47454. removeParticleSystem(toRemove: IParticleSystem): number;
  47455. /**
  47456. * Remove a animation for the list of scene's animations
  47457. * @param toRemove defines the animation to remove
  47458. * @returns the index where the animation was in the animation list
  47459. */
  47460. removeAnimation(toRemove: Animation): number;
  47461. /**
  47462. * Will stop the animation of the given target
  47463. * @param target - the target
  47464. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  47465. * @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)
  47466. */
  47467. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  47468. /**
  47469. * Removes the given animation group from this scene.
  47470. * @param toRemove The animation group to remove
  47471. * @returns The index of the removed animation group
  47472. */
  47473. removeAnimationGroup(toRemove: AnimationGroup): number;
  47474. /**
  47475. * Removes the given multi-material from this scene.
  47476. * @param toRemove The multi-material to remove
  47477. * @returns The index of the removed multi-material
  47478. */
  47479. removeMultiMaterial(toRemove: MultiMaterial): number;
  47480. /**
  47481. * Removes the given material from this scene.
  47482. * @param toRemove The material to remove
  47483. * @returns The index of the removed material
  47484. */
  47485. removeMaterial(toRemove: Material): number;
  47486. /**
  47487. * Removes the given action manager from this scene.
  47488. * @param toRemove The action manager to remove
  47489. * @returns The index of the removed action manager
  47490. */
  47491. removeActionManager(toRemove: AbstractActionManager): number;
  47492. /**
  47493. * Removes the given texture from this scene.
  47494. * @param toRemove The texture to remove
  47495. * @returns The index of the removed texture
  47496. */
  47497. removeTexture(toRemove: BaseTexture): number;
  47498. /**
  47499. * Adds the given light to this scene
  47500. * @param newLight The light to add
  47501. */
  47502. addLight(newLight: Light): void;
  47503. /**
  47504. * Sorts the list list based on light priorities
  47505. */
  47506. sortLightsByPriority(): void;
  47507. /**
  47508. * Adds the given camera to this scene
  47509. * @param newCamera The camera to add
  47510. */
  47511. addCamera(newCamera: Camera): void;
  47512. /**
  47513. * Adds the given skeleton to this scene
  47514. * @param newSkeleton The skeleton to add
  47515. */
  47516. addSkeleton(newSkeleton: Skeleton): void;
  47517. /**
  47518. * Adds the given particle system to this scene
  47519. * @param newParticleSystem The particle system to add
  47520. */
  47521. addParticleSystem(newParticleSystem: IParticleSystem): void;
  47522. /**
  47523. * Adds the given animation to this scene
  47524. * @param newAnimation The animation to add
  47525. */
  47526. addAnimation(newAnimation: Animation): void;
  47527. /**
  47528. * Adds the given animation group to this scene.
  47529. * @param newAnimationGroup The animation group to add
  47530. */
  47531. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  47532. /**
  47533. * Adds the given multi-material to this scene
  47534. * @param newMultiMaterial The multi-material to add
  47535. */
  47536. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  47537. /**
  47538. * Adds the given material to this scene
  47539. * @param newMaterial The material to add
  47540. */
  47541. addMaterial(newMaterial: Material): void;
  47542. /**
  47543. * Adds the given morph target to this scene
  47544. * @param newMorphTargetManager The morph target to add
  47545. */
  47546. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  47547. /**
  47548. * Adds the given geometry to this scene
  47549. * @param newGeometry The geometry to add
  47550. */
  47551. addGeometry(newGeometry: Geometry): void;
  47552. /**
  47553. * Adds the given action manager to this scene
  47554. * @param newActionManager The action manager to add
  47555. */
  47556. addActionManager(newActionManager: AbstractActionManager): void;
  47557. /**
  47558. * Adds the given texture to this scene.
  47559. * @param newTexture The texture to add
  47560. */
  47561. addTexture(newTexture: BaseTexture): void;
  47562. /**
  47563. * Switch active camera
  47564. * @param newCamera defines the new active camera
  47565. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  47566. */
  47567. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  47568. /**
  47569. * sets the active camera of the scene using its ID
  47570. * @param id defines the camera's ID
  47571. * @return the new active camera or null if none found.
  47572. */
  47573. setActiveCameraByID(id: string): Nullable<Camera>;
  47574. /**
  47575. * sets the active camera of the scene using its name
  47576. * @param name defines the camera's name
  47577. * @returns the new active camera or null if none found.
  47578. */
  47579. setActiveCameraByName(name: string): Nullable<Camera>;
  47580. /**
  47581. * get an animation group using its name
  47582. * @param name defines the material's name
  47583. * @return the animation group or null if none found.
  47584. */
  47585. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  47586. /**
  47587. * Get a material using its unique id
  47588. * @param uniqueId defines the material's unique id
  47589. * @return the material or null if none found.
  47590. */
  47591. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  47592. /**
  47593. * get a material using its id
  47594. * @param id defines the material's ID
  47595. * @return the material or null if none found.
  47596. */
  47597. getMaterialByID(id: string): Nullable<Material>;
  47598. /**
  47599. * Gets a the last added material using a given id
  47600. * @param id defines the material's ID
  47601. * @return the last material with the given id or null if none found.
  47602. */
  47603. getLastMaterialByID(id: string): Nullable<Material>;
  47604. /**
  47605. * Gets a material using its name
  47606. * @param name defines the material's name
  47607. * @return the material or null if none found.
  47608. */
  47609. getMaterialByName(name: string): Nullable<Material>;
  47610. /**
  47611. * Get a texture using its unique id
  47612. * @param uniqueId defines the texture's unique id
  47613. * @return the texture or null if none found.
  47614. */
  47615. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  47616. /**
  47617. * Gets a camera using its id
  47618. * @param id defines the id to look for
  47619. * @returns the camera or null if not found
  47620. */
  47621. getCameraByID(id: string): Nullable<Camera>;
  47622. /**
  47623. * Gets a camera using its unique id
  47624. * @param uniqueId defines the unique id to look for
  47625. * @returns the camera or null if not found
  47626. */
  47627. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  47628. /**
  47629. * Gets a camera using its name
  47630. * @param name defines the camera's name
  47631. * @return the camera or null if none found.
  47632. */
  47633. getCameraByName(name: string): Nullable<Camera>;
  47634. /**
  47635. * Gets a bone using its id
  47636. * @param id defines the bone's id
  47637. * @return the bone or null if not found
  47638. */
  47639. getBoneByID(id: string): Nullable<Bone>;
  47640. /**
  47641. * Gets a bone using its id
  47642. * @param name defines the bone's name
  47643. * @return the bone or null if not found
  47644. */
  47645. getBoneByName(name: string): Nullable<Bone>;
  47646. /**
  47647. * Gets a light node using its name
  47648. * @param name defines the the light's name
  47649. * @return the light or null if none found.
  47650. */
  47651. getLightByName(name: string): Nullable<Light>;
  47652. /**
  47653. * Gets a light node using its id
  47654. * @param id defines the light's id
  47655. * @return the light or null if none found.
  47656. */
  47657. getLightByID(id: string): Nullable<Light>;
  47658. /**
  47659. * Gets a light node using its scene-generated unique ID
  47660. * @param uniqueId defines the light's unique id
  47661. * @return the light or null if none found.
  47662. */
  47663. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  47664. /**
  47665. * Gets a particle system by id
  47666. * @param id defines the particle system id
  47667. * @return the corresponding system or null if none found
  47668. */
  47669. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  47670. /**
  47671. * Gets a geometry using its ID
  47672. * @param id defines the geometry's id
  47673. * @return the geometry or null if none found.
  47674. */
  47675. getGeometryByID(id: string): Nullable<Geometry>;
  47676. private _getGeometryByUniqueID;
  47677. /**
  47678. * Add a new geometry to this scene
  47679. * @param geometry defines the geometry to be added to the scene.
  47680. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  47681. * @return a boolean defining if the geometry was added or not
  47682. */
  47683. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  47684. /**
  47685. * Removes an existing geometry
  47686. * @param geometry defines the geometry to be removed from the scene
  47687. * @return a boolean defining if the geometry was removed or not
  47688. */
  47689. removeGeometry(geometry: Geometry): boolean;
  47690. /**
  47691. * Gets the list of geometries attached to the scene
  47692. * @returns an array of Geometry
  47693. */
  47694. getGeometries(): Geometry[];
  47695. /**
  47696. * Gets the first added mesh found of a given ID
  47697. * @param id defines the id to search for
  47698. * @return the mesh found or null if not found at all
  47699. */
  47700. getMeshByID(id: string): Nullable<AbstractMesh>;
  47701. /**
  47702. * Gets a list of meshes using their id
  47703. * @param id defines the id to search for
  47704. * @returns a list of meshes
  47705. */
  47706. getMeshesByID(id: string): Array<AbstractMesh>;
  47707. /**
  47708. * Gets the first added transform node found of a given ID
  47709. * @param id defines the id to search for
  47710. * @return the found transform node or null if not found at all.
  47711. */
  47712. getTransformNodeByID(id: string): Nullable<TransformNode>;
  47713. /**
  47714. * Gets a transform node with its auto-generated unique id
  47715. * @param uniqueId efines the unique id to search for
  47716. * @return the found transform node or null if not found at all.
  47717. */
  47718. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  47719. /**
  47720. * Gets a list of transform nodes using their id
  47721. * @param id defines the id to search for
  47722. * @returns a list of transform nodes
  47723. */
  47724. getTransformNodesByID(id: string): Array<TransformNode>;
  47725. /**
  47726. * Gets a mesh with its auto-generated unique id
  47727. * @param uniqueId defines the unique id to search for
  47728. * @return the found mesh or null if not found at all.
  47729. */
  47730. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  47731. /**
  47732. * Gets a the last added mesh using a given id
  47733. * @param id defines the id to search for
  47734. * @return the found mesh or null if not found at all.
  47735. */
  47736. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  47737. /**
  47738. * Gets a the last added node (Mesh, Camera, Light) using a given id
  47739. * @param id defines the id to search for
  47740. * @return the found node or null if not found at all
  47741. */
  47742. getLastEntryByID(id: string): Nullable<Node>;
  47743. /**
  47744. * Gets a node (Mesh, Camera, Light) using a given id
  47745. * @param id defines the id to search for
  47746. * @return the found node or null if not found at all
  47747. */
  47748. getNodeByID(id: string): Nullable<Node>;
  47749. /**
  47750. * Gets a node (Mesh, Camera, Light) using a given name
  47751. * @param name defines the name to search for
  47752. * @return the found node or null if not found at all.
  47753. */
  47754. getNodeByName(name: string): Nullable<Node>;
  47755. /**
  47756. * Gets a mesh using a given name
  47757. * @param name defines the name to search for
  47758. * @return the found mesh or null if not found at all.
  47759. */
  47760. getMeshByName(name: string): Nullable<AbstractMesh>;
  47761. /**
  47762. * Gets a transform node using a given name
  47763. * @param name defines the name to search for
  47764. * @return the found transform node or null if not found at all.
  47765. */
  47766. getTransformNodeByName(name: string): Nullable<TransformNode>;
  47767. /**
  47768. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  47769. * @param id defines the id to search for
  47770. * @return the found skeleton or null if not found at all.
  47771. */
  47772. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  47773. /**
  47774. * Gets a skeleton using a given auto generated unique id
  47775. * @param uniqueId defines the unique id to search for
  47776. * @return the found skeleton or null if not found at all.
  47777. */
  47778. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  47779. /**
  47780. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  47781. * @param id defines the id to search for
  47782. * @return the found skeleton or null if not found at all.
  47783. */
  47784. getSkeletonById(id: string): Nullable<Skeleton>;
  47785. /**
  47786. * Gets a skeleton using a given name
  47787. * @param name defines the name to search for
  47788. * @return the found skeleton or null if not found at all.
  47789. */
  47790. getSkeletonByName(name: string): Nullable<Skeleton>;
  47791. /**
  47792. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  47793. * @param id defines the id to search for
  47794. * @return the found morph target manager or null if not found at all.
  47795. */
  47796. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  47797. /**
  47798. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  47799. * @param id defines the id to search for
  47800. * @return the found morph target or null if not found at all.
  47801. */
  47802. getMorphTargetById(id: string): Nullable<MorphTarget>;
  47803. /**
  47804. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  47805. * @param name defines the name to search for
  47806. * @return the found morph target or null if not found at all.
  47807. */
  47808. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  47809. /**
  47810. * Gets a post process using a given name (if many are found, this function will pick the first one)
  47811. * @param name defines the name to search for
  47812. * @return the found post process or null if not found at all.
  47813. */
  47814. getPostProcessByName(name: string): Nullable<PostProcess>;
  47815. /**
  47816. * Gets a boolean indicating if the given mesh is active
  47817. * @param mesh defines the mesh to look for
  47818. * @returns true if the mesh is in the active list
  47819. */
  47820. isActiveMesh(mesh: AbstractMesh): boolean;
  47821. /**
  47822. * Return a unique id as a string which can serve as an identifier for the scene
  47823. */
  47824. get uid(): string;
  47825. /**
  47826. * Add an externaly attached data from its key.
  47827. * This method call will fail and return false, if such key already exists.
  47828. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  47829. * @param key the unique key that identifies the data
  47830. * @param data the data object to associate to the key for this Engine instance
  47831. * @return true if no such key were already present and the data was added successfully, false otherwise
  47832. */
  47833. addExternalData<T>(key: string, data: T): boolean;
  47834. /**
  47835. * Get an externaly attached data from its key
  47836. * @param key the unique key that identifies the data
  47837. * @return the associated data, if present (can be null), or undefined if not present
  47838. */
  47839. getExternalData<T>(key: string): Nullable<T>;
  47840. /**
  47841. * Get an externaly attached data from its key, create it using a factory if it's not already present
  47842. * @param key the unique key that identifies the data
  47843. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  47844. * @return the associated data, can be null if the factory returned null.
  47845. */
  47846. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  47847. /**
  47848. * Remove an externaly attached data from the Engine instance
  47849. * @param key the unique key that identifies the data
  47850. * @return true if the data was successfully removed, false if it doesn't exist
  47851. */
  47852. removeExternalData(key: string): boolean;
  47853. private _evaluateSubMesh;
  47854. /**
  47855. * Clear the processed materials smart array preventing retention point in material dispose.
  47856. */
  47857. freeProcessedMaterials(): void;
  47858. private _preventFreeActiveMeshesAndRenderingGroups;
  47859. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  47860. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  47861. * when disposing several meshes in a row or a hierarchy of meshes.
  47862. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  47863. */
  47864. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  47865. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  47866. /**
  47867. * Clear the active meshes smart array preventing retention point in mesh dispose.
  47868. */
  47869. freeActiveMeshes(): void;
  47870. /**
  47871. * Clear the info related to rendering groups preventing retention points during dispose.
  47872. */
  47873. freeRenderingGroups(): void;
  47874. /** @hidden */
  47875. _isInIntermediateRendering(): boolean;
  47876. /**
  47877. * Lambda returning the list of potentially active meshes.
  47878. */
  47879. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  47880. /**
  47881. * Lambda returning the list of potentially active sub meshes.
  47882. */
  47883. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  47884. /**
  47885. * Lambda returning the list of potentially intersecting sub meshes.
  47886. */
  47887. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  47888. /**
  47889. * Lambda returning the list of potentially colliding sub meshes.
  47890. */
  47891. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  47892. /** @hidden */
  47893. _activeMeshesFrozen: boolean;
  47894. private _skipEvaluateActiveMeshesCompletely;
  47895. /**
  47896. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  47897. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  47898. * @param onSuccess optional success callback
  47899. * @param onError optional error callback
  47900. * @returns the current scene
  47901. */
  47902. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  47903. /**
  47904. * Use this function to restart evaluating active meshes on every frame
  47905. * @returns the current scene
  47906. */
  47907. unfreezeActiveMeshes(): Scene;
  47908. private _evaluateActiveMeshes;
  47909. private _activeMesh;
  47910. /**
  47911. * Update the transform matrix to update from the current active camera
  47912. * @param force defines a boolean used to force the update even if cache is up to date
  47913. */
  47914. updateTransformMatrix(force?: boolean): void;
  47915. private _bindFrameBuffer;
  47916. /** @hidden */
  47917. _allowPostProcessClearColor: boolean;
  47918. /** @hidden */
  47919. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  47920. private _processSubCameras;
  47921. private _checkIntersections;
  47922. /** @hidden */
  47923. _advancePhysicsEngineStep(step: number): void;
  47924. /**
  47925. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  47926. */
  47927. getDeterministicFrameTime: () => number;
  47928. /** @hidden */
  47929. _animate(): void;
  47930. /** Execute all animations (for a frame) */
  47931. animate(): void;
  47932. /**
  47933. * Render the scene
  47934. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  47935. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  47936. */
  47937. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  47938. /**
  47939. * Freeze all materials
  47940. * A frozen material will not be updatable but should be faster to render
  47941. */
  47942. freezeMaterials(): void;
  47943. /**
  47944. * Unfreeze all materials
  47945. * A frozen material will not be updatable but should be faster to render
  47946. */
  47947. unfreezeMaterials(): void;
  47948. /**
  47949. * Releases all held ressources
  47950. */
  47951. dispose(): void;
  47952. /**
  47953. * Gets if the scene is already disposed
  47954. */
  47955. get isDisposed(): boolean;
  47956. /**
  47957. * Call this function to reduce memory footprint of the scene.
  47958. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  47959. */
  47960. clearCachedVertexData(): void;
  47961. /**
  47962. * This function will remove the local cached buffer data from texture.
  47963. * It will save memory but will prevent the texture from being rebuilt
  47964. */
  47965. cleanCachedTextureBuffer(): void;
  47966. /**
  47967. * Get the world extend vectors with an optional filter
  47968. *
  47969. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  47970. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  47971. */
  47972. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  47973. min: Vector3;
  47974. max: Vector3;
  47975. };
  47976. /**
  47977. * Creates a ray that can be used to pick in the scene
  47978. * @param x defines the x coordinate of the origin (on-screen)
  47979. * @param y defines the y coordinate of the origin (on-screen)
  47980. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  47981. * @param camera defines the camera to use for the picking
  47982. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  47983. * @returns a Ray
  47984. */
  47985. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  47986. /**
  47987. * Creates a ray that can be used to pick in the scene
  47988. * @param x defines the x coordinate of the origin (on-screen)
  47989. * @param y defines the y coordinate of the origin (on-screen)
  47990. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  47991. * @param result defines the ray where to store the picking ray
  47992. * @param camera defines the camera to use for the picking
  47993. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  47994. * @returns the current scene
  47995. */
  47996. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  47997. /**
  47998. * Creates a ray that can be used to pick in the scene
  47999. * @param x defines the x coordinate of the origin (on-screen)
  48000. * @param y defines the y coordinate of the origin (on-screen)
  48001. * @param camera defines the camera to use for the picking
  48002. * @returns a Ray
  48003. */
  48004. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  48005. /**
  48006. * Creates a ray that can be used to pick in the scene
  48007. * @param x defines the x coordinate of the origin (on-screen)
  48008. * @param y defines the y coordinate of the origin (on-screen)
  48009. * @param result defines the ray where to store the picking ray
  48010. * @param camera defines the camera to use for the picking
  48011. * @returns the current scene
  48012. */
  48013. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  48014. /** Launch a ray to try to pick a mesh in the scene
  48015. * @param x position on screen
  48016. * @param y position on screen
  48017. * @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
  48018. * @param fastCheck defines if the first intersection will be used (and not the closest)
  48019. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  48020. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  48021. * @returns a PickingInfo
  48022. */
  48023. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  48024. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  48025. * @param x position on screen
  48026. * @param y position on screen
  48027. * @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
  48028. * @param fastCheck defines if the first intersection will be used (and not the closest)
  48029. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  48030. * @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)
  48031. */
  48032. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  48033. /** Use the given ray to pick a mesh in the scene
  48034. * @param ray The ray to use to pick meshes
  48035. * @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
  48036. * @param fastCheck defines if the first intersection will be used (and not the closest)
  48037. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  48038. * @returns a PickingInfo
  48039. */
  48040. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  48041. /**
  48042. * Launch a ray to try to pick a mesh in the scene
  48043. * @param x X position on screen
  48044. * @param y Y position on screen
  48045. * @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
  48046. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  48047. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  48048. * @returns an array of PickingInfo
  48049. */
  48050. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  48051. /**
  48052. * Launch a ray to try to pick a mesh in the scene
  48053. * @param ray Ray to use
  48054. * @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
  48055. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  48056. * @returns an array of PickingInfo
  48057. */
  48058. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  48059. /**
  48060. * Force the value of meshUnderPointer
  48061. * @param mesh defines the mesh to use
  48062. * @param pointerId optional pointer id when using more than one pointer
  48063. */
  48064. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  48065. /**
  48066. * Gets the mesh under the pointer
  48067. * @returns a Mesh or null if no mesh is under the pointer
  48068. */
  48069. getPointerOverMesh(): Nullable<AbstractMesh>;
  48070. /** @hidden */
  48071. _rebuildGeometries(): void;
  48072. /** @hidden */
  48073. _rebuildTextures(): void;
  48074. private _getByTags;
  48075. /**
  48076. * Get a list of meshes by tags
  48077. * @param tagsQuery defines the tags query to use
  48078. * @param forEach defines a predicate used to filter results
  48079. * @returns an array of Mesh
  48080. */
  48081. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  48082. /**
  48083. * Get a list of cameras by tags
  48084. * @param tagsQuery defines the tags query to use
  48085. * @param forEach defines a predicate used to filter results
  48086. * @returns an array of Camera
  48087. */
  48088. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  48089. /**
  48090. * Get a list of lights by tags
  48091. * @param tagsQuery defines the tags query to use
  48092. * @param forEach defines a predicate used to filter results
  48093. * @returns an array of Light
  48094. */
  48095. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  48096. /**
  48097. * Get a list of materials by tags
  48098. * @param tagsQuery defines the tags query to use
  48099. * @param forEach defines a predicate used to filter results
  48100. * @returns an array of Material
  48101. */
  48102. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  48103. /**
  48104. * Get a list of transform nodes by tags
  48105. * @param tagsQuery defines the tags query to use
  48106. * @param forEach defines a predicate used to filter results
  48107. * @returns an array of TransformNode
  48108. */
  48109. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  48110. /**
  48111. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  48112. * This allowed control for front to back rendering or reversly depending of the special needs.
  48113. *
  48114. * @param renderingGroupId The rendering group id corresponding to its index
  48115. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  48116. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  48117. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  48118. */
  48119. 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;
  48120. /**
  48121. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  48122. *
  48123. * @param renderingGroupId The rendering group id corresponding to its index
  48124. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48125. * @param depth Automatically clears depth between groups if true and autoClear is true.
  48126. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  48127. */
  48128. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  48129. /**
  48130. * Gets the current auto clear configuration for one rendering group of the rendering
  48131. * manager.
  48132. * @param index the rendering group index to get the information for
  48133. * @returns The auto clear setup for the requested rendering group
  48134. */
  48135. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  48136. private _blockMaterialDirtyMechanism;
  48137. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  48138. get blockMaterialDirtyMechanism(): boolean;
  48139. set blockMaterialDirtyMechanism(value: boolean);
  48140. /**
  48141. * Will flag all materials as dirty to trigger new shader compilation
  48142. * @param flag defines the flag used to specify which material part must be marked as dirty
  48143. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  48144. */
  48145. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  48146. /** @hidden */
  48147. _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;
  48148. /** @hidden */
  48149. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  48150. /** @hidden */
  48151. _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;
  48152. /** @hidden */
  48153. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  48154. /** @hidden */
  48155. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  48156. /** @hidden */
  48157. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  48158. }
  48159. }
  48160. declare module BABYLON {
  48161. /**
  48162. * Set of assets to keep when moving a scene into an asset container.
  48163. */
  48164. export class KeepAssets extends AbstractScene {
  48165. }
  48166. /**
  48167. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  48168. */
  48169. export class InstantiatedEntries {
  48170. /**
  48171. * List of new root nodes (eg. nodes with no parent)
  48172. */
  48173. rootNodes: TransformNode[];
  48174. /**
  48175. * List of new skeletons
  48176. */
  48177. skeletons: Skeleton[];
  48178. /**
  48179. * List of new animation groups
  48180. */
  48181. animationGroups: AnimationGroup[];
  48182. }
  48183. /**
  48184. * Container with a set of assets that can be added or removed from a scene.
  48185. */
  48186. export class AssetContainer extends AbstractScene {
  48187. private _wasAddedToScene;
  48188. /**
  48189. * The scene the AssetContainer belongs to.
  48190. */
  48191. scene: Scene;
  48192. /**
  48193. * Instantiates an AssetContainer.
  48194. * @param scene The scene the AssetContainer belongs to.
  48195. */
  48196. constructor(scene: Scene);
  48197. /**
  48198. * Instantiate or clone all meshes and add the new ones to the scene.
  48199. * Skeletons and animation groups will all be cloned
  48200. * @param nameFunction defines an optional function used to get new names for clones
  48201. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  48202. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  48203. */
  48204. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  48205. /**
  48206. * Adds all the assets from the container to the scene.
  48207. */
  48208. addAllToScene(): void;
  48209. /**
  48210. * Removes all the assets in the container from the scene
  48211. */
  48212. removeAllFromScene(): void;
  48213. /**
  48214. * Disposes all the assets in the container
  48215. */
  48216. dispose(): void;
  48217. private _moveAssets;
  48218. /**
  48219. * Removes all the assets contained in the scene and adds them to the container.
  48220. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  48221. */
  48222. moveAllFromScene(keepAssets?: KeepAssets): void;
  48223. /**
  48224. * 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.
  48225. * @returns the root mesh
  48226. */
  48227. createRootMesh(): Mesh;
  48228. /**
  48229. * Merge animations (direct and animation groups) from this asset container into a scene
  48230. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48231. * @param animatables set of animatables to retarget to a node from the scene
  48232. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  48233. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  48234. */
  48235. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  48236. }
  48237. }
  48238. declare module BABYLON {
  48239. /**
  48240. * Defines how the parser contract is defined.
  48241. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  48242. */
  48243. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  48244. /**
  48245. * Defines how the individual parser contract is defined.
  48246. * These parser can parse an individual asset
  48247. */
  48248. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  48249. /**
  48250. * Base class of the scene acting as a container for the different elements composing a scene.
  48251. * This class is dynamically extended by the different components of the scene increasing
  48252. * flexibility and reducing coupling
  48253. */
  48254. export abstract class AbstractScene {
  48255. /**
  48256. * Stores the list of available parsers in the application.
  48257. */
  48258. private static _BabylonFileParsers;
  48259. /**
  48260. * Stores the list of available individual parsers in the application.
  48261. */
  48262. private static _IndividualBabylonFileParsers;
  48263. /**
  48264. * Adds a parser in the list of available ones
  48265. * @param name Defines the name of the parser
  48266. * @param parser Defines the parser to add
  48267. */
  48268. static AddParser(name: string, parser: BabylonFileParser): void;
  48269. /**
  48270. * Gets a general parser from the list of avaialble ones
  48271. * @param name Defines the name of the parser
  48272. * @returns the requested parser or null
  48273. */
  48274. static GetParser(name: string): Nullable<BabylonFileParser>;
  48275. /**
  48276. * Adds n individual parser in the list of available ones
  48277. * @param name Defines the name of the parser
  48278. * @param parser Defines the parser to add
  48279. */
  48280. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  48281. /**
  48282. * Gets an individual parser from the list of avaialble ones
  48283. * @param name Defines the name of the parser
  48284. * @returns the requested parser or null
  48285. */
  48286. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  48287. /**
  48288. * Parser json data and populate both a scene and its associated container object
  48289. * @param jsonData Defines the data to parse
  48290. * @param scene Defines the scene to parse the data for
  48291. * @param container Defines the container attached to the parsing sequence
  48292. * @param rootUrl Defines the root url of the data
  48293. */
  48294. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  48295. /**
  48296. * Gets the list of root nodes (ie. nodes with no parent)
  48297. */
  48298. rootNodes: Node[];
  48299. /** All of the cameras added to this scene
  48300. * @see https://doc.babylonjs.com/babylon101/cameras
  48301. */
  48302. cameras: Camera[];
  48303. /**
  48304. * All of the lights added to this scene
  48305. * @see https://doc.babylonjs.com/babylon101/lights
  48306. */
  48307. lights: Light[];
  48308. /**
  48309. * All of the (abstract) meshes added to this scene
  48310. */
  48311. meshes: AbstractMesh[];
  48312. /**
  48313. * The list of skeletons added to the scene
  48314. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  48315. */
  48316. skeletons: Skeleton[];
  48317. /**
  48318. * All of the particle systems added to this scene
  48319. * @see https://doc.babylonjs.com/babylon101/particles
  48320. */
  48321. particleSystems: IParticleSystem[];
  48322. /**
  48323. * Gets a list of Animations associated with the scene
  48324. */
  48325. animations: Animation[];
  48326. /**
  48327. * All of the animation groups added to this scene
  48328. * @see https://doc.babylonjs.com/how_to/group
  48329. */
  48330. animationGroups: AnimationGroup[];
  48331. /**
  48332. * All of the multi-materials added to this scene
  48333. * @see https://doc.babylonjs.com/how_to/multi_materials
  48334. */
  48335. multiMaterials: MultiMaterial[];
  48336. /**
  48337. * All of the materials added to this scene
  48338. * In the context of a Scene, it is not supposed to be modified manually.
  48339. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  48340. * Note also that the order of the Material within the array is not significant and might change.
  48341. * @see https://doc.babylonjs.com/babylon101/materials
  48342. */
  48343. materials: Material[];
  48344. /**
  48345. * The list of morph target managers added to the scene
  48346. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  48347. */
  48348. morphTargetManagers: MorphTargetManager[];
  48349. /**
  48350. * The list of geometries used in the scene.
  48351. */
  48352. geometries: Geometry[];
  48353. /**
  48354. * All of the tranform nodes added to this scene
  48355. * In the context of a Scene, it is not supposed to be modified manually.
  48356. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  48357. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  48358. * @see https://doc.babylonjs.com/how_to/transformnode
  48359. */
  48360. transformNodes: TransformNode[];
  48361. /**
  48362. * ActionManagers available on the scene.
  48363. */
  48364. actionManagers: AbstractActionManager[];
  48365. /**
  48366. * Textures to keep.
  48367. */
  48368. textures: BaseTexture[];
  48369. /** @hidden */
  48370. protected _environmentTexture: Nullable<BaseTexture>;
  48371. /**
  48372. * Texture used in all pbr material as the reflection texture.
  48373. * As in the majority of the scene they are the same (exception for multi room and so on),
  48374. * this is easier to reference from here than from all the materials.
  48375. */
  48376. get environmentTexture(): Nullable<BaseTexture>;
  48377. set environmentTexture(value: Nullable<BaseTexture>);
  48378. /**
  48379. * The list of postprocesses added to the scene
  48380. */
  48381. postProcesses: PostProcess[];
  48382. /**
  48383. * @returns all meshes, lights, cameras, transformNodes and bones
  48384. */
  48385. getNodes(): Array<Node>;
  48386. }
  48387. }
  48388. declare module BABYLON {
  48389. /**
  48390. * Interface used to define options for Sound class
  48391. */
  48392. export interface ISoundOptions {
  48393. /**
  48394. * Does the sound autoplay once loaded.
  48395. */
  48396. autoplay?: boolean;
  48397. /**
  48398. * Does the sound loop after it finishes playing once.
  48399. */
  48400. loop?: boolean;
  48401. /**
  48402. * Sound's volume
  48403. */
  48404. volume?: number;
  48405. /**
  48406. * Is it a spatial sound?
  48407. */
  48408. spatialSound?: boolean;
  48409. /**
  48410. * Maximum distance to hear that sound
  48411. */
  48412. maxDistance?: number;
  48413. /**
  48414. * Uses user defined attenuation function
  48415. */
  48416. useCustomAttenuation?: boolean;
  48417. /**
  48418. * Define the roll off factor of spatial sounds.
  48419. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48420. */
  48421. rolloffFactor?: number;
  48422. /**
  48423. * Define the reference distance the sound should be heard perfectly.
  48424. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48425. */
  48426. refDistance?: number;
  48427. /**
  48428. * Define the distance attenuation model the sound will follow.
  48429. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48430. */
  48431. distanceModel?: string;
  48432. /**
  48433. * Defines the playback speed (1 by default)
  48434. */
  48435. playbackRate?: number;
  48436. /**
  48437. * Defines if the sound is from a streaming source
  48438. */
  48439. streaming?: boolean;
  48440. /**
  48441. * Defines an optional length (in seconds) inside the sound file
  48442. */
  48443. length?: number;
  48444. /**
  48445. * Defines an optional offset (in seconds) inside the sound file
  48446. */
  48447. offset?: number;
  48448. /**
  48449. * If true, URLs will not be required to state the audio file codec to use.
  48450. */
  48451. skipCodecCheck?: boolean;
  48452. }
  48453. }
  48454. declare module BABYLON {
  48455. /**
  48456. * Defines a sound that can be played in the application.
  48457. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  48458. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48459. */
  48460. export class Sound {
  48461. /**
  48462. * The name of the sound in the scene.
  48463. */
  48464. name: string;
  48465. /**
  48466. * Does the sound autoplay once loaded.
  48467. */
  48468. autoplay: boolean;
  48469. private _loop;
  48470. /**
  48471. * Does the sound loop after it finishes playing once.
  48472. */
  48473. get loop(): boolean;
  48474. set loop(value: boolean);
  48475. /**
  48476. * Does the sound use a custom attenuation curve to simulate the falloff
  48477. * happening when the source gets further away from the camera.
  48478. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  48479. */
  48480. useCustomAttenuation: boolean;
  48481. /**
  48482. * The sound track id this sound belongs to.
  48483. */
  48484. soundTrackId: number;
  48485. /**
  48486. * Is this sound currently played.
  48487. */
  48488. isPlaying: boolean;
  48489. /**
  48490. * Is this sound currently paused.
  48491. */
  48492. isPaused: boolean;
  48493. /**
  48494. * Does this sound enables spatial sound.
  48495. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48496. */
  48497. spatialSound: boolean;
  48498. /**
  48499. * Define the reference distance the sound should be heard perfectly.
  48500. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48501. */
  48502. refDistance: number;
  48503. /**
  48504. * Define the roll off factor of spatial sounds.
  48505. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48506. */
  48507. rolloffFactor: number;
  48508. /**
  48509. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  48510. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48511. */
  48512. maxDistance: number;
  48513. /**
  48514. * Define the distance attenuation model the sound will follow.
  48515. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48516. */
  48517. distanceModel: string;
  48518. /**
  48519. * @hidden
  48520. * Back Compat
  48521. **/
  48522. onended: () => any;
  48523. /**
  48524. * Gets or sets an object used to store user defined information for the sound.
  48525. */
  48526. metadata: any;
  48527. /**
  48528. * Observable event when the current playing sound finishes.
  48529. */
  48530. onEndedObservable: Observable<Sound>;
  48531. /**
  48532. * Gets the current time for the sound.
  48533. */
  48534. get currentTime(): number;
  48535. private _panningModel;
  48536. private _playbackRate;
  48537. private _streaming;
  48538. private _startTime;
  48539. private _startOffset;
  48540. private _position;
  48541. /** @hidden */
  48542. _positionInEmitterSpace: boolean;
  48543. private _localDirection;
  48544. private _volume;
  48545. private _isReadyToPlay;
  48546. private _isDirectional;
  48547. private _readyToPlayCallback;
  48548. private _audioBuffer;
  48549. private _soundSource;
  48550. private _streamingSource;
  48551. private _soundPanner;
  48552. private _soundGain;
  48553. private _inputAudioNode;
  48554. private _outputAudioNode;
  48555. private _coneInnerAngle;
  48556. private _coneOuterAngle;
  48557. private _coneOuterGain;
  48558. private _scene;
  48559. private _connectedTransformNode;
  48560. private _customAttenuationFunction;
  48561. private _registerFunc;
  48562. private _isOutputConnected;
  48563. private _htmlAudioElement;
  48564. private _urlType;
  48565. private _length?;
  48566. private _offset?;
  48567. /** @hidden */
  48568. static _SceneComponentInitialization: (scene: Scene) => void;
  48569. /**
  48570. * Create a sound and attach it to a scene
  48571. * @param name Name of your sound
  48572. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  48573. * @param scene defines the scene the sound belongs to
  48574. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  48575. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  48576. */
  48577. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  48578. /**
  48579. * Release the sound and its associated resources
  48580. */
  48581. dispose(): void;
  48582. /**
  48583. * Gets if the sounds is ready to be played or not.
  48584. * @returns true if ready, otherwise false
  48585. */
  48586. isReady(): boolean;
  48587. /**
  48588. * Get the current class name.
  48589. * @returns current class name
  48590. */
  48591. getClassName(): string;
  48592. private _soundLoaded;
  48593. /**
  48594. * Sets the data of the sound from an audiobuffer
  48595. * @param audioBuffer The audioBuffer containing the data
  48596. */
  48597. setAudioBuffer(audioBuffer: AudioBuffer): void;
  48598. /**
  48599. * Updates the current sounds options such as maxdistance, loop...
  48600. * @param options A JSON object containing values named as the object properties
  48601. */
  48602. updateOptions(options: ISoundOptions): void;
  48603. private _createSpatialParameters;
  48604. private _updateSpatialParameters;
  48605. /**
  48606. * Switch the panning model to HRTF:
  48607. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  48608. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48609. */
  48610. switchPanningModelToHRTF(): void;
  48611. /**
  48612. * Switch the panning model to Equal Power:
  48613. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  48614. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48615. */
  48616. switchPanningModelToEqualPower(): void;
  48617. private _switchPanningModel;
  48618. /**
  48619. * Connect this sound to a sound track audio node like gain...
  48620. * @param soundTrackAudioNode the sound track audio node to connect to
  48621. */
  48622. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  48623. /**
  48624. * Transform this sound into a directional source
  48625. * @param coneInnerAngle Size of the inner cone in degree
  48626. * @param coneOuterAngle Size of the outer cone in degree
  48627. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  48628. */
  48629. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  48630. /**
  48631. * Gets or sets the inner angle for the directional cone.
  48632. */
  48633. get directionalConeInnerAngle(): number;
  48634. /**
  48635. * Gets or sets the inner angle for the directional cone.
  48636. */
  48637. set directionalConeInnerAngle(value: number);
  48638. /**
  48639. * Gets or sets the outer angle for the directional cone.
  48640. */
  48641. get directionalConeOuterAngle(): number;
  48642. /**
  48643. * Gets or sets the outer angle for the directional cone.
  48644. */
  48645. set directionalConeOuterAngle(value: number);
  48646. /**
  48647. * Sets the position of the emitter if spatial sound is enabled
  48648. * @param newPosition Defines the new position
  48649. */
  48650. setPosition(newPosition: Vector3): void;
  48651. /**
  48652. * Sets the local direction of the emitter if spatial sound is enabled
  48653. * @param newLocalDirection Defines the new local direction
  48654. */
  48655. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  48656. private _updateDirection;
  48657. /** @hidden */
  48658. updateDistanceFromListener(): void;
  48659. /**
  48660. * Sets a new custom attenuation function for the sound.
  48661. * @param callback Defines the function used for the attenuation
  48662. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  48663. */
  48664. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  48665. /**
  48666. * Play the sound
  48667. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  48668. * @param offset (optional) Start the sound at a specific time in seconds
  48669. * @param length (optional) Sound duration (in seconds)
  48670. */
  48671. play(time?: number, offset?: number, length?: number): void;
  48672. private _onended;
  48673. /**
  48674. * Stop the sound
  48675. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  48676. */
  48677. stop(time?: number): void;
  48678. /**
  48679. * Put the sound in pause
  48680. */
  48681. pause(): void;
  48682. /**
  48683. * Sets a dedicated volume for this sounds
  48684. * @param newVolume Define the new volume of the sound
  48685. * @param time Define time for gradual change to new volume
  48686. */
  48687. setVolume(newVolume: number, time?: number): void;
  48688. /**
  48689. * Set the sound play back rate
  48690. * @param newPlaybackRate Define the playback rate the sound should be played at
  48691. */
  48692. setPlaybackRate(newPlaybackRate: number): void;
  48693. /**
  48694. * Gets the volume of the sound.
  48695. * @returns the volume of the sound
  48696. */
  48697. getVolume(): number;
  48698. /**
  48699. * Attach the sound to a dedicated mesh
  48700. * @param transformNode The transform node to connect the sound with
  48701. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  48702. */
  48703. attachToMesh(transformNode: TransformNode): void;
  48704. /**
  48705. * Detach the sound from the previously attached mesh
  48706. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  48707. */
  48708. detachFromMesh(): void;
  48709. private _onRegisterAfterWorldMatrixUpdate;
  48710. /**
  48711. * Clone the current sound in the scene.
  48712. * @returns the new sound clone
  48713. */
  48714. clone(): Nullable<Sound>;
  48715. /**
  48716. * Gets the current underlying audio buffer containing the data
  48717. * @returns the audio buffer
  48718. */
  48719. getAudioBuffer(): Nullable<AudioBuffer>;
  48720. /**
  48721. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  48722. * @returns the source node
  48723. */
  48724. getSoundSource(): Nullable<AudioBufferSourceNode>;
  48725. /**
  48726. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  48727. * @returns the gain node
  48728. */
  48729. getSoundGain(): Nullable<GainNode>;
  48730. /**
  48731. * Serializes the Sound in a JSON representation
  48732. * @returns the JSON representation of the sound
  48733. */
  48734. serialize(): any;
  48735. /**
  48736. * Parse a JSON representation of a sound to instantiate in a given scene
  48737. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  48738. * @param scene Define the scene the new parsed sound should be created in
  48739. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  48740. * @param sourceSound Define a sound place holder if do not need to instantiate a new one
  48741. * @returns the newly parsed sound
  48742. */
  48743. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  48744. }
  48745. }
  48746. declare module BABYLON {
  48747. /**
  48748. * This defines an action helpful to play a defined sound on a triggered action.
  48749. */
  48750. export class PlaySoundAction extends Action {
  48751. private _sound;
  48752. /**
  48753. * Instantiate the action
  48754. * @param triggerOptions defines the trigger options
  48755. * @param sound defines the sound to play
  48756. * @param condition defines the trigger related conditions
  48757. */
  48758. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  48759. /** @hidden */
  48760. _prepare(): void;
  48761. /**
  48762. * Execute the action and play the sound.
  48763. */
  48764. execute(): void;
  48765. /**
  48766. * Serializes the actions and its related information.
  48767. * @param parent defines the object to serialize in
  48768. * @returns the serialized object
  48769. */
  48770. serialize(parent: any): any;
  48771. }
  48772. /**
  48773. * This defines an action helpful to stop a defined sound on a triggered action.
  48774. */
  48775. export class StopSoundAction extends Action {
  48776. private _sound;
  48777. /**
  48778. * Instantiate the action
  48779. * @param triggerOptions defines the trigger options
  48780. * @param sound defines the sound to stop
  48781. * @param condition defines the trigger related conditions
  48782. */
  48783. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  48784. /** @hidden */
  48785. _prepare(): void;
  48786. /**
  48787. * Execute the action and stop the sound.
  48788. */
  48789. execute(): void;
  48790. /**
  48791. * Serializes the actions and its related information.
  48792. * @param parent defines the object to serialize in
  48793. * @returns the serialized object
  48794. */
  48795. serialize(parent: any): any;
  48796. }
  48797. }
  48798. declare module BABYLON {
  48799. /**
  48800. * This defines an action responsible to change the value of a property
  48801. * by interpolating between its current value and the newly set one once triggered.
  48802. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  48803. */
  48804. export class InterpolateValueAction extends Action {
  48805. /**
  48806. * Defines the path of the property where the value should be interpolated
  48807. */
  48808. propertyPath: string;
  48809. /**
  48810. * Defines the target value at the end of the interpolation.
  48811. */
  48812. value: any;
  48813. /**
  48814. * Defines the time it will take for the property to interpolate to the value.
  48815. */
  48816. duration: number;
  48817. /**
  48818. * Defines if the other scene animations should be stopped when the action has been triggered
  48819. */
  48820. stopOtherAnimations?: boolean;
  48821. /**
  48822. * Defines a callback raised once the interpolation animation has been done.
  48823. */
  48824. onInterpolationDone?: () => void;
  48825. /**
  48826. * Observable triggered once the interpolation animation has been done.
  48827. */
  48828. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  48829. private _target;
  48830. private _effectiveTarget;
  48831. private _property;
  48832. /**
  48833. * Instantiate the action
  48834. * @param triggerOptions defines the trigger options
  48835. * @param target defines the object containing the value to interpolate
  48836. * @param propertyPath defines the path to the property in the target object
  48837. * @param value defines the target value at the end of the interpolation
  48838. * @param duration defines the time it will take for the property to interpolate to the value.
  48839. * @param condition defines the trigger related conditions
  48840. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  48841. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  48842. */
  48843. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  48844. /** @hidden */
  48845. _prepare(): void;
  48846. /**
  48847. * Execute the action starts the value interpolation.
  48848. */
  48849. execute(): void;
  48850. /**
  48851. * Serializes the actions and its related information.
  48852. * @param parent defines the object to serialize in
  48853. * @returns the serialized object
  48854. */
  48855. serialize(parent: any): any;
  48856. }
  48857. }
  48858. declare module BABYLON {
  48859. /**
  48860. * A cursor which tracks a point on a path
  48861. */
  48862. export class PathCursor {
  48863. private path;
  48864. /**
  48865. * Stores path cursor callbacks for when an onchange event is triggered
  48866. */
  48867. private _onchange;
  48868. /**
  48869. * The value of the path cursor
  48870. */
  48871. value: number;
  48872. /**
  48873. * The animation array of the path cursor
  48874. */
  48875. animations: Animation[];
  48876. /**
  48877. * Initializes the path cursor
  48878. * @param path The path to track
  48879. */
  48880. constructor(path: Path2);
  48881. /**
  48882. * Gets the cursor point on the path
  48883. * @returns A point on the path cursor at the cursor location
  48884. */
  48885. getPoint(): Vector3;
  48886. /**
  48887. * Moves the cursor ahead by the step amount
  48888. * @param step The amount to move the cursor forward
  48889. * @returns This path cursor
  48890. */
  48891. moveAhead(step?: number): PathCursor;
  48892. /**
  48893. * Moves the cursor behind by the step amount
  48894. * @param step The amount to move the cursor back
  48895. * @returns This path cursor
  48896. */
  48897. moveBack(step?: number): PathCursor;
  48898. /**
  48899. * Moves the cursor by the step amount
  48900. * If the step amount is greater than one, an exception is thrown
  48901. * @param step The amount to move the cursor
  48902. * @returns This path cursor
  48903. */
  48904. move(step: number): PathCursor;
  48905. /**
  48906. * Ensures that the value is limited between zero and one
  48907. * @returns This path cursor
  48908. */
  48909. private ensureLimits;
  48910. /**
  48911. * Runs onchange callbacks on change (used by the animation engine)
  48912. * @returns This path cursor
  48913. */
  48914. private raiseOnChange;
  48915. /**
  48916. * Executes a function on change
  48917. * @param f A path cursor onchange callback
  48918. * @returns This path cursor
  48919. */
  48920. onchange(f: (cursor: PathCursor) => void): PathCursor;
  48921. }
  48922. }
  48923. declare module BABYLON {
  48924. /**
  48925. * This represents the default audio engine used in babylon.
  48926. * It is responsible to play, synchronize and analyse sounds throughout the application.
  48927. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48928. */
  48929. export class AudioEngine implements IAudioEngine {
  48930. private _audioContext;
  48931. private _audioContextInitialized;
  48932. private _muteButton;
  48933. private _hostElement;
  48934. /**
  48935. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  48936. */
  48937. canUseWebAudio: boolean;
  48938. /**
  48939. * The master gain node defines the global audio volume of your audio engine.
  48940. */
  48941. masterGain: GainNode;
  48942. /**
  48943. * Defines if Babylon should emit a warning if WebAudio is not supported.
  48944. * @ignoreNaming
  48945. */
  48946. WarnedWebAudioUnsupported: boolean;
  48947. /**
  48948. * Gets whether or not mp3 are supported by your browser.
  48949. */
  48950. isMP3supported: boolean;
  48951. /**
  48952. * Gets whether or not ogg are supported by your browser.
  48953. */
  48954. isOGGsupported: boolean;
  48955. /**
  48956. * Gets whether audio has been unlocked on the device.
  48957. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  48958. * a user interaction has happened.
  48959. */
  48960. unlocked: boolean;
  48961. /**
  48962. * Defines if the audio engine relies on a custom unlocked button.
  48963. * In this case, the embedded button will not be displayed.
  48964. */
  48965. useCustomUnlockedButton: boolean;
  48966. /**
  48967. * Event raised when audio has been unlocked on the browser.
  48968. */
  48969. onAudioUnlockedObservable: Observable<IAudioEngine>;
  48970. /**
  48971. * Event raised when audio has been locked on the browser.
  48972. */
  48973. onAudioLockedObservable: Observable<IAudioEngine>;
  48974. /**
  48975. * Gets the current AudioContext if available.
  48976. */
  48977. get audioContext(): Nullable<AudioContext>;
  48978. private _connectedAnalyser;
  48979. /**
  48980. * Instantiates a new audio engine.
  48981. *
  48982. * There should be only one per page as some browsers restrict the number
  48983. * of audio contexts you can create.
  48984. * @param hostElement defines the host element where to display the mute icon if necessary
  48985. */
  48986. constructor(hostElement?: Nullable<HTMLElement>);
  48987. /**
  48988. * Flags the audio engine in Locked state.
  48989. * This happens due to new browser policies preventing audio to autoplay.
  48990. */
  48991. lock(): void;
  48992. /**
  48993. * Unlocks the audio engine once a user action has been done on the dom.
  48994. * This is helpful to resume play once browser policies have been satisfied.
  48995. */
  48996. unlock(): void;
  48997. private _resumeAudioContext;
  48998. private _initializeAudioContext;
  48999. private _tryToRun;
  49000. private _triggerRunningState;
  49001. private _triggerSuspendedState;
  49002. private _displayMuteButton;
  49003. private _moveButtonToTopLeft;
  49004. private _onResize;
  49005. private _hideMuteButton;
  49006. /**
  49007. * Destroy and release the resources associated with the audio context.
  49008. */
  49009. dispose(): void;
  49010. /**
  49011. * Gets the global volume sets on the master gain.
  49012. * @returns the global volume if set or -1 otherwise
  49013. */
  49014. getGlobalVolume(): number;
  49015. /**
  49016. * Sets the global volume of your experience (sets on the master gain).
  49017. * @param newVolume Defines the new global volume of the application
  49018. */
  49019. setGlobalVolume(newVolume: number): void;
  49020. /**
  49021. * Connect the audio engine to an audio analyser allowing some amazing
  49022. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  49023. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  49024. * @param analyser The analyser to connect to the engine
  49025. */
  49026. connectToAnalyser(analyser: Analyser): void;
  49027. }
  49028. }
  49029. declare module BABYLON {
  49030. /**
  49031. * Options allowed during the creation of a sound track.
  49032. */
  49033. export interface ISoundTrackOptions {
  49034. /**
  49035. * The volume the sound track should take during creation
  49036. */
  49037. volume?: number;
  49038. /**
  49039. * Define if the sound track is the main sound track of the scene
  49040. */
  49041. mainTrack?: boolean;
  49042. }
  49043. /**
  49044. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  49045. * It will be also used in a future release to apply effects on a specific track.
  49046. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  49047. */
  49048. export class SoundTrack {
  49049. /**
  49050. * The unique identifier of the sound track in the scene.
  49051. */
  49052. id: number;
  49053. /**
  49054. * The list of sounds included in the sound track.
  49055. */
  49056. soundCollection: Array<Sound>;
  49057. private _outputAudioNode;
  49058. private _scene;
  49059. private _connectedAnalyser;
  49060. private _options;
  49061. private _isInitialized;
  49062. /**
  49063. * Creates a new sound track.
  49064. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  49065. * @param scene Define the scene the sound track belongs to
  49066. * @param options
  49067. */
  49068. constructor(scene: Scene, options?: ISoundTrackOptions);
  49069. private _initializeSoundTrackAudioGraph;
  49070. /**
  49071. * Release the sound track and its associated resources
  49072. */
  49073. dispose(): void;
  49074. /**
  49075. * Adds a sound to this sound track
  49076. * @param sound define the sound to add
  49077. * @ignoreNaming
  49078. */
  49079. addSound(sound: Sound): void;
  49080. /**
  49081. * Removes a sound to this sound track
  49082. * @param sound define the sound to remove
  49083. * @ignoreNaming
  49084. */
  49085. removeSound(sound: Sound): void;
  49086. /**
  49087. * Set a global volume for the full sound track.
  49088. * @param newVolume Define the new volume of the sound track
  49089. */
  49090. setVolume(newVolume: number): void;
  49091. /**
  49092. * Switch the panning model to HRTF:
  49093. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  49094. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49095. */
  49096. switchPanningModelToHRTF(): void;
  49097. /**
  49098. * Switch the panning model to Equal Power:
  49099. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  49100. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49101. */
  49102. switchPanningModelToEqualPower(): void;
  49103. /**
  49104. * Connect the sound track to an audio analyser allowing some amazing
  49105. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  49106. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  49107. * @param analyser The analyser to connect to the engine
  49108. */
  49109. connectToAnalyser(analyser: Analyser): void;
  49110. }
  49111. }
  49112. declare module BABYLON {
  49113. interface AbstractScene {
  49114. /**
  49115. * The list of sounds used in the scene.
  49116. */
  49117. sounds: Nullable<Array<Sound>>;
  49118. }
  49119. interface Scene {
  49120. /**
  49121. * @hidden
  49122. * Backing field
  49123. */
  49124. _mainSoundTrack: SoundTrack;
  49125. /**
  49126. * The main sound track played by the scene.
  49127. * It contains your primary collection of sounds.
  49128. */
  49129. mainSoundTrack: SoundTrack;
  49130. /**
  49131. * The list of sound tracks added to the scene
  49132. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49133. */
  49134. soundTracks: Nullable<Array<SoundTrack>>;
  49135. /**
  49136. * Gets a sound using a given name
  49137. * @param name defines the name to search for
  49138. * @return the found sound or null if not found at all.
  49139. */
  49140. getSoundByName(name: string): Nullable<Sound>;
  49141. /**
  49142. * Gets or sets if audio support is enabled
  49143. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49144. */
  49145. audioEnabled: boolean;
  49146. /**
  49147. * Gets or sets if audio will be output to headphones
  49148. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49149. */
  49150. headphone: boolean;
  49151. /**
  49152. * Gets or sets custom audio listener position provider
  49153. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49154. */
  49155. audioListenerPositionProvider: Nullable<() => Vector3>;
  49156. /**
  49157. * Gets or sets a refresh rate when using 3D audio positioning
  49158. */
  49159. audioPositioningRefreshRate: number;
  49160. }
  49161. /**
  49162. * Defines the sound scene component responsible to manage any sounds
  49163. * in a given scene.
  49164. */
  49165. export class AudioSceneComponent implements ISceneSerializableComponent {
  49166. private static _CameraDirectionLH;
  49167. private static _CameraDirectionRH;
  49168. /**
  49169. * The component name helpful to identify the component in the list of scene components.
  49170. */
  49171. readonly name: string;
  49172. /**
  49173. * The scene the component belongs to.
  49174. */
  49175. scene: Scene;
  49176. private _audioEnabled;
  49177. /**
  49178. * Gets whether audio is enabled or not.
  49179. * Please use related enable/disable method to switch state.
  49180. */
  49181. get audioEnabled(): boolean;
  49182. private _headphone;
  49183. /**
  49184. * Gets whether audio is outputting to headphone or not.
  49185. * Please use the according Switch methods to change output.
  49186. */
  49187. get headphone(): boolean;
  49188. /**
  49189. * Gets or sets a refresh rate when using 3D audio positioning
  49190. */
  49191. audioPositioningRefreshRate: number;
  49192. private _audioListenerPositionProvider;
  49193. /**
  49194. * Gets the current audio listener position provider
  49195. */
  49196. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  49197. /**
  49198. * Sets a custom listener position for all sounds in the scene
  49199. * By default, this is the position of the first active camera
  49200. */
  49201. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  49202. /**
  49203. * Creates a new instance of the component for the given scene
  49204. * @param scene Defines the scene to register the component in
  49205. */
  49206. constructor(scene: Scene);
  49207. /**
  49208. * Registers the component in a given scene
  49209. */
  49210. register(): void;
  49211. /**
  49212. * Rebuilds the elements related to this component in case of
  49213. * context lost for instance.
  49214. */
  49215. rebuild(): void;
  49216. /**
  49217. * Serializes the component data to the specified json object
  49218. * @param serializationObject The object to serialize to
  49219. */
  49220. serialize(serializationObject: any): void;
  49221. /**
  49222. * Adds all the elements from the container to the scene
  49223. * @param container the container holding the elements
  49224. */
  49225. addFromContainer(container: AbstractScene): void;
  49226. /**
  49227. * Removes all the elements in the container from the scene
  49228. * @param container contains the elements to remove
  49229. * @param dispose if the removed element should be disposed (default: false)
  49230. */
  49231. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49232. /**
  49233. * Disposes the component and the associated resources.
  49234. */
  49235. dispose(): void;
  49236. /**
  49237. * Disables audio in the associated scene.
  49238. */
  49239. disableAudio(): void;
  49240. /**
  49241. * Enables audio in the associated scene.
  49242. */
  49243. enableAudio(): void;
  49244. /**
  49245. * Switch audio to headphone output.
  49246. */
  49247. switchAudioModeForHeadphones(): void;
  49248. /**
  49249. * Switch audio to normal speakers.
  49250. */
  49251. switchAudioModeForNormalSpeakers(): void;
  49252. private _cachedCameraDirection;
  49253. private _cachedCameraPosition;
  49254. private _lastCheck;
  49255. private _afterRender;
  49256. }
  49257. }
  49258. declare module BABYLON {
  49259. /**
  49260. * Wraps one or more Sound objects and selects one with random weight for playback.
  49261. */
  49262. export class WeightedSound {
  49263. /** When true a Sound will be selected and played when the current playing Sound completes. */
  49264. loop: boolean;
  49265. private _coneInnerAngle;
  49266. private _coneOuterAngle;
  49267. private _volume;
  49268. /** A Sound is currently playing. */
  49269. isPlaying: boolean;
  49270. /** A Sound is currently paused. */
  49271. isPaused: boolean;
  49272. private _sounds;
  49273. private _weights;
  49274. private _currentIndex?;
  49275. /**
  49276. * Creates a new WeightedSound from the list of sounds given.
  49277. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  49278. * @param sounds Array of Sounds that will be selected from.
  49279. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  49280. */
  49281. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  49282. /**
  49283. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  49284. */
  49285. get directionalConeInnerAngle(): number;
  49286. /**
  49287. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  49288. */
  49289. set directionalConeInnerAngle(value: number);
  49290. /**
  49291. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  49292. * Listener angles between innerAngle and outerAngle will falloff linearly.
  49293. */
  49294. get directionalConeOuterAngle(): number;
  49295. /**
  49296. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  49297. * Listener angles between innerAngle and outerAngle will falloff linearly.
  49298. */
  49299. set directionalConeOuterAngle(value: number);
  49300. /**
  49301. * Playback volume.
  49302. */
  49303. get volume(): number;
  49304. /**
  49305. * Playback volume.
  49306. */
  49307. set volume(value: number);
  49308. private _onended;
  49309. /**
  49310. * Suspend playback
  49311. */
  49312. pause(): void;
  49313. /**
  49314. * Stop playback
  49315. */
  49316. stop(): void;
  49317. /**
  49318. * Start playback.
  49319. * @param startOffset Position the clip head at a specific time in seconds.
  49320. */
  49321. play(startOffset?: number): void;
  49322. }
  49323. }
  49324. declare module BABYLON {
  49325. /**
  49326. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  49327. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49328. */
  49329. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  49330. /**
  49331. * Gets the name of the behavior.
  49332. */
  49333. get name(): string;
  49334. /**
  49335. * The easing function used by animations
  49336. */
  49337. static EasingFunction: BackEase;
  49338. /**
  49339. * The easing mode used by animations
  49340. */
  49341. static EasingMode: number;
  49342. /**
  49343. * The duration of the animation, in milliseconds
  49344. */
  49345. transitionDuration: number;
  49346. /**
  49347. * Length of the distance animated by the transition when lower radius is reached
  49348. */
  49349. lowerRadiusTransitionRange: number;
  49350. /**
  49351. * Length of the distance animated by the transition when upper radius is reached
  49352. */
  49353. upperRadiusTransitionRange: number;
  49354. private _autoTransitionRange;
  49355. /**
  49356. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  49357. */
  49358. get autoTransitionRange(): boolean;
  49359. /**
  49360. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  49361. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  49362. */
  49363. set autoTransitionRange(value: boolean);
  49364. private _attachedCamera;
  49365. private _onAfterCheckInputsObserver;
  49366. private _onMeshTargetChangedObserver;
  49367. /**
  49368. * Initializes the behavior.
  49369. */
  49370. init(): void;
  49371. /**
  49372. * Attaches the behavior to its arc rotate camera.
  49373. * @param camera Defines the camera to attach the behavior to
  49374. */
  49375. attach(camera: ArcRotateCamera): void;
  49376. /**
  49377. * Detaches the behavior from its current arc rotate camera.
  49378. */
  49379. detach(): void;
  49380. private _radiusIsAnimating;
  49381. private _radiusBounceTransition;
  49382. private _animatables;
  49383. private _cachedWheelPrecision;
  49384. /**
  49385. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  49386. * @param radiusLimit The limit to check against.
  49387. * @return Bool to indicate if at limit.
  49388. */
  49389. private _isRadiusAtLimit;
  49390. /**
  49391. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  49392. * @param radiusDelta The delta by which to animate to. Can be negative.
  49393. */
  49394. private _applyBoundRadiusAnimation;
  49395. /**
  49396. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  49397. */
  49398. protected _clearAnimationLocks(): void;
  49399. /**
  49400. * Stops and removes all animations that have been applied to the camera
  49401. */
  49402. stopAllAnimations(): void;
  49403. }
  49404. }
  49405. declare module BABYLON {
  49406. /**
  49407. * 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.
  49408. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  49409. */
  49410. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  49411. /**
  49412. * Gets the name of the behavior.
  49413. */
  49414. get name(): string;
  49415. private _mode;
  49416. private _radiusScale;
  49417. private _positionScale;
  49418. private _defaultElevation;
  49419. private _elevationReturnTime;
  49420. private _elevationReturnWaitTime;
  49421. private _zoomStopsAnimation;
  49422. private _framingTime;
  49423. /**
  49424. * The easing function used by animations
  49425. */
  49426. static EasingFunction: ExponentialEase;
  49427. /**
  49428. * The easing mode used by animations
  49429. */
  49430. static EasingMode: number;
  49431. /**
  49432. * Sets the current mode used by the behavior
  49433. */
  49434. set mode(mode: number);
  49435. /**
  49436. * Gets current mode used by the behavior.
  49437. */
  49438. get mode(): number;
  49439. /**
  49440. * Sets the scale applied to the radius (1 by default)
  49441. */
  49442. set radiusScale(radius: number);
  49443. /**
  49444. * Gets the scale applied to the radius
  49445. */
  49446. get radiusScale(): number;
  49447. /**
  49448. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  49449. */
  49450. set positionScale(scale: number);
  49451. /**
  49452. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  49453. */
  49454. get positionScale(): number;
  49455. /**
  49456. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  49457. * behaviour is triggered, in radians.
  49458. */
  49459. set defaultElevation(elevation: number);
  49460. /**
  49461. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  49462. * behaviour is triggered, in radians.
  49463. */
  49464. get defaultElevation(): number;
  49465. /**
  49466. * Sets the time (in milliseconds) taken to return to the default beta position.
  49467. * Negative value indicates camera should not return to default.
  49468. */
  49469. set elevationReturnTime(speed: number);
  49470. /**
  49471. * Gets the time (in milliseconds) taken to return to the default beta position.
  49472. * Negative value indicates camera should not return to default.
  49473. */
  49474. get elevationReturnTime(): number;
  49475. /**
  49476. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  49477. */
  49478. set elevationReturnWaitTime(time: number);
  49479. /**
  49480. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  49481. */
  49482. get elevationReturnWaitTime(): number;
  49483. /**
  49484. * Sets the flag that indicates if user zooming should stop animation.
  49485. */
  49486. set zoomStopsAnimation(flag: boolean);
  49487. /**
  49488. * Gets the flag that indicates if user zooming should stop animation.
  49489. */
  49490. get zoomStopsAnimation(): boolean;
  49491. /**
  49492. * Sets the transition time when framing the mesh, in milliseconds
  49493. */
  49494. set framingTime(time: number);
  49495. /**
  49496. * Gets the transition time when framing the mesh, in milliseconds
  49497. */
  49498. get framingTime(): number;
  49499. /**
  49500. * Define if the behavior should automatically change the configured
  49501. * camera limits and sensibilities.
  49502. */
  49503. autoCorrectCameraLimitsAndSensibility: boolean;
  49504. private _onPrePointerObservableObserver;
  49505. private _onAfterCheckInputsObserver;
  49506. private _onMeshTargetChangedObserver;
  49507. private _attachedCamera;
  49508. private _isPointerDown;
  49509. private _lastInteractionTime;
  49510. /**
  49511. * Initializes the behavior.
  49512. */
  49513. init(): void;
  49514. /**
  49515. * Attaches the behavior to its arc rotate camera.
  49516. * @param camera Defines the camera to attach the behavior to
  49517. */
  49518. attach(camera: ArcRotateCamera): void;
  49519. /**
  49520. * Detaches the behavior from its current arc rotate camera.
  49521. */
  49522. detach(): void;
  49523. private _animatables;
  49524. private _betaIsAnimating;
  49525. private _betaTransition;
  49526. private _radiusTransition;
  49527. private _vectorTransition;
  49528. /**
  49529. * Targets the given mesh and updates zoom level accordingly.
  49530. * @param mesh The mesh to target.
  49531. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49532. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49533. */
  49534. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49535. /**
  49536. * Targets the given mesh with its children and updates zoom level accordingly.
  49537. * @param mesh The mesh to target.
  49538. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49539. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49540. */
  49541. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49542. /**
  49543. * Targets the given meshes with their children and updates zoom level accordingly.
  49544. * @param meshes The mesh to target.
  49545. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49546. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49547. */
  49548. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49549. /**
  49550. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  49551. * @param minimumWorld Determines the smaller position of the bounding box extend
  49552. * @param maximumWorld Determines the bigger position of the bounding box extend
  49553. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49554. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49555. */
  49556. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49557. /**
  49558. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  49559. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  49560. * frustum width.
  49561. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  49562. * to fully enclose the mesh in the viewing frustum.
  49563. */
  49564. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  49565. /**
  49566. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  49567. * is automatically returned to its default position (expected to be above ground plane).
  49568. */
  49569. private _maintainCameraAboveGround;
  49570. /**
  49571. * Returns the frustum slope based on the canvas ratio and camera FOV
  49572. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  49573. */
  49574. private _getFrustumSlope;
  49575. /**
  49576. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  49577. */
  49578. private _clearAnimationLocks;
  49579. /**
  49580. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  49581. */
  49582. private _applyUserInteraction;
  49583. /**
  49584. * Stops and removes all animations that have been applied to the camera
  49585. */
  49586. stopAllAnimations(): void;
  49587. /**
  49588. * Gets a value indicating if the user is moving the camera
  49589. */
  49590. get isUserIsMoving(): boolean;
  49591. /**
  49592. * The camera can move all the way towards the mesh.
  49593. */
  49594. static IgnoreBoundsSizeMode: number;
  49595. /**
  49596. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  49597. */
  49598. static FitFrustumSidesMode: number;
  49599. }
  49600. }
  49601. declare module BABYLON {
  49602. /**
  49603. * Base class for Camera Pointer Inputs.
  49604. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  49605. * for example usage.
  49606. */
  49607. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  49608. /**
  49609. * Defines the camera the input is attached to.
  49610. */
  49611. abstract camera: Camera;
  49612. /**
  49613. * Whether keyboard modifier keys are pressed at time of last mouse event.
  49614. */
  49615. protected _altKey: boolean;
  49616. protected _ctrlKey: boolean;
  49617. protected _metaKey: boolean;
  49618. protected _shiftKey: boolean;
  49619. /**
  49620. * Which mouse buttons were pressed at time of last mouse event.
  49621. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  49622. */
  49623. protected _buttonsPressed: number;
  49624. /**
  49625. * Defines the buttons associated with the input to handle camera move.
  49626. */
  49627. buttons: number[];
  49628. /**
  49629. * Attach the input controls to a specific dom element to get the input from.
  49630. * @param element Defines the element the controls should be listened from
  49631. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49632. */
  49633. attachControl(noPreventDefault?: boolean): void;
  49634. /**
  49635. * Detach the current controls from the specified dom element.
  49636. */
  49637. detachControl(): void;
  49638. /**
  49639. * Gets the class name of the current input.
  49640. * @returns the class name
  49641. */
  49642. getClassName(): string;
  49643. /**
  49644. * Get the friendly name associated with the input class.
  49645. * @returns the input friendly name
  49646. */
  49647. getSimpleName(): string;
  49648. /**
  49649. * Called on pointer POINTERDOUBLETAP event.
  49650. * Override this method to provide functionality on POINTERDOUBLETAP event.
  49651. */
  49652. protected onDoubleTap(type: string): void;
  49653. /**
  49654. * Called on pointer POINTERMOVE event if only a single touch is active.
  49655. * Override this method to provide functionality.
  49656. */
  49657. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49658. /**
  49659. * Called on pointer POINTERMOVE event if multiple touches are active.
  49660. * Override this method to provide functionality.
  49661. */
  49662. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49663. /**
  49664. * Called on JS contextmenu event.
  49665. * Override this method to provide functionality.
  49666. */
  49667. protected onContextMenu(evt: PointerEvent): void;
  49668. /**
  49669. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  49670. * press.
  49671. * Override this method to provide functionality.
  49672. */
  49673. protected onButtonDown(evt: PointerEvent): void;
  49674. /**
  49675. * Called each time a new POINTERUP event occurs. Ie, for each button
  49676. * release.
  49677. * Override this method to provide functionality.
  49678. */
  49679. protected onButtonUp(evt: PointerEvent): void;
  49680. /**
  49681. * Called when window becomes inactive.
  49682. * Override this method to provide functionality.
  49683. */
  49684. protected onLostFocus(): void;
  49685. private _pointerInput;
  49686. private _observer;
  49687. private _onLostFocus;
  49688. private pointA;
  49689. private pointB;
  49690. }
  49691. }
  49692. declare module BABYLON {
  49693. /**
  49694. * Manage the pointers inputs to control an arc rotate camera.
  49695. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49696. */
  49697. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  49698. /**
  49699. * Defines the camera the input is attached to.
  49700. */
  49701. camera: ArcRotateCamera;
  49702. /**
  49703. * Gets the class name of the current input.
  49704. * @returns the class name
  49705. */
  49706. getClassName(): string;
  49707. /**
  49708. * Defines the buttons associated with the input to handle camera move.
  49709. */
  49710. buttons: number[];
  49711. /**
  49712. * Defines the pointer angular sensibility along the X axis or how fast is
  49713. * the camera rotating.
  49714. */
  49715. angularSensibilityX: number;
  49716. /**
  49717. * Defines the pointer angular sensibility along the Y axis or how fast is
  49718. * the camera rotating.
  49719. */
  49720. angularSensibilityY: number;
  49721. /**
  49722. * Defines the pointer pinch precision or how fast is the camera zooming.
  49723. */
  49724. pinchPrecision: number;
  49725. /**
  49726. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49727. * from 0.
  49728. * It defines the percentage of current camera.radius to use as delta when
  49729. * pinch zoom is used.
  49730. */
  49731. pinchDeltaPercentage: number;
  49732. /**
  49733. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  49734. * that any object in the plane at the camera's target point will scale
  49735. * perfectly with finger motion.
  49736. * Overrides pinchDeltaPercentage and pinchPrecision.
  49737. */
  49738. useNaturalPinchZoom: boolean;
  49739. /**
  49740. * Defines whether zoom (2 fingers pinch) is enabled through multitouch
  49741. */
  49742. pinchZoom: boolean;
  49743. /**
  49744. * Defines the pointer panning sensibility or how fast is the camera moving.
  49745. */
  49746. panningSensibility: number;
  49747. /**
  49748. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  49749. */
  49750. multiTouchPanning: boolean;
  49751. /**
  49752. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  49753. * zoom (pinch) through multitouch.
  49754. */
  49755. multiTouchPanAndZoom: boolean;
  49756. /**
  49757. * Revers pinch action direction.
  49758. */
  49759. pinchInwards: boolean;
  49760. private _isPanClick;
  49761. private _twoFingerActivityCount;
  49762. private _isPinching;
  49763. /**
  49764. * Move camera from multi touch panning positions.
  49765. */
  49766. private _computeMultiTouchPanning;
  49767. /**
  49768. * Move camera from pinch zoom distances.
  49769. */
  49770. private _computePinchZoom;
  49771. /**
  49772. * Called on pointer POINTERMOVE event if only a single touch is active.
  49773. */
  49774. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49775. /**
  49776. * Called on pointer POINTERDOUBLETAP event.
  49777. */
  49778. protected onDoubleTap(type: string): void;
  49779. /**
  49780. * Called on pointer POINTERMOVE event if multiple touches are active.
  49781. */
  49782. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49783. /**
  49784. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  49785. * press.
  49786. */
  49787. protected onButtonDown(evt: PointerEvent): void;
  49788. /**
  49789. * Called each time a new POINTERUP event occurs. Ie, for each button
  49790. * release.
  49791. */
  49792. protected onButtonUp(evt: PointerEvent): void;
  49793. /**
  49794. * Called when window becomes inactive.
  49795. */
  49796. protected onLostFocus(): void;
  49797. }
  49798. }
  49799. declare module BABYLON {
  49800. /**
  49801. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  49802. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49803. */
  49804. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  49805. /**
  49806. * Defines the camera the input is attached to.
  49807. */
  49808. camera: ArcRotateCamera;
  49809. /**
  49810. * Defines the list of key codes associated with the up action (increase alpha)
  49811. */
  49812. keysUp: number[];
  49813. /**
  49814. * Defines the list of key codes associated with the down action (decrease alpha)
  49815. */
  49816. keysDown: number[];
  49817. /**
  49818. * Defines the list of key codes associated with the left action (increase beta)
  49819. */
  49820. keysLeft: number[];
  49821. /**
  49822. * Defines the list of key codes associated with the right action (decrease beta)
  49823. */
  49824. keysRight: number[];
  49825. /**
  49826. * Defines the list of key codes associated with the reset action.
  49827. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  49828. */
  49829. keysReset: number[];
  49830. /**
  49831. * Defines the panning sensibility of the inputs.
  49832. * (How fast is the camera panning)
  49833. */
  49834. panningSensibility: number;
  49835. /**
  49836. * Defines the zooming sensibility of the inputs.
  49837. * (How fast is the camera zooming)
  49838. */
  49839. zoomingSensibility: number;
  49840. /**
  49841. * Defines whether maintaining the alt key down switch the movement mode from
  49842. * orientation to zoom.
  49843. */
  49844. useAltToZoom: boolean;
  49845. /**
  49846. * Rotation speed of the camera
  49847. */
  49848. angularSpeed: number;
  49849. private _keys;
  49850. private _ctrlPressed;
  49851. private _altPressed;
  49852. private _onCanvasBlurObserver;
  49853. private _onKeyboardObserver;
  49854. private _engine;
  49855. private _scene;
  49856. /**
  49857. * Attach the input controls to a specific dom element to get the input from.
  49858. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49859. */
  49860. attachControl(noPreventDefault?: boolean): void;
  49861. /**
  49862. * Detach the current controls from the specified dom element.
  49863. */
  49864. detachControl(): void;
  49865. /**
  49866. * Update the current camera state depending on the inputs that have been used this frame.
  49867. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49868. */
  49869. checkInputs(): void;
  49870. /**
  49871. * Gets the class name of the current input.
  49872. * @returns the class name
  49873. */
  49874. getClassName(): string;
  49875. /**
  49876. * Get the friendly name associated with the input class.
  49877. * @returns the input friendly name
  49878. */
  49879. getSimpleName(): string;
  49880. }
  49881. }
  49882. declare module BABYLON {
  49883. /**
  49884. * Manage the mouse wheel inputs to control an arc rotate camera.
  49885. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49886. */
  49887. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  49888. /**
  49889. * Defines the camera the input is attached to.
  49890. */
  49891. camera: ArcRotateCamera;
  49892. /**
  49893. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  49894. */
  49895. wheelPrecision: number;
  49896. /**
  49897. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49898. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49899. */
  49900. wheelDeltaPercentage: number;
  49901. private _wheel;
  49902. private _observer;
  49903. private computeDeltaFromMouseWheelLegacyEvent;
  49904. /**
  49905. * Attach the input controls to a specific dom element to get the input from.
  49906. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49907. */
  49908. attachControl(noPreventDefault?: boolean): void;
  49909. /**
  49910. * Detach the current controls from the specified dom element.
  49911. */
  49912. detachControl(): void;
  49913. /**
  49914. * Gets the class name of the current input.
  49915. * @returns the class name
  49916. */
  49917. getClassName(): string;
  49918. /**
  49919. * Get the friendly name associated with the input class.
  49920. * @returns the input friendly name
  49921. */
  49922. getSimpleName(): string;
  49923. }
  49924. }
  49925. declare module BABYLON {
  49926. /**
  49927. * Default Inputs manager for the ArcRotateCamera.
  49928. * It groups all the default supported inputs for ease of use.
  49929. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49930. */
  49931. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  49932. /**
  49933. * Instantiates a new ArcRotateCameraInputsManager.
  49934. * @param camera Defines the camera the inputs belong to
  49935. */
  49936. constructor(camera: ArcRotateCamera);
  49937. /**
  49938. * Add mouse wheel input support to the input manager.
  49939. * @returns the current input manager
  49940. */
  49941. addMouseWheel(): ArcRotateCameraInputsManager;
  49942. /**
  49943. * Add pointers input support to the input manager.
  49944. * @returns the current input manager
  49945. */
  49946. addPointers(): ArcRotateCameraInputsManager;
  49947. /**
  49948. * Add keyboard input support to the input manager.
  49949. * @returns the current input manager
  49950. */
  49951. addKeyboard(): ArcRotateCameraInputsManager;
  49952. }
  49953. }
  49954. declare module BABYLON {
  49955. /**
  49956. * This represents an orbital type of camera.
  49957. *
  49958. * 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.
  49959. * 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.
  49960. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  49961. */
  49962. export class ArcRotateCamera extends TargetCamera {
  49963. /**
  49964. * Defines the rotation angle of the camera along the longitudinal axis.
  49965. */
  49966. alpha: number;
  49967. /**
  49968. * Defines the rotation angle of the camera along the latitudinal axis.
  49969. */
  49970. beta: number;
  49971. /**
  49972. * Defines the radius of the camera from it s target point.
  49973. */
  49974. radius: number;
  49975. protected _target: Vector3;
  49976. protected _targetHost: Nullable<AbstractMesh>;
  49977. /**
  49978. * Defines the target point of the camera.
  49979. * The camera looks towards it form the radius distance.
  49980. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  49981. */
  49982. get target(): Vector3;
  49983. set target(value: Vector3);
  49984. /**
  49985. * Define the current local position of the camera in the scene
  49986. */
  49987. get position(): Vector3;
  49988. set position(newPosition: Vector3);
  49989. protected _upToYMatrix: Matrix;
  49990. protected _YToUpMatrix: Matrix;
  49991. /**
  49992. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  49993. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  49994. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  49995. */
  49996. set upVector(vec: Vector3);
  49997. get upVector(): Vector3;
  49998. /**
  49999. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  50000. */
  50001. setMatUp(): void;
  50002. /**
  50003. * Current inertia value on the longitudinal axis.
  50004. * The bigger this number the longer it will take for the camera to stop.
  50005. */
  50006. inertialAlphaOffset: number;
  50007. /**
  50008. * Current inertia value on the latitudinal axis.
  50009. * The bigger this number the longer it will take for the camera to stop.
  50010. */
  50011. inertialBetaOffset: number;
  50012. /**
  50013. * Current inertia value on the radius axis.
  50014. * The bigger this number the longer it will take for the camera to stop.
  50015. */
  50016. inertialRadiusOffset: number;
  50017. /**
  50018. * Minimum allowed angle on the longitudinal axis.
  50019. * This can help limiting how the Camera is able to move in the scene.
  50020. */
  50021. lowerAlphaLimit: Nullable<number>;
  50022. /**
  50023. * Maximum allowed angle on the longitudinal axis.
  50024. * This can help limiting how the Camera is able to move in the scene.
  50025. */
  50026. upperAlphaLimit: Nullable<number>;
  50027. /**
  50028. * Minimum allowed angle on the latitudinal axis.
  50029. * This can help limiting how the Camera is able to move in the scene.
  50030. */
  50031. lowerBetaLimit: number;
  50032. /**
  50033. * Maximum allowed angle on the latitudinal axis.
  50034. * This can help limiting how the Camera is able to move in the scene.
  50035. */
  50036. upperBetaLimit: number;
  50037. /**
  50038. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  50039. * This can help limiting how the Camera is able to move in the scene.
  50040. */
  50041. lowerRadiusLimit: Nullable<number>;
  50042. /**
  50043. * Maximum allowed distance of the camera to the target (The camera can not get further).
  50044. * This can help limiting how the Camera is able to move in the scene.
  50045. */
  50046. upperRadiusLimit: Nullable<number>;
  50047. /**
  50048. * Defines the current inertia value used during panning of the camera along the X axis.
  50049. */
  50050. inertialPanningX: number;
  50051. /**
  50052. * Defines the current inertia value used during panning of the camera along the Y axis.
  50053. */
  50054. inertialPanningY: number;
  50055. /**
  50056. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  50057. * Basically if your fingers moves away from more than this distance you will be considered
  50058. * in pinch mode.
  50059. */
  50060. pinchToPanMaxDistance: number;
  50061. /**
  50062. * Defines the maximum distance the camera can pan.
  50063. * This could help keeping the camera always in your scene.
  50064. */
  50065. panningDistanceLimit: Nullable<number>;
  50066. /**
  50067. * Defines the target of the camera before panning.
  50068. */
  50069. panningOriginTarget: Vector3;
  50070. /**
  50071. * Defines the value of the inertia used during panning.
  50072. * 0 would mean stop inertia and one would mean no decelleration at all.
  50073. */
  50074. panningInertia: number;
  50075. /**
  50076. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  50077. */
  50078. get angularSensibilityX(): number;
  50079. set angularSensibilityX(value: number);
  50080. /**
  50081. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  50082. */
  50083. get angularSensibilityY(): number;
  50084. set angularSensibilityY(value: number);
  50085. /**
  50086. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  50087. */
  50088. get pinchPrecision(): number;
  50089. set pinchPrecision(value: number);
  50090. /**
  50091. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  50092. * It will be used instead of pinchDeltaPrecision if different from 0.
  50093. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  50094. */
  50095. get pinchDeltaPercentage(): number;
  50096. set pinchDeltaPercentage(value: number);
  50097. /**
  50098. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  50099. * and pinch delta percentage.
  50100. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  50101. * that any object in the plane at the camera's target point will scale
  50102. * perfectly with finger motion.
  50103. */
  50104. get useNaturalPinchZoom(): boolean;
  50105. set useNaturalPinchZoom(value: boolean);
  50106. /**
  50107. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  50108. */
  50109. get panningSensibility(): number;
  50110. set panningSensibility(value: number);
  50111. /**
  50112. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  50113. */
  50114. get keysUp(): number[];
  50115. set keysUp(value: number[]);
  50116. /**
  50117. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  50118. */
  50119. get keysDown(): number[];
  50120. set keysDown(value: number[]);
  50121. /**
  50122. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  50123. */
  50124. get keysLeft(): number[];
  50125. set keysLeft(value: number[]);
  50126. /**
  50127. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  50128. */
  50129. get keysRight(): number[];
  50130. set keysRight(value: number[]);
  50131. /**
  50132. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  50133. */
  50134. get wheelPrecision(): number;
  50135. set wheelPrecision(value: number);
  50136. /**
  50137. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  50138. * It will be used instead of pinchDeltaPrecision if different from 0.
  50139. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  50140. */
  50141. get wheelDeltaPercentage(): number;
  50142. set wheelDeltaPercentage(value: number);
  50143. /**
  50144. * Defines how much the radius should be scaled while zooming on a particular mesh (through the zoomOn function)
  50145. */
  50146. zoomOnFactor: number;
  50147. /**
  50148. * Defines a screen offset for the camera position.
  50149. */
  50150. targetScreenOffset: Vector2;
  50151. /**
  50152. * Allows the camera to be completely reversed.
  50153. * If false the camera can not arrive upside down.
  50154. */
  50155. allowUpsideDown: boolean;
  50156. /**
  50157. * Define if double tap/click is used to restore the previously saved state of the camera.
  50158. */
  50159. useInputToRestoreState: boolean;
  50160. /** @hidden */
  50161. _viewMatrix: Matrix;
  50162. /** @hidden */
  50163. _useCtrlForPanning: boolean;
  50164. /** @hidden */
  50165. _panningMouseButton: number;
  50166. /**
  50167. * Defines the input associated to the camera.
  50168. */
  50169. inputs: ArcRotateCameraInputsManager;
  50170. /** @hidden */
  50171. _reset: () => void;
  50172. /**
  50173. * Defines the allowed panning axis.
  50174. */
  50175. panningAxis: Vector3;
  50176. protected _transformedDirection: Vector3;
  50177. private _bouncingBehavior;
  50178. /**
  50179. * Gets the bouncing behavior of the camera if it has been enabled.
  50180. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  50181. */
  50182. get bouncingBehavior(): Nullable<BouncingBehavior>;
  50183. /**
  50184. * Defines if the bouncing behavior of the camera is enabled on the camera.
  50185. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  50186. */
  50187. get useBouncingBehavior(): boolean;
  50188. set useBouncingBehavior(value: boolean);
  50189. private _framingBehavior;
  50190. /**
  50191. * Gets the framing behavior of the camera if it has been enabled.
  50192. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  50193. */
  50194. get framingBehavior(): Nullable<FramingBehavior>;
  50195. /**
  50196. * Defines if the framing behavior of the camera is enabled on the camera.
  50197. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  50198. */
  50199. get useFramingBehavior(): boolean;
  50200. set useFramingBehavior(value: boolean);
  50201. private _autoRotationBehavior;
  50202. /**
  50203. * Gets the auto rotation behavior of the camera if it has been enabled.
  50204. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  50205. */
  50206. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  50207. /**
  50208. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  50209. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  50210. */
  50211. get useAutoRotationBehavior(): boolean;
  50212. set useAutoRotationBehavior(value: boolean);
  50213. /**
  50214. * Observable triggered when the mesh target has been changed on the camera.
  50215. */
  50216. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  50217. /**
  50218. * Event raised when the camera is colliding with a mesh.
  50219. */
  50220. onCollide: (collidedMesh: AbstractMesh) => void;
  50221. /**
  50222. * Defines whether the camera should check collision with the objects oh the scene.
  50223. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  50224. */
  50225. checkCollisions: boolean;
  50226. /**
  50227. * Defines the collision radius of the camera.
  50228. * This simulates a sphere around the camera.
  50229. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  50230. */
  50231. collisionRadius: Vector3;
  50232. protected _collider: Collider;
  50233. protected _previousPosition: Vector3;
  50234. protected _collisionVelocity: Vector3;
  50235. protected _newPosition: Vector3;
  50236. protected _previousAlpha: number;
  50237. protected _previousBeta: number;
  50238. protected _previousRadius: number;
  50239. protected _collisionTriggered: boolean;
  50240. protected _targetBoundingCenter: Nullable<Vector3>;
  50241. private _computationVector;
  50242. /**
  50243. * Instantiates a new ArcRotateCamera in a given scene
  50244. * @param name Defines the name of the camera
  50245. * @param alpha Defines the camera rotation along the longitudinal axis
  50246. * @param beta Defines the camera rotation along the latitudinal axis
  50247. * @param radius Defines the camera distance from its target
  50248. * @param target Defines the camera target
  50249. * @param scene Defines the scene the camera belongs to
  50250. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  50251. */
  50252. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  50253. /** @hidden */
  50254. _initCache(): void;
  50255. /** @hidden */
  50256. _updateCache(ignoreParentClass?: boolean): void;
  50257. protected _getTargetPosition(): Vector3;
  50258. private _storedAlpha;
  50259. private _storedBeta;
  50260. private _storedRadius;
  50261. private _storedTarget;
  50262. private _storedTargetScreenOffset;
  50263. /**
  50264. * Stores the current state of the camera (alpha, beta, radius and target)
  50265. * @returns the camera itself
  50266. */
  50267. storeState(): Camera;
  50268. /**
  50269. * @hidden
  50270. * Restored camera state. You must call storeState() first
  50271. */
  50272. _restoreStateValues(): boolean;
  50273. /** @hidden */
  50274. _isSynchronizedViewMatrix(): boolean;
  50275. /**
  50276. * Attach the input controls to a specific dom element to get the input from.
  50277. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50278. */
  50279. attachControl(noPreventDefault?: boolean): void;
  50280. /**
  50281. * Attach the input controls to a specific dom element to get the input from.
  50282. * @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
  50283. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50284. */
  50285. attachControl(ignored: any, noPreventDefault?: boolean): void;
  50286. /**
  50287. * Attached controls to the current camera.
  50288. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50289. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  50290. */
  50291. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  50292. /**
  50293. * Attached controls to the current camera.
  50294. * @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
  50295. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50296. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  50297. */
  50298. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  50299. /**
  50300. * Attached controls to the current camera.
  50301. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50302. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  50303. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  50304. */
  50305. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  50306. /**
  50307. * Detach the current controls from the specified dom element.
  50308. */
  50309. detachControl(): void;
  50310. /**
  50311. * Detach the current controls from the specified dom element.
  50312. * @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
  50313. */
  50314. detachControl(ignored: any): void;
  50315. /** @hidden */
  50316. _checkInputs(): void;
  50317. protected _checkLimits(): void;
  50318. /**
  50319. * Rebuilds angles (alpha, beta) and radius from the give position and target
  50320. */
  50321. rebuildAnglesAndRadius(): void;
  50322. /**
  50323. * Use a position to define the current camera related information like alpha, beta and radius
  50324. * @param position Defines the position to set the camera at
  50325. */
  50326. setPosition(position: Vector3): void;
  50327. /**
  50328. * Defines the target the camera should look at.
  50329. * This will automatically adapt alpha beta and radius to fit within the new target.
  50330. * @param target Defines the new target as a Vector or a mesh
  50331. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  50332. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  50333. */
  50334. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  50335. /** @hidden */
  50336. _getViewMatrix(): Matrix;
  50337. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  50338. /**
  50339. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  50340. * @param meshes Defines the mesh to zoom on
  50341. * @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)
  50342. */
  50343. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  50344. /**
  50345. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  50346. * The target will be changed but the radius
  50347. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  50348. * @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)
  50349. */
  50350. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  50351. min: Vector3;
  50352. max: Vector3;
  50353. distance: number;
  50354. }, doNotUpdateMaxZ?: boolean): void;
  50355. /**
  50356. * @override
  50357. * Override Camera.createRigCamera
  50358. */
  50359. createRigCamera(name: string, cameraIndex: number): Camera;
  50360. /**
  50361. * @hidden
  50362. * @override
  50363. * Override Camera._updateRigCameras
  50364. */
  50365. _updateRigCameras(): void;
  50366. /**
  50367. * Destroy the camera and release the current resources hold by it.
  50368. */
  50369. dispose(): void;
  50370. /**
  50371. * Gets the current object class name.
  50372. * @return the class name
  50373. */
  50374. getClassName(): string;
  50375. }
  50376. }
  50377. declare module BABYLON {
  50378. /**
  50379. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  50380. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  50381. */
  50382. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  50383. /**
  50384. * Gets the name of the behavior.
  50385. */
  50386. get name(): string;
  50387. private _zoomStopsAnimation;
  50388. private _idleRotationSpeed;
  50389. private _idleRotationWaitTime;
  50390. private _idleRotationSpinupTime;
  50391. /**
  50392. * Sets the flag that indicates if user zooming should stop animation.
  50393. */
  50394. set zoomStopsAnimation(flag: boolean);
  50395. /**
  50396. * Gets the flag that indicates if user zooming should stop animation.
  50397. */
  50398. get zoomStopsAnimation(): boolean;
  50399. /**
  50400. * Sets the default speed at which the camera rotates around the model.
  50401. */
  50402. set idleRotationSpeed(speed: number);
  50403. /**
  50404. * Gets the default speed at which the camera rotates around the model.
  50405. */
  50406. get idleRotationSpeed(): number;
  50407. /**
  50408. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  50409. */
  50410. set idleRotationWaitTime(time: number);
  50411. /**
  50412. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  50413. */
  50414. get idleRotationWaitTime(): number;
  50415. /**
  50416. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  50417. */
  50418. set idleRotationSpinupTime(time: number);
  50419. /**
  50420. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  50421. */
  50422. get idleRotationSpinupTime(): number;
  50423. /**
  50424. * Gets a value indicating if the camera is currently rotating because of this behavior
  50425. */
  50426. get rotationInProgress(): boolean;
  50427. private _onPrePointerObservableObserver;
  50428. private _onAfterCheckInputsObserver;
  50429. private _attachedCamera;
  50430. private _isPointerDown;
  50431. private _lastFrameTime;
  50432. private _lastInteractionTime;
  50433. private _cameraRotationSpeed;
  50434. /**
  50435. * Initializes the behavior.
  50436. */
  50437. init(): void;
  50438. /**
  50439. * Attaches the behavior to its arc rotate camera.
  50440. * @param camera Defines the camera to attach the behavior to
  50441. */
  50442. attach(camera: ArcRotateCamera): void;
  50443. /**
  50444. * Detaches the behavior from its current arc rotate camera.
  50445. */
  50446. detach(): void;
  50447. /**
  50448. * Returns true if user is scrolling.
  50449. * @return true if user is scrolling.
  50450. */
  50451. private _userIsZooming;
  50452. private _lastFrameRadius;
  50453. private _shouldAnimationStopForInteraction;
  50454. /**
  50455. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  50456. */
  50457. private _applyUserInteraction;
  50458. private _userIsMoving;
  50459. }
  50460. }
  50461. declare module BABYLON {
  50462. /**
  50463. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  50464. */
  50465. export class AttachToBoxBehavior implements Behavior<Mesh> {
  50466. private ui;
  50467. /**
  50468. * The name of the behavior
  50469. */
  50470. name: string;
  50471. /**
  50472. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  50473. */
  50474. distanceAwayFromFace: number;
  50475. /**
  50476. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  50477. */
  50478. distanceAwayFromBottomOfFace: number;
  50479. private _faceVectors;
  50480. private _target;
  50481. private _scene;
  50482. private _onRenderObserver;
  50483. private _tmpMatrix;
  50484. private _tmpVector;
  50485. /**
  50486. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  50487. * @param ui The transform node that should be attached to the mesh
  50488. */
  50489. constructor(ui: TransformNode);
  50490. /**
  50491. * Initializes the behavior
  50492. */
  50493. init(): void;
  50494. private _closestFace;
  50495. private _zeroVector;
  50496. private _lookAtTmpMatrix;
  50497. private _lookAtToRef;
  50498. /**
  50499. * Attaches the AttachToBoxBehavior to the passed in mesh
  50500. * @param target The mesh that the specified node will be attached to
  50501. */
  50502. attach(target: Mesh): void;
  50503. /**
  50504. * Detaches the behavior from the mesh
  50505. */
  50506. detach(): void;
  50507. }
  50508. }
  50509. declare module BABYLON {
  50510. /**
  50511. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  50512. */
  50513. export class FadeInOutBehavior implements Behavior<Mesh> {
  50514. /**
  50515. * Time in milliseconds to delay before fading in (Default: 0)
  50516. */
  50517. delay: number;
  50518. /**
  50519. * Time in milliseconds for the mesh to fade in (Default: 300)
  50520. */
  50521. fadeInTime: number;
  50522. private _millisecondsPerFrame;
  50523. private _hovered;
  50524. private _hoverValue;
  50525. private _ownerNode;
  50526. /**
  50527. * Instantiates the FadeInOutBehavior
  50528. */
  50529. constructor();
  50530. /**
  50531. * The name of the behavior
  50532. */
  50533. get name(): string;
  50534. /**
  50535. * Initializes the behavior
  50536. */
  50537. init(): void;
  50538. /**
  50539. * Attaches the fade behavior on the passed in mesh
  50540. * @param ownerNode The mesh that will be faded in/out once attached
  50541. */
  50542. attach(ownerNode: Mesh): void;
  50543. /**
  50544. * Detaches the behavior from the mesh
  50545. */
  50546. detach(): void;
  50547. /**
  50548. * Triggers the mesh to begin fading in or out
  50549. * @param value if the object should fade in or out (true to fade in)
  50550. */
  50551. fadeIn(value: boolean): void;
  50552. private _update;
  50553. private _setAllVisibility;
  50554. }
  50555. }
  50556. declare module BABYLON {
  50557. /**
  50558. * Class containing a set of static utilities functions for managing Pivots
  50559. * @hidden
  50560. */
  50561. export class PivotTools {
  50562. private static _PivotCached;
  50563. private static _OldPivotPoint;
  50564. private static _PivotTranslation;
  50565. private static _PivotTmpVector;
  50566. private static _PivotPostMultiplyPivotMatrix;
  50567. /** @hidden */
  50568. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  50569. /** @hidden */
  50570. static _RestorePivotPoint(mesh: AbstractMesh): void;
  50571. }
  50572. }
  50573. declare module BABYLON {
  50574. /**
  50575. * Class containing static functions to help procedurally build meshes
  50576. */
  50577. export class PlaneBuilder {
  50578. /**
  50579. * Creates a plane mesh
  50580. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50581. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50582. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50583. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50584. * * 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
  50585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50586. * @param name defines the name of the mesh
  50587. * @param options defines the options used to create the mesh
  50588. * @param scene defines the hosting scene
  50589. * @returns the plane mesh
  50590. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50591. */
  50592. static CreatePlane(name: string, options: {
  50593. size?: number;
  50594. width?: number;
  50595. height?: number;
  50596. sideOrientation?: number;
  50597. frontUVs?: Vector4;
  50598. backUVs?: Vector4;
  50599. updatable?: boolean;
  50600. sourcePlane?: Plane;
  50601. }, scene?: Nullable<Scene>): Mesh;
  50602. }
  50603. }
  50604. declare module BABYLON {
  50605. /**
  50606. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  50607. */
  50608. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  50609. private static _AnyMouseID;
  50610. /**
  50611. * Abstract mesh the behavior is set on
  50612. */
  50613. attachedNode: AbstractMesh;
  50614. private _dragPlane;
  50615. private _scene;
  50616. private _pointerObserver;
  50617. private _beforeRenderObserver;
  50618. private static _planeScene;
  50619. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  50620. /**
  50621. * 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)
  50622. */
  50623. maxDragAngle: number;
  50624. /**
  50625. * @hidden
  50626. */
  50627. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  50628. /**
  50629. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  50630. */
  50631. currentDraggingPointerID: number;
  50632. /**
  50633. * The last position where the pointer hit the drag plane in world space
  50634. */
  50635. lastDragPosition: Vector3;
  50636. /**
  50637. * If the behavior is currently in a dragging state
  50638. */
  50639. dragging: boolean;
  50640. /**
  50641. * 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)
  50642. */
  50643. dragDeltaRatio: number;
  50644. /**
  50645. * If the drag plane orientation should be updated during the dragging (Default: true)
  50646. */
  50647. updateDragPlane: boolean;
  50648. private _debugMode;
  50649. private _moving;
  50650. /**
  50651. * Fires each time the attached mesh is dragged with the pointer
  50652. * * delta between last drag position and current drag position in world space
  50653. * * dragDistance along the drag axis
  50654. * * dragPlaneNormal normal of the current drag plane used during the drag
  50655. * * dragPlanePoint in world space where the drag intersects the drag plane
  50656. */
  50657. onDragObservable: Observable<{
  50658. delta: Vector3;
  50659. dragPlanePoint: Vector3;
  50660. dragPlaneNormal: Vector3;
  50661. dragDistance: number;
  50662. pointerId: number;
  50663. }>;
  50664. /**
  50665. * Fires each time a drag begins (eg. mouse down on mesh)
  50666. */
  50667. onDragStartObservable: Observable<{
  50668. dragPlanePoint: Vector3;
  50669. pointerId: number;
  50670. }>;
  50671. /**
  50672. * Fires each time a drag ends (eg. mouse release after drag)
  50673. */
  50674. onDragEndObservable: Observable<{
  50675. dragPlanePoint: Vector3;
  50676. pointerId: number;
  50677. }>;
  50678. /**
  50679. * If the attached mesh should be moved when dragged
  50680. */
  50681. moveAttached: boolean;
  50682. /**
  50683. * If the drag behavior will react to drag events (Default: true)
  50684. */
  50685. enabled: boolean;
  50686. /**
  50687. * If pointer events should start and release the drag (Default: true)
  50688. */
  50689. startAndReleaseDragOnPointerEvents: boolean;
  50690. /**
  50691. * If camera controls should be detached during the drag
  50692. */
  50693. detachCameraControls: boolean;
  50694. /**
  50695. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  50696. */
  50697. useObjectOrientationForDragging: boolean;
  50698. private _options;
  50699. /**
  50700. * Gets the options used by the behavior
  50701. */
  50702. get options(): {
  50703. dragAxis?: Vector3;
  50704. dragPlaneNormal?: Vector3;
  50705. };
  50706. /**
  50707. * Sets the options used by the behavior
  50708. */
  50709. set options(options: {
  50710. dragAxis?: Vector3;
  50711. dragPlaneNormal?: Vector3;
  50712. });
  50713. /**
  50714. * Creates a pointer drag behavior that can be attached to a mesh
  50715. * @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)
  50716. */
  50717. constructor(options?: {
  50718. dragAxis?: Vector3;
  50719. dragPlaneNormal?: Vector3;
  50720. });
  50721. /**
  50722. * Predicate to determine if it is valid to move the object to a new position when it is moved
  50723. */
  50724. validateDrag: (targetPosition: Vector3) => boolean;
  50725. /**
  50726. * The name of the behavior
  50727. */
  50728. get name(): string;
  50729. /**
  50730. * Initializes the behavior
  50731. */
  50732. init(): void;
  50733. private _tmpVector;
  50734. private _alternatePickedPoint;
  50735. private _worldDragAxis;
  50736. private _targetPosition;
  50737. private _attachedToElement;
  50738. /**
  50739. * Attaches the drag behavior the passed in mesh
  50740. * @param ownerNode The mesh that will be dragged around once attached
  50741. * @param predicate Predicate to use for pick filtering
  50742. */
  50743. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  50744. /**
  50745. * Force release the drag action by code.
  50746. */
  50747. releaseDrag(): void;
  50748. private _startDragRay;
  50749. private _lastPointerRay;
  50750. /**
  50751. * Simulates the start of a pointer drag event on the behavior
  50752. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  50753. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  50754. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  50755. */
  50756. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  50757. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  50758. private _dragDelta;
  50759. protected _moveDrag(ray: Ray): void;
  50760. private _pickWithRayOnDragPlane;
  50761. private _pointA;
  50762. private _pointC;
  50763. private _localAxis;
  50764. private _lookAt;
  50765. private _updateDragPlanePosition;
  50766. /**
  50767. * Detaches the behavior from the mesh
  50768. */
  50769. detach(): void;
  50770. }
  50771. }
  50772. declare module BABYLON {
  50773. /**
  50774. * A behavior that when attached to a mesh will allow the mesh to be scaled
  50775. */
  50776. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  50777. private _dragBehaviorA;
  50778. private _dragBehaviorB;
  50779. private _startDistance;
  50780. private _initialScale;
  50781. private _targetScale;
  50782. private _ownerNode;
  50783. private _sceneRenderObserver;
  50784. /**
  50785. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  50786. */
  50787. constructor();
  50788. /**
  50789. * The name of the behavior
  50790. */
  50791. get name(): string;
  50792. /**
  50793. * Initializes the behavior
  50794. */
  50795. init(): void;
  50796. private _getCurrentDistance;
  50797. /**
  50798. * Attaches the scale behavior the passed in mesh
  50799. * @param ownerNode The mesh that will be scaled around once attached
  50800. */
  50801. attach(ownerNode: Mesh): void;
  50802. /**
  50803. * Detaches the behavior from the mesh
  50804. */
  50805. detach(): void;
  50806. }
  50807. }
  50808. declare module BABYLON {
  50809. /**
  50810. * 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
  50811. */
  50812. export class SixDofDragBehavior implements Behavior<Mesh> {
  50813. private static _virtualScene;
  50814. private _ownerNode;
  50815. private _sceneRenderObserver;
  50816. private _scene;
  50817. private _targetPosition;
  50818. private _virtualOriginMesh;
  50819. private _virtualDragMesh;
  50820. private _pointerObserver;
  50821. private _moving;
  50822. private _startingOrientation;
  50823. private _attachedToElement;
  50824. /**
  50825. * 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)
  50826. */
  50827. private zDragFactor;
  50828. /**
  50829. * If the object should rotate to face the drag origin
  50830. */
  50831. rotateDraggedObject: boolean;
  50832. /**
  50833. * If the behavior is currently in a dragging state
  50834. */
  50835. dragging: boolean;
  50836. /**
  50837. * 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)
  50838. */
  50839. dragDeltaRatio: number;
  50840. /**
  50841. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  50842. */
  50843. currentDraggingPointerID: number;
  50844. /**
  50845. * If camera controls should be detached during the drag
  50846. */
  50847. detachCameraControls: boolean;
  50848. /**
  50849. * Fires each time a drag starts
  50850. */
  50851. onDragStartObservable: Observable<{}>;
  50852. /**
  50853. * Fires each time a drag happens
  50854. */
  50855. onDragObservable: Observable<void>;
  50856. /**
  50857. * Fires each time a drag ends (eg. mouse release after drag)
  50858. */
  50859. onDragEndObservable: Observable<{}>;
  50860. /**
  50861. * 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
  50862. */
  50863. constructor();
  50864. /**
  50865. * The name of the behavior
  50866. */
  50867. get name(): string;
  50868. /**
  50869. * Initializes the behavior
  50870. */
  50871. init(): void;
  50872. /**
  50873. * In the case of multiple active cameras, the cameraToUseForPointers should be used if set instead of active camera
  50874. */
  50875. private get _pointerCamera();
  50876. /**
  50877. * Attaches the scale behavior the passed in mesh
  50878. * @param ownerNode The mesh that will be scaled around once attached
  50879. */
  50880. attach(ownerNode: Mesh): void;
  50881. /**
  50882. * Detaches the behavior from the mesh
  50883. */
  50884. detach(): void;
  50885. }
  50886. }
  50887. declare module BABYLON {
  50888. /**
  50889. * Class used to apply inverse kinematics to bones
  50890. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  50891. */
  50892. export class BoneIKController {
  50893. private static _tmpVecs;
  50894. private static _tmpQuat;
  50895. private static _tmpMats;
  50896. /**
  50897. * Gets or sets the target mesh
  50898. */
  50899. targetMesh: AbstractMesh;
  50900. /** Gets or sets the mesh used as pole */
  50901. poleTargetMesh: AbstractMesh;
  50902. /**
  50903. * Gets or sets the bone used as pole
  50904. */
  50905. poleTargetBone: Nullable<Bone>;
  50906. /**
  50907. * Gets or sets the target position
  50908. */
  50909. targetPosition: Vector3;
  50910. /**
  50911. * Gets or sets the pole target position
  50912. */
  50913. poleTargetPosition: Vector3;
  50914. /**
  50915. * Gets or sets the pole target local offset
  50916. */
  50917. poleTargetLocalOffset: Vector3;
  50918. /**
  50919. * Gets or sets the pole angle
  50920. */
  50921. poleAngle: number;
  50922. /**
  50923. * Gets or sets the mesh associated with the controller
  50924. */
  50925. mesh: AbstractMesh;
  50926. /**
  50927. * 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)
  50928. */
  50929. slerpAmount: number;
  50930. private _bone1Quat;
  50931. private _bone1Mat;
  50932. private _bone2Ang;
  50933. private _bone1;
  50934. private _bone2;
  50935. private _bone1Length;
  50936. private _bone2Length;
  50937. private _maxAngle;
  50938. private _maxReach;
  50939. private _rightHandedSystem;
  50940. private _bendAxis;
  50941. private _slerping;
  50942. private _adjustRoll;
  50943. /**
  50944. * Gets or sets maximum allowed angle
  50945. */
  50946. get maxAngle(): number;
  50947. set maxAngle(value: number);
  50948. /**
  50949. * Creates a new BoneIKController
  50950. * @param mesh defines the mesh to control
  50951. * @param bone defines the bone to control
  50952. * @param options defines options to set up the controller
  50953. */
  50954. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  50955. targetMesh?: AbstractMesh;
  50956. poleTargetMesh?: AbstractMesh;
  50957. poleTargetBone?: Bone;
  50958. poleTargetLocalOffset?: Vector3;
  50959. poleAngle?: number;
  50960. bendAxis?: Vector3;
  50961. maxAngle?: number;
  50962. slerpAmount?: number;
  50963. });
  50964. private _setMaxAngle;
  50965. /**
  50966. * Force the controller to update the bones
  50967. */
  50968. update(): void;
  50969. }
  50970. }
  50971. declare module BABYLON {
  50972. /**
  50973. * Class used to make a bone look toward a point in space
  50974. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  50975. */
  50976. export class BoneLookController {
  50977. private static _tmpVecs;
  50978. private static _tmpQuat;
  50979. private static _tmpMats;
  50980. /**
  50981. * The target Vector3 that the bone will look at
  50982. */
  50983. target: Vector3;
  50984. /**
  50985. * The mesh that the bone is attached to
  50986. */
  50987. mesh: AbstractMesh;
  50988. /**
  50989. * The bone that will be looking to the target
  50990. */
  50991. bone: Bone;
  50992. /**
  50993. * The up axis of the coordinate system that is used when the bone is rotated
  50994. */
  50995. upAxis: Vector3;
  50996. /**
  50997. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  50998. */
  50999. upAxisSpace: Space;
  51000. /**
  51001. * Used to make an adjustment to the yaw of the bone
  51002. */
  51003. adjustYaw: number;
  51004. /**
  51005. * Used to make an adjustment to the pitch of the bone
  51006. */
  51007. adjustPitch: number;
  51008. /**
  51009. * Used to make an adjustment to the roll of the bone
  51010. */
  51011. adjustRoll: number;
  51012. /**
  51013. * 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)
  51014. */
  51015. slerpAmount: number;
  51016. private _minYaw;
  51017. private _maxYaw;
  51018. private _minPitch;
  51019. private _maxPitch;
  51020. private _minYawSin;
  51021. private _minYawCos;
  51022. private _maxYawSin;
  51023. private _maxYawCos;
  51024. private _midYawConstraint;
  51025. private _minPitchTan;
  51026. private _maxPitchTan;
  51027. private _boneQuat;
  51028. private _slerping;
  51029. private _transformYawPitch;
  51030. private _transformYawPitchInv;
  51031. private _firstFrameSkipped;
  51032. private _yawRange;
  51033. private _fowardAxis;
  51034. /**
  51035. * Gets or sets the minimum yaw angle that the bone can look to
  51036. */
  51037. get minYaw(): number;
  51038. set minYaw(value: number);
  51039. /**
  51040. * Gets or sets the maximum yaw angle that the bone can look to
  51041. */
  51042. get maxYaw(): number;
  51043. set maxYaw(value: number);
  51044. /**
  51045. * Gets or sets the minimum pitch angle that the bone can look to
  51046. */
  51047. get minPitch(): number;
  51048. set minPitch(value: number);
  51049. /**
  51050. * Gets or sets the maximum pitch angle that the bone can look to
  51051. */
  51052. get maxPitch(): number;
  51053. set maxPitch(value: number);
  51054. /**
  51055. * Create a BoneLookController
  51056. * @param mesh the mesh that the bone belongs to
  51057. * @param bone the bone that will be looking to the target
  51058. * @param target the target Vector3 to look at
  51059. * @param options optional settings:
  51060. * * maxYaw: the maximum angle the bone will yaw to
  51061. * * minYaw: the minimum angle the bone will yaw to
  51062. * * maxPitch: the maximum angle the bone will pitch to
  51063. * * minPitch: the minimum angle the bone will yaw to
  51064. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  51065. * * upAxis: the up axis of the coordinate system
  51066. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  51067. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  51068. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  51069. * * adjustYaw: used to make an adjustment to the yaw of the bone
  51070. * * adjustPitch: used to make an adjustment to the pitch of the bone
  51071. * * adjustRoll: used to make an adjustment to the roll of the bone
  51072. **/
  51073. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  51074. maxYaw?: number;
  51075. minYaw?: number;
  51076. maxPitch?: number;
  51077. minPitch?: number;
  51078. slerpAmount?: number;
  51079. upAxis?: Vector3;
  51080. upAxisSpace?: Space;
  51081. yawAxis?: Vector3;
  51082. pitchAxis?: Vector3;
  51083. adjustYaw?: number;
  51084. adjustPitch?: number;
  51085. adjustRoll?: number;
  51086. });
  51087. /**
  51088. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  51089. */
  51090. update(): void;
  51091. private _getAngleDiff;
  51092. private _getAngleBetween;
  51093. private _isAngleBetween;
  51094. }
  51095. }
  51096. declare module BABYLON {
  51097. /**
  51098. * Manage the gamepad inputs to control an arc rotate camera.
  51099. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51100. */
  51101. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  51102. /**
  51103. * Defines the camera the input is attached to.
  51104. */
  51105. camera: ArcRotateCamera;
  51106. /**
  51107. * Defines the gamepad the input is gathering event from.
  51108. */
  51109. gamepad: Nullable<Gamepad>;
  51110. /**
  51111. * Defines the gamepad rotation sensiblity.
  51112. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  51113. */
  51114. gamepadRotationSensibility: number;
  51115. /**
  51116. * Defines the gamepad move sensiblity.
  51117. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  51118. */
  51119. gamepadMoveSensibility: number;
  51120. private _yAxisScale;
  51121. /**
  51122. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  51123. */
  51124. get invertYAxis(): boolean;
  51125. set invertYAxis(value: boolean);
  51126. private _onGamepadConnectedObserver;
  51127. private _onGamepadDisconnectedObserver;
  51128. /**
  51129. * Attach the input controls to a specific dom element to get the input from.
  51130. */
  51131. attachControl(): void;
  51132. /**
  51133. * Detach the current controls from the specified dom element.
  51134. */
  51135. detachControl(): void;
  51136. /**
  51137. * Update the current camera state depending on the inputs that have been used this frame.
  51138. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51139. */
  51140. checkInputs(): void;
  51141. /**
  51142. * Gets the class name of the current intput.
  51143. * @returns the class name
  51144. */
  51145. getClassName(): string;
  51146. /**
  51147. * Get the friendly name associated with the input class.
  51148. * @returns the input friendly name
  51149. */
  51150. getSimpleName(): string;
  51151. }
  51152. }
  51153. declare module BABYLON {
  51154. interface ArcRotateCameraInputsManager {
  51155. /**
  51156. * Add orientation input support to the input manager.
  51157. * @returns the current input manager
  51158. */
  51159. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  51160. }
  51161. /**
  51162. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  51163. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51164. */
  51165. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  51166. /**
  51167. * Defines the camera the input is attached to.
  51168. */
  51169. camera: ArcRotateCamera;
  51170. /**
  51171. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  51172. */
  51173. alphaCorrection: number;
  51174. /**
  51175. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  51176. */
  51177. gammaCorrection: number;
  51178. private _alpha;
  51179. private _gamma;
  51180. private _dirty;
  51181. private _deviceOrientationHandler;
  51182. /**
  51183. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  51184. */
  51185. constructor();
  51186. /**
  51187. * Attach the input controls to a specific dom element to get the input from.
  51188. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51189. */
  51190. attachControl(noPreventDefault?: boolean): void;
  51191. /** @hidden */
  51192. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  51193. /**
  51194. * Update the current camera state depending on the inputs that have been used this frame.
  51195. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51196. */
  51197. checkInputs(): void;
  51198. /**
  51199. * Detach the current controls from the specified dom element.
  51200. */
  51201. detachControl(): void;
  51202. /**
  51203. * Gets the class name of the current input.
  51204. * @returns the class name
  51205. */
  51206. getClassName(): string;
  51207. /**
  51208. * Get the friendly name associated with the input class.
  51209. * @returns the input friendly name
  51210. */
  51211. getSimpleName(): string;
  51212. }
  51213. }
  51214. declare module BABYLON {
  51215. /**
  51216. * Listen to mouse events to control the camera.
  51217. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51218. */
  51219. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  51220. /**
  51221. * Defines the camera the input is attached to.
  51222. */
  51223. camera: FlyCamera;
  51224. /**
  51225. * Defines if touch is enabled. (Default is true.)
  51226. */
  51227. touchEnabled: boolean;
  51228. /**
  51229. * Defines the buttons associated with the input to handle camera rotation.
  51230. */
  51231. buttons: number[];
  51232. /**
  51233. * Assign buttons for Yaw control.
  51234. */
  51235. buttonsYaw: number[];
  51236. /**
  51237. * Assign buttons for Pitch control.
  51238. */
  51239. buttonsPitch: number[];
  51240. /**
  51241. * Assign buttons for Roll control.
  51242. */
  51243. buttonsRoll: number[];
  51244. /**
  51245. * Detect if any button is being pressed while mouse is moved.
  51246. * -1 = Mouse locked.
  51247. * 0 = Left button.
  51248. * 1 = Middle Button.
  51249. * 2 = Right Button.
  51250. */
  51251. activeButton: number;
  51252. /**
  51253. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  51254. * Higher values reduce its sensitivity.
  51255. */
  51256. angularSensibility: number;
  51257. private _observer;
  51258. private _rollObserver;
  51259. private previousPosition;
  51260. private noPreventDefault;
  51261. private element;
  51262. /**
  51263. * Listen to mouse events to control the camera.
  51264. * @param touchEnabled Define if touch is enabled. (Default is true.)
  51265. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51266. */
  51267. constructor(touchEnabled?: boolean);
  51268. /**
  51269. * Attach the mouse control to the HTML DOM element.
  51270. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  51271. */
  51272. attachControl(noPreventDefault?: boolean): void;
  51273. /**
  51274. * Detach the current controls from the specified dom element.
  51275. */
  51276. detachControl(): void;
  51277. /**
  51278. * Gets the class name of the current input.
  51279. * @returns the class name.
  51280. */
  51281. getClassName(): string;
  51282. /**
  51283. * Get the friendly name associated with the input class.
  51284. * @returns the input's friendly name.
  51285. */
  51286. getSimpleName(): string;
  51287. private _pointerInput;
  51288. private _onMouseMove;
  51289. /**
  51290. * Rotate camera by mouse offset.
  51291. */
  51292. private rotateCamera;
  51293. }
  51294. }
  51295. declare module BABYLON {
  51296. /**
  51297. * Default Inputs manager for the FlyCamera.
  51298. * It groups all the default supported inputs for ease of use.
  51299. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51300. */
  51301. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  51302. /**
  51303. * Instantiates a new FlyCameraInputsManager.
  51304. * @param camera Defines the camera the inputs belong to.
  51305. */
  51306. constructor(camera: FlyCamera);
  51307. /**
  51308. * Add keyboard input support to the input manager.
  51309. * @returns the new FlyCameraKeyboardMoveInput().
  51310. */
  51311. addKeyboard(): FlyCameraInputsManager;
  51312. /**
  51313. * Add mouse input support to the input manager.
  51314. * @param touchEnabled Enable touch screen support.
  51315. * @returns the new FlyCameraMouseInput().
  51316. */
  51317. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  51318. }
  51319. }
  51320. declare module BABYLON {
  51321. /**
  51322. * This is a flying camera, designed for 3D movement and rotation in all directions,
  51323. * such as in a 3D Space Shooter or a Flight Simulator.
  51324. */
  51325. export class FlyCamera extends TargetCamera {
  51326. /**
  51327. * Define the collision ellipsoid of the camera.
  51328. * This is helpful for simulating a camera body, like a player's body.
  51329. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  51330. */
  51331. ellipsoid: Vector3;
  51332. /**
  51333. * Define an offset for the position of the ellipsoid around the camera.
  51334. * This can be helpful if the camera is attached away from the player's body center,
  51335. * such as at its head.
  51336. */
  51337. ellipsoidOffset: Vector3;
  51338. /**
  51339. * Enable or disable collisions of the camera with the rest of the scene objects.
  51340. */
  51341. checkCollisions: boolean;
  51342. /**
  51343. * Enable or disable gravity on the camera.
  51344. */
  51345. applyGravity: boolean;
  51346. /**
  51347. * Define the current direction the camera is moving to.
  51348. */
  51349. cameraDirection: Vector3;
  51350. /**
  51351. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  51352. * This overrides and empties cameraRotation.
  51353. */
  51354. rotationQuaternion: Quaternion;
  51355. /**
  51356. * Track Roll to maintain the wanted Rolling when looking around.
  51357. */
  51358. _trackRoll: number;
  51359. /**
  51360. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  51361. */
  51362. rollCorrect: number;
  51363. /**
  51364. * Mimic a banked turn, Rolling the camera when Yawing.
  51365. * It's recommended to use rollCorrect = 10 for faster banking correction.
  51366. */
  51367. bankedTurn: boolean;
  51368. /**
  51369. * Limit in radians for how much Roll banking will add. (Default: 90°)
  51370. */
  51371. bankedTurnLimit: number;
  51372. /**
  51373. * Value of 0 disables the banked Roll.
  51374. * Value of 1 is equal to the Yaw angle in radians.
  51375. */
  51376. bankedTurnMultiplier: number;
  51377. /**
  51378. * The inputs manager loads all the input sources, such as keyboard and mouse.
  51379. */
  51380. inputs: FlyCameraInputsManager;
  51381. /**
  51382. * Gets the input sensibility for mouse input.
  51383. * Higher values reduce sensitivity.
  51384. */
  51385. get angularSensibility(): number;
  51386. /**
  51387. * Sets the input sensibility for a mouse input.
  51388. * Higher values reduce sensitivity.
  51389. */
  51390. set angularSensibility(value: number);
  51391. /**
  51392. * Get the keys for camera movement forward.
  51393. */
  51394. get keysForward(): number[];
  51395. /**
  51396. * Set the keys for camera movement forward.
  51397. */
  51398. set keysForward(value: number[]);
  51399. /**
  51400. * Get the keys for camera movement backward.
  51401. */
  51402. get keysBackward(): number[];
  51403. set keysBackward(value: number[]);
  51404. /**
  51405. * Get the keys for camera movement up.
  51406. */
  51407. get keysUp(): number[];
  51408. /**
  51409. * Set the keys for camera movement up.
  51410. */
  51411. set keysUp(value: number[]);
  51412. /**
  51413. * Get the keys for camera movement down.
  51414. */
  51415. get keysDown(): number[];
  51416. /**
  51417. * Set the keys for camera movement down.
  51418. */
  51419. set keysDown(value: number[]);
  51420. /**
  51421. * Get the keys for camera movement left.
  51422. */
  51423. get keysLeft(): number[];
  51424. /**
  51425. * Set the keys for camera movement left.
  51426. */
  51427. set keysLeft(value: number[]);
  51428. /**
  51429. * Set the keys for camera movement right.
  51430. */
  51431. get keysRight(): number[];
  51432. /**
  51433. * Set the keys for camera movement right.
  51434. */
  51435. set keysRight(value: number[]);
  51436. /**
  51437. * Event raised when the camera collides with a mesh in the scene.
  51438. */
  51439. onCollide: (collidedMesh: AbstractMesh) => void;
  51440. private _collider;
  51441. private _needMoveForGravity;
  51442. private _oldPosition;
  51443. private _diffPosition;
  51444. private _newPosition;
  51445. /** @hidden */
  51446. _localDirection: Vector3;
  51447. /** @hidden */
  51448. _transformedDirection: Vector3;
  51449. /**
  51450. * Instantiates a FlyCamera.
  51451. * This is a flying camera, designed for 3D movement and rotation in all directions,
  51452. * such as in a 3D Space Shooter or a Flight Simulator.
  51453. * @param name Define the name of the camera in the scene.
  51454. * @param position Define the starting position of the camera in the scene.
  51455. * @param scene Define the scene the camera belongs to.
  51456. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active, if no other camera has been defined as active.
  51457. */
  51458. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  51459. /**
  51460. * Attach the input controls to a specific dom element to get the input from.
  51461. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51462. */
  51463. attachControl(noPreventDefault?: boolean): void;
  51464. /**
  51465. * Detach a control from the HTML DOM element.
  51466. * The camera will stop reacting to that input.
  51467. */
  51468. detachControl(): void;
  51469. private _collisionMask;
  51470. /**
  51471. * Get the mask that the camera ignores in collision events.
  51472. */
  51473. get collisionMask(): number;
  51474. /**
  51475. * Set the mask that the camera ignores in collision events.
  51476. */
  51477. set collisionMask(mask: number);
  51478. /** @hidden */
  51479. _collideWithWorld(displacement: Vector3): void;
  51480. /** @hidden */
  51481. private _onCollisionPositionChange;
  51482. /** @hidden */
  51483. _checkInputs(): void;
  51484. /** @hidden */
  51485. _decideIfNeedsToMove(): boolean;
  51486. /** @hidden */
  51487. _updatePosition(): void;
  51488. /**
  51489. * Restore the Roll to its target value at the rate specified.
  51490. * @param rate - Higher means slower restoring.
  51491. * @hidden
  51492. */
  51493. restoreRoll(rate: number): void;
  51494. /**
  51495. * Destroy the camera and release the current resources held by it.
  51496. */
  51497. dispose(): void;
  51498. /**
  51499. * Get the current object class name.
  51500. * @returns the class name.
  51501. */
  51502. getClassName(): string;
  51503. }
  51504. }
  51505. declare module BABYLON {
  51506. /**
  51507. * Listen to keyboard events to control the camera.
  51508. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51509. */
  51510. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  51511. /**
  51512. * Defines the camera the input is attached to.
  51513. */
  51514. camera: FlyCamera;
  51515. /**
  51516. * The list of keyboard keys used to control the forward move of the camera.
  51517. */
  51518. keysForward: number[];
  51519. /**
  51520. * The list of keyboard keys used to control the backward move of the camera.
  51521. */
  51522. keysBackward: number[];
  51523. /**
  51524. * The list of keyboard keys used to control the forward move of the camera.
  51525. */
  51526. keysUp: number[];
  51527. /**
  51528. * The list of keyboard keys used to control the backward move of the camera.
  51529. */
  51530. keysDown: number[];
  51531. /**
  51532. * The list of keyboard keys used to control the right strafe move of the camera.
  51533. */
  51534. keysRight: number[];
  51535. /**
  51536. * The list of keyboard keys used to control the left strafe move of the camera.
  51537. */
  51538. keysLeft: number[];
  51539. private _keys;
  51540. private _onCanvasBlurObserver;
  51541. private _onKeyboardObserver;
  51542. private _engine;
  51543. private _scene;
  51544. /**
  51545. * Attach the input controls to a specific dom element to get the input from.
  51546. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51547. */
  51548. attachControl(noPreventDefault?: boolean): void;
  51549. /**
  51550. * Detach the current controls from the specified dom element.
  51551. */
  51552. detachControl(): void;
  51553. /**
  51554. * Gets the class name of the current intput.
  51555. * @returns the class name
  51556. */
  51557. getClassName(): string;
  51558. /** @hidden */
  51559. _onLostFocus(e: FocusEvent): void;
  51560. /**
  51561. * Get the friendly name associated with the input class.
  51562. * @returns the input friendly name
  51563. */
  51564. getSimpleName(): string;
  51565. /**
  51566. * Update the current camera state depending on the inputs that have been used this frame.
  51567. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51568. */
  51569. checkInputs(): void;
  51570. }
  51571. }
  51572. declare module BABYLON {
  51573. /**
  51574. * Manage the mouse wheel inputs to control a follow camera.
  51575. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51576. */
  51577. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  51578. /**
  51579. * Defines the camera the input is attached to.
  51580. */
  51581. camera: FollowCamera;
  51582. /**
  51583. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  51584. */
  51585. axisControlRadius: boolean;
  51586. /**
  51587. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  51588. */
  51589. axisControlHeight: boolean;
  51590. /**
  51591. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  51592. */
  51593. axisControlRotation: boolean;
  51594. /**
  51595. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  51596. * relation to mouseWheel events.
  51597. */
  51598. wheelPrecision: number;
  51599. /**
  51600. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  51601. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  51602. */
  51603. wheelDeltaPercentage: number;
  51604. private _wheel;
  51605. private _observer;
  51606. /**
  51607. * Attach the input controls to a specific dom element to get the input from.
  51608. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51609. */
  51610. attachControl(noPreventDefault?: boolean): void;
  51611. /**
  51612. * Detach the current controls from the specified dom element.
  51613. */
  51614. detachControl(): void;
  51615. /**
  51616. * Gets the class name of the current input.
  51617. * @returns the class name
  51618. */
  51619. getClassName(): string;
  51620. /**
  51621. * Get the friendly name associated with the input class.
  51622. * @returns the input friendly name
  51623. */
  51624. getSimpleName(): string;
  51625. }
  51626. }
  51627. declare module BABYLON {
  51628. /**
  51629. * Manage the pointers inputs to control an follow camera.
  51630. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51631. */
  51632. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  51633. /**
  51634. * Defines the camera the input is attached to.
  51635. */
  51636. camera: FollowCamera;
  51637. /**
  51638. * Gets the class name of the current input.
  51639. * @returns the class name
  51640. */
  51641. getClassName(): string;
  51642. /**
  51643. * Defines the pointer angular sensibility along the X axis or how fast is
  51644. * the camera rotating.
  51645. * A negative number will reverse the axis direction.
  51646. */
  51647. angularSensibilityX: number;
  51648. /**
  51649. * Defines the pointer angular sensibility along the Y axis or how fast is
  51650. * the camera rotating.
  51651. * A negative number will reverse the axis direction.
  51652. */
  51653. angularSensibilityY: number;
  51654. /**
  51655. * Defines the pointer pinch precision or how fast is the camera zooming.
  51656. * A negative number will reverse the axis direction.
  51657. */
  51658. pinchPrecision: number;
  51659. /**
  51660. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  51661. * from 0.
  51662. * It defines the percentage of current camera.radius to use as delta when
  51663. * pinch zoom is used.
  51664. */
  51665. pinchDeltaPercentage: number;
  51666. /**
  51667. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  51668. */
  51669. axisXControlRadius: boolean;
  51670. /**
  51671. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  51672. */
  51673. axisXControlHeight: boolean;
  51674. /**
  51675. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  51676. */
  51677. axisXControlRotation: boolean;
  51678. /**
  51679. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  51680. */
  51681. axisYControlRadius: boolean;
  51682. /**
  51683. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  51684. */
  51685. axisYControlHeight: boolean;
  51686. /**
  51687. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  51688. */
  51689. axisYControlRotation: boolean;
  51690. /**
  51691. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  51692. */
  51693. axisPinchControlRadius: boolean;
  51694. /**
  51695. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  51696. */
  51697. axisPinchControlHeight: boolean;
  51698. /**
  51699. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  51700. */
  51701. axisPinchControlRotation: boolean;
  51702. /**
  51703. * Log error messages if basic misconfiguration has occurred.
  51704. */
  51705. warningEnable: boolean;
  51706. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  51707. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  51708. private _warningCounter;
  51709. private _warning;
  51710. }
  51711. }
  51712. declare module BABYLON {
  51713. /**
  51714. * Default Inputs manager for the FollowCamera.
  51715. * It groups all the default supported inputs for ease of use.
  51716. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51717. */
  51718. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  51719. /**
  51720. * Instantiates a new FollowCameraInputsManager.
  51721. * @param camera Defines the camera the inputs belong to
  51722. */
  51723. constructor(camera: FollowCamera);
  51724. /**
  51725. * Add keyboard input support to the input manager.
  51726. * @returns the current input manager
  51727. */
  51728. addKeyboard(): FollowCameraInputsManager;
  51729. /**
  51730. * Add mouse wheel input support to the input manager.
  51731. * @returns the current input manager
  51732. */
  51733. addMouseWheel(): FollowCameraInputsManager;
  51734. /**
  51735. * Add pointers input support to the input manager.
  51736. * @returns the current input manager
  51737. */
  51738. addPointers(): FollowCameraInputsManager;
  51739. /**
  51740. * Add orientation input support to the input manager.
  51741. * @returns the current input manager
  51742. */
  51743. addVRDeviceOrientation(): FollowCameraInputsManager;
  51744. }
  51745. }
  51746. declare module BABYLON {
  51747. /**
  51748. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  51749. * an arc rotate version arcFollowCamera are available.
  51750. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51751. */
  51752. export class FollowCamera extends TargetCamera {
  51753. /**
  51754. * Distance the follow camera should follow an object at
  51755. */
  51756. radius: number;
  51757. /**
  51758. * Minimum allowed distance of the camera to the axis of rotation
  51759. * (The camera can not get closer).
  51760. * This can help limiting how the Camera is able to move in the scene.
  51761. */
  51762. lowerRadiusLimit: Nullable<number>;
  51763. /**
  51764. * Maximum allowed distance of the camera to the axis of rotation
  51765. * (The camera can not get further).
  51766. * This can help limiting how the Camera is able to move in the scene.
  51767. */
  51768. upperRadiusLimit: Nullable<number>;
  51769. /**
  51770. * Define a rotation offset between the camera and the object it follows
  51771. */
  51772. rotationOffset: number;
  51773. /**
  51774. * Minimum allowed angle to camera position relative to target object.
  51775. * This can help limiting how the Camera is able to move in the scene.
  51776. */
  51777. lowerRotationOffsetLimit: Nullable<number>;
  51778. /**
  51779. * Maximum allowed angle to camera position relative to target object.
  51780. * This can help limiting how the Camera is able to move in the scene.
  51781. */
  51782. upperRotationOffsetLimit: Nullable<number>;
  51783. /**
  51784. * Define a height offset between the camera and the object it follows.
  51785. * It can help following an object from the top (like a car chasing a plane)
  51786. */
  51787. heightOffset: number;
  51788. /**
  51789. * Minimum allowed height of camera position relative to target object.
  51790. * This can help limiting how the Camera is able to move in the scene.
  51791. */
  51792. lowerHeightOffsetLimit: Nullable<number>;
  51793. /**
  51794. * Maximum allowed height of camera position relative to target object.
  51795. * This can help limiting how the Camera is able to move in the scene.
  51796. */
  51797. upperHeightOffsetLimit: Nullable<number>;
  51798. /**
  51799. * Define how fast the camera can accelerate to follow it s target.
  51800. */
  51801. cameraAcceleration: number;
  51802. /**
  51803. * Define the speed limit of the camera following an object.
  51804. */
  51805. maxCameraSpeed: number;
  51806. /**
  51807. * Define the target of the camera.
  51808. */
  51809. lockedTarget: Nullable<AbstractMesh>;
  51810. /**
  51811. * Defines the input associated with the camera.
  51812. */
  51813. inputs: FollowCameraInputsManager;
  51814. /**
  51815. * Instantiates the follow camera.
  51816. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51817. * @param name Define the name of the camera in the scene
  51818. * @param position Define the position of the camera
  51819. * @param scene Define the scene the camera belong to
  51820. * @param lockedTarget Define the target of the camera
  51821. */
  51822. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  51823. private _follow;
  51824. /**
  51825. * Attach the input controls to a specific dom element to get the input from.
  51826. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51827. */
  51828. attachControl(noPreventDefault?: boolean): void;
  51829. /**
  51830. * Detach the current controls from the specified dom element.
  51831. */
  51832. detachControl(): void;
  51833. /** @hidden */
  51834. _checkInputs(): void;
  51835. private _checkLimits;
  51836. /**
  51837. * Gets the camera class name.
  51838. * @returns the class name
  51839. */
  51840. getClassName(): string;
  51841. }
  51842. /**
  51843. * Arc Rotate version of the follow camera.
  51844. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  51845. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51846. */
  51847. export class ArcFollowCamera extends TargetCamera {
  51848. /** The longitudinal angle of the camera */
  51849. alpha: number;
  51850. /** The latitudinal angle of the camera */
  51851. beta: number;
  51852. /** The radius of the camera from its target */
  51853. radius: number;
  51854. private _cartesianCoordinates;
  51855. /** Define the camera target (the mesh it should follow) */
  51856. private _meshTarget;
  51857. /**
  51858. * Instantiates a new ArcFollowCamera
  51859. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51860. * @param name Define the name of the camera
  51861. * @param alpha Define the rotation angle of the camera around the longitudinal axis
  51862. * @param beta Define the rotation angle of the camera around the elevation axis
  51863. * @param radius Define the radius of the camera from its target point
  51864. * @param target Define the target of the camera
  51865. * @param scene Define the scene the camera belongs to
  51866. */
  51867. constructor(name: string,
  51868. /** The longitudinal angle of the camera */
  51869. alpha: number,
  51870. /** The latitudinal angle of the camera */
  51871. beta: number,
  51872. /** The radius of the camera from its target */
  51873. radius: number,
  51874. /** Define the camera target (the mesh it should follow) */
  51875. target: Nullable<AbstractMesh>, scene: Scene);
  51876. private _follow;
  51877. /** @hidden */
  51878. _checkInputs(): void;
  51879. /**
  51880. * Returns the class name of the object.
  51881. * It is mostly used internally for serialization purposes.
  51882. */
  51883. getClassName(): string;
  51884. }
  51885. }
  51886. declare module BABYLON {
  51887. /**
  51888. * Manage the keyboard inputs to control the movement of a follow camera.
  51889. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51890. */
  51891. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  51892. /**
  51893. * Defines the camera the input is attached to.
  51894. */
  51895. camera: FollowCamera;
  51896. /**
  51897. * Defines the list of key codes associated with the up action (increase heightOffset)
  51898. */
  51899. keysHeightOffsetIncr: number[];
  51900. /**
  51901. * Defines the list of key codes associated with the down action (decrease heightOffset)
  51902. */
  51903. keysHeightOffsetDecr: number[];
  51904. /**
  51905. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  51906. */
  51907. keysHeightOffsetModifierAlt: boolean;
  51908. /**
  51909. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  51910. */
  51911. keysHeightOffsetModifierCtrl: boolean;
  51912. /**
  51913. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  51914. */
  51915. keysHeightOffsetModifierShift: boolean;
  51916. /**
  51917. * Defines the list of key codes associated with the left action (increase rotationOffset)
  51918. */
  51919. keysRotationOffsetIncr: number[];
  51920. /**
  51921. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  51922. */
  51923. keysRotationOffsetDecr: number[];
  51924. /**
  51925. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  51926. */
  51927. keysRotationOffsetModifierAlt: boolean;
  51928. /**
  51929. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  51930. */
  51931. keysRotationOffsetModifierCtrl: boolean;
  51932. /**
  51933. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  51934. */
  51935. keysRotationOffsetModifierShift: boolean;
  51936. /**
  51937. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  51938. */
  51939. keysRadiusIncr: number[];
  51940. /**
  51941. * Defines the list of key codes associated with the zoom-out action (increase radius)
  51942. */
  51943. keysRadiusDecr: number[];
  51944. /**
  51945. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  51946. */
  51947. keysRadiusModifierAlt: boolean;
  51948. /**
  51949. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  51950. */
  51951. keysRadiusModifierCtrl: boolean;
  51952. /**
  51953. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  51954. */
  51955. keysRadiusModifierShift: boolean;
  51956. /**
  51957. * Defines the rate of change of heightOffset.
  51958. */
  51959. heightSensibility: number;
  51960. /**
  51961. * Defines the rate of change of rotationOffset.
  51962. */
  51963. rotationSensibility: number;
  51964. /**
  51965. * Defines the rate of change of radius.
  51966. */
  51967. radiusSensibility: number;
  51968. private _keys;
  51969. private _ctrlPressed;
  51970. private _altPressed;
  51971. private _shiftPressed;
  51972. private _onCanvasBlurObserver;
  51973. private _onKeyboardObserver;
  51974. private _engine;
  51975. private _scene;
  51976. /**
  51977. * Attach the input controls to a specific dom element to get the input from.
  51978. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51979. */
  51980. attachControl(noPreventDefault?: boolean): void;
  51981. /**
  51982. * Detach the current controls from the specified dom element.
  51983. */
  51984. detachControl(): void;
  51985. /**
  51986. * Update the current camera state depending on the inputs that have been used this frame.
  51987. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51988. */
  51989. checkInputs(): void;
  51990. /**
  51991. * Gets the class name of the current input.
  51992. * @returns the class name
  51993. */
  51994. getClassName(): string;
  51995. /**
  51996. * Get the friendly name associated with the input class.
  51997. * @returns the input friendly name
  51998. */
  51999. getSimpleName(): string;
  52000. /**
  52001. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  52002. * allow modification of the heightOffset value.
  52003. */
  52004. private _modifierHeightOffset;
  52005. /**
  52006. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  52007. * allow modification of the rotationOffset value.
  52008. */
  52009. private _modifierRotationOffset;
  52010. /**
  52011. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  52012. * allow modification of the radius value.
  52013. */
  52014. private _modifierRadius;
  52015. }
  52016. }
  52017. declare module BABYLON {
  52018. interface FreeCameraInputsManager {
  52019. /**
  52020. * @hidden
  52021. */
  52022. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  52023. /**
  52024. * Add orientation input support to the input manager.
  52025. * @returns the current input manager
  52026. */
  52027. addDeviceOrientation(): FreeCameraInputsManager;
  52028. }
  52029. /**
  52030. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  52031. * Screen rotation is taken into account.
  52032. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52033. */
  52034. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  52035. private _camera;
  52036. private _screenOrientationAngle;
  52037. private _constantTranform;
  52038. private _screenQuaternion;
  52039. private _alpha;
  52040. private _beta;
  52041. private _gamma;
  52042. /**
  52043. * Can be used to detect if a device orientation sensor is available on a device
  52044. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  52045. * @returns a promise that will resolve on orientation change
  52046. */
  52047. static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
  52048. /**
  52049. * @hidden
  52050. */
  52051. _onDeviceOrientationChangedObservable: Observable<void>;
  52052. /**
  52053. * Instantiates a new input
  52054. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52055. */
  52056. constructor();
  52057. /**
  52058. * Define the camera controlled by the input.
  52059. */
  52060. get camera(): FreeCamera;
  52061. set camera(camera: FreeCamera);
  52062. /**
  52063. * Attach the input controls to a specific dom element to get the input from.
  52064. */
  52065. attachControl(): void;
  52066. private _orientationChanged;
  52067. private _deviceOrientation;
  52068. /**
  52069. * Detach the current controls from the specified dom element.
  52070. */
  52071. detachControl(): void;
  52072. /**
  52073. * Update the current camera state depending on the inputs that have been used this frame.
  52074. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52075. */
  52076. checkInputs(): void;
  52077. /**
  52078. * Gets the class name of the current input.
  52079. * @returns the class name
  52080. */
  52081. getClassName(): string;
  52082. /**
  52083. * Get the friendly name associated with the input class.
  52084. * @returns the input friendly name
  52085. */
  52086. getSimpleName(): string;
  52087. }
  52088. }
  52089. declare module BABYLON {
  52090. /**
  52091. * Manage the gamepad inputs to control a free camera.
  52092. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52093. */
  52094. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  52095. /**
  52096. * Define the camera the input is attached to.
  52097. */
  52098. camera: FreeCamera;
  52099. /**
  52100. * Define the Gamepad controlling the input
  52101. */
  52102. gamepad: Nullable<Gamepad>;
  52103. /**
  52104. * Defines the gamepad rotation sensiblity.
  52105. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  52106. */
  52107. gamepadAngularSensibility: number;
  52108. /**
  52109. * Defines the gamepad move sensiblity.
  52110. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  52111. */
  52112. gamepadMoveSensibility: number;
  52113. private _yAxisScale;
  52114. /**
  52115. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  52116. */
  52117. get invertYAxis(): boolean;
  52118. set invertYAxis(value: boolean);
  52119. private _onGamepadConnectedObserver;
  52120. private _onGamepadDisconnectedObserver;
  52121. private _cameraTransform;
  52122. private _deltaTransform;
  52123. private _vector3;
  52124. private _vector2;
  52125. /**
  52126. * Attach the input controls to a specific dom element to get the input from.
  52127. */
  52128. attachControl(): void;
  52129. /**
  52130. * Detach the current controls from the specified dom element.
  52131. */
  52132. detachControl(): void;
  52133. /**
  52134. * Update the current camera state depending on the inputs that have been used this frame.
  52135. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52136. */
  52137. checkInputs(): void;
  52138. /**
  52139. * Gets the class name of the current input.
  52140. * @returns the class name
  52141. */
  52142. getClassName(): string;
  52143. /**
  52144. * Get the friendly name associated with the input class.
  52145. * @returns the input friendly name
  52146. */
  52147. getSimpleName(): string;
  52148. }
  52149. }
  52150. declare module BABYLON {
  52151. /**
  52152. * Defines the potential axis of a Joystick
  52153. */
  52154. export enum JoystickAxis {
  52155. /** X axis */
  52156. X = 0,
  52157. /** Y axis */
  52158. Y = 1,
  52159. /** Z axis */
  52160. Z = 2
  52161. }
  52162. /**
  52163. * Represents the different customization options available
  52164. * for VirtualJoystick
  52165. */
  52166. interface VirtualJoystickCustomizations {
  52167. /**
  52168. * Size of the joystick's puck
  52169. */
  52170. puckSize: number;
  52171. /**
  52172. * Size of the joystick's container
  52173. */
  52174. containerSize: number;
  52175. /**
  52176. * Color of the joystick && puck
  52177. */
  52178. color: string;
  52179. /**
  52180. * Image URL for the joystick's puck
  52181. */
  52182. puckImage?: string;
  52183. /**
  52184. * Image URL for the joystick's container
  52185. */
  52186. containerImage?: string;
  52187. /**
  52188. * Defines the unmoving position of the joystick container
  52189. */
  52190. position?: {
  52191. x: number;
  52192. y: number;
  52193. };
  52194. /**
  52195. * Defines whether or not the joystick container is always visible
  52196. */
  52197. alwaysVisible: boolean;
  52198. /**
  52199. * Defines whether or not to limit the movement of the puck to the joystick's container
  52200. */
  52201. limitToContainer: boolean;
  52202. }
  52203. /**
  52204. * Class used to define virtual joystick (used in touch mode)
  52205. */
  52206. export class VirtualJoystick {
  52207. /**
  52208. * Gets or sets a boolean indicating that left and right values must be inverted
  52209. */
  52210. reverseLeftRight: boolean;
  52211. /**
  52212. * Gets or sets a boolean indicating that up and down values must be inverted
  52213. */
  52214. reverseUpDown: boolean;
  52215. /**
  52216. * Gets the offset value for the position (ie. the change of the position value)
  52217. */
  52218. deltaPosition: Vector3;
  52219. /**
  52220. * Gets a boolean indicating if the virtual joystick was pressed
  52221. */
  52222. pressed: boolean;
  52223. /**
  52224. * Canvas the virtual joystick will render onto, default z-index of this is 5
  52225. */
  52226. static Canvas: Nullable<HTMLCanvasElement>;
  52227. /**
  52228. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  52229. */
  52230. limitToContainer: boolean;
  52231. private static _globalJoystickIndex;
  52232. private static _alwaysVisibleSticks;
  52233. private static vjCanvasContext;
  52234. private static vjCanvasWidth;
  52235. private static vjCanvasHeight;
  52236. private static halfWidth;
  52237. private static _GetDefaultOptions;
  52238. private _action;
  52239. private _axisTargetedByLeftAndRight;
  52240. private _axisTargetedByUpAndDown;
  52241. private _joystickSensibility;
  52242. private _inversedSensibility;
  52243. private _joystickPointerID;
  52244. private _joystickColor;
  52245. private _joystickPointerPos;
  52246. private _joystickPreviousPointerPos;
  52247. private _joystickPointerStartPos;
  52248. private _deltaJoystickVector;
  52249. private _leftJoystick;
  52250. private _touches;
  52251. private _joystickPosition;
  52252. private _alwaysVisible;
  52253. private _puckImage;
  52254. private _containerImage;
  52255. private _joystickPuckSize;
  52256. private _joystickContainerSize;
  52257. private _clearPuckSize;
  52258. private _clearContainerSize;
  52259. private _clearPuckSizeOffset;
  52260. private _clearContainerSizeOffset;
  52261. private _onPointerDownHandlerRef;
  52262. private _onPointerMoveHandlerRef;
  52263. private _onPointerUpHandlerRef;
  52264. private _onResize;
  52265. /**
  52266. * Creates a new virtual joystick
  52267. * @param leftJoystick defines that the joystick is for left hand (false by default)
  52268. * @param customizations Defines the options we want to customize the VirtualJoystick
  52269. */
  52270. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  52271. /**
  52272. * Defines joystick sensibility (ie. the ratio between a physical move and virtual joystick position change)
  52273. * @param newJoystickSensibility defines the new sensibility
  52274. */
  52275. setJoystickSensibility(newJoystickSensibility: number): void;
  52276. private _onPointerDown;
  52277. private _onPointerMove;
  52278. private _onPointerUp;
  52279. /**
  52280. * Change the color of the virtual joystick
  52281. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  52282. */
  52283. setJoystickColor(newColor: string): void;
  52284. /**
  52285. * Size of the joystick's container
  52286. */
  52287. set containerSize(newSize: number);
  52288. get containerSize(): number;
  52289. /**
  52290. * Size of the joystick's puck
  52291. */
  52292. set puckSize(newSize: number);
  52293. get puckSize(): number;
  52294. /**
  52295. * Clears the set position of the joystick
  52296. */
  52297. clearPosition(): void;
  52298. /**
  52299. * Defines whether or not the joystick container is always visible
  52300. */
  52301. set alwaysVisible(value: boolean);
  52302. get alwaysVisible(): boolean;
  52303. /**
  52304. * Sets the constant position of the Joystick container
  52305. * @param x X axis coordinate
  52306. * @param y Y axis coordinate
  52307. */
  52308. setPosition(x: number, y: number): void;
  52309. /**
  52310. * Defines a callback to call when the joystick is touched
  52311. * @param action defines the callback
  52312. */
  52313. setActionOnTouch(action: () => any): void;
  52314. /**
  52315. * Defines which axis you'd like to control for left & right
  52316. * @param axis defines the axis to use
  52317. */
  52318. setAxisForLeftRight(axis: JoystickAxis): void;
  52319. /**
  52320. * Defines which axis you'd like to control for up & down
  52321. * @param axis defines the axis to use
  52322. */
  52323. setAxisForUpDown(axis: JoystickAxis): void;
  52324. /**
  52325. * Clears the canvas from the previous puck / container draw
  52326. */
  52327. private _clearPreviousDraw;
  52328. /**
  52329. * Loads `urlPath` to be used for the container's image
  52330. * @param urlPath defines the urlPath of an image to use
  52331. */
  52332. setContainerImage(urlPath: string): void;
  52333. /**
  52334. * Loads `urlPath` to be used for the puck's image
  52335. * @param urlPath defines the urlPath of an image to use
  52336. */
  52337. setPuckImage(urlPath: string): void;
  52338. /**
  52339. * Draws the Virtual Joystick's container
  52340. */
  52341. private _drawContainer;
  52342. /**
  52343. * Draws the Virtual Joystick's puck
  52344. */
  52345. private _drawPuck;
  52346. private _drawVirtualJoystick;
  52347. /**
  52348. * Release internal HTML canvas
  52349. */
  52350. releaseCanvas(): void;
  52351. }
  52352. }
  52353. declare module BABYLON {
  52354. interface FreeCameraInputsManager {
  52355. /**
  52356. * Add virtual joystick input support to the input manager.
  52357. * @returns the current input manager
  52358. */
  52359. addVirtualJoystick(): FreeCameraInputsManager;
  52360. }
  52361. /**
  52362. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  52363. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52364. */
  52365. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  52366. /**
  52367. * Defines the camera the input is attached to.
  52368. */
  52369. camera: FreeCamera;
  52370. private _leftjoystick;
  52371. private _rightjoystick;
  52372. /**
  52373. * Gets the left stick of the virtual joystick.
  52374. * @returns The virtual Joystick
  52375. */
  52376. getLeftJoystick(): VirtualJoystick;
  52377. /**
  52378. * Gets the right stick of the virtual joystick.
  52379. * @returns The virtual Joystick
  52380. */
  52381. getRightJoystick(): VirtualJoystick;
  52382. /**
  52383. * Update the current camera state depending on the inputs that have been used this frame.
  52384. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52385. */
  52386. checkInputs(): void;
  52387. /**
  52388. * Attach the input controls to a specific dom element to get the input from.
  52389. */
  52390. attachControl(): void;
  52391. /**
  52392. * Detach the current controls from the specified dom element.
  52393. */
  52394. detachControl(): void;
  52395. /**
  52396. * Gets the class name of the current input.
  52397. * @returns the class name
  52398. */
  52399. getClassName(): string;
  52400. /**
  52401. * Get the friendly name associated with the input class.
  52402. * @returns the input friendly name
  52403. */
  52404. getSimpleName(): string;
  52405. }
  52406. }
  52407. declare module BABYLON {
  52408. /**
  52409. * This represents a FPS type of camera controlled by touch.
  52410. * This is like a universal camera minus the Gamepad controls.
  52411. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52412. */
  52413. export class TouchCamera extends FreeCamera {
  52414. /**
  52415. * Defines the touch sensibility for rotation.
  52416. * The higher the faster.
  52417. */
  52418. get touchAngularSensibility(): number;
  52419. set touchAngularSensibility(value: number);
  52420. /**
  52421. * Defines the touch sensibility for move.
  52422. * The higher the faster.
  52423. */
  52424. get touchMoveSensibility(): number;
  52425. set touchMoveSensibility(value: number);
  52426. /**
  52427. * Instantiates a new touch camera.
  52428. * This represents a FPS type of camera controlled by touch.
  52429. * This is like a universal camera minus the Gamepad controls.
  52430. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52431. * @param name Define the name of the camera in the scene
  52432. * @param position Define the start position of the camera in the scene
  52433. * @param scene Define the scene the camera belongs to
  52434. */
  52435. constructor(name: string, position: Vector3, scene: Scene);
  52436. /**
  52437. * Gets the current object class name.
  52438. * @return the class name
  52439. */
  52440. getClassName(): string;
  52441. /** @hidden */
  52442. _setupInputs(): void;
  52443. }
  52444. }
  52445. declare module BABYLON {
  52446. /**
  52447. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  52448. * being tilted forward or back and left or right.
  52449. */
  52450. export class DeviceOrientationCamera extends FreeCamera {
  52451. private _initialQuaternion;
  52452. private _quaternionCache;
  52453. private _tmpDragQuaternion;
  52454. private _disablePointerInputWhenUsingDeviceOrientation;
  52455. /**
  52456. * Creates a new device orientation camera
  52457. * @param name The name of the camera
  52458. * @param position The start position camera
  52459. * @param scene The scene the camera belongs to
  52460. */
  52461. constructor(name: string, position: Vector3, scene: Scene);
  52462. /**
  52463. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  52464. */
  52465. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  52466. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  52467. private _dragFactor;
  52468. /**
  52469. * Enabled turning on the y axis when the orientation sensor is active
  52470. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  52471. */
  52472. enableHorizontalDragging(dragFactor?: number): void;
  52473. /**
  52474. * Gets the current instance class name ("DeviceOrientationCamera").
  52475. * This helps avoiding instanceof at run time.
  52476. * @returns the class name
  52477. */
  52478. getClassName(): string;
  52479. /**
  52480. * @hidden
  52481. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  52482. */
  52483. _checkInputs(): void;
  52484. /**
  52485. * Reset the camera to its default orientation on the specified axis only.
  52486. * @param axis The axis to reset
  52487. */
  52488. resetToCurrentRotation(axis?: Axis): void;
  52489. }
  52490. }
  52491. declare module BABYLON {
  52492. /**
  52493. * Defines supported buttons for XBox360 compatible gamepads
  52494. */
  52495. export enum Xbox360Button {
  52496. /** A */
  52497. A = 0,
  52498. /** B */
  52499. B = 1,
  52500. /** X */
  52501. X = 2,
  52502. /** Y */
  52503. Y = 3,
  52504. /** Left button */
  52505. LB = 4,
  52506. /** Right button */
  52507. RB = 5,
  52508. /** Back */
  52509. Back = 8,
  52510. /** Start */
  52511. Start = 9,
  52512. /** Left stick */
  52513. LeftStick = 10,
  52514. /** Right stick */
  52515. RightStick = 11
  52516. }
  52517. /** Defines values for XBox360 DPad */
  52518. export enum Xbox360Dpad {
  52519. /** Up */
  52520. Up = 12,
  52521. /** Down */
  52522. Down = 13,
  52523. /** Left */
  52524. Left = 14,
  52525. /** Right */
  52526. Right = 15
  52527. }
  52528. /**
  52529. * Defines a XBox360 gamepad
  52530. */
  52531. export class Xbox360Pad extends Gamepad {
  52532. private _leftTrigger;
  52533. private _rightTrigger;
  52534. private _onlefttriggerchanged;
  52535. private _onrighttriggerchanged;
  52536. private _onbuttondown;
  52537. private _onbuttonup;
  52538. private _ondpaddown;
  52539. private _ondpadup;
  52540. /** Observable raised when a button is pressed */
  52541. onButtonDownObservable: Observable<Xbox360Button>;
  52542. /** Observable raised when a button is released */
  52543. onButtonUpObservable: Observable<Xbox360Button>;
  52544. /** Observable raised when a pad is pressed */
  52545. onPadDownObservable: Observable<Xbox360Dpad>;
  52546. /** Observable raised when a pad is released */
  52547. onPadUpObservable: Observable<Xbox360Dpad>;
  52548. private _buttonA;
  52549. private _buttonB;
  52550. private _buttonX;
  52551. private _buttonY;
  52552. private _buttonBack;
  52553. private _buttonStart;
  52554. private _buttonLB;
  52555. private _buttonRB;
  52556. private _buttonLeftStick;
  52557. private _buttonRightStick;
  52558. private _dPadUp;
  52559. private _dPadDown;
  52560. private _dPadLeft;
  52561. private _dPadRight;
  52562. private _isXboxOnePad;
  52563. /**
  52564. * Creates a new XBox360 gamepad object
  52565. * @param id defines the id of this gamepad
  52566. * @param index defines its index
  52567. * @param gamepad defines the internal HTML gamepad object
  52568. * @param xboxOne defines if it is a XBox One gamepad
  52569. */
  52570. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  52571. /**
  52572. * Defines the callback to call when left trigger is pressed
  52573. * @param callback defines the callback to use
  52574. */
  52575. onlefttriggerchanged(callback: (value: number) => void): void;
  52576. /**
  52577. * Defines the callback to call when right trigger is pressed
  52578. * @param callback defines the callback to use
  52579. */
  52580. onrighttriggerchanged(callback: (value: number) => void): void;
  52581. /**
  52582. * Gets the left trigger value
  52583. */
  52584. get leftTrigger(): number;
  52585. /**
  52586. * Sets the left trigger value
  52587. */
  52588. set leftTrigger(newValue: number);
  52589. /**
  52590. * Gets the right trigger value
  52591. */
  52592. get rightTrigger(): number;
  52593. /**
  52594. * Sets the right trigger value
  52595. */
  52596. set rightTrigger(newValue: number);
  52597. /**
  52598. * Defines the callback to call when a button is pressed
  52599. * @param callback defines the callback to use
  52600. */
  52601. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  52602. /**
  52603. * Defines the callback to call when a button is released
  52604. * @param callback defines the callback to use
  52605. */
  52606. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  52607. /**
  52608. * Defines the callback to call when a pad is pressed
  52609. * @param callback defines the callback to use
  52610. */
  52611. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  52612. /**
  52613. * Defines the callback to call when a pad is released
  52614. * @param callback defines the callback to use
  52615. */
  52616. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  52617. private _setButtonValue;
  52618. private _setDPadValue;
  52619. /**
  52620. * Gets the value of the `A` button
  52621. */
  52622. get buttonA(): number;
  52623. /**
  52624. * Sets the value of the `A` button
  52625. */
  52626. set buttonA(value: number);
  52627. /**
  52628. * Gets the value of the `B` button
  52629. */
  52630. get buttonB(): number;
  52631. /**
  52632. * Sets the value of the `B` button
  52633. */
  52634. set buttonB(value: number);
  52635. /**
  52636. * Gets the value of the `X` button
  52637. */
  52638. get buttonX(): number;
  52639. /**
  52640. * Sets the value of the `X` button
  52641. */
  52642. set buttonX(value: number);
  52643. /**
  52644. * Gets the value of the `Y` button
  52645. */
  52646. get buttonY(): number;
  52647. /**
  52648. * Sets the value of the `Y` button
  52649. */
  52650. set buttonY(value: number);
  52651. /**
  52652. * Gets the value of the `Start` button
  52653. */
  52654. get buttonStart(): number;
  52655. /**
  52656. * Sets the value of the `Start` button
  52657. */
  52658. set buttonStart(value: number);
  52659. /**
  52660. * Gets the value of the `Back` button
  52661. */
  52662. get buttonBack(): number;
  52663. /**
  52664. * Sets the value of the `Back` button
  52665. */
  52666. set buttonBack(value: number);
  52667. /**
  52668. * Gets the value of the `Left` button
  52669. */
  52670. get buttonLB(): number;
  52671. /**
  52672. * Sets the value of the `Left` button
  52673. */
  52674. set buttonLB(value: number);
  52675. /**
  52676. * Gets the value of the `Right` button
  52677. */
  52678. get buttonRB(): number;
  52679. /**
  52680. * Sets the value of the `Right` button
  52681. */
  52682. set buttonRB(value: number);
  52683. /**
  52684. * Gets the value of the Left joystick
  52685. */
  52686. get buttonLeftStick(): number;
  52687. /**
  52688. * Sets the value of the Left joystick
  52689. */
  52690. set buttonLeftStick(value: number);
  52691. /**
  52692. * Gets the value of the Right joystick
  52693. */
  52694. get buttonRightStick(): number;
  52695. /**
  52696. * Sets the value of the Right joystick
  52697. */
  52698. set buttonRightStick(value: number);
  52699. /**
  52700. * Gets the value of D-pad up
  52701. */
  52702. get dPadUp(): number;
  52703. /**
  52704. * Sets the value of D-pad up
  52705. */
  52706. set dPadUp(value: number);
  52707. /**
  52708. * Gets the value of D-pad down
  52709. */
  52710. get dPadDown(): number;
  52711. /**
  52712. * Sets the value of D-pad down
  52713. */
  52714. set dPadDown(value: number);
  52715. /**
  52716. * Gets the value of D-pad left
  52717. */
  52718. get dPadLeft(): number;
  52719. /**
  52720. * Sets the value of D-pad left
  52721. */
  52722. set dPadLeft(value: number);
  52723. /**
  52724. * Gets the value of D-pad right
  52725. */
  52726. get dPadRight(): number;
  52727. /**
  52728. * Sets the value of D-pad right
  52729. */
  52730. set dPadRight(value: number);
  52731. /**
  52732. * Force the gamepad to synchronize with device values
  52733. */
  52734. update(): void;
  52735. /**
  52736. * Disposes the gamepad
  52737. */
  52738. dispose(): void;
  52739. }
  52740. }
  52741. declare module BABYLON {
  52742. /**
  52743. * Defines supported buttons for DualShock compatible gamepads
  52744. */
  52745. export enum DualShockButton {
  52746. /** Cross */
  52747. Cross = 0,
  52748. /** Circle */
  52749. Circle = 1,
  52750. /** Square */
  52751. Square = 2,
  52752. /** Triangle */
  52753. Triangle = 3,
  52754. /** L1 */
  52755. L1 = 4,
  52756. /** R1 */
  52757. R1 = 5,
  52758. /** Share */
  52759. Share = 8,
  52760. /** Options */
  52761. Options = 9,
  52762. /** Left stick */
  52763. LeftStick = 10,
  52764. /** Right stick */
  52765. RightStick = 11
  52766. }
  52767. /** Defines values for DualShock DPad */
  52768. export enum DualShockDpad {
  52769. /** Up */
  52770. Up = 12,
  52771. /** Down */
  52772. Down = 13,
  52773. /** Left */
  52774. Left = 14,
  52775. /** Right */
  52776. Right = 15
  52777. }
  52778. /**
  52779. * Defines a DualShock gamepad
  52780. */
  52781. export class DualShockPad extends Gamepad {
  52782. private _leftTrigger;
  52783. private _rightTrigger;
  52784. private _onlefttriggerchanged;
  52785. private _onrighttriggerchanged;
  52786. private _onbuttondown;
  52787. private _onbuttonup;
  52788. private _ondpaddown;
  52789. private _ondpadup;
  52790. /** Observable raised when a button is pressed */
  52791. onButtonDownObservable: Observable<DualShockButton>;
  52792. /** Observable raised when a button is released */
  52793. onButtonUpObservable: Observable<DualShockButton>;
  52794. /** Observable raised when a pad is pressed */
  52795. onPadDownObservable: Observable<DualShockDpad>;
  52796. /** Observable raised when a pad is released */
  52797. onPadUpObservable: Observable<DualShockDpad>;
  52798. private _buttonCross;
  52799. private _buttonCircle;
  52800. private _buttonSquare;
  52801. private _buttonTriangle;
  52802. private _buttonShare;
  52803. private _buttonOptions;
  52804. private _buttonL1;
  52805. private _buttonR1;
  52806. private _buttonLeftStick;
  52807. private _buttonRightStick;
  52808. private _dPadUp;
  52809. private _dPadDown;
  52810. private _dPadLeft;
  52811. private _dPadRight;
  52812. /**
  52813. * Creates a new DualShock gamepad object
  52814. * @param id defines the id of this gamepad
  52815. * @param index defines its index
  52816. * @param gamepad defines the internal HTML gamepad object
  52817. */
  52818. constructor(id: string, index: number, gamepad: any);
  52819. /**
  52820. * Defines the callback to call when left trigger is pressed
  52821. * @param callback defines the callback to use
  52822. */
  52823. onlefttriggerchanged(callback: (value: number) => void): void;
  52824. /**
  52825. * Defines the callback to call when right trigger is pressed
  52826. * @param callback defines the callback to use
  52827. */
  52828. onrighttriggerchanged(callback: (value: number) => void): void;
  52829. /**
  52830. * Gets the left trigger value
  52831. */
  52832. get leftTrigger(): number;
  52833. /**
  52834. * Sets the left trigger value
  52835. */
  52836. set leftTrigger(newValue: number);
  52837. /**
  52838. * Gets the right trigger value
  52839. */
  52840. get rightTrigger(): number;
  52841. /**
  52842. * Sets the right trigger value
  52843. */
  52844. set rightTrigger(newValue: number);
  52845. /**
  52846. * Defines the callback to call when a button is pressed
  52847. * @param callback defines the callback to use
  52848. */
  52849. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  52850. /**
  52851. * Defines the callback to call when a button is released
  52852. * @param callback defines the callback to use
  52853. */
  52854. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  52855. /**
  52856. * Defines the callback to call when a pad is pressed
  52857. * @param callback defines the callback to use
  52858. */
  52859. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  52860. /**
  52861. * Defines the callback to call when a pad is released
  52862. * @param callback defines the callback to use
  52863. */
  52864. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  52865. private _setButtonValue;
  52866. private _setDPadValue;
  52867. /**
  52868. * Gets the value of the `Cross` button
  52869. */
  52870. get buttonCross(): number;
  52871. /**
  52872. * Sets the value of the `Cross` button
  52873. */
  52874. set buttonCross(value: number);
  52875. /**
  52876. * Gets the value of the `Circle` button
  52877. */
  52878. get buttonCircle(): number;
  52879. /**
  52880. * Sets the value of the `Circle` button
  52881. */
  52882. set buttonCircle(value: number);
  52883. /**
  52884. * Gets the value of the `Square` button
  52885. */
  52886. get buttonSquare(): number;
  52887. /**
  52888. * Sets the value of the `Square` button
  52889. */
  52890. set buttonSquare(value: number);
  52891. /**
  52892. * Gets the value of the `Triangle` button
  52893. */
  52894. get buttonTriangle(): number;
  52895. /**
  52896. * Sets the value of the `Triangle` button
  52897. */
  52898. set buttonTriangle(value: number);
  52899. /**
  52900. * Gets the value of the `Options` button
  52901. */
  52902. get buttonOptions(): number;
  52903. /**
  52904. * Sets the value of the `Options` button
  52905. */
  52906. set buttonOptions(value: number);
  52907. /**
  52908. * Gets the value of the `Share` button
  52909. */
  52910. get buttonShare(): number;
  52911. /**
  52912. * Sets the value of the `Share` button
  52913. */
  52914. set buttonShare(value: number);
  52915. /**
  52916. * Gets the value of the `L1` button
  52917. */
  52918. get buttonL1(): number;
  52919. /**
  52920. * Sets the value of the `L1` button
  52921. */
  52922. set buttonL1(value: number);
  52923. /**
  52924. * Gets the value of the `R1` button
  52925. */
  52926. get buttonR1(): number;
  52927. /**
  52928. * Sets the value of the `R1` button
  52929. */
  52930. set buttonR1(value: number);
  52931. /**
  52932. * Gets the value of the Left joystick
  52933. */
  52934. get buttonLeftStick(): number;
  52935. /**
  52936. * Sets the value of the Left joystick
  52937. */
  52938. set buttonLeftStick(value: number);
  52939. /**
  52940. * Gets the value of the Right joystick
  52941. */
  52942. get buttonRightStick(): number;
  52943. /**
  52944. * Sets the value of the Right joystick
  52945. */
  52946. set buttonRightStick(value: number);
  52947. /**
  52948. * Gets the value of D-pad up
  52949. */
  52950. get dPadUp(): number;
  52951. /**
  52952. * Sets the value of D-pad up
  52953. */
  52954. set dPadUp(value: number);
  52955. /**
  52956. * Gets the value of D-pad down
  52957. */
  52958. get dPadDown(): number;
  52959. /**
  52960. * Sets the value of D-pad down
  52961. */
  52962. set dPadDown(value: number);
  52963. /**
  52964. * Gets the value of D-pad left
  52965. */
  52966. get dPadLeft(): number;
  52967. /**
  52968. * Sets the value of D-pad left
  52969. */
  52970. set dPadLeft(value: number);
  52971. /**
  52972. * Gets the value of D-pad right
  52973. */
  52974. get dPadRight(): number;
  52975. /**
  52976. * Sets the value of D-pad right
  52977. */
  52978. set dPadRight(value: number);
  52979. /**
  52980. * Force the gamepad to synchronize with device values
  52981. */
  52982. update(): void;
  52983. /**
  52984. * Disposes the gamepad
  52985. */
  52986. dispose(): void;
  52987. }
  52988. }
  52989. declare module BABYLON {
  52990. /**
  52991. * Manager for handling gamepads
  52992. */
  52993. export class GamepadManager {
  52994. private _scene?;
  52995. private _babylonGamepads;
  52996. private _oneGamepadConnected;
  52997. /** @hidden */
  52998. _isMonitoring: boolean;
  52999. private _gamepadEventSupported;
  53000. private _gamepadSupport?;
  53001. /**
  53002. * observable to be triggered when the gamepad controller has been connected
  53003. */
  53004. onGamepadConnectedObservable: Observable<Gamepad>;
  53005. /**
  53006. * observable to be triggered when the gamepad controller has been disconnected
  53007. */
  53008. onGamepadDisconnectedObservable: Observable<Gamepad>;
  53009. private _onGamepadConnectedEvent;
  53010. private _onGamepadDisconnectedEvent;
  53011. /**
  53012. * Initializes the gamepad manager
  53013. * @param _scene BabylonJS scene
  53014. */
  53015. constructor(_scene?: Scene | undefined);
  53016. /**
  53017. * The gamepads in the game pad manager
  53018. */
  53019. get gamepads(): Gamepad[];
  53020. /**
  53021. * Get the gamepad controllers based on type
  53022. * @param type The type of gamepad controller
  53023. * @returns Nullable gamepad
  53024. */
  53025. getGamepadByType(type?: number): Nullable<Gamepad>;
  53026. /**
  53027. * Disposes the gamepad manager
  53028. */
  53029. dispose(): void;
  53030. private _addNewGamepad;
  53031. private _startMonitoringGamepads;
  53032. private _stopMonitoringGamepads;
  53033. /** @hidden */
  53034. _checkGamepadsStatus(): void;
  53035. private _updateGamepadObjects;
  53036. }
  53037. }
  53038. declare module BABYLON {
  53039. interface Scene {
  53040. /** @hidden */
  53041. _gamepadManager: Nullable<GamepadManager>;
  53042. /**
  53043. * Gets the gamepad manager associated with the scene
  53044. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  53045. */
  53046. gamepadManager: GamepadManager;
  53047. }
  53048. /**
  53049. * Interface representing a free camera inputs manager
  53050. */
  53051. interface FreeCameraInputsManager {
  53052. /**
  53053. * Adds gamepad input support to the FreeCameraInputsManager.
  53054. * @returns the FreeCameraInputsManager
  53055. */
  53056. addGamepad(): FreeCameraInputsManager;
  53057. }
  53058. /**
  53059. * Interface representing an arc rotate camera inputs manager
  53060. */
  53061. interface ArcRotateCameraInputsManager {
  53062. /**
  53063. * Adds gamepad input support to the ArcRotateCamera InputManager.
  53064. * @returns the camera inputs manager
  53065. */
  53066. addGamepad(): ArcRotateCameraInputsManager;
  53067. }
  53068. /**
  53069. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  53070. */
  53071. export class GamepadSystemSceneComponent implements ISceneComponent {
  53072. /**
  53073. * The component name helpfull to identify the component in the list of scene components.
  53074. */
  53075. readonly name: string;
  53076. /**
  53077. * The scene the component belongs to.
  53078. */
  53079. scene: Scene;
  53080. /**
  53081. * Creates a new instance of the component for the given scene
  53082. * @param scene Defines the scene to register the component in
  53083. */
  53084. constructor(scene: Scene);
  53085. /**
  53086. * Registers the component in a given scene
  53087. */
  53088. register(): void;
  53089. /**
  53090. * Rebuilds the elements related to this component in case of
  53091. * context lost for instance.
  53092. */
  53093. rebuild(): void;
  53094. /**
  53095. * Disposes the component and the associated ressources
  53096. */
  53097. dispose(): void;
  53098. private _beforeCameraUpdate;
  53099. }
  53100. }
  53101. declare module BABYLON {
  53102. /**
  53103. * 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,
  53104. * which still works and will still be found in many Playgrounds.
  53105. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53106. */
  53107. export class UniversalCamera extends TouchCamera {
  53108. /**
  53109. * Defines the gamepad rotation sensiblity.
  53110. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  53111. */
  53112. get gamepadAngularSensibility(): number;
  53113. set gamepadAngularSensibility(value: number);
  53114. /**
  53115. * Defines the gamepad move sensiblity.
  53116. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  53117. */
  53118. get gamepadMoveSensibility(): number;
  53119. set gamepadMoveSensibility(value: number);
  53120. /**
  53121. * 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,
  53122. * which still works and will still be found in many Playgrounds.
  53123. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53124. * @param name Define the name of the camera in the scene
  53125. * @param position Define the start position of the camera in the scene
  53126. * @param scene Define the scene the camera belongs to
  53127. */
  53128. constructor(name: string, position: Vector3, scene: Scene);
  53129. /**
  53130. * Gets the current object class name.
  53131. * @return the class name
  53132. */
  53133. getClassName(): string;
  53134. }
  53135. }
  53136. declare module BABYLON {
  53137. /**
  53138. * This represents a FPS type of camera. This is only here for back compat purpose.
  53139. * Please use the UniversalCamera instead as both are identical.
  53140. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53141. */
  53142. export class GamepadCamera extends UniversalCamera {
  53143. /**
  53144. * Instantiates a new Gamepad Camera
  53145. * This represents a FPS type of camera. This is only here for back compat purpose.
  53146. * Please use the UniversalCamera instead as both are identical.
  53147. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53148. * @param name Define the name of the camera in the scene
  53149. * @param position Define the start position of the camera in the scene
  53150. * @param scene Define the scene the camera belongs to
  53151. */
  53152. constructor(name: string, position: Vector3, scene: Scene);
  53153. /**
  53154. * Gets the current object class name.
  53155. * @return the class name
  53156. */
  53157. getClassName(): string;
  53158. }
  53159. }
  53160. declare module BABYLON {
  53161. /** @hidden */
  53162. export var anaglyphPixelShader: {
  53163. name: string;
  53164. shader: string;
  53165. };
  53166. }
  53167. declare module BABYLON {
  53168. /**
  53169. * Postprocess used to generate anaglyphic rendering
  53170. */
  53171. export class AnaglyphPostProcess extends PostProcess {
  53172. private _passedProcess;
  53173. /**
  53174. * Gets a string identifying the name of the class
  53175. * @returns "AnaglyphPostProcess" string
  53176. */
  53177. getClassName(): string;
  53178. /**
  53179. * Creates a new AnaglyphPostProcess
  53180. * @param name defines postprocess name
  53181. * @param options defines creation options or target ratio scale
  53182. * @param rigCameras defines cameras using this postprocess
  53183. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  53184. * @param engine defines hosting engine
  53185. * @param reusable defines if the postprocess will be reused multiple times per frame
  53186. */
  53187. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  53188. }
  53189. }
  53190. declare module BABYLON {
  53191. /**
  53192. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  53193. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53194. */
  53195. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  53196. /**
  53197. * Creates a new AnaglyphArcRotateCamera
  53198. * @param name defines camera name
  53199. * @param alpha defines alpha angle (in radians)
  53200. * @param beta defines beta angle (in radians)
  53201. * @param radius defines radius
  53202. * @param target defines camera target
  53203. * @param interaxialDistance defines distance between each color axis
  53204. * @param scene defines the hosting scene
  53205. */
  53206. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  53207. /**
  53208. * Gets camera class name
  53209. * @returns AnaglyphArcRotateCamera
  53210. */
  53211. getClassName(): string;
  53212. }
  53213. }
  53214. declare module BABYLON {
  53215. /**
  53216. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  53217. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53218. */
  53219. export class AnaglyphFreeCamera extends FreeCamera {
  53220. /**
  53221. * Creates a new AnaglyphFreeCamera
  53222. * @param name defines camera name
  53223. * @param position defines initial position
  53224. * @param interaxialDistance defines distance between each color axis
  53225. * @param scene defines the hosting scene
  53226. */
  53227. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  53228. /**
  53229. * Gets camera class name
  53230. * @returns AnaglyphFreeCamera
  53231. */
  53232. getClassName(): string;
  53233. }
  53234. }
  53235. declare module BABYLON {
  53236. /**
  53237. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  53238. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53239. */
  53240. export class AnaglyphGamepadCamera extends GamepadCamera {
  53241. /**
  53242. * Creates a new AnaglyphGamepadCamera
  53243. * @param name defines camera name
  53244. * @param position defines initial position
  53245. * @param interaxialDistance defines distance between each color axis
  53246. * @param scene defines the hosting scene
  53247. */
  53248. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  53249. /**
  53250. * Gets camera class name
  53251. * @returns AnaglyphGamepadCamera
  53252. */
  53253. getClassName(): string;
  53254. }
  53255. }
  53256. declare module BABYLON {
  53257. /**
  53258. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  53259. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53260. */
  53261. export class AnaglyphUniversalCamera extends UniversalCamera {
  53262. /**
  53263. * Creates a new AnaglyphUniversalCamera
  53264. * @param name defines camera name
  53265. * @param position defines initial position
  53266. * @param interaxialDistance defines distance between each color axis
  53267. * @param scene defines the hosting scene
  53268. */
  53269. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  53270. /**
  53271. * Gets camera class name
  53272. * @returns AnaglyphUniversalCamera
  53273. */
  53274. getClassName(): string;
  53275. }
  53276. }
  53277. declare module BABYLON {
  53278. /** @hidden */
  53279. export var stereoscopicInterlacePixelShader: {
  53280. name: string;
  53281. shader: string;
  53282. };
  53283. }
  53284. declare module BABYLON {
  53285. /**
  53286. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  53287. */
  53288. export class StereoscopicInterlacePostProcessI extends PostProcess {
  53289. private _stepSize;
  53290. private _passedProcess;
  53291. /**
  53292. * Gets a string identifying the name of the class
  53293. * @returns "StereoscopicInterlacePostProcessI" string
  53294. */
  53295. getClassName(): string;
  53296. /**
  53297. * Initializes a StereoscopicInterlacePostProcessI
  53298. * @param name The name of the effect.
  53299. * @param rigCameras The rig cameras to be applied to the post process
  53300. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  53301. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  53302. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53303. * @param engine The engine which the post process will be applied. (default: current engine)
  53304. * @param reusable If the post process can be reused on the same frame. (default: false)
  53305. */
  53306. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53307. }
  53308. /**
  53309. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  53310. */
  53311. export class StereoscopicInterlacePostProcess extends PostProcess {
  53312. private _stepSize;
  53313. private _passedProcess;
  53314. /**
  53315. * Gets a string identifying the name of the class
  53316. * @returns "StereoscopicInterlacePostProcess" string
  53317. */
  53318. getClassName(): string;
  53319. /**
  53320. * Initializes a StereoscopicInterlacePostProcess
  53321. * @param name The name of the effect.
  53322. * @param rigCameras The rig cameras to be applied to the post process
  53323. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  53324. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53325. * @param engine The engine which the post process will be applied. (default: current engine)
  53326. * @param reusable If the post process can be reused on the same frame. (default: false)
  53327. */
  53328. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53329. }
  53330. }
  53331. declare module BABYLON {
  53332. /**
  53333. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  53334. * @see https://doc.babylonjs.com/features/cameras
  53335. */
  53336. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  53337. /**
  53338. * Creates a new StereoscopicArcRotateCamera
  53339. * @param name defines camera name
  53340. * @param alpha defines alpha angle (in radians)
  53341. * @param beta defines beta angle (in radians)
  53342. * @param radius defines radius
  53343. * @param target defines camera target
  53344. * @param interaxialDistance defines distance between each color axis
  53345. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53346. * @param scene defines the hosting scene
  53347. */
  53348. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53349. /**
  53350. * Gets camera class name
  53351. * @returns StereoscopicArcRotateCamera
  53352. */
  53353. getClassName(): string;
  53354. }
  53355. }
  53356. declare module BABYLON {
  53357. /**
  53358. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  53359. * @see https://doc.babylonjs.com/features/cameras
  53360. */
  53361. export class StereoscopicFreeCamera extends FreeCamera {
  53362. /**
  53363. * Creates a new StereoscopicFreeCamera
  53364. * @param name defines camera name
  53365. * @param position defines initial position
  53366. * @param interaxialDistance defines distance between each color axis
  53367. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53368. * @param scene defines the hosting scene
  53369. */
  53370. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53371. /**
  53372. * Gets camera class name
  53373. * @returns StereoscopicFreeCamera
  53374. */
  53375. getClassName(): string;
  53376. }
  53377. }
  53378. declare module BABYLON {
  53379. /**
  53380. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  53381. * @see https://doc.babylonjs.com/features/cameras
  53382. */
  53383. export class StereoscopicGamepadCamera extends GamepadCamera {
  53384. /**
  53385. * Creates a new StereoscopicGamepadCamera
  53386. * @param name defines camera name
  53387. * @param position defines initial position
  53388. * @param interaxialDistance defines distance between each color axis
  53389. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53390. * @param scene defines the hosting scene
  53391. */
  53392. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53393. /**
  53394. * Gets camera class name
  53395. * @returns StereoscopicGamepadCamera
  53396. */
  53397. getClassName(): string;
  53398. }
  53399. }
  53400. declare module BABYLON {
  53401. /**
  53402. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  53403. * @see https://doc.babylonjs.com/features/cameras
  53404. */
  53405. export class StereoscopicUniversalCamera extends UniversalCamera {
  53406. /**
  53407. * Creates a new StereoscopicUniversalCamera
  53408. * @param name defines camera name
  53409. * @param position defines initial position
  53410. * @param interaxialDistance defines distance between each color axis
  53411. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53412. * @param scene defines the hosting scene
  53413. */
  53414. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53415. /**
  53416. * Gets camera class name
  53417. * @returns StereoscopicUniversalCamera
  53418. */
  53419. getClassName(): string;
  53420. }
  53421. }
  53422. declare module BABYLON {
  53423. /**
  53424. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  53425. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  53426. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  53427. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  53428. */
  53429. export class VirtualJoysticksCamera extends FreeCamera {
  53430. /**
  53431. * Instantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  53432. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  53433. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  53434. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  53435. * @param name Define the name of the camera in the scene
  53436. * @param position Define the start position of the camera in the scene
  53437. * @param scene Define the scene the camera belongs to
  53438. */
  53439. constructor(name: string, position: Vector3, scene: Scene);
  53440. /**
  53441. * Gets the current object class name.
  53442. * @return the class name
  53443. */
  53444. getClassName(): string;
  53445. }
  53446. }
  53447. declare module BABYLON {
  53448. /**
  53449. * This represents all the required metrics to create a VR camera.
  53450. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  53451. */
  53452. export class VRCameraMetrics {
  53453. /**
  53454. * Define the horizontal resolution off the screen.
  53455. */
  53456. hResolution: number;
  53457. /**
  53458. * Define the vertical resolution off the screen.
  53459. */
  53460. vResolution: number;
  53461. /**
  53462. * Define the horizontal screen size.
  53463. */
  53464. hScreenSize: number;
  53465. /**
  53466. * Define the vertical screen size.
  53467. */
  53468. vScreenSize: number;
  53469. /**
  53470. * Define the vertical screen center position.
  53471. */
  53472. vScreenCenter: number;
  53473. /**
  53474. * Define the distance of the eyes to the screen.
  53475. */
  53476. eyeToScreenDistance: number;
  53477. /**
  53478. * Define the distance between both lenses
  53479. */
  53480. lensSeparationDistance: number;
  53481. /**
  53482. * Define the distance between both viewer's eyes.
  53483. */
  53484. interpupillaryDistance: number;
  53485. /**
  53486. * Define the distortion factor of the VR postprocess.
  53487. * Please, touch with care.
  53488. */
  53489. distortionK: number[];
  53490. /**
  53491. * Define the chromatic aberration correction factors for the VR post process.
  53492. */
  53493. chromaAbCorrection: number[];
  53494. /**
  53495. * Define the scale factor of the post process.
  53496. * The smaller the better but the slower.
  53497. */
  53498. postProcessScaleFactor: number;
  53499. /**
  53500. * Define an offset for the lens center.
  53501. */
  53502. lensCenterOffset: number;
  53503. /**
  53504. * Define if the current vr camera should compensate the distortion of the lens or not.
  53505. */
  53506. compensateDistortion: boolean;
  53507. /**
  53508. * Defines if multiview should be enabled when rendering (Default: false)
  53509. */
  53510. multiviewEnabled: boolean;
  53511. /**
  53512. * Gets the rendering aspect ratio based on the provided resolutions.
  53513. */
  53514. get aspectRatio(): number;
  53515. /**
  53516. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  53517. */
  53518. get aspectRatioFov(): number;
  53519. /**
  53520. * @hidden
  53521. */
  53522. get leftHMatrix(): Matrix;
  53523. /**
  53524. * @hidden
  53525. */
  53526. get rightHMatrix(): Matrix;
  53527. /**
  53528. * @hidden
  53529. */
  53530. get leftPreViewMatrix(): Matrix;
  53531. /**
  53532. * @hidden
  53533. */
  53534. get rightPreViewMatrix(): Matrix;
  53535. /**
  53536. * Get the default VRMetrics based on the most generic setup.
  53537. * @returns the default vr metrics
  53538. */
  53539. static GetDefault(): VRCameraMetrics;
  53540. }
  53541. }
  53542. declare module BABYLON {
  53543. /** @hidden */
  53544. export var vrDistortionCorrectionPixelShader: {
  53545. name: string;
  53546. shader: string;
  53547. };
  53548. }
  53549. declare module BABYLON {
  53550. /**
  53551. * VRDistortionCorrectionPostProcess used for mobile VR
  53552. */
  53553. export class VRDistortionCorrectionPostProcess extends PostProcess {
  53554. private _isRightEye;
  53555. private _distortionFactors;
  53556. private _postProcessScaleFactor;
  53557. private _lensCenterOffset;
  53558. private _scaleIn;
  53559. private _scaleFactor;
  53560. private _lensCenter;
  53561. /**
  53562. * Gets a string identifying the name of the class
  53563. * @returns "VRDistortionCorrectionPostProcess" string
  53564. */
  53565. getClassName(): string;
  53566. /**
  53567. * Initializes the VRDistortionCorrectionPostProcess
  53568. * @param name The name of the effect.
  53569. * @param camera The camera to apply the render pass to.
  53570. * @param isRightEye If this is for the right eye distortion
  53571. * @param vrMetrics All the required metrics for the VR camera
  53572. */
  53573. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  53574. }
  53575. }
  53576. declare module BABYLON {
  53577. /**
  53578. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  53579. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53580. */
  53581. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  53582. /**
  53583. * Creates a new VRDeviceOrientationArcRotateCamera
  53584. * @param name defines camera name
  53585. * @param alpha defines the camera rotation along the longitudinal axis
  53586. * @param beta defines the camera rotation along the latitudinal axis
  53587. * @param radius defines the camera distance from its target
  53588. * @param target defines the camera target
  53589. * @param scene defines the scene the camera belongs to
  53590. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  53591. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53592. */
  53593. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53594. /**
  53595. * Gets camera class name
  53596. * @returns VRDeviceOrientationArcRotateCamera
  53597. */
  53598. getClassName(): string;
  53599. }
  53600. }
  53601. declare module BABYLON {
  53602. /**
  53603. * Camera used to simulate VR rendering (based on FreeCamera)
  53604. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53605. */
  53606. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  53607. /**
  53608. * Creates a new VRDeviceOrientationFreeCamera
  53609. * @param name defines camera name
  53610. * @param position defines the start position of the camera
  53611. * @param scene defines the scene the camera belongs to
  53612. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  53613. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53614. */
  53615. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53616. /**
  53617. * Gets camera class name
  53618. * @returns VRDeviceOrientationFreeCamera
  53619. */
  53620. getClassName(): string;
  53621. }
  53622. }
  53623. declare module BABYLON {
  53624. /**
  53625. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  53626. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53627. */
  53628. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  53629. /**
  53630. * Creates a new VRDeviceOrientationGamepadCamera
  53631. * @param name defines camera name
  53632. * @param position defines the start position of the camera
  53633. * @param scene defines the scene the camera belongs to
  53634. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  53635. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53636. */
  53637. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53638. /**
  53639. * Gets camera class name
  53640. * @returns VRDeviceOrientationGamepadCamera
  53641. */
  53642. getClassName(): string;
  53643. }
  53644. }
  53645. declare module BABYLON {
  53646. /**
  53647. * A class extending Texture allowing drawing on a texture
  53648. * @see https://doc.babylonjs.com/how_to/dynamictexture
  53649. */
  53650. export class DynamicTexture extends Texture {
  53651. private _generateMipMaps;
  53652. private _canvas;
  53653. private _context;
  53654. /**
  53655. * Creates a DynamicTexture
  53656. * @param name defines the name of the texture
  53657. * @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
  53658. * @param scene defines the scene where you want the texture
  53659. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  53660. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  53661. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  53662. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  53663. */
  53664. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  53665. /**
  53666. * Get the current class name of the texture useful for serialization or dynamic coding.
  53667. * @returns "DynamicTexture"
  53668. */
  53669. getClassName(): string;
  53670. /**
  53671. * Gets the current state of canRescale
  53672. */
  53673. get canRescale(): boolean;
  53674. private _recreate;
  53675. /**
  53676. * Scales the texture
  53677. * @param ratio the scale factor to apply to both width and height
  53678. */
  53679. scale(ratio: number): void;
  53680. /**
  53681. * Resizes the texture
  53682. * @param width the new width
  53683. * @param height the new height
  53684. */
  53685. scaleTo(width: number, height: number): void;
  53686. /**
  53687. * Gets the context of the canvas used by the texture
  53688. * @returns the canvas context of the dynamic texture
  53689. */
  53690. getContext(): CanvasRenderingContext2D;
  53691. /**
  53692. * Clears the texture
  53693. */
  53694. clear(): void;
  53695. /**
  53696. * Updates the texture
  53697. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  53698. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  53699. */
  53700. update(invertY?: boolean, premulAlpha?: boolean): void;
  53701. /**
  53702. * Draws text onto the texture
  53703. * @param text defines the text to be drawn
  53704. * @param x defines the placement of the text from the left
  53705. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  53706. * @param font defines the font to be used with font-style, font-size, font-name
  53707. * @param color defines the color used for the text
  53708. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  53709. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  53710. * @param update defines whether texture is immediately update (default is true)
  53711. */
  53712. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  53713. /**
  53714. * Clones the texture
  53715. * @returns the clone of the texture.
  53716. */
  53717. clone(): DynamicTexture;
  53718. /**
  53719. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  53720. * @returns a serialized dynamic texture object
  53721. */
  53722. serialize(): any;
  53723. private _IsCanvasElement;
  53724. /** @hidden */
  53725. _rebuild(): void;
  53726. }
  53727. }
  53728. declare module BABYLON {
  53729. /**
  53730. * Class containing static functions to help procedurally build meshes
  53731. */
  53732. export class GroundBuilder {
  53733. /**
  53734. * Creates a ground mesh
  53735. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53736. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53738. * @param name defines the name of the mesh
  53739. * @param options defines the options used to create the mesh
  53740. * @param scene defines the hosting scene
  53741. * @returns the ground mesh
  53742. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53743. */
  53744. static CreateGround(name: string, options: {
  53745. width?: number;
  53746. height?: number;
  53747. subdivisions?: number;
  53748. subdivisionsX?: number;
  53749. subdivisionsY?: number;
  53750. updatable?: boolean;
  53751. }, scene: any): Mesh;
  53752. /**
  53753. * Creates a tiled ground mesh
  53754. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53755. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53756. * * 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
  53757. * * 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
  53758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53759. * @param name defines the name of the mesh
  53760. * @param options defines the options used to create the mesh
  53761. * @param scene defines the hosting scene
  53762. * @returns the tiled ground mesh
  53763. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53764. */
  53765. static CreateTiledGround(name: string, options: {
  53766. xmin: number;
  53767. zmin: number;
  53768. xmax: number;
  53769. zmax: number;
  53770. subdivisions?: {
  53771. w: number;
  53772. h: number;
  53773. };
  53774. precision?: {
  53775. w: number;
  53776. h: number;
  53777. };
  53778. updatable?: boolean;
  53779. }, scene?: Nullable<Scene>): Mesh;
  53780. /**
  53781. * Creates a ground mesh from a height map
  53782. * * The parameter `url` sets the URL of the height map image resource.
  53783. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53784. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53785. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53786. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53787. * * 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.
  53788. * * 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).
  53789. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53791. * @param name defines the name of the mesh
  53792. * @param url defines the url to the height map
  53793. * @param options defines the options used to create the mesh
  53794. * @param scene defines the hosting scene
  53795. * @returns the ground mesh
  53796. * @see https://doc.babylonjs.com/babylon101/height_map
  53797. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53798. */
  53799. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53800. width?: number;
  53801. height?: number;
  53802. subdivisions?: number;
  53803. minHeight?: number;
  53804. maxHeight?: number;
  53805. colorFilter?: Color3;
  53806. alphaFilter?: number;
  53807. updatable?: boolean;
  53808. onReady?: (mesh: GroundMesh) => void;
  53809. }, scene?: Nullable<Scene>): GroundMesh;
  53810. }
  53811. }
  53812. declare module BABYLON {
  53813. /**
  53814. * Class containing static functions to help procedurally build meshes
  53815. */
  53816. export class TorusBuilder {
  53817. /**
  53818. * Creates a torus mesh
  53819. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  53820. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  53821. * * The parameter `tessellation` sets the number of torus sides (positive integer, default 16)
  53822. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53823. * * 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
  53824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53825. * @param name defines the name of the mesh
  53826. * @param options defines the options used to create the mesh
  53827. * @param scene defines the hosting scene
  53828. * @returns the torus mesh
  53829. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  53830. */
  53831. static CreateTorus(name: string, options: {
  53832. diameter?: number;
  53833. thickness?: number;
  53834. tessellation?: number;
  53835. updatable?: boolean;
  53836. sideOrientation?: number;
  53837. frontUVs?: Vector4;
  53838. backUVs?: Vector4;
  53839. }, scene: any): Mesh;
  53840. }
  53841. }
  53842. declare module BABYLON {
  53843. /**
  53844. * Class containing static functions to help procedurally build meshes
  53845. */
  53846. export class CylinderBuilder {
  53847. /**
  53848. * Creates a cylinder or a cone mesh
  53849. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  53850. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  53851. * * 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.
  53852. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  53853. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  53854. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  53855. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  53856. * * 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).
  53857. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  53858. * * 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).
  53859. * * 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
  53860. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  53861. * * 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
  53862. * * 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.
  53863. * * If `enclose` is false, a ring surface is one element.
  53864. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  53865. * * 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
  53866. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53867. * * 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
  53868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53869. * @param name defines the name of the mesh
  53870. * @param options defines the options used to create the mesh
  53871. * @param scene defines the hosting scene
  53872. * @returns the cylinder mesh
  53873. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  53874. */
  53875. static CreateCylinder(name: string, options: {
  53876. height?: number;
  53877. diameterTop?: number;
  53878. diameterBottom?: number;
  53879. diameter?: number;
  53880. tessellation?: number;
  53881. subdivisions?: number;
  53882. arc?: number;
  53883. faceColors?: Color4[];
  53884. faceUV?: Vector4[];
  53885. updatable?: boolean;
  53886. hasRings?: boolean;
  53887. enclose?: boolean;
  53888. cap?: number;
  53889. sideOrientation?: number;
  53890. frontUVs?: Vector4;
  53891. backUVs?: Vector4;
  53892. }, scene: any): Mesh;
  53893. }
  53894. }
  53895. declare module BABYLON {
  53896. /**
  53897. * States of the webXR experience
  53898. */
  53899. export enum WebXRState {
  53900. /**
  53901. * Transitioning to being in XR mode
  53902. */
  53903. ENTERING_XR = 0,
  53904. /**
  53905. * Transitioning to non XR mode
  53906. */
  53907. EXITING_XR = 1,
  53908. /**
  53909. * In XR mode and presenting
  53910. */
  53911. IN_XR = 2,
  53912. /**
  53913. * Not entered XR mode
  53914. */
  53915. NOT_IN_XR = 3
  53916. }
  53917. /**
  53918. * The state of the XR camera's tracking
  53919. */
  53920. export enum WebXRTrackingState {
  53921. /**
  53922. * No transformation received, device is not being tracked
  53923. */
  53924. NOT_TRACKING = 0,
  53925. /**
  53926. * Tracking lost - using emulated position
  53927. */
  53928. TRACKING_LOST = 1,
  53929. /**
  53930. * Transformation tracking works normally
  53931. */
  53932. TRACKING = 2
  53933. }
  53934. /**
  53935. * Abstraction of the XR render target
  53936. */
  53937. export interface WebXRRenderTarget extends IDisposable {
  53938. /**
  53939. * xrpresent context of the canvas which can be used to display/mirror xr content
  53940. */
  53941. canvasContext: WebGLRenderingContext;
  53942. /**
  53943. * xr layer for the canvas
  53944. */
  53945. xrLayer: Nullable<XRWebGLLayer>;
  53946. /**
  53947. * Initializes the xr layer for the session
  53948. * @param xrSession xr session
  53949. * @returns a promise that will resolve once the XR Layer has been created
  53950. */
  53951. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  53952. }
  53953. }
  53954. declare module BABYLON {
  53955. /**
  53956. * Configuration object for WebXR output canvas
  53957. */
  53958. export class WebXRManagedOutputCanvasOptions {
  53959. /**
  53960. * An optional canvas in case you wish to create it yourself and provide it here.
  53961. * If not provided, a new canvas will be created
  53962. */
  53963. canvasElement?: HTMLCanvasElement;
  53964. /**
  53965. * Options for this XR Layer output
  53966. */
  53967. canvasOptions?: XRWebGLLayerInit;
  53968. /**
  53969. * CSS styling for a newly created canvas (if not provided)
  53970. */
  53971. newCanvasCssStyle?: string;
  53972. /**
  53973. * Get the default values of the configuration object
  53974. * @param engine defines the engine to use (can be null)
  53975. * @returns default values of this configuration object
  53976. */
  53977. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  53978. }
  53979. /**
  53980. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  53981. */
  53982. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  53983. private _options;
  53984. private _canvas;
  53985. private _engine;
  53986. private _originalCanvasSize;
  53987. /**
  53988. * Rendering context of the canvas which can be used to display/mirror xr content
  53989. */
  53990. canvasContext: WebGLRenderingContext;
  53991. /**
  53992. * xr layer for the canvas
  53993. */
  53994. xrLayer: Nullable<XRWebGLLayer>;
  53995. /**
  53996. * Observers registered here will be triggered when the xr layer was initialized
  53997. */
  53998. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  53999. /**
  54000. * Initializes the canvas to be added/removed upon entering/exiting xr
  54001. * @param _xrSessionManager The XR Session manager
  54002. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  54003. */
  54004. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  54005. /**
  54006. * Disposes of the object
  54007. */
  54008. dispose(): void;
  54009. /**
  54010. * Initializes the xr layer for the session
  54011. * @param xrSession xr session
  54012. * @returns a promise that will resolve once the XR Layer has been created
  54013. */
  54014. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  54015. private _addCanvas;
  54016. private _removeCanvas;
  54017. private _setCanvasSize;
  54018. private _setManagedOutputCanvas;
  54019. }
  54020. }
  54021. declare module BABYLON {
  54022. /**
  54023. * Manages an XRSession to work with Babylon's engine
  54024. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  54025. */
  54026. export class WebXRSessionManager implements IDisposable {
  54027. /** The scene which the session should be created for */
  54028. scene: Scene;
  54029. private _referenceSpace;
  54030. private _rttProvider;
  54031. private _sessionEnded;
  54032. private _xrNavigator;
  54033. private baseLayer;
  54034. /**
  54035. * The base reference space from which the session started. good if you want to reset your
  54036. * reference space
  54037. */
  54038. baseReferenceSpace: XRReferenceSpace;
  54039. /**
  54040. * Current XR frame
  54041. */
  54042. currentFrame: Nullable<XRFrame>;
  54043. /** WebXR timestamp updated every frame */
  54044. currentTimestamp: number;
  54045. /**
  54046. * Used just in case of a failure to initialize an immersive session.
  54047. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  54048. */
  54049. defaultHeightCompensation: number;
  54050. /**
  54051. * Fires every time a new xrFrame arrives which can be used to update the camera
  54052. */
  54053. onXRFrameObservable: Observable<XRFrame>;
  54054. /**
  54055. * Fires when the reference space changed
  54056. */
  54057. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  54058. /**
  54059. * Fires when the xr session is ended either by the device or manually done
  54060. */
  54061. onXRSessionEnded: Observable<any>;
  54062. /**
  54063. * Fires when the xr session is ended either by the device or manually done
  54064. */
  54065. onXRSessionInit: Observable<XRSession>;
  54066. /**
  54067. * Underlying xr session
  54068. */
  54069. session: XRSession;
  54070. /**
  54071. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  54072. * or get the offset the player is currently at.
  54073. */
  54074. viewerReferenceSpace: XRReferenceSpace;
  54075. /**
  54076. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  54077. * @param scene The scene which the session should be created for
  54078. */
  54079. constructor(
  54080. /** The scene which the session should be created for */
  54081. scene: Scene);
  54082. /**
  54083. * The current reference space used in this session. This reference space can constantly change!
  54084. * It is mainly used to offset the camera's position.
  54085. */
  54086. get referenceSpace(): XRReferenceSpace;
  54087. /**
  54088. * Set a new reference space and triggers the observable
  54089. */
  54090. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  54091. /**
  54092. * Disposes of the session manager
  54093. */
  54094. dispose(): void;
  54095. /**
  54096. * Stops the xrSession and restores the render loop
  54097. * @returns Promise which resolves after it exits XR
  54098. */
  54099. exitXRAsync(): Promise<void>;
  54100. /**
  54101. * Gets the correct render target texture to be rendered this frame for this eye
  54102. * @param eye the eye for which to get the render target
  54103. * @returns the render target for the specified eye
  54104. */
  54105. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  54106. /**
  54107. * Creates a WebXRRenderTarget object for the XR session
  54108. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  54109. * @param options optional options to provide when creating a new render target
  54110. * @returns a WebXR render target to which the session can render
  54111. */
  54112. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  54113. /**
  54114. * Initializes the manager
  54115. * After initialization enterXR can be called to start an XR session
  54116. * @returns Promise which resolves after it is initialized
  54117. */
  54118. initializeAsync(): Promise<void>;
  54119. /**
  54120. * Initializes an xr session
  54121. * @param xrSessionMode mode to initialize
  54122. * @param xrSessionInit defines optional and required values to pass to the session builder
  54123. * @returns a promise which will resolve once the session has been initialized
  54124. */
  54125. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  54126. /**
  54127. * Checks if a session would be supported for the creation options specified
  54128. * @param sessionMode session mode to check if supported eg. immersive-vr
  54129. * @returns A Promise that resolves to true if supported and false if not
  54130. */
  54131. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  54132. /**
  54133. * Resets the reference space to the one started the session
  54134. */
  54135. resetReferenceSpace(): void;
  54136. /**
  54137. * Starts rendering to the xr layer
  54138. */
  54139. runXRRenderLoop(): void;
  54140. /**
  54141. * Sets the reference space on the xr session
  54142. * @param referenceSpaceType space to set
  54143. * @returns a promise that will resolve once the reference space has been set
  54144. */
  54145. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  54146. /**
  54147. * Updates the render state of the session
  54148. * @param state state to set
  54149. * @returns a promise that resolves once the render state has been updated
  54150. */
  54151. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  54152. /**
  54153. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  54154. * @param sessionMode defines the session to test
  54155. * @returns a promise with boolean as final value
  54156. */
  54157. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  54158. /**
  54159. * Returns true if Babylon.js is using the BabylonNative backend, otherwise false
  54160. */
  54161. get isNative(): boolean;
  54162. private _createRenderTargetTexture;
  54163. }
  54164. }
  54165. declare module BABYLON {
  54166. /**
  54167. * WebXR Camera which holds the views for the xrSession
  54168. * @see https://doc.babylonjs.com/how_to/webxr_camera
  54169. */
  54170. export class WebXRCamera extends FreeCamera {
  54171. private _xrSessionManager;
  54172. private _firstFrame;
  54173. private _referenceQuaternion;
  54174. private _referencedPosition;
  54175. private _xrInvPositionCache;
  54176. private _xrInvQuaternionCache;
  54177. private _trackingState;
  54178. /**
  54179. * Observable raised before camera teleportation
  54180. */
  54181. onBeforeCameraTeleport: Observable<Vector3>;
  54182. /**
  54183. * Observable raised after camera teleportation
  54184. */
  54185. onAfterCameraTeleport: Observable<Vector3>;
  54186. /**
  54187. * Notifies when the camera's tracking state has changed.
  54188. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  54189. */
  54190. onTrackingStateChanged: Observable<WebXRTrackingState>;
  54191. /**
  54192. * Should position compensation execute on first frame.
  54193. * This is used when copying the position from a native (non XR) camera
  54194. */
  54195. compensateOnFirstFrame: boolean;
  54196. /**
  54197. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  54198. * @param name the name of the camera
  54199. * @param scene the scene to add the camera to
  54200. * @param _xrSessionManager a constructed xr session manager
  54201. */
  54202. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  54203. /**
  54204. * Get the current XR tracking state of the camera
  54205. */
  54206. get trackingState(): WebXRTrackingState;
  54207. private _setTrackingState;
  54208. /**
  54209. * Return the user's height, unrelated to the current ground.
  54210. * This will be the y position of this camera, when ground level is 0.
  54211. */
  54212. get realWorldHeight(): number;
  54213. /** @hidden */
  54214. _updateForDualEyeDebugging(): void;
  54215. /**
  54216. * Sets this camera's transformation based on a non-vr camera
  54217. * @param otherCamera the non-vr camera to copy the transformation from
  54218. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  54219. */
  54220. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  54221. /**
  54222. * Gets the current instance class name ("WebXRCamera").
  54223. * @returns the class name
  54224. */
  54225. getClassName(): string;
  54226. private _rotate180;
  54227. private _updateFromXRSession;
  54228. private _updateNumberOfRigCameras;
  54229. private _updateReferenceSpace;
  54230. private _updateReferenceSpaceOffset;
  54231. }
  54232. }
  54233. declare module BABYLON {
  54234. /**
  54235. * Defining the interface required for a (webxr) feature
  54236. */
  54237. export interface IWebXRFeature extends IDisposable {
  54238. /**
  54239. * Is this feature attached
  54240. */
  54241. attached: boolean;
  54242. /**
  54243. * Should auto-attach be disabled?
  54244. */
  54245. disableAutoAttach: boolean;
  54246. /**
  54247. * Attach the feature to the session
  54248. * Will usually be called by the features manager
  54249. *
  54250. * @param force should attachment be forced (even when already attached)
  54251. * @returns true if successful.
  54252. */
  54253. attach(force?: boolean): boolean;
  54254. /**
  54255. * Detach the feature from the session
  54256. * Will usually be called by the features manager
  54257. *
  54258. * @returns true if successful.
  54259. */
  54260. detach(): boolean;
  54261. /**
  54262. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  54263. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  54264. *
  54265. * @returns whether or not the feature is compatible in this environment
  54266. */
  54267. isCompatible(): boolean;
  54268. /**
  54269. * Was this feature disposed;
  54270. */
  54271. isDisposed: boolean;
  54272. /**
  54273. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  54274. */
  54275. xrNativeFeatureName?: string;
  54276. /**
  54277. * A list of (Babylon WebXR) features this feature depends on
  54278. */
  54279. dependsOn?: string[];
  54280. /**
  54281. * If this feature requires to extend the XRSessionInit object, this function will return the partial XR session init object
  54282. */
  54283. getXRSessionInitExtension?: () => Promise<Partial<XRSessionInit>>;
  54284. }
  54285. /**
  54286. * A list of the currently available features without referencing them
  54287. */
  54288. export class WebXRFeatureName {
  54289. /**
  54290. * The name of the anchor system feature
  54291. */
  54292. static readonly ANCHOR_SYSTEM: string;
  54293. /**
  54294. * The name of the background remover feature
  54295. */
  54296. static readonly BACKGROUND_REMOVER: string;
  54297. /**
  54298. * The name of the hit test feature
  54299. */
  54300. static readonly HIT_TEST: string;
  54301. /**
  54302. * The name of the mesh detection feature
  54303. */
  54304. static readonly MESH_DETECTION: string;
  54305. /**
  54306. * physics impostors for xr controllers feature
  54307. */
  54308. static readonly PHYSICS_CONTROLLERS: string;
  54309. /**
  54310. * The name of the plane detection feature
  54311. */
  54312. static readonly PLANE_DETECTION: string;
  54313. /**
  54314. * The name of the pointer selection feature
  54315. */
  54316. static readonly POINTER_SELECTION: string;
  54317. /**
  54318. * The name of the teleportation feature
  54319. */
  54320. static readonly TELEPORTATION: string;
  54321. /**
  54322. * The name of the feature points feature.
  54323. */
  54324. static readonly FEATURE_POINTS: string;
  54325. /**
  54326. * The name of the hand tracking feature.
  54327. */
  54328. static readonly HAND_TRACKING: string;
  54329. /**
  54330. * The name of the image tracking feature
  54331. */
  54332. static readonly IMAGE_TRACKING: string;
  54333. }
  54334. /**
  54335. * Defining the constructor of a feature. Used to register the modules.
  54336. */
  54337. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  54338. /**
  54339. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  54340. * It is mainly used in AR sessions.
  54341. *
  54342. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  54343. */
  54344. export class WebXRFeaturesManager implements IDisposable {
  54345. private _xrSessionManager;
  54346. private static readonly _AvailableFeatures;
  54347. private _features;
  54348. /**
  54349. * constructs a new features manages.
  54350. *
  54351. * @param _xrSessionManager an instance of WebXRSessionManager
  54352. */
  54353. constructor(_xrSessionManager: WebXRSessionManager);
  54354. /**
  54355. * Used to register a module. After calling this function a developer can use this feature in the scene.
  54356. * Mainly used internally.
  54357. *
  54358. * @param featureName the name of the feature to register
  54359. * @param constructorFunction the function used to construct the module
  54360. * @param version the (babylon) version of the module
  54361. * @param stable is that a stable version of this module
  54362. */
  54363. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  54364. /**
  54365. * Returns a constructor of a specific feature.
  54366. *
  54367. * @param featureName the name of the feature to construct
  54368. * @param version the version of the feature to load
  54369. * @param xrSessionManager the xrSessionManager. Used to construct the module
  54370. * @param options optional options provided to the module.
  54371. * @returns a function that, when called, will return a new instance of this feature
  54372. */
  54373. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  54374. /**
  54375. * Can be used to return the list of features currently registered
  54376. *
  54377. * @returns an Array of available features
  54378. */
  54379. static GetAvailableFeatures(): string[];
  54380. /**
  54381. * Gets the versions available for a specific feature
  54382. * @param featureName the name of the feature
  54383. * @returns an array with the available versions
  54384. */
  54385. static GetAvailableVersions(featureName: string): string[];
  54386. /**
  54387. * Return the latest unstable version of this feature
  54388. * @param featureName the name of the feature to search
  54389. * @returns the version number. if not found will return -1
  54390. */
  54391. static GetLatestVersionOfFeature(featureName: string): number;
  54392. /**
  54393. * Return the latest stable version of this feature
  54394. * @param featureName the name of the feature to search
  54395. * @returns the version number. if not found will return -1
  54396. */
  54397. static GetStableVersionOfFeature(featureName: string): number;
  54398. /**
  54399. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  54400. * Can be used during a session to start a feature
  54401. * @param featureName the name of feature to attach
  54402. */
  54403. attachFeature(featureName: string): void;
  54404. /**
  54405. * Can be used inside a session or when the session ends to detach a specific feature
  54406. * @param featureName the name of the feature to detach
  54407. */
  54408. detachFeature(featureName: string): void;
  54409. /**
  54410. * Used to disable an already-enabled feature
  54411. * The feature will be disposed and will be recreated once enabled.
  54412. * @param featureName the feature to disable
  54413. * @returns true if disable was successful
  54414. */
  54415. disableFeature(featureName: string | {
  54416. Name: string;
  54417. }): boolean;
  54418. /**
  54419. * dispose this features manager
  54420. */
  54421. dispose(): void;
  54422. /**
  54423. * 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.
  54424. * 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.
  54425. *
  54426. * @param featureName the name of the feature to load or the class of the feature
  54427. * @param version optional version to load. if not provided the latest version will be enabled
  54428. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  54429. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  54430. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  54431. * @returns a new constructed feature or throws an error if feature not found.
  54432. */
  54433. enableFeature(featureName: string | {
  54434. Name: string;
  54435. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  54436. /**
  54437. * get the implementation of an enabled feature.
  54438. * @param featureName the name of the feature to load
  54439. * @returns the feature class, if found
  54440. */
  54441. getEnabledFeature(featureName: string): IWebXRFeature;
  54442. /**
  54443. * Get the list of enabled features
  54444. * @returns an array of enabled features
  54445. */
  54446. getEnabledFeatures(): string[];
  54447. /**
  54448. * This function will extend the session creation configuration object with enabled features.
  54449. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  54450. * according to the defined "required" variable, provided during enableFeature call
  54451. * @param xrSessionInit the xr Session init object to extend
  54452. *
  54453. * @returns an extended XRSessionInit object
  54454. */
  54455. _extendXRSessionInitObject(xrSessionInit: XRSessionInit): Promise<XRSessionInit>;
  54456. }
  54457. }
  54458. declare module BABYLON {
  54459. /**
  54460. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  54461. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  54462. */
  54463. export class WebXRExperienceHelper implements IDisposable {
  54464. private scene;
  54465. private _nonVRCamera;
  54466. private _originalSceneAutoClear;
  54467. private _supported;
  54468. /**
  54469. * Camera used to render xr content
  54470. */
  54471. camera: WebXRCamera;
  54472. /** A features manager for this xr session */
  54473. featuresManager: WebXRFeaturesManager;
  54474. /**
  54475. * Observers registered here will be triggered after the camera's initial transformation is set
  54476. * This can be used to set a different ground level or an extra rotation.
  54477. *
  54478. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  54479. * to the position set after this observable is done executing.
  54480. */
  54481. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  54482. /**
  54483. * Fires when the state of the experience helper has changed
  54484. */
  54485. onStateChangedObservable: Observable<WebXRState>;
  54486. /** Session manager used to keep track of xr session */
  54487. sessionManager: WebXRSessionManager;
  54488. /**
  54489. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  54490. */
  54491. state: WebXRState;
  54492. /**
  54493. * Creates a WebXRExperienceHelper
  54494. * @param scene The scene the helper should be created in
  54495. */
  54496. private constructor();
  54497. /**
  54498. * Creates the experience helper
  54499. * @param scene the scene to attach the experience helper to
  54500. * @returns a promise for the experience helper
  54501. */
  54502. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  54503. /**
  54504. * Disposes of the experience helper
  54505. */
  54506. dispose(): void;
  54507. /**
  54508. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  54509. * @param sessionMode options for the XR session
  54510. * @param referenceSpaceType frame of reference of the XR session
  54511. * @param renderTarget the output canvas that will be used to enter XR mode
  54512. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  54513. * @returns promise that resolves after xr mode has entered
  54514. */
  54515. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  54516. /**
  54517. * Exits XR mode and returns the scene to its original state
  54518. * @returns promise that resolves after xr mode has exited
  54519. */
  54520. exitXRAsync(): Promise<void>;
  54521. private _nonXRToXRCamera;
  54522. private _setState;
  54523. }
  54524. }
  54525. declare module BABYLON {
  54526. /**
  54527. * X-Y values for axes in WebXR
  54528. */
  54529. export interface IWebXRMotionControllerAxesValue {
  54530. /**
  54531. * The value of the x axis
  54532. */
  54533. x: number;
  54534. /**
  54535. * The value of the y-axis
  54536. */
  54537. y: number;
  54538. }
  54539. /**
  54540. * changed / previous values for the values of this component
  54541. */
  54542. export interface IWebXRMotionControllerComponentChangesValues<T> {
  54543. /**
  54544. * current (this frame) value
  54545. */
  54546. current: T;
  54547. /**
  54548. * previous (last change) value
  54549. */
  54550. previous: T;
  54551. }
  54552. /**
  54553. * Represents changes in the component between current frame and last values recorded
  54554. */
  54555. export interface IWebXRMotionControllerComponentChanges {
  54556. /**
  54557. * will be populated with previous and current values if axes changed
  54558. */
  54559. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  54560. /**
  54561. * will be populated with previous and current values if pressed changed
  54562. */
  54563. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  54564. /**
  54565. * will be populated with previous and current values if touched changed
  54566. */
  54567. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  54568. /**
  54569. * will be populated with previous and current values if value changed
  54570. */
  54571. value?: IWebXRMotionControllerComponentChangesValues<number>;
  54572. }
  54573. /**
  54574. * This class represents a single component (for example button or thumbstick) of a motion controller
  54575. */
  54576. export class WebXRControllerComponent implements IDisposable {
  54577. /**
  54578. * the id of this component
  54579. */
  54580. id: string;
  54581. /**
  54582. * the type of the component
  54583. */
  54584. type: MotionControllerComponentType;
  54585. private _buttonIndex;
  54586. private _axesIndices;
  54587. private _axes;
  54588. private _changes;
  54589. private _currentValue;
  54590. private _hasChanges;
  54591. private _pressed;
  54592. private _touched;
  54593. /**
  54594. * button component type
  54595. */
  54596. static BUTTON_TYPE: MotionControllerComponentType;
  54597. /**
  54598. * squeeze component type
  54599. */
  54600. static SQUEEZE_TYPE: MotionControllerComponentType;
  54601. /**
  54602. * Thumbstick component type
  54603. */
  54604. static THUMBSTICK_TYPE: MotionControllerComponentType;
  54605. /**
  54606. * Touchpad component type
  54607. */
  54608. static TOUCHPAD_TYPE: MotionControllerComponentType;
  54609. /**
  54610. * trigger component type
  54611. */
  54612. static TRIGGER_TYPE: MotionControllerComponentType;
  54613. /**
  54614. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  54615. * the axes data changes
  54616. */
  54617. onAxisValueChangedObservable: Observable<{
  54618. x: number;
  54619. y: number;
  54620. }>;
  54621. /**
  54622. * Observers registered here will be triggered when the state of a button changes
  54623. * State change is either pressed / touched / value
  54624. */
  54625. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  54626. /**
  54627. * Creates a new component for a motion controller.
  54628. * It is created by the motion controller itself
  54629. *
  54630. * @param id the id of this component
  54631. * @param type the type of the component
  54632. * @param _buttonIndex index in the buttons array of the gamepad
  54633. * @param _axesIndices indices of the values in the axes array of the gamepad
  54634. */
  54635. constructor(
  54636. /**
  54637. * the id of this component
  54638. */
  54639. id: string,
  54640. /**
  54641. * the type of the component
  54642. */
  54643. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  54644. /**
  54645. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  54646. */
  54647. get axes(): IWebXRMotionControllerAxesValue;
  54648. /**
  54649. * Get the changes. Elements will be populated only if they changed with their previous and current value
  54650. */
  54651. get changes(): IWebXRMotionControllerComponentChanges;
  54652. /**
  54653. * Return whether or not the component changed the last frame
  54654. */
  54655. get hasChanges(): boolean;
  54656. /**
  54657. * is the button currently pressed
  54658. */
  54659. get pressed(): boolean;
  54660. /**
  54661. * is the button currently touched
  54662. */
  54663. get touched(): boolean;
  54664. /**
  54665. * Get the current value of this component
  54666. */
  54667. get value(): number;
  54668. /**
  54669. * Dispose this component
  54670. */
  54671. dispose(): void;
  54672. /**
  54673. * Are there axes correlating to this component
  54674. * @return true is axes data is available
  54675. */
  54676. isAxes(): boolean;
  54677. /**
  54678. * Is this component a button (hence - pressable)
  54679. * @returns true if can be pressed
  54680. */
  54681. isButton(): boolean;
  54682. /**
  54683. * update this component using the gamepad object it is in. Called on every frame
  54684. * @param nativeController the native gamepad controller object
  54685. */
  54686. update(nativeController: IMinimalMotionControllerObject): void;
  54687. }
  54688. }
  54689. declare module BABYLON {
  54690. /**
  54691. * Type used for the success callback of ImportMesh
  54692. */
  54693. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  54694. /**
  54695. * Interface used for the result of ImportMeshAsync
  54696. */
  54697. export interface ISceneLoaderAsyncResult {
  54698. /**
  54699. * The array of loaded meshes
  54700. */
  54701. readonly meshes: AbstractMesh[];
  54702. /**
  54703. * The array of loaded particle systems
  54704. */
  54705. readonly particleSystems: IParticleSystem[];
  54706. /**
  54707. * The array of loaded skeletons
  54708. */
  54709. readonly skeletons: Skeleton[];
  54710. /**
  54711. * The array of loaded animation groups
  54712. */
  54713. readonly animationGroups: AnimationGroup[];
  54714. /**
  54715. * The array of loaded transform nodes
  54716. */
  54717. readonly transformNodes: TransformNode[];
  54718. /**
  54719. * The array of loaded geometries
  54720. */
  54721. readonly geometries: Geometry[];
  54722. /**
  54723. * The array of loaded lights
  54724. */
  54725. readonly lights: Light[];
  54726. }
  54727. /**
  54728. * Interface used to represent data loading progression
  54729. */
  54730. export interface ISceneLoaderProgressEvent {
  54731. /**
  54732. * Defines if data length to load can be evaluated
  54733. */
  54734. readonly lengthComputable: boolean;
  54735. /**
  54736. * Defines the loaded data length
  54737. */
  54738. readonly loaded: number;
  54739. /**
  54740. * Defines the data length to load
  54741. */
  54742. readonly total: number;
  54743. }
  54744. /**
  54745. * Interface used by SceneLoader plugins to define supported file extensions
  54746. */
  54747. export interface ISceneLoaderPluginExtensions {
  54748. /**
  54749. * Defines the list of supported extensions
  54750. */
  54751. [extension: string]: {
  54752. isBinary: boolean;
  54753. };
  54754. }
  54755. /**
  54756. * Interface used by SceneLoader plugin factory
  54757. */
  54758. export interface ISceneLoaderPluginFactory {
  54759. /**
  54760. * Defines the name of the factory
  54761. */
  54762. name: string;
  54763. /**
  54764. * Function called to create a new plugin
  54765. * @return the new plugin
  54766. */
  54767. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  54768. /**
  54769. * The callback that returns true if the data can be directly loaded.
  54770. * @param data string containing the file data
  54771. * @returns if the data can be loaded directly
  54772. */
  54773. canDirectLoad?(data: string): boolean;
  54774. }
  54775. /**
  54776. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  54777. */
  54778. export interface ISceneLoaderPluginBase {
  54779. /**
  54780. * The friendly name of this plugin.
  54781. */
  54782. name: string;
  54783. /**
  54784. * The file extensions supported by this plugin.
  54785. */
  54786. extensions: string | ISceneLoaderPluginExtensions;
  54787. /**
  54788. * The callback called when loading from a url.
  54789. * @param scene scene loading this url
  54790. * @param url url to load
  54791. * @param onSuccess callback called when the file successfully loads
  54792. * @param onProgress callback called while file is loading (if the server supports this mode)
  54793. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  54794. * @param onError callback called when the file fails to load
  54795. * @returns a file request object
  54796. */
  54797. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  54798. /**
  54799. * The callback called when loading from a file object.
  54800. * @param scene scene loading this file
  54801. * @param file defines the file to load
  54802. * @param onSuccess defines the callback to call when data is loaded
  54803. * @param onProgress defines the callback to call during loading process
  54804. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  54805. * @param onError defines the callback to call when an error occurs
  54806. * @returns a file request object
  54807. */
  54808. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  54809. /**
  54810. * The callback that returns true if the data can be directly loaded.
  54811. * @param data string containing the file data
  54812. * @returns if the data can be loaded directly
  54813. */
  54814. canDirectLoad?(data: string): boolean;
  54815. /**
  54816. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  54817. * @param scene scene loading this data
  54818. * @param data string containing the data
  54819. * @returns data to pass to the plugin
  54820. */
  54821. directLoad?(scene: Scene, data: string): any;
  54822. /**
  54823. * The callback that allows custom handling of the root url based on the response url.
  54824. * @param rootUrl the original root url
  54825. * @param responseURL the response url if available
  54826. * @returns the new root url
  54827. */
  54828. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  54829. }
  54830. /**
  54831. * Interface used to define a SceneLoader plugin
  54832. */
  54833. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  54834. /**
  54835. * Import meshes into a scene.
  54836. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54837. * @param scene The scene to import into
  54838. * @param data The data to import
  54839. * @param rootUrl The root url for scene and resources
  54840. * @param meshes The meshes array to import into
  54841. * @param particleSystems The particle systems array to import into
  54842. * @param skeletons The skeletons array to import into
  54843. * @param onError The callback when import fails
  54844. * @returns True if successful or false otherwise
  54845. */
  54846. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  54847. /**
  54848. * Load into a scene.
  54849. * @param scene The scene to load into
  54850. * @param data The data to import
  54851. * @param rootUrl The root url for scene and resources
  54852. * @param onError The callback when import fails
  54853. * @returns True if successful or false otherwise
  54854. */
  54855. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  54856. /**
  54857. * Load into an asset container.
  54858. * @param scene The scene to load into
  54859. * @param data The data to import
  54860. * @param rootUrl The root url for scene and resources
  54861. * @param onError The callback when import fails
  54862. * @returns The loaded asset container
  54863. */
  54864. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  54865. }
  54866. /**
  54867. * Interface used to define an async SceneLoader plugin
  54868. */
  54869. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  54870. /**
  54871. * Import meshes into a scene.
  54872. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54873. * @param scene The scene to import into
  54874. * @param data The data to import
  54875. * @param rootUrl The root url for scene and resources
  54876. * @param onProgress The callback when the load progresses
  54877. * @param fileName Defines the name of the file to load
  54878. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  54879. */
  54880. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  54881. /**
  54882. * Load into a scene.
  54883. * @param scene The scene to load into
  54884. * @param data The data to import
  54885. * @param rootUrl The root url for scene and resources
  54886. * @param onProgress The callback when the load progresses
  54887. * @param fileName Defines the name of the file to load
  54888. * @returns Nothing
  54889. */
  54890. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  54891. /**
  54892. * Load into an asset container.
  54893. * @param scene The scene to load into
  54894. * @param data The data to import
  54895. * @param rootUrl The root url for scene and resources
  54896. * @param onProgress The callback when the load progresses
  54897. * @param fileName Defines the name of the file to load
  54898. * @returns The loaded asset container
  54899. */
  54900. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  54901. }
  54902. /**
  54903. * Mode that determines how to handle old animation groups before loading new ones.
  54904. */
  54905. export enum SceneLoaderAnimationGroupLoadingMode {
  54906. /**
  54907. * Reset all old animations to initial state then dispose them.
  54908. */
  54909. Clean = 0,
  54910. /**
  54911. * Stop all old animations.
  54912. */
  54913. Stop = 1,
  54914. /**
  54915. * Restart old animations from first frame.
  54916. */
  54917. Sync = 2,
  54918. /**
  54919. * Old animations remains untouched.
  54920. */
  54921. NoSync = 3
  54922. }
  54923. /**
  54924. * Defines a plugin registered by the SceneLoader
  54925. */
  54926. interface IRegisteredPlugin {
  54927. /**
  54928. * Defines the plugin to use
  54929. */
  54930. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  54931. /**
  54932. * Defines if the plugin supports binary data
  54933. */
  54934. isBinary: boolean;
  54935. }
  54936. /**
  54937. * Class used to load scene from various file formats using registered plugins
  54938. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  54939. */
  54940. export class SceneLoader {
  54941. /**
  54942. * No logging while loading
  54943. */
  54944. static readonly NO_LOGGING: number;
  54945. /**
  54946. * Minimal logging while loading
  54947. */
  54948. static readonly MINIMAL_LOGGING: number;
  54949. /**
  54950. * Summary logging while loading
  54951. */
  54952. static readonly SUMMARY_LOGGING: number;
  54953. /**
  54954. * Detailed logging while loading
  54955. */
  54956. static readonly DETAILED_LOGGING: number;
  54957. /**
  54958. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  54959. */
  54960. static get ForceFullSceneLoadingForIncremental(): boolean;
  54961. static set ForceFullSceneLoadingForIncremental(value: boolean);
  54962. /**
  54963. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  54964. */
  54965. static get ShowLoadingScreen(): boolean;
  54966. static set ShowLoadingScreen(value: boolean);
  54967. /**
  54968. * Defines the current logging level (while loading the scene)
  54969. * @ignorenaming
  54970. */
  54971. static get loggingLevel(): number;
  54972. static set loggingLevel(value: number);
  54973. /**
  54974. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  54975. */
  54976. static get CleanBoneMatrixWeights(): boolean;
  54977. static set CleanBoneMatrixWeights(value: boolean);
  54978. /**
  54979. * Event raised when a plugin is used to load a scene
  54980. */
  54981. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  54982. private static _registeredPlugins;
  54983. private static _showingLoadingScreen;
  54984. /**
  54985. * Gets the default plugin (used to load Babylon files)
  54986. * @returns the .babylon plugin
  54987. */
  54988. static GetDefaultPlugin(): IRegisteredPlugin;
  54989. private static _GetPluginForExtension;
  54990. private static _GetPluginForDirectLoad;
  54991. private static _GetPluginForFilename;
  54992. private static _GetDirectLoad;
  54993. private static _LoadData;
  54994. private static _GetFileInfo;
  54995. /**
  54996. * Gets a plugin that can load the given extension
  54997. * @param extension defines the extension to load
  54998. * @returns a plugin or null if none works
  54999. */
  55000. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  55001. /**
  55002. * Gets a boolean indicating that the given extension can be loaded
  55003. * @param extension defines the extension to load
  55004. * @returns true if the extension is supported
  55005. */
  55006. static IsPluginForExtensionAvailable(extension: string): boolean;
  55007. /**
  55008. * Adds a new plugin to the list of registered plugins
  55009. * @param plugin defines the plugin to add
  55010. */
  55011. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  55012. /**
  55013. * Import meshes into a scene
  55014. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  55015. * @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)
  55016. * @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)
  55017. * @param scene the instance of BABYLON.Scene to append to
  55018. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  55019. * @param onProgress a callback with a progress event for each file being loaded
  55020. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55021. * @param pluginExtension the extension used to determine the plugin
  55022. * @returns The loaded plugin
  55023. */
  55024. 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>;
  55025. /**
  55026. * Import meshes into a scene
  55027. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  55028. * @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)
  55029. * @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)
  55030. * @param scene the instance of BABYLON.Scene to append to
  55031. * @param onProgress a callback with a progress event for each file being loaded
  55032. * @param pluginExtension the extension used to determine the plugin
  55033. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  55034. */
  55035. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  55036. /**
  55037. * Load a scene
  55038. * @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)
  55039. * @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)
  55040. * @param engine is the instance of BABYLON.Engine to use to create the scene
  55041. * @param onSuccess a callback with the scene when import succeeds
  55042. * @param onProgress a callback with a progress event for each file being loaded
  55043. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55044. * @param pluginExtension the extension used to determine the plugin
  55045. * @returns The loaded plugin
  55046. */
  55047. 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>;
  55048. /**
  55049. * Load a scene
  55050. * @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)
  55051. * @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)
  55052. * @param engine is the instance of BABYLON.Engine to use to create the scene
  55053. * @param onProgress a callback with a progress event for each file being loaded
  55054. * @param pluginExtension the extension used to determine the plugin
  55055. * @returns The loaded scene
  55056. */
  55057. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  55058. /**
  55059. * Append a scene
  55060. * @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)
  55061. * @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)
  55062. * @param scene is the instance of BABYLON.Scene to append to
  55063. * @param onSuccess a callback with the scene when import succeeds
  55064. * @param onProgress a callback with a progress event for each file being loaded
  55065. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55066. * @param pluginExtension the extension used to determine the plugin
  55067. * @returns The loaded plugin
  55068. */
  55069. 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>;
  55070. /**
  55071. * Append a scene
  55072. * @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)
  55073. * @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)
  55074. * @param scene is the instance of BABYLON.Scene to append to
  55075. * @param onProgress a callback with a progress event for each file being loaded
  55076. * @param pluginExtension the extension used to determine the plugin
  55077. * @returns The given scene
  55078. */
  55079. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  55080. /**
  55081. * Load a scene into an asset container
  55082. * @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)
  55083. * @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)
  55084. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  55085. * @param onSuccess a callback with the scene when import succeeds
  55086. * @param onProgress a callback with a progress event for each file being loaded
  55087. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55088. * @param pluginExtension the extension used to determine the plugin
  55089. * @returns The loaded plugin
  55090. */
  55091. 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>;
  55092. /**
  55093. * Load a scene into an asset container
  55094. * @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)
  55095. * @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)
  55096. * @param scene is the instance of Scene to append to
  55097. * @param onProgress a callback with a progress event for each file being loaded
  55098. * @param pluginExtension the extension used to determine the plugin
  55099. * @returns The loaded asset container
  55100. */
  55101. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  55102. /**
  55103. * Import animations from a file into a scene
  55104. * @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)
  55105. * @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)
  55106. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  55107. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  55108. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  55109. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  55110. * @param onSuccess a callback with the scene when import succeeds
  55111. * @param onProgress a callback with a progress event for each file being loaded
  55112. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55113. * @param pluginExtension the extension used to determine the plugin
  55114. */
  55115. 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;
  55116. /**
  55117. * Import animations from a file into a scene
  55118. * @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)
  55119. * @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)
  55120. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  55121. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  55122. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  55123. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  55124. * @param onSuccess a callback with the scene when import succeeds
  55125. * @param onProgress a callback with a progress event for each file being loaded
  55126. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55127. * @param pluginExtension the extension used to determine the plugin
  55128. * @returns the updated scene with imported animations
  55129. */
  55130. 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>;
  55131. }
  55132. }
  55133. declare module BABYLON {
  55134. /**
  55135. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  55136. */
  55137. export type MotionControllerHandedness = "none" | "left" | "right";
  55138. /**
  55139. * The type of components available in motion controllers.
  55140. * This is not the name of the component.
  55141. */
  55142. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  55143. /**
  55144. * The state of a controller component
  55145. */
  55146. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  55147. /**
  55148. * The schema of motion controller layout.
  55149. * No object will be initialized using this interface
  55150. * This is used just to define the profile.
  55151. */
  55152. export interface IMotionControllerLayout {
  55153. /**
  55154. * Path to load the assets. Usually relative to the base path
  55155. */
  55156. assetPath: string;
  55157. /**
  55158. * Available components (unsorted)
  55159. */
  55160. components: {
  55161. /**
  55162. * A map of component Ids
  55163. */
  55164. [componentId: string]: {
  55165. /**
  55166. * The type of input the component outputs
  55167. */
  55168. type: MotionControllerComponentType;
  55169. /**
  55170. * The indices of this component in the gamepad object
  55171. */
  55172. gamepadIndices: {
  55173. /**
  55174. * Index of button
  55175. */
  55176. button?: number;
  55177. /**
  55178. * If available, index of x-axis
  55179. */
  55180. xAxis?: number;
  55181. /**
  55182. * If available, index of y-axis
  55183. */
  55184. yAxis?: number;
  55185. };
  55186. /**
  55187. * The mesh's root node name
  55188. */
  55189. rootNodeName: string;
  55190. /**
  55191. * Animation definitions for this model
  55192. */
  55193. visualResponses: {
  55194. [stateKey: string]: {
  55195. /**
  55196. * What property will be animated
  55197. */
  55198. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  55199. /**
  55200. * What states influence this visual response
  55201. */
  55202. states: MotionControllerComponentStateType[];
  55203. /**
  55204. * Type of animation - movement or visibility
  55205. */
  55206. valueNodeProperty: "transform" | "visibility";
  55207. /**
  55208. * Base node name to move. Its position will be calculated according to the min and max nodes
  55209. */
  55210. valueNodeName?: string;
  55211. /**
  55212. * Minimum movement node
  55213. */
  55214. minNodeName?: string;
  55215. /**
  55216. * Max movement node
  55217. */
  55218. maxNodeName?: string;
  55219. };
  55220. };
  55221. /**
  55222. * If touch enabled, what is the name of node to display user feedback
  55223. */
  55224. touchPointNodeName?: string;
  55225. };
  55226. };
  55227. /**
  55228. * Is it xr standard mapping or not
  55229. */
  55230. gamepadMapping: "" | "xr-standard";
  55231. /**
  55232. * Base root node of this entire model
  55233. */
  55234. rootNodeName: string;
  55235. /**
  55236. * Defines the main button component id
  55237. */
  55238. selectComponentId: string;
  55239. }
  55240. /**
  55241. * A definition for the layout map in the input profile
  55242. */
  55243. export interface IMotionControllerLayoutMap {
  55244. /**
  55245. * Layouts with handedness type as a key
  55246. */
  55247. [handedness: string]: IMotionControllerLayout;
  55248. }
  55249. /**
  55250. * The XR Input profile schema
  55251. * Profiles can be found here:
  55252. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  55253. */
  55254. export interface IMotionControllerProfile {
  55255. /**
  55256. * fallback profiles for this profileId
  55257. */
  55258. fallbackProfileIds: string[];
  55259. /**
  55260. * The layout map, with handedness as key
  55261. */
  55262. layouts: IMotionControllerLayoutMap;
  55263. /**
  55264. * The id of this profile
  55265. * correlates to the profile(s) in the xrInput.profiles array
  55266. */
  55267. profileId: string;
  55268. }
  55269. /**
  55270. * A helper-interface for the 3 meshes needed for controller button animation
  55271. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  55272. */
  55273. export interface IMotionControllerButtonMeshMap {
  55274. /**
  55275. * the mesh that defines the pressed value mesh position.
  55276. * This is used to find the max-position of this button
  55277. */
  55278. pressedMesh: AbstractMesh;
  55279. /**
  55280. * the mesh that defines the unpressed value mesh position.
  55281. * This is used to find the min (or initial) position of this button
  55282. */
  55283. unpressedMesh: AbstractMesh;
  55284. /**
  55285. * The mesh that will be changed when value changes
  55286. */
  55287. valueMesh: AbstractMesh;
  55288. }
  55289. /**
  55290. * A helper-interface for the 3 meshes needed for controller axis animation.
  55291. * This will be expanded when touchpad animations are fully supported
  55292. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  55293. */
  55294. export interface IMotionControllerMeshMap {
  55295. /**
  55296. * the mesh that defines the maximum value mesh position.
  55297. */
  55298. maxMesh?: AbstractMesh;
  55299. /**
  55300. * the mesh that defines the minimum value mesh position.
  55301. */
  55302. minMesh?: AbstractMesh;
  55303. /**
  55304. * The mesh that will be changed when axis value changes
  55305. */
  55306. valueMesh?: AbstractMesh;
  55307. }
  55308. /**
  55309. * The elements needed for change-detection of the gamepad objects in motion controllers
  55310. */
  55311. export interface IMinimalMotionControllerObject {
  55312. /**
  55313. * Available axes of this controller
  55314. */
  55315. axes: number[];
  55316. /**
  55317. * An array of available buttons
  55318. */
  55319. buttons: Array<{
  55320. /**
  55321. * Value of the button/trigger
  55322. */
  55323. value: number;
  55324. /**
  55325. * If the button/trigger is currently touched
  55326. */
  55327. touched: boolean;
  55328. /**
  55329. * If the button/trigger is currently pressed
  55330. */
  55331. pressed: boolean;
  55332. }>;
  55333. /**
  55334. * EXPERIMENTAL haptic support.
  55335. */
  55336. hapticActuators?: Array<{
  55337. pulse: (value: number, duration: number) => Promise<boolean>;
  55338. }>;
  55339. }
  55340. /**
  55341. * An Abstract Motion controller
  55342. * This class receives an xrInput and a profile layout and uses those to initialize the components
  55343. * Each component has an observable to check for changes in value and state
  55344. */
  55345. export abstract class WebXRAbstractMotionController implements IDisposable {
  55346. protected scene: Scene;
  55347. protected layout: IMotionControllerLayout;
  55348. /**
  55349. * The gamepad object correlating to this controller
  55350. */
  55351. gamepadObject: IMinimalMotionControllerObject;
  55352. /**
  55353. * handedness (left/right/none) of this controller
  55354. */
  55355. handedness: MotionControllerHandedness;
  55356. private _initComponent;
  55357. private _modelReady;
  55358. /**
  55359. * A map of components (WebXRControllerComponent) in this motion controller
  55360. * Components have a ComponentType and can also have both button and axis definitions
  55361. */
  55362. readonly components: {
  55363. [id: string]: WebXRControllerComponent;
  55364. };
  55365. /**
  55366. * Disable the model's animation. Can be set at any time.
  55367. */
  55368. disableAnimation: boolean;
  55369. /**
  55370. * Observers registered here will be triggered when the model of this controller is done loading
  55371. */
  55372. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  55373. /**
  55374. * The profile id of this motion controller
  55375. */
  55376. abstract profileId: string;
  55377. /**
  55378. * The root mesh of the model. It is null if the model was not yet initialized
  55379. */
  55380. rootMesh: Nullable<AbstractMesh>;
  55381. /**
  55382. * constructs a new abstract motion controller
  55383. * @param scene the scene to which the model of the controller will be added
  55384. * @param layout The profile layout to load
  55385. * @param gamepadObject The gamepad object correlating to this controller
  55386. * @param handedness handedness (left/right/none) of this controller
  55387. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  55388. */
  55389. constructor(scene: Scene, layout: IMotionControllerLayout,
  55390. /**
  55391. * The gamepad object correlating to this controller
  55392. */
  55393. gamepadObject: IMinimalMotionControllerObject,
  55394. /**
  55395. * handedness (left/right/none) of this controller
  55396. */
  55397. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  55398. /**
  55399. * Dispose this controller, the model mesh and all its components
  55400. */
  55401. dispose(): void;
  55402. /**
  55403. * Returns all components of specific type
  55404. * @param type the type to search for
  55405. * @return an array of components with this type
  55406. */
  55407. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  55408. /**
  55409. * get a component based an its component id as defined in layout.components
  55410. * @param id the id of the component
  55411. * @returns the component correlates to the id or undefined if not found
  55412. */
  55413. getComponent(id: string): WebXRControllerComponent;
  55414. /**
  55415. * Get the list of components available in this motion controller
  55416. * @returns an array of strings correlating to available components
  55417. */
  55418. getComponentIds(): string[];
  55419. /**
  55420. * Get the first component of specific type
  55421. * @param type type of component to find
  55422. * @return a controller component or null if not found
  55423. */
  55424. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  55425. /**
  55426. * Get the main (Select) component of this controller as defined in the layout
  55427. * @returns the main component of this controller
  55428. */
  55429. getMainComponent(): WebXRControllerComponent;
  55430. /**
  55431. * Loads the model correlating to this controller
  55432. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  55433. * @returns A promise fulfilled with the result of the model loading
  55434. */
  55435. loadModel(): Promise<boolean>;
  55436. /**
  55437. * Update this model using the current XRFrame
  55438. * @param xrFrame the current xr frame to use and update the model
  55439. */
  55440. updateFromXRFrame(xrFrame: XRFrame): void;
  55441. /**
  55442. * Backwards compatibility due to a deeply-integrated typo
  55443. */
  55444. get handness(): XREye;
  55445. /**
  55446. * Pulse (vibrate) this controller
  55447. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  55448. * Consecutive calls to this function will cancel the last pulse call
  55449. *
  55450. * @param value the strength of the pulse in 0.0...1.0 range
  55451. * @param duration Duration of the pulse in milliseconds
  55452. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  55453. * @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
  55454. */
  55455. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  55456. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  55457. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  55458. /**
  55459. * Moves the axis on the controller mesh based on its current state
  55460. * @param axis the index of the axis
  55461. * @param axisValue the value of the axis which determines the meshes new position
  55462. * @hidden
  55463. */
  55464. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  55465. /**
  55466. * Update the model itself with the current frame data
  55467. * @param xrFrame the frame to use for updating the model mesh
  55468. */
  55469. protected updateModel(xrFrame: XRFrame): void;
  55470. /**
  55471. * Get the filename and path for this controller's model
  55472. * @returns a map of filename and path
  55473. */
  55474. protected abstract _getFilenameAndPath(): {
  55475. filename: string;
  55476. path: string;
  55477. };
  55478. /**
  55479. * This function is called before the mesh is loaded. It checks for loading constraints.
  55480. * For example, this function can check if the GLB loader is available
  55481. * If this function returns false, the generic controller will be loaded instead
  55482. * @returns Is the client ready to load the mesh
  55483. */
  55484. protected abstract _getModelLoadingConstraints(): boolean;
  55485. /**
  55486. * This function will be called after the model was successfully loaded and can be used
  55487. * for mesh transformations before it is available for the user
  55488. * @param meshes the loaded meshes
  55489. */
  55490. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  55491. /**
  55492. * Set the root mesh for this controller. Important for the WebXR controller class
  55493. * @param meshes the loaded meshes
  55494. */
  55495. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  55496. /**
  55497. * A function executed each frame that updates the mesh (if needed)
  55498. * @param xrFrame the current xrFrame
  55499. */
  55500. protected abstract _updateModel(xrFrame: XRFrame): void;
  55501. private _getGenericFilenameAndPath;
  55502. private _getGenericParentMesh;
  55503. }
  55504. }
  55505. declare module BABYLON {
  55506. /**
  55507. * A generic trigger-only motion controller for WebXR
  55508. */
  55509. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  55510. /**
  55511. * Static version of the profile id of this controller
  55512. */
  55513. static ProfileId: string;
  55514. profileId: string;
  55515. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  55516. protected _getFilenameAndPath(): {
  55517. filename: string;
  55518. path: string;
  55519. };
  55520. protected _getModelLoadingConstraints(): boolean;
  55521. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  55522. protected _setRootMesh(meshes: AbstractMesh[]): void;
  55523. protected _updateModel(): void;
  55524. }
  55525. }
  55526. declare module BABYLON {
  55527. /**
  55528. * Class containing static functions to help procedurally build meshes
  55529. */
  55530. export class SphereBuilder {
  55531. /**
  55532. * Creates a sphere mesh
  55533. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55534. * * 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`)
  55535. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55536. * * 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
  55537. * * 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)
  55538. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55539. * * 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
  55540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55541. * @param name defines the name of the mesh
  55542. * @param options defines the options used to create the mesh
  55543. * @param scene defines the hosting scene
  55544. * @returns the sphere mesh
  55545. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55546. */
  55547. static CreateSphere(name: string, options: {
  55548. segments?: number;
  55549. diameter?: number;
  55550. diameterX?: number;
  55551. diameterY?: number;
  55552. diameterZ?: number;
  55553. arc?: number;
  55554. slice?: number;
  55555. sideOrientation?: number;
  55556. frontUVs?: Vector4;
  55557. backUVs?: Vector4;
  55558. updatable?: boolean;
  55559. }, scene?: Nullable<Scene>): Mesh;
  55560. }
  55561. }
  55562. declare module BABYLON {
  55563. /**
  55564. * A profiled motion controller has its profile loaded from an online repository.
  55565. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  55566. */
  55567. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  55568. private _repositoryUrl;
  55569. private _buttonMeshMapping;
  55570. private _touchDots;
  55571. /**
  55572. * The profile ID of this controller. Will be populated when the controller initializes.
  55573. */
  55574. profileId: string;
  55575. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  55576. dispose(): void;
  55577. protected _getFilenameAndPath(): {
  55578. filename: string;
  55579. path: string;
  55580. };
  55581. protected _getModelLoadingConstraints(): boolean;
  55582. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  55583. protected _setRootMesh(meshes: AbstractMesh[]): void;
  55584. protected _updateModel(_xrFrame: XRFrame): void;
  55585. }
  55586. }
  55587. declare module BABYLON {
  55588. /**
  55589. * A construction function type to create a new controller based on an xrInput object
  55590. */
  55591. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  55592. /**
  55593. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  55594. *
  55595. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  55596. * it should be replaced with auto-loaded controllers.
  55597. *
  55598. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  55599. */
  55600. export class WebXRMotionControllerManager {
  55601. private static _AvailableControllers;
  55602. private static _Fallbacks;
  55603. private static _ProfileLoadingPromises;
  55604. private static _ProfilesList;
  55605. /**
  55606. * The base URL of the online controller repository. Can be changed at any time.
  55607. */
  55608. static BaseRepositoryUrl: string;
  55609. /**
  55610. * Which repository gets priority - local or online
  55611. */
  55612. static PrioritizeOnlineRepository: boolean;
  55613. /**
  55614. * Use the online repository, or use only locally-defined controllers
  55615. */
  55616. static UseOnlineRepository: boolean;
  55617. /**
  55618. * Clear the cache used for profile loading and reload when requested again
  55619. */
  55620. static ClearProfilesCache(): void;
  55621. /**
  55622. * Register the default fallbacks.
  55623. * This function is called automatically when this file is imported.
  55624. */
  55625. static DefaultFallbacks(): void;
  55626. /**
  55627. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  55628. * @param profileId the profile to which a fallback needs to be found
  55629. * @return an array with corresponding fallback profiles
  55630. */
  55631. static FindFallbackWithProfileId(profileId: string): string[];
  55632. /**
  55633. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  55634. * The order of search:
  55635. *
  55636. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  55637. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  55638. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  55639. * 4) return the generic trigger controller if none were found
  55640. *
  55641. * @param xrInput the xrInput to which a new controller is initialized
  55642. * @param scene the scene to which the model will be added
  55643. * @param forceProfile force a certain profile for this controller
  55644. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  55645. */
  55646. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  55647. /**
  55648. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  55649. *
  55650. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  55651. *
  55652. * @param type the profile type to register
  55653. * @param constructFunction the function to be called when loading this profile
  55654. */
  55655. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  55656. /**
  55657. * Register a fallback to a specific profile.
  55658. * @param profileId the profileId that will receive the fallbacks
  55659. * @param fallbacks A list of fallback profiles
  55660. */
  55661. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  55662. /**
  55663. * Will update the list of profiles available in the repository
  55664. * @return a promise that resolves to a map of profiles available online
  55665. */
  55666. static UpdateProfilesList(): Promise<{
  55667. [profile: string]: string;
  55668. }>;
  55669. private static _LoadProfileFromRepository;
  55670. private static _LoadProfilesFromAvailableControllers;
  55671. }
  55672. }
  55673. declare module BABYLON {
  55674. /**
  55675. * Configuration options for the WebXR controller creation
  55676. */
  55677. export interface IWebXRControllerOptions {
  55678. /**
  55679. * Should the controller mesh be animated when a user interacts with it
  55680. * The pressed buttons / thumbstick and touchpad animations will be disabled
  55681. */
  55682. disableMotionControllerAnimation?: boolean;
  55683. /**
  55684. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  55685. */
  55686. doNotLoadControllerMesh?: boolean;
  55687. /**
  55688. * Force a specific controller type for this controller.
  55689. * This can be used when creating your own profile or when testing different controllers
  55690. */
  55691. forceControllerProfile?: string;
  55692. /**
  55693. * Defines a rendering group ID for meshes that will be loaded.
  55694. * This is for the default controllers only.
  55695. */
  55696. renderingGroupId?: number;
  55697. }
  55698. /**
  55699. * Represents an XR controller
  55700. */
  55701. export class WebXRInputSource {
  55702. private _scene;
  55703. /** The underlying input source for the controller */
  55704. inputSource: XRInputSource;
  55705. private _options;
  55706. private _tmpVector;
  55707. private _uniqueId;
  55708. private _disposed;
  55709. /**
  55710. * 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
  55711. */
  55712. grip?: AbstractMesh;
  55713. /**
  55714. * If available, this is the gamepad object related to this controller.
  55715. * Using this object it is possible to get click events and trackpad changes of the
  55716. * webxr controller that is currently being used.
  55717. */
  55718. motionController?: WebXRAbstractMotionController;
  55719. /**
  55720. * Event that fires when the controller is removed/disposed.
  55721. * The object provided as event data is this controller, after associated assets were disposed.
  55722. * uniqueId is still available.
  55723. */
  55724. onDisposeObservable: Observable<WebXRInputSource>;
  55725. /**
  55726. * Will be triggered when the mesh associated with the motion controller is done loading.
  55727. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  55728. * A shortened version of controller -> motion controller -> on mesh loaded.
  55729. */
  55730. onMeshLoadedObservable: Observable<AbstractMesh>;
  55731. /**
  55732. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  55733. */
  55734. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  55735. /**
  55736. * Pointer which can be used to select objects or attach a visible laser to
  55737. */
  55738. pointer: AbstractMesh;
  55739. /**
  55740. * Creates the input source object
  55741. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  55742. * @param _scene the scene which the controller should be associated to
  55743. * @param inputSource the underlying input source for the controller
  55744. * @param _options options for this controller creation
  55745. */
  55746. constructor(_scene: Scene,
  55747. /** The underlying input source for the controller */
  55748. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  55749. /**
  55750. * Get this controllers unique id
  55751. */
  55752. get uniqueId(): string;
  55753. /**
  55754. * Disposes of the object
  55755. */
  55756. dispose(): void;
  55757. /**
  55758. * Gets a world space ray coming from the pointer or grip
  55759. * @param result the resulting ray
  55760. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  55761. */
  55762. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  55763. /**
  55764. * Updates the controller pose based on the given XRFrame
  55765. * @param xrFrame xr frame to update the pose with
  55766. * @param referenceSpace reference space to use
  55767. */
  55768. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  55769. }
  55770. }
  55771. declare module BABYLON {
  55772. /**
  55773. * The schema for initialization options of the XR Input class
  55774. */
  55775. export interface IWebXRInputOptions {
  55776. /**
  55777. * If set to true no model will be automatically loaded
  55778. */
  55779. doNotLoadControllerMeshes?: boolean;
  55780. /**
  55781. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  55782. * If not found, the xr input profile data will be used.
  55783. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  55784. */
  55785. forceInputProfile?: string;
  55786. /**
  55787. * Do not send a request to the controller repository to load the profile.
  55788. *
  55789. * Instead, use the controllers available in babylon itself.
  55790. */
  55791. disableOnlineControllerRepository?: boolean;
  55792. /**
  55793. * A custom URL for the controllers repository
  55794. */
  55795. customControllersRepositoryURL?: string;
  55796. /**
  55797. * Should the controller model's components not move according to the user input
  55798. */
  55799. disableControllerAnimation?: boolean;
  55800. /**
  55801. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  55802. */
  55803. controllerOptions?: IWebXRControllerOptions;
  55804. }
  55805. /**
  55806. * XR input used to track XR inputs such as controllers/rays
  55807. */
  55808. export class WebXRInput implements IDisposable {
  55809. /**
  55810. * the xr session manager for this session
  55811. */
  55812. xrSessionManager: WebXRSessionManager;
  55813. /**
  55814. * the WebXR camera for this session. Mainly used for teleportation
  55815. */
  55816. xrCamera: WebXRCamera;
  55817. private readonly options;
  55818. /**
  55819. * XR controllers being tracked
  55820. */
  55821. controllers: Array<WebXRInputSource>;
  55822. private _frameObserver;
  55823. private _sessionEndedObserver;
  55824. private _sessionInitObserver;
  55825. /**
  55826. * Event when a controller has been connected/added
  55827. */
  55828. onControllerAddedObservable: Observable<WebXRInputSource>;
  55829. /**
  55830. * Event when a controller has been removed/disconnected
  55831. */
  55832. onControllerRemovedObservable: Observable<WebXRInputSource>;
  55833. /**
  55834. * Initializes the WebXRInput
  55835. * @param xrSessionManager the xr session manager for this session
  55836. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  55837. * @param options = initialization options for this xr input
  55838. */
  55839. constructor(
  55840. /**
  55841. * the xr session manager for this session
  55842. */
  55843. xrSessionManager: WebXRSessionManager,
  55844. /**
  55845. * the WebXR camera for this session. Mainly used for teleportation
  55846. */
  55847. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  55848. private _onInputSourcesChange;
  55849. private _addAndRemoveControllers;
  55850. /**
  55851. * Disposes of the object
  55852. */
  55853. dispose(): void;
  55854. }
  55855. }
  55856. declare module BABYLON {
  55857. /**
  55858. * This is the base class for all WebXR features.
  55859. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  55860. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  55861. */
  55862. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  55863. protected _xrSessionManager: WebXRSessionManager;
  55864. private _attached;
  55865. private _removeOnDetach;
  55866. /**
  55867. * Is this feature disposed?
  55868. */
  55869. isDisposed: boolean;
  55870. /**
  55871. * Should auto-attach be disabled?
  55872. */
  55873. disableAutoAttach: boolean;
  55874. /**
  55875. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  55876. */
  55877. xrNativeFeatureName: string;
  55878. /**
  55879. * Construct a new (abstract) WebXR feature
  55880. * @param _xrSessionManager the xr session manager for this feature
  55881. */
  55882. constructor(_xrSessionManager: WebXRSessionManager);
  55883. /**
  55884. * Is this feature attached
  55885. */
  55886. get attached(): boolean;
  55887. /**
  55888. * attach this feature
  55889. *
  55890. * @param force should attachment be forced (even when already attached)
  55891. * @returns true if successful, false is failed or already attached
  55892. */
  55893. attach(force?: boolean): boolean;
  55894. /**
  55895. * detach this feature.
  55896. *
  55897. * @returns true if successful, false if failed or already detached
  55898. */
  55899. detach(): boolean;
  55900. /**
  55901. * Dispose this feature and all of the resources attached
  55902. */
  55903. dispose(): void;
  55904. /**
  55905. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  55906. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  55907. *
  55908. * @returns whether or not the feature is compatible in this environment
  55909. */
  55910. isCompatible(): boolean;
  55911. /**
  55912. * This is used to register callbacks that will automatically be removed when detach is called.
  55913. * @param observable the observable to which the observer will be attached
  55914. * @param callback the callback to register
  55915. */
  55916. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  55917. /**
  55918. * Code in this function will be executed on each xrFrame received from the browser.
  55919. * This function will not execute after the feature is detached.
  55920. * @param _xrFrame the current frame
  55921. */
  55922. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  55923. }
  55924. }
  55925. declare module BABYLON {
  55926. /**
  55927. * Renders a layer on top of an existing scene
  55928. */
  55929. export class UtilityLayerRenderer implements IDisposable {
  55930. /** the original scene that will be rendered on top of */
  55931. originalScene: Scene;
  55932. private _pointerCaptures;
  55933. private _lastPointerEvents;
  55934. private static _DefaultUtilityLayer;
  55935. private static _DefaultKeepDepthUtilityLayer;
  55936. private _sharedGizmoLight;
  55937. private _renderCamera;
  55938. /**
  55939. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  55940. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  55941. * @returns the camera that is used when rendering the utility layer
  55942. */
  55943. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  55944. /**
  55945. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  55946. * @param cam the camera that should be used when rendering the utility layer
  55947. */
  55948. setRenderCamera(cam: Nullable<Camera>): void;
  55949. /**
  55950. * @hidden
  55951. * Light which used by gizmos to get light shading
  55952. */
  55953. _getSharedGizmoLight(): HemisphericLight;
  55954. /**
  55955. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  55956. */
  55957. pickUtilitySceneFirst: boolean;
  55958. /**
  55959. * 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)
  55960. */
  55961. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  55962. /**
  55963. * 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)
  55964. */
  55965. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  55966. /**
  55967. * The scene that is rendered on top of the original scene
  55968. */
  55969. utilityLayerScene: Scene;
  55970. /**
  55971. * If the utility layer should automatically be rendered on top of existing scene
  55972. */
  55973. shouldRender: boolean;
  55974. /**
  55975. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  55976. */
  55977. onlyCheckPointerDownEvents: boolean;
  55978. /**
  55979. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  55980. */
  55981. processAllEvents: boolean;
  55982. /**
  55983. * Observable raised when the pointer move from the utility layer scene to the main scene
  55984. */
  55985. onPointerOutObservable: Observable<number>;
  55986. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  55987. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  55988. private _afterRenderObserver;
  55989. private _sceneDisposeObserver;
  55990. private _originalPointerObserver;
  55991. /**
  55992. * Instantiates a UtilityLayerRenderer
  55993. * @param originalScene the original scene that will be rendered on top of
  55994. * @param handleEvents boolean indicating if the utility layer should handle events
  55995. */
  55996. constructor(
  55997. /** the original scene that will be rendered on top of */
  55998. originalScene: Scene, handleEvents?: boolean);
  55999. private _notifyObservers;
  56000. /**
  56001. * Renders the utility layers scene on top of the original scene
  56002. */
  56003. render(): void;
  56004. /**
  56005. * Disposes of the renderer
  56006. */
  56007. dispose(): void;
  56008. private _updateCamera;
  56009. }
  56010. }
  56011. declare module BABYLON {
  56012. /**
  56013. * Options interface for the pointer selection module
  56014. */
  56015. export interface IWebXRControllerPointerSelectionOptions {
  56016. /**
  56017. * if provided, this scene will be used to render meshes.
  56018. */
  56019. customUtilityLayerScene?: Scene;
  56020. /**
  56021. * 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)
  56022. * If not disabled, the last picked point will be used to execute a pointer up event
  56023. * If disabled, pointer up event will be triggered right after the pointer down event.
  56024. * Used in screen and gaze target ray mode only
  56025. */
  56026. disablePointerUpOnTouchOut: boolean;
  56027. /**
  56028. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  56029. */
  56030. forceGazeMode: boolean;
  56031. /**
  56032. * 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
  56033. * to start a new countdown to the pointer down event.
  56034. * Defaults to 1.
  56035. */
  56036. gazeModePointerMovedFactor?: number;
  56037. /**
  56038. * Different button type to use instead of the main component
  56039. */
  56040. overrideButtonId?: string;
  56041. /**
  56042. * use this rendering group id for the meshes (optional)
  56043. */
  56044. renderingGroupId?: number;
  56045. /**
  56046. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  56047. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  56048. * 3000 means 3 seconds between pointing at something and selecting it
  56049. */
  56050. timeToSelect?: number;
  56051. /**
  56052. * Should meshes created here be added to a utility layer or the main scene
  56053. */
  56054. useUtilityLayer?: boolean;
  56055. /**
  56056. * Optional WebXR camera to be used for gaze selection
  56057. */
  56058. gazeCamera?: WebXRCamera;
  56059. /**
  56060. * the xr input to use with this pointer selection
  56061. */
  56062. xrInput: WebXRInput;
  56063. /**
  56064. * Should the scene pointerX and pointerY update be disabled
  56065. * This is required for fullscreen AR GUI, but might slow down other experiences.
  56066. * Disable in VR, if not needed.
  56067. * The first rig camera (left eye) will be used to calculate the projection
  56068. */
  56069. disableScenePointerVectorUpdate: boolean;
  56070. /**
  56071. * Enable pointer selection on all controllers instead of switching between them
  56072. */
  56073. enablePointerSelectionOnAllControllers?: boolean;
  56074. /**
  56075. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  56076. * If switch is enabled, it will still allow the user to switch between the different controllers
  56077. */
  56078. preferredHandedness?: XRHandedness;
  56079. /**
  56080. * Disable switching the pointer selection from one controller to the other.
  56081. * 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
  56082. */
  56083. disableSwitchOnClick?: boolean;
  56084. /**
  56085. * The maximum distance of the pointer selection feature. Defaults to 100.
  56086. */
  56087. maxPointerDistance?: number;
  56088. }
  56089. /**
  56090. * A module that will enable pointer selection for motion controllers of XR Input Sources
  56091. */
  56092. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  56093. private readonly _options;
  56094. private static _idCounter;
  56095. private _attachController;
  56096. private _controllers;
  56097. private _scene;
  56098. private _tmpVectorForPickCompare;
  56099. private _attachedController;
  56100. /**
  56101. * The module's name
  56102. */
  56103. static readonly Name: string;
  56104. /**
  56105. * The (Babylon) version of this module.
  56106. * This is an integer representing the implementation version.
  56107. * This number does not correspond to the WebXR specs version
  56108. */
  56109. static readonly Version: number;
  56110. /**
  56111. * Disable lighting on the laser pointer (so it will always be visible)
  56112. */
  56113. disablePointerLighting: boolean;
  56114. /**
  56115. * Disable lighting on the selection mesh (so it will always be visible)
  56116. */
  56117. disableSelectionMeshLighting: boolean;
  56118. /**
  56119. * Should the laser pointer be displayed
  56120. */
  56121. displayLaserPointer: boolean;
  56122. /**
  56123. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  56124. */
  56125. displaySelectionMesh: boolean;
  56126. /**
  56127. * This color will be set to the laser pointer when selection is triggered
  56128. */
  56129. laserPointerPickedColor: Color3;
  56130. /**
  56131. * Default color of the laser pointer
  56132. */
  56133. laserPointerDefaultColor: Color3;
  56134. /**
  56135. * default color of the selection ring
  56136. */
  56137. selectionMeshDefaultColor: Color3;
  56138. /**
  56139. * This color will be applied to the selection ring when selection is triggered
  56140. */
  56141. selectionMeshPickedColor: Color3;
  56142. /**
  56143. * Optional filter to be used for ray selection. This predicate shares behavior with
  56144. * scene.pointerMovePredicate which takes priority if it is also assigned.
  56145. */
  56146. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  56147. /**
  56148. * constructs a new background remover module
  56149. * @param _xrSessionManager the session manager for this module
  56150. * @param _options read-only options to be used in this module
  56151. */
  56152. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  56153. /**
  56154. * attach this feature
  56155. * Will usually be called by the features manager
  56156. *
  56157. * @returns true if successful.
  56158. */
  56159. attach(): boolean;
  56160. /**
  56161. * detach this feature.
  56162. * Will usually be called by the features manager
  56163. *
  56164. * @returns true if successful.
  56165. */
  56166. detach(): boolean;
  56167. /**
  56168. * Will get the mesh under a specific pointer.
  56169. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  56170. * @param controllerId the controllerId to check
  56171. * @returns The mesh under pointer or null if no mesh is under the pointer
  56172. */
  56173. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  56174. /**
  56175. * Get the xr controller that correlates to the pointer id in the pointer event
  56176. *
  56177. * @param id the pointer id to search for
  56178. * @returns the controller that correlates to this id or null if not found
  56179. */
  56180. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  56181. private _identityMatrix;
  56182. private _screenCoordinatesRef;
  56183. private _viewportRef;
  56184. protected _onXRFrame(_xrFrame: XRFrame): void;
  56185. private _attachGazeMode;
  56186. private _attachScreenRayMode;
  56187. private _attachTrackedPointerRayMode;
  56188. private _convertNormalToDirectionOfRay;
  56189. private _detachController;
  56190. private _generateNewMeshPair;
  56191. private _pickingMoved;
  56192. private _updatePointerDistance;
  56193. /** @hidden */
  56194. get lasterPointerDefaultColor(): Color3;
  56195. }
  56196. }
  56197. declare module BABYLON {
  56198. /**
  56199. * Button which can be used to enter a different mode of XR
  56200. */
  56201. export class WebXREnterExitUIButton {
  56202. /** button element */
  56203. element: HTMLElement;
  56204. /** XR initialization options for the button */
  56205. sessionMode: XRSessionMode;
  56206. /** Reference space type */
  56207. referenceSpaceType: XRReferenceSpaceType;
  56208. /**
  56209. * Creates a WebXREnterExitUIButton
  56210. * @param element button element
  56211. * @param sessionMode XR initialization session mode
  56212. * @param referenceSpaceType the type of reference space to be used
  56213. */
  56214. constructor(
  56215. /** button element */
  56216. element: HTMLElement,
  56217. /** XR initialization options for the button */
  56218. sessionMode: XRSessionMode,
  56219. /** Reference space type */
  56220. referenceSpaceType: XRReferenceSpaceType);
  56221. /**
  56222. * Extendable function which can be used to update the button's visuals when the state changes
  56223. * @param activeButton the current active button in the UI
  56224. */
  56225. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  56226. }
  56227. /**
  56228. * Options to create the webXR UI
  56229. */
  56230. export class WebXREnterExitUIOptions {
  56231. /**
  56232. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  56233. */
  56234. customButtons?: Array<WebXREnterExitUIButton>;
  56235. /**
  56236. * A reference space type to use when creating the default button.
  56237. * Default is local-floor
  56238. */
  56239. referenceSpaceType?: XRReferenceSpaceType;
  56240. /**
  56241. * Context to enter xr with
  56242. */
  56243. renderTarget?: Nullable<WebXRRenderTarget>;
  56244. /**
  56245. * A session mode to use when creating the default button.
  56246. * Default is immersive-vr
  56247. */
  56248. sessionMode?: XRSessionMode;
  56249. /**
  56250. * A list of optional features to init the session with
  56251. */
  56252. optionalFeatures?: string[];
  56253. /**
  56254. * A list of optional features to init the session with
  56255. */
  56256. requiredFeatures?: string[];
  56257. /**
  56258. * If defined, this function will be executed if the UI encounters an error when entering XR
  56259. */
  56260. onError?: (error: any) => void;
  56261. }
  56262. /**
  56263. * UI to allow the user to enter/exit XR mode
  56264. */
  56265. export class WebXREnterExitUI implements IDisposable {
  56266. private scene;
  56267. /** version of the options passed to this UI */
  56268. options: WebXREnterExitUIOptions;
  56269. private _activeButton;
  56270. private _buttons;
  56271. /**
  56272. * The HTML Div Element to which buttons are added.
  56273. */
  56274. readonly overlay: HTMLDivElement;
  56275. /**
  56276. * Fired every time the active button is changed.
  56277. *
  56278. * When xr is entered via a button that launches xr that button will be the callback parameter
  56279. *
  56280. * When exiting xr the callback parameter will be null)
  56281. */
  56282. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  56283. /**
  56284. *
  56285. * @param scene babylon scene object to use
  56286. * @param options (read-only) version of the options passed to this UI
  56287. */
  56288. private constructor();
  56289. /**
  56290. * Creates UI to allow the user to enter/exit XR mode
  56291. * @param scene the scene to add the ui to
  56292. * @param helper the xr experience helper to enter/exit xr with
  56293. * @param options options to configure the UI
  56294. * @returns the created ui
  56295. */
  56296. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  56297. /**
  56298. * Disposes of the XR UI component
  56299. */
  56300. dispose(): void;
  56301. private _updateButtons;
  56302. }
  56303. }
  56304. declare module BABYLON {
  56305. /**
  56306. * Class containing static functions to help procedurally build meshes
  56307. */
  56308. export class LinesBuilder {
  56309. /**
  56310. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56311. * * 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
  56312. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56313. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56314. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56315. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56316. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56317. * * 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
  56318. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56320. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56321. * @param name defines the name of the new line system
  56322. * @param options defines the options used to create the line system
  56323. * @param scene defines the hosting scene
  56324. * @returns a new line system mesh
  56325. */
  56326. static CreateLineSystem(name: string, options: {
  56327. lines: Vector3[][];
  56328. updatable?: boolean;
  56329. instance?: Nullable<LinesMesh>;
  56330. colors?: Nullable<Color4[][]>;
  56331. useVertexAlpha?: boolean;
  56332. }, scene: Nullable<Scene>): LinesMesh;
  56333. /**
  56334. * Creates a line mesh
  56335. * 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
  56336. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56337. * * The parameter `points` is an array successive Vector3
  56338. * * 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
  56339. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56340. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56341. * * When updating an instance, remember that only point positions can change, not the number of points
  56342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56343. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56344. * @param name defines the name of the new line system
  56345. * @param options defines the options used to create the line system
  56346. * @param scene defines the hosting scene
  56347. * @returns a new line mesh
  56348. */
  56349. static CreateLines(name: string, options: {
  56350. points: Vector3[];
  56351. updatable?: boolean;
  56352. instance?: Nullable<LinesMesh>;
  56353. colors?: Color4[];
  56354. useVertexAlpha?: boolean;
  56355. }, scene?: Nullable<Scene>): LinesMesh;
  56356. /**
  56357. * Creates a dashed line mesh
  56358. * * 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
  56359. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56360. * * The parameter `points` is an array successive Vector3
  56361. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56362. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56363. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56364. * * 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
  56365. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56366. * * When updating an instance, remember that only point positions can change, not the number of points
  56367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56368. * @param name defines the name of the mesh
  56369. * @param options defines the options used to create the mesh
  56370. * @param scene defines the hosting scene
  56371. * @returns the dashed line mesh
  56372. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56373. */
  56374. static CreateDashedLines(name: string, options: {
  56375. points: Vector3[];
  56376. dashSize?: number;
  56377. gapSize?: number;
  56378. dashNb?: number;
  56379. updatable?: boolean;
  56380. instance?: LinesMesh;
  56381. useVertexAlpha?: boolean;
  56382. }, scene?: Nullable<Scene>): LinesMesh;
  56383. }
  56384. }
  56385. declare module BABYLON {
  56386. /**
  56387. * Construction options for a timer
  56388. */
  56389. export interface ITimerOptions<T> {
  56390. /**
  56391. * Time-to-end
  56392. */
  56393. timeout: number;
  56394. /**
  56395. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  56396. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  56397. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  56398. */
  56399. contextObservable: Observable<T>;
  56400. /**
  56401. * Optional parameters when adding an observer to the observable
  56402. */
  56403. observableParameters?: {
  56404. mask?: number;
  56405. insertFirst?: boolean;
  56406. scope?: any;
  56407. };
  56408. /**
  56409. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  56410. */
  56411. breakCondition?: (data?: ITimerData<T>) => boolean;
  56412. /**
  56413. * Will be triggered when the time condition has met
  56414. */
  56415. onEnded?: (data: ITimerData<any>) => void;
  56416. /**
  56417. * Will be triggered when the break condition has met (prematurely ended)
  56418. */
  56419. onAborted?: (data: ITimerData<any>) => void;
  56420. /**
  56421. * Optional function to execute on each tick (or count)
  56422. */
  56423. onTick?: (data: ITimerData<any>) => void;
  56424. }
  56425. /**
  56426. * An interface defining the data sent by the timer
  56427. */
  56428. export interface ITimerData<T> {
  56429. /**
  56430. * When did it start
  56431. */
  56432. startTime: number;
  56433. /**
  56434. * Time now
  56435. */
  56436. currentTime: number;
  56437. /**
  56438. * Time passed since started
  56439. */
  56440. deltaTime: number;
  56441. /**
  56442. * How much is completed, in [0.0...1.0].
  56443. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  56444. */
  56445. completeRate: number;
  56446. /**
  56447. * What the registered observable sent in the last count
  56448. */
  56449. payload: T;
  56450. }
  56451. /**
  56452. * The current state of the timer
  56453. */
  56454. export enum TimerState {
  56455. /**
  56456. * Timer initialized, not yet started
  56457. */
  56458. INIT = 0,
  56459. /**
  56460. * Timer started and counting
  56461. */
  56462. STARTED = 1,
  56463. /**
  56464. * Timer ended (whether aborted or time reached)
  56465. */
  56466. ENDED = 2
  56467. }
  56468. /**
  56469. * A simple version of the timer. Will take options and start the timer immediately after calling it
  56470. *
  56471. * @param options options with which to initialize this timer
  56472. */
  56473. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  56474. /**
  56475. * An advanced implementation of a timer class
  56476. */
  56477. export class AdvancedTimer<T = any> implements IDisposable {
  56478. /**
  56479. * Will notify each time the timer calculates the remaining time
  56480. */
  56481. onEachCountObservable: Observable<ITimerData<T>>;
  56482. /**
  56483. * Will trigger when the timer was aborted due to the break condition
  56484. */
  56485. onTimerAbortedObservable: Observable<ITimerData<T>>;
  56486. /**
  56487. * Will trigger when the timer ended successfully
  56488. */
  56489. onTimerEndedObservable: Observable<ITimerData<T>>;
  56490. /**
  56491. * Will trigger when the timer state has changed
  56492. */
  56493. onStateChangedObservable: Observable<TimerState>;
  56494. private _observer;
  56495. private _contextObservable;
  56496. private _observableParameters;
  56497. private _startTime;
  56498. private _timer;
  56499. private _state;
  56500. private _breakCondition;
  56501. private _timeToEnd;
  56502. private _breakOnNextTick;
  56503. /**
  56504. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  56505. * @param options construction options for this advanced timer
  56506. */
  56507. constructor(options: ITimerOptions<T>);
  56508. /**
  56509. * set a breaking condition for this timer. Default is to never break during count
  56510. * @param predicate the new break condition. Returns true to break, false otherwise
  56511. */
  56512. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  56513. /**
  56514. * Reset ALL associated observables in this advanced timer
  56515. */
  56516. clearObservables(): void;
  56517. /**
  56518. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  56519. *
  56520. * @param timeToEnd how much time to measure until timer ended
  56521. */
  56522. start(timeToEnd?: number): void;
  56523. /**
  56524. * Will force a stop on the next tick.
  56525. */
  56526. stop(): void;
  56527. /**
  56528. * Dispose this timer, clearing all resources
  56529. */
  56530. dispose(): void;
  56531. private _setState;
  56532. private _tick;
  56533. private _stop;
  56534. }
  56535. }
  56536. declare module BABYLON {
  56537. /**
  56538. * The options container for the teleportation module
  56539. */
  56540. export interface IWebXRTeleportationOptions {
  56541. /**
  56542. * if provided, this scene will be used to render meshes.
  56543. */
  56544. customUtilityLayerScene?: Scene;
  56545. /**
  56546. * Values to configure the default target mesh
  56547. */
  56548. defaultTargetMeshOptions?: {
  56549. /**
  56550. * Fill color of the teleportation area
  56551. */
  56552. teleportationFillColor?: string;
  56553. /**
  56554. * Border color for the teleportation area
  56555. */
  56556. teleportationBorderColor?: string;
  56557. /**
  56558. * Disable the mesh's animation sequence
  56559. */
  56560. disableAnimation?: boolean;
  56561. /**
  56562. * Disable lighting on the material or the ring and arrow
  56563. */
  56564. disableLighting?: boolean;
  56565. /**
  56566. * Override the default material of the torus and arrow
  56567. */
  56568. torusArrowMaterial?: Material;
  56569. };
  56570. /**
  56571. * A list of meshes to use as floor meshes.
  56572. * Meshes can be added and removed after initializing the feature using the
  56573. * addFloorMesh and removeFloorMesh functions
  56574. * If empty, rotation will still work
  56575. */
  56576. floorMeshes?: AbstractMesh[];
  56577. /**
  56578. * use this rendering group id for the meshes (optional)
  56579. */
  56580. renderingGroupId?: number;
  56581. /**
  56582. * Should teleportation move only to snap points
  56583. */
  56584. snapPointsOnly?: boolean;
  56585. /**
  56586. * An array of points to which the teleportation will snap to.
  56587. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  56588. */
  56589. snapPositions?: Vector3[];
  56590. /**
  56591. * How close should the teleportation ray be in order to snap to position.
  56592. * Default to 0.8 units (meters)
  56593. */
  56594. snapToPositionRadius?: number;
  56595. /**
  56596. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  56597. * If you want to support rotation, make sure your mesh has a direction indicator.
  56598. *
  56599. * When left untouched, the default mesh will be initialized.
  56600. */
  56601. teleportationTargetMesh?: AbstractMesh;
  56602. /**
  56603. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  56604. */
  56605. timeToTeleport?: number;
  56606. /**
  56607. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  56608. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  56609. */
  56610. useMainComponentOnly?: boolean;
  56611. /**
  56612. * Should meshes created here be added to a utility layer or the main scene
  56613. */
  56614. useUtilityLayer?: boolean;
  56615. /**
  56616. * Babylon XR Input class for controller
  56617. */
  56618. xrInput: WebXRInput;
  56619. /**
  56620. * Meshes that the teleportation ray cannot go through
  56621. */
  56622. pickBlockerMeshes?: AbstractMesh[];
  56623. /**
  56624. * Should teleport work only on a specific hand?
  56625. */
  56626. forceHandedness?: XRHandedness;
  56627. /**
  56628. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  56629. */
  56630. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  56631. }
  56632. /**
  56633. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  56634. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  56635. * the input of the attached controllers.
  56636. */
  56637. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  56638. private _options;
  56639. private _controllers;
  56640. private _currentTeleportationControllerId;
  56641. private _floorMeshes;
  56642. private _quadraticBezierCurve;
  56643. private _selectionFeature;
  56644. private _snapToPositions;
  56645. private _snappedToPoint;
  56646. private _teleportationRingMaterial?;
  56647. private _tmpRay;
  56648. private _tmpVector;
  56649. private _tmpQuaternion;
  56650. /**
  56651. * The module's name
  56652. */
  56653. static readonly Name: string;
  56654. /**
  56655. * The (Babylon) version of this module.
  56656. * This is an integer representing the implementation version.
  56657. * This number does not correspond to the webxr specs version
  56658. */
  56659. static readonly Version: number;
  56660. /**
  56661. * Is movement backwards enabled
  56662. */
  56663. backwardsMovementEnabled: boolean;
  56664. /**
  56665. * Distance to travel when moving backwards
  56666. */
  56667. backwardsTeleportationDistance: number;
  56668. /**
  56669. * The distance from the user to the inspection point in the direction of the controller
  56670. * A higher number will allow the user to move further
  56671. * defaults to 5 (meters, in xr units)
  56672. */
  56673. parabolicCheckRadius: number;
  56674. /**
  56675. * Should the module support parabolic ray on top of direct ray
  56676. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  56677. * Very helpful when moving between floors / different heights
  56678. */
  56679. parabolicRayEnabled: boolean;
  56680. /**
  56681. * The second type of ray - straight line.
  56682. * Should it be enabled or should the parabolic line be the only one.
  56683. */
  56684. straightRayEnabled: boolean;
  56685. /**
  56686. * How much rotation should be applied when rotating right and left
  56687. */
  56688. rotationAngle: number;
  56689. private _rotationEnabled;
  56690. /**
  56691. * Is rotation enabled when moving forward?
  56692. * Disabling this feature will prevent the user from deciding the direction when teleporting
  56693. */
  56694. get rotationEnabled(): boolean;
  56695. /**
  56696. * Sets whether rotation is enabled or not
  56697. * @param enabled is rotation enabled when teleportation is shown
  56698. */
  56699. set rotationEnabled(enabled: boolean);
  56700. /**
  56701. * Exposes the currently set teleportation target mesh.
  56702. */
  56703. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  56704. /**
  56705. * constructs a new anchor system
  56706. * @param _xrSessionManager an instance of WebXRSessionManager
  56707. * @param _options configuration object for this feature
  56708. */
  56709. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  56710. /**
  56711. * Get the snapPointsOnly flag
  56712. */
  56713. get snapPointsOnly(): boolean;
  56714. /**
  56715. * Sets the snapPointsOnly flag
  56716. * @param snapToPoints should teleportation be exclusively to snap points
  56717. */
  56718. set snapPointsOnly(snapToPoints: boolean);
  56719. /**
  56720. * Add a new mesh to the floor meshes array
  56721. * @param mesh the mesh to use as floor mesh
  56722. */
  56723. addFloorMesh(mesh: AbstractMesh): void;
  56724. /**
  56725. * Add a new snap-to point to fix teleportation to this position
  56726. * @param newSnapPoint The new Snap-To point
  56727. */
  56728. addSnapPoint(newSnapPoint: Vector3): void;
  56729. attach(): boolean;
  56730. detach(): boolean;
  56731. dispose(): void;
  56732. /**
  56733. * Remove a mesh from the floor meshes array
  56734. * @param mesh the mesh to remove
  56735. */
  56736. removeFloorMesh(mesh: AbstractMesh): void;
  56737. /**
  56738. * Remove a mesh from the floor meshes array using its name
  56739. * @param name the mesh name to remove
  56740. */
  56741. removeFloorMeshByName(name: string): void;
  56742. /**
  56743. * 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
  56744. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  56745. * @returns was the point found and removed or not
  56746. */
  56747. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  56748. /**
  56749. * This function sets a selection feature that will be disabled when
  56750. * the forward ray is shown and will be reattached when hidden.
  56751. * This is used to remove the selection rays when moving.
  56752. * @param selectionFeature the feature to disable when forward movement is enabled
  56753. */
  56754. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  56755. protected _onXRFrame(_xrFrame: XRFrame): void;
  56756. private _attachController;
  56757. private _createDefaultTargetMesh;
  56758. private _detachController;
  56759. private _findClosestSnapPointWithRadius;
  56760. private _setTargetMeshPosition;
  56761. private _setTargetMeshVisibility;
  56762. private _showParabolicPath;
  56763. private _teleportForward;
  56764. }
  56765. }
  56766. declare module BABYLON {
  56767. /**
  56768. * Options for the default xr helper
  56769. */
  56770. export class WebXRDefaultExperienceOptions {
  56771. /**
  56772. * Enable or disable default UI to enter XR
  56773. */
  56774. disableDefaultUI?: boolean;
  56775. /**
  56776. * Should teleportation not initialize. defaults to false.
  56777. */
  56778. disableTeleportation?: boolean;
  56779. /**
  56780. * Floor meshes that will be used for teleport
  56781. */
  56782. floorMeshes?: Array<AbstractMesh>;
  56783. /**
  56784. * If set to true, the first frame will not be used to reset position
  56785. * The first frame is mainly used when copying transformation from the old camera
  56786. * Mainly used in AR
  56787. */
  56788. ignoreNativeCameraTransformation?: boolean;
  56789. /**
  56790. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  56791. */
  56792. inputOptions?: IWebXRInputOptions;
  56793. /**
  56794. * optional configuration for the output canvas
  56795. */
  56796. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  56797. /**
  56798. * optional UI options. This can be used among other to change session mode and reference space type
  56799. */
  56800. uiOptions?: WebXREnterExitUIOptions;
  56801. /**
  56802. * When loading teleportation and pointer select, use stable versions instead of latest.
  56803. */
  56804. useStablePlugins?: boolean;
  56805. /**
  56806. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  56807. */
  56808. renderingGroupId?: number;
  56809. /**
  56810. * A list of optional features to init the session with
  56811. * If set to true, all features we support will be added
  56812. */
  56813. optionalFeatures?: boolean | string[];
  56814. }
  56815. /**
  56816. * Default experience which provides a similar setup to the previous webVRExperience
  56817. */
  56818. export class WebXRDefaultExperience {
  56819. /**
  56820. * Base experience
  56821. */
  56822. baseExperience: WebXRExperienceHelper;
  56823. /**
  56824. * Enables ui for entering/exiting xr
  56825. */
  56826. enterExitUI: WebXREnterExitUI;
  56827. /**
  56828. * Input experience extension
  56829. */
  56830. input: WebXRInput;
  56831. /**
  56832. * Enables laser pointer and selection
  56833. */
  56834. pointerSelection: WebXRControllerPointerSelection;
  56835. /**
  56836. * Default target xr should render to
  56837. */
  56838. renderTarget: WebXRRenderTarget;
  56839. /**
  56840. * Enables teleportation
  56841. */
  56842. teleportation: WebXRMotionControllerTeleportation;
  56843. private constructor();
  56844. /**
  56845. * Creates the default xr experience
  56846. * @param scene scene
  56847. * @param options options for basic configuration
  56848. * @returns resulting WebXRDefaultExperience
  56849. */
  56850. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56851. /**
  56852. * Disposes of the experience helper
  56853. */
  56854. dispose(): void;
  56855. }
  56856. }
  56857. declare module BABYLON {
  56858. /**
  56859. * Options to modify the vr teleportation behavior.
  56860. */
  56861. export interface VRTeleportationOptions {
  56862. /**
  56863. * The name of the mesh which should be used as the teleportation floor. (default: null)
  56864. */
  56865. floorMeshName?: string;
  56866. /**
  56867. * A list of meshes to be used as the teleportation floor. (default: empty)
  56868. */
  56869. floorMeshes?: Mesh[];
  56870. /**
  56871. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  56872. */
  56873. teleportationMode?: number;
  56874. /**
  56875. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  56876. */
  56877. teleportationTime?: number;
  56878. /**
  56879. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  56880. */
  56881. teleportationSpeed?: number;
  56882. /**
  56883. * The easing function used in the animation or null for Linear. (default CircleEase)
  56884. */
  56885. easingFunction?: EasingFunction;
  56886. }
  56887. /**
  56888. * Options to modify the vr experience helper's behavior.
  56889. */
  56890. export interface VRExperienceHelperOptions extends WebVROptions {
  56891. /**
  56892. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  56893. */
  56894. createDeviceOrientationCamera?: boolean;
  56895. /**
  56896. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  56897. */
  56898. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  56899. /**
  56900. * Uses the main button on the controller to toggle the laser casted. (default: true)
  56901. */
  56902. laserToggle?: boolean;
  56903. /**
  56904. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  56905. */
  56906. floorMeshes?: Mesh[];
  56907. /**
  56908. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  56909. */
  56910. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  56911. /**
  56912. * Defines if WebXR should be used instead of WebVR (if available)
  56913. */
  56914. useXR?: boolean;
  56915. }
  56916. /**
  56917. * Event containing information after VR has been entered
  56918. */
  56919. export class OnAfterEnteringVRObservableEvent {
  56920. /**
  56921. * If entering vr was successful
  56922. */
  56923. success: boolean;
  56924. }
  56925. /**
  56926. * Helps to quickly add VR support to an existing scene.
  56927. * See https://doc.babylonjs.com/how_to/webvr_helper
  56928. */
  56929. export class VRExperienceHelper {
  56930. /** Options to modify the vr experience helper's behavior. */
  56931. webVROptions: VRExperienceHelperOptions;
  56932. private _scene;
  56933. private _position;
  56934. private _btnVR;
  56935. private _btnVRDisplayed;
  56936. private _webVRsupported;
  56937. private _webVRready;
  56938. private _webVRrequesting;
  56939. private _webVRpresenting;
  56940. private _hasEnteredVR;
  56941. private _fullscreenVRpresenting;
  56942. private _inputElement;
  56943. private _webVRCamera;
  56944. private _vrDeviceOrientationCamera;
  56945. private _deviceOrientationCamera;
  56946. private _existingCamera;
  56947. private _onKeyDown;
  56948. private _onVrDisplayPresentChange;
  56949. private _onVRDisplayChanged;
  56950. private _onVRRequestPresentStart;
  56951. private _onVRRequestPresentComplete;
  56952. /**
  56953. * 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)
  56954. */
  56955. enableGazeEvenWhenNoPointerLock: boolean;
  56956. /**
  56957. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  56958. */
  56959. exitVROnDoubleTap: boolean;
  56960. /**
  56961. * Observable raised right before entering VR.
  56962. */
  56963. onEnteringVRObservable: Observable<VRExperienceHelper>;
  56964. /**
  56965. * Observable raised when entering VR has completed.
  56966. */
  56967. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  56968. /**
  56969. * Observable raised when exiting VR.
  56970. */
  56971. onExitingVRObservable: Observable<VRExperienceHelper>;
  56972. /**
  56973. * Observable raised when controller mesh is loaded.
  56974. */
  56975. onControllerMeshLoadedObservable: Observable<WebVRController>;
  56976. /** Return this.onEnteringVRObservable
  56977. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  56978. */
  56979. get onEnteringVR(): Observable<VRExperienceHelper>;
  56980. /** Return this.onExitingVRObservable
  56981. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  56982. */
  56983. get onExitingVR(): Observable<VRExperienceHelper>;
  56984. /** Return this.onControllerMeshLoadedObservable
  56985. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  56986. */
  56987. get onControllerMeshLoaded(): Observable<WebVRController>;
  56988. private _rayLength;
  56989. private _useCustomVRButton;
  56990. private _teleportationRequested;
  56991. private _teleportActive;
  56992. private _floorMeshName;
  56993. private _floorMeshesCollection;
  56994. private _teleportationMode;
  56995. private _teleportationTime;
  56996. private _teleportationSpeed;
  56997. private _teleportationEasing;
  56998. private _rotationAllowed;
  56999. private _teleportBackwardsVector;
  57000. private _teleportationTarget;
  57001. private _isDefaultTeleportationTarget;
  57002. private _postProcessMove;
  57003. private _teleportationFillColor;
  57004. private _teleportationBorderColor;
  57005. private _rotationAngle;
  57006. private _haloCenter;
  57007. private _cameraGazer;
  57008. private _padSensibilityUp;
  57009. private _padSensibilityDown;
  57010. private _leftController;
  57011. private _rightController;
  57012. private _gazeColor;
  57013. private _laserColor;
  57014. private _pickedLaserColor;
  57015. private _pickedGazeColor;
  57016. /**
  57017. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  57018. */
  57019. onNewMeshSelected: Observable<AbstractMesh>;
  57020. /**
  57021. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  57022. * This observable will provide the mesh and the controller used to select the mesh
  57023. */
  57024. onMeshSelectedWithController: Observable<{
  57025. mesh: AbstractMesh;
  57026. controller: WebVRController;
  57027. }>;
  57028. /**
  57029. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  57030. */
  57031. onNewMeshPicked: Observable<PickingInfo>;
  57032. private _circleEase;
  57033. /**
  57034. * Observable raised before camera teleportation
  57035. */
  57036. onBeforeCameraTeleport: Observable<Vector3>;
  57037. /**
  57038. * Observable raised after camera teleportation
  57039. */
  57040. onAfterCameraTeleport: Observable<Vector3>;
  57041. /**
  57042. * Observable raised when current selected mesh gets unselected
  57043. */
  57044. onSelectedMeshUnselected: Observable<AbstractMesh>;
  57045. private _raySelectionPredicate;
  57046. /**
  57047. * To be optionally changed by user to define custom ray selection
  57048. */
  57049. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  57050. /**
  57051. * To be optionally changed by user to define custom selection logic (after ray selection)
  57052. */
  57053. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57054. /**
  57055. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  57056. */
  57057. teleportationEnabled: boolean;
  57058. private _defaultHeight;
  57059. private _teleportationInitialized;
  57060. private _interactionsEnabled;
  57061. private _interactionsRequested;
  57062. private _displayGaze;
  57063. private _displayLaserPointer;
  57064. /**
  57065. * The mesh used to display where the user is going to teleport.
  57066. */
  57067. get teleportationTarget(): Mesh;
  57068. /**
  57069. * Sets the mesh to be used to display where the user is going to teleport.
  57070. */
  57071. set teleportationTarget(value: Mesh);
  57072. /**
  57073. * 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
  57074. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  57075. * See https://doc.babylonjs.com/resources/baking_transformations
  57076. */
  57077. get gazeTrackerMesh(): Mesh;
  57078. set gazeTrackerMesh(value: Mesh);
  57079. /**
  57080. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  57081. */
  57082. updateGazeTrackerScale: boolean;
  57083. /**
  57084. * If the gaze trackers color should be updated when selecting meshes
  57085. */
  57086. updateGazeTrackerColor: boolean;
  57087. /**
  57088. * If the controller laser color should be updated when selecting meshes
  57089. */
  57090. updateControllerLaserColor: boolean;
  57091. /**
  57092. * The gaze tracking mesh corresponding to the left controller
  57093. */
  57094. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  57095. /**
  57096. * The gaze tracking mesh corresponding to the right controller
  57097. */
  57098. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  57099. /**
  57100. * If the ray of the gaze should be displayed.
  57101. */
  57102. get displayGaze(): boolean;
  57103. /**
  57104. * Sets if the ray of the gaze should be displayed.
  57105. */
  57106. set displayGaze(value: boolean);
  57107. /**
  57108. * If the ray of the LaserPointer should be displayed.
  57109. */
  57110. get displayLaserPointer(): boolean;
  57111. /**
  57112. * Sets if the ray of the LaserPointer should be displayed.
  57113. */
  57114. set displayLaserPointer(value: boolean);
  57115. /**
  57116. * The deviceOrientationCamera used as the camera when not in VR.
  57117. */
  57118. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  57119. /**
  57120. * Based on the current WebVR support, returns the current VR camera used.
  57121. */
  57122. get currentVRCamera(): Nullable<Camera>;
  57123. /**
  57124. * The webVRCamera which is used when in VR.
  57125. */
  57126. get webVRCamera(): WebVRFreeCamera;
  57127. /**
  57128. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  57129. */
  57130. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  57131. /**
  57132. * The html button that is used to trigger entering into VR.
  57133. */
  57134. get vrButton(): Nullable<HTMLButtonElement>;
  57135. private get _teleportationRequestInitiated();
  57136. /**
  57137. * Defines whether or not Pointer lock should be requested when switching to
  57138. * full screen.
  57139. */
  57140. requestPointerLockOnFullScreen: boolean;
  57141. /**
  57142. * If asking to force XR, this will be populated with the default xr experience
  57143. */
  57144. xr: WebXRDefaultExperience;
  57145. /**
  57146. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  57147. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  57148. */
  57149. xrTestDone: boolean;
  57150. /**
  57151. * Instantiates a VRExperienceHelper.
  57152. * Helps to quickly add VR support to an existing scene.
  57153. * @param scene The scene the VRExperienceHelper belongs to.
  57154. * @param webVROptions Options to modify the vr experience helper's behavior.
  57155. */
  57156. constructor(scene: Scene,
  57157. /** Options to modify the vr experience helper's behavior. */
  57158. webVROptions?: VRExperienceHelperOptions);
  57159. private completeVRInit;
  57160. private _onDefaultMeshLoaded;
  57161. private _onResize;
  57162. private _onFullscreenChange;
  57163. /**
  57164. * Gets a value indicating if we are currently in VR mode.
  57165. */
  57166. get isInVRMode(): boolean;
  57167. private onVrDisplayPresentChange;
  57168. private onVRDisplayChanged;
  57169. private moveButtonToBottomRight;
  57170. private displayVRButton;
  57171. private updateButtonVisibility;
  57172. private _cachedAngularSensibility;
  57173. /**
  57174. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  57175. * Otherwise, will use the fullscreen API.
  57176. */
  57177. enterVR(): void;
  57178. /**
  57179. * Attempt to exit VR, or fullscreen.
  57180. */
  57181. exitVR(): void;
  57182. /**
  57183. * The position of the vr experience helper.
  57184. */
  57185. get position(): Vector3;
  57186. /**
  57187. * Sets the position of the vr experience helper.
  57188. */
  57189. set position(value: Vector3);
  57190. /**
  57191. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  57192. */
  57193. enableInteractions(): void;
  57194. private get _noControllerIsActive();
  57195. private beforeRender;
  57196. private _isTeleportationFloor;
  57197. /**
  57198. * Adds a floor mesh to be used for teleportation.
  57199. * @param floorMesh the mesh to be used for teleportation.
  57200. */
  57201. addFloorMesh(floorMesh: Mesh): void;
  57202. /**
  57203. * Removes a floor mesh from being used for teleportation.
  57204. * @param floorMesh the mesh to be removed.
  57205. */
  57206. removeFloorMesh(floorMesh: Mesh): void;
  57207. /**
  57208. * Enables interactions and teleportation using the VR controllers and gaze.
  57209. * @param vrTeleportationOptions options to modify teleportation behavior.
  57210. */
  57211. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  57212. private _onNewGamepadConnected;
  57213. private _tryEnableInteractionOnController;
  57214. private _onNewGamepadDisconnected;
  57215. private _enableInteractionOnController;
  57216. private _checkTeleportWithRay;
  57217. private _checkRotate;
  57218. private _checkTeleportBackwards;
  57219. private _enableTeleportationOnController;
  57220. private _createTeleportationCircles;
  57221. private _displayTeleportationTarget;
  57222. private _hideTeleportationTarget;
  57223. private _rotateCamera;
  57224. private _moveTeleportationSelectorTo;
  57225. private _workingVector;
  57226. private _workingQuaternion;
  57227. private _workingMatrix;
  57228. /**
  57229. * Time Constant Teleportation Mode
  57230. */
  57231. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  57232. /**
  57233. * Speed Constant Teleportation Mode
  57234. */
  57235. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  57236. /**
  57237. * Teleports the users feet to the desired location
  57238. * @param location The location where the user's feet should be placed
  57239. */
  57240. teleportCamera(location: Vector3): void;
  57241. private _convertNormalToDirectionOfRay;
  57242. private _castRayAndSelectObject;
  57243. private _notifySelectedMeshUnselected;
  57244. /**
  57245. * Permanently set new colors for the laser pointer
  57246. * @param color the new laser color
  57247. * @param pickedColor the new laser color when picked mesh detected
  57248. */
  57249. setLaserColor(color: Color3, pickedColor?: Color3): void;
  57250. /**
  57251. * Set lighting enabled / disabled on the laser pointer of both controllers
  57252. * @param enabled should the lighting be enabled on the laser pointer
  57253. */
  57254. setLaserLightingState(enabled?: boolean): void;
  57255. /**
  57256. * Permanently set new colors for the gaze pointer
  57257. * @param color the new gaze color
  57258. * @param pickedColor the new gaze color when picked mesh detected
  57259. */
  57260. setGazeColor(color: Color3, pickedColor?: Color3): void;
  57261. /**
  57262. * Sets the color of the laser ray from the vr controllers.
  57263. * @param color new color for the ray.
  57264. */
  57265. changeLaserColor(color: Color3): void;
  57266. /**
  57267. * Sets the color of the ray from the vr headsets gaze.
  57268. * @param color new color for the ray.
  57269. */
  57270. changeGazeColor(color: Color3): void;
  57271. /**
  57272. * Exits VR and disposes of the vr experience helper
  57273. */
  57274. dispose(): void;
  57275. /**
  57276. * Gets the name of the VRExperienceHelper class
  57277. * @returns "VRExperienceHelper"
  57278. */
  57279. getClassName(): string;
  57280. }
  57281. }
  57282. declare module BABYLON {
  57283. /**
  57284. * Contains an array of blocks representing the octree
  57285. */
  57286. export interface IOctreeContainer<T> {
  57287. /**
  57288. * Blocks within the octree
  57289. */
  57290. blocks: Array<OctreeBlock<T>>;
  57291. }
  57292. /**
  57293. * Class used to store a cell in an octree
  57294. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57295. */
  57296. export class OctreeBlock<T> {
  57297. /**
  57298. * Gets the content of the current block
  57299. */
  57300. entries: T[];
  57301. /**
  57302. * Gets the list of block children
  57303. */
  57304. blocks: Array<OctreeBlock<T>>;
  57305. private _depth;
  57306. private _maxDepth;
  57307. private _capacity;
  57308. private _minPoint;
  57309. private _maxPoint;
  57310. private _boundingVectors;
  57311. private _creationFunc;
  57312. /**
  57313. * Creates a new block
  57314. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  57315. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  57316. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  57317. * @param depth defines the current depth of this block in the octree
  57318. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  57319. * @param creationFunc defines a callback to call when an element is added to the block
  57320. */
  57321. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  57322. /**
  57323. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  57324. */
  57325. get capacity(): number;
  57326. /**
  57327. * Gets the minimum vector (in world space) of the block's bounding box
  57328. */
  57329. get minPoint(): Vector3;
  57330. /**
  57331. * Gets the maximum vector (in world space) of the block's bounding box
  57332. */
  57333. get maxPoint(): Vector3;
  57334. /**
  57335. * Add a new element to this block
  57336. * @param entry defines the element to add
  57337. */
  57338. addEntry(entry: T): void;
  57339. /**
  57340. * Remove an element from this block
  57341. * @param entry defines the element to remove
  57342. */
  57343. removeEntry(entry: T): void;
  57344. /**
  57345. * Add an array of elements to this block
  57346. * @param entries defines the array of elements to add
  57347. */
  57348. addEntries(entries: T[]): void;
  57349. /**
  57350. * Test if the current block intersects the frustum planes and if yes, then add its content to the selection array
  57351. * @param frustumPlanes defines the frustum planes to test
  57352. * @param selection defines the array to store current content if selection is positive
  57353. * @param allowDuplicate defines if the selection array can contains duplicated entries
  57354. */
  57355. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  57356. /**
  57357. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  57358. * @param sphereCenter defines the bounding sphere center
  57359. * @param sphereRadius defines the bounding sphere radius
  57360. * @param selection defines the array to store current content if selection is positive
  57361. * @param allowDuplicate defines if the selection array can contains duplicated entries
  57362. */
  57363. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  57364. /**
  57365. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  57366. * @param ray defines the ray to test with
  57367. * @param selection defines the array to store current content if selection is positive
  57368. */
  57369. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  57370. /**
  57371. * Subdivide the content into child blocks (this block will then be empty)
  57372. */
  57373. createInnerBlocks(): void;
  57374. /**
  57375. * @hidden
  57376. */
  57377. 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;
  57378. }
  57379. }
  57380. declare module BABYLON {
  57381. /**
  57382. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  57383. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57384. */
  57385. export class Octree<T> {
  57386. /** 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.) */
  57387. maxDepth: number;
  57388. /**
  57389. * Blocks within the octree containing objects
  57390. */
  57391. blocks: Array<OctreeBlock<T>>;
  57392. /**
  57393. * Content stored in the octree
  57394. */
  57395. dynamicContent: T[];
  57396. private _maxBlockCapacity;
  57397. private _selectionContent;
  57398. private _creationFunc;
  57399. /**
  57400. * Creates a octree
  57401. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57402. * @param creationFunc function to be used to instantiate the octree
  57403. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  57404. * @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.)
  57405. */
  57406. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  57407. /** 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.) */
  57408. maxDepth?: number);
  57409. /**
  57410. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  57411. * @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);
  57412. * @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);
  57413. * @param entries meshes to be added to the octree blocks
  57414. */
  57415. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  57416. /**
  57417. * Adds a mesh to the octree
  57418. * @param entry Mesh to add to the octree
  57419. */
  57420. addMesh(entry: T): void;
  57421. /**
  57422. * Remove an element from the octree
  57423. * @param entry defines the element to remove
  57424. */
  57425. removeMesh(entry: T): void;
  57426. /**
  57427. * Selects an array of meshes within the frustum
  57428. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  57429. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  57430. * @returns array of meshes within the frustum
  57431. */
  57432. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  57433. /**
  57434. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  57435. * @param sphereCenter defines the bounding sphere center
  57436. * @param sphereRadius defines the bounding sphere radius
  57437. * @param allowDuplicate defines if the selection array can contains duplicated entries
  57438. * @returns an array of objects that intersect the sphere
  57439. */
  57440. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  57441. /**
  57442. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  57443. * @param ray defines the ray to test with
  57444. * @returns array of intersected objects
  57445. */
  57446. intersectsRay(ray: Ray): SmartArray<T>;
  57447. /**
  57448. * Adds a mesh into the octree block if it intersects the block
  57449. */
  57450. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  57451. /**
  57452. * Adds a submesh into the octree block if it intersects the block
  57453. */
  57454. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  57455. }
  57456. }
  57457. declare module BABYLON {
  57458. interface Scene {
  57459. /**
  57460. * @hidden
  57461. * Backing Filed
  57462. */
  57463. _selectionOctree: Octree<AbstractMesh>;
  57464. /**
  57465. * Gets the octree used to boost mesh selection (picking)
  57466. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57467. */
  57468. selectionOctree: Octree<AbstractMesh>;
  57469. /**
  57470. * Creates or updates the octree used to boost selection (picking)
  57471. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57472. * @param maxCapacity defines the maximum capacity per leaf
  57473. * @param maxDepth defines the maximum depth of the octree
  57474. * @returns an octree of AbstractMesh
  57475. */
  57476. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  57477. }
  57478. interface AbstractMesh {
  57479. /**
  57480. * @hidden
  57481. * Backing Field
  57482. */
  57483. _submeshesOctree: Octree<SubMesh>;
  57484. /**
  57485. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  57486. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  57487. * @param maxCapacity defines the maximum size of each block (64 by default)
  57488. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  57489. * @returns the new octree
  57490. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  57491. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57492. */
  57493. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  57494. }
  57495. /**
  57496. * Defines the octree scene component responsible to manage any octrees
  57497. * in a given scene.
  57498. */
  57499. export class OctreeSceneComponent {
  57500. /**
  57501. * The component name help to identify the component in the list of scene components.
  57502. */
  57503. readonly name: string;
  57504. /**
  57505. * The scene the component belongs to.
  57506. */
  57507. scene: Scene;
  57508. /**
  57509. * Indicates if the meshes have been checked to make sure they are isEnabled()
  57510. */
  57511. readonly checksIsEnabled: boolean;
  57512. /**
  57513. * Creates a new instance of the component for the given scene
  57514. * @param scene Defines the scene to register the component in
  57515. */
  57516. constructor(scene: Scene);
  57517. /**
  57518. * Registers the component in a given scene
  57519. */
  57520. register(): void;
  57521. /**
  57522. * Return the list of active meshes
  57523. * @returns the list of active meshes
  57524. */
  57525. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  57526. /**
  57527. * Return the list of active sub meshes
  57528. * @param mesh The mesh to get the candidates sub meshes from
  57529. * @returns the list of active sub meshes
  57530. */
  57531. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  57532. private _tempRay;
  57533. /**
  57534. * Return the list of sub meshes intersecting with a given local ray
  57535. * @param mesh defines the mesh to find the submesh for
  57536. * @param localRay defines the ray in local space
  57537. * @returns the list of intersecting sub meshes
  57538. */
  57539. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  57540. /**
  57541. * Return the list of sub meshes colliding with a collider
  57542. * @param mesh defines the mesh to find the submesh for
  57543. * @param collider defines the collider to evaluate the collision against
  57544. * @returns the list of colliding sub meshes
  57545. */
  57546. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  57547. /**
  57548. * Rebuilds the elements related to this component in case of
  57549. * context lost for instance.
  57550. */
  57551. rebuild(): void;
  57552. /**
  57553. * Disposes the component and the associated resources.
  57554. */
  57555. dispose(): void;
  57556. }
  57557. }
  57558. declare module BABYLON {
  57559. /**
  57560. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  57561. */
  57562. export interface GizmoAxisCache {
  57563. /** Mesh used to render the Gizmo */
  57564. gizmoMeshes: Mesh[];
  57565. /** Mesh used to detect user interaction with Gizmo */
  57566. colliderMeshes: Mesh[];
  57567. /** Material used to indicate color of gizmo mesh */
  57568. material: StandardMaterial;
  57569. /** Material used to indicate hover state of the Gizmo */
  57570. hoverMaterial: StandardMaterial;
  57571. /** Material used to indicate disabled state of the Gizmo */
  57572. disableMaterial: StandardMaterial;
  57573. /** Used to indicate Active state of the Gizmo */
  57574. active: boolean;
  57575. }
  57576. /**
  57577. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  57578. */
  57579. export class Gizmo implements IDisposable {
  57580. /** The utility layer the gizmo will be added to */
  57581. gizmoLayer: UtilityLayerRenderer;
  57582. /**
  57583. * The root mesh of the gizmo
  57584. */
  57585. _rootMesh: Mesh;
  57586. private _attachedMesh;
  57587. private _attachedNode;
  57588. /**
  57589. * Ratio for the scale of the gizmo (Default: 1)
  57590. */
  57591. protected _scaleRatio: number;
  57592. /**
  57593. * boolean updated by pointermove when a gizmo mesh is hovered
  57594. */
  57595. protected _isHovered: boolean;
  57596. /**
  57597. * Ratio for the scale of the gizmo (Default: 1)
  57598. */
  57599. set scaleRatio(value: number);
  57600. get scaleRatio(): number;
  57601. /**
  57602. * True when the mouse pointer is hovered a gizmo mesh
  57603. */
  57604. get isHovered(): boolean;
  57605. /**
  57606. * If a custom mesh has been set (Default: false)
  57607. */
  57608. protected _customMeshSet: boolean;
  57609. /**
  57610. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  57611. * * When set, interactions will be enabled
  57612. */
  57613. get attachedMesh(): Nullable<AbstractMesh>;
  57614. set attachedMesh(value: Nullable<AbstractMesh>);
  57615. /**
  57616. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  57617. * * When set, interactions will be enabled
  57618. */
  57619. get attachedNode(): Nullable<Node>;
  57620. set attachedNode(value: Nullable<Node>);
  57621. /**
  57622. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  57623. * @param mesh The mesh to replace the default mesh of the gizmo
  57624. */
  57625. setCustomMesh(mesh: Mesh): void;
  57626. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  57627. /**
  57628. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  57629. */
  57630. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57631. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57632. /**
  57633. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  57634. */
  57635. updateGizmoPositionToMatchAttachedMesh: boolean;
  57636. /**
  57637. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  57638. */
  57639. updateScale: boolean;
  57640. protected _interactionsEnabled: boolean;
  57641. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57642. private _beforeRenderObserver;
  57643. private _tempQuaternion;
  57644. private _tempVector;
  57645. private _tempVector2;
  57646. private _tempMatrix1;
  57647. private _tempMatrix2;
  57648. private _rightHandtoLeftHandMatrix;
  57649. /**
  57650. * Creates a gizmo
  57651. * @param gizmoLayer The utility layer the gizmo will be added to
  57652. */
  57653. constructor(
  57654. /** The utility layer the gizmo will be added to */
  57655. gizmoLayer?: UtilityLayerRenderer);
  57656. /**
  57657. * Updates the gizmo to match the attached mesh's position/rotation
  57658. */
  57659. protected _update(): void;
  57660. /**
  57661. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  57662. * @param value Node, TransformNode or mesh
  57663. */
  57664. protected _matrixChanged(): void;
  57665. /**
  57666. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  57667. * @param gizmoLayer The utility layer the gizmo will be added to
  57668. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  57669. * @returns {Observer<PointerInfo>} pointerObserver
  57670. */
  57671. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  57672. /**
  57673. * Disposes of the gizmo
  57674. */
  57675. dispose(): void;
  57676. }
  57677. }
  57678. declare module BABYLON {
  57679. /**
  57680. * Single plane drag gizmo
  57681. */
  57682. export class PlaneDragGizmo extends Gizmo {
  57683. /**
  57684. * Drag behavior responsible for the gizmos dragging interactions
  57685. */
  57686. dragBehavior: PointerDragBehavior;
  57687. private _pointerObserver;
  57688. /**
  57689. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57690. */
  57691. snapDistance: number;
  57692. /**
  57693. * Event that fires each time the gizmo snaps to a new location.
  57694. * * snapDistance is the the change in distance
  57695. */
  57696. onSnapObservable: Observable<{
  57697. snapDistance: number;
  57698. }>;
  57699. private _gizmoMesh;
  57700. private _coloredMaterial;
  57701. private _hoverMaterial;
  57702. private _disableMaterial;
  57703. private _isEnabled;
  57704. private _parent;
  57705. private _dragging;
  57706. /** @hidden */
  57707. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  57708. /**
  57709. * Creates a PlaneDragGizmo
  57710. * @param gizmoLayer The utility layer the gizmo will be added to
  57711. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  57712. * @param color The color of the gizmo
  57713. */
  57714. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  57715. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57716. /**
  57717. * If the gizmo is enabled
  57718. */
  57719. set isEnabled(value: boolean);
  57720. get isEnabled(): boolean;
  57721. /**
  57722. * Disposes of the gizmo
  57723. */
  57724. dispose(): void;
  57725. }
  57726. }
  57727. declare module BABYLON {
  57728. /**
  57729. * Single plane rotation gizmo
  57730. */
  57731. export class PlaneRotationGizmo extends Gizmo {
  57732. /**
  57733. * Drag behavior responsible for the gizmos dragging interactions
  57734. */
  57735. dragBehavior: PointerDragBehavior;
  57736. private _pointerObserver;
  57737. /**
  57738. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  57739. */
  57740. snapDistance: number;
  57741. /**
  57742. * Event that fires each time the gizmo snaps to a new location.
  57743. * * snapDistance is the the change in distance
  57744. */
  57745. onSnapObservable: Observable<{
  57746. snapDistance: number;
  57747. }>;
  57748. private _isEnabled;
  57749. private _parent;
  57750. private _coloredMaterial;
  57751. private _hoverMaterial;
  57752. private _disableMaterial;
  57753. private _gizmoMesh;
  57754. private _rotationCircle;
  57755. private _dragging;
  57756. private static _CircleConstants;
  57757. /**
  57758. * Creates a PlaneRotationGizmo
  57759. * @param gizmoLayer The utility layer the gizmo will be added to
  57760. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  57761. * @param color The color of the gizmo
  57762. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57763. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57764. * @param thickness display gizmo axis thickness
  57765. */
  57766. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  57767. /** Create Geometry for Gizmo */
  57768. private _createGizmoMesh;
  57769. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57770. private setupRotationCircle;
  57771. private updateRotationPath;
  57772. private updateRotationCircle;
  57773. /**
  57774. * If the gizmo is enabled
  57775. */
  57776. set isEnabled(value: boolean);
  57777. get isEnabled(): boolean;
  57778. /**
  57779. * Disposes of the gizmo
  57780. */
  57781. dispose(): void;
  57782. }
  57783. }
  57784. declare module BABYLON {
  57785. /**
  57786. * Gizmo that enables rotating a mesh along 3 axis
  57787. */
  57788. export class RotationGizmo extends Gizmo {
  57789. /**
  57790. * Internal gizmo used for interactions on the x axis
  57791. */
  57792. xGizmo: PlaneRotationGizmo;
  57793. /**
  57794. * Internal gizmo used for interactions on the y axis
  57795. */
  57796. yGizmo: PlaneRotationGizmo;
  57797. /**
  57798. * Internal gizmo used for interactions on the z axis
  57799. */
  57800. zGizmo: PlaneRotationGizmo;
  57801. /** Fires an event when any of it's sub gizmos are dragged */
  57802. onDragStartObservable: Observable<unknown>;
  57803. /** Fires an event when any of it's sub gizmos are released from dragging */
  57804. onDragEndObservable: Observable<unknown>;
  57805. private _meshAttached;
  57806. private _nodeAttached;
  57807. private _observables;
  57808. /** Node Caching for quick lookup */
  57809. private _gizmoAxisCache;
  57810. get attachedMesh(): Nullable<AbstractMesh>;
  57811. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57812. get attachedNode(): Nullable<Node>;
  57813. set attachedNode(node: Nullable<Node>);
  57814. protected _checkBillboardTransform(): void;
  57815. /**
  57816. * True when the mouse pointer is hovering a gizmo mesh
  57817. */
  57818. get isHovered(): boolean;
  57819. /**
  57820. * Creates a RotationGizmo
  57821. * @param gizmoLayer The utility layer the gizmo will be added to
  57822. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57823. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57824. * @param thickness display gizmo axis thickness
  57825. */
  57826. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  57827. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57828. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57829. /**
  57830. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57831. */
  57832. set snapDistance(value: number);
  57833. get snapDistance(): number;
  57834. /**
  57835. * Ratio for the scale of the gizmo (Default: 1)
  57836. */
  57837. set scaleRatio(value: number);
  57838. get scaleRatio(): number;
  57839. /**
  57840. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57841. * @param mesh Axis gizmo mesh
  57842. * @param cache Gizmo axis definition used for reactive gizmo UI
  57843. */
  57844. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57845. /**
  57846. * Disposes of the gizmo
  57847. */
  57848. dispose(): void;
  57849. /**
  57850. * CustomMeshes are not supported by this gizmo
  57851. * @param mesh The mesh to replace the default mesh of the gizmo
  57852. */
  57853. setCustomMesh(mesh: Mesh): void;
  57854. }
  57855. }
  57856. declare module BABYLON {
  57857. /**
  57858. * Class containing static functions to help procedurally build meshes
  57859. */
  57860. export class PolyhedronBuilder {
  57861. /**
  57862. * Creates a polyhedron mesh
  57863. * * 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
  57864. * * The parameter `size` (positive float, default 1) sets the polygon size
  57865. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57866. * * 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`
  57867. * * 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
  57868. * * 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)`)
  57869. * * 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
  57870. * * 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
  57871. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57872. * * 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
  57873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57874. * @param name defines the name of the mesh
  57875. * @param options defines the options used to create the mesh
  57876. * @param scene defines the hosting scene
  57877. * @returns the polyhedron mesh
  57878. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57879. */
  57880. static CreatePolyhedron(name: string, options: {
  57881. type?: number;
  57882. size?: number;
  57883. sizeX?: number;
  57884. sizeY?: number;
  57885. sizeZ?: number;
  57886. custom?: any;
  57887. faceUV?: Vector4[];
  57888. faceColors?: Color4[];
  57889. flat?: boolean;
  57890. updatable?: boolean;
  57891. sideOrientation?: number;
  57892. frontUVs?: Vector4;
  57893. backUVs?: Vector4;
  57894. }, scene?: Nullable<Scene>): Mesh;
  57895. }
  57896. }
  57897. declare module BABYLON {
  57898. /**
  57899. * Class containing static functions to help procedurally build meshes
  57900. */
  57901. export class BoxBuilder {
  57902. /**
  57903. * Creates a box mesh
  57904. * * The parameter `size` sets the size (float) of each box side (default 1)
  57905. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  57906. * * 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)
  57907. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57908. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57909. * * 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
  57910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57911. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57912. * @param name defines the name of the mesh
  57913. * @param options defines the options used to create the mesh
  57914. * @param scene defines the hosting scene
  57915. * @returns the box mesh
  57916. */
  57917. static CreateBox(name: string, options: {
  57918. size?: number;
  57919. width?: number;
  57920. height?: number;
  57921. depth?: number;
  57922. faceUV?: Vector4[];
  57923. faceColors?: Color4[];
  57924. sideOrientation?: number;
  57925. frontUVs?: Vector4;
  57926. backUVs?: Vector4;
  57927. wrap?: boolean;
  57928. topBaseAt?: number;
  57929. bottomBaseAt?: number;
  57930. updatable?: boolean;
  57931. }, scene?: Nullable<Scene>): Mesh;
  57932. }
  57933. }
  57934. declare module BABYLON {
  57935. /**
  57936. * Single axis scale gizmo
  57937. */
  57938. export class AxisScaleGizmo extends Gizmo {
  57939. /**
  57940. * Drag behavior responsible for the gizmos dragging interactions
  57941. */
  57942. dragBehavior: PointerDragBehavior;
  57943. private _pointerObserver;
  57944. /**
  57945. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57946. */
  57947. snapDistance: number;
  57948. /**
  57949. * Event that fires each time the gizmo snaps to a new location.
  57950. * * snapDistance is the the change in distance
  57951. */
  57952. onSnapObservable: Observable<{
  57953. snapDistance: number;
  57954. }>;
  57955. /**
  57956. * If the scaling operation should be done on all axis (default: false)
  57957. */
  57958. uniformScaling: boolean;
  57959. /**
  57960. * Custom sensitivity value for the drag strength
  57961. */
  57962. sensitivity: number;
  57963. private _isEnabled;
  57964. private _parent;
  57965. private _gizmoMesh;
  57966. private _coloredMaterial;
  57967. private _hoverMaterial;
  57968. private _disableMaterial;
  57969. private _dragging;
  57970. private _tmpVector;
  57971. private _tmpMatrix;
  57972. private _tmpMatrix2;
  57973. /**
  57974. * Creates an AxisScaleGizmo
  57975. * @param gizmoLayer The utility layer the gizmo will be added to
  57976. * @param dragAxis The axis which the gizmo will be able to scale on
  57977. * @param color The color of the gizmo
  57978. * @param thickness display gizmo axis thickness
  57979. */
  57980. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  57981. /** Create Geometry for Gizmo */
  57982. private _createGizmoMesh;
  57983. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57984. /**
  57985. * If the gizmo is enabled
  57986. */
  57987. set isEnabled(value: boolean);
  57988. get isEnabled(): boolean;
  57989. /**
  57990. * Disposes of the gizmo
  57991. */
  57992. dispose(): void;
  57993. /**
  57994. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  57995. * @param mesh The mesh to replace the default mesh of the gizmo
  57996. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  57997. */
  57998. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  57999. }
  58000. }
  58001. declare module BABYLON {
  58002. /**
  58003. * Gizmo that enables scaling a mesh along 3 axis
  58004. */
  58005. export class ScaleGizmo extends Gizmo {
  58006. /**
  58007. * Internal gizmo used for interactions on the x axis
  58008. */
  58009. xGizmo: AxisScaleGizmo;
  58010. /**
  58011. * Internal gizmo used for interactions on the y axis
  58012. */
  58013. yGizmo: AxisScaleGizmo;
  58014. /**
  58015. * Internal gizmo used for interactions on the z axis
  58016. */
  58017. zGizmo: AxisScaleGizmo;
  58018. /**
  58019. * Internal gizmo used to scale all axis equally
  58020. */
  58021. uniformScaleGizmo: AxisScaleGizmo;
  58022. private _meshAttached;
  58023. private _nodeAttached;
  58024. private _snapDistance;
  58025. private _uniformScalingMesh;
  58026. private _octahedron;
  58027. private _sensitivity;
  58028. private _coloredMaterial;
  58029. private _hoverMaterial;
  58030. private _disableMaterial;
  58031. private _observables;
  58032. /** Node Caching for quick lookup */
  58033. private _gizmoAxisCache;
  58034. /** Fires an event when any of it's sub gizmos are dragged */
  58035. onDragStartObservable: Observable<unknown>;
  58036. /** Fires an event when any of it's sub gizmos are released from dragging */
  58037. onDragEndObservable: Observable<unknown>;
  58038. get attachedMesh(): Nullable<AbstractMesh>;
  58039. set attachedMesh(mesh: Nullable<AbstractMesh>);
  58040. get attachedNode(): Nullable<Node>;
  58041. set attachedNode(node: Nullable<Node>);
  58042. /**
  58043. * True when the mouse pointer is hovering a gizmo mesh
  58044. */
  58045. get isHovered(): boolean;
  58046. /**
  58047. * Creates a ScaleGizmo
  58048. * @param gizmoLayer The utility layer the gizmo will be added to
  58049. * @param thickness display gizmo axis thickness
  58050. */
  58051. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  58052. /** Create Geometry for Gizmo */
  58053. private _createUniformScaleMesh;
  58054. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  58055. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  58056. /**
  58057. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58058. */
  58059. set snapDistance(value: number);
  58060. get snapDistance(): number;
  58061. /**
  58062. * Ratio for the scale of the gizmo (Default: 1)
  58063. */
  58064. set scaleRatio(value: number);
  58065. get scaleRatio(): number;
  58066. /**
  58067. * Sensitivity factor for dragging (Default: 1)
  58068. */
  58069. set sensitivity(value: number);
  58070. get sensitivity(): number;
  58071. /**
  58072. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  58073. * @param mesh Axis gizmo mesh
  58074. * @param cache Gizmo axis definition used for reactive gizmo UI
  58075. */
  58076. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  58077. /**
  58078. * Disposes of the gizmo
  58079. */
  58080. dispose(): void;
  58081. }
  58082. }
  58083. declare module BABYLON {
  58084. /**
  58085. * Bounding box gizmo
  58086. */
  58087. export class BoundingBoxGizmo extends Gizmo {
  58088. private _lineBoundingBox;
  58089. private _rotateSpheresParent;
  58090. private _scaleBoxesParent;
  58091. private _boundingDimensions;
  58092. private _renderObserver;
  58093. private _pointerObserver;
  58094. private _scaleDragSpeed;
  58095. private _tmpQuaternion;
  58096. private _tmpVector;
  58097. private _tmpRotationMatrix;
  58098. /**
  58099. * 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)
  58100. */
  58101. ignoreChildren: boolean;
  58102. /**
  58103. * 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)
  58104. */
  58105. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  58106. /**
  58107. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  58108. */
  58109. rotationSphereSize: number;
  58110. /**
  58111. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  58112. */
  58113. scaleBoxSize: number;
  58114. /**
  58115. * 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)
  58116. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  58117. */
  58118. fixedDragMeshScreenSize: boolean;
  58119. /**
  58120. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  58121. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  58122. */
  58123. fixedDragMeshBoundsSize: boolean;
  58124. /**
  58125. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  58126. */
  58127. fixedDragMeshScreenSizeDistanceFactor: number;
  58128. /**
  58129. * Fired when a rotation sphere or scale box is dragged
  58130. */
  58131. onDragStartObservable: Observable<{}>;
  58132. /**
  58133. * Fired when a scale box is dragged
  58134. */
  58135. onScaleBoxDragObservable: Observable<{}>;
  58136. /**
  58137. * Fired when a scale box drag is ended
  58138. */
  58139. onScaleBoxDragEndObservable: Observable<{}>;
  58140. /**
  58141. * Fired when a rotation sphere is dragged
  58142. */
  58143. onRotationSphereDragObservable: Observable<{}>;
  58144. /**
  58145. * Fired when a rotation sphere drag is ended
  58146. */
  58147. onRotationSphereDragEndObservable: Observable<{}>;
  58148. /**
  58149. * 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)
  58150. */
  58151. scalePivot: Nullable<Vector3>;
  58152. /**
  58153. * Mesh used as a pivot to rotate the attached node
  58154. */
  58155. private _anchorMesh;
  58156. private _existingMeshScale;
  58157. private _dragMesh;
  58158. private pointerDragBehavior;
  58159. private coloredMaterial;
  58160. private hoverColoredMaterial;
  58161. /**
  58162. * Sets the color of the bounding box gizmo
  58163. * @param color the color to set
  58164. */
  58165. setColor(color: Color3): void;
  58166. /**
  58167. * Creates an BoundingBoxGizmo
  58168. * @param gizmoLayer The utility layer the gizmo will be added to
  58169. * @param color The color of the gizmo
  58170. */
  58171. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  58172. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  58173. private _selectNode;
  58174. /**
  58175. * Updates the bounding box information for the Gizmo
  58176. */
  58177. updateBoundingBox(): void;
  58178. private _updateRotationSpheres;
  58179. private _updateScaleBoxes;
  58180. /**
  58181. * Enables rotation on the specified axis and disables rotation on the others
  58182. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  58183. */
  58184. setEnabledRotationAxis(axis: string): void;
  58185. /**
  58186. * Enables/disables scaling
  58187. * @param enable if scaling should be enabled
  58188. * @param homogeneousScaling defines if scaling should only be homogeneous
  58189. */
  58190. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  58191. private _updateDummy;
  58192. /**
  58193. * Enables a pointer drag behavior on the bounding box of the gizmo
  58194. */
  58195. enableDragBehavior(): void;
  58196. /**
  58197. * Disposes of the gizmo
  58198. */
  58199. dispose(): void;
  58200. /**
  58201. * 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)
  58202. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  58203. * @returns the bounding box mesh with the passed in mesh as a child
  58204. */
  58205. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  58206. /**
  58207. * CustomMeshes are not supported by this gizmo
  58208. * @param mesh The mesh to replace the default mesh of the gizmo
  58209. */
  58210. setCustomMesh(mesh: Mesh): void;
  58211. }
  58212. }
  58213. declare module BABYLON {
  58214. /**
  58215. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  58216. */
  58217. export class GizmoManager implements IDisposable {
  58218. private scene;
  58219. /**
  58220. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  58221. */
  58222. gizmos: {
  58223. positionGizmo: Nullable<PositionGizmo>;
  58224. rotationGizmo: Nullable<RotationGizmo>;
  58225. scaleGizmo: Nullable<ScaleGizmo>;
  58226. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  58227. };
  58228. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  58229. clearGizmoOnEmptyPointerEvent: boolean;
  58230. /** Fires an event when the manager is attached to a mesh */
  58231. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  58232. /** Fires an event when the manager is attached to a node */
  58233. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  58234. private _gizmosEnabled;
  58235. private _pointerObservers;
  58236. private _attachedMesh;
  58237. private _attachedNode;
  58238. private _boundingBoxColor;
  58239. private _defaultUtilityLayer;
  58240. private _defaultKeepDepthUtilityLayer;
  58241. private _thickness;
  58242. /** Node Caching for quick lookup */
  58243. private _gizmoAxisCache;
  58244. /**
  58245. * When bounding box gizmo is enabled, this can be used to track drag/end events
  58246. */
  58247. boundingBoxDragBehavior: SixDofDragBehavior;
  58248. /**
  58249. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  58250. */
  58251. attachableMeshes: Nullable<Array<AbstractMesh>>;
  58252. /**
  58253. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  58254. */
  58255. attachableNodes: Nullable<Array<Node>>;
  58256. /**
  58257. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  58258. */
  58259. usePointerToAttachGizmos: boolean;
  58260. /**
  58261. * Utility layer that the bounding box gizmo belongs to
  58262. */
  58263. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  58264. /**
  58265. * Utility layer that all gizmos besides bounding box belong to
  58266. */
  58267. get utilityLayer(): UtilityLayerRenderer;
  58268. /**
  58269. * True when the mouse pointer is hovering a gizmo mesh
  58270. */
  58271. get isHovered(): boolean;
  58272. /**
  58273. * Instantiates a gizmo manager
  58274. * @param scene the scene to overlay the gizmos on top of
  58275. * @param thickness display gizmo axis thickness
  58276. * @param utilityLayer the layer where gizmos are rendered
  58277. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  58278. */
  58279. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  58280. /**
  58281. * Subscribes to pointer down events, for attaching and detaching mesh
  58282. * @param scene The scene layer the observer will be added to
  58283. */
  58284. private _attachToMeshPointerObserver;
  58285. /**
  58286. * Attaches a set of gizmos to the specified mesh
  58287. * @param mesh The mesh the gizmo's should be attached to
  58288. */
  58289. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58290. /**
  58291. * Attaches a set of gizmos to the specified node
  58292. * @param node The node the gizmo's should be attached to
  58293. */
  58294. attachToNode(node: Nullable<Node>): void;
  58295. /**
  58296. * If the position gizmo is enabled
  58297. */
  58298. set positionGizmoEnabled(value: boolean);
  58299. get positionGizmoEnabled(): boolean;
  58300. /**
  58301. * If the rotation gizmo is enabled
  58302. */
  58303. set rotationGizmoEnabled(value: boolean);
  58304. get rotationGizmoEnabled(): boolean;
  58305. /**
  58306. * If the scale gizmo is enabled
  58307. */
  58308. set scaleGizmoEnabled(value: boolean);
  58309. get scaleGizmoEnabled(): boolean;
  58310. /**
  58311. * If the boundingBox gizmo is enabled
  58312. */
  58313. set boundingBoxGizmoEnabled(value: boolean);
  58314. get boundingBoxGizmoEnabled(): boolean;
  58315. /**
  58316. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  58317. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  58318. */
  58319. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  58320. /**
  58321. * Disposes of the gizmo manager
  58322. */
  58323. dispose(): void;
  58324. }
  58325. }
  58326. declare module BABYLON {
  58327. /**
  58328. * Gizmo that enables dragging a mesh along 3 axis
  58329. */
  58330. export class PositionGizmo extends Gizmo {
  58331. /**
  58332. * Internal gizmo used for interactions on the x axis
  58333. */
  58334. xGizmo: AxisDragGizmo;
  58335. /**
  58336. * Internal gizmo used for interactions on the y axis
  58337. */
  58338. yGizmo: AxisDragGizmo;
  58339. /**
  58340. * Internal gizmo used for interactions on the z axis
  58341. */
  58342. zGizmo: AxisDragGizmo;
  58343. /**
  58344. * Internal gizmo used for interactions on the yz plane
  58345. */
  58346. xPlaneGizmo: PlaneDragGizmo;
  58347. /**
  58348. * Internal gizmo used for interactions on the xz plane
  58349. */
  58350. yPlaneGizmo: PlaneDragGizmo;
  58351. /**
  58352. * Internal gizmo used for interactions on the xy plane
  58353. */
  58354. zPlaneGizmo: PlaneDragGizmo;
  58355. /**
  58356. * private variables
  58357. */
  58358. private _meshAttached;
  58359. private _nodeAttached;
  58360. private _snapDistance;
  58361. private _observables;
  58362. /** Node Caching for quick lookup */
  58363. private _gizmoAxisCache;
  58364. /** Fires an event when any of it's sub gizmos are dragged */
  58365. onDragStartObservable: Observable<unknown>;
  58366. /** Fires an event when any of it's sub gizmos are released from dragging */
  58367. onDragEndObservable: Observable<unknown>;
  58368. /**
  58369. * If set to true, planar drag is enabled
  58370. */
  58371. private _planarGizmoEnabled;
  58372. get attachedMesh(): Nullable<AbstractMesh>;
  58373. set attachedMesh(mesh: Nullable<AbstractMesh>);
  58374. get attachedNode(): Nullable<Node>;
  58375. set attachedNode(node: Nullable<Node>);
  58376. /**
  58377. * True when the mouse pointer is hovering a gizmo mesh
  58378. */
  58379. get isHovered(): boolean;
  58380. /**
  58381. * Creates a PositionGizmo
  58382. * @param gizmoLayer The utility layer the gizmo will be added to
  58383. @param thickness display gizmo axis thickness
  58384. */
  58385. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  58386. /**
  58387. * If the planar drag gizmo is enabled
  58388. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  58389. */
  58390. set planarGizmoEnabled(value: boolean);
  58391. get planarGizmoEnabled(): boolean;
  58392. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  58393. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  58394. /**
  58395. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58396. */
  58397. set snapDistance(value: number);
  58398. get snapDistance(): number;
  58399. /**
  58400. * Ratio for the scale of the gizmo (Default: 1)
  58401. */
  58402. set scaleRatio(value: number);
  58403. get scaleRatio(): number;
  58404. /**
  58405. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  58406. * @param mesh Axis gizmo mesh
  58407. * @param cache Gizmo axis definition used for reactive gizmo UI
  58408. */
  58409. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  58410. /**
  58411. * Disposes of the gizmo
  58412. */
  58413. dispose(): void;
  58414. /**
  58415. * CustomMeshes are not supported by this gizmo
  58416. * @param mesh The mesh to replace the default mesh of the gizmo
  58417. */
  58418. setCustomMesh(mesh: Mesh): void;
  58419. }
  58420. }
  58421. declare module BABYLON {
  58422. /**
  58423. * Single axis drag gizmo
  58424. */
  58425. export class AxisDragGizmo extends Gizmo {
  58426. /**
  58427. * Drag behavior responsible for the gizmos dragging interactions
  58428. */
  58429. dragBehavior: PointerDragBehavior;
  58430. private _pointerObserver;
  58431. /**
  58432. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58433. */
  58434. snapDistance: number;
  58435. /**
  58436. * Event that fires each time the gizmo snaps to a new location.
  58437. * * snapDistance is the the change in distance
  58438. */
  58439. onSnapObservable: Observable<{
  58440. snapDistance: number;
  58441. }>;
  58442. private _isEnabled;
  58443. private _parent;
  58444. private _gizmoMesh;
  58445. private _coloredMaterial;
  58446. private _hoverMaterial;
  58447. private _disableMaterial;
  58448. private _dragging;
  58449. /** @hidden */
  58450. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  58451. /** @hidden */
  58452. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  58453. /**
  58454. * Creates an AxisDragGizmo
  58455. * @param gizmoLayer The utility layer the gizmo will be added to
  58456. * @param dragAxis The axis which the gizmo will be able to drag on
  58457. * @param color The color of the gizmo
  58458. * @param thickness display gizmo axis thickness
  58459. */
  58460. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  58461. protected _attachedNodeChanged(value: Nullable<Node>): void;
  58462. /**
  58463. * If the gizmo is enabled
  58464. */
  58465. set isEnabled(value: boolean);
  58466. get isEnabled(): boolean;
  58467. /**
  58468. * Disposes of the gizmo
  58469. */
  58470. dispose(): void;
  58471. }
  58472. }
  58473. declare module BABYLON.Debug {
  58474. /**
  58475. * The Axes viewer will show 3 axes in a specific point in space
  58476. */
  58477. export class AxesViewer {
  58478. private _xAxis;
  58479. private _yAxis;
  58480. private _zAxis;
  58481. private _scaleLinesFactor;
  58482. private _instanced;
  58483. /**
  58484. * Gets the hosting scene
  58485. */
  58486. scene: Nullable<Scene>;
  58487. /**
  58488. * Gets or sets a number used to scale line length
  58489. */
  58490. scaleLines: number;
  58491. /** Gets the node hierarchy used to render x-axis */
  58492. get xAxis(): TransformNode;
  58493. /** Gets the node hierarchy used to render y-axis */
  58494. get yAxis(): TransformNode;
  58495. /** Gets the node hierarchy used to render z-axis */
  58496. get zAxis(): TransformNode;
  58497. /**
  58498. * Creates a new AxesViewer
  58499. * @param scene defines the hosting scene
  58500. * @param scaleLines defines a number used to scale line length (1 by default)
  58501. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  58502. * @param xAxis defines the node hierarchy used to render the x-axis
  58503. * @param yAxis defines the node hierarchy used to render the y-axis
  58504. * @param zAxis defines the node hierarchy used to render the z-axis
  58505. */
  58506. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  58507. /**
  58508. * Force the viewer to update
  58509. * @param position defines the position of the viewer
  58510. * @param xaxis defines the x axis of the viewer
  58511. * @param yaxis defines the y axis of the viewer
  58512. * @param zaxis defines the z axis of the viewer
  58513. */
  58514. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  58515. /**
  58516. * Creates an instance of this axes viewer.
  58517. * @returns a new axes viewer with instanced meshes
  58518. */
  58519. createInstance(): AxesViewer;
  58520. /** Releases resources */
  58521. dispose(): void;
  58522. private static _SetRenderingGroupId;
  58523. }
  58524. }
  58525. declare module BABYLON.Debug {
  58526. /**
  58527. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  58528. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  58529. */
  58530. export class BoneAxesViewer extends AxesViewer {
  58531. /**
  58532. * Gets or sets the target mesh where to display the axes viewer
  58533. */
  58534. mesh: Nullable<Mesh>;
  58535. /**
  58536. * Gets or sets the target bone where to display the axes viewer
  58537. */
  58538. bone: Nullable<Bone>;
  58539. /** Gets current position */
  58540. pos: Vector3;
  58541. /** Gets direction of X axis */
  58542. xaxis: Vector3;
  58543. /** Gets direction of Y axis */
  58544. yaxis: Vector3;
  58545. /** Gets direction of Z axis */
  58546. zaxis: Vector3;
  58547. /**
  58548. * Creates a new BoneAxesViewer
  58549. * @param scene defines the hosting scene
  58550. * @param bone defines the target bone
  58551. * @param mesh defines the target mesh
  58552. * @param scaleLines defines a scaling factor for line length (1 by default)
  58553. */
  58554. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  58555. /**
  58556. * Force the viewer to update
  58557. */
  58558. update(): void;
  58559. /** Releases resources */
  58560. dispose(): void;
  58561. }
  58562. }
  58563. declare module BABYLON {
  58564. /**
  58565. * Interface used to define scene explorer extensibility option
  58566. */
  58567. export interface IExplorerExtensibilityOption {
  58568. /**
  58569. * Define the option label
  58570. */
  58571. label: string;
  58572. /**
  58573. * Defines the action to execute on click
  58574. */
  58575. action: (entity: any) => void;
  58576. }
  58577. /**
  58578. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  58579. */
  58580. export interface IExplorerExtensibilityGroup {
  58581. /**
  58582. * Defines a predicate to test if a given type mut be extended
  58583. */
  58584. predicate: (entity: any) => boolean;
  58585. /**
  58586. * Gets the list of options added to a type
  58587. */
  58588. entries: IExplorerExtensibilityOption[];
  58589. }
  58590. /**
  58591. * Interface used to define the options to use to create the Inspector
  58592. */
  58593. export interface IInspectorOptions {
  58594. /**
  58595. * Display in overlay mode (default: false)
  58596. */
  58597. overlay?: boolean;
  58598. /**
  58599. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  58600. */
  58601. globalRoot?: HTMLElement;
  58602. /**
  58603. * Display the Scene explorer
  58604. */
  58605. showExplorer?: boolean;
  58606. /**
  58607. * Display the property inspector
  58608. */
  58609. showInspector?: boolean;
  58610. /**
  58611. * Display in embed mode (both panes on the right)
  58612. */
  58613. embedMode?: boolean;
  58614. /**
  58615. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  58616. */
  58617. handleResize?: boolean;
  58618. /**
  58619. * Allow the panes to popup (default: true)
  58620. */
  58621. enablePopup?: boolean;
  58622. /**
  58623. * Allow the panes to be closed by users (default: true)
  58624. */
  58625. enableClose?: boolean;
  58626. /**
  58627. * Optional list of extensibility entries
  58628. */
  58629. explorerExtensibility?: IExplorerExtensibilityGroup[];
  58630. /**
  58631. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  58632. */
  58633. inspectorURL?: string;
  58634. /**
  58635. * Optional initial tab (default to DebugLayerTab.Properties)
  58636. */
  58637. initialTab?: DebugLayerTab;
  58638. }
  58639. interface Scene {
  58640. /**
  58641. * @hidden
  58642. * Backing field
  58643. */
  58644. _debugLayer: DebugLayer;
  58645. /**
  58646. * Gets the debug layer (aka Inspector) associated with the scene
  58647. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58648. */
  58649. debugLayer: DebugLayer;
  58650. }
  58651. /**
  58652. * Enum of inspector action tab
  58653. */
  58654. export enum DebugLayerTab {
  58655. /**
  58656. * Properties tag (default)
  58657. */
  58658. Properties = 0,
  58659. /**
  58660. * Debug tab
  58661. */
  58662. Debug = 1,
  58663. /**
  58664. * Statistics tab
  58665. */
  58666. Statistics = 2,
  58667. /**
  58668. * Tools tab
  58669. */
  58670. Tools = 3,
  58671. /**
  58672. * Settings tab
  58673. */
  58674. Settings = 4
  58675. }
  58676. /**
  58677. * The debug layer (aka Inspector) is the go to tool in order to better understand
  58678. * what is happening in your scene
  58679. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58680. */
  58681. export class DebugLayer {
  58682. /**
  58683. * Define the url to get the inspector script from.
  58684. * By default it uses the babylonjs CDN.
  58685. * @ignoreNaming
  58686. */
  58687. static InspectorURL: string;
  58688. private _scene;
  58689. private BJSINSPECTOR;
  58690. private _onPropertyChangedObservable?;
  58691. /**
  58692. * Observable triggered when a property is changed through the inspector.
  58693. */
  58694. get onPropertyChangedObservable(): any;
  58695. /**
  58696. * Instantiates a new debug layer.
  58697. * The debug layer (aka Inspector) is the go to tool in order to better understand
  58698. * what is happening in your scene
  58699. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58700. * @param scene Defines the scene to inspect
  58701. */
  58702. constructor(scene: Scene);
  58703. /** Creates the inspector window. */
  58704. private _createInspector;
  58705. /**
  58706. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  58707. * @param entity defines the entity to select
  58708. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  58709. */
  58710. select(entity: any, lineContainerTitles?: string | string[]): void;
  58711. /** Get the inspector from bundle or global */
  58712. private _getGlobalInspector;
  58713. /**
  58714. * Get if the inspector is visible or not.
  58715. * @returns true if visible otherwise, false
  58716. */
  58717. isVisible(): boolean;
  58718. /**
  58719. * Hide the inspector and close its window.
  58720. */
  58721. hide(): void;
  58722. /**
  58723. * Update the scene in the inspector
  58724. */
  58725. setAsActiveScene(): void;
  58726. /**
  58727. * Launch the debugLayer.
  58728. * @param config Define the configuration of the inspector
  58729. * @return a promise fulfilled when the debug layer is visible
  58730. */
  58731. show(config?: IInspectorOptions): Promise<DebugLayer>;
  58732. }
  58733. }
  58734. declare module BABYLON.Debug {
  58735. /**
  58736. * Used to show the physics impostor around the specific mesh
  58737. */
  58738. export class PhysicsViewer {
  58739. /** @hidden */
  58740. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  58741. /** @hidden */
  58742. protected _meshes: Array<Nullable<AbstractMesh>>;
  58743. /** @hidden */
  58744. protected _scene: Nullable<Scene>;
  58745. /** @hidden */
  58746. protected _numMeshes: number;
  58747. /** @hidden */
  58748. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  58749. private _renderFunction;
  58750. private _utilityLayer;
  58751. private _debugBoxMesh;
  58752. private _debugSphereMesh;
  58753. private _debugCylinderMesh;
  58754. private _debugMaterial;
  58755. private _debugMeshMeshes;
  58756. /**
  58757. * Creates a new PhysicsViewer
  58758. * @param scene defines the hosting scene
  58759. */
  58760. constructor(scene: Scene);
  58761. /** @hidden */
  58762. protected _updateDebugMeshes(): void;
  58763. /**
  58764. * Renders a specified physic impostor
  58765. * @param impostor defines the impostor to render
  58766. * @param targetMesh defines the mesh represented by the impostor
  58767. * @returns the new debug mesh used to render the impostor
  58768. */
  58769. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  58770. /**
  58771. * Hides a specified physic impostor
  58772. * @param impostor defines the impostor to hide
  58773. */
  58774. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  58775. private _getDebugMaterial;
  58776. private _getDebugBoxMesh;
  58777. private _getDebugSphereMesh;
  58778. private _getDebugCylinderMesh;
  58779. private _getDebugMeshMesh;
  58780. private _getDebugMesh;
  58781. /** Releases all resources */
  58782. dispose(): void;
  58783. }
  58784. }
  58785. declare module BABYLON {
  58786. /**
  58787. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  58788. * in order to better appreciate the issue one might have.
  58789. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  58790. */
  58791. export class RayHelper {
  58792. /**
  58793. * Defines the ray we are currently tryin to visualize.
  58794. */
  58795. ray: Nullable<Ray>;
  58796. private _renderPoints;
  58797. private _renderLine;
  58798. private _renderFunction;
  58799. private _scene;
  58800. private _onAfterRenderObserver;
  58801. private _onAfterStepObserver;
  58802. private _attachedToMesh;
  58803. private _meshSpaceDirection;
  58804. private _meshSpaceOrigin;
  58805. /**
  58806. * Helper function to create a colored helper in a scene in one line.
  58807. * @param ray Defines the ray we are currently tryin to visualize
  58808. * @param scene Defines the scene the ray is used in
  58809. * @param color Defines the color we want to see the ray in
  58810. * @returns The newly created ray helper.
  58811. */
  58812. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  58813. /**
  58814. * Instantiate a new ray helper.
  58815. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  58816. * in order to better appreciate the issue one might have.
  58817. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  58818. * @param ray Defines the ray we are currently tryin to visualize
  58819. */
  58820. constructor(ray: Ray);
  58821. /**
  58822. * Shows the ray we are willing to debug.
  58823. * @param scene Defines the scene the ray needs to be rendered in
  58824. * @param color Defines the color the ray needs to be rendered in
  58825. */
  58826. show(scene: Scene, color?: Color3): void;
  58827. /**
  58828. * Hides the ray we are debugging.
  58829. */
  58830. hide(): void;
  58831. private _render;
  58832. /**
  58833. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  58834. * @param mesh Defines the mesh we want the helper attached to
  58835. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  58836. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  58837. * @param length Defines the length of the ray
  58838. */
  58839. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  58840. /**
  58841. * Detach the ray helper from the mesh it has previously been attached to.
  58842. */
  58843. detachFromMesh(): void;
  58844. private _updateToMesh;
  58845. /**
  58846. * Dispose the helper and release its associated resources.
  58847. */
  58848. dispose(): void;
  58849. }
  58850. }
  58851. declare module BABYLON {
  58852. /**
  58853. * Defines the options associated with the creation of a SkeletonViewer.
  58854. */
  58855. export interface ISkeletonViewerOptions {
  58856. /** Should the system pause animations before building the Viewer? */
  58857. pauseAnimations: boolean;
  58858. /** Should the system return the skeleton to rest before building? */
  58859. returnToRest: boolean;
  58860. /** public Display Mode of the Viewer */
  58861. displayMode: number;
  58862. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  58863. displayOptions: ISkeletonViewerDisplayOptions;
  58864. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  58865. computeBonesUsingShaders: boolean;
  58866. /** Flag ignore non weighted bones */
  58867. useAllBones: boolean;
  58868. }
  58869. /**
  58870. * Defines how to display the various bone meshes for the viewer.
  58871. */
  58872. export interface ISkeletonViewerDisplayOptions {
  58873. /** How far down to start tapering the bone spurs */
  58874. midStep?: number;
  58875. /** How big is the midStep? */
  58876. midStepFactor?: number;
  58877. /** Base for the Sphere Size */
  58878. sphereBaseSize?: number;
  58879. /** The ratio of the sphere to the longest bone in units */
  58880. sphereScaleUnit?: number;
  58881. /** Ratio for the Sphere Size */
  58882. sphereFactor?: number;
  58883. /** Whether a spur should attach its far end to the child bone position */
  58884. spurFollowsChild?: boolean;
  58885. /** Whether to show local axes or not */
  58886. showLocalAxes?: boolean;
  58887. /** Length of each local axis */
  58888. localAxesSize?: number;
  58889. }
  58890. /**
  58891. * Defines the constructor options for the BoneWeight Shader.
  58892. */
  58893. export interface IBoneWeightShaderOptions {
  58894. /** Skeleton to Map */
  58895. skeleton: Skeleton;
  58896. /** Colors for Uninfluenced bones */
  58897. colorBase?: Color3;
  58898. /** Colors for 0.0-0.25 Weight bones */
  58899. colorZero?: Color3;
  58900. /** Color for 0.25-0.5 Weight Influence */
  58901. colorQuarter?: Color3;
  58902. /** Color for 0.5-0.75 Weight Influence */
  58903. colorHalf?: Color3;
  58904. /** Color for 0.75-1 Weight Influence */
  58905. colorFull?: Color3;
  58906. /** Color for Zero Weight Influence */
  58907. targetBoneIndex?: number;
  58908. }
  58909. /**
  58910. * Simple structure of the gradient steps for the Color Map.
  58911. */
  58912. export interface ISkeletonMapShaderColorMapKnot {
  58913. /** Color of the Knot */
  58914. color: Color3;
  58915. /** Location of the Knot */
  58916. location: number;
  58917. }
  58918. /**
  58919. * Defines the constructor options for the SkeletonMap Shader.
  58920. */
  58921. export interface ISkeletonMapShaderOptions {
  58922. /** Skeleton to Map */
  58923. skeleton: Skeleton;
  58924. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  58925. colorMap?: ISkeletonMapShaderColorMapKnot[];
  58926. }
  58927. }
  58928. declare module BABYLON {
  58929. /**
  58930. * Class containing static functions to help procedurally build meshes
  58931. */
  58932. export class RibbonBuilder {
  58933. /**
  58934. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58935. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58936. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58937. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58938. * * 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
  58939. * * 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
  58940. * * 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
  58941. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58942. * * 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
  58943. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58944. * * 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
  58945. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58946. * * 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
  58947. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58949. * @param name defines the name of the mesh
  58950. * @param options defines the options used to create the mesh
  58951. * @param scene defines the hosting scene
  58952. * @returns the ribbon mesh
  58953. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58954. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58955. */
  58956. static CreateRibbon(name: string, options: {
  58957. pathArray: Vector3[][];
  58958. closeArray?: boolean;
  58959. closePath?: boolean;
  58960. offset?: number;
  58961. updatable?: boolean;
  58962. sideOrientation?: number;
  58963. frontUVs?: Vector4;
  58964. backUVs?: Vector4;
  58965. instance?: Mesh;
  58966. invertUV?: boolean;
  58967. uvs?: Vector2[];
  58968. colors?: Color4[];
  58969. }, scene?: Nullable<Scene>): Mesh;
  58970. }
  58971. }
  58972. declare module BABYLON {
  58973. /**
  58974. * Class containing static functions to help procedurally build meshes
  58975. */
  58976. export class ShapeBuilder {
  58977. /**
  58978. * 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.
  58979. * * 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.
  58980. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58981. * * 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.
  58982. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58983. * * 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
  58984. * * 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
  58985. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58987. * * 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
  58988. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58990. * @param name defines the name of the mesh
  58991. * @param options defines the options used to create the mesh
  58992. * @param scene defines the hosting scene
  58993. * @returns the extruded shape mesh
  58994. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58995. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58996. */
  58997. static ExtrudeShape(name: string, options: {
  58998. shape: Vector3[];
  58999. path: Vector3[];
  59000. scale?: number;
  59001. rotation?: number;
  59002. cap?: number;
  59003. updatable?: boolean;
  59004. sideOrientation?: number;
  59005. frontUVs?: Vector4;
  59006. backUVs?: Vector4;
  59007. instance?: Mesh;
  59008. invertUV?: boolean;
  59009. }, scene?: Nullable<Scene>): Mesh;
  59010. /**
  59011. * Creates an custom extruded shape mesh.
  59012. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59013. * * 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.
  59014. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59015. * * 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
  59016. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59017. * * 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
  59018. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59019. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59020. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59021. * * 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
  59022. * * 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
  59023. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59024. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59025. * * 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
  59026. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59028. * @param name defines the name of the mesh
  59029. * @param options defines the options used to create the mesh
  59030. * @param scene defines the hosting scene
  59031. * @returns the custom extruded shape mesh
  59032. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59033. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59034. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59035. */
  59036. static ExtrudeShapeCustom(name: string, options: {
  59037. shape: Vector3[];
  59038. path: Vector3[];
  59039. scaleFunction?: any;
  59040. rotationFunction?: any;
  59041. ribbonCloseArray?: boolean;
  59042. ribbonClosePath?: boolean;
  59043. cap?: number;
  59044. updatable?: boolean;
  59045. sideOrientation?: number;
  59046. frontUVs?: Vector4;
  59047. backUVs?: Vector4;
  59048. instance?: Mesh;
  59049. invertUV?: boolean;
  59050. }, scene?: Nullable<Scene>): Mesh;
  59051. private static _ExtrudeShapeGeneric;
  59052. }
  59053. }
  59054. declare module BABYLON.Debug {
  59055. /**
  59056. * Class used to render a debug view of a given skeleton
  59057. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  59058. */
  59059. export class SkeletonViewer {
  59060. /** defines the skeleton to render */
  59061. skeleton: Skeleton;
  59062. /** defines the mesh attached to the skeleton */
  59063. mesh: AbstractMesh;
  59064. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  59065. autoUpdateBonesMatrices: boolean;
  59066. /** defines the rendering group id to use with the viewer */
  59067. renderingGroupId: number;
  59068. /** is the options for the viewer */
  59069. options: Partial<ISkeletonViewerOptions>;
  59070. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  59071. static readonly DISPLAY_LINES: number;
  59072. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  59073. static readonly DISPLAY_SPHERES: number;
  59074. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  59075. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  59076. /** public static method to create a BoneWeight Shader
  59077. * @param options The constructor options
  59078. * @param scene The scene that the shader is scoped to
  59079. * @returns The created ShaderMaterial
  59080. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  59081. */
  59082. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  59083. /** public static method to create a BoneWeight Shader
  59084. * @param options The constructor options
  59085. * @param scene The scene that the shader is scoped to
  59086. * @returns The created ShaderMaterial
  59087. */
  59088. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  59089. /** private static method to create a BoneWeight Shader
  59090. * @param size The size of the buffer to create (usually the bone count)
  59091. * @param colorMap The gradient data to generate
  59092. * @param scene The scene that the shader is scoped to
  59093. * @returns an Array of floats from the color gradient values
  59094. */
  59095. private static _CreateBoneMapColorBuffer;
  59096. /** If SkeletonViewer scene scope. */
  59097. private _scene;
  59098. /** Gets or sets the color used to render the skeleton */
  59099. color: Color3;
  59100. /** Array of the points of the skeleton fo the line view. */
  59101. private _debugLines;
  59102. /** The SkeletonViewers Mesh. */
  59103. private _debugMesh;
  59104. /** The local axes Meshes. */
  59105. private _localAxes;
  59106. /** If SkeletonViewer is enabled. */
  59107. private _isEnabled;
  59108. /** If SkeletonViewer is ready. */
  59109. private _ready;
  59110. /** SkeletonViewer render observable. */
  59111. private _obs;
  59112. /** The Utility Layer to render the gizmos in. */
  59113. private _utilityLayer;
  59114. private _boneIndices;
  59115. /** Gets the Scene. */
  59116. get scene(): Scene;
  59117. /** Gets the utilityLayer. */
  59118. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  59119. /** Checks Ready Status. */
  59120. get isReady(): Boolean;
  59121. /** Sets Ready Status. */
  59122. set ready(value: boolean);
  59123. /** Gets the debugMesh */
  59124. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  59125. /** Sets the debugMesh */
  59126. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  59127. /** Gets the displayMode */
  59128. get displayMode(): number;
  59129. /** Sets the displayMode */
  59130. set displayMode(value: number);
  59131. /**
  59132. * Creates a new SkeletonViewer
  59133. * @param skeleton defines the skeleton to render
  59134. * @param mesh defines the mesh attached to the skeleton
  59135. * @param scene defines the hosting scene
  59136. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  59137. * @param renderingGroupId defines the rendering group id to use with the viewer
  59138. * @param options All of the extra constructor options for the SkeletonViewer
  59139. */
  59140. constructor(
  59141. /** defines the skeleton to render */
  59142. skeleton: Skeleton,
  59143. /** defines the mesh attached to the skeleton */
  59144. mesh: AbstractMesh,
  59145. /** The Scene scope*/
  59146. scene: Scene,
  59147. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  59148. autoUpdateBonesMatrices?: boolean,
  59149. /** defines the rendering group id to use with the viewer */
  59150. renderingGroupId?: number,
  59151. /** is the options for the viewer */
  59152. options?: Partial<ISkeletonViewerOptions>);
  59153. /** The Dynamic bindings for the update functions */
  59154. private _bindObs;
  59155. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  59156. update(): void;
  59157. /** Gets or sets a boolean indicating if the viewer is enabled */
  59158. set isEnabled(value: boolean);
  59159. get isEnabled(): boolean;
  59160. private _getBonePosition;
  59161. private _getLinesForBonesWithLength;
  59162. private _getLinesForBonesNoLength;
  59163. /** function to revert the mesh and scene back to the initial state. */
  59164. private _revert;
  59165. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  59166. private _getAbsoluteBindPoseToRef;
  59167. /** function to build and bind sphere joint points and spur bone representations. */
  59168. private _buildSpheresAndSpurs;
  59169. private _buildLocalAxes;
  59170. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  59171. private _displayLinesUpdate;
  59172. /** Changes the displayMode of the skeleton viewer
  59173. * @param mode The displayMode numerical value
  59174. */
  59175. changeDisplayMode(mode: number): void;
  59176. /** Sets a display option of the skeleton viewer
  59177. *
  59178. * | Option | Type | Default | Description |
  59179. * | ---------------- | ------- | ------- | ----------- |
  59180. * | 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`. |
  59181. * | 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`. |
  59182. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  59183. * | 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`. |
  59184. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  59185. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  59186. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  59187. *
  59188. * @param option String of the option name
  59189. * @param value The numerical option value
  59190. */
  59191. changeDisplayOptions(option: string, value: number): void;
  59192. /** Release associated resources */
  59193. dispose(): void;
  59194. }
  59195. }
  59196. declare module BABYLON {
  59197. /**
  59198. * Enum for Device Types
  59199. */
  59200. export enum DeviceType {
  59201. /** Generic */
  59202. Generic = 0,
  59203. /** Keyboard */
  59204. Keyboard = 1,
  59205. /** Mouse */
  59206. Mouse = 2,
  59207. /** Touch Pointers */
  59208. Touch = 3,
  59209. /** PS4 Dual Shock */
  59210. DualShock = 4,
  59211. /** Xbox */
  59212. Xbox = 5,
  59213. /** Switch Controller */
  59214. Switch = 6
  59215. }
  59216. /**
  59217. * Enum for All Pointers (Touch/Mouse)
  59218. */
  59219. export enum PointerInput {
  59220. /** Horizontal Axis */
  59221. Horizontal = 0,
  59222. /** Vertical Axis */
  59223. Vertical = 1,
  59224. /** Left Click or Touch */
  59225. LeftClick = 2,
  59226. /** Middle Click */
  59227. MiddleClick = 3,
  59228. /** Right Click */
  59229. RightClick = 4,
  59230. /** Browser Back */
  59231. BrowserBack = 5,
  59232. /** Browser Forward */
  59233. BrowserForward = 6
  59234. }
  59235. /**
  59236. * Enum for Dual Shock Gamepad
  59237. */
  59238. export enum DualShockInput {
  59239. /** Cross */
  59240. Cross = 0,
  59241. /** Circle */
  59242. Circle = 1,
  59243. /** Square */
  59244. Square = 2,
  59245. /** Triangle */
  59246. Triangle = 3,
  59247. /** L1 */
  59248. L1 = 4,
  59249. /** R1 */
  59250. R1 = 5,
  59251. /** L2 */
  59252. L2 = 6,
  59253. /** R2 */
  59254. R2 = 7,
  59255. /** Share */
  59256. Share = 8,
  59257. /** Options */
  59258. Options = 9,
  59259. /** L3 */
  59260. L3 = 10,
  59261. /** R3 */
  59262. R3 = 11,
  59263. /** DPadUp */
  59264. DPadUp = 12,
  59265. /** DPadDown */
  59266. DPadDown = 13,
  59267. /** DPadLeft */
  59268. DPadLeft = 14,
  59269. /** DRight */
  59270. DPadRight = 15,
  59271. /** Home */
  59272. Home = 16,
  59273. /** TouchPad */
  59274. TouchPad = 17,
  59275. /** LStickXAxis */
  59276. LStickXAxis = 18,
  59277. /** LStickYAxis */
  59278. LStickYAxis = 19,
  59279. /** RStickXAxis */
  59280. RStickXAxis = 20,
  59281. /** RStickYAxis */
  59282. RStickYAxis = 21
  59283. }
  59284. /**
  59285. * Enum for Xbox Gamepad
  59286. */
  59287. export enum XboxInput {
  59288. /** A */
  59289. A = 0,
  59290. /** B */
  59291. B = 1,
  59292. /** X */
  59293. X = 2,
  59294. /** Y */
  59295. Y = 3,
  59296. /** LB */
  59297. LB = 4,
  59298. /** RB */
  59299. RB = 5,
  59300. /** LT */
  59301. LT = 6,
  59302. /** RT */
  59303. RT = 7,
  59304. /** Back */
  59305. Back = 8,
  59306. /** Start */
  59307. Start = 9,
  59308. /** LS */
  59309. LS = 10,
  59310. /** RS */
  59311. RS = 11,
  59312. /** DPadUp */
  59313. DPadUp = 12,
  59314. /** DPadDown */
  59315. DPadDown = 13,
  59316. /** DPadLeft */
  59317. DPadLeft = 14,
  59318. /** DRight */
  59319. DPadRight = 15,
  59320. /** Home */
  59321. Home = 16,
  59322. /** LStickXAxis */
  59323. LStickXAxis = 17,
  59324. /** LStickYAxis */
  59325. LStickYAxis = 18,
  59326. /** RStickXAxis */
  59327. RStickXAxis = 19,
  59328. /** RStickYAxis */
  59329. RStickYAxis = 20
  59330. }
  59331. /**
  59332. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  59333. */
  59334. export enum SwitchInput {
  59335. /** B */
  59336. B = 0,
  59337. /** A */
  59338. A = 1,
  59339. /** Y */
  59340. Y = 2,
  59341. /** X */
  59342. X = 3,
  59343. /** L */
  59344. L = 4,
  59345. /** R */
  59346. R = 5,
  59347. /** ZL */
  59348. ZL = 6,
  59349. /** ZR */
  59350. ZR = 7,
  59351. /** Minus */
  59352. Minus = 8,
  59353. /** Plus */
  59354. Plus = 9,
  59355. /** LS */
  59356. LS = 10,
  59357. /** RS */
  59358. RS = 11,
  59359. /** DPadUp */
  59360. DPadUp = 12,
  59361. /** DPadDown */
  59362. DPadDown = 13,
  59363. /** DPadLeft */
  59364. DPadLeft = 14,
  59365. /** DRight */
  59366. DPadRight = 15,
  59367. /** Home */
  59368. Home = 16,
  59369. /** Capture */
  59370. Capture = 17,
  59371. /** LStickXAxis */
  59372. LStickXAxis = 18,
  59373. /** LStickYAxis */
  59374. LStickYAxis = 19,
  59375. /** RStickXAxis */
  59376. RStickXAxis = 20,
  59377. /** RStickYAxis */
  59378. RStickYAxis = 21
  59379. }
  59380. }
  59381. declare module BABYLON {
  59382. /**
  59383. * This class will take all inputs from Keyboard, Pointer, and
  59384. * any Gamepads and provide a polling system that all devices
  59385. * will use. This class assumes that there will only be one
  59386. * pointer device and one keyboard.
  59387. */
  59388. export class DeviceInputSystem implements IDisposable {
  59389. /**
  59390. * Returns onDeviceConnected callback property
  59391. * @returns Callback with function to execute when a device is connected
  59392. */
  59393. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  59394. /**
  59395. * Sets callback function when a device is connected and executes against all connected devices
  59396. * @param callback Function to execute when a device is connected
  59397. */
  59398. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  59399. /**
  59400. * Callback to be triggered when a device is disconnected
  59401. */
  59402. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  59403. /**
  59404. * Callback to be triggered when event driven input is updated
  59405. */
  59406. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  59407. private _inputs;
  59408. private _gamepads;
  59409. private _keyboardActive;
  59410. private _pointerActive;
  59411. private _elementToAttachTo;
  59412. private _keyboardDownEvent;
  59413. private _keyboardUpEvent;
  59414. private _pointerMoveEvent;
  59415. private _pointerDownEvent;
  59416. private _pointerUpEvent;
  59417. private _gamepadConnectedEvent;
  59418. private _gamepadDisconnectedEvent;
  59419. private _onDeviceConnected;
  59420. private static _MAX_KEYCODES;
  59421. private static _MAX_POINTER_INPUTS;
  59422. private constructor();
  59423. /**
  59424. * Creates a new DeviceInputSystem instance
  59425. * @param engine Engine to pull input element from
  59426. * @returns The new instance
  59427. */
  59428. static Create(engine: Engine): DeviceInputSystem;
  59429. /**
  59430. * Checks for current device input value, given an id and input index
  59431. * @param deviceName Id of connected device
  59432. * @param inputIndex Index of device input
  59433. * @returns Current value of input
  59434. */
  59435. /**
  59436. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  59437. * @param deviceType Enum specifiying device type
  59438. * @param deviceSlot "Slot" or index that device is referenced in
  59439. * @param inputIndex Id of input to be checked
  59440. * @returns Current value of input
  59441. */
  59442. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  59443. /**
  59444. * Dispose of all the eventlisteners
  59445. */
  59446. dispose(): void;
  59447. /**
  59448. * Checks for existing connections to devices and register them, if necessary
  59449. * Currently handles gamepads and mouse
  59450. */
  59451. private _checkForConnectedDevices;
  59452. /**
  59453. * Add a gamepad to the DeviceInputSystem
  59454. * @param gamepad A single DOM Gamepad object
  59455. */
  59456. private _addGamePad;
  59457. /**
  59458. * Add pointer device to DeviceInputSystem
  59459. * @param deviceType Type of Pointer to add
  59460. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  59461. * @param currentX Current X at point of adding
  59462. * @param currentY Current Y at point of adding
  59463. */
  59464. private _addPointerDevice;
  59465. /**
  59466. * Add device and inputs to device array
  59467. * @param deviceType Enum specifiying device type
  59468. * @param deviceSlot "Slot" or index that device is referenced in
  59469. * @param numberOfInputs Number of input entries to create for given device
  59470. */
  59471. private _registerDevice;
  59472. /**
  59473. * Given a specific device name, remove that device from the device map
  59474. * @param deviceType Enum specifiying device type
  59475. * @param deviceSlot "Slot" or index that device is referenced in
  59476. */
  59477. private _unregisterDevice;
  59478. /**
  59479. * Handle all actions that come from keyboard interaction
  59480. */
  59481. private _handleKeyActions;
  59482. /**
  59483. * Handle all actions that come from pointer interaction
  59484. */
  59485. private _handlePointerActions;
  59486. /**
  59487. * Handle all actions that come from gamepad interaction
  59488. */
  59489. private _handleGamepadActions;
  59490. /**
  59491. * Update all non-event based devices with each frame
  59492. * @param deviceType Enum specifiying device type
  59493. * @param deviceSlot "Slot" or index that device is referenced in
  59494. * @param inputIndex Id of input to be checked
  59495. */
  59496. private _updateDevice;
  59497. /**
  59498. * Gets DeviceType from the device name
  59499. * @param deviceName Name of Device from DeviceInputSystem
  59500. * @returns DeviceType enum value
  59501. */
  59502. private _getGamepadDeviceType;
  59503. }
  59504. }
  59505. declare module BABYLON {
  59506. /**
  59507. * Type to handle enforcement of inputs
  59508. */
  59509. 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;
  59510. }
  59511. declare module BABYLON {
  59512. /**
  59513. * Class that handles all input for a specific device
  59514. */
  59515. export class DeviceSource<T extends DeviceType> {
  59516. /** Type of device */
  59517. readonly deviceType: DeviceType;
  59518. /** "Slot" or index that device is referenced in */
  59519. readonly deviceSlot: number;
  59520. /**
  59521. * Observable to handle device input changes per device
  59522. */
  59523. readonly onInputChangedObservable: Observable<{
  59524. inputIndex: DeviceInput<T>;
  59525. previousState: Nullable<number>;
  59526. currentState: Nullable<number>;
  59527. }>;
  59528. private readonly _deviceInputSystem;
  59529. /**
  59530. * Default Constructor
  59531. * @param deviceInputSystem Reference to DeviceInputSystem
  59532. * @param deviceType Type of device
  59533. * @param deviceSlot "Slot" or index that device is referenced in
  59534. */
  59535. constructor(deviceInputSystem: DeviceInputSystem,
  59536. /** Type of device */
  59537. deviceType: DeviceType,
  59538. /** "Slot" or index that device is referenced in */
  59539. deviceSlot?: number);
  59540. /**
  59541. * Get input for specific input
  59542. * @param inputIndex index of specific input on device
  59543. * @returns Input value from DeviceInputSystem
  59544. */
  59545. getInput(inputIndex: DeviceInput<T>): number;
  59546. }
  59547. /**
  59548. * Class to keep track of devices
  59549. */
  59550. export class DeviceSourceManager implements IDisposable {
  59551. /**
  59552. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  59553. */
  59554. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  59555. /**
  59556. * Observable to be triggered when after a device is disconnected
  59557. */
  59558. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  59559. private readonly _devices;
  59560. private readonly _firstDevice;
  59561. private readonly _deviceInputSystem;
  59562. /**
  59563. * Default Constructor
  59564. * @param engine engine to pull input element from
  59565. */
  59566. constructor(engine: Engine);
  59567. /**
  59568. * Gets a DeviceSource, given a type and slot
  59569. * @param deviceType Enum specifying device type
  59570. * @param deviceSlot "Slot" or index that device is referenced in
  59571. * @returns DeviceSource object
  59572. */
  59573. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  59574. /**
  59575. * Gets an array of DeviceSource objects for a given device type
  59576. * @param deviceType Enum specifying device type
  59577. * @returns Array of DeviceSource objects
  59578. */
  59579. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  59580. /**
  59581. * Returns a read-only list of all available devices
  59582. * @returns Read-only array with active devices
  59583. */
  59584. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  59585. /**
  59586. * Dispose of DeviceInputSystem and other parts
  59587. */
  59588. dispose(): void;
  59589. /**
  59590. * Function to add device name to device list
  59591. * @param deviceType Enum specifying device type
  59592. * @param deviceSlot "Slot" or index that device is referenced in
  59593. */
  59594. private _addDevice;
  59595. /**
  59596. * Function to remove device name to device list
  59597. * @param deviceType Enum specifying device type
  59598. * @param deviceSlot "Slot" or index that device is referenced in
  59599. */
  59600. private _removeDevice;
  59601. /**
  59602. * Updates array storing first connected device of each type
  59603. * @param type Type of Device
  59604. */
  59605. private _updateFirstDevices;
  59606. }
  59607. }
  59608. declare module BABYLON {
  59609. /**
  59610. * Options to create the null engine
  59611. */
  59612. export class NullEngineOptions {
  59613. /**
  59614. * Render width (Default: 512)
  59615. */
  59616. renderWidth: number;
  59617. /**
  59618. * Render height (Default: 256)
  59619. */
  59620. renderHeight: number;
  59621. /**
  59622. * Texture size (Default: 512)
  59623. */
  59624. textureSize: number;
  59625. /**
  59626. * If delta time between frames should be constant
  59627. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59628. */
  59629. deterministicLockstep: boolean;
  59630. /**
  59631. * Maximum about of steps between frames (Default: 4)
  59632. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59633. */
  59634. lockstepMaxSteps: number;
  59635. /**
  59636. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  59637. */
  59638. useHighPrecisionMatrix?: boolean;
  59639. }
  59640. /**
  59641. * The null engine class provides support for headless version of babylon.js.
  59642. * This can be used in server side scenario or for testing purposes
  59643. */
  59644. export class NullEngine extends Engine {
  59645. private _options;
  59646. /**
  59647. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  59648. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59649. * @returns true if engine is in deterministic lock step mode
  59650. */
  59651. isDeterministicLockStep(): boolean;
  59652. /**
  59653. * Gets the max steps when engine is running in deterministic lock step
  59654. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59655. * @returns the max steps
  59656. */
  59657. getLockstepMaxSteps(): number;
  59658. /**
  59659. * Gets the current hardware scaling level.
  59660. * By default the hardware scaling level is computed from the window device ratio.
  59661. * 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.
  59662. * @returns a number indicating the current hardware scaling level
  59663. */
  59664. getHardwareScalingLevel(): number;
  59665. constructor(options?: NullEngineOptions);
  59666. /**
  59667. * Creates a vertex buffer
  59668. * @param vertices the data for the vertex buffer
  59669. * @returns the new WebGL static buffer
  59670. */
  59671. createVertexBuffer(vertices: FloatArray): DataBuffer;
  59672. /**
  59673. * Creates a new index buffer
  59674. * @param indices defines the content of the index buffer
  59675. * @param updatable defines if the index buffer must be updatable
  59676. * @returns a new webGL buffer
  59677. */
  59678. createIndexBuffer(indices: IndicesArray): DataBuffer;
  59679. /**
  59680. * Clear the current render buffer or the current render target (if any is set up)
  59681. * @param color defines the color to use
  59682. * @param backBuffer defines if the back buffer must be cleared
  59683. * @param depth defines if the depth buffer must be cleared
  59684. * @param stencil defines if the stencil buffer must be cleared
  59685. */
  59686. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  59687. /**
  59688. * Gets the current render width
  59689. * @param useScreen defines if screen size must be used (or the current render target if any)
  59690. * @returns a number defining the current render width
  59691. */
  59692. getRenderWidth(useScreen?: boolean): number;
  59693. /**
  59694. * Gets the current render height
  59695. * @param useScreen defines if screen size must be used (or the current render target if any)
  59696. * @returns a number defining the current render height
  59697. */
  59698. getRenderHeight(useScreen?: boolean): number;
  59699. /**
  59700. * Set the WebGL's viewport
  59701. * @param viewport defines the viewport element to be used
  59702. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  59703. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  59704. */
  59705. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  59706. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  59707. /**
  59708. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  59709. * @param pipelineContext defines the pipeline context to use
  59710. * @param uniformsNames defines the list of uniform names
  59711. * @returns an array of webGL uniform locations
  59712. */
  59713. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  59714. /**
  59715. * Gets the lsit of active attributes for a given webGL program
  59716. * @param pipelineContext defines the pipeline context to use
  59717. * @param attributesNames defines the list of attribute names to get
  59718. * @returns an array of indices indicating the offset of each attribute
  59719. */
  59720. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  59721. /**
  59722. * Binds an effect to the webGL context
  59723. * @param effect defines the effect to bind
  59724. */
  59725. bindSamplers(effect: Effect): void;
  59726. /**
  59727. * Activates an effect, making it the current one (ie. the one used for rendering)
  59728. * @param effect defines the effect to activate
  59729. */
  59730. enableEffect(effect: Effect): void;
  59731. /**
  59732. * Set various states to the webGL context
  59733. * @param culling defines backface culling state
  59734. * @param zOffset defines the value to apply to zOffset (0 by default)
  59735. * @param force defines if states must be applied even if cache is up to date
  59736. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  59737. */
  59738. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  59739. /**
  59740. * Set the value of an uniform to an array of int32
  59741. * @param uniform defines the webGL uniform location where to store the value
  59742. * @param array defines the array of int32 to store
  59743. * @returns true if value was set
  59744. */
  59745. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59746. /**
  59747. * Set the value of an uniform to an array of int32 (stored as vec2)
  59748. * @param uniform defines the webGL uniform location where to store the value
  59749. * @param array defines the array of int32 to store
  59750. * @returns true if value was set
  59751. */
  59752. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59753. /**
  59754. * Set the value of an uniform to an array of int32 (stored as vec3)
  59755. * @param uniform defines the webGL uniform location where to store the value
  59756. * @param array defines the array of int32 to store
  59757. * @returns true if value was set
  59758. */
  59759. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59760. /**
  59761. * Set the value of an uniform to an array of int32 (stored as vec4)
  59762. * @param uniform defines the webGL uniform location where to store the value
  59763. * @param array defines the array of int32 to store
  59764. * @returns true if value was set
  59765. */
  59766. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59767. /**
  59768. * Set the value of an uniform to an array of float32
  59769. * @param uniform defines the webGL uniform location where to store the value
  59770. * @param array defines the array of float32 to store
  59771. * @returns true if value was set
  59772. */
  59773. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59774. /**
  59775. * Set the value of an uniform to an array of float32 (stored as vec2)
  59776. * @param uniform defines the webGL uniform location where to store the value
  59777. * @param array defines the array of float32 to store
  59778. * @returns true if value was set
  59779. */
  59780. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59781. /**
  59782. * Set the value of an uniform to an array of float32 (stored as vec3)
  59783. * @param uniform defines the webGL uniform location where to store the value
  59784. * @param array defines the array of float32 to store
  59785. * @returns true if value was set
  59786. */
  59787. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59788. /**
  59789. * Set the value of an uniform to an array of float32 (stored as vec4)
  59790. * @param uniform defines the webGL uniform location where to store the value
  59791. * @param array defines the array of float32 to store
  59792. * @returns true if value was set
  59793. */
  59794. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59795. /**
  59796. * Set the value of an uniform to an array of number
  59797. * @param uniform defines the webGL uniform location where to store the value
  59798. * @param array defines the array of number to store
  59799. * @returns true if value was set
  59800. */
  59801. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  59802. /**
  59803. * Set the value of an uniform to an array of number (stored as vec2)
  59804. * @param uniform defines the webGL uniform location where to store the value
  59805. * @param array defines the array of number to store
  59806. * @returns true if value was set
  59807. */
  59808. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  59809. /**
  59810. * Set the value of an uniform to an array of number (stored as vec3)
  59811. * @param uniform defines the webGL uniform location where to store the value
  59812. * @param array defines the array of number to store
  59813. * @returns true if value was set
  59814. */
  59815. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  59816. /**
  59817. * Set the value of an uniform to an array of number (stored as vec4)
  59818. * @param uniform defines the webGL uniform location where to store the value
  59819. * @param array defines the array of number to store
  59820. * @returns true if value was set
  59821. */
  59822. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  59823. /**
  59824. * Set the value of an uniform to an array of float32 (stored as matrices)
  59825. * @param uniform defines the webGL uniform location where to store the value
  59826. * @param matrices defines the array of float32 to store
  59827. * @returns true if value was set
  59828. */
  59829. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  59830. /**
  59831. * Set the value of an uniform to a matrix (3x3)
  59832. * @param uniform defines the webGL uniform location where to store the value
  59833. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  59834. * @returns true if value was set
  59835. */
  59836. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59837. /**
  59838. * Set the value of an uniform to a matrix (2x2)
  59839. * @param uniform defines the webGL uniform location where to store the value
  59840. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  59841. * @returns true if value was set
  59842. */
  59843. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59844. /**
  59845. * Set the value of an uniform to a number (float)
  59846. * @param uniform defines the webGL uniform location where to store the value
  59847. * @param value defines the float number to store
  59848. * @returns true if value was set
  59849. */
  59850. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  59851. /**
  59852. * Set the value of an uniform to a vec2
  59853. * @param uniform defines the webGL uniform location where to store the value
  59854. * @param x defines the 1st component of the value
  59855. * @param y defines the 2nd component of the value
  59856. * @returns true if value was set
  59857. */
  59858. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  59859. /**
  59860. * Set the value of an uniform to a vec3
  59861. * @param uniform defines the webGL uniform location where to store the value
  59862. * @param x defines the 1st component of the value
  59863. * @param y defines the 2nd component of the value
  59864. * @param z defines the 3rd component of the value
  59865. * @returns true if value was set
  59866. */
  59867. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  59868. /**
  59869. * Set the value of an uniform to a boolean
  59870. * @param uniform defines the webGL uniform location where to store the value
  59871. * @param bool defines the boolean to store
  59872. * @returns true if value was set
  59873. */
  59874. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  59875. /**
  59876. * Set the value of an uniform to a vec4
  59877. * @param uniform defines the webGL uniform location where to store the value
  59878. * @param x defines the 1st component of the value
  59879. * @param y defines the 2nd component of the value
  59880. * @param z defines the 3rd component of the value
  59881. * @param w defines the 4th component of the value
  59882. * @returns true if value was set
  59883. */
  59884. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  59885. /**
  59886. * Sets the current alpha mode
  59887. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  59888. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  59889. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59890. */
  59891. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  59892. /**
  59893. * Bind webGl buffers directly to the webGL context
  59894. * @param vertexBuffers defines the vertex buffer to bind
  59895. * @param indexBuffer defines the index buffer to bind
  59896. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  59897. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  59898. * @param effect defines the effect associated with the vertex buffer
  59899. */
  59900. bindBuffers(vertexBuffers: {
  59901. [key: string]: VertexBuffer;
  59902. }, indexBuffer: DataBuffer, effect: Effect): void;
  59903. /**
  59904. * Force the entire cache to be cleared
  59905. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  59906. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  59907. */
  59908. wipeCaches(bruteForce?: boolean): void;
  59909. /**
  59910. * Send a draw order
  59911. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  59912. * @param indexStart defines the starting index
  59913. * @param indexCount defines the number of index to draw
  59914. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59915. */
  59916. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  59917. /**
  59918. * Draw a list of indexed primitives
  59919. * @param fillMode defines the primitive to use
  59920. * @param indexStart defines the starting index
  59921. * @param indexCount defines the number of index to draw
  59922. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59923. */
  59924. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  59925. /**
  59926. * Draw a list of unindexed primitives
  59927. * @param fillMode defines the primitive to use
  59928. * @param verticesStart defines the index of first vertex to draw
  59929. * @param verticesCount defines the count of vertices to draw
  59930. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59931. */
  59932. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  59933. /** @hidden */
  59934. protected _createTexture(): WebGLTexture;
  59935. /** @hidden */
  59936. _releaseTexture(texture: InternalTexture): void;
  59937. /**
  59938. * Usually called from Texture.ts.
  59939. * Passed information to create a WebGLTexture
  59940. * @param urlArg defines a value which contains one of the following:
  59941. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  59942. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  59943. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  59944. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  59945. * @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)
  59946. * @param scene needed for loading to the correct scene
  59947. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  59948. * @param onLoad optional callback to be called upon successful completion
  59949. * @param onError optional callback to be called upon failure
  59950. * @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
  59951. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  59952. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  59953. * @param forcedExtension defines the extension to use to pick the right loader
  59954. * @param mimeType defines an optional mime type
  59955. * @returns a InternalTexture for assignment back into BABYLON.Texture
  59956. */
  59957. 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;
  59958. /**
  59959. * Creates a new render target texture
  59960. * @param size defines the size of the texture
  59961. * @param options defines the options used to create the texture
  59962. * @returns a new render target texture stored in an InternalTexture
  59963. */
  59964. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  59965. /**
  59966. * Update the sampling mode of a given texture
  59967. * @param samplingMode defines the required sampling mode
  59968. * @param texture defines the texture to update
  59969. */
  59970. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  59971. /**
  59972. * Binds the frame buffer to the specified texture.
  59973. * @param texture The texture to render to or null for the default canvas
  59974. * @param faceIndex The face of the texture to render to in case of cube texture
  59975. * @param requiredWidth The width of the target to render to
  59976. * @param requiredHeight The height of the target to render to
  59977. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  59978. * @param lodLevel defines le lod level to bind to the frame buffer
  59979. */
  59980. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  59981. /**
  59982. * Unbind the current render target texture from the webGL context
  59983. * @param texture defines the render target texture to unbind
  59984. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  59985. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  59986. */
  59987. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  59988. /**
  59989. * Creates a dynamic vertex buffer
  59990. * @param vertices the data for the dynamic vertex buffer
  59991. * @returns the new WebGL dynamic buffer
  59992. */
  59993. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  59994. /**
  59995. * Update the content of a dynamic texture
  59996. * @param texture defines the texture to update
  59997. * @param canvas defines the canvas containing the source
  59998. * @param invertY defines if data must be stored with Y axis inverted
  59999. * @param premulAlpha defines if alpha is stored as premultiplied
  60000. * @param format defines the format of the data
  60001. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  60002. */
  60003. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  60004. /**
  60005. * Gets a boolean indicating if all created effects are ready
  60006. * @returns true if all effects are ready
  60007. */
  60008. areAllEffectsReady(): boolean;
  60009. /**
  60010. * @hidden
  60011. * Get the current error code of the webGL context
  60012. * @returns the error code
  60013. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  60014. */
  60015. getError(): number;
  60016. /** @hidden */
  60017. _getUnpackAlignement(): number;
  60018. /** @hidden */
  60019. _unpackFlipY(value: boolean): void;
  60020. /**
  60021. * Update a dynamic index buffer
  60022. * @param indexBuffer defines the target index buffer
  60023. * @param indices defines the data to update
  60024. * @param offset defines the offset in the target index buffer where update should start
  60025. */
  60026. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  60027. /**
  60028. * Updates a dynamic vertex buffer.
  60029. * @param vertexBuffer the vertex buffer to update
  60030. * @param vertices the data used to update the vertex buffer
  60031. * @param byteOffset the byte offset of the data (optional)
  60032. * @param byteLength the byte length of the data (optional)
  60033. */
  60034. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  60035. /** @hidden */
  60036. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  60037. /** @hidden */
  60038. _bindTexture(channel: number, texture: InternalTexture): void;
  60039. protected _deleteBuffer(buffer: WebGLBuffer): void;
  60040. /**
  60041. * 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
  60042. */
  60043. releaseEffects(): void;
  60044. displayLoadingUI(): void;
  60045. hideLoadingUI(): void;
  60046. /** @hidden */
  60047. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60048. /** @hidden */
  60049. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60050. /** @hidden */
  60051. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60052. /** @hidden */
  60053. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  60054. }
  60055. }
  60056. declare module BABYLON {
  60057. /** @hidden */
  60058. export class _OcclusionDataStorage {
  60059. /** @hidden */
  60060. occlusionInternalRetryCounter: number;
  60061. /** @hidden */
  60062. isOcclusionQueryInProgress: boolean;
  60063. /** @hidden */
  60064. isOccluded: boolean;
  60065. /** @hidden */
  60066. occlusionRetryCount: number;
  60067. /** @hidden */
  60068. occlusionType: number;
  60069. /** @hidden */
  60070. occlusionQueryAlgorithmType: number;
  60071. }
  60072. interface Engine {
  60073. /**
  60074. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  60075. * @return the new query
  60076. */
  60077. createQuery(): WebGLQuery;
  60078. /**
  60079. * Delete and release a webGL query
  60080. * @param query defines the query to delete
  60081. * @return the current engine
  60082. */
  60083. deleteQuery(query: WebGLQuery): Engine;
  60084. /**
  60085. * Check if a given query has resolved and got its value
  60086. * @param query defines the query to check
  60087. * @returns true if the query got its value
  60088. */
  60089. isQueryResultAvailable(query: WebGLQuery): boolean;
  60090. /**
  60091. * Gets the value of a given query
  60092. * @param query defines the query to check
  60093. * @returns the value of the query
  60094. */
  60095. getQueryResult(query: WebGLQuery): number;
  60096. /**
  60097. * Initiates an occlusion query
  60098. * @param algorithmType defines the algorithm to use
  60099. * @param query defines the query to use
  60100. * @returns the current engine
  60101. * @see https://doc.babylonjs.com/features/occlusionquery
  60102. */
  60103. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  60104. /**
  60105. * Ends an occlusion query
  60106. * @see https://doc.babylonjs.com/features/occlusionquery
  60107. * @param algorithmType defines the algorithm to use
  60108. * @returns the current engine
  60109. */
  60110. endOcclusionQuery(algorithmType: number): Engine;
  60111. /**
  60112. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  60113. * Please note that only one query can be issued at a time
  60114. * @returns a time token used to track the time span
  60115. */
  60116. startTimeQuery(): Nullable<_TimeToken>;
  60117. /**
  60118. * Ends a time query
  60119. * @param token defines the token used to measure the time span
  60120. * @returns the time spent (in ns)
  60121. */
  60122. endTimeQuery(token: _TimeToken): int;
  60123. /** @hidden */
  60124. _currentNonTimestampToken: Nullable<_TimeToken>;
  60125. /** @hidden */
  60126. _createTimeQuery(): WebGLQuery;
  60127. /** @hidden */
  60128. _deleteTimeQuery(query: WebGLQuery): void;
  60129. /** @hidden */
  60130. _getGlAlgorithmType(algorithmType: number): number;
  60131. /** @hidden */
  60132. _getTimeQueryResult(query: WebGLQuery): any;
  60133. /** @hidden */
  60134. _getTimeQueryAvailability(query: WebGLQuery): any;
  60135. }
  60136. interface AbstractMesh {
  60137. /**
  60138. * Backing filed
  60139. * @hidden
  60140. */
  60141. __occlusionDataStorage: _OcclusionDataStorage;
  60142. /**
  60143. * Access property
  60144. * @hidden
  60145. */
  60146. _occlusionDataStorage: _OcclusionDataStorage;
  60147. /**
  60148. * 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.
  60149. * The default value is -1 which means don't break the query and wait till the result
  60150. * @see https://doc.babylonjs.com/features/occlusionquery
  60151. */
  60152. occlusionRetryCount: number;
  60153. /**
  60154. * 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:
  60155. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query within the Mesh.
  60156. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  60157. * * 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.
  60158. * @see https://doc.babylonjs.com/features/occlusionquery
  60159. */
  60160. occlusionType: number;
  60161. /**
  60162. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  60163. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  60164. * * 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.
  60165. * @see https://doc.babylonjs.com/features/occlusionquery
  60166. */
  60167. occlusionQueryAlgorithmType: number;
  60168. /**
  60169. * 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
  60170. * @see https://doc.babylonjs.com/features/occlusionquery
  60171. */
  60172. isOccluded: boolean;
  60173. /**
  60174. * Flag to check the progress status of the query
  60175. * @see https://doc.babylonjs.com/features/occlusionquery
  60176. */
  60177. isOcclusionQueryInProgress: boolean;
  60178. }
  60179. }
  60180. declare module BABYLON {
  60181. /** @hidden */
  60182. export var _forceTransformFeedbackToBundle: boolean;
  60183. interface Engine {
  60184. /**
  60185. * Creates a webGL transform feedback object
  60186. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  60187. * @returns the webGL transform feedback object
  60188. */
  60189. createTransformFeedback(): WebGLTransformFeedback;
  60190. /**
  60191. * Delete a webGL transform feedback object
  60192. * @param value defines the webGL transform feedback object to delete
  60193. */
  60194. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  60195. /**
  60196. * Bind a webGL transform feedback object to the webgl context
  60197. * @param value defines the webGL transform feedback object to bind
  60198. */
  60199. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  60200. /**
  60201. * Begins a transform feedback operation
  60202. * @param usePoints defines if points or triangles must be used
  60203. */
  60204. beginTransformFeedback(usePoints: boolean): void;
  60205. /**
  60206. * Ends a transform feedback operation
  60207. */
  60208. endTransformFeedback(): void;
  60209. /**
  60210. * Specify the varyings to use with transform feedback
  60211. * @param program defines the associated webGL program
  60212. * @param value defines the list of strings representing the varying names
  60213. */
  60214. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  60215. /**
  60216. * Bind a webGL buffer for a transform feedback operation
  60217. * @param value defines the webGL buffer to bind
  60218. */
  60219. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  60220. }
  60221. }
  60222. declare module BABYLON {
  60223. /**
  60224. * Class used to define an additional view for the engine
  60225. * @see https://doc.babylonjs.com/how_to/multi_canvases
  60226. */
  60227. export class EngineView {
  60228. /** Defines the canvas where to render the view */
  60229. target: HTMLCanvasElement;
  60230. /** Defines an optional camera used to render the view (will use active camera else) */
  60231. camera?: Camera;
  60232. }
  60233. interface Engine {
  60234. /**
  60235. * Gets or sets the HTML element to use for attaching events
  60236. */
  60237. inputElement: Nullable<HTMLElement>;
  60238. /**
  60239. * Gets the current engine view
  60240. * @see https://doc.babylonjs.com/how_to/multi_canvases
  60241. */
  60242. activeView: Nullable<EngineView>;
  60243. /** Gets or sets the list of views */
  60244. views: EngineView[];
  60245. /**
  60246. * Register a new child canvas
  60247. * @param canvas defines the canvas to register
  60248. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  60249. * @returns the associated view
  60250. */
  60251. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  60252. /**
  60253. * Remove a registered child canvas
  60254. * @param canvas defines the canvas to remove
  60255. * @returns the current engine
  60256. */
  60257. unRegisterView(canvas: HTMLCanvasElement): Engine;
  60258. }
  60259. }
  60260. declare module BABYLON {
  60261. interface Engine {
  60262. /** @hidden */
  60263. _excludedCompressedTextures: string[];
  60264. /** @hidden */
  60265. _textureFormatInUse: string;
  60266. /**
  60267. * Gets the list of texture formats supported
  60268. */
  60269. readonly texturesSupported: Array<string>;
  60270. /**
  60271. * Gets the texture format in use
  60272. */
  60273. readonly textureFormatInUse: Nullable<string>;
  60274. /**
  60275. * Set the compressed texture extensions or file names to skip.
  60276. *
  60277. * @param skippedFiles defines the list of those texture files you want to skip
  60278. * Example: [".dds", ".env", "myfile.png"]
  60279. */
  60280. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  60281. /**
  60282. * Set the compressed texture format to use, based on the formats you have, and the formats
  60283. * supported by the hardware / browser.
  60284. *
  60285. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  60286. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  60287. * to API arguments needed to compressed textures. This puts the burden on the container
  60288. * generator to house the arcane code for determining these for current & future formats.
  60289. *
  60290. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60291. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60292. *
  60293. * Note: The result of this call is not taken into account when a texture is base64.
  60294. *
  60295. * @param formatsAvailable defines the list of those format families you have created
  60296. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  60297. *
  60298. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  60299. * @returns The extension selected.
  60300. */
  60301. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  60302. }
  60303. }
  60304. declare module BABYLON {
  60305. /** @hidden */
  60306. export var rgbdEncodePixelShader: {
  60307. name: string;
  60308. shader: string;
  60309. };
  60310. }
  60311. declare module BABYLON {
  60312. /**
  60313. * Raw texture data and descriptor sufficient for WebGL texture upload
  60314. */
  60315. export interface EnvironmentTextureInfo {
  60316. /**
  60317. * Version of the environment map
  60318. */
  60319. version: number;
  60320. /**
  60321. * Width of image
  60322. */
  60323. width: number;
  60324. /**
  60325. * Irradiance information stored in the file.
  60326. */
  60327. irradiance: any;
  60328. /**
  60329. * Specular information stored in the file.
  60330. */
  60331. specular: any;
  60332. }
  60333. /**
  60334. * Defines One Image in the file. It requires only the position in the file
  60335. * as well as the length.
  60336. */
  60337. interface BufferImageData {
  60338. /**
  60339. * Length of the image data.
  60340. */
  60341. length: number;
  60342. /**
  60343. * Position of the data from the null terminator delimiting the end of the JSON.
  60344. */
  60345. position: number;
  60346. }
  60347. /**
  60348. * Defines the specular data enclosed in the file.
  60349. * This corresponds to the version 1 of the data.
  60350. */
  60351. export interface EnvironmentTextureSpecularInfoV1 {
  60352. /**
  60353. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  60354. */
  60355. specularDataPosition?: number;
  60356. /**
  60357. * This contains all the images data needed to reconstruct the cubemap.
  60358. */
  60359. mipmaps: Array<BufferImageData>;
  60360. /**
  60361. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  60362. */
  60363. lodGenerationScale: number;
  60364. }
  60365. /**
  60366. * Sets of helpers addressing the serialization and deserialization of environment texture
  60367. * stored in a BabylonJS env file.
  60368. * Those files are usually stored as .env files.
  60369. */
  60370. export class EnvironmentTextureTools {
  60371. /**
  60372. * Magic number identifying the env file.
  60373. */
  60374. private static _MagicBytes;
  60375. /**
  60376. * Gets the environment info from an env file.
  60377. * @param data The array buffer containing the .env bytes.
  60378. * @returns the environment file info (the json header) if successfully parsed.
  60379. */
  60380. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  60381. /**
  60382. * Creates an environment texture from a loaded cube texture.
  60383. * @param texture defines the cube texture to convert in env file
  60384. * @return a promise containing the environment data if successful.
  60385. */
  60386. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  60387. /**
  60388. * Creates a JSON representation of the spherical data.
  60389. * @param texture defines the texture containing the polynomials
  60390. * @return the JSON representation of the spherical info
  60391. */
  60392. private static _CreateEnvTextureIrradiance;
  60393. /**
  60394. * Creates the ArrayBufferViews used for initializing environment texture image data.
  60395. * @param data the image data
  60396. * @param info parameters that determine what views will be created for accessing the underlying buffer
  60397. * @return the views described by info providing access to the underlying buffer
  60398. */
  60399. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  60400. /**
  60401. * Uploads the texture info contained in the env file to the GPU.
  60402. * @param texture defines the internal texture to upload to
  60403. * @param data defines the data to load
  60404. * @param info defines the texture info retrieved through the GetEnvInfo method
  60405. * @returns a promise
  60406. */
  60407. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  60408. private static _OnImageReadyAsync;
  60409. /**
  60410. * Uploads the levels of image data to the GPU.
  60411. * @param texture defines the internal texture to upload to
  60412. * @param imageData defines the array buffer views of image data [mipmap][face]
  60413. * @returns a promise
  60414. */
  60415. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  60416. /**
  60417. * Uploads spherical polynomials information to the texture.
  60418. * @param texture defines the texture we are trying to upload the information to
  60419. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  60420. */
  60421. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  60422. /** @hidden */
  60423. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  60424. }
  60425. }
  60426. declare module BABYLON {
  60427. /**
  60428. * Container for accessors for natively-stored mesh data buffers.
  60429. */
  60430. class NativeDataBuffer extends DataBuffer {
  60431. /**
  60432. * Accessor value used to identify/retrieve a natively-stored index buffer.
  60433. */
  60434. nativeIndexBuffer?: any;
  60435. /**
  60436. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  60437. */
  60438. nativeVertexBuffer?: any;
  60439. }
  60440. /** @hidden */
  60441. class NativeTexture extends InternalTexture {
  60442. getInternalTexture(): InternalTexture;
  60443. getViewCount(): number;
  60444. }
  60445. /** @hidden */
  60446. export class NativeEngine extends Engine {
  60447. private readonly _native;
  60448. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  60449. private readonly INVALID_HANDLE;
  60450. private _boundBuffersVertexArray;
  60451. private _currentDepthTest;
  60452. getHardwareScalingLevel(): number;
  60453. constructor();
  60454. dispose(): void;
  60455. /**
  60456. * Can be used to override the current requestAnimationFrame requester.
  60457. * @hidden
  60458. */
  60459. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  60460. /**
  60461. * Override default engine behavior.
  60462. * @param color
  60463. * @param backBuffer
  60464. * @param depth
  60465. * @param stencil
  60466. */
  60467. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  60468. /**
  60469. * Gets host document
  60470. * @returns the host document object
  60471. */
  60472. getHostDocument(): Nullable<Document>;
  60473. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  60474. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  60475. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  60476. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  60477. [key: string]: VertexBuffer;
  60478. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  60479. bindBuffers(vertexBuffers: {
  60480. [key: string]: VertexBuffer;
  60481. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  60482. recordVertexArrayObject(vertexBuffers: {
  60483. [key: string]: VertexBuffer;
  60484. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  60485. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  60486. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  60487. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  60488. /**
  60489. * Draw a list of indexed primitives
  60490. * @param fillMode defines the primitive to use
  60491. * @param indexStart defines the starting index
  60492. * @param indexCount defines the number of index to draw
  60493. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  60494. */
  60495. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  60496. /**
  60497. * Draw a list of unindexed primitives
  60498. * @param fillMode defines the primitive to use
  60499. * @param verticesStart defines the index of first vertex to draw
  60500. * @param verticesCount defines the count of vertices to draw
  60501. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  60502. */
  60503. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  60504. createPipelineContext(): IPipelineContext;
  60505. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  60506. /** @hidden */
  60507. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  60508. /** @hidden */
  60509. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  60510. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  60511. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  60512. protected _setProgram(program: WebGLProgram): void;
  60513. _releaseEffect(effect: Effect): void;
  60514. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  60515. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  60516. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  60517. bindSamplers(effect: Effect): void;
  60518. setMatrix(uniform: WebGLUniformLocation, matrix: IMatrixLike): void;
  60519. getRenderWidth(useScreen?: boolean): number;
  60520. getRenderHeight(useScreen?: boolean): number;
  60521. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  60522. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  60523. /**
  60524. * Set the z offset to apply to current rendering
  60525. * @param value defines the offset to apply
  60526. */
  60527. setZOffset(value: number): void;
  60528. /**
  60529. * Gets the current value of the zOffset
  60530. * @returns the current zOffset state
  60531. */
  60532. getZOffset(): number;
  60533. /**
  60534. * Enable or disable depth buffering
  60535. * @param enable defines the state to set
  60536. */
  60537. setDepthBuffer(enable: boolean): void;
  60538. /**
  60539. * Gets a boolean indicating if depth writing is enabled
  60540. * @returns the current depth writing state
  60541. */
  60542. getDepthWrite(): boolean;
  60543. setDepthFunctionToGreater(): void;
  60544. setDepthFunctionToGreaterOrEqual(): void;
  60545. setDepthFunctionToLess(): void;
  60546. setDepthFunctionToLessOrEqual(): void;
  60547. /**
  60548. * Enable or disable depth writing
  60549. * @param enable defines the state to set
  60550. */
  60551. setDepthWrite(enable: boolean): void;
  60552. /**
  60553. * Enable or disable color writing
  60554. * @param enable defines the state to set
  60555. */
  60556. setColorWrite(enable: boolean): void;
  60557. /**
  60558. * Gets a boolean indicating if color writing is enabled
  60559. * @returns the current color writing state
  60560. */
  60561. getColorWrite(): boolean;
  60562. /**
  60563. * Sets alpha constants used by some alpha blending modes
  60564. * @param r defines the red component
  60565. * @param g defines the green component
  60566. * @param b defines the blue component
  60567. * @param a defines the alpha component
  60568. */
  60569. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  60570. /**
  60571. * Sets the current alpha mode
  60572. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  60573. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  60574. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  60575. */
  60576. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  60577. /**
  60578. * Gets the current alpha mode
  60579. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  60580. * @returns the current alpha mode
  60581. */
  60582. getAlphaMode(): number;
  60583. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  60584. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60585. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60586. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60587. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60588. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60589. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60590. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60591. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60592. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  60593. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  60594. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  60595. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  60596. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  60597. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  60598. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  60599. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  60600. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  60601. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  60602. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  60603. setColor3(uniform: WebGLUniformLocation, color3: IColor3Like): boolean;
  60604. setColor4(uniform: WebGLUniformLocation, color3: IColor3Like, alpha: number): boolean;
  60605. wipeCaches(bruteForce?: boolean): void;
  60606. protected _createTexture(): WebGLTexture;
  60607. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  60608. /**
  60609. * Update the content of a dynamic texture
  60610. * @param texture defines the texture to update
  60611. * @param canvas defines the canvas containing the source
  60612. * @param invertY defines if data must be stored with Y axis inverted
  60613. * @param premulAlpha defines if alpha is stored as premultiplied
  60614. * @param format defines the format of the data
  60615. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  60616. */
  60617. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  60618. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  60619. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  60620. /**
  60621. * Usually called from Texture.ts.
  60622. * Passed information to create a WebGLTexture
  60623. * @param url defines a value which contains one of the following:
  60624. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  60625. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  60626. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  60627. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  60628. * @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)
  60629. * @param scene needed for loading to the correct scene
  60630. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  60631. * @param onLoad optional callback to be called upon successful completion
  60632. * @param onError optional callback to be called upon failure
  60633. * @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
  60634. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  60635. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  60636. * @param forcedExtension defines the extension to use to pick the right loader
  60637. * @param mimeType defines an optional mime type
  60638. * @param loaderOptions options to be passed to the loader
  60639. * @returns a InternalTexture for assignment back into BABYLON.Texture
  60640. */
  60641. 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;
  60642. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  60643. _releaseFramebufferObjects(texture: InternalTexture): void;
  60644. /**
  60645. * Creates a cube texture
  60646. * @param rootUrl defines the url where the files to load is located
  60647. * @param scene defines the current scene
  60648. * @param files defines the list of files to load (1 per face)
  60649. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  60650. * @param onLoad defines an optional callback raised when the texture is loaded
  60651. * @param onError defines an optional callback raised if there is an issue to load the texture
  60652. * @param format defines the format of the data
  60653. * @param forcedExtension defines the extension to use to pick the right loader
  60654. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  60655. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60656. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60657. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  60658. * @returns the cube texture as an InternalTexture
  60659. */
  60660. 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;
  60661. createRenderTargetTexture(size: number | {
  60662. width: number;
  60663. height: number;
  60664. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  60665. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  60666. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  60667. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  60668. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  60669. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  60670. /**
  60671. * Updates a dynamic vertex buffer.
  60672. * @param vertexBuffer the vertex buffer to update
  60673. * @param data the data used to update the vertex buffer
  60674. * @param byteOffset the byte offset of the data (optional)
  60675. * @param byteLength the byte length of the data (optional)
  60676. */
  60677. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  60678. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  60679. private _updateAnisotropicLevel;
  60680. private _getAddressMode;
  60681. /** @hidden */
  60682. _bindTexture(channel: number, texture: InternalTexture): void;
  60683. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  60684. releaseEffects(): void;
  60685. /** @hidden */
  60686. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60687. /** @hidden */
  60688. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60689. /** @hidden */
  60690. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60691. /** @hidden */
  60692. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  60693. private _getNativeSamplingMode;
  60694. private _getNativeTextureFormat;
  60695. private _getNativeAlphaMode;
  60696. private _getNativeAttribType;
  60697. }
  60698. }
  60699. declare module BABYLON {
  60700. /**
  60701. * Helper class to create the best engine depending on the current hardware
  60702. */
  60703. export class EngineFactory {
  60704. /**
  60705. * Creates an engine based on the capabilities of the underlying hardware
  60706. * @param canvas Defines the canvas to use to display the result
  60707. * @param options Defines the options passed to the engine to create the context dependencies
  60708. * @returns a promise that resolves with the created engine
  60709. */
  60710. static CreateAsync(canvas: HTMLCanvasElement, options: any): Promise<ThinEngine>;
  60711. }
  60712. }
  60713. declare module BABYLON {
  60714. /**
  60715. * Gather the list of clipboard event types as constants.
  60716. */
  60717. export class ClipboardEventTypes {
  60718. /**
  60719. * The clipboard event is fired when a copy command is active (pressed).
  60720. */
  60721. static readonly COPY: number;
  60722. /**
  60723. * The clipboard event is fired when a cut command is active (pressed).
  60724. */
  60725. static readonly CUT: number;
  60726. /**
  60727. * The clipboard event is fired when a paste command is active (pressed).
  60728. */
  60729. static readonly PASTE: number;
  60730. }
  60731. /**
  60732. * This class is used to store clipboard related info for the onClipboardObservable event.
  60733. */
  60734. export class ClipboardInfo {
  60735. /**
  60736. * Defines the type of event (BABYLON.ClipboardEventTypes)
  60737. */
  60738. type: number;
  60739. /**
  60740. * Defines the related dom event
  60741. */
  60742. event: ClipboardEvent;
  60743. /**
  60744. *Creates an instance of ClipboardInfo.
  60745. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  60746. * @param event Defines the related dom event
  60747. */
  60748. constructor(
  60749. /**
  60750. * Defines the type of event (BABYLON.ClipboardEventTypes)
  60751. */
  60752. type: number,
  60753. /**
  60754. * Defines the related dom event
  60755. */
  60756. event: ClipboardEvent);
  60757. /**
  60758. * Get the clipboard event's type from the keycode.
  60759. * @param keyCode Defines the keyCode for the current keyboard event.
  60760. * @return {number}
  60761. */
  60762. static GetTypeFromCharacter(keyCode: number): number;
  60763. }
  60764. }
  60765. declare module BABYLON {
  60766. /**
  60767. * Google Daydream controller
  60768. */
  60769. export class DaydreamController extends WebVRController {
  60770. /**
  60771. * Base Url for the controller model.
  60772. */
  60773. static MODEL_BASE_URL: string;
  60774. /**
  60775. * File name for the controller model.
  60776. */
  60777. static MODEL_FILENAME: string;
  60778. /**
  60779. * Gamepad Id prefix used to identify Daydream Controller.
  60780. */
  60781. static readonly GAMEPAD_ID_PREFIX: string;
  60782. /**
  60783. * Creates a new DaydreamController from a gamepad
  60784. * @param vrGamepad the gamepad that the controller should be created from
  60785. */
  60786. constructor(vrGamepad: any);
  60787. /**
  60788. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60789. * @param scene scene in which to add meshes
  60790. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60791. */
  60792. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60793. /**
  60794. * Called once for each button that changed state since the last frame
  60795. * @param buttonIdx Which button index changed
  60796. * @param state New state of the button
  60797. * @param changes Which properties on the state changed since last frame
  60798. */
  60799. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60800. }
  60801. }
  60802. declare module BABYLON {
  60803. /**
  60804. * Gear VR Controller
  60805. */
  60806. export class GearVRController extends WebVRController {
  60807. /**
  60808. * Base Url for the controller model.
  60809. */
  60810. static MODEL_BASE_URL: string;
  60811. /**
  60812. * File name for the controller model.
  60813. */
  60814. static MODEL_FILENAME: string;
  60815. /**
  60816. * Gamepad Id prefix used to identify this controller.
  60817. */
  60818. static readonly GAMEPAD_ID_PREFIX: string;
  60819. private readonly _buttonIndexToObservableNameMap;
  60820. /**
  60821. * Creates a new GearVRController from a gamepad
  60822. * @param vrGamepad the gamepad that the controller should be created from
  60823. */
  60824. constructor(vrGamepad: any);
  60825. /**
  60826. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60827. * @param scene scene in which to add meshes
  60828. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60829. */
  60830. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60831. /**
  60832. * Called once for each button that changed state since the last frame
  60833. * @param buttonIdx Which button index changed
  60834. * @param state New state of the button
  60835. * @param changes Which properties on the state changed since last frame
  60836. */
  60837. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60838. }
  60839. }
  60840. declare module BABYLON {
  60841. /**
  60842. * Generic Controller
  60843. */
  60844. export class GenericController extends WebVRController {
  60845. /**
  60846. * Base Url for the controller model.
  60847. */
  60848. static readonly MODEL_BASE_URL: string;
  60849. /**
  60850. * File name for the controller model.
  60851. */
  60852. static readonly MODEL_FILENAME: string;
  60853. /**
  60854. * Creates a new GenericController from a gamepad
  60855. * @param vrGamepad the gamepad that the controller should be created from
  60856. */
  60857. constructor(vrGamepad: any);
  60858. /**
  60859. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60860. * @param scene scene in which to add meshes
  60861. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60862. */
  60863. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60864. /**
  60865. * Called once for each button that changed state since the last frame
  60866. * @param buttonIdx Which button index changed
  60867. * @param state New state of the button
  60868. * @param changes Which properties on the state changed since last frame
  60869. */
  60870. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60871. }
  60872. }
  60873. declare module BABYLON {
  60874. /**
  60875. * Oculus Touch Controller
  60876. */
  60877. export class OculusTouchController extends WebVRController {
  60878. /**
  60879. * Base Url for the controller model.
  60880. */
  60881. static MODEL_BASE_URL: string;
  60882. /**
  60883. * File name for the left controller model.
  60884. */
  60885. static MODEL_LEFT_FILENAME: string;
  60886. /**
  60887. * File name for the right controller model.
  60888. */
  60889. static MODEL_RIGHT_FILENAME: string;
  60890. /**
  60891. * Base Url for the Quest controller model.
  60892. */
  60893. static QUEST_MODEL_BASE_URL: string;
  60894. /**
  60895. * @hidden
  60896. * If the controllers are running on a device that needs the updated Quest controller models
  60897. */
  60898. static _IsQuest: boolean;
  60899. /**
  60900. * Fired when the secondary trigger on this controller is modified
  60901. */
  60902. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  60903. /**
  60904. * Fired when the thumb rest on this controller is modified
  60905. */
  60906. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  60907. /**
  60908. * Creates a new OculusTouchController from a gamepad
  60909. * @param vrGamepad the gamepad that the controller should be created from
  60910. */
  60911. constructor(vrGamepad: any);
  60912. /**
  60913. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60914. * @param scene scene in which to add meshes
  60915. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60916. */
  60917. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60918. /**
  60919. * Fired when the A button on this controller is modified
  60920. */
  60921. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60922. /**
  60923. * Fired when the B button on this controller is modified
  60924. */
  60925. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60926. /**
  60927. * Fired when the X button on this controller is modified
  60928. */
  60929. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60930. /**
  60931. * Fired when the Y button on this controller is modified
  60932. */
  60933. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60934. /**
  60935. * Called once for each button that changed state since the last frame
  60936. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  60937. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  60938. * 2) secondary trigger (same)
  60939. * 3) A (right) X (left), touch, pressed = value
  60940. * 4) B / Y
  60941. * 5) thumb rest
  60942. * @param buttonIdx Which button index changed
  60943. * @param state New state of the button
  60944. * @param changes Which properties on the state changed since last frame
  60945. */
  60946. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60947. }
  60948. }
  60949. declare module BABYLON {
  60950. /**
  60951. * Vive Controller
  60952. */
  60953. export class ViveController extends WebVRController {
  60954. /**
  60955. * Base Url for the controller model.
  60956. */
  60957. static MODEL_BASE_URL: string;
  60958. /**
  60959. * File name for the controller model.
  60960. */
  60961. static MODEL_FILENAME: string;
  60962. /**
  60963. * Creates a new ViveController from a gamepad
  60964. * @param vrGamepad the gamepad that the controller should be created from
  60965. */
  60966. constructor(vrGamepad: any);
  60967. /**
  60968. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60969. * @param scene scene in which to add meshes
  60970. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60971. */
  60972. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60973. /**
  60974. * Fired when the left button on this controller is modified
  60975. */
  60976. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60977. /**
  60978. * Fired when the right button on this controller is modified
  60979. */
  60980. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60981. /**
  60982. * Fired when the menu button on this controller is modified
  60983. */
  60984. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60985. /**
  60986. * Called once for each button that changed state since the last frame
  60987. * Vive mapping:
  60988. * 0: touchpad
  60989. * 1: trigger
  60990. * 2: left AND right buttons
  60991. * 3: menu button
  60992. * @param buttonIdx Which button index changed
  60993. * @param state New state of the button
  60994. * @param changes Which properties on the state changed since last frame
  60995. */
  60996. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60997. }
  60998. }
  60999. declare module BABYLON {
  61000. /**
  61001. * Defines the WindowsMotionController object that the state of the windows motion controller
  61002. */
  61003. export class WindowsMotionController extends WebVRController {
  61004. /**
  61005. * The base url used to load the left and right controller models
  61006. */
  61007. static MODEL_BASE_URL: string;
  61008. /**
  61009. * The name of the left controller model file
  61010. */
  61011. static MODEL_LEFT_FILENAME: string;
  61012. /**
  61013. * The name of the right controller model file
  61014. */
  61015. static MODEL_RIGHT_FILENAME: string;
  61016. /**
  61017. * The controller name prefix for this controller type
  61018. */
  61019. static readonly GAMEPAD_ID_PREFIX: string;
  61020. /**
  61021. * The controller id pattern for this controller type
  61022. */
  61023. private static readonly GAMEPAD_ID_PATTERN;
  61024. private _loadedMeshInfo;
  61025. protected readonly _mapping: {
  61026. buttons: string[];
  61027. buttonMeshNames: {
  61028. trigger: string;
  61029. menu: string;
  61030. grip: string;
  61031. thumbstick: string;
  61032. trackpad: string;
  61033. };
  61034. buttonObservableNames: {
  61035. trigger: string;
  61036. menu: string;
  61037. grip: string;
  61038. thumbstick: string;
  61039. trackpad: string;
  61040. };
  61041. axisMeshNames: string[];
  61042. pointingPoseMeshName: string;
  61043. };
  61044. /**
  61045. * Fired when the trackpad on this controller is clicked
  61046. */
  61047. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  61048. /**
  61049. * Fired when the trackpad on this controller is modified
  61050. */
  61051. onTrackpadValuesChangedObservable: Observable<StickValues>;
  61052. /**
  61053. * The current x and y values of this controller's trackpad
  61054. */
  61055. trackpad: StickValues;
  61056. /**
  61057. * Creates a new WindowsMotionController from a gamepad
  61058. * @param vrGamepad the gamepad that the controller should be created from
  61059. */
  61060. constructor(vrGamepad: any);
  61061. /**
  61062. * Fired when the trigger on this controller is modified
  61063. */
  61064. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61065. /**
  61066. * Fired when the menu button on this controller is modified
  61067. */
  61068. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61069. /**
  61070. * Fired when the grip button on this controller is modified
  61071. */
  61072. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61073. /**
  61074. * Fired when the thumbstick button on this controller is modified
  61075. */
  61076. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61077. /**
  61078. * Fired when the touchpad button on this controller is modified
  61079. */
  61080. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61081. /**
  61082. * Fired when the touchpad values on this controller are modified
  61083. */
  61084. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  61085. protected _updateTrackpad(): void;
  61086. /**
  61087. * Called once per frame by the engine.
  61088. */
  61089. update(): void;
  61090. /**
  61091. * Called once for each button that changed state since the last frame
  61092. * @param buttonIdx Which button index changed
  61093. * @param state New state of the button
  61094. * @param changes Which properties on the state changed since last frame
  61095. */
  61096. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  61097. /**
  61098. * Moves the buttons on the controller mesh based on their current state
  61099. * @param buttonName the name of the button to move
  61100. * @param buttonValue the value of the button which determines the buttons new position
  61101. */
  61102. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  61103. /**
  61104. * Moves the axis on the controller mesh based on its current state
  61105. * @param axis the index of the axis
  61106. * @param axisValue the value of the axis which determines the meshes new position
  61107. * @hidden
  61108. */
  61109. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  61110. /**
  61111. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  61112. * @param scene scene in which to add meshes
  61113. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  61114. */
  61115. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  61116. /**
  61117. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  61118. * can be transformed by button presses and axes values, based on this._mapping.
  61119. *
  61120. * @param scene scene in which the meshes exist
  61121. * @param meshes list of meshes that make up the controller model to process
  61122. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  61123. */
  61124. private processModel;
  61125. private createMeshInfo;
  61126. /**
  61127. * Gets the ray of the controller in the direction the controller is pointing
  61128. * @param length the length the resulting ray should be
  61129. * @returns a ray in the direction the controller is pointing
  61130. */
  61131. getForwardRay(length?: number): Ray;
  61132. /**
  61133. * Disposes of the controller
  61134. */
  61135. dispose(): void;
  61136. }
  61137. /**
  61138. * This class represents a new windows motion controller in XR.
  61139. */
  61140. export class XRWindowsMotionController extends WindowsMotionController {
  61141. /**
  61142. * Changing the original WIndowsMotionController mapping to fir the new mapping
  61143. */
  61144. protected readonly _mapping: {
  61145. buttons: string[];
  61146. buttonMeshNames: {
  61147. trigger: string;
  61148. menu: string;
  61149. grip: string;
  61150. thumbstick: string;
  61151. trackpad: string;
  61152. };
  61153. buttonObservableNames: {
  61154. trigger: string;
  61155. menu: string;
  61156. grip: string;
  61157. thumbstick: string;
  61158. trackpad: string;
  61159. };
  61160. axisMeshNames: string[];
  61161. pointingPoseMeshName: string;
  61162. };
  61163. /**
  61164. * Construct a new XR-Based windows motion controller
  61165. *
  61166. * @param gamepadInfo the gamepad object from the browser
  61167. */
  61168. constructor(gamepadInfo: any);
  61169. /**
  61170. * holds the thumbstick values (X,Y)
  61171. */
  61172. thumbstickValues: StickValues;
  61173. /**
  61174. * Fired when the thumbstick on this controller is clicked
  61175. */
  61176. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  61177. /**
  61178. * Fired when the thumbstick on this controller is modified
  61179. */
  61180. onThumbstickValuesChangedObservable: Observable<StickValues>;
  61181. /**
  61182. * Fired when the touchpad button on this controller is modified
  61183. */
  61184. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  61185. /**
  61186. * Fired when the touchpad values on this controller are modified
  61187. */
  61188. onTrackpadValuesChangedObservable: Observable<StickValues>;
  61189. /**
  61190. * Fired when the thumbstick button on this controller is modified
  61191. * here to prevent breaking changes
  61192. */
  61193. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61194. /**
  61195. * updating the thumbstick(!) and not the trackpad.
  61196. * This is named this way due to the difference between WebVR and XR and to avoid
  61197. * changing the parent class.
  61198. */
  61199. protected _updateTrackpad(): void;
  61200. /**
  61201. * Disposes the class with joy
  61202. */
  61203. dispose(): void;
  61204. }
  61205. }
  61206. declare module BABYLON {
  61207. /**
  61208. * A directional light is defined by a direction (what a surprise!).
  61209. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  61210. * 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.
  61211. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61212. */
  61213. export class DirectionalLight extends ShadowLight {
  61214. private _shadowFrustumSize;
  61215. /**
  61216. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  61217. */
  61218. get shadowFrustumSize(): number;
  61219. /**
  61220. * Specifies a fix frustum size for the shadow generation.
  61221. */
  61222. set shadowFrustumSize(value: number);
  61223. private _shadowOrthoScale;
  61224. /**
  61225. * Gets the shadow projection scale against the optimal computed one.
  61226. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  61227. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  61228. */
  61229. get shadowOrthoScale(): number;
  61230. /**
  61231. * Sets the shadow projection scale against the optimal computed one.
  61232. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  61233. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  61234. */
  61235. set shadowOrthoScale(value: number);
  61236. /**
  61237. * Automatically compute the projection matrix to best fit (including all the casters)
  61238. * on each frame.
  61239. */
  61240. autoUpdateExtends: boolean;
  61241. /**
  61242. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  61243. * on each frame. autoUpdateExtends must be set to true for this to work
  61244. */
  61245. autoCalcShadowZBounds: boolean;
  61246. private _orthoLeft;
  61247. private _orthoRight;
  61248. private _orthoTop;
  61249. private _orthoBottom;
  61250. /**
  61251. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  61252. * The directional light is emitted from everywhere in the given direction.
  61253. * It can cast shadows.
  61254. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61255. * @param name The friendly name of the light
  61256. * @param direction The direction of the light
  61257. * @param scene The scene the light belongs to
  61258. */
  61259. constructor(name: string, direction: Vector3, scene: Scene);
  61260. /**
  61261. * Returns the string "DirectionalLight".
  61262. * @return The class name
  61263. */
  61264. getClassName(): string;
  61265. /**
  61266. * Returns the integer 1.
  61267. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61268. */
  61269. getTypeID(): number;
  61270. /**
  61271. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  61272. * Returns the DirectionalLight Shadow projection matrix.
  61273. */
  61274. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61275. /**
  61276. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  61277. * Returns the DirectionalLight Shadow projection matrix.
  61278. */
  61279. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  61280. /**
  61281. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  61282. * Returns the DirectionalLight Shadow projection matrix.
  61283. */
  61284. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61285. protected _buildUniformLayout(): void;
  61286. /**
  61287. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  61288. * @param effect The effect to update
  61289. * @param lightIndex The index of the light in the effect to update
  61290. * @returns The directional light
  61291. */
  61292. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  61293. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  61294. /**
  61295. * Gets the minZ used for shadow according to both the scene and the light.
  61296. *
  61297. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  61298. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  61299. * @param activeCamera The camera we are returning the min for
  61300. * @returns the depth min z
  61301. */
  61302. getDepthMinZ(activeCamera: Camera): number;
  61303. /**
  61304. * Gets the maxZ used for shadow according to both the scene and the light.
  61305. *
  61306. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  61307. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  61308. * @param activeCamera The camera we are returning the max for
  61309. * @returns the depth max z
  61310. */
  61311. getDepthMaxZ(activeCamera: Camera): number;
  61312. /**
  61313. * Prepares the list of defines specific to the light type.
  61314. * @param defines the list of defines
  61315. * @param lightIndex defines the index of the light for the effect
  61316. */
  61317. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61318. }
  61319. }
  61320. declare module BABYLON {
  61321. /**
  61322. * Class containing static functions to help procedurally build meshes
  61323. */
  61324. export class HemisphereBuilder {
  61325. /**
  61326. * Creates a hemisphere mesh
  61327. * @param name defines the name of the mesh
  61328. * @param options defines the options used to create the mesh
  61329. * @param scene defines the hosting scene
  61330. * @returns the hemisphere mesh
  61331. */
  61332. static CreateHemisphere(name: string, options: {
  61333. segments?: number;
  61334. diameter?: number;
  61335. sideOrientation?: number;
  61336. }, scene: any): Mesh;
  61337. }
  61338. }
  61339. declare module BABYLON {
  61340. /**
  61341. * A spot light is defined by a position, a direction, an angle, and an exponent.
  61342. * These values define a cone of light starting from the position, emitting toward the direction.
  61343. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  61344. * and the exponent defines the speed of the decay of the light with distance (reach).
  61345. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61346. */
  61347. export class SpotLight extends ShadowLight {
  61348. private _angle;
  61349. private _innerAngle;
  61350. private _cosHalfAngle;
  61351. private _lightAngleScale;
  61352. private _lightAngleOffset;
  61353. /**
  61354. * Gets the cone angle of the spot light in Radians.
  61355. */
  61356. get angle(): number;
  61357. /**
  61358. * Sets the cone angle of the spot light in Radians.
  61359. */
  61360. set angle(value: number);
  61361. /**
  61362. * Only used in gltf falloff mode, this defines the angle where
  61363. * the directional falloff will start before cutting at angle which could be seen
  61364. * as outer angle.
  61365. */
  61366. get innerAngle(): number;
  61367. /**
  61368. * Only used in gltf falloff mode, this defines the angle where
  61369. * the directional falloff will start before cutting at angle which could be seen
  61370. * as outer angle.
  61371. */
  61372. set innerAngle(value: number);
  61373. private _shadowAngleScale;
  61374. /**
  61375. * Allows scaling the angle of the light for shadow generation only.
  61376. */
  61377. get shadowAngleScale(): number;
  61378. /**
  61379. * Allows scaling the angle of the light for shadow generation only.
  61380. */
  61381. set shadowAngleScale(value: number);
  61382. /**
  61383. * The light decay speed with the distance from the emission spot.
  61384. */
  61385. exponent: number;
  61386. private _projectionTextureMatrix;
  61387. /**
  61388. * Allows reading the projection texture
  61389. */
  61390. get projectionTextureMatrix(): Matrix;
  61391. protected _projectionTextureLightNear: number;
  61392. /**
  61393. * Gets the near clip of the Spotlight for texture projection.
  61394. */
  61395. get projectionTextureLightNear(): number;
  61396. /**
  61397. * Sets the near clip of the Spotlight for texture projection.
  61398. */
  61399. set projectionTextureLightNear(value: number);
  61400. protected _projectionTextureLightFar: number;
  61401. /**
  61402. * Gets the far clip of the Spotlight for texture projection.
  61403. */
  61404. get projectionTextureLightFar(): number;
  61405. /**
  61406. * Sets the far clip of the Spotlight for texture projection.
  61407. */
  61408. set projectionTextureLightFar(value: number);
  61409. protected _projectionTextureUpDirection: Vector3;
  61410. /**
  61411. * Gets the Up vector of the Spotlight for texture projection.
  61412. */
  61413. get projectionTextureUpDirection(): Vector3;
  61414. /**
  61415. * Sets the Up vector of the Spotlight for texture projection.
  61416. */
  61417. set projectionTextureUpDirection(value: Vector3);
  61418. private _projectionTexture;
  61419. /**
  61420. * Gets the projection texture of the light.
  61421. */
  61422. get projectionTexture(): Nullable<BaseTexture>;
  61423. /**
  61424. * Sets the projection texture of the light.
  61425. */
  61426. set projectionTexture(value: Nullable<BaseTexture>);
  61427. private static _IsProceduralTexture;
  61428. private static _IsTexture;
  61429. private _projectionTextureViewLightDirty;
  61430. private _projectionTextureProjectionLightDirty;
  61431. private _projectionTextureDirty;
  61432. private _projectionTextureViewTargetVector;
  61433. private _projectionTextureViewLightMatrix;
  61434. private _projectionTextureProjectionLightMatrix;
  61435. private _projectionTextureScalingMatrix;
  61436. /**
  61437. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  61438. * It can cast shadows.
  61439. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61440. * @param name The light friendly name
  61441. * @param position The position of the spot light in the scene
  61442. * @param direction The direction of the light in the scene
  61443. * @param angle The cone angle of the light in Radians
  61444. * @param exponent The light decay speed with the distance from the emission spot
  61445. * @param scene The scene the lights belongs to
  61446. */
  61447. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  61448. /**
  61449. * Returns the string "SpotLight".
  61450. * @returns the class name
  61451. */
  61452. getClassName(): string;
  61453. /**
  61454. * Returns the integer 2.
  61455. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61456. */
  61457. getTypeID(): number;
  61458. /**
  61459. * Overrides the direction setter to recompute the projection texture view light Matrix.
  61460. */
  61461. protected _setDirection(value: Vector3): void;
  61462. /**
  61463. * Overrides the position setter to recompute the projection texture view light Matrix.
  61464. */
  61465. protected _setPosition(value: Vector3): void;
  61466. /**
  61467. * 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.
  61468. * Returns the SpotLight.
  61469. */
  61470. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61471. protected _computeProjectionTextureViewLightMatrix(): void;
  61472. protected _computeProjectionTextureProjectionLightMatrix(): void;
  61473. /**
  61474. * Main function for light texture projection matrix computing.
  61475. */
  61476. protected _computeProjectionTextureMatrix(): void;
  61477. protected _buildUniformLayout(): void;
  61478. private _computeAngleValues;
  61479. /**
  61480. * Sets the passed Effect "effect" with the Light textures.
  61481. * @param effect The effect to update
  61482. * @param lightIndex The index of the light in the effect to update
  61483. * @returns The light
  61484. */
  61485. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  61486. /**
  61487. * Sets the passed Effect object with the SpotLight transformed position (or position if not parented) and normalized direction.
  61488. * @param effect The effect to update
  61489. * @param lightIndex The index of the light in the effect to update
  61490. * @returns The spot light
  61491. */
  61492. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  61493. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61494. /**
  61495. * Disposes the light and the associated resources.
  61496. */
  61497. dispose(): void;
  61498. /**
  61499. * Prepares the list of defines specific to the light type.
  61500. * @param defines the list of defines
  61501. * @param lightIndex defines the index of the light for the effect
  61502. */
  61503. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61504. }
  61505. }
  61506. declare module BABYLON {
  61507. /**
  61508. * Gizmo that enables viewing a light
  61509. */
  61510. export class LightGizmo extends Gizmo {
  61511. private _lightMesh;
  61512. private _material;
  61513. private _cachedPosition;
  61514. private _cachedForward;
  61515. private _attachedMeshParent;
  61516. private _pointerObserver;
  61517. /**
  61518. * Event that fires each time the gizmo is clicked
  61519. */
  61520. onClickedObservable: Observable<Light>;
  61521. /**
  61522. * Creates a LightGizmo
  61523. * @param gizmoLayer The utility layer the gizmo will be added to
  61524. */
  61525. constructor(gizmoLayer?: UtilityLayerRenderer);
  61526. private _light;
  61527. /**
  61528. * The light that the gizmo is attached to
  61529. */
  61530. set light(light: Nullable<Light>);
  61531. get light(): Nullable<Light>;
  61532. /**
  61533. * Gets the material used to render the light gizmo
  61534. */
  61535. get material(): StandardMaterial;
  61536. /**
  61537. * @hidden
  61538. * Updates the gizmo to match the attached mesh's position/rotation
  61539. */
  61540. protected _update(): void;
  61541. private static _Scale;
  61542. /**
  61543. * Creates the lines for a light mesh
  61544. */
  61545. private static _CreateLightLines;
  61546. /**
  61547. * Disposes of the light gizmo
  61548. */
  61549. dispose(): void;
  61550. private static _CreateHemisphericLightMesh;
  61551. private static _CreatePointLightMesh;
  61552. private static _CreateSpotLightMesh;
  61553. private static _CreateDirectionalLightMesh;
  61554. }
  61555. }
  61556. declare module BABYLON {
  61557. /**
  61558. * Gizmo that enables viewing a camera
  61559. */
  61560. export class CameraGizmo extends Gizmo {
  61561. private _cameraMesh;
  61562. private _cameraLinesMesh;
  61563. private _material;
  61564. private _pointerObserver;
  61565. /**
  61566. * Event that fires each time the gizmo is clicked
  61567. */
  61568. onClickedObservable: Observable<Camera>;
  61569. /**
  61570. * Creates a CameraGizmo
  61571. * @param gizmoLayer The utility layer the gizmo will be added to
  61572. */
  61573. constructor(gizmoLayer?: UtilityLayerRenderer);
  61574. private _camera;
  61575. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  61576. get displayFrustum(): boolean;
  61577. set displayFrustum(value: boolean);
  61578. /**
  61579. * The camera that the gizmo is attached to
  61580. */
  61581. set camera(camera: Nullable<Camera>);
  61582. get camera(): Nullable<Camera>;
  61583. /**
  61584. * Gets the material used to render the camera gizmo
  61585. */
  61586. get material(): StandardMaterial;
  61587. /**
  61588. * @hidden
  61589. * Updates the gizmo to match the attached mesh's position/rotation
  61590. */
  61591. protected _update(): void;
  61592. private static _Scale;
  61593. private _invProjection;
  61594. /**
  61595. * Disposes of the camera gizmo
  61596. */
  61597. dispose(): void;
  61598. private static _CreateCameraMesh;
  61599. private static _CreateCameraFrustum;
  61600. }
  61601. }
  61602. declare module BABYLON {
  61603. /** @hidden */
  61604. export var backgroundFragmentDeclaration: {
  61605. name: string;
  61606. shader: string;
  61607. };
  61608. }
  61609. declare module BABYLON {
  61610. /** @hidden */
  61611. export var backgroundUboDeclaration: {
  61612. name: string;
  61613. shader: string;
  61614. };
  61615. }
  61616. declare module BABYLON {
  61617. /** @hidden */
  61618. export var backgroundPixelShader: {
  61619. name: string;
  61620. shader: string;
  61621. };
  61622. }
  61623. declare module BABYLON {
  61624. /** @hidden */
  61625. export var backgroundVertexDeclaration: {
  61626. name: string;
  61627. shader: string;
  61628. };
  61629. }
  61630. declare module BABYLON {
  61631. /** @hidden */
  61632. export var backgroundVertexShader: {
  61633. name: string;
  61634. shader: string;
  61635. };
  61636. }
  61637. declare module BABYLON {
  61638. /**
  61639. * Background material used to create an efficient environment around your scene.
  61640. */
  61641. export class BackgroundMaterial extends PushMaterial {
  61642. /**
  61643. * Standard reflectance value at parallel view angle.
  61644. */
  61645. static StandardReflectance0: number;
  61646. /**
  61647. * Standard reflectance value at grazing angle.
  61648. */
  61649. static StandardReflectance90: number;
  61650. protected _primaryColor: Color3;
  61651. /**
  61652. * Key light Color (multiply against the environment texture)
  61653. */
  61654. primaryColor: Color3;
  61655. protected __perceptualColor: Nullable<Color3>;
  61656. /**
  61657. * Experimental Internal Use Only.
  61658. *
  61659. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  61660. * This acts as a helper to set the primary color to a more "human friendly" value.
  61661. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  61662. * output color as close as possible from the chosen value.
  61663. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  61664. * part of lighting setup.)
  61665. */
  61666. get _perceptualColor(): Nullable<Color3>;
  61667. set _perceptualColor(value: Nullable<Color3>);
  61668. protected _primaryColorShadowLevel: float;
  61669. /**
  61670. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  61671. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  61672. */
  61673. get primaryColorShadowLevel(): float;
  61674. set primaryColorShadowLevel(value: float);
  61675. protected _primaryColorHighlightLevel: float;
  61676. /**
  61677. * Defines the level of the highlights (highlight area of the reflection map) in order to help scaling the colors.
  61678. * The primary color is used at the level chosen to define what the white area would look.
  61679. */
  61680. get primaryColorHighlightLevel(): float;
  61681. set primaryColorHighlightLevel(value: float);
  61682. protected _reflectionTexture: Nullable<BaseTexture>;
  61683. /**
  61684. * Reflection Texture used in the material.
  61685. * Should be author in a specific way for the best result (refer to the documentation).
  61686. */
  61687. reflectionTexture: Nullable<BaseTexture>;
  61688. protected _reflectionBlur: float;
  61689. /**
  61690. * Reflection Texture level of blur.
  61691. *
  61692. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  61693. * texture twice.
  61694. */
  61695. reflectionBlur: float;
  61696. protected _diffuseTexture: Nullable<BaseTexture>;
  61697. /**
  61698. * Diffuse Texture used in the material.
  61699. * Should be author in a specific way for the best result (refer to the documentation).
  61700. */
  61701. diffuseTexture: Nullable<BaseTexture>;
  61702. protected _shadowLights: Nullable<IShadowLight[]>;
  61703. /**
  61704. * Specify the list of lights casting shadow on the material.
  61705. * All scene shadow lights will be included if null.
  61706. */
  61707. shadowLights: Nullable<IShadowLight[]>;
  61708. protected _shadowLevel: float;
  61709. /**
  61710. * Helps adjusting the shadow to a softer level if required.
  61711. * 0 means black shadows and 1 means no shadows.
  61712. */
  61713. shadowLevel: float;
  61714. protected _sceneCenter: Vector3;
  61715. /**
  61716. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  61717. * It is usually zero but might be interesting to modify according to your setup.
  61718. */
  61719. sceneCenter: Vector3;
  61720. protected _opacityFresnel: boolean;
  61721. /**
  61722. * This helps specifying that the material is falling off to the sky box at grazing angle.
  61723. * This helps ensuring a nice transition when the camera goes under the ground.
  61724. */
  61725. opacityFresnel: boolean;
  61726. protected _reflectionFresnel: boolean;
  61727. /**
  61728. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  61729. * This helps adding a mirror texture on the ground.
  61730. */
  61731. reflectionFresnel: boolean;
  61732. protected _reflectionFalloffDistance: number;
  61733. /**
  61734. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  61735. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  61736. */
  61737. reflectionFalloffDistance: number;
  61738. protected _reflectionAmount: number;
  61739. /**
  61740. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  61741. */
  61742. reflectionAmount: number;
  61743. protected _reflectionReflectance0: number;
  61744. /**
  61745. * This specifies the weight of the reflection at grazing angle.
  61746. */
  61747. reflectionReflectance0: number;
  61748. protected _reflectionReflectance90: number;
  61749. /**
  61750. * This specifies the weight of the reflection at a perpendicular point of view.
  61751. */
  61752. reflectionReflectance90: number;
  61753. /**
  61754. * Sets the reflection reflectance fresnel values according to the default standard
  61755. * empirically know to work well :-)
  61756. */
  61757. set reflectionStandardFresnelWeight(value: number);
  61758. protected _useRGBColor: boolean;
  61759. /**
  61760. * Helps to directly use the maps channels instead of their level.
  61761. */
  61762. useRGBColor: boolean;
  61763. protected _enableNoise: boolean;
  61764. /**
  61765. * This helps reducing the banding effect that could occur on the background.
  61766. */
  61767. enableNoise: boolean;
  61768. /**
  61769. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61770. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  61771. * Recommended to be keep at 1.0 except for special cases.
  61772. */
  61773. get fovMultiplier(): number;
  61774. set fovMultiplier(value: number);
  61775. private _fovMultiplier;
  61776. /**
  61777. * Enable the FOV adjustment feature controlled by fovMultiplier.
  61778. */
  61779. useEquirectangularFOV: boolean;
  61780. private _maxSimultaneousLights;
  61781. /**
  61782. * Number of Simultaneous lights allowed on the material.
  61783. */
  61784. maxSimultaneousLights: int;
  61785. private _shadowOnly;
  61786. /**
  61787. * Make the material only render shadows
  61788. */
  61789. shadowOnly: boolean;
  61790. /**
  61791. * Default configuration related to image processing available in the Background Material.
  61792. */
  61793. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  61794. /**
  61795. * Keep track of the image processing observer to allow dispose and replace.
  61796. */
  61797. private _imageProcessingObserver;
  61798. /**
  61799. * Attaches a new image processing configuration to the PBR Material.
  61800. * @param configuration (if null the scene configuration will be use)
  61801. */
  61802. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  61803. /**
  61804. * Gets the image processing configuration used either in this material.
  61805. */
  61806. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  61807. /**
  61808. * Sets the Default image processing configuration used either in the this material.
  61809. *
  61810. * If sets to null, the scene one is in use.
  61811. */
  61812. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  61813. /**
  61814. * Gets whether the color curves effect is enabled.
  61815. */
  61816. get cameraColorCurvesEnabled(): boolean;
  61817. /**
  61818. * Sets whether the color curves effect is enabled.
  61819. */
  61820. set cameraColorCurvesEnabled(value: boolean);
  61821. /**
  61822. * Gets whether the color grading effect is enabled.
  61823. */
  61824. get cameraColorGradingEnabled(): boolean;
  61825. /**
  61826. * Gets whether the color grading effect is enabled.
  61827. */
  61828. set cameraColorGradingEnabled(value: boolean);
  61829. /**
  61830. * Gets whether tonemapping is enabled or not.
  61831. */
  61832. get cameraToneMappingEnabled(): boolean;
  61833. /**
  61834. * Sets whether tonemapping is enabled or not
  61835. */
  61836. set cameraToneMappingEnabled(value: boolean);
  61837. /**
  61838. * The camera exposure used on this material.
  61839. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61840. * This corresponds to a photographic exposure.
  61841. */
  61842. get cameraExposure(): float;
  61843. /**
  61844. * The camera exposure used on this material.
  61845. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61846. * This corresponds to a photographic exposure.
  61847. */
  61848. set cameraExposure(value: float);
  61849. /**
  61850. * Gets The camera contrast used on this material.
  61851. */
  61852. get cameraContrast(): float;
  61853. /**
  61854. * Sets The camera contrast used on this material.
  61855. */
  61856. set cameraContrast(value: float);
  61857. /**
  61858. * Gets the Color Grading 2D Lookup Texture.
  61859. */
  61860. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  61861. /**
  61862. * Sets the Color Grading 2D Lookup Texture.
  61863. */
  61864. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  61865. /**
  61866. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  61867. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61868. * 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;
  61869. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61870. */
  61871. get cameraColorCurves(): Nullable<ColorCurves>;
  61872. /**
  61873. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  61874. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61875. * 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;
  61876. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61877. */
  61878. set cameraColorCurves(value: Nullable<ColorCurves>);
  61879. /**
  61880. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  61881. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  61882. */
  61883. switchToBGR: boolean;
  61884. private _renderTargets;
  61885. private _reflectionControls;
  61886. private _white;
  61887. private _primaryShadowColor;
  61888. private _primaryHighlightColor;
  61889. /**
  61890. * Instantiates a Background Material in the given scene
  61891. * @param name The friendly name of the material
  61892. * @param scene The scene to add the material to
  61893. */
  61894. constructor(name: string, scene: Scene);
  61895. /**
  61896. * Gets a boolean indicating that current material needs to register RTT
  61897. */
  61898. get hasRenderTargetTextures(): boolean;
  61899. /**
  61900. * The entire material has been created in order to prevent overdraw.
  61901. * @returns false
  61902. */
  61903. needAlphaTesting(): boolean;
  61904. /**
  61905. * The entire material has been created in order to prevent overdraw.
  61906. * @returns true if blending is enable
  61907. */
  61908. needAlphaBlending(): boolean;
  61909. /**
  61910. * Checks whether the material is ready to be rendered for a given mesh.
  61911. * @param mesh The mesh to render
  61912. * @param subMesh The submesh to check against
  61913. * @param useInstances Specify wether or not the material is used with instances
  61914. * @returns true if all the dependencies are ready (Textures, Effects...)
  61915. */
  61916. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  61917. /**
  61918. * Compute the primary color according to the chosen perceptual color.
  61919. */
  61920. private _computePrimaryColorFromPerceptualColor;
  61921. /**
  61922. * Compute the highlights and shadow colors according to their chosen levels.
  61923. */
  61924. private _computePrimaryColors;
  61925. /**
  61926. * Build the uniform buffer used in the material.
  61927. */
  61928. buildUniformLayout(): void;
  61929. /**
  61930. * Unbind the material.
  61931. */
  61932. unbind(): void;
  61933. /**
  61934. * Bind only the world matrix to the material.
  61935. * @param world The world matrix to bind.
  61936. */
  61937. bindOnlyWorldMatrix(world: Matrix): void;
  61938. /**
  61939. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  61940. * @param world The world matrix to bind.
  61941. * @param subMesh The submesh to bind for.
  61942. */
  61943. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  61944. /**
  61945. * Checks to see if a texture is used in the material.
  61946. * @param texture - Base texture to use.
  61947. * @returns - Boolean specifying if a texture is used in the material.
  61948. */
  61949. hasTexture(texture: BaseTexture): boolean;
  61950. /**
  61951. * Dispose the material.
  61952. * @param forceDisposeEffect Force disposal of the associated effect.
  61953. * @param forceDisposeTextures Force disposal of the associated textures.
  61954. */
  61955. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  61956. /**
  61957. * Clones the material.
  61958. * @param name The cloned name.
  61959. * @returns The cloned material.
  61960. */
  61961. clone(name: string): BackgroundMaterial;
  61962. /**
  61963. * Serializes the current material to its JSON representation.
  61964. * @returns The JSON representation.
  61965. */
  61966. serialize(): any;
  61967. /**
  61968. * Gets the class name of the material
  61969. * @returns "BackgroundMaterial"
  61970. */
  61971. getClassName(): string;
  61972. /**
  61973. * Parse a JSON input to create back a background material.
  61974. * @param source The JSON data to parse
  61975. * @param scene The scene to create the parsed material in
  61976. * @param rootUrl The root url of the assets the material depends upon
  61977. * @returns the instantiated BackgroundMaterial.
  61978. */
  61979. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  61980. }
  61981. }
  61982. declare module BABYLON {
  61983. /**
  61984. * Represents the different options available during the creation of
  61985. * a Environment helper.
  61986. *
  61987. * This can control the default ground, skybox and image processing setup of your scene.
  61988. */
  61989. export interface IEnvironmentHelperOptions {
  61990. /**
  61991. * Specifies whether or not to create a ground.
  61992. * True by default.
  61993. */
  61994. createGround: boolean;
  61995. /**
  61996. * Specifies the ground size.
  61997. * 15 by default.
  61998. */
  61999. groundSize: number;
  62000. /**
  62001. * The texture used on the ground for the main color.
  62002. * Comes from the BabylonJS CDN by default.
  62003. *
  62004. * Remarks: Can be either a texture or a url.
  62005. */
  62006. groundTexture: string | BaseTexture;
  62007. /**
  62008. * The color mixed in the ground texture by default.
  62009. * BabylonJS clearColor by default.
  62010. */
  62011. groundColor: Color3;
  62012. /**
  62013. * Specifies the ground opacity.
  62014. * 1 by default.
  62015. */
  62016. groundOpacity: number;
  62017. /**
  62018. * Enables the ground to receive shadows.
  62019. * True by default.
  62020. */
  62021. enableGroundShadow: boolean;
  62022. /**
  62023. * Helps preventing the shadow to be fully black on the ground.
  62024. * 0.5 by default.
  62025. */
  62026. groundShadowLevel: number;
  62027. /**
  62028. * Creates a mirror texture attach to the ground.
  62029. * false by default.
  62030. */
  62031. enableGroundMirror: boolean;
  62032. /**
  62033. * Specifies the ground mirror size ratio.
  62034. * 0.3 by default as the default kernel is 64.
  62035. */
  62036. groundMirrorSizeRatio: number;
  62037. /**
  62038. * Specifies the ground mirror blur kernel size.
  62039. * 64 by default.
  62040. */
  62041. groundMirrorBlurKernel: number;
  62042. /**
  62043. * Specifies the ground mirror visibility amount.
  62044. * 1 by default
  62045. */
  62046. groundMirrorAmount: number;
  62047. /**
  62048. * Specifies the ground mirror reflectance weight.
  62049. * This uses the standard weight of the background material to setup the fresnel effect
  62050. * of the mirror.
  62051. * 1 by default.
  62052. */
  62053. groundMirrorFresnelWeight: number;
  62054. /**
  62055. * Specifies the ground mirror Falloff distance.
  62056. * This can helps reducing the size of the reflection.
  62057. * 0 by Default.
  62058. */
  62059. groundMirrorFallOffDistance: number;
  62060. /**
  62061. * Specifies the ground mirror texture type.
  62062. * Unsigned Int by Default.
  62063. */
  62064. groundMirrorTextureType: number;
  62065. /**
  62066. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  62067. * the shown objects.
  62068. */
  62069. groundYBias: number;
  62070. /**
  62071. * Specifies whether or not to create a skybox.
  62072. * True by default.
  62073. */
  62074. createSkybox: boolean;
  62075. /**
  62076. * Specifies the skybox size.
  62077. * 20 by default.
  62078. */
  62079. skyboxSize: number;
  62080. /**
  62081. * The texture used on the skybox for the main color.
  62082. * Comes from the BabylonJS CDN by default.
  62083. *
  62084. * Remarks: Can be either a texture or a url.
  62085. */
  62086. skyboxTexture: string | BaseTexture;
  62087. /**
  62088. * The color mixed in the skybox texture by default.
  62089. * BabylonJS clearColor by default.
  62090. */
  62091. skyboxColor: Color3;
  62092. /**
  62093. * The background rotation around the Y axis of the scene.
  62094. * This helps aligning the key lights of your scene with the background.
  62095. * 0 by default.
  62096. */
  62097. backgroundYRotation: number;
  62098. /**
  62099. * Compute automatically the size of the elements to best fit with the scene.
  62100. */
  62101. sizeAuto: boolean;
  62102. /**
  62103. * Default position of the rootMesh if autoSize is not true.
  62104. */
  62105. rootPosition: Vector3;
  62106. /**
  62107. * Sets up the image processing in the scene.
  62108. * true by default.
  62109. */
  62110. setupImageProcessing: boolean;
  62111. /**
  62112. * The texture used as your environment texture in the scene.
  62113. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  62114. *
  62115. * Remarks: Can be either a texture or a url.
  62116. */
  62117. environmentTexture: string | BaseTexture;
  62118. /**
  62119. * The value of the exposure to apply to the scene.
  62120. * 0.6 by default if setupImageProcessing is true.
  62121. */
  62122. cameraExposure: number;
  62123. /**
  62124. * The value of the contrast to apply to the scene.
  62125. * 1.6 by default if setupImageProcessing is true.
  62126. */
  62127. cameraContrast: number;
  62128. /**
  62129. * Specifies whether or not tonemapping should be enabled in the scene.
  62130. * true by default if setupImageProcessing is true.
  62131. */
  62132. toneMappingEnabled: boolean;
  62133. }
  62134. /**
  62135. * The Environment helper class can be used to add a fully featured none expensive background to your scene.
  62136. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  62137. * It also helps with the default setup of your imageProcessing configuration.
  62138. */
  62139. export class EnvironmentHelper {
  62140. /**
  62141. * Default ground texture URL.
  62142. */
  62143. private static _groundTextureCDNUrl;
  62144. /**
  62145. * Default skybox texture URL.
  62146. */
  62147. private static _skyboxTextureCDNUrl;
  62148. /**
  62149. * Default environment texture URL.
  62150. */
  62151. private static _environmentTextureCDNUrl;
  62152. /**
  62153. * Creates the default options for the helper.
  62154. */
  62155. private static _getDefaultOptions;
  62156. private _rootMesh;
  62157. /**
  62158. * Gets the root mesh created by the helper.
  62159. */
  62160. get rootMesh(): Mesh;
  62161. private _skybox;
  62162. /**
  62163. * Gets the skybox created by the helper.
  62164. */
  62165. get skybox(): Nullable<Mesh>;
  62166. private _skyboxTexture;
  62167. /**
  62168. * Gets the skybox texture created by the helper.
  62169. */
  62170. get skyboxTexture(): Nullable<BaseTexture>;
  62171. private _skyboxMaterial;
  62172. /**
  62173. * Gets the skybox material created by the helper.
  62174. */
  62175. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  62176. private _ground;
  62177. /**
  62178. * Gets the ground mesh created by the helper.
  62179. */
  62180. get ground(): Nullable<Mesh>;
  62181. private _groundTexture;
  62182. /**
  62183. * Gets the ground texture created by the helper.
  62184. */
  62185. get groundTexture(): Nullable<BaseTexture>;
  62186. private _groundMirror;
  62187. /**
  62188. * Gets the ground mirror created by the helper.
  62189. */
  62190. get groundMirror(): Nullable<MirrorTexture>;
  62191. /**
  62192. * Gets the ground mirror render list to helps pushing the meshes
  62193. * you wish in the ground reflection.
  62194. */
  62195. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  62196. private _groundMaterial;
  62197. /**
  62198. * Gets the ground material created by the helper.
  62199. */
  62200. get groundMaterial(): Nullable<BackgroundMaterial>;
  62201. /**
  62202. * Stores the creation options.
  62203. */
  62204. private readonly _scene;
  62205. private _options;
  62206. /**
  62207. * This observable will be notified with any error during the creation of the environment,
  62208. * mainly texture creation errors.
  62209. */
  62210. onErrorObservable: Observable<{
  62211. message?: string;
  62212. exception?: any;
  62213. }>;
  62214. /**
  62215. * constructor
  62216. * @param options Defines the options we want to customize the helper
  62217. * @param scene The scene to add the material to
  62218. */
  62219. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  62220. /**
  62221. * Updates the background according to the new options
  62222. * @param options
  62223. */
  62224. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  62225. /**
  62226. * Sets the primary color of all the available elements.
  62227. * @param color the main color to affect to the ground and the background
  62228. */
  62229. setMainColor(color: Color3): void;
  62230. /**
  62231. * Setup the image processing according to the specified options.
  62232. */
  62233. private _setupImageProcessing;
  62234. /**
  62235. * Setup the environment texture according to the specified options.
  62236. */
  62237. private _setupEnvironmentTexture;
  62238. /**
  62239. * Setup the background according to the specified options.
  62240. */
  62241. private _setupBackground;
  62242. /**
  62243. * Get the scene sizes according to the setup.
  62244. */
  62245. private _getSceneSize;
  62246. /**
  62247. * Setup the ground according to the specified options.
  62248. */
  62249. private _setupGround;
  62250. /**
  62251. * Setup the ground material according to the specified options.
  62252. */
  62253. private _setupGroundMaterial;
  62254. /**
  62255. * Setup the ground diffuse texture according to the specified options.
  62256. */
  62257. private _setupGroundDiffuseTexture;
  62258. /**
  62259. * Setup the ground mirror texture according to the specified options.
  62260. */
  62261. private _setupGroundMirrorTexture;
  62262. /**
  62263. * Setup the ground to receive the mirror texture.
  62264. */
  62265. private _setupMirrorInGroundMaterial;
  62266. /**
  62267. * Setup the skybox according to the specified options.
  62268. */
  62269. private _setupSkybox;
  62270. /**
  62271. * Setup the skybox material according to the specified options.
  62272. */
  62273. private _setupSkyboxMaterial;
  62274. /**
  62275. * Setup the skybox reflection texture according to the specified options.
  62276. */
  62277. private _setupSkyboxReflectionTexture;
  62278. private _errorHandler;
  62279. /**
  62280. * Dispose all the elements created by the Helper.
  62281. */
  62282. dispose(): void;
  62283. }
  62284. }
  62285. declare module BABYLON {
  62286. /**
  62287. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  62288. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  62289. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  62290. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62291. */
  62292. export abstract class TextureDome<T extends Texture> extends TransformNode {
  62293. protected onError: Nullable<(message?: string, exception?: any) => void>;
  62294. /**
  62295. * Define the source as a Monoscopic panoramic 360/180.
  62296. */
  62297. static readonly MODE_MONOSCOPIC: number;
  62298. /**
  62299. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  62300. */
  62301. static readonly MODE_TOPBOTTOM: number;
  62302. /**
  62303. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  62304. */
  62305. static readonly MODE_SIDEBYSIDE: number;
  62306. private _halfDome;
  62307. private _crossEye;
  62308. protected _useDirectMapping: boolean;
  62309. /**
  62310. * The texture being displayed on the sphere
  62311. */
  62312. protected _texture: T;
  62313. /**
  62314. * Gets the texture being displayed on the sphere
  62315. */
  62316. get texture(): T;
  62317. /**
  62318. * Sets the texture being displayed on the sphere
  62319. */
  62320. set texture(newTexture: T);
  62321. /**
  62322. * The skybox material
  62323. */
  62324. protected _material: BackgroundMaterial;
  62325. /**
  62326. * The surface used for the dome
  62327. */
  62328. protected _mesh: Mesh;
  62329. /**
  62330. * Gets the mesh used for the dome.
  62331. */
  62332. get mesh(): Mesh;
  62333. /**
  62334. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  62335. */
  62336. private _halfDomeMask;
  62337. /**
  62338. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  62339. * Also see the options.resolution property.
  62340. */
  62341. get fovMultiplier(): number;
  62342. set fovMultiplier(value: number);
  62343. protected _textureMode: number;
  62344. /**
  62345. * Gets or set the current texture mode for the texture. It can be:
  62346. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62347. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62348. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62349. */
  62350. get textureMode(): number;
  62351. /**
  62352. * Sets the current texture mode for the texture. It can be:
  62353. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62354. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62355. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62356. */
  62357. set textureMode(value: number);
  62358. /**
  62359. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  62360. */
  62361. get halfDome(): boolean;
  62362. /**
  62363. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  62364. */
  62365. set halfDome(enabled: boolean);
  62366. /**
  62367. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  62368. */
  62369. set crossEye(enabled: boolean);
  62370. /**
  62371. * Is it a cross-eye texture?
  62372. */
  62373. get crossEye(): boolean;
  62374. /**
  62375. * The background material of this dome.
  62376. */
  62377. get material(): BackgroundMaterial;
  62378. /**
  62379. * Oberserver used in Stereoscopic VR Mode.
  62380. */
  62381. private _onBeforeCameraRenderObserver;
  62382. /**
  62383. * Observable raised when an error occurred while loading the texture
  62384. */
  62385. onLoadErrorObservable: Observable<string>;
  62386. /**
  62387. * Observable raised when the texture finished loading
  62388. */
  62389. onLoadObservable: Observable<void>;
  62390. /**
  62391. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  62392. * @param name Element's name, child elements will append suffixes for their own names.
  62393. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  62394. * @param options An object containing optional or exposed sub element properties
  62395. */
  62396. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  62397. resolution?: number;
  62398. clickToPlay?: boolean;
  62399. autoPlay?: boolean;
  62400. loop?: boolean;
  62401. size?: number;
  62402. poster?: string;
  62403. faceForward?: boolean;
  62404. useDirectMapping?: boolean;
  62405. halfDomeMode?: boolean;
  62406. crossEyeMode?: boolean;
  62407. generateMipMaps?: boolean;
  62408. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  62409. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  62410. protected _changeTextureMode(value: number): void;
  62411. /**
  62412. * Releases resources associated with this node.
  62413. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  62414. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  62415. */
  62416. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  62417. }
  62418. }
  62419. declare module BABYLON {
  62420. /**
  62421. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  62422. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  62423. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  62424. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62425. */
  62426. export class PhotoDome extends TextureDome<Texture> {
  62427. /**
  62428. * Define the image as a Monoscopic panoramic 360 image.
  62429. */
  62430. static readonly MODE_MONOSCOPIC: number;
  62431. /**
  62432. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  62433. */
  62434. static readonly MODE_TOPBOTTOM: number;
  62435. /**
  62436. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  62437. */
  62438. static readonly MODE_SIDEBYSIDE: number;
  62439. /**
  62440. * Gets or sets the texture being displayed on the sphere
  62441. */
  62442. get photoTexture(): Texture;
  62443. /**
  62444. * sets the texture being displayed on the sphere
  62445. */
  62446. set photoTexture(value: Texture);
  62447. /**
  62448. * Gets the current video mode for the video. It can be:
  62449. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62450. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62451. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62452. */
  62453. get imageMode(): number;
  62454. /**
  62455. * Sets the current video mode for the video. It can be:
  62456. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62457. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62458. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62459. */
  62460. set imageMode(value: number);
  62461. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  62462. }
  62463. }
  62464. declare module BABYLON {
  62465. /**
  62466. * Direct draw surface info
  62467. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  62468. */
  62469. export interface DDSInfo {
  62470. /**
  62471. * Width of the texture
  62472. */
  62473. width: number;
  62474. /**
  62475. * Width of the texture
  62476. */
  62477. height: number;
  62478. /**
  62479. * Number of Mipmaps for the texture
  62480. * @see https://en.wikipedia.org/wiki/Mipmap
  62481. */
  62482. mipmapCount: number;
  62483. /**
  62484. * If the textures format is a known fourCC format
  62485. * @see https://www.fourcc.org/
  62486. */
  62487. isFourCC: boolean;
  62488. /**
  62489. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  62490. */
  62491. isRGB: boolean;
  62492. /**
  62493. * If the texture is a lumincance format
  62494. */
  62495. isLuminance: boolean;
  62496. /**
  62497. * If this is a cube texture
  62498. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  62499. */
  62500. isCube: boolean;
  62501. /**
  62502. * If the texture is a compressed format eg. FOURCC_DXT1
  62503. */
  62504. isCompressed: boolean;
  62505. /**
  62506. * The dxgiFormat of the texture
  62507. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  62508. */
  62509. dxgiFormat: number;
  62510. /**
  62511. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  62512. */
  62513. textureType: number;
  62514. /**
  62515. * Sphericle polynomial created for the dds texture
  62516. */
  62517. sphericalPolynomial?: SphericalPolynomial;
  62518. }
  62519. /**
  62520. * Class used to provide DDS decompression tools
  62521. */
  62522. export class DDSTools {
  62523. /**
  62524. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  62525. */
  62526. static StoreLODInAlphaChannel: boolean;
  62527. /**
  62528. * Gets DDS information from an array buffer
  62529. * @param data defines the array buffer view to read data from
  62530. * @returns the DDS information
  62531. */
  62532. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  62533. private static _FloatView;
  62534. private static _Int32View;
  62535. private static _ToHalfFloat;
  62536. private static _FromHalfFloat;
  62537. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  62538. private static _GetHalfFloatRGBAArrayBuffer;
  62539. private static _GetFloatRGBAArrayBuffer;
  62540. private static _GetFloatAsUIntRGBAArrayBuffer;
  62541. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  62542. private static _GetRGBAArrayBuffer;
  62543. private static _ExtractLongWordOrder;
  62544. private static _GetRGBArrayBuffer;
  62545. private static _GetLuminanceArrayBuffer;
  62546. /**
  62547. * Uploads DDS Levels to a Babylon Texture
  62548. * @hidden
  62549. */
  62550. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  62551. }
  62552. interface ThinEngine {
  62553. /**
  62554. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  62555. * @param rootUrl defines the url where the file to load is located
  62556. * @param scene defines the current scene
  62557. * @param lodScale defines scale to apply to the mip map selection
  62558. * @param lodOffset defines offset to apply to the mip map selection
  62559. * @param onLoad defines an optional callback raised when the texture is loaded
  62560. * @param onError defines an optional callback raised if there is an issue to load the texture
  62561. * @param format defines the format of the data
  62562. * @param forcedExtension defines the extension to use to pick the right loader
  62563. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  62564. * @returns the cube texture as an InternalTexture
  62565. */
  62566. 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;
  62567. }
  62568. }
  62569. declare module BABYLON {
  62570. /**
  62571. * Implementation of the DDS Texture Loader.
  62572. * @hidden
  62573. */
  62574. export class _DDSTextureLoader implements IInternalTextureLoader {
  62575. /**
  62576. * Defines whether the loader supports cascade loading the different faces.
  62577. */
  62578. readonly supportCascades: boolean;
  62579. /**
  62580. * This returns if the loader support the current file information.
  62581. * @param extension defines the file extension of the file being loaded
  62582. * @returns true if the loader can load the specified file
  62583. */
  62584. canLoad(extension: string): boolean;
  62585. /**
  62586. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62587. * @param data contains the texture data
  62588. * @param texture defines the BabylonJS internal texture
  62589. * @param createPolynomials will be true if polynomials have been requested
  62590. * @param onLoad defines the callback to trigger once the texture is ready
  62591. * @param onError defines the callback to trigger in case of error
  62592. */
  62593. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62594. /**
  62595. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62596. * @param data contains the texture data
  62597. * @param texture defines the BabylonJS internal texture
  62598. * @param callback defines the method to call once ready to upload
  62599. */
  62600. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62601. }
  62602. }
  62603. declare module BABYLON {
  62604. /**
  62605. * Implementation of the ENV Texture Loader.
  62606. * @hidden
  62607. */
  62608. export class _ENVTextureLoader implements IInternalTextureLoader {
  62609. /**
  62610. * Defines whether the loader supports cascade loading the different faces.
  62611. */
  62612. readonly supportCascades: boolean;
  62613. /**
  62614. * This returns if the loader support the current file information.
  62615. * @param extension defines the file extension of the file being loaded
  62616. * @returns true if the loader can load the specified file
  62617. */
  62618. canLoad(extension: string): boolean;
  62619. /**
  62620. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62621. * @param data contains the texture data
  62622. * @param texture defines the BabylonJS internal texture
  62623. * @param createPolynomials will be true if polynomials have been requested
  62624. * @param onLoad defines the callback to trigger once the texture is ready
  62625. * @param onError defines the callback to trigger in case of error
  62626. */
  62627. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62628. /**
  62629. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62630. * @param data contains the texture data
  62631. * @param texture defines the BabylonJS internal texture
  62632. * @param callback defines the method to call once ready to upload
  62633. */
  62634. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62635. }
  62636. }
  62637. declare module BABYLON {
  62638. /**
  62639. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  62640. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  62641. */
  62642. export class KhronosTextureContainer {
  62643. /** contents of the KTX container file */
  62644. data: ArrayBufferView;
  62645. private static HEADER_LEN;
  62646. private static COMPRESSED_2D;
  62647. private static COMPRESSED_3D;
  62648. private static TEX_2D;
  62649. private static TEX_3D;
  62650. /**
  62651. * Gets the openGL type
  62652. */
  62653. glType: number;
  62654. /**
  62655. * Gets the openGL type size
  62656. */
  62657. glTypeSize: number;
  62658. /**
  62659. * Gets the openGL format
  62660. */
  62661. glFormat: number;
  62662. /**
  62663. * Gets the openGL internal format
  62664. */
  62665. glInternalFormat: number;
  62666. /**
  62667. * Gets the base internal format
  62668. */
  62669. glBaseInternalFormat: number;
  62670. /**
  62671. * Gets image width in pixel
  62672. */
  62673. pixelWidth: number;
  62674. /**
  62675. * Gets image height in pixel
  62676. */
  62677. pixelHeight: number;
  62678. /**
  62679. * Gets image depth in pixels
  62680. */
  62681. pixelDepth: number;
  62682. /**
  62683. * Gets the number of array elements
  62684. */
  62685. numberOfArrayElements: number;
  62686. /**
  62687. * Gets the number of faces
  62688. */
  62689. numberOfFaces: number;
  62690. /**
  62691. * Gets the number of mipmap levels
  62692. */
  62693. numberOfMipmapLevels: number;
  62694. /**
  62695. * Gets the bytes of key value data
  62696. */
  62697. bytesOfKeyValueData: number;
  62698. /**
  62699. * Gets the load type
  62700. */
  62701. loadType: number;
  62702. /**
  62703. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  62704. */
  62705. isInvalid: boolean;
  62706. /**
  62707. * Creates a new KhronosTextureContainer
  62708. * @param data contents of the KTX container file
  62709. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  62710. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  62711. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  62712. */
  62713. constructor(
  62714. /** contents of the KTX container file */
  62715. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  62716. /**
  62717. * Uploads KTX content to a Babylon Texture.
  62718. * It is assumed that the texture has already been created & is currently bound
  62719. * @hidden
  62720. */
  62721. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  62722. private _upload2DCompressedLevels;
  62723. /**
  62724. * Checks if the given data starts with a KTX file identifier.
  62725. * @param data the data to check
  62726. * @returns true if the data is a KTX file or false otherwise
  62727. */
  62728. static IsValid(data: ArrayBufferView): boolean;
  62729. }
  62730. }
  62731. declare module BABYLON {
  62732. /**
  62733. * Helper class to push actions to a pool of workers.
  62734. */
  62735. export class WorkerPool implements IDisposable {
  62736. private _workerInfos;
  62737. private _pendingActions;
  62738. /**
  62739. * Constructor
  62740. * @param workers Array of workers to use for actions
  62741. */
  62742. constructor(workers: Array<Worker>);
  62743. /**
  62744. * Terminates all workers and clears any pending actions.
  62745. */
  62746. dispose(): void;
  62747. /**
  62748. * Pushes an action to the worker pool. If all the workers are active, the action will be
  62749. * pended until a worker has completed its action.
  62750. * @param action The action to perform. Call onComplete when the action is complete.
  62751. */
  62752. push(action: (worker: Worker, onComplete: () => void) => void): void;
  62753. private _execute;
  62754. }
  62755. }
  62756. declare module BABYLON {
  62757. /**
  62758. * Class for loading KTX2 files
  62759. */
  62760. export class KhronosTextureContainer2 {
  62761. private static _WorkerPoolPromise?;
  62762. private static _Initialized;
  62763. private static _Ktx2Decoder;
  62764. /**
  62765. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  62766. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  62767. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  62768. * Urls you can change:
  62769. * URLConfig.jsDecoderModule
  62770. * URLConfig.wasmUASTCToASTC
  62771. * URLConfig.wasmUASTCToBC7
  62772. * URLConfig.wasmUASTCToRGBA_UNORM
  62773. * URLConfig.wasmUASTCToRGBA_SRGB
  62774. * URLConfig.jsMSCTranscoder
  62775. * URLConfig.wasmMSCTranscoder
  62776. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#22
  62777. */
  62778. static URLConfig: {
  62779. jsDecoderModule: string;
  62780. wasmUASTCToASTC: null;
  62781. wasmUASTCToBC7: null;
  62782. wasmUASTCToRGBA_UNORM: null;
  62783. wasmUASTCToRGBA_SRGB: null;
  62784. jsMSCTranscoder: null;
  62785. wasmMSCTranscoder: null;
  62786. };
  62787. /**
  62788. * Default number of workers used to handle data decoding
  62789. */
  62790. static DefaultNumWorkers: number;
  62791. private static GetDefaultNumWorkers;
  62792. private _engine;
  62793. private static _CreateWorkerPool;
  62794. /**
  62795. * Constructor
  62796. * @param engine The engine to use
  62797. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  62798. */
  62799. constructor(engine: ThinEngine, numWorkers?: number);
  62800. /** @hidden */
  62801. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  62802. /**
  62803. * Stop all async operations and release resources.
  62804. */
  62805. dispose(): void;
  62806. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  62807. /**
  62808. * Checks if the given data starts with a KTX2 file identifier.
  62809. * @param data the data to check
  62810. * @returns true if the data is a KTX2 file or false otherwise
  62811. */
  62812. static IsValid(data: ArrayBufferView): boolean;
  62813. }
  62814. }
  62815. declare module BABYLON {
  62816. /**
  62817. * Implementation of the KTX Texture Loader.
  62818. * @hidden
  62819. */
  62820. export class _KTXTextureLoader implements IInternalTextureLoader {
  62821. /**
  62822. * Defines whether the loader supports cascade loading the different faces.
  62823. */
  62824. readonly supportCascades: boolean;
  62825. /**
  62826. * This returns if the loader support the current file information.
  62827. * @param extension defines the file extension of the file being loaded
  62828. * @param mimeType defines the optional mime type of the file being loaded
  62829. * @returns true if the loader can load the specified file
  62830. */
  62831. canLoad(extension: string, mimeType?: string): boolean;
  62832. /**
  62833. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62834. * @param data contains the texture data
  62835. * @param texture defines the BabylonJS internal texture
  62836. * @param createPolynomials will be true if polynomials have been requested
  62837. * @param onLoad defines the callback to trigger once the texture is ready
  62838. * @param onError defines the callback to trigger in case of error
  62839. */
  62840. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62841. /**
  62842. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62843. * @param data contains the texture data
  62844. * @param texture defines the BabylonJS internal texture
  62845. * @param callback defines the method to call once ready to upload
  62846. */
  62847. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  62848. }
  62849. }
  62850. declare module BABYLON {
  62851. /** @hidden */
  62852. export var _forceSceneHelpersToBundle: boolean;
  62853. interface Scene {
  62854. /**
  62855. * Creates a default light for the scene.
  62856. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  62857. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  62858. */
  62859. createDefaultLight(replace?: boolean): void;
  62860. /**
  62861. * Creates a default camera for the scene.
  62862. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  62863. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62864. * @param replace has default false, when true replaces the active camera in the scene
  62865. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  62866. */
  62867. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62868. /**
  62869. * Creates a default camera and a default light.
  62870. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  62871. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62872. * @param replace has the default false, when true replaces the active camera/light in the scene
  62873. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  62874. */
  62875. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62876. /**
  62877. * Creates a new sky box
  62878. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  62879. * @param environmentTexture defines the texture to use as environment texture
  62880. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  62881. * @param scale defines the overall scale of the skybox
  62882. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  62883. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  62884. * @returns a new mesh holding the sky box
  62885. */
  62886. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  62887. /**
  62888. * Creates a new environment
  62889. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  62890. * @param options defines the options you can use to configure the environment
  62891. * @returns the new EnvironmentHelper
  62892. */
  62893. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  62894. /**
  62895. * Creates a new VREXperienceHelper
  62896. * @see https://doc.babylonjs.com/how_to/webvr_helper
  62897. * @param webVROptions defines the options used to create the new VREXperienceHelper
  62898. * @returns a new VREXperienceHelper
  62899. */
  62900. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  62901. /**
  62902. * Creates a new WebXRDefaultExperience
  62903. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  62904. * @param options experience options
  62905. * @returns a promise for a new WebXRDefaultExperience
  62906. */
  62907. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  62908. }
  62909. }
  62910. declare module BABYLON {
  62911. /**
  62912. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  62913. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  62914. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  62915. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62916. */
  62917. export class VideoDome extends TextureDome<VideoTexture> {
  62918. /**
  62919. * Define the video source as a Monoscopic panoramic 360 video.
  62920. */
  62921. static readonly MODE_MONOSCOPIC: number;
  62922. /**
  62923. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  62924. */
  62925. static readonly MODE_TOPBOTTOM: number;
  62926. /**
  62927. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  62928. */
  62929. static readonly MODE_SIDEBYSIDE: number;
  62930. /**
  62931. * Get the video texture associated with this video dome
  62932. */
  62933. get videoTexture(): VideoTexture;
  62934. /**
  62935. * Get the video mode of this dome
  62936. */
  62937. get videoMode(): number;
  62938. /**
  62939. * Set the video mode of this dome.
  62940. * @see textureMode
  62941. */
  62942. set videoMode(value: number);
  62943. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  62944. }
  62945. }
  62946. declare module BABYLON {
  62947. /**
  62948. * This class can be used to get instrumentation data from a Babylon engine
  62949. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62950. */
  62951. export class EngineInstrumentation implements IDisposable {
  62952. /**
  62953. * Define the instrumented engine.
  62954. */
  62955. engine: Engine;
  62956. private _captureGPUFrameTime;
  62957. private _gpuFrameTimeToken;
  62958. private _gpuFrameTime;
  62959. private _captureShaderCompilationTime;
  62960. private _shaderCompilationTime;
  62961. private _onBeginFrameObserver;
  62962. private _onEndFrameObserver;
  62963. private _onBeforeShaderCompilationObserver;
  62964. private _onAfterShaderCompilationObserver;
  62965. /**
  62966. * Gets the perf counter used for GPU frame time
  62967. */
  62968. get gpuFrameTimeCounter(): PerfCounter;
  62969. /**
  62970. * Gets the GPU frame time capture status
  62971. */
  62972. get captureGPUFrameTime(): boolean;
  62973. /**
  62974. * Enable or disable the GPU frame time capture
  62975. */
  62976. set captureGPUFrameTime(value: boolean);
  62977. /**
  62978. * Gets the perf counter used for shader compilation time
  62979. */
  62980. get shaderCompilationTimeCounter(): PerfCounter;
  62981. /**
  62982. * Gets the shader compilation time capture status
  62983. */
  62984. get captureShaderCompilationTime(): boolean;
  62985. /**
  62986. * Enable or disable the shader compilation time capture
  62987. */
  62988. set captureShaderCompilationTime(value: boolean);
  62989. /**
  62990. * Instantiates a new engine instrumentation.
  62991. * This class can be used to get instrumentation data from a Babylon engine
  62992. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62993. * @param engine Defines the engine to instrument
  62994. */
  62995. constructor(
  62996. /**
  62997. * Define the instrumented engine.
  62998. */
  62999. engine: Engine);
  63000. /**
  63001. * Dispose and release associated resources.
  63002. */
  63003. dispose(): void;
  63004. }
  63005. }
  63006. declare module BABYLON {
  63007. /**
  63008. * This class can be used to get instrumentation data from a Babylon engine
  63009. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  63010. */
  63011. export class SceneInstrumentation implements IDisposable {
  63012. /**
  63013. * Defines the scene to instrument
  63014. */
  63015. scene: Scene;
  63016. private _captureActiveMeshesEvaluationTime;
  63017. private _activeMeshesEvaluationTime;
  63018. private _captureRenderTargetsRenderTime;
  63019. private _renderTargetsRenderTime;
  63020. private _captureFrameTime;
  63021. private _frameTime;
  63022. private _captureRenderTime;
  63023. private _renderTime;
  63024. private _captureInterFrameTime;
  63025. private _interFrameTime;
  63026. private _captureParticlesRenderTime;
  63027. private _particlesRenderTime;
  63028. private _captureSpritesRenderTime;
  63029. private _spritesRenderTime;
  63030. private _capturePhysicsTime;
  63031. private _physicsTime;
  63032. private _captureAnimationsTime;
  63033. private _animationsTime;
  63034. private _captureCameraRenderTime;
  63035. private _cameraRenderTime;
  63036. private _onBeforeActiveMeshesEvaluationObserver;
  63037. private _onAfterActiveMeshesEvaluationObserver;
  63038. private _onBeforeRenderTargetsRenderObserver;
  63039. private _onAfterRenderTargetsRenderObserver;
  63040. private _onAfterRenderObserver;
  63041. private _onBeforeDrawPhaseObserver;
  63042. private _onAfterDrawPhaseObserver;
  63043. private _onBeforeAnimationsObserver;
  63044. private _onBeforeParticlesRenderingObserver;
  63045. private _onAfterParticlesRenderingObserver;
  63046. private _onBeforeSpritesRenderingObserver;
  63047. private _onAfterSpritesRenderingObserver;
  63048. private _onBeforePhysicsObserver;
  63049. private _onAfterPhysicsObserver;
  63050. private _onAfterAnimationsObserver;
  63051. private _onBeforeCameraRenderObserver;
  63052. private _onAfterCameraRenderObserver;
  63053. /**
  63054. * Gets the perf counter used for active meshes evaluation time
  63055. */
  63056. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  63057. /**
  63058. * Gets the active meshes evaluation time capture status
  63059. */
  63060. get captureActiveMeshesEvaluationTime(): boolean;
  63061. /**
  63062. * Enable or disable the active meshes evaluation time capture
  63063. */
  63064. set captureActiveMeshesEvaluationTime(value: boolean);
  63065. /**
  63066. * Gets the perf counter used for render targets render time
  63067. */
  63068. get renderTargetsRenderTimeCounter(): PerfCounter;
  63069. /**
  63070. * Gets the render targets render time capture status
  63071. */
  63072. get captureRenderTargetsRenderTime(): boolean;
  63073. /**
  63074. * Enable or disable the render targets render time capture
  63075. */
  63076. set captureRenderTargetsRenderTime(value: boolean);
  63077. /**
  63078. * Gets the perf counter used for particles render time
  63079. */
  63080. get particlesRenderTimeCounter(): PerfCounter;
  63081. /**
  63082. * Gets the particles render time capture status
  63083. */
  63084. get captureParticlesRenderTime(): boolean;
  63085. /**
  63086. * Enable or disable the particles render time capture
  63087. */
  63088. set captureParticlesRenderTime(value: boolean);
  63089. /**
  63090. * Gets the perf counter used for sprites render time
  63091. */
  63092. get spritesRenderTimeCounter(): PerfCounter;
  63093. /**
  63094. * Gets the sprites render time capture status
  63095. */
  63096. get captureSpritesRenderTime(): boolean;
  63097. /**
  63098. * Enable or disable the sprites render time capture
  63099. */
  63100. set captureSpritesRenderTime(value: boolean);
  63101. /**
  63102. * Gets the perf counter used for physics time
  63103. */
  63104. get physicsTimeCounter(): PerfCounter;
  63105. /**
  63106. * Gets the physics time capture status
  63107. */
  63108. get capturePhysicsTime(): boolean;
  63109. /**
  63110. * Enable or disable the physics time capture
  63111. */
  63112. set capturePhysicsTime(value: boolean);
  63113. /**
  63114. * Gets the perf counter used for animations time
  63115. */
  63116. get animationsTimeCounter(): PerfCounter;
  63117. /**
  63118. * Gets the animations time capture status
  63119. */
  63120. get captureAnimationsTime(): boolean;
  63121. /**
  63122. * Enable or disable the animations time capture
  63123. */
  63124. set captureAnimationsTime(value: boolean);
  63125. /**
  63126. * Gets the perf counter used for frame time capture
  63127. */
  63128. get frameTimeCounter(): PerfCounter;
  63129. /**
  63130. * Gets the frame time capture status
  63131. */
  63132. get captureFrameTime(): boolean;
  63133. /**
  63134. * Enable or disable the frame time capture
  63135. */
  63136. set captureFrameTime(value: boolean);
  63137. /**
  63138. * Gets the perf counter used for inter-frames time capture
  63139. */
  63140. get interFrameTimeCounter(): PerfCounter;
  63141. /**
  63142. * Gets the inter-frames time capture status
  63143. */
  63144. get captureInterFrameTime(): boolean;
  63145. /**
  63146. * Enable or disable the inter-frames time capture
  63147. */
  63148. set captureInterFrameTime(value: boolean);
  63149. /**
  63150. * Gets the perf counter used for render time capture
  63151. */
  63152. get renderTimeCounter(): PerfCounter;
  63153. /**
  63154. * Gets the render time capture status
  63155. */
  63156. get captureRenderTime(): boolean;
  63157. /**
  63158. * Enable or disable the render time capture
  63159. */
  63160. set captureRenderTime(value: boolean);
  63161. /**
  63162. * Gets the perf counter used for camera render time capture
  63163. */
  63164. get cameraRenderTimeCounter(): PerfCounter;
  63165. /**
  63166. * Gets the camera render time capture status
  63167. */
  63168. get captureCameraRenderTime(): boolean;
  63169. /**
  63170. * Enable or disable the camera render time capture
  63171. */
  63172. set captureCameraRenderTime(value: boolean);
  63173. /**
  63174. * Gets the perf counter used for draw calls
  63175. */
  63176. get drawCallsCounter(): PerfCounter;
  63177. /**
  63178. * Instantiates a new scene instrumentation.
  63179. * This class can be used to get instrumentation data from a Babylon engine
  63180. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  63181. * @param scene Defines the scene to instrument
  63182. */
  63183. constructor(
  63184. /**
  63185. * Defines the scene to instrument
  63186. */
  63187. scene: Scene);
  63188. /**
  63189. * Dispose and release associated resources.
  63190. */
  63191. dispose(): void;
  63192. }
  63193. }
  63194. declare module BABYLON {
  63195. /** @hidden */
  63196. export var glowMapGenerationPixelShader: {
  63197. name: string;
  63198. shader: string;
  63199. };
  63200. }
  63201. declare module BABYLON {
  63202. /** @hidden */
  63203. export var glowMapGenerationVertexShader: {
  63204. name: string;
  63205. shader: string;
  63206. };
  63207. }
  63208. declare module BABYLON {
  63209. /**
  63210. * Effect layer options. This helps customizing the behaviour
  63211. * of the effect layer.
  63212. */
  63213. export interface IEffectLayerOptions {
  63214. /**
  63215. * Multiplication factor apply to the canvas size to compute the render target size
  63216. * used to generated the objects (the smaller the faster).
  63217. */
  63218. mainTextureRatio: number;
  63219. /**
  63220. * Enforces a fixed size texture to ensure effect stability across devices.
  63221. */
  63222. mainTextureFixedSize?: number;
  63223. /**
  63224. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  63225. */
  63226. alphaBlendingMode: number;
  63227. /**
  63228. * The camera attached to the layer.
  63229. */
  63230. camera: Nullable<Camera>;
  63231. /**
  63232. * The rendering group to draw the layer in.
  63233. */
  63234. renderingGroupId: number;
  63235. }
  63236. /**
  63237. * The effect layer Helps adding post process effect blended with the main pass.
  63238. *
  63239. * This can be for instance use to generate glow or highlight effects on the scene.
  63240. *
  63241. * The effect layer class can not be used directly and is intented to inherited from to be
  63242. * customized per effects.
  63243. */
  63244. export abstract class EffectLayer {
  63245. private _vertexBuffers;
  63246. private _indexBuffer;
  63247. private _cachedDefines;
  63248. private _effectLayerMapGenerationEffect;
  63249. private _effectLayerOptions;
  63250. private _mergeEffect;
  63251. protected _scene: Scene;
  63252. protected _engine: Engine;
  63253. protected _maxSize: number;
  63254. protected _mainTextureDesiredSize: ISize;
  63255. protected _mainTexture: RenderTargetTexture;
  63256. protected _shouldRender: boolean;
  63257. protected _postProcesses: PostProcess[];
  63258. protected _textures: BaseTexture[];
  63259. protected _emissiveTextureAndColor: {
  63260. texture: Nullable<BaseTexture>;
  63261. color: Color4;
  63262. };
  63263. /**
  63264. * The name of the layer
  63265. */
  63266. name: string;
  63267. /**
  63268. * The clear color of the texture used to generate the glow map.
  63269. */
  63270. neutralColor: Color4;
  63271. /**
  63272. * Specifies whether the highlight layer is enabled or not.
  63273. */
  63274. isEnabled: boolean;
  63275. /**
  63276. * Gets the camera attached to the layer.
  63277. */
  63278. get camera(): Nullable<Camera>;
  63279. /**
  63280. * Gets the rendering group id the layer should render in.
  63281. */
  63282. get renderingGroupId(): number;
  63283. set renderingGroupId(renderingGroupId: number);
  63284. /**
  63285. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  63286. */
  63287. disableBoundingBoxesFromEffectLayer: boolean;
  63288. /**
  63289. * An event triggered when the effect layer has been disposed.
  63290. */
  63291. onDisposeObservable: Observable<EffectLayer>;
  63292. /**
  63293. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  63294. */
  63295. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  63296. /**
  63297. * An event triggered when the generated texture is being merged in the scene.
  63298. */
  63299. onBeforeComposeObservable: Observable<EffectLayer>;
  63300. /**
  63301. * An event triggered when the mesh is rendered into the effect render target.
  63302. */
  63303. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  63304. /**
  63305. * An event triggered after the mesh has been rendered into the effect render target.
  63306. */
  63307. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  63308. /**
  63309. * An event triggered when the generated texture has been merged in the scene.
  63310. */
  63311. onAfterComposeObservable: Observable<EffectLayer>;
  63312. /**
  63313. * An event triggered when the effect layer changes its size.
  63314. */
  63315. onSizeChangedObservable: Observable<EffectLayer>;
  63316. /** @hidden */
  63317. static _SceneComponentInitialization: (scene: Scene) => void;
  63318. /**
  63319. * Instantiates a new effect Layer and references it in the scene.
  63320. * @param name The name of the layer
  63321. * @param scene The scene to use the layer in
  63322. */
  63323. constructor(
  63324. /** The Friendly of the effect in the scene */
  63325. name: string, scene: Scene);
  63326. /**
  63327. * Get the effect name of the layer.
  63328. * @return The effect name
  63329. */
  63330. abstract getEffectName(): string;
  63331. /**
  63332. * Checks for the readiness of the element composing the layer.
  63333. * @param subMesh the mesh to check for
  63334. * @param useInstances specify whether or not to use instances to render the mesh
  63335. * @return true if ready otherwise, false
  63336. */
  63337. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63338. /**
  63339. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  63340. * @returns true if the effect requires stencil during the main canvas render pass.
  63341. */
  63342. abstract needStencil(): boolean;
  63343. /**
  63344. * Create the merge effect. This is the shader use to blit the information back
  63345. * to the main canvas at the end of the scene rendering.
  63346. * @returns The effect containing the shader used to merge the effect on the main canvas
  63347. */
  63348. protected abstract _createMergeEffect(): Effect;
  63349. /**
  63350. * Creates the render target textures and post processes used in the effect layer.
  63351. */
  63352. protected abstract _createTextureAndPostProcesses(): void;
  63353. /**
  63354. * Implementation specific of rendering the generating effect on the main canvas.
  63355. * @param effect The effect used to render through
  63356. */
  63357. protected abstract _internalRender(effect: Effect): void;
  63358. /**
  63359. * Sets the required values for both the emissive texture and and the main color.
  63360. */
  63361. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63362. /**
  63363. * Free any resources and references associated to a mesh.
  63364. * Internal use
  63365. * @param mesh The mesh to free.
  63366. */
  63367. abstract _disposeMesh(mesh: Mesh): void;
  63368. /**
  63369. * Serializes this layer (Glow or Highlight for example)
  63370. * @returns a serialized layer object
  63371. */
  63372. abstract serialize?(): any;
  63373. /**
  63374. * Initializes the effect layer with the required options.
  63375. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  63376. */
  63377. protected _init(options: Partial<IEffectLayerOptions>): void;
  63378. /**
  63379. * Generates the index buffer of the full screen quad blending to the main canvas.
  63380. */
  63381. private _generateIndexBuffer;
  63382. /**
  63383. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  63384. */
  63385. private _generateVertexBuffer;
  63386. /**
  63387. * Sets the main texture desired size which is the closest power of two
  63388. * of the engine canvas size.
  63389. */
  63390. private _setMainTextureSize;
  63391. /**
  63392. * Creates the main texture for the effect layer.
  63393. */
  63394. protected _createMainTexture(): void;
  63395. /**
  63396. * Adds specific effects defines.
  63397. * @param defines The defines to add specifics to.
  63398. */
  63399. protected _addCustomEffectDefines(defines: string[]): void;
  63400. /**
  63401. * Checks for the readiness of the element composing the layer.
  63402. * @param subMesh the mesh to check for
  63403. * @param useInstances specify whether or not to use instances to render the mesh
  63404. * @param emissiveTexture the associated emissive texture used to generate the glow
  63405. * @return true if ready otherwise, false
  63406. */
  63407. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  63408. /**
  63409. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  63410. */
  63411. render(): void;
  63412. /**
  63413. * Determine if a given mesh will be used in the current effect.
  63414. * @param mesh mesh to test
  63415. * @returns true if the mesh will be used
  63416. */
  63417. hasMesh(mesh: AbstractMesh): boolean;
  63418. /**
  63419. * Returns true if the layer contains information to display, otherwise false.
  63420. * @returns true if the glow layer should be rendered
  63421. */
  63422. shouldRender(): boolean;
  63423. /**
  63424. * Returns true if the mesh should render, otherwise false.
  63425. * @param mesh The mesh to render
  63426. * @returns true if it should render otherwise false
  63427. */
  63428. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  63429. /**
  63430. * Returns true if the mesh can be rendered, otherwise false.
  63431. * @param mesh The mesh to render
  63432. * @param material The material used on the mesh
  63433. * @returns true if it can be rendered otherwise false
  63434. */
  63435. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63436. /**
  63437. * Returns true if the mesh should render, otherwise false.
  63438. * @param mesh The mesh to render
  63439. * @returns true if it should render otherwise false
  63440. */
  63441. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  63442. /**
  63443. * Renders the submesh passed in parameter to the generation map.
  63444. */
  63445. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  63446. /**
  63447. * Defines whether the current material of the mesh should be use to render the effect.
  63448. * @param mesh defines the current mesh to render
  63449. */
  63450. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  63451. /**
  63452. * Rebuild the required buffers.
  63453. * @hidden Internal use only.
  63454. */
  63455. _rebuild(): void;
  63456. /**
  63457. * Dispose only the render target textures and post process.
  63458. */
  63459. private _disposeTextureAndPostProcesses;
  63460. /**
  63461. * Dispose the highlight layer and free resources.
  63462. */
  63463. dispose(): void;
  63464. /**
  63465. * Gets the class name of the effect layer
  63466. * @returns the string with the class name of the effect layer
  63467. */
  63468. getClassName(): string;
  63469. /**
  63470. * Creates an effect layer from parsed effect layer data
  63471. * @param parsedEffectLayer defines effect layer data
  63472. * @param scene defines the current scene
  63473. * @param rootUrl defines the root URL containing the effect layer information
  63474. * @returns a parsed effect Layer
  63475. */
  63476. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  63477. }
  63478. }
  63479. declare module BABYLON {
  63480. interface AbstractScene {
  63481. /**
  63482. * The list of effect layers (highlights/glow) added to the scene
  63483. * @see https://doc.babylonjs.com/how_to/highlight_layer
  63484. * @see https://doc.babylonjs.com/how_to/glow_layer
  63485. */
  63486. effectLayers: Array<EffectLayer>;
  63487. /**
  63488. * Removes the given effect layer from this scene.
  63489. * @param toRemove defines the effect layer to remove
  63490. * @returns the index of the removed effect layer
  63491. */
  63492. removeEffectLayer(toRemove: EffectLayer): number;
  63493. /**
  63494. * Adds the given effect layer to this scene
  63495. * @param newEffectLayer defines the effect layer to add
  63496. */
  63497. addEffectLayer(newEffectLayer: EffectLayer): void;
  63498. }
  63499. /**
  63500. * Defines the layer scene component responsible to manage any effect layers
  63501. * in a given scene.
  63502. */
  63503. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  63504. /**
  63505. * The component name helpful to identify the component in the list of scene components.
  63506. */
  63507. readonly name: string;
  63508. /**
  63509. * The scene the component belongs to.
  63510. */
  63511. scene: Scene;
  63512. private _engine;
  63513. private _renderEffects;
  63514. private _needStencil;
  63515. private _previousStencilState;
  63516. /**
  63517. * Creates a new instance of the component for the given scene
  63518. * @param scene Defines the scene to register the component in
  63519. */
  63520. constructor(scene: Scene);
  63521. /**
  63522. * Registers the component in a given scene
  63523. */
  63524. register(): void;
  63525. /**
  63526. * Rebuilds the elements related to this component in case of
  63527. * context lost for instance.
  63528. */
  63529. rebuild(): void;
  63530. /**
  63531. * Serializes the component data to the specified json object
  63532. * @param serializationObject The object to serialize to
  63533. */
  63534. serialize(serializationObject: any): void;
  63535. /**
  63536. * Adds all the elements from the container to the scene
  63537. * @param container the container holding the elements
  63538. */
  63539. addFromContainer(container: AbstractScene): void;
  63540. /**
  63541. * Removes all the elements in the container from the scene
  63542. * @param container contains the elements to remove
  63543. * @param dispose if the removed element should be disposed (default: false)
  63544. */
  63545. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63546. /**
  63547. * Disposes the component and the associated resources.
  63548. */
  63549. dispose(): void;
  63550. private _isReadyForMesh;
  63551. private _renderMainTexture;
  63552. private _setStencil;
  63553. private _setStencilBack;
  63554. private _draw;
  63555. private _drawCamera;
  63556. private _drawRenderingGroup;
  63557. }
  63558. }
  63559. declare module BABYLON {
  63560. /** @hidden */
  63561. export var glowMapMergePixelShader: {
  63562. name: string;
  63563. shader: string;
  63564. };
  63565. }
  63566. declare module BABYLON {
  63567. /** @hidden */
  63568. export var glowMapMergeVertexShader: {
  63569. name: string;
  63570. shader: string;
  63571. };
  63572. }
  63573. declare module BABYLON {
  63574. interface AbstractScene {
  63575. /**
  63576. * Return a the first highlight layer of the scene with a given name.
  63577. * @param name The name of the highlight layer to look for.
  63578. * @return The highlight layer if found otherwise null.
  63579. */
  63580. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  63581. }
  63582. /**
  63583. * Glow layer options. This helps customizing the behaviour
  63584. * of the glow layer.
  63585. */
  63586. export interface IGlowLayerOptions {
  63587. /**
  63588. * Multiplication factor apply to the canvas size to compute the render target size
  63589. * used to generated the glowing objects (the smaller the faster).
  63590. */
  63591. mainTextureRatio: number;
  63592. /**
  63593. * Enforces a fixed size texture to ensure resize independent blur.
  63594. */
  63595. mainTextureFixedSize?: number;
  63596. /**
  63597. * How big is the kernel of the blur texture.
  63598. */
  63599. blurKernelSize: number;
  63600. /**
  63601. * The camera attached to the layer.
  63602. */
  63603. camera: Nullable<Camera>;
  63604. /**
  63605. * Enable MSAA by choosing the number of samples.
  63606. */
  63607. mainTextureSamples?: number;
  63608. /**
  63609. * The rendering group to draw the layer in.
  63610. */
  63611. renderingGroupId: number;
  63612. }
  63613. /**
  63614. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  63615. *
  63616. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  63617. *
  63618. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  63619. */
  63620. export class GlowLayer extends EffectLayer {
  63621. /**
  63622. * Effect Name of the layer.
  63623. */
  63624. static readonly EffectName: string;
  63625. /**
  63626. * The default blur kernel size used for the glow.
  63627. */
  63628. static DefaultBlurKernelSize: number;
  63629. /**
  63630. * The default texture size ratio used for the glow.
  63631. */
  63632. static DefaultTextureRatio: number;
  63633. /**
  63634. * Sets the kernel size of the blur.
  63635. */
  63636. set blurKernelSize(value: number);
  63637. /**
  63638. * Gets the kernel size of the blur.
  63639. */
  63640. get blurKernelSize(): number;
  63641. /**
  63642. * Sets the glow intensity.
  63643. */
  63644. set intensity(value: number);
  63645. /**
  63646. * Gets the glow intensity.
  63647. */
  63648. get intensity(): number;
  63649. private _options;
  63650. private _intensity;
  63651. private _horizontalBlurPostprocess1;
  63652. private _verticalBlurPostprocess1;
  63653. private _horizontalBlurPostprocess2;
  63654. private _verticalBlurPostprocess2;
  63655. private _blurTexture1;
  63656. private _blurTexture2;
  63657. private _postProcesses1;
  63658. private _postProcesses2;
  63659. private _includedOnlyMeshes;
  63660. private _excludedMeshes;
  63661. private _meshesUsingTheirOwnMaterials;
  63662. /**
  63663. * Callback used to let the user override the color selection on a per mesh basis
  63664. */
  63665. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  63666. /**
  63667. * Callback used to let the user override the texture selection on a per mesh basis
  63668. */
  63669. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  63670. /**
  63671. * Instantiates a new glow Layer and references it to the scene.
  63672. * @param name The name of the layer
  63673. * @param scene The scene to use the layer in
  63674. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  63675. */
  63676. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  63677. /**
  63678. * Get the effect name of the layer.
  63679. * @return The effect name
  63680. */
  63681. getEffectName(): string;
  63682. /**
  63683. * Create the merge effect. This is the shader use to blit the information back
  63684. * to the main canvas at the end of the scene rendering.
  63685. */
  63686. protected _createMergeEffect(): Effect;
  63687. /**
  63688. * Creates the render target textures and post processes used in the glow layer.
  63689. */
  63690. protected _createTextureAndPostProcesses(): void;
  63691. /**
  63692. * Checks for the readiness of the element composing the layer.
  63693. * @param subMesh the mesh to check for
  63694. * @param useInstances specify whether or not to use instances to render the mesh
  63695. * @param emissiveTexture the associated emissive texture used to generate the glow
  63696. * @return true if ready otherwise, false
  63697. */
  63698. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63699. /**
  63700. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  63701. */
  63702. needStencil(): boolean;
  63703. /**
  63704. * Returns true if the mesh can be rendered, otherwise false.
  63705. * @param mesh The mesh to render
  63706. * @param material The material used on the mesh
  63707. * @returns true if it can be rendered otherwise false
  63708. */
  63709. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63710. /**
  63711. * Implementation specific of rendering the generating effect on the main canvas.
  63712. * @param effect The effect used to render through
  63713. */
  63714. protected _internalRender(effect: Effect): void;
  63715. /**
  63716. * Sets the required values for both the emissive texture and and the main color.
  63717. */
  63718. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63719. /**
  63720. * Returns true if the mesh should render, otherwise false.
  63721. * @param mesh The mesh to render
  63722. * @returns true if it should render otherwise false
  63723. */
  63724. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63725. /**
  63726. * Adds specific effects defines.
  63727. * @param defines The defines to add specifics to.
  63728. */
  63729. protected _addCustomEffectDefines(defines: string[]): void;
  63730. /**
  63731. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  63732. * @param mesh The mesh to exclude from the glow layer
  63733. */
  63734. addExcludedMesh(mesh: Mesh): void;
  63735. /**
  63736. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  63737. * @param mesh The mesh to remove
  63738. */
  63739. removeExcludedMesh(mesh: Mesh): void;
  63740. /**
  63741. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  63742. * @param mesh The mesh to include in the glow layer
  63743. */
  63744. addIncludedOnlyMesh(mesh: Mesh): void;
  63745. /**
  63746. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  63747. * @param mesh The mesh to remove
  63748. */
  63749. removeIncludedOnlyMesh(mesh: Mesh): void;
  63750. /**
  63751. * Determine if a given mesh will be used in the glow layer
  63752. * @param mesh The mesh to test
  63753. * @returns true if the mesh will be highlighted by the current glow layer
  63754. */
  63755. hasMesh(mesh: AbstractMesh): boolean;
  63756. /**
  63757. * Defines whether the current material of the mesh should be use to render the effect.
  63758. * @param mesh defines the current mesh to render
  63759. */
  63760. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  63761. /**
  63762. * Add a mesh to be rendered through its own material and not with emissive only.
  63763. * @param mesh The mesh for which we need to use its material
  63764. */
  63765. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  63766. /**
  63767. * Remove a mesh from being rendered through its own material and not with emissive only.
  63768. * @param mesh The mesh for which we need to not use its material
  63769. */
  63770. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  63771. /**
  63772. * Free any resources and references associated to a mesh.
  63773. * Internal use
  63774. * @param mesh The mesh to free.
  63775. * @hidden
  63776. */
  63777. _disposeMesh(mesh: Mesh): void;
  63778. /**
  63779. * Gets the class name of the effect layer
  63780. * @returns the string with the class name of the effect layer
  63781. */
  63782. getClassName(): string;
  63783. /**
  63784. * Serializes this glow layer
  63785. * @returns a serialized glow layer object
  63786. */
  63787. serialize(): any;
  63788. /**
  63789. * Creates a Glow Layer from parsed glow layer data
  63790. * @param parsedGlowLayer defines glow layer data
  63791. * @param scene defines the current scene
  63792. * @param rootUrl defines the root URL containing the glow layer information
  63793. * @returns a parsed Glow Layer
  63794. */
  63795. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  63796. }
  63797. }
  63798. declare module BABYLON {
  63799. /** @hidden */
  63800. export var glowBlurPostProcessPixelShader: {
  63801. name: string;
  63802. shader: string;
  63803. };
  63804. }
  63805. declare module BABYLON {
  63806. interface AbstractScene {
  63807. /**
  63808. * Return a the first highlight layer of the scene with a given name.
  63809. * @param name The name of the highlight layer to look for.
  63810. * @return The highlight layer if found otherwise null.
  63811. */
  63812. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  63813. }
  63814. /**
  63815. * Highlight layer options. This helps customizing the behaviour
  63816. * of the highlight layer.
  63817. */
  63818. export interface IHighlightLayerOptions {
  63819. /**
  63820. * Multiplication factor apply to the canvas size to compute the render target size
  63821. * used to generated the glowing objects (the smaller the faster).
  63822. */
  63823. mainTextureRatio: number;
  63824. /**
  63825. * Enforces a fixed size texture to ensure resize independent blur.
  63826. */
  63827. mainTextureFixedSize?: number;
  63828. /**
  63829. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  63830. * of the picture to blur (the smaller the faster).
  63831. */
  63832. blurTextureSizeRatio: number;
  63833. /**
  63834. * How big in texel of the blur texture is the vertical blur.
  63835. */
  63836. blurVerticalSize: number;
  63837. /**
  63838. * How big in texel of the blur texture is the horizontal blur.
  63839. */
  63840. blurHorizontalSize: number;
  63841. /**
  63842. * Alpha blending mode used to apply the blur. Default is combine.
  63843. */
  63844. alphaBlendingMode: number;
  63845. /**
  63846. * The camera attached to the layer.
  63847. */
  63848. camera: Nullable<Camera>;
  63849. /**
  63850. * Should we display highlight as a solid stroke?
  63851. */
  63852. isStroke?: boolean;
  63853. /**
  63854. * The rendering group to draw the layer in.
  63855. */
  63856. renderingGroupId: number;
  63857. }
  63858. /**
  63859. * The highlight layer Helps adding a glow effect around a mesh.
  63860. *
  63861. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  63862. * glowy meshes to your scene.
  63863. *
  63864. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  63865. */
  63866. export class HighlightLayer extends EffectLayer {
  63867. name: string;
  63868. /**
  63869. * Effect Name of the highlight layer.
  63870. */
  63871. static readonly EffectName: string;
  63872. /**
  63873. * The neutral color used during the preparation of the glow effect.
  63874. * This is black by default as the blend operation is a blend operation.
  63875. */
  63876. static NeutralColor: Color4;
  63877. /**
  63878. * Stencil value used for glowing meshes.
  63879. */
  63880. static GlowingMeshStencilReference: number;
  63881. /**
  63882. * Stencil value used for the other meshes in the scene.
  63883. */
  63884. static NormalMeshStencilReference: number;
  63885. /**
  63886. * Specifies whether or not the inner glow is ACTIVE in the layer.
  63887. */
  63888. innerGlow: boolean;
  63889. /**
  63890. * Specifies whether or not the outer glow is ACTIVE in the layer.
  63891. */
  63892. outerGlow: boolean;
  63893. /**
  63894. * Specifies the horizontal size of the blur.
  63895. */
  63896. set blurHorizontalSize(value: number);
  63897. /**
  63898. * Specifies the vertical size of the blur.
  63899. */
  63900. set blurVerticalSize(value: number);
  63901. /**
  63902. * Gets the horizontal size of the blur.
  63903. */
  63904. get blurHorizontalSize(): number;
  63905. /**
  63906. * Gets the vertical size of the blur.
  63907. */
  63908. get blurVerticalSize(): number;
  63909. /**
  63910. * An event triggered when the highlight layer is being blurred.
  63911. */
  63912. onBeforeBlurObservable: Observable<HighlightLayer>;
  63913. /**
  63914. * An event triggered when the highlight layer has been blurred.
  63915. */
  63916. onAfterBlurObservable: Observable<HighlightLayer>;
  63917. private _instanceGlowingMeshStencilReference;
  63918. private _options;
  63919. private _downSamplePostprocess;
  63920. private _horizontalBlurPostprocess;
  63921. private _verticalBlurPostprocess;
  63922. private _blurTexture;
  63923. private _meshes;
  63924. private _excludedMeshes;
  63925. /**
  63926. * Instantiates a new highlight Layer and references it to the scene..
  63927. * @param name The name of the layer
  63928. * @param scene The scene to use the layer in
  63929. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  63930. */
  63931. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  63932. /**
  63933. * Get the effect name of the layer.
  63934. * @return The effect name
  63935. */
  63936. getEffectName(): string;
  63937. /**
  63938. * Create the merge effect. This is the shader use to blit the information back
  63939. * to the main canvas at the end of the scene rendering.
  63940. */
  63941. protected _createMergeEffect(): Effect;
  63942. /**
  63943. * Creates the render target textures and post processes used in the highlight layer.
  63944. */
  63945. protected _createTextureAndPostProcesses(): void;
  63946. /**
  63947. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  63948. */
  63949. needStencil(): boolean;
  63950. /**
  63951. * Checks for the readiness of the element composing the layer.
  63952. * @param subMesh the mesh to check for
  63953. * @param useInstances specify wether or not to use instances to render the mesh
  63954. * @param emissiveTexture the associated emissive texture used to generate the glow
  63955. * @return true if ready otherwise, false
  63956. */
  63957. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63958. /**
  63959. * Implementation specific of rendering the generating effect on the main canvas.
  63960. * @param effect The effect used to render through
  63961. */
  63962. protected _internalRender(effect: Effect): void;
  63963. /**
  63964. * Returns true if the layer contains information to display, otherwise false.
  63965. */
  63966. shouldRender(): boolean;
  63967. /**
  63968. * Returns true if the mesh should render, otherwise false.
  63969. * @param mesh The mesh to render
  63970. * @returns true if it should render otherwise false
  63971. */
  63972. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63973. /**
  63974. * Returns true if the mesh can be rendered, otherwise false.
  63975. * @param mesh The mesh to render
  63976. * @param material The material used on the mesh
  63977. * @returns true if it can be rendered otherwise false
  63978. */
  63979. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63980. /**
  63981. * Adds specific effects defines.
  63982. * @param defines The defines to add specifics to.
  63983. */
  63984. protected _addCustomEffectDefines(defines: string[]): void;
  63985. /**
  63986. * Sets the required values for both the emissive texture and and the main color.
  63987. */
  63988. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63989. /**
  63990. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  63991. * @param mesh The mesh to exclude from the highlight layer
  63992. */
  63993. addExcludedMesh(mesh: Mesh): void;
  63994. /**
  63995. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  63996. * @param mesh The mesh to highlight
  63997. */
  63998. removeExcludedMesh(mesh: Mesh): void;
  63999. /**
  64000. * Determine if a given mesh will be highlighted by the current HighlightLayer
  64001. * @param mesh mesh to test
  64002. * @returns true if the mesh will be highlighted by the current HighlightLayer
  64003. */
  64004. hasMesh(mesh: AbstractMesh): boolean;
  64005. /**
  64006. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  64007. * @param mesh The mesh to highlight
  64008. * @param color The color of the highlight
  64009. * @param glowEmissiveOnly Extract the glow from the emissive texture
  64010. */
  64011. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  64012. /**
  64013. * Remove a mesh from the highlight layer in order to make it stop glowing.
  64014. * @param mesh The mesh to highlight
  64015. */
  64016. removeMesh(mesh: Mesh): void;
  64017. /**
  64018. * Remove all the meshes currently referenced in the highlight layer
  64019. */
  64020. removeAllMeshes(): void;
  64021. /**
  64022. * Force the stencil to the normal expected value for none glowing parts
  64023. */
  64024. private _defaultStencilReference;
  64025. /**
  64026. * Free any resources and references associated to a mesh.
  64027. * Internal use
  64028. * @param mesh The mesh to free.
  64029. * @hidden
  64030. */
  64031. _disposeMesh(mesh: Mesh): void;
  64032. /**
  64033. * Dispose the highlight layer and free resources.
  64034. */
  64035. dispose(): void;
  64036. /**
  64037. * Gets the class name of the effect layer
  64038. * @returns the string with the class name of the effect layer
  64039. */
  64040. getClassName(): string;
  64041. /**
  64042. * Serializes this Highlight layer
  64043. * @returns a serialized Highlight layer object
  64044. */
  64045. serialize(): any;
  64046. /**
  64047. * Creates a Highlight layer from parsed Highlight layer data
  64048. * @param parsedHightlightLayer defines the Highlight layer data
  64049. * @param scene defines the current scene
  64050. * @param rootUrl defines the root URL containing the Highlight layer information
  64051. * @returns a parsed Highlight layer
  64052. */
  64053. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  64054. }
  64055. }
  64056. declare module BABYLON {
  64057. interface AbstractScene {
  64058. /**
  64059. * The list of layers (background and foreground) of the scene
  64060. */
  64061. layers: Array<Layer>;
  64062. }
  64063. /**
  64064. * Defines the layer scene component responsible to manage any layers
  64065. * in a given scene.
  64066. */
  64067. export class LayerSceneComponent implements ISceneComponent {
  64068. /**
  64069. * The component name helpful to identify the component in the list of scene components.
  64070. */
  64071. readonly name: string;
  64072. /**
  64073. * The scene the component belongs to.
  64074. */
  64075. scene: Scene;
  64076. private _engine;
  64077. /**
  64078. * Creates a new instance of the component for the given scene
  64079. * @param scene Defines the scene to register the component in
  64080. */
  64081. constructor(scene: Scene);
  64082. /**
  64083. * Registers the component in a given scene
  64084. */
  64085. register(): void;
  64086. /**
  64087. * Rebuilds the elements related to this component in case of
  64088. * context lost for instance.
  64089. */
  64090. rebuild(): void;
  64091. /**
  64092. * Disposes the component and the associated resources.
  64093. */
  64094. dispose(): void;
  64095. private _draw;
  64096. private _drawCameraPredicate;
  64097. private _drawCameraBackground;
  64098. private _drawCameraForeground;
  64099. private _drawRenderTargetPredicate;
  64100. private _drawRenderTargetBackground;
  64101. private _drawRenderTargetForeground;
  64102. /**
  64103. * Adds all the elements from the container to the scene
  64104. * @param container the container holding the elements
  64105. */
  64106. addFromContainer(container: AbstractScene): void;
  64107. /**
  64108. * Removes all the elements in the container from the scene
  64109. * @param container contains the elements to remove
  64110. * @param dispose if the removed element should be disposed (default: false)
  64111. */
  64112. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64113. }
  64114. }
  64115. declare module BABYLON {
  64116. /** @hidden */
  64117. export var layerPixelShader: {
  64118. name: string;
  64119. shader: string;
  64120. };
  64121. }
  64122. declare module BABYLON {
  64123. /** @hidden */
  64124. export var layerVertexShader: {
  64125. name: string;
  64126. shader: string;
  64127. };
  64128. }
  64129. declare module BABYLON {
  64130. /**
  64131. * This represents a full screen 2d layer.
  64132. * This can be useful to display a picture in the background of your scene for instance.
  64133. * @see https://www.babylonjs-playground.com/#08A2BS#1
  64134. */
  64135. export class Layer {
  64136. /**
  64137. * Define the name of the layer.
  64138. */
  64139. name: string;
  64140. /**
  64141. * Define the texture the layer should display.
  64142. */
  64143. texture: Nullable<Texture>;
  64144. /**
  64145. * Is the layer in background or foreground.
  64146. */
  64147. isBackground: boolean;
  64148. /**
  64149. * Define the color of the layer (instead of texture).
  64150. */
  64151. color: Color4;
  64152. /**
  64153. * Define the scale of the layer in order to zoom in out of the texture.
  64154. */
  64155. scale: Vector2;
  64156. /**
  64157. * Define an offset for the layer in order to shift the texture.
  64158. */
  64159. offset: Vector2;
  64160. /**
  64161. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  64162. */
  64163. alphaBlendingMode: number;
  64164. /**
  64165. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  64166. * Alpha test will not mix with the background color in case of transparency.
  64167. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  64168. */
  64169. alphaTest: boolean;
  64170. /**
  64171. * Define a mask to restrict the layer to only some of the scene cameras.
  64172. */
  64173. layerMask: number;
  64174. /**
  64175. * Define the list of render target the layer is visible into.
  64176. */
  64177. renderTargetTextures: RenderTargetTexture[];
  64178. /**
  64179. * Define if the layer is only used in renderTarget or if it also
  64180. * renders in the main frame buffer of the canvas.
  64181. */
  64182. renderOnlyInRenderTargetTextures: boolean;
  64183. private _scene;
  64184. private _vertexBuffers;
  64185. private _indexBuffer;
  64186. private _effect;
  64187. private _previousDefines;
  64188. /**
  64189. * An event triggered when the layer is disposed.
  64190. */
  64191. onDisposeObservable: Observable<Layer>;
  64192. private _onDisposeObserver;
  64193. /**
  64194. * Back compatibility with callback before the onDisposeObservable existed.
  64195. * The set callback will be triggered when the layer has been disposed.
  64196. */
  64197. set onDispose(callback: () => void);
  64198. /**
  64199. * An event triggered before rendering the scene
  64200. */
  64201. onBeforeRenderObservable: Observable<Layer>;
  64202. private _onBeforeRenderObserver;
  64203. /**
  64204. * Back compatibility with callback before the onBeforeRenderObservable existed.
  64205. * The set callback will be triggered just before rendering the layer.
  64206. */
  64207. set onBeforeRender(callback: () => void);
  64208. /**
  64209. * An event triggered after rendering the scene
  64210. */
  64211. onAfterRenderObservable: Observable<Layer>;
  64212. private _onAfterRenderObserver;
  64213. /**
  64214. * Back compatibility with callback before the onAfterRenderObservable existed.
  64215. * The set callback will be triggered just after rendering the layer.
  64216. */
  64217. set onAfterRender(callback: () => void);
  64218. /**
  64219. * Instantiates a new layer.
  64220. * This represents a full screen 2d layer.
  64221. * This can be useful to display a picture in the background of your scene for instance.
  64222. * @see https://www.babylonjs-playground.com/#08A2BS#1
  64223. * @param name Define the name of the layer in the scene
  64224. * @param imgUrl Define the url of the texture to display in the layer
  64225. * @param scene Define the scene the layer belongs to
  64226. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  64227. * @param color Defines a color for the layer
  64228. */
  64229. constructor(
  64230. /**
  64231. * Define the name of the layer.
  64232. */
  64233. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  64234. private _createIndexBuffer;
  64235. /** @hidden */
  64236. _rebuild(): void;
  64237. /**
  64238. * Renders the layer in the scene.
  64239. */
  64240. render(): void;
  64241. /**
  64242. * Disposes and releases the associated resources.
  64243. */
  64244. dispose(): void;
  64245. }
  64246. }
  64247. declare module BABYLON {
  64248. /** @hidden */
  64249. export var lensFlarePixelShader: {
  64250. name: string;
  64251. shader: string;
  64252. };
  64253. }
  64254. declare module BABYLON {
  64255. /** @hidden */
  64256. export var lensFlareVertexShader: {
  64257. name: string;
  64258. shader: string;
  64259. };
  64260. }
  64261. declare module BABYLON {
  64262. /**
  64263. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  64264. * It is usually composed of several `lensFlare`.
  64265. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64266. */
  64267. export class LensFlareSystem {
  64268. /**
  64269. * Define the name of the lens flare system
  64270. */
  64271. name: string;
  64272. /**
  64273. * List of lens flares used in this system.
  64274. */
  64275. lensFlares: LensFlare[];
  64276. /**
  64277. * Define a limit from the border the lens flare can be visible.
  64278. */
  64279. borderLimit: number;
  64280. /**
  64281. * Define a viewport border we do not want to see the lens flare in.
  64282. */
  64283. viewportBorder: number;
  64284. /**
  64285. * Define a predicate which could limit the list of meshes able to occlude the effect.
  64286. */
  64287. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  64288. /**
  64289. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  64290. */
  64291. layerMask: number;
  64292. /**
  64293. * Define the id of the lens flare system in the scene.
  64294. * (equal to name by default)
  64295. */
  64296. id: string;
  64297. private _scene;
  64298. private _emitter;
  64299. private _vertexBuffers;
  64300. private _indexBuffer;
  64301. private _effect;
  64302. private _positionX;
  64303. private _positionY;
  64304. private _isEnabled;
  64305. /** @hidden */
  64306. static _SceneComponentInitialization: (scene: Scene) => void;
  64307. /**
  64308. * Instantiates a lens flare system.
  64309. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  64310. * It is usually composed of several `lensFlare`.
  64311. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64312. * @param name Define the name of the lens flare system in the scene
  64313. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  64314. * @param scene Define the scene the lens flare system belongs to
  64315. */
  64316. constructor(
  64317. /**
  64318. * Define the name of the lens flare system
  64319. */
  64320. name: string, emitter: any, scene: Scene);
  64321. /**
  64322. * Define if the lens flare system is enabled.
  64323. */
  64324. get isEnabled(): boolean;
  64325. set isEnabled(value: boolean);
  64326. /**
  64327. * Get the scene the effects belongs to.
  64328. * @returns the scene holding the lens flare system
  64329. */
  64330. getScene(): Scene;
  64331. /**
  64332. * Get the emitter of the lens flare system.
  64333. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  64334. * @returns the emitter of the lens flare system
  64335. */
  64336. getEmitter(): any;
  64337. /**
  64338. * Set the emitter of the lens flare system.
  64339. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  64340. * @param newEmitter Define the new emitter of the system
  64341. */
  64342. setEmitter(newEmitter: any): void;
  64343. /**
  64344. * Get the lens flare system emitter position.
  64345. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  64346. * @returns the position
  64347. */
  64348. getEmitterPosition(): Vector3;
  64349. /**
  64350. * @hidden
  64351. */
  64352. computeEffectivePosition(globalViewport: Viewport): boolean;
  64353. /** @hidden */
  64354. _isVisible(): boolean;
  64355. /**
  64356. * @hidden
  64357. */
  64358. render(): boolean;
  64359. /**
  64360. * Dispose and release the lens flare with its associated resources.
  64361. */
  64362. dispose(): void;
  64363. /**
  64364. * Parse a lens flare system from a JSON representation
  64365. * @param parsedLensFlareSystem Define the JSON to parse
  64366. * @param scene Define the scene the parsed system should be instantiated in
  64367. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  64368. * @returns the parsed system
  64369. */
  64370. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  64371. /**
  64372. * Serialize the current Lens Flare System into a JSON representation.
  64373. * @returns the serialized JSON
  64374. */
  64375. serialize(): any;
  64376. }
  64377. }
  64378. declare module BABYLON {
  64379. /**
  64380. * This represents one of the lens effect in a `lensFlareSystem`.
  64381. * It controls one of the individual texture used in the effect.
  64382. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64383. */
  64384. export class LensFlare {
  64385. /**
  64386. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  64387. */
  64388. size: number;
  64389. /**
  64390. * 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.
  64391. */
  64392. position: number;
  64393. /**
  64394. * Define the lens color.
  64395. */
  64396. color: Color3;
  64397. /**
  64398. * Define the lens texture.
  64399. */
  64400. texture: Nullable<Texture>;
  64401. /**
  64402. * Define the alpha mode to render this particular lens.
  64403. */
  64404. alphaMode: number;
  64405. private _system;
  64406. /**
  64407. * Creates a new Lens Flare.
  64408. * This represents one of the lens effect in a `lensFlareSystem`.
  64409. * It controls one of the individual texture used in the effect.
  64410. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64411. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  64412. * @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.
  64413. * @param color Define the lens color
  64414. * @param imgUrl Define the lens texture url
  64415. * @param system Define the `lensFlareSystem` this flare is part of
  64416. * @returns The newly created Lens Flare
  64417. */
  64418. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  64419. /**
  64420. * Instantiates a new Lens Flare.
  64421. * This represents one of the lens effect in a `lensFlareSystem`.
  64422. * It controls one of the individual texture used in the effect.
  64423. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64424. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  64425. * @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.
  64426. * @param color Define the lens color
  64427. * @param imgUrl Define the lens texture url
  64428. * @param system Define the `lensFlareSystem` this flare is part of
  64429. */
  64430. constructor(
  64431. /**
  64432. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  64433. */
  64434. size: number,
  64435. /**
  64436. * 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.
  64437. */
  64438. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  64439. /**
  64440. * Dispose and release the lens flare with its associated resources.
  64441. */
  64442. dispose(): void;
  64443. }
  64444. }
  64445. declare module BABYLON {
  64446. interface AbstractScene {
  64447. /**
  64448. * The list of lens flare system added to the scene
  64449. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64450. */
  64451. lensFlareSystems: Array<LensFlareSystem>;
  64452. /**
  64453. * Removes the given lens flare system from this scene.
  64454. * @param toRemove The lens flare system to remove
  64455. * @returns The index of the removed lens flare system
  64456. */
  64457. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  64458. /**
  64459. * Adds the given lens flare system to this scene
  64460. * @param newLensFlareSystem The lens flare system to add
  64461. */
  64462. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  64463. /**
  64464. * Gets a lens flare system using its name
  64465. * @param name defines the name to look for
  64466. * @returns the lens flare system or null if not found
  64467. */
  64468. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  64469. /**
  64470. * Gets a lens flare system using its id
  64471. * @param id defines the id to look for
  64472. * @returns the lens flare system or null if not found
  64473. */
  64474. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  64475. }
  64476. /**
  64477. * Defines the lens flare scene component responsible to manage any lens flares
  64478. * in a given scene.
  64479. */
  64480. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  64481. /**
  64482. * The component name helpful to identify the component in the list of scene components.
  64483. */
  64484. readonly name: string;
  64485. /**
  64486. * The scene the component belongs to.
  64487. */
  64488. scene: Scene;
  64489. /**
  64490. * Creates a new instance of the component for the given scene
  64491. * @param scene Defines the scene to register the component in
  64492. */
  64493. constructor(scene: Scene);
  64494. /**
  64495. * Registers the component in a given scene
  64496. */
  64497. register(): void;
  64498. /**
  64499. * Rebuilds the elements related to this component in case of
  64500. * context lost for instance.
  64501. */
  64502. rebuild(): void;
  64503. /**
  64504. * Adds all the elements from the container to the scene
  64505. * @param container the container holding the elements
  64506. */
  64507. addFromContainer(container: AbstractScene): void;
  64508. /**
  64509. * Removes all the elements in the container from the scene
  64510. * @param container contains the elements to remove
  64511. * @param dispose if the removed element should be disposed (default: false)
  64512. */
  64513. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64514. /**
  64515. * Serializes the component data to the specified json object
  64516. * @param serializationObject The object to serialize to
  64517. */
  64518. serialize(serializationObject: any): void;
  64519. /**
  64520. * Disposes the component and the associated resources.
  64521. */
  64522. dispose(): void;
  64523. private _draw;
  64524. }
  64525. }
  64526. declare module BABYLON {
  64527. /** @hidden */
  64528. export var depthPixelShader: {
  64529. name: string;
  64530. shader: string;
  64531. };
  64532. }
  64533. declare module BABYLON {
  64534. /** @hidden */
  64535. export var depthVertexShader: {
  64536. name: string;
  64537. shader: string;
  64538. };
  64539. }
  64540. declare module BABYLON {
  64541. /**
  64542. * This represents a depth renderer in Babylon.
  64543. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64544. */
  64545. export class DepthRenderer {
  64546. private _scene;
  64547. private _depthMap;
  64548. private _effect;
  64549. private readonly _storeNonLinearDepth;
  64550. private readonly _clearColor;
  64551. /** Get if the depth renderer is using packed depth or not */
  64552. readonly isPacked: boolean;
  64553. private _cachedDefines;
  64554. private _camera;
  64555. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  64556. enabled: boolean;
  64557. /**
  64558. * Specifies that the depth renderer will only be used within
  64559. * the camera it is created for.
  64560. * This can help forcing its rendering during the camera processing.
  64561. */
  64562. useOnlyInActiveCamera: boolean;
  64563. /** @hidden */
  64564. static _SceneComponentInitialization: (scene: Scene) => void;
  64565. /**
  64566. * Instantiates a depth renderer
  64567. * @param scene The scene the renderer belongs to
  64568. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64569. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64570. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64571. */
  64572. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64573. /**
  64574. * Creates the depth rendering effect and checks if the effect is ready.
  64575. * @param subMesh The submesh to be used to render the depth map of
  64576. * @param useInstances If multiple world instances should be used
  64577. * @returns if the depth renderer is ready to render the depth map
  64578. */
  64579. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64580. /**
  64581. * Gets the texture which the depth map will be written to.
  64582. * @returns The depth map texture
  64583. */
  64584. getDepthMap(): RenderTargetTexture;
  64585. /**
  64586. * Disposes of the depth renderer.
  64587. */
  64588. dispose(): void;
  64589. }
  64590. }
  64591. declare module BABYLON {
  64592. /** @hidden */
  64593. export var minmaxReduxPixelShader: {
  64594. name: string;
  64595. shader: string;
  64596. };
  64597. }
  64598. declare module BABYLON {
  64599. /**
  64600. * This class computes a min/max reduction from a texture: it means it computes the minimum
  64601. * and maximum values from all values of the texture.
  64602. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  64603. * The source values are read from the red channel of the texture.
  64604. */
  64605. export class MinMaxReducer {
  64606. /**
  64607. * Observable triggered when the computation has been performed
  64608. */
  64609. onAfterReductionPerformed: Observable<{
  64610. min: number;
  64611. max: number;
  64612. }>;
  64613. protected _camera: Camera;
  64614. protected _sourceTexture: Nullable<RenderTargetTexture>;
  64615. protected _reductionSteps: Nullable<Array<PostProcess>>;
  64616. protected _postProcessManager: PostProcessManager;
  64617. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  64618. protected _forceFullscreenViewport: boolean;
  64619. /**
  64620. * Creates a min/max reducer
  64621. * @param camera The camera to use for the post processes
  64622. */
  64623. constructor(camera: Camera);
  64624. /**
  64625. * Gets the texture used to read the values from.
  64626. */
  64627. get sourceTexture(): Nullable<RenderTargetTexture>;
  64628. /**
  64629. * Sets the source texture to read the values from.
  64630. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  64631. * because in such textures '1' value must not be taken into account to compute the maximum
  64632. * as this value is used to clear the texture.
  64633. * Note that the computation is not activated by calling this function, you must call activate() for that!
  64634. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  64635. * @param depthRedux Indicates if the texture is a depth texture or not
  64636. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  64637. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64638. */
  64639. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64640. /**
  64641. * Defines the refresh rate of the computation.
  64642. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64643. */
  64644. get refreshRate(): number;
  64645. set refreshRate(value: number);
  64646. protected _activated: boolean;
  64647. /**
  64648. * Gets the activation status of the reducer
  64649. */
  64650. get activated(): boolean;
  64651. /**
  64652. * Activates the reduction computation.
  64653. * When activated, the observers registered in onAfterReductionPerformed are
  64654. * called after the computation is performed
  64655. */
  64656. activate(): void;
  64657. /**
  64658. * Deactivates the reduction computation.
  64659. */
  64660. deactivate(): void;
  64661. /**
  64662. * Disposes the min/max reducer
  64663. * @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.
  64664. */
  64665. dispose(disposeAll?: boolean): void;
  64666. }
  64667. }
  64668. declare module BABYLON {
  64669. /**
  64670. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  64671. */
  64672. export class DepthReducer extends MinMaxReducer {
  64673. private _depthRenderer;
  64674. private _depthRendererId;
  64675. /**
  64676. * Gets the depth renderer used for the computation.
  64677. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  64678. */
  64679. get depthRenderer(): Nullable<DepthRenderer>;
  64680. /**
  64681. * Creates a depth reducer
  64682. * @param camera The camera used to render the depth texture
  64683. */
  64684. constructor(camera: Camera);
  64685. /**
  64686. * Sets the depth renderer to use to generate the depth map
  64687. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  64688. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  64689. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64690. */
  64691. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  64692. /** @hidden */
  64693. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64694. /**
  64695. * Activates the reduction computation.
  64696. * When activated, the observers registered in onAfterReductionPerformed are
  64697. * called after the computation is performed
  64698. */
  64699. activate(): void;
  64700. /**
  64701. * Deactivates the reduction computation.
  64702. */
  64703. deactivate(): void;
  64704. /**
  64705. * Disposes the depth reducer
  64706. * @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.
  64707. */
  64708. dispose(disposeAll?: boolean): void;
  64709. }
  64710. }
  64711. declare module BABYLON {
  64712. /**
  64713. * A CSM implementation allowing casting shadows on large scenes.
  64714. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64715. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  64716. */
  64717. export class CascadedShadowGenerator extends ShadowGenerator {
  64718. private static readonly frustumCornersNDCSpace;
  64719. /**
  64720. * Name of the CSM class
  64721. */
  64722. static CLASSNAME: string;
  64723. /**
  64724. * Defines the default number of cascades used by the CSM.
  64725. */
  64726. static readonly DEFAULT_CASCADES_COUNT: number;
  64727. /**
  64728. * Defines the minimum number of cascades used by the CSM.
  64729. */
  64730. static readonly MIN_CASCADES_COUNT: number;
  64731. /**
  64732. * Defines the maximum number of cascades used by the CSM.
  64733. */
  64734. static readonly MAX_CASCADES_COUNT: number;
  64735. protected _validateFilter(filter: number): number;
  64736. /**
  64737. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  64738. */
  64739. penumbraDarkness: number;
  64740. private _numCascades;
  64741. /**
  64742. * Gets or set the number of cascades used by the CSM.
  64743. */
  64744. get numCascades(): number;
  64745. set numCascades(value: number);
  64746. /**
  64747. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  64748. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  64749. */
  64750. stabilizeCascades: boolean;
  64751. private _freezeShadowCastersBoundingInfo;
  64752. private _freezeShadowCastersBoundingInfoObservable;
  64753. /**
  64754. * Enables or disables the shadow casters bounding info computation.
  64755. * If your shadow casters don't move, you can disable this feature.
  64756. * If it is enabled, the bounding box computation is done every frame.
  64757. */
  64758. get freezeShadowCastersBoundingInfo(): boolean;
  64759. set freezeShadowCastersBoundingInfo(freeze: boolean);
  64760. private _scbiMin;
  64761. private _scbiMax;
  64762. protected _computeShadowCastersBoundingInfo(): void;
  64763. protected _shadowCastersBoundingInfo: BoundingInfo;
  64764. /**
  64765. * Gets or sets the shadow casters bounding info.
  64766. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  64767. * so that the system won't overwrite the bounds you provide
  64768. */
  64769. get shadowCastersBoundingInfo(): BoundingInfo;
  64770. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  64771. protected _breaksAreDirty: boolean;
  64772. protected _minDistance: number;
  64773. protected _maxDistance: number;
  64774. /**
  64775. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  64776. *
  64777. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  64778. * If you don't know these values, simply leave them to their defaults and don't call this function.
  64779. * @param min minimal distance for the breaks (default to 0.)
  64780. * @param max maximal distance for the breaks (default to 1.)
  64781. */
  64782. setMinMaxDistance(min: number, max: number): void;
  64783. /** Gets the minimal distance used in the cascade break computation */
  64784. get minDistance(): number;
  64785. /** Gets the maximal distance used in the cascade break computation */
  64786. get maxDistance(): number;
  64787. /**
  64788. * Gets the class name of that object
  64789. * @returns "CascadedShadowGenerator"
  64790. */
  64791. getClassName(): string;
  64792. private _cascadeMinExtents;
  64793. private _cascadeMaxExtents;
  64794. /**
  64795. * Gets a cascade minimum extents
  64796. * @param cascadeIndex index of the cascade
  64797. * @returns the minimum cascade extents
  64798. */
  64799. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  64800. /**
  64801. * Gets a cascade maximum extents
  64802. * @param cascadeIndex index of the cascade
  64803. * @returns the maximum cascade extents
  64804. */
  64805. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  64806. private _cascades;
  64807. private _currentLayer;
  64808. private _viewSpaceFrustumsZ;
  64809. private _viewMatrices;
  64810. private _projectionMatrices;
  64811. private _transformMatrices;
  64812. private _transformMatricesAsArray;
  64813. private _frustumLengths;
  64814. private _lightSizeUVCorrection;
  64815. private _depthCorrection;
  64816. private _frustumCornersWorldSpace;
  64817. private _frustumCenter;
  64818. private _shadowCameraPos;
  64819. private _shadowMaxZ;
  64820. /**
  64821. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  64822. * It defaults to camera.maxZ
  64823. */
  64824. get shadowMaxZ(): number;
  64825. /**
  64826. * Sets the shadow max z distance.
  64827. */
  64828. set shadowMaxZ(value: number);
  64829. protected _debug: boolean;
  64830. /**
  64831. * Gets or sets the debug flag.
  64832. * When enabled, the cascades are materialized by different colors on the screen.
  64833. */
  64834. get debug(): boolean;
  64835. set debug(dbg: boolean);
  64836. private _depthClamp;
  64837. /**
  64838. * Gets or sets the depth clamping value.
  64839. *
  64840. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  64841. * to account for the shadow casters far away.
  64842. *
  64843. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  64844. */
  64845. get depthClamp(): boolean;
  64846. set depthClamp(value: boolean);
  64847. private _cascadeBlendPercentage;
  64848. /**
  64849. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  64850. * It defaults to 0.1 (10% blending).
  64851. */
  64852. get cascadeBlendPercentage(): number;
  64853. set cascadeBlendPercentage(value: number);
  64854. private _lambda;
  64855. /**
  64856. * Gets or set the lambda parameter.
  64857. * This parameter is used to split the camera frustum and create the cascades.
  64858. * 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.
  64859. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  64860. */
  64861. get lambda(): number;
  64862. set lambda(value: number);
  64863. /**
  64864. * Gets the view matrix corresponding to a given cascade
  64865. * @param cascadeNum cascade to retrieve the view matrix from
  64866. * @returns the cascade view matrix
  64867. */
  64868. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  64869. /**
  64870. * Gets the projection matrix corresponding to a given cascade
  64871. * @param cascadeNum cascade to retrieve the projection matrix from
  64872. * @returns the cascade projection matrix
  64873. */
  64874. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  64875. /**
  64876. * Gets the transformation matrix corresponding to a given cascade
  64877. * @param cascadeNum cascade to retrieve the transformation matrix from
  64878. * @returns the cascade transformation matrix
  64879. */
  64880. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  64881. private _depthRenderer;
  64882. /**
  64883. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  64884. *
  64885. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  64886. *
  64887. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  64888. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  64889. * @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
  64890. */
  64891. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  64892. private _depthReducer;
  64893. private _autoCalcDepthBounds;
  64894. /**
  64895. * Gets or sets the autoCalcDepthBounds property.
  64896. *
  64897. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  64898. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  64899. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  64900. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  64901. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  64902. */
  64903. get autoCalcDepthBounds(): boolean;
  64904. set autoCalcDepthBounds(value: boolean);
  64905. /**
  64906. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  64907. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64908. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  64909. * for setting the refresh rate on the renderer yourself!
  64910. */
  64911. get autoCalcDepthBoundsRefreshRate(): number;
  64912. set autoCalcDepthBoundsRefreshRate(value: number);
  64913. /**
  64914. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  64915. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  64916. * you change the camera near/far planes!
  64917. */
  64918. splitFrustum(): void;
  64919. private _splitFrustum;
  64920. private _computeMatrices;
  64921. private _computeFrustumInWorldSpace;
  64922. private _computeCascadeFrustum;
  64923. /**
  64924. * Support test.
  64925. */
  64926. static get IsSupported(): boolean;
  64927. /** @hidden */
  64928. static _SceneComponentInitialization: (scene: Scene) => void;
  64929. /**
  64930. * Creates a Cascaded Shadow Generator object.
  64931. * A ShadowGenerator is the required tool to use the shadows.
  64932. * Each directional light casting shadows needs to use its own ShadowGenerator.
  64933. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64934. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  64935. * @param light The directional light object generating the shadows.
  64936. * @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.
  64937. */
  64938. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  64939. protected _initializeGenerator(): void;
  64940. protected _createTargetRenderTexture(): void;
  64941. protected _initializeShadowMap(): void;
  64942. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  64943. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  64944. /**
  64945. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  64946. * @param defines Defines of the material we want to update
  64947. * @param lightIndex Index of the light in the enabled light list of the material
  64948. */
  64949. prepareDefines(defines: any, lightIndex: number): void;
  64950. /**
  64951. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  64952. * defined in the generator but impacting the effect).
  64953. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  64954. * @param effect The effect we are binfing the information for
  64955. */
  64956. bindShadowLight(lightIndex: string, effect: Effect): void;
  64957. /**
  64958. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  64959. * (eq to view projection * shadow projection matrices)
  64960. * @returns The transform matrix used to create the shadow map
  64961. */
  64962. getTransformMatrix(): Matrix;
  64963. /**
  64964. * Disposes the ShadowGenerator.
  64965. * Returns nothing.
  64966. */
  64967. dispose(): void;
  64968. /**
  64969. * Serializes the shadow generator setup to a json object.
  64970. * @returns The serialized JSON object
  64971. */
  64972. serialize(): any;
  64973. /**
  64974. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  64975. * @param parsedShadowGenerator The JSON object to parse
  64976. * @param scene The scene to create the shadow map for
  64977. * @returns The parsed shadow generator
  64978. */
  64979. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  64980. }
  64981. }
  64982. declare module BABYLON {
  64983. /**
  64984. * Defines the shadow generator component responsible to manage any shadow generators
  64985. * in a given scene.
  64986. */
  64987. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  64988. /**
  64989. * The component name helpful to identify the component in the list of scene components.
  64990. */
  64991. readonly name: string;
  64992. /**
  64993. * The scene the component belongs to.
  64994. */
  64995. scene: Scene;
  64996. /**
  64997. * Creates a new instance of the component for the given scene
  64998. * @param scene Defines the scene to register the component in
  64999. */
  65000. constructor(scene: Scene);
  65001. /**
  65002. * Registers the component in a given scene
  65003. */
  65004. register(): void;
  65005. /**
  65006. * Rebuilds the elements related to this component in case of
  65007. * context lost for instance.
  65008. */
  65009. rebuild(): void;
  65010. /**
  65011. * Serializes the component data to the specified json object
  65012. * @param serializationObject The object to serialize to
  65013. */
  65014. serialize(serializationObject: any): void;
  65015. /**
  65016. * Adds all the elements from the container to the scene
  65017. * @param container the container holding the elements
  65018. */
  65019. addFromContainer(container: AbstractScene): void;
  65020. /**
  65021. * Removes all the elements in the container from the scene
  65022. * @param container contains the elements to remove
  65023. * @param dispose if the removed element should be disposed (default: false)
  65024. */
  65025. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  65026. /**
  65027. * Rebuilds the elements related to this component in case of
  65028. * context lost for instance.
  65029. */
  65030. dispose(): void;
  65031. private _gatherRenderTargets;
  65032. }
  65033. }
  65034. declare module BABYLON {
  65035. /**
  65036. * A point light is a light defined by an unique point in world space.
  65037. * The light is emitted in every direction from this point.
  65038. * A good example of a point light is a standard light bulb.
  65039. * Documentation: https://doc.babylonjs.com/babylon101/lights
  65040. */
  65041. export class PointLight extends ShadowLight {
  65042. private _shadowAngle;
  65043. /**
  65044. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  65045. * This specifies what angle the shadow will use to be created.
  65046. *
  65047. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  65048. */
  65049. get shadowAngle(): number;
  65050. /**
  65051. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  65052. * This specifies what angle the shadow will use to be created.
  65053. *
  65054. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  65055. */
  65056. set shadowAngle(value: number);
  65057. /**
  65058. * Gets the direction if it has been set.
  65059. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  65060. */
  65061. get direction(): Vector3;
  65062. /**
  65063. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  65064. */
  65065. set direction(value: Vector3);
  65066. /**
  65067. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  65068. * A PointLight emits the light in every direction.
  65069. * It can cast shadows.
  65070. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  65071. * ```javascript
  65072. * var pointLight = new PointLight("pl", camera.position, scene);
  65073. * ```
  65074. * Documentation : https://doc.babylonjs.com/babylon101/lights
  65075. * @param name The light friendly name
  65076. * @param position The position of the point light in the scene
  65077. * @param scene The scene the lights belongs to
  65078. */
  65079. constructor(name: string, position: Vector3, scene: Scene);
  65080. /**
  65081. * Returns the string "PointLight"
  65082. * @returns the class name
  65083. */
  65084. getClassName(): string;
  65085. /**
  65086. * Returns the integer 0.
  65087. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  65088. */
  65089. getTypeID(): number;
  65090. /**
  65091. * Specifies whether or not the shadowmap should be a cube texture.
  65092. * @returns true if the shadowmap needs to be a cube texture.
  65093. */
  65094. needCube(): boolean;
  65095. /**
  65096. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  65097. * @param faceIndex The index of the face we are computed the direction to generate shadow
  65098. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  65099. */
  65100. getShadowDirection(faceIndex?: number): Vector3;
  65101. /**
  65102. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  65103. * - fov = PI / 2
  65104. * - aspect ratio : 1.0
  65105. * - z-near and far equal to the active camera minZ and maxZ.
  65106. * Returns the PointLight.
  65107. */
  65108. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  65109. protected _buildUniformLayout(): void;
  65110. /**
  65111. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  65112. * @param effect The effect to update
  65113. * @param lightIndex The index of the light in the effect to update
  65114. * @returns The point light
  65115. */
  65116. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  65117. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  65118. /**
  65119. * Prepares the list of defines specific to the light type.
  65120. * @param defines the list of defines
  65121. * @param lightIndex defines the index of the light for the effect
  65122. */
  65123. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  65124. }
  65125. }
  65126. declare module BABYLON {
  65127. /**
  65128. * Header information of HDR texture files.
  65129. */
  65130. export interface HDRInfo {
  65131. /**
  65132. * The height of the texture in pixels.
  65133. */
  65134. height: number;
  65135. /**
  65136. * The width of the texture in pixels.
  65137. */
  65138. width: number;
  65139. /**
  65140. * The index of the beginning of the data in the binary file.
  65141. */
  65142. dataPosition: number;
  65143. }
  65144. /**
  65145. * This groups tools to convert HDR texture to native colors array.
  65146. */
  65147. export class HDRTools {
  65148. private static Ldexp;
  65149. private static Rgbe2float;
  65150. private static readStringLine;
  65151. /**
  65152. * Reads header information from an RGBE texture stored in a native array.
  65153. * More information on this format are available here:
  65154. * https://en.wikipedia.org/wiki/RGBE_image_format
  65155. *
  65156. * @param uint8array The binary file stored in native array.
  65157. * @return The header information.
  65158. */
  65159. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  65160. /**
  65161. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  65162. * This RGBE texture needs to store the information as a panorama.
  65163. *
  65164. * More information on this format are available here:
  65165. * https://en.wikipedia.org/wiki/RGBE_image_format
  65166. *
  65167. * @param buffer The binary file stored in an array buffer.
  65168. * @param size The expected size of the extracted cubemap.
  65169. * @return The Cube Map information.
  65170. */
  65171. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  65172. /**
  65173. * Returns the pixels data extracted from an RGBE texture.
  65174. * This pixels will be stored left to right up to down in the R G B order in one array.
  65175. *
  65176. * More information on this format are available here:
  65177. * https://en.wikipedia.org/wiki/RGBE_image_format
  65178. *
  65179. * @param uint8array The binary file stored in an array buffer.
  65180. * @param hdrInfo The header information of the file.
  65181. * @return The pixels data in RGB right to left up to down order.
  65182. */
  65183. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  65184. private static RGBE_ReadPixels_RLE;
  65185. private static RGBE_ReadPixels_NOT_RLE;
  65186. }
  65187. }
  65188. declare module BABYLON {
  65189. /**
  65190. * Effect Render Options
  65191. */
  65192. export interface IEffectRendererOptions {
  65193. /**
  65194. * Defines the vertices positions.
  65195. */
  65196. positions?: number[];
  65197. /**
  65198. * Defines the indices.
  65199. */
  65200. indices?: number[];
  65201. }
  65202. /**
  65203. * Helper class to render one or more effects.
  65204. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  65205. */
  65206. export class EffectRenderer {
  65207. private engine;
  65208. private static _DefaultOptions;
  65209. private _vertexBuffers;
  65210. private _indexBuffer;
  65211. private _fullscreenViewport;
  65212. /**
  65213. * Creates an effect renderer
  65214. * @param engine the engine to use for rendering
  65215. * @param options defines the options of the effect renderer
  65216. */
  65217. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  65218. /**
  65219. * Sets the current viewport in normalized coordinates 0-1
  65220. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  65221. */
  65222. setViewport(viewport?: Viewport): void;
  65223. /**
  65224. * Binds the embedded attributes buffer to the effect.
  65225. * @param effect Defines the effect to bind the attributes for
  65226. */
  65227. bindBuffers(effect: Effect): void;
  65228. /**
  65229. * Sets the current effect wrapper to use during draw.
  65230. * The effect needs to be ready before calling this api.
  65231. * This also sets the default full screen position attribute.
  65232. * @param effectWrapper Defines the effect to draw with
  65233. */
  65234. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  65235. /**
  65236. * Restores engine states
  65237. */
  65238. restoreStates(): void;
  65239. /**
  65240. * Draws a full screen quad.
  65241. */
  65242. draw(): void;
  65243. private isRenderTargetTexture;
  65244. /**
  65245. * renders one or more effects to a specified texture
  65246. * @param effectWrapper the effect to renderer
  65247. * @param outputTexture texture to draw to, if null it will render to the screen.
  65248. */
  65249. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  65250. /**
  65251. * Disposes of the effect renderer
  65252. */
  65253. dispose(): void;
  65254. }
  65255. /**
  65256. * Options to create an EffectWrapper
  65257. */
  65258. interface EffectWrapperCreationOptions {
  65259. /**
  65260. * Engine to use to create the effect
  65261. */
  65262. engine: ThinEngine;
  65263. /**
  65264. * Fragment shader for the effect
  65265. */
  65266. fragmentShader: string;
  65267. /**
  65268. * Use the shader store instead of direct source code
  65269. */
  65270. useShaderStore?: boolean;
  65271. /**
  65272. * Vertex shader for the effect
  65273. */
  65274. vertexShader?: string;
  65275. /**
  65276. * Attributes to use in the shader
  65277. */
  65278. attributeNames?: Array<string>;
  65279. /**
  65280. * Uniforms to use in the shader
  65281. */
  65282. uniformNames?: Array<string>;
  65283. /**
  65284. * Texture sampler names to use in the shader
  65285. */
  65286. samplerNames?: Array<string>;
  65287. /**
  65288. * Defines to use in the shader
  65289. */
  65290. defines?: Array<string>;
  65291. /**
  65292. * Callback when effect is compiled
  65293. */
  65294. onCompiled?: Nullable<(effect: Effect) => void>;
  65295. /**
  65296. * The friendly name of the effect displayed in Spector.
  65297. */
  65298. name?: string;
  65299. }
  65300. /**
  65301. * Wraps an effect to be used for rendering
  65302. */
  65303. export class EffectWrapper {
  65304. /**
  65305. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  65306. */
  65307. onApplyObservable: Observable<{}>;
  65308. /**
  65309. * The underlying effect
  65310. */
  65311. effect: Effect;
  65312. /**
  65313. * Creates an effect to be renderer
  65314. * @param creationOptions options to create the effect
  65315. */
  65316. constructor(creationOptions: EffectWrapperCreationOptions);
  65317. /**
  65318. * Disposes of the effect wrapper
  65319. */
  65320. dispose(): void;
  65321. }
  65322. }
  65323. declare module BABYLON {
  65324. /** @hidden */
  65325. export var hdrFilteringVertexShader: {
  65326. name: string;
  65327. shader: string;
  65328. };
  65329. }
  65330. declare module BABYLON {
  65331. /** @hidden */
  65332. export var hdrFilteringPixelShader: {
  65333. name: string;
  65334. shader: string;
  65335. };
  65336. }
  65337. declare module BABYLON {
  65338. /**
  65339. * Options for texture filtering
  65340. */
  65341. interface IHDRFilteringOptions {
  65342. /**
  65343. * Scales pixel intensity for the input HDR map.
  65344. */
  65345. hdrScale?: number;
  65346. /**
  65347. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  65348. */
  65349. quality?: number;
  65350. }
  65351. /**
  65352. * Filters HDR maps to get correct renderings of PBR reflections
  65353. */
  65354. export class HDRFiltering {
  65355. private _engine;
  65356. private _effectRenderer;
  65357. private _effectWrapper;
  65358. private _lodGenerationOffset;
  65359. private _lodGenerationScale;
  65360. /**
  65361. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  65362. * you care about baking speed.
  65363. */
  65364. quality: number;
  65365. /**
  65366. * Scales pixel intensity for the input HDR map.
  65367. */
  65368. hdrScale: number;
  65369. /**
  65370. * Instantiates HDR filter for reflection maps
  65371. *
  65372. * @param engine Thin engine
  65373. * @param options Options
  65374. */
  65375. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  65376. private _createRenderTarget;
  65377. private _prefilterInternal;
  65378. private _createEffect;
  65379. /**
  65380. * Get a value indicating if the filter is ready to be used
  65381. * @param texture Texture to filter
  65382. * @returns true if the filter is ready
  65383. */
  65384. isReady(texture: BaseTexture): boolean;
  65385. /**
  65386. * Prefilters a cube texture to have mipmap levels representing roughness values.
  65387. * Prefiltering will be invoked at the end of next rendering pass.
  65388. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  65389. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  65390. * @param texture Texture to filter
  65391. * @param onFinished Callback when filtering is done
  65392. * @return Promise called when prefiltering is done
  65393. */
  65394. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
  65395. }
  65396. }
  65397. declare module BABYLON {
  65398. /**
  65399. * This represents a texture coming from an HDR input.
  65400. *
  65401. * The only supported format is currently panorama picture stored in RGBE format.
  65402. * Example of such files can be found on HDRLib: http://hdrlib.com/
  65403. */
  65404. export class HDRCubeTexture extends BaseTexture {
  65405. private static _facesMapping;
  65406. private _generateHarmonics;
  65407. private _noMipmap;
  65408. private _prefilterOnLoad;
  65409. private _textureMatrix;
  65410. private _size;
  65411. private _onLoad;
  65412. private _onError;
  65413. /**
  65414. * The texture URL.
  65415. */
  65416. url: string;
  65417. protected _isBlocking: boolean;
  65418. /**
  65419. * Sets whether or not the texture is blocking during loading.
  65420. */
  65421. set isBlocking(value: boolean);
  65422. /**
  65423. * Gets whether or not the texture is blocking during loading.
  65424. */
  65425. get isBlocking(): boolean;
  65426. protected _rotationY: number;
  65427. /**
  65428. * Sets texture matrix rotation angle around Y axis in radians.
  65429. */
  65430. set rotationY(value: number);
  65431. /**
  65432. * Gets texture matrix rotation angle around Y axis radians.
  65433. */
  65434. get rotationY(): number;
  65435. /**
  65436. * Gets or sets the center of the bounding box associated with the cube texture
  65437. * It must define where the camera used to render the texture was set
  65438. */
  65439. boundingBoxPosition: Vector3;
  65440. private _boundingBoxSize;
  65441. /**
  65442. * Gets or sets the size of the bounding box associated with the cube texture
  65443. * When defined, the cubemap will switch to local mode
  65444. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  65445. * @example https://www.babylonjs-playground.com/#RNASML
  65446. */
  65447. set boundingBoxSize(value: Vector3);
  65448. get boundingBoxSize(): Vector3;
  65449. /**
  65450. * Instantiates an HDRTexture from the following parameters.
  65451. *
  65452. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  65453. * @param sceneOrEngine The scene or engine the texture will be used in
  65454. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  65455. * @param noMipmap Forces to not generate the mipmap if true
  65456. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  65457. * @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)
  65458. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  65459. */
  65460. 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>);
  65461. /**
  65462. * Get the current class name of the texture useful for serialization or dynamic coding.
  65463. * @returns "HDRCubeTexture"
  65464. */
  65465. getClassName(): string;
  65466. /**
  65467. * Occurs when the file is raw .hdr file.
  65468. */
  65469. private loadTexture;
  65470. clone(): HDRCubeTexture;
  65471. delayLoad(): void;
  65472. /**
  65473. * Get the texture reflection matrix used to rotate/transform the reflection.
  65474. * @returns the reflection matrix
  65475. */
  65476. getReflectionTextureMatrix(): Matrix;
  65477. /**
  65478. * Set the texture reflection matrix used to rotate/transform the reflection.
  65479. * @param value Define the reflection matrix to set
  65480. */
  65481. setReflectionTextureMatrix(value: Matrix): void;
  65482. /**
  65483. * Parses a JSON representation of an HDR Texture in order to create the texture
  65484. * @param parsedTexture Define the JSON representation
  65485. * @param scene Define the scene the texture should be created in
  65486. * @param rootUrl Define the root url in case we need to load relative dependencies
  65487. * @returns the newly created texture after parsing
  65488. */
  65489. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  65490. serialize(): any;
  65491. }
  65492. }
  65493. declare module BABYLON {
  65494. /**
  65495. * Class used to control physics engine
  65496. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  65497. */
  65498. export class PhysicsEngine implements IPhysicsEngine {
  65499. private _physicsPlugin;
  65500. /**
  65501. * Global value used to control the smallest number supported by the simulation
  65502. */
  65503. static Epsilon: number;
  65504. private _impostors;
  65505. private _joints;
  65506. private _subTimeStep;
  65507. /**
  65508. * Gets the gravity vector used by the simulation
  65509. */
  65510. gravity: Vector3;
  65511. /**
  65512. * Factory used to create the default physics plugin.
  65513. * @returns The default physics plugin
  65514. */
  65515. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  65516. /**
  65517. * Creates a new Physics Engine
  65518. * @param gravity defines the gravity vector used by the simulation
  65519. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  65520. */
  65521. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  65522. /**
  65523. * Sets the gravity vector used by the simulation
  65524. * @param gravity defines the gravity vector to use
  65525. */
  65526. setGravity(gravity: Vector3): void;
  65527. /**
  65528. * Set the time step of the physics engine.
  65529. * Default is 1/60.
  65530. * To slow it down, enter 1/600 for example.
  65531. * To speed it up, 1/30
  65532. * @param newTimeStep defines the new timestep to apply to this world.
  65533. */
  65534. setTimeStep(newTimeStep?: number): void;
  65535. /**
  65536. * Get the time step of the physics engine.
  65537. * @returns the current time step
  65538. */
  65539. getTimeStep(): number;
  65540. /**
  65541. * Set the sub time step of the physics engine.
  65542. * Default is 0 meaning there is no sub steps
  65543. * To increase physics resolution precision, set a small value (like 1 ms)
  65544. * @param subTimeStep defines the new sub timestep used for physics resolution.
  65545. */
  65546. setSubTimeStep(subTimeStep?: number): void;
  65547. /**
  65548. * Get the sub time step of the physics engine.
  65549. * @returns the current sub time step
  65550. */
  65551. getSubTimeStep(): number;
  65552. /**
  65553. * Release all resources
  65554. */
  65555. dispose(): void;
  65556. /**
  65557. * Gets the name of the current physics plugin
  65558. * @returns the name of the plugin
  65559. */
  65560. getPhysicsPluginName(): string;
  65561. /**
  65562. * Adding a new impostor for the impostor tracking.
  65563. * This will be done by the impostor itself.
  65564. * @param impostor the impostor to add
  65565. */
  65566. addImpostor(impostor: PhysicsImpostor): void;
  65567. /**
  65568. * Remove an impostor from the engine.
  65569. * This impostor and its mesh will not longer be updated by the physics engine.
  65570. * @param impostor the impostor to remove
  65571. */
  65572. removeImpostor(impostor: PhysicsImpostor): void;
  65573. /**
  65574. * Add a joint to the physics engine
  65575. * @param mainImpostor defines the main impostor to which the joint is added.
  65576. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  65577. * @param joint defines the joint that will connect both impostors.
  65578. */
  65579. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65580. /**
  65581. * Removes a joint from the simulation
  65582. * @param mainImpostor defines the impostor used with the joint
  65583. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  65584. * @param joint defines the joint to remove
  65585. */
  65586. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65587. /**
  65588. * Called by the scene. No need to call it.
  65589. * @param delta defines the timespan between frames
  65590. */
  65591. _step(delta: number): void;
  65592. /**
  65593. * Gets the current plugin used to run the simulation
  65594. * @returns current plugin
  65595. */
  65596. getPhysicsPlugin(): IPhysicsEnginePlugin;
  65597. /**
  65598. * Gets the list of physic impostors
  65599. * @returns an array of PhysicsImpostor
  65600. */
  65601. getImpostors(): Array<PhysicsImpostor>;
  65602. /**
  65603. * Gets the impostor for a physics enabled object
  65604. * @param object defines the object impersonated by the impostor
  65605. * @returns the PhysicsImpostor or null if not found
  65606. */
  65607. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  65608. /**
  65609. * Gets the impostor for a physics body object
  65610. * @param body defines physics body used by the impostor
  65611. * @returns the PhysicsImpostor or null if not found
  65612. */
  65613. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  65614. /**
  65615. * Does a raycast in the physics world
  65616. * @param from when should the ray start?
  65617. * @param to when should the ray end?
  65618. * @returns PhysicsRaycastResult
  65619. */
  65620. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65621. }
  65622. }
  65623. declare module BABYLON {
  65624. /** @hidden */
  65625. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  65626. private _useDeltaForWorldStep;
  65627. world: any;
  65628. name: string;
  65629. private _physicsMaterials;
  65630. private _fixedTimeStep;
  65631. private _cannonRaycastResult;
  65632. private _raycastResult;
  65633. private _physicsBodysToRemoveAfterStep;
  65634. private _firstFrame;
  65635. BJSCANNON: any;
  65636. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  65637. setGravity(gravity: Vector3): void;
  65638. setTimeStep(timeStep: number): void;
  65639. getTimeStep(): number;
  65640. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65641. private _removeMarkedPhysicsBodiesFromWorld;
  65642. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65643. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65644. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65645. private _processChildMeshes;
  65646. removePhysicsBody(impostor: PhysicsImpostor): void;
  65647. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65648. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65649. private _addMaterial;
  65650. private _checkWithEpsilon;
  65651. private _createShape;
  65652. private _createHeightmap;
  65653. private _minus90X;
  65654. private _plus90X;
  65655. private _tmpPosition;
  65656. private _tmpDeltaPosition;
  65657. private _tmpUnityRotation;
  65658. private _updatePhysicsBodyTransformation;
  65659. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65660. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65661. isSupported(): boolean;
  65662. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65663. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65664. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65665. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65666. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65667. getBodyMass(impostor: PhysicsImpostor): number;
  65668. getBodyFriction(impostor: PhysicsImpostor): number;
  65669. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65670. getBodyRestitution(impostor: PhysicsImpostor): number;
  65671. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65672. sleepBody(impostor: PhysicsImpostor): void;
  65673. wakeUpBody(impostor: PhysicsImpostor): void;
  65674. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  65675. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65676. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65677. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65678. getRadius(impostor: PhysicsImpostor): number;
  65679. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65680. dispose(): void;
  65681. private _extendNamespace;
  65682. /**
  65683. * Does a raycast in the physics world
  65684. * @param from when should the ray start?
  65685. * @param to when should the ray end?
  65686. * @returns PhysicsRaycastResult
  65687. */
  65688. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65689. }
  65690. }
  65691. declare module BABYLON {
  65692. /** @hidden */
  65693. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  65694. private _useDeltaForWorldStep;
  65695. world: any;
  65696. name: string;
  65697. BJSOIMO: any;
  65698. private _raycastResult;
  65699. private _fixedTimeStep;
  65700. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  65701. setGravity(gravity: Vector3): void;
  65702. setTimeStep(timeStep: number): void;
  65703. getTimeStep(): number;
  65704. private _tmpImpostorsArray;
  65705. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65706. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65707. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65708. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65709. private _tmpPositionVector;
  65710. removePhysicsBody(impostor: PhysicsImpostor): void;
  65711. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65712. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65713. isSupported(): boolean;
  65714. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65715. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65716. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65717. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65718. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65719. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65720. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65721. getBodyMass(impostor: PhysicsImpostor): number;
  65722. getBodyFriction(impostor: PhysicsImpostor): number;
  65723. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65724. getBodyRestitution(impostor: PhysicsImpostor): number;
  65725. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65726. sleepBody(impostor: PhysicsImpostor): void;
  65727. wakeUpBody(impostor: PhysicsImpostor): void;
  65728. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65729. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  65730. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  65731. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65732. getRadius(impostor: PhysicsImpostor): number;
  65733. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65734. dispose(): void;
  65735. /**
  65736. * Does a raycast in the physics world
  65737. * @param from when should the ray start?
  65738. * @param to when should the ray end?
  65739. * @returns PhysicsRaycastResult
  65740. */
  65741. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65742. }
  65743. }
  65744. declare module BABYLON {
  65745. /**
  65746. * AmmoJS Physics plugin
  65747. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  65748. * @see https://github.com/kripken/ammo.js/
  65749. */
  65750. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  65751. private _useDeltaForWorldStep;
  65752. /**
  65753. * Reference to the Ammo library
  65754. */
  65755. bjsAMMO: any;
  65756. /**
  65757. * Created ammoJS world which physics bodies are added to
  65758. */
  65759. world: any;
  65760. /**
  65761. * Name of the plugin
  65762. */
  65763. name: string;
  65764. private _timeStep;
  65765. private _fixedTimeStep;
  65766. private _maxSteps;
  65767. private _tmpQuaternion;
  65768. private _tmpAmmoTransform;
  65769. private _tmpAmmoQuaternion;
  65770. private _tmpAmmoConcreteContactResultCallback;
  65771. private _collisionConfiguration;
  65772. private _dispatcher;
  65773. private _overlappingPairCache;
  65774. private _solver;
  65775. private _softBodySolver;
  65776. private _tmpAmmoVectorA;
  65777. private _tmpAmmoVectorB;
  65778. private _tmpAmmoVectorC;
  65779. private _tmpAmmoVectorD;
  65780. private _tmpContactCallbackResult;
  65781. private _tmpAmmoVectorRCA;
  65782. private _tmpAmmoVectorRCB;
  65783. private _raycastResult;
  65784. private _tmpContactPoint;
  65785. private static readonly DISABLE_COLLISION_FLAG;
  65786. private static readonly KINEMATIC_FLAG;
  65787. private static readonly DISABLE_DEACTIVATION_FLAG;
  65788. /**
  65789. * Initializes the ammoJS plugin
  65790. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  65791. * @param ammoInjection can be used to inject your own ammo reference
  65792. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  65793. */
  65794. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  65795. /**
  65796. * Sets the gravity of the physics world (m/(s^2))
  65797. * @param gravity Gravity to set
  65798. */
  65799. setGravity(gravity: Vector3): void;
  65800. /**
  65801. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  65802. * @param timeStep timestep to use in seconds
  65803. */
  65804. setTimeStep(timeStep: number): void;
  65805. /**
  65806. * 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)
  65807. * @param fixedTimeStep fixedTimeStep to use in seconds
  65808. */
  65809. setFixedTimeStep(fixedTimeStep: number): void;
  65810. /**
  65811. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  65812. * @param maxSteps the maximum number of steps by the physics engine per frame
  65813. */
  65814. setMaxSteps(maxSteps: number): void;
  65815. /**
  65816. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  65817. * @returns the current timestep in seconds
  65818. */
  65819. getTimeStep(): number;
  65820. /**
  65821. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  65822. */
  65823. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  65824. private _isImpostorInContact;
  65825. private _isImpostorPairInContact;
  65826. private _stepSimulation;
  65827. /**
  65828. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  65829. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  65830. * After the step the babylon meshes are set to the position of the physics imposters
  65831. * @param delta amount of time to step forward
  65832. * @param impostors array of imposters to update before/after the step
  65833. */
  65834. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65835. /**
  65836. * Update babylon mesh to match physics world object
  65837. * @param impostor imposter to match
  65838. */
  65839. private _afterSoftStep;
  65840. /**
  65841. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65842. * @param impostor imposter to match
  65843. */
  65844. private _ropeStep;
  65845. /**
  65846. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65847. * @param impostor imposter to match
  65848. */
  65849. private _softbodyOrClothStep;
  65850. private _tmpMatrix;
  65851. /**
  65852. * Applies an impulse on the imposter
  65853. * @param impostor imposter to apply impulse to
  65854. * @param force amount of force to be applied to the imposter
  65855. * @param contactPoint the location to apply the impulse on the imposter
  65856. */
  65857. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65858. /**
  65859. * Applies a force on the imposter
  65860. * @param impostor imposter to apply force
  65861. * @param force amount of force to be applied to the imposter
  65862. * @param contactPoint the location to apply the force on the imposter
  65863. */
  65864. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65865. /**
  65866. * Creates a physics body using the plugin
  65867. * @param impostor the imposter to create the physics body on
  65868. */
  65869. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65870. /**
  65871. * Removes the physics body from the imposter and disposes of the body's memory
  65872. * @param impostor imposter to remove the physics body from
  65873. */
  65874. removePhysicsBody(impostor: PhysicsImpostor): void;
  65875. /**
  65876. * Generates a joint
  65877. * @param impostorJoint the imposter joint to create the joint with
  65878. */
  65879. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65880. /**
  65881. * Removes a joint
  65882. * @param impostorJoint the imposter joint to remove the joint from
  65883. */
  65884. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65885. private _addMeshVerts;
  65886. /**
  65887. * Initialise the soft body vertices to match its object's (mesh) vertices
  65888. * Softbody vertices (nodes) are in world space and to match this
  65889. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  65890. * @param impostor to create the softbody for
  65891. */
  65892. private _softVertexData;
  65893. /**
  65894. * Create an impostor's soft body
  65895. * @param impostor to create the softbody for
  65896. */
  65897. private _createSoftbody;
  65898. /**
  65899. * Create cloth for an impostor
  65900. * @param impostor to create the softbody for
  65901. */
  65902. private _createCloth;
  65903. /**
  65904. * Create rope for an impostor
  65905. * @param impostor to create the softbody for
  65906. */
  65907. private _createRope;
  65908. /**
  65909. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  65910. * @param impostor to create the custom physics shape for
  65911. */
  65912. private _createCustom;
  65913. private _addHullVerts;
  65914. private _createShape;
  65915. /**
  65916. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  65917. * @param impostor imposter containing the physics body and babylon object
  65918. */
  65919. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65920. /**
  65921. * Sets the babylon object's position/rotation from the physics body's position/rotation
  65922. * @param impostor imposter containing the physics body and babylon object
  65923. * @param newPosition new position
  65924. * @param newRotation new rotation
  65925. */
  65926. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65927. /**
  65928. * If this plugin is supported
  65929. * @returns true if its supported
  65930. */
  65931. isSupported(): boolean;
  65932. /**
  65933. * Sets the linear velocity of the physics body
  65934. * @param impostor imposter to set the velocity on
  65935. * @param velocity velocity to set
  65936. */
  65937. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65938. /**
  65939. * Sets the angular velocity of the physics body
  65940. * @param impostor imposter to set the velocity on
  65941. * @param velocity velocity to set
  65942. */
  65943. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65944. /**
  65945. * gets the linear velocity
  65946. * @param impostor imposter to get linear velocity from
  65947. * @returns linear velocity
  65948. */
  65949. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65950. /**
  65951. * gets the angular velocity
  65952. * @param impostor imposter to get angular velocity from
  65953. * @returns angular velocity
  65954. */
  65955. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65956. /**
  65957. * Sets the mass of physics body
  65958. * @param impostor imposter to set the mass on
  65959. * @param mass mass to set
  65960. */
  65961. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65962. /**
  65963. * Gets the mass of the physics body
  65964. * @param impostor imposter to get the mass from
  65965. * @returns mass
  65966. */
  65967. getBodyMass(impostor: PhysicsImpostor): number;
  65968. /**
  65969. * Gets friction of the impostor
  65970. * @param impostor impostor to get friction from
  65971. * @returns friction value
  65972. */
  65973. getBodyFriction(impostor: PhysicsImpostor): number;
  65974. /**
  65975. * Sets friction of the impostor
  65976. * @param impostor impostor to set friction on
  65977. * @param friction friction value
  65978. */
  65979. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65980. /**
  65981. * Gets restitution of the impostor
  65982. * @param impostor impostor to get restitution from
  65983. * @returns restitution value
  65984. */
  65985. getBodyRestitution(impostor: PhysicsImpostor): number;
  65986. /**
  65987. * Sets restitution of the impostor
  65988. * @param impostor impostor to set resitution on
  65989. * @param restitution resitution value
  65990. */
  65991. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65992. /**
  65993. * Gets pressure inside the impostor
  65994. * @param impostor impostor to get pressure from
  65995. * @returns pressure value
  65996. */
  65997. getBodyPressure(impostor: PhysicsImpostor): number;
  65998. /**
  65999. * Sets pressure inside a soft body impostor
  66000. * Cloth and rope must remain 0 pressure
  66001. * @param impostor impostor to set pressure on
  66002. * @param pressure pressure value
  66003. */
  66004. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  66005. /**
  66006. * Gets stiffness of the impostor
  66007. * @param impostor impostor to get stiffness from
  66008. * @returns pressure value
  66009. */
  66010. getBodyStiffness(impostor: PhysicsImpostor): number;
  66011. /**
  66012. * Sets stiffness of the impostor
  66013. * @param impostor impostor to set stiffness on
  66014. * @param stiffness stiffness value from 0 to 1
  66015. */
  66016. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  66017. /**
  66018. * Gets velocityIterations of the impostor
  66019. * @param impostor impostor to get velocity iterations from
  66020. * @returns velocityIterations value
  66021. */
  66022. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  66023. /**
  66024. * Sets velocityIterations of the impostor
  66025. * @param impostor impostor to set velocity iterations on
  66026. * @param velocityIterations velocityIterations value
  66027. */
  66028. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  66029. /**
  66030. * Gets positionIterations of the impostor
  66031. * @param impostor impostor to get position iterations from
  66032. * @returns positionIterations value
  66033. */
  66034. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  66035. /**
  66036. * Sets positionIterations of the impostor
  66037. * @param impostor impostor to set position on
  66038. * @param positionIterations positionIterations value
  66039. */
  66040. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  66041. /**
  66042. * Append an anchor to a cloth object
  66043. * @param impostor is the cloth impostor to add anchor to
  66044. * @param otherImpostor is the rigid impostor to anchor to
  66045. * @param width ratio across width from 0 to 1
  66046. * @param height ratio up height from 0 to 1
  66047. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little stretch
  66048. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  66049. */
  66050. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  66051. /**
  66052. * Append an hook to a rope object
  66053. * @param impostor is the rope impostor to add hook to
  66054. * @param otherImpostor is the rigid impostor to hook to
  66055. * @param length ratio along the rope from 0 to 1
  66056. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little stretch
  66057. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  66058. */
  66059. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  66060. /**
  66061. * Sleeps the physics body and stops it from being active
  66062. * @param impostor impostor to sleep
  66063. */
  66064. sleepBody(impostor: PhysicsImpostor): void;
  66065. /**
  66066. * Activates the physics body
  66067. * @param impostor impostor to activate
  66068. */
  66069. wakeUpBody(impostor: PhysicsImpostor): void;
  66070. /**
  66071. * Updates the distance parameters of the joint
  66072. * @param joint joint to update
  66073. * @param maxDistance maximum distance of the joint
  66074. * @param minDistance minimum distance of the joint
  66075. */
  66076. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  66077. /**
  66078. * Sets a motor on the joint
  66079. * @param joint joint to set motor on
  66080. * @param speed speed of the motor
  66081. * @param maxForce maximum force of the motor
  66082. * @param motorIndex index of the motor
  66083. */
  66084. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  66085. /**
  66086. * Sets the motors limit
  66087. * @param joint joint to set limit on
  66088. * @param upperLimit upper limit
  66089. * @param lowerLimit lower limit
  66090. */
  66091. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  66092. /**
  66093. * Syncs the position and rotation of a mesh with the impostor
  66094. * @param mesh mesh to sync
  66095. * @param impostor impostor to update the mesh with
  66096. */
  66097. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  66098. /**
  66099. * Gets the radius of the impostor
  66100. * @param impostor impostor to get radius from
  66101. * @returns the radius
  66102. */
  66103. getRadius(impostor: PhysicsImpostor): number;
  66104. /**
  66105. * Gets the box size of the impostor
  66106. * @param impostor impostor to get box size from
  66107. * @param result the resulting box size
  66108. */
  66109. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  66110. /**
  66111. * Disposes of the impostor
  66112. */
  66113. dispose(): void;
  66114. /**
  66115. * Does a raycast in the physics world
  66116. * @param from when should the ray start?
  66117. * @param to when should the ray end?
  66118. * @returns PhysicsRaycastResult
  66119. */
  66120. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  66121. }
  66122. }
  66123. declare module BABYLON {
  66124. interface AbstractScene {
  66125. /**
  66126. * The list of reflection probes added to the scene
  66127. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  66128. */
  66129. reflectionProbes: Array<ReflectionProbe>;
  66130. /**
  66131. * Removes the given reflection probe from this scene.
  66132. * @param toRemove The reflection probe to remove
  66133. * @returns The index of the removed reflection probe
  66134. */
  66135. removeReflectionProbe(toRemove: ReflectionProbe): number;
  66136. /**
  66137. * Adds the given reflection probe to this scene.
  66138. * @param newReflectionProbe The reflection probe to add
  66139. */
  66140. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  66141. }
  66142. /**
  66143. * Class used to generate realtime reflection / refraction cube textures
  66144. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  66145. */
  66146. export class ReflectionProbe {
  66147. /** defines the name of the probe */
  66148. name: string;
  66149. private _scene;
  66150. private _renderTargetTexture;
  66151. private _projectionMatrix;
  66152. private _viewMatrix;
  66153. private _target;
  66154. private _add;
  66155. private _attachedMesh;
  66156. private _invertYAxis;
  66157. /** Gets or sets probe position (center of the cube map) */
  66158. position: Vector3;
  66159. /**
  66160. * Creates a new reflection probe
  66161. * @param name defines the name of the probe
  66162. * @param size defines the texture resolution (for each face)
  66163. * @param scene defines the hosting scene
  66164. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  66165. * @param useFloat defines if HDR data (float data) should be used to store colors (false by default)
  66166. */
  66167. constructor(
  66168. /** defines the name of the probe */
  66169. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  66170. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  66171. get samples(): number;
  66172. set samples(value: number);
  66173. /** Gets or sets the refresh rate to use (on every frame by default) */
  66174. get refreshRate(): number;
  66175. set refreshRate(value: number);
  66176. /**
  66177. * Gets the hosting scene
  66178. * @returns a Scene
  66179. */
  66180. getScene(): Scene;
  66181. /** Gets the internal CubeTexture used to render to */
  66182. get cubeTexture(): RenderTargetTexture;
  66183. /** Gets the list of meshes to render */
  66184. get renderList(): Nullable<AbstractMesh[]>;
  66185. /**
  66186. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  66187. * @param mesh defines the mesh to attach to
  66188. */
  66189. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  66190. /**
  66191. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  66192. * @param renderingGroupId The rendering group id corresponding to its index
  66193. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  66194. */
  66195. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  66196. /**
  66197. * Clean all associated resources
  66198. */
  66199. dispose(): void;
  66200. /**
  66201. * Converts the reflection probe information to a readable string for debug purpose.
  66202. * @param fullDetails Supports for multiple levels of logging within scene loading
  66203. * @returns the human readable reflection probe info
  66204. */
  66205. toString(fullDetails?: boolean): string;
  66206. /**
  66207. * Get the class name of the refection probe.
  66208. * @returns "ReflectionProbe"
  66209. */
  66210. getClassName(): string;
  66211. /**
  66212. * Serialize the reflection probe to a JSON representation we can easily use in the respective Parse function.
  66213. * @returns The JSON representation of the texture
  66214. */
  66215. serialize(): any;
  66216. /**
  66217. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  66218. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  66219. * @param scene Define the scene the parsed reflection probe should be instantiated in
  66220. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  66221. * @returns The parsed reflection probe if successful
  66222. */
  66223. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  66224. }
  66225. }
  66226. declare module BABYLON {
  66227. /** @hidden */
  66228. export var _BabylonLoaderRegistered: boolean;
  66229. /**
  66230. * Helps setting up some configuration for the babylon file loader.
  66231. */
  66232. export class BabylonFileLoaderConfiguration {
  66233. /**
  66234. * The loader does not allow injecting custom physics engine into the plugins.
  66235. * Unfortunately in ES6, we need to manually inject them into the plugin.
  66236. * So you could set this variable to your engine import to make it work.
  66237. */
  66238. static LoaderInjectedPhysicsEngine: any;
  66239. }
  66240. }
  66241. declare module BABYLON {
  66242. /**
  66243. * A material to use for fast depth-only rendering.
  66244. */
  66245. export class OcclusionMaterial extends ShaderMaterial {
  66246. constructor(name: string, scene: Scene);
  66247. }
  66248. }
  66249. declare module BABYLON {
  66250. /**
  66251. * The Physically based simple base material of BJS.
  66252. *
  66253. * This enables better naming and convention enforcements on top of the pbrMaterial.
  66254. * It is used as the base class for both the specGloss and metalRough conventions.
  66255. */
  66256. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  66257. /**
  66258. * Number of Simultaneous lights allowed on the material.
  66259. */
  66260. maxSimultaneousLights: number;
  66261. /**
  66262. * If sets to true, disables all the lights affecting the material.
  66263. */
  66264. disableLighting: boolean;
  66265. /**
  66266. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  66267. */
  66268. environmentTexture: BaseTexture;
  66269. /**
  66270. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  66271. */
  66272. invertNormalMapX: boolean;
  66273. /**
  66274. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  66275. */
  66276. invertNormalMapY: boolean;
  66277. /**
  66278. * Normal map used in the model.
  66279. */
  66280. normalTexture: BaseTexture;
  66281. /**
  66282. * Emissivie color used to self-illuminate the model.
  66283. */
  66284. emissiveColor: Color3;
  66285. /**
  66286. * Emissivie texture used to self-illuminate the model.
  66287. */
  66288. emissiveTexture: BaseTexture;
  66289. /**
  66290. * Occlusion Channel Strength.
  66291. */
  66292. occlusionStrength: number;
  66293. /**
  66294. * Occlusion Texture of the material (adding extra occlusion effects).
  66295. */
  66296. occlusionTexture: BaseTexture;
  66297. /**
  66298. * Defines the alpha limits in alpha test mode.
  66299. */
  66300. alphaCutOff: number;
  66301. /**
  66302. * Gets the current double sided mode.
  66303. */
  66304. get doubleSided(): boolean;
  66305. /**
  66306. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  66307. */
  66308. set doubleSided(value: boolean);
  66309. /**
  66310. * Stores the pre-calculated light information of a mesh in a texture.
  66311. */
  66312. lightmapTexture: BaseTexture;
  66313. /**
  66314. * If true, the light map contains occlusion information instead of lighting info.
  66315. */
  66316. useLightmapAsShadowmap: boolean;
  66317. /**
  66318. * Instantiates a new PBRMaterial instance.
  66319. *
  66320. * @param name The material name
  66321. * @param scene The scene the material will be use in.
  66322. */
  66323. constructor(name: string, scene: Scene);
  66324. getClassName(): string;
  66325. }
  66326. }
  66327. declare module BABYLON {
  66328. /**
  66329. * The PBR material of BJS following the metal roughness convention.
  66330. *
  66331. * This fits to the PBR convention in the GLTF definition:
  66332. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  66333. */
  66334. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  66335. /**
  66336. * The base color has two different interpretations depending on the value of metalness.
  66337. * When the material is a metal, the base color is the specific measured reflectance value
  66338. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  66339. * of the material.
  66340. */
  66341. baseColor: Color3;
  66342. /**
  66343. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  66344. * well as opacity information in the alpha channel.
  66345. */
  66346. baseTexture: BaseTexture;
  66347. /**
  66348. * Specifies the metallic scalar value of the material.
  66349. * Can also be used to scale the metalness values of the metallic texture.
  66350. */
  66351. metallic: number;
  66352. /**
  66353. * Specifies the roughness scalar value of the material.
  66354. * Can also be used to scale the roughness values of the metallic texture.
  66355. */
  66356. roughness: number;
  66357. /**
  66358. * Texture containing both the metallic value in the B channel and the
  66359. * roughness value in the G channel to keep better precision.
  66360. */
  66361. metallicRoughnessTexture: BaseTexture;
  66362. /**
  66363. * Instantiates a new PBRMetalRoughnessMaterial instance.
  66364. *
  66365. * @param name The material name
  66366. * @param scene The scene the material will be use in.
  66367. */
  66368. constructor(name: string, scene: Scene);
  66369. /**
  66370. * Return the current class name of the material.
  66371. */
  66372. getClassName(): string;
  66373. /**
  66374. * Makes a duplicate of the current material.
  66375. * @param name - name to use for the new material.
  66376. */
  66377. clone(name: string): PBRMetallicRoughnessMaterial;
  66378. /**
  66379. * Serialize the material to a parsable JSON object.
  66380. */
  66381. serialize(): any;
  66382. /**
  66383. * Parses a JSON object corresponding to the serialize function.
  66384. */
  66385. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  66386. }
  66387. }
  66388. declare module BABYLON {
  66389. /**
  66390. * The PBR material of BJS following the specular glossiness convention.
  66391. *
  66392. * This fits to the PBR convention in the GLTF definition:
  66393. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  66394. */
  66395. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  66396. /**
  66397. * Specifies the diffuse color of the material.
  66398. */
  66399. diffuseColor: Color3;
  66400. /**
  66401. * Specifies the diffuse texture of the material. This can also contains the opacity value in its alpha
  66402. * channel.
  66403. */
  66404. diffuseTexture: BaseTexture;
  66405. /**
  66406. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  66407. */
  66408. specularColor: Color3;
  66409. /**
  66410. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  66411. */
  66412. glossiness: number;
  66413. /**
  66414. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  66415. */
  66416. specularGlossinessTexture: BaseTexture;
  66417. /**
  66418. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  66419. */
  66420. get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
  66421. /**
  66422. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  66423. *
  66424. * @param name The material name
  66425. * @param scene The scene the material will be use in.
  66426. */
  66427. constructor(name: string, scene: Scene);
  66428. /**
  66429. * Return the current class name of the material.
  66430. */
  66431. getClassName(): string;
  66432. /**
  66433. * Makes a duplicate of the current material.
  66434. * @param name - name to use for the new material.
  66435. */
  66436. clone(name: string): PBRSpecularGlossinessMaterial;
  66437. /**
  66438. * Serialize the material to a parsable JSON object.
  66439. */
  66440. serialize(): any;
  66441. /**
  66442. * Parses a JSON object corresponding to the serialize function.
  66443. */
  66444. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  66445. }
  66446. }
  66447. declare module BABYLON {
  66448. /**
  66449. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  66450. * It can help converting any input color in a desired output one. This can then be used to create effects
  66451. * from sepia, black and white to sixties or futuristic rendering...
  66452. *
  66453. * The only supported format is currently 3dl.
  66454. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  66455. */
  66456. export class ColorGradingTexture extends BaseTexture {
  66457. /**
  66458. * The texture URL.
  66459. */
  66460. url: string;
  66461. /**
  66462. * Empty line regex stored for GC.
  66463. */
  66464. private static _noneEmptyLineRegex;
  66465. private _textureMatrix;
  66466. private _onLoad;
  66467. /**
  66468. * Instantiates a ColorGradingTexture from the following parameters.
  66469. *
  66470. * @param url The location of the color grading data (currently only supporting 3dl)
  66471. * @param sceneOrEngine The scene or engine the texture will be used in
  66472. * @param onLoad defines a callback triggered when the texture has been loaded
  66473. */
  66474. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  66475. /**
  66476. * Fires the onload event from the constructor if requested.
  66477. */
  66478. private _triggerOnLoad;
  66479. /**
  66480. * Returns the texture matrix used in most of the material.
  66481. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  66482. */
  66483. getTextureMatrix(): Matrix;
  66484. /**
  66485. * Occurs when the file being loaded is a .3dl LUT file.
  66486. */
  66487. private load3dlTexture;
  66488. /**
  66489. * Starts the loading process of the texture.
  66490. */
  66491. private loadTexture;
  66492. /**
  66493. * Clones the color grading texture.
  66494. */
  66495. clone(): ColorGradingTexture;
  66496. /**
  66497. * Called during delayed load for textures.
  66498. */
  66499. delayLoad(): void;
  66500. /**
  66501. * Parses a color grading texture serialized by Babylon.
  66502. * @param parsedTexture The texture information being parsedTexture
  66503. * @param scene The scene to load the texture in
  66504. * @param rootUrl The root url of the data assets to load
  66505. * @return A color grading texture
  66506. */
  66507. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  66508. /**
  66509. * Serializes the LUT texture to json format.
  66510. */
  66511. serialize(): any;
  66512. }
  66513. }
  66514. declare module BABYLON {
  66515. /**
  66516. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  66517. */
  66518. export class EquiRectangularCubeTexture extends BaseTexture {
  66519. /** The six faces of the cube. */
  66520. private static _FacesMapping;
  66521. private _noMipmap;
  66522. private _onLoad;
  66523. private _onError;
  66524. /** The size of the cubemap. */
  66525. private _size;
  66526. /** The buffer of the image. */
  66527. private _buffer;
  66528. /** The width of the input image. */
  66529. private _width;
  66530. /** The height of the input image. */
  66531. private _height;
  66532. /** The URL to the image. */
  66533. url: string;
  66534. /**
  66535. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  66536. * @param url The location of the image
  66537. * @param scene The scene the texture will be used in
  66538. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  66539. * @param noMipmap Forces to not generate the mipmap if true
  66540. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66541. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66542. * @param onLoad — defines a callback called when texture is loaded
  66543. * @param onError — defines a callback called if there is an error
  66544. */
  66545. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  66546. /**
  66547. * Load the image data, by putting the image on a canvas and extracting its buffer.
  66548. */
  66549. private loadImage;
  66550. /**
  66551. * Convert the image buffer into a cubemap and create a CubeTexture.
  66552. */
  66553. private loadTexture;
  66554. /**
  66555. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  66556. * @param buffer The ArrayBuffer that should be converted.
  66557. * @returns The buffer as Float32Array.
  66558. */
  66559. private getFloat32ArrayFromArrayBuffer;
  66560. /**
  66561. * Get the current class name of the texture useful for serialization or dynamic coding.
  66562. * @returns "EquiRectangularCubeTexture"
  66563. */
  66564. getClassName(): string;
  66565. /**
  66566. * Create a clone of the current EquiRectangularCubeTexture and return it.
  66567. * @returns A clone of the current EquiRectangularCubeTexture.
  66568. */
  66569. clone(): EquiRectangularCubeTexture;
  66570. }
  66571. }
  66572. declare module BABYLON {
  66573. /**
  66574. * Defines the options related to the creation of an HtmlElementTexture
  66575. */
  66576. export interface IHtmlElementTextureOptions {
  66577. /**
  66578. * Defines whether mip maps should be created or not.
  66579. */
  66580. generateMipMaps?: boolean;
  66581. /**
  66582. * Defines the sampling mode of the texture.
  66583. */
  66584. samplingMode?: number;
  66585. /**
  66586. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  66587. */
  66588. engine: Nullable<ThinEngine>;
  66589. /**
  66590. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  66591. */
  66592. scene: Nullable<Scene>;
  66593. }
  66594. /**
  66595. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  66596. * To be as efficient as possible depending on your constraints nothing aside the first upload
  66597. * is automatically managed.
  66598. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  66599. * in your application.
  66600. *
  66601. * As the update is not automatic, you need to call them manually.
  66602. */
  66603. export class HtmlElementTexture extends BaseTexture {
  66604. /**
  66605. * The texture URL.
  66606. */
  66607. element: HTMLVideoElement | HTMLCanvasElement;
  66608. private static readonly DefaultOptions;
  66609. private _textureMatrix;
  66610. private _isVideo;
  66611. private _generateMipMaps;
  66612. private _samplingMode;
  66613. /**
  66614. * Instantiates a HtmlElementTexture from the following parameters.
  66615. *
  66616. * @param name Defines the name of the texture
  66617. * @param element Defines the video or canvas the texture is filled with
  66618. * @param options Defines the other none mandatory texture creation options
  66619. */
  66620. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  66621. private _createInternalTexture;
  66622. /**
  66623. * Returns the texture matrix used in most of the material.
  66624. */
  66625. getTextureMatrix(): Matrix;
  66626. /**
  66627. * Updates the content of the texture.
  66628. * @param invertY Defines whether the texture should be inverted on Y (false by default on video and true on canvas)
  66629. */
  66630. update(invertY?: Nullable<boolean>): void;
  66631. }
  66632. }
  66633. declare module BABYLON {
  66634. /**
  66635. * Based on jsTGALoader - Javascript loader for TGA file
  66636. * By Vincent Thibault
  66637. * @see http://blog.robrowser.com/javascript-tga-loader.html
  66638. */
  66639. export class TGATools {
  66640. private static _TYPE_INDEXED;
  66641. private static _TYPE_RGB;
  66642. private static _TYPE_GREY;
  66643. private static _TYPE_RLE_INDEXED;
  66644. private static _TYPE_RLE_RGB;
  66645. private static _TYPE_RLE_GREY;
  66646. private static _ORIGIN_MASK;
  66647. private static _ORIGIN_SHIFT;
  66648. private static _ORIGIN_BL;
  66649. private static _ORIGIN_BR;
  66650. private static _ORIGIN_UL;
  66651. private static _ORIGIN_UR;
  66652. /**
  66653. * Gets the header of a TGA file
  66654. * @param data defines the TGA data
  66655. * @returns the header
  66656. */
  66657. static GetTGAHeader(data: Uint8Array): any;
  66658. /**
  66659. * Uploads TGA content to a Babylon Texture
  66660. * @hidden
  66661. */
  66662. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  66663. /** @hidden */
  66664. 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;
  66665. /** @hidden */
  66666. 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;
  66667. /** @hidden */
  66668. 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;
  66669. /** @hidden */
  66670. 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;
  66671. /** @hidden */
  66672. 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;
  66673. /** @hidden */
  66674. 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;
  66675. }
  66676. }
  66677. declare module BABYLON {
  66678. /**
  66679. * Implementation of the TGA Texture Loader.
  66680. * @hidden
  66681. */
  66682. export class _TGATextureLoader implements IInternalTextureLoader {
  66683. /**
  66684. * Defines whether the loader supports cascade loading the different faces.
  66685. */
  66686. readonly supportCascades: boolean;
  66687. /**
  66688. * This returns if the loader support the current file information.
  66689. * @param extension defines the file extension of the file being loaded
  66690. * @returns true if the loader can load the specified file
  66691. */
  66692. canLoad(extension: string): boolean;
  66693. /**
  66694. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66695. * @param data contains the texture data
  66696. * @param texture defines the BabylonJS internal texture
  66697. * @param createPolynomials will be true if polynomials have been requested
  66698. * @param onLoad defines the callback to trigger once the texture is ready
  66699. * @param onError defines the callback to trigger in case of error
  66700. */
  66701. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66702. /**
  66703. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66704. * @param data contains the texture data
  66705. * @param texture defines the BabylonJS internal texture
  66706. * @param callback defines the method to call once ready to upload
  66707. */
  66708. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66709. }
  66710. }
  66711. declare module BABYLON {
  66712. /**
  66713. * Implementation of the HDR Texture Loader.
  66714. * @hidden
  66715. */
  66716. export class _HDRTextureLoader implements IInternalTextureLoader {
  66717. /**
  66718. * Defines whether the loader supports cascade loading the different faces.
  66719. */
  66720. readonly supportCascades: boolean;
  66721. /**
  66722. * This returns if the loader support the current file information.
  66723. * @param extension defines the file extension of the file being loaded
  66724. * @returns true if the loader can load the specified file
  66725. */
  66726. canLoad(extension: string): boolean;
  66727. /**
  66728. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66729. * @param data contains the texture data
  66730. * @param texture defines the BabylonJS internal texture
  66731. * @param createPolynomials will be true if polynomials have been requested
  66732. * @param onLoad defines the callback to trigger once the texture is ready
  66733. * @param onError defines the callback to trigger in case of error
  66734. */
  66735. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66736. /**
  66737. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66738. * @param data contains the texture data
  66739. * @param texture defines the BabylonJS internal texture
  66740. * @param callback defines the method to call once ready to upload
  66741. */
  66742. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66743. }
  66744. }
  66745. declare module BABYLON {
  66746. /**
  66747. * Info about the .basis files
  66748. */
  66749. class BasisFileInfo {
  66750. /**
  66751. * If the file has alpha
  66752. */
  66753. hasAlpha: boolean;
  66754. /**
  66755. * Info about each image of the basis file
  66756. */
  66757. images: Array<{
  66758. levels: Array<{
  66759. width: number;
  66760. height: number;
  66761. transcodedPixels: ArrayBufferView;
  66762. }>;
  66763. }>;
  66764. }
  66765. /**
  66766. * Result of transcoding a basis file
  66767. */
  66768. class TranscodeResult {
  66769. /**
  66770. * Info about the .basis file
  66771. */
  66772. fileInfo: BasisFileInfo;
  66773. /**
  66774. * Format to use when loading the file
  66775. */
  66776. format: number;
  66777. }
  66778. /**
  66779. * Configuration options for the Basis transcoder
  66780. */
  66781. export class BasisTranscodeConfiguration {
  66782. /**
  66783. * Supported compression formats used to determine the supported output format of the transcoder
  66784. */
  66785. supportedCompressionFormats?: {
  66786. /**
  66787. * etc1 compression format
  66788. */
  66789. etc1?: boolean;
  66790. /**
  66791. * s3tc compression format
  66792. */
  66793. s3tc?: boolean;
  66794. /**
  66795. * pvrtc compression format
  66796. */
  66797. pvrtc?: boolean;
  66798. /**
  66799. * etc2 compression format
  66800. */
  66801. etc2?: boolean;
  66802. };
  66803. /**
  66804. * If mipmap levels should be loaded for transcoded images (Default: true)
  66805. */
  66806. loadMipmapLevels?: boolean;
  66807. /**
  66808. * Index of a single image to load (Default: all images)
  66809. */
  66810. loadSingleImage?: number;
  66811. }
  66812. /**
  66813. * Used to load .Basis files
  66814. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  66815. */
  66816. export class BasisTools {
  66817. private static _IgnoreSupportedFormats;
  66818. /**
  66819. * URL to use when loading the basis transcoder
  66820. */
  66821. static JSModuleURL: string;
  66822. /**
  66823. * URL to use when loading the wasm module for the transcoder
  66824. */
  66825. static WasmModuleURL: string;
  66826. /**
  66827. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  66828. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  66829. * @returns internal format corresponding to the Basis format
  66830. */
  66831. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  66832. private static _WorkerPromise;
  66833. private static _Worker;
  66834. private static _actionId;
  66835. private static _CreateWorkerAsync;
  66836. /**
  66837. * Transcodes a loaded image file to compressed pixel data
  66838. * @param data image data to transcode
  66839. * @param config configuration options for the transcoding
  66840. * @returns a promise resulting in the transcoded image
  66841. */
  66842. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  66843. /**
  66844. * Loads a texture from the transcode result
  66845. * @param texture texture load to
  66846. * @param transcodeResult the result of transcoding the basis file to load from
  66847. */
  66848. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  66849. }
  66850. }
  66851. declare module BABYLON {
  66852. /**
  66853. * Loader for .basis file format
  66854. */
  66855. export class _BasisTextureLoader implements IInternalTextureLoader {
  66856. /**
  66857. * Defines whether the loader supports cascade loading the different faces.
  66858. */
  66859. readonly supportCascades: boolean;
  66860. /**
  66861. * This returns if the loader support the current file information.
  66862. * @param extension defines the file extension of the file being loaded
  66863. * @returns true if the loader can load the specified file
  66864. */
  66865. canLoad(extension: string): boolean;
  66866. /**
  66867. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66868. * @param data contains the texture data
  66869. * @param texture defines the BabylonJS internal texture
  66870. * @param createPolynomials will be true if polynomials have been requested
  66871. * @param onLoad defines the callback to trigger once the texture is ready
  66872. * @param onError defines the callback to trigger in case of error
  66873. */
  66874. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66875. /**
  66876. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66877. * @param data contains the texture data
  66878. * @param texture defines the BabylonJS internal texture
  66879. * @param callback defines the method to call once ready to upload
  66880. */
  66881. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66882. }
  66883. }
  66884. declare module BABYLON {
  66885. /**
  66886. * Defines the basic options interface of a TexturePacker Frame
  66887. */
  66888. export interface ITexturePackerFrame {
  66889. /**
  66890. * The frame ID
  66891. */
  66892. id: number;
  66893. /**
  66894. * The frames Scale
  66895. */
  66896. scale: Vector2;
  66897. /**
  66898. * The Frames offset
  66899. */
  66900. offset: Vector2;
  66901. }
  66902. /**
  66903. * This is a support class for frame Data on texture packer sets.
  66904. */
  66905. export class TexturePackerFrame implements ITexturePackerFrame {
  66906. /**
  66907. * The frame ID
  66908. */
  66909. id: number;
  66910. /**
  66911. * The frames Scale
  66912. */
  66913. scale: Vector2;
  66914. /**
  66915. * The Frames offset
  66916. */
  66917. offset: Vector2;
  66918. /**
  66919. * Initializes a texture package frame.
  66920. * @param id The numerical frame identifier
  66921. * @param scale Scalar Vector2 for UV frame
  66922. * @param offset Vector2 for the frame position in UV units.
  66923. * @returns TexturePackerFrame
  66924. */
  66925. constructor(id: number, scale: Vector2, offset: Vector2);
  66926. }
  66927. }
  66928. declare module BABYLON {
  66929. /**
  66930. * Defines the basic options interface of a TexturePacker
  66931. */
  66932. export interface ITexturePackerOptions {
  66933. /**
  66934. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  66935. */
  66936. map?: string[];
  66937. /**
  66938. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66939. */
  66940. uvsIn?: string;
  66941. /**
  66942. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66943. */
  66944. uvsOut?: string;
  66945. /**
  66946. * number representing the layout style. Defaults to LAYOUT_STRIP
  66947. */
  66948. layout?: number;
  66949. /**
  66950. * number of columns if using custom column count layout(2). This defaults to 4.
  66951. */
  66952. colnum?: number;
  66953. /**
  66954. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  66955. */
  66956. updateInputMeshes?: boolean;
  66957. /**
  66958. * boolean flag to dispose all the source textures. Defaults to true.
  66959. */
  66960. disposeSources?: boolean;
  66961. /**
  66962. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  66963. */
  66964. fillBlanks?: boolean;
  66965. /**
  66966. * string value representing the context fill style color. Defaults to 'black'.
  66967. */
  66968. customFillColor?: string;
  66969. /**
  66970. * Width and Height Value of each Frame in the TexturePacker Sets
  66971. */
  66972. frameSize?: number;
  66973. /**
  66974. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  66975. */
  66976. paddingRatio?: number;
  66977. /**
  66978. * Number that declares the fill method for the padding gutter.
  66979. */
  66980. paddingMode?: number;
  66981. /**
  66982. * If in SUBUV_COLOR padding mode what color to use.
  66983. */
  66984. paddingColor?: Color3 | Color4;
  66985. }
  66986. /**
  66987. * Defines the basic interface of a TexturePacker JSON File
  66988. */
  66989. export interface ITexturePackerJSON {
  66990. /**
  66991. * The frame ID
  66992. */
  66993. name: string;
  66994. /**
  66995. * The base64 channel data
  66996. */
  66997. sets: any;
  66998. /**
  66999. * The options of the Packer
  67000. */
  67001. options: ITexturePackerOptions;
  67002. /**
  67003. * The frame data of the Packer
  67004. */
  67005. frames: Array<number>;
  67006. }
  67007. /**
  67008. * This is a support class that generates a series of packed texture sets.
  67009. * @see https://doc.babylonjs.com/babylon101/materials
  67010. */
  67011. export class TexturePacker {
  67012. /** Packer Layout Constant 0 */
  67013. static readonly LAYOUT_STRIP: number;
  67014. /** Packer Layout Constant 1 */
  67015. static readonly LAYOUT_POWER2: number;
  67016. /** Packer Layout Constant 2 */
  67017. static readonly LAYOUT_COLNUM: number;
  67018. /** Packer Layout Constant 0 */
  67019. static readonly SUBUV_WRAP: number;
  67020. /** Packer Layout Constant 1 */
  67021. static readonly SUBUV_EXTEND: number;
  67022. /** Packer Layout Constant 2 */
  67023. static readonly SUBUV_COLOR: number;
  67024. /** The Name of the Texture Package */
  67025. name: string;
  67026. /** The scene scope of the TexturePacker */
  67027. scene: Scene;
  67028. /** The Meshes to target */
  67029. meshes: AbstractMesh[];
  67030. /** Arguments passed with the Constructor */
  67031. options: ITexturePackerOptions;
  67032. /** The promise that is started upon initialization */
  67033. promise: Nullable<Promise<TexturePacker | string>>;
  67034. /** The Container object for the channel sets that are generated */
  67035. sets: object;
  67036. /** The Container array for the frames that are generated */
  67037. frames: TexturePackerFrame[];
  67038. /** The expected number of textures the system is parsing. */
  67039. private _expecting;
  67040. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  67041. private _paddingValue;
  67042. /**
  67043. * Initializes a texture package series from an array of meshes or a single mesh.
  67044. * @param name The name of the package
  67045. * @param meshes The target meshes to compose the package from
  67046. * @param options The arguments that texture packer should follow while building.
  67047. * @param scene The scene which the textures are scoped to.
  67048. * @returns TexturePacker
  67049. */
  67050. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  67051. /**
  67052. * Starts the package process
  67053. * @param resolve The promises resolution function
  67054. * @returns TexturePacker
  67055. */
  67056. private _createFrames;
  67057. /**
  67058. * Calculates the Size of the Channel Sets
  67059. * @returns Vector2
  67060. */
  67061. private _calculateSize;
  67062. /**
  67063. * Calculates the UV data for the frames.
  67064. * @param baseSize the base frameSize
  67065. * @param padding the base frame padding
  67066. * @param dtSize size of the Dynamic Texture for that channel
  67067. * @param dtUnits is 1/dtSize
  67068. * @param update flag to update the input meshes
  67069. */
  67070. private _calculateMeshUVFrames;
  67071. /**
  67072. * Calculates the frames Offset.
  67073. * @param index of the frame
  67074. * @returns Vector2
  67075. */
  67076. private _getFrameOffset;
  67077. /**
  67078. * Updates a Mesh to the frame data
  67079. * @param mesh that is the target
  67080. * @param frameID or the frame index
  67081. */
  67082. private _updateMeshUV;
  67083. /**
  67084. * Updates a Meshes materials to use the texture packer channels
  67085. * @param m is the mesh to target
  67086. * @param force all channels on the packer to be set.
  67087. */
  67088. private _updateTextureReferences;
  67089. /**
  67090. * Public method to set a Mesh to a frame
  67091. * @param m that is the target
  67092. * @param frameID or the frame index
  67093. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  67094. */
  67095. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  67096. /**
  67097. * Starts the async promise to compile the texture packer.
  67098. * @returns Promise<void>
  67099. */
  67100. processAsync(): Promise<void>;
  67101. /**
  67102. * Disposes all textures associated with this packer
  67103. */
  67104. dispose(): void;
  67105. /**
  67106. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  67107. * @param imageType is the image type to use.
  67108. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  67109. */
  67110. download(imageType?: string, quality?: number): void;
  67111. /**
  67112. * Public method to load a texturePacker JSON file.
  67113. * @param data of the JSON file in string format.
  67114. */
  67115. updateFromJSON(data: string): void;
  67116. }
  67117. }
  67118. declare module BABYLON {
  67119. /**
  67120. * 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.
  67121. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  67122. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  67123. */
  67124. export class CustomProceduralTexture extends ProceduralTexture {
  67125. private _animate;
  67126. private _time;
  67127. private _config;
  67128. private _texturePath;
  67129. /**
  67130. * Instantiates a new Custom Procedural Texture.
  67131. * 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.
  67132. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  67133. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  67134. * @param name Define the name of the texture
  67135. * @param texturePath Define the folder path containing all the custom texture related files (config, shaders...)
  67136. * @param size Define the size of the texture to create
  67137. * @param scene Define the scene the texture belongs to
  67138. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  67139. * @param generateMipMaps Define if the texture should creates mip maps or not
  67140. */
  67141. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  67142. private _loadJson;
  67143. /**
  67144. * Is the texture ready to be used ? (rendered at least once)
  67145. * @returns true if ready, otherwise, false.
  67146. */
  67147. isReady(): boolean;
  67148. /**
  67149. * Render the texture to its associated render target.
  67150. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  67151. */
  67152. render(useCameraPostProcess?: boolean): void;
  67153. /**
  67154. * Update the list of dependant textures samplers in the shader.
  67155. */
  67156. updateTextures(): void;
  67157. /**
  67158. * Update the uniform values of the procedural texture in the shader.
  67159. */
  67160. updateShaderUniforms(): void;
  67161. /**
  67162. * Define if the texture animates or not.
  67163. */
  67164. get animate(): boolean;
  67165. set animate(value: boolean);
  67166. }
  67167. }
  67168. declare module BABYLON {
  67169. /** @hidden */
  67170. export var noisePixelShader: {
  67171. name: string;
  67172. shader: string;
  67173. };
  67174. }
  67175. declare module BABYLON {
  67176. /**
  67177. * Class used to generate noise procedural textures
  67178. */
  67179. export class NoiseProceduralTexture extends ProceduralTexture {
  67180. /** Gets or sets the start time (default is 0) */
  67181. time: number;
  67182. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  67183. brightness: number;
  67184. /** Defines the number of octaves to process */
  67185. octaves: number;
  67186. /** Defines the level of persistence (0.8 by default) */
  67187. persistence: number;
  67188. /** Gets or sets animation speed factor (default is 1) */
  67189. animationSpeedFactor: number;
  67190. /**
  67191. * Creates a new NoiseProceduralTexture
  67192. * @param name defines the name fo the texture
  67193. * @param size defines the size of the texture (default is 256)
  67194. * @param scene defines the hosting scene
  67195. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  67196. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  67197. */
  67198. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  67199. private _updateShaderUniforms;
  67200. protected _getDefines(): string;
  67201. /** Generate the current state of the procedural texture */
  67202. render(useCameraPostProcess?: boolean): void;
  67203. /**
  67204. * Serializes this noise procedural texture
  67205. * @returns a serialized noise procedural texture object
  67206. */
  67207. serialize(): any;
  67208. /**
  67209. * Clone the texture.
  67210. * @returns the cloned texture
  67211. */
  67212. clone(): NoiseProceduralTexture;
  67213. /**
  67214. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  67215. * @param parsedTexture defines parsed texture data
  67216. * @param scene defines the current scene
  67217. * @param rootUrl defines the root URL containing noise procedural texture information
  67218. * @returns a parsed NoiseProceduralTexture
  67219. */
  67220. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  67221. }
  67222. }
  67223. declare module BABYLON {
  67224. /**
  67225. * Raw cube texture where the raw buffers are passed in
  67226. */
  67227. export class RawCubeTexture extends CubeTexture {
  67228. /**
  67229. * Creates a cube texture where the raw buffers are passed in.
  67230. * @param scene defines the scene the texture is attached to
  67231. * @param data defines the array of data to use to create each face
  67232. * @param size defines the size of the textures
  67233. * @param format defines the format of the data
  67234. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  67235. * @param generateMipMaps defines if the engine should generate the mip levels
  67236. * @param invertY defines if data must be stored with Y axis inverted
  67237. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  67238. * @param compression defines the compression used (null by default)
  67239. */
  67240. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  67241. /**
  67242. * Updates the raw cube texture.
  67243. * @param data defines the data to store
  67244. * @param format defines the data format
  67245. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67246. * @param invertY defines if data must be stored with Y axis inverted
  67247. * @param compression defines the compression used (null by default)
  67248. * @param level defines which level of the texture to update
  67249. */
  67250. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  67251. /**
  67252. * Updates a raw cube texture with RGBD encoded data.
  67253. * @param data defines the array of data [mipmap][face] to use to create each face
  67254. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  67255. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  67256. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  67257. * @returns a promise that resolves when the operation is complete
  67258. */
  67259. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  67260. /**
  67261. * Clones the raw cube texture.
  67262. * @return a new cube texture
  67263. */
  67264. clone(): CubeTexture;
  67265. /** @hidden */
  67266. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  67267. }
  67268. }
  67269. declare module BABYLON {
  67270. /**
  67271. * Class used to store 3D textures containing user data
  67272. */
  67273. export class RawTexture3D extends Texture {
  67274. /** Gets or sets the texture format to use */
  67275. format: number;
  67276. /**
  67277. * Create a new RawTexture3D
  67278. * @param data defines the data of the texture
  67279. * @param width defines the width of the texture
  67280. * @param height defines the height of the texture
  67281. * @param depth defines the depth of the texture
  67282. * @param format defines the texture format to use
  67283. * @param scene defines the hosting scene
  67284. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  67285. * @param invertY defines if texture must be stored with Y axis inverted
  67286. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67287. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  67288. */
  67289. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  67290. /** Gets or sets the texture format to use */
  67291. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  67292. /**
  67293. * Update the texture with new data
  67294. * @param data defines the data to store in the texture
  67295. */
  67296. update(data: ArrayBufferView): void;
  67297. }
  67298. }
  67299. declare module BABYLON {
  67300. /**
  67301. * Creates a refraction texture used by refraction channel of the standard material.
  67302. * It is like a mirror but to see through a material.
  67303. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  67304. */
  67305. export class RefractionTexture extends RenderTargetTexture {
  67306. /**
  67307. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  67308. * 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.
  67309. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  67310. */
  67311. refractionPlane: Plane;
  67312. /**
  67313. * Define how deep under the surface we should see.
  67314. */
  67315. depth: number;
  67316. /**
  67317. * Creates a refraction texture used by refraction channel of the standard material.
  67318. * It is like a mirror but to see through a material.
  67319. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  67320. * @param name Define the texture name
  67321. * @param size Define the size of the underlying texture
  67322. * @param scene Define the scene the refraction belongs to
  67323. * @param generateMipMaps Define if we need to generate mips level for the refraction
  67324. */
  67325. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  67326. /**
  67327. * Clone the refraction texture.
  67328. * @returns the cloned texture
  67329. */
  67330. clone(): RefractionTexture;
  67331. /**
  67332. * Serialize the texture to a JSON representation you could use in Parse later on
  67333. * @returns the serialized JSON representation
  67334. */
  67335. serialize(): any;
  67336. }
  67337. }
  67338. declare module BABYLON {
  67339. /**
  67340. * Block used to add support for vertex skinning (bones)
  67341. */
  67342. export class BonesBlock extends NodeMaterialBlock {
  67343. /**
  67344. * Creates a new BonesBlock
  67345. * @param name defines the block name
  67346. */
  67347. constructor(name: string);
  67348. /**
  67349. * Initialize the block and prepare the context for build
  67350. * @param state defines the state that will be used for the build
  67351. */
  67352. initialize(state: NodeMaterialBuildState): void;
  67353. /**
  67354. * Gets the current class name
  67355. * @returns the class name
  67356. */
  67357. getClassName(): string;
  67358. /**
  67359. * Gets the matrix indices input component
  67360. */
  67361. get matricesIndices(): NodeMaterialConnectionPoint;
  67362. /**
  67363. * Gets the matrix weights input component
  67364. */
  67365. get matricesWeights(): NodeMaterialConnectionPoint;
  67366. /**
  67367. * Gets the extra matrix indices input component
  67368. */
  67369. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  67370. /**
  67371. * Gets the extra matrix weights input component
  67372. */
  67373. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  67374. /**
  67375. * Gets the world input component
  67376. */
  67377. get world(): NodeMaterialConnectionPoint;
  67378. /**
  67379. * Gets the output component
  67380. */
  67381. get output(): NodeMaterialConnectionPoint;
  67382. autoConfigure(material: NodeMaterial): void;
  67383. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  67384. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67385. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67386. protected _buildBlock(state: NodeMaterialBuildState): this;
  67387. }
  67388. }
  67389. declare module BABYLON {
  67390. /**
  67391. * Block used to add support for instances
  67392. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  67393. */
  67394. export class InstancesBlock extends NodeMaterialBlock {
  67395. /**
  67396. * Creates a new InstancesBlock
  67397. * @param name defines the block name
  67398. */
  67399. constructor(name: string);
  67400. /**
  67401. * Gets the current class name
  67402. * @returns the class name
  67403. */
  67404. getClassName(): string;
  67405. /**
  67406. * Gets the first world row input component
  67407. */
  67408. get world0(): NodeMaterialConnectionPoint;
  67409. /**
  67410. * Gets the second world row input component
  67411. */
  67412. get world1(): NodeMaterialConnectionPoint;
  67413. /**
  67414. * Gets the third world row input component
  67415. */
  67416. get world2(): NodeMaterialConnectionPoint;
  67417. /**
  67418. * Gets the forth world row input component
  67419. */
  67420. get world3(): NodeMaterialConnectionPoint;
  67421. /**
  67422. * Gets the world input component
  67423. */
  67424. get world(): NodeMaterialConnectionPoint;
  67425. /**
  67426. * Gets the output component
  67427. */
  67428. get output(): NodeMaterialConnectionPoint;
  67429. /**
  67430. * Gets the instanceID component
  67431. */
  67432. get instanceID(): NodeMaterialConnectionPoint;
  67433. autoConfigure(material: NodeMaterial): void;
  67434. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  67435. protected _buildBlock(state: NodeMaterialBuildState): this;
  67436. }
  67437. }
  67438. declare module BABYLON {
  67439. /**
  67440. * Block used to add morph targets support to vertex shader
  67441. */
  67442. export class MorphTargetsBlock extends NodeMaterialBlock {
  67443. private _repeatableContentAnchor;
  67444. /**
  67445. * Create a new MorphTargetsBlock
  67446. * @param name defines the block name
  67447. */
  67448. constructor(name: string);
  67449. /**
  67450. * Gets the current class name
  67451. * @returns the class name
  67452. */
  67453. getClassName(): string;
  67454. /**
  67455. * Gets the position input component
  67456. */
  67457. get position(): NodeMaterialConnectionPoint;
  67458. /**
  67459. * Gets the normal input component
  67460. */
  67461. get normal(): NodeMaterialConnectionPoint;
  67462. /**
  67463. * Gets the tangent input component
  67464. */
  67465. get tangent(): NodeMaterialConnectionPoint;
  67466. /**
  67467. * Gets the tangent input component
  67468. */
  67469. get uv(): NodeMaterialConnectionPoint;
  67470. /**
  67471. * Gets the position output component
  67472. */
  67473. get positionOutput(): NodeMaterialConnectionPoint;
  67474. /**
  67475. * Gets the normal output component
  67476. */
  67477. get normalOutput(): NodeMaterialConnectionPoint;
  67478. /**
  67479. * Gets the tangent output component
  67480. */
  67481. get tangentOutput(): NodeMaterialConnectionPoint;
  67482. /**
  67483. * Gets the tangent output component
  67484. */
  67485. get uvOutput(): NodeMaterialConnectionPoint;
  67486. initialize(state: NodeMaterialBuildState): void;
  67487. autoConfigure(material: NodeMaterial): void;
  67488. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67489. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67490. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  67491. protected _buildBlock(state: NodeMaterialBuildState): this;
  67492. }
  67493. }
  67494. declare module BABYLON {
  67495. /**
  67496. * Block used to get data information from a light
  67497. */
  67498. export class LightInformationBlock extends NodeMaterialBlock {
  67499. private _lightDataUniformName;
  67500. private _lightColorUniformName;
  67501. private _lightTypeDefineName;
  67502. /**
  67503. * Gets or sets the light associated with this block
  67504. */
  67505. light: Nullable<Light>;
  67506. /**
  67507. * Creates a new LightInformationBlock
  67508. * @param name defines the block name
  67509. */
  67510. constructor(name: string);
  67511. /**
  67512. * Gets the current class name
  67513. * @returns the class name
  67514. */
  67515. getClassName(): string;
  67516. /**
  67517. * Gets the world position input component
  67518. */
  67519. get worldPosition(): NodeMaterialConnectionPoint;
  67520. /**
  67521. * Gets the direction output component
  67522. */
  67523. get direction(): NodeMaterialConnectionPoint;
  67524. /**
  67525. * Gets the direction output component
  67526. */
  67527. get color(): NodeMaterialConnectionPoint;
  67528. /**
  67529. * Gets the direction output component
  67530. */
  67531. get intensity(): NodeMaterialConnectionPoint;
  67532. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67533. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67534. protected _buildBlock(state: NodeMaterialBuildState): this;
  67535. serialize(): any;
  67536. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67537. }
  67538. }
  67539. declare module BABYLON {
  67540. /**
  67541. * Block used to add image processing support to fragment shader
  67542. */
  67543. export class ImageProcessingBlock extends NodeMaterialBlock {
  67544. /**
  67545. * Create a new ImageProcessingBlock
  67546. * @param name defines the block name
  67547. */
  67548. constructor(name: string);
  67549. /**
  67550. * Gets the current class name
  67551. * @returns the class name
  67552. */
  67553. getClassName(): string;
  67554. /**
  67555. * Gets the color input component
  67556. */
  67557. get color(): NodeMaterialConnectionPoint;
  67558. /**
  67559. * Gets the output component
  67560. */
  67561. get output(): NodeMaterialConnectionPoint;
  67562. /**
  67563. * Initialize the block and prepare the context for build
  67564. * @param state defines the state that will be used for the build
  67565. */
  67566. initialize(state: NodeMaterialBuildState): void;
  67567. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  67568. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67569. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67570. protected _buildBlock(state: NodeMaterialBuildState): this;
  67571. }
  67572. }
  67573. declare module BABYLON {
  67574. /**
  67575. * Block used to perturb normals based on a normal map
  67576. */
  67577. export class PerturbNormalBlock extends NodeMaterialBlock {
  67578. private _tangentSpaceParameterName;
  67579. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67580. invertX: boolean;
  67581. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  67582. invertY: boolean;
  67583. /**
  67584. * Create a new PerturbNormalBlock
  67585. * @param name defines the block name
  67586. */
  67587. constructor(name: string);
  67588. /**
  67589. * Gets the current class name
  67590. * @returns the class name
  67591. */
  67592. getClassName(): string;
  67593. /**
  67594. * Gets the world position input component
  67595. */
  67596. get worldPosition(): NodeMaterialConnectionPoint;
  67597. /**
  67598. * Gets the world normal input component
  67599. */
  67600. get worldNormal(): NodeMaterialConnectionPoint;
  67601. /**
  67602. * Gets the world tangent input component
  67603. */
  67604. get worldTangent(): NodeMaterialConnectionPoint;
  67605. /**
  67606. * Gets the uv input component
  67607. */
  67608. get uv(): NodeMaterialConnectionPoint;
  67609. /**
  67610. * Gets the normal map color input component
  67611. */
  67612. get normalMapColor(): NodeMaterialConnectionPoint;
  67613. /**
  67614. * Gets the strength input component
  67615. */
  67616. get strength(): NodeMaterialConnectionPoint;
  67617. /**
  67618. * Gets the output component
  67619. */
  67620. get output(): NodeMaterialConnectionPoint;
  67621. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67622. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67623. autoConfigure(material: NodeMaterial): void;
  67624. protected _buildBlock(state: NodeMaterialBuildState): this;
  67625. protected _dumpPropertiesCode(): string;
  67626. serialize(): any;
  67627. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67628. }
  67629. }
  67630. declare module BABYLON {
  67631. /**
  67632. * Block used to discard a pixel if a value is smaller than a cutoff
  67633. */
  67634. export class DiscardBlock extends NodeMaterialBlock {
  67635. /**
  67636. * Create a new DiscardBlock
  67637. * @param name defines the block name
  67638. */
  67639. constructor(name: string);
  67640. /**
  67641. * Gets the current class name
  67642. * @returns the class name
  67643. */
  67644. getClassName(): string;
  67645. /**
  67646. * Gets the color input component
  67647. */
  67648. get value(): NodeMaterialConnectionPoint;
  67649. /**
  67650. * Gets the cutoff input component
  67651. */
  67652. get cutoff(): NodeMaterialConnectionPoint;
  67653. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67654. }
  67655. }
  67656. declare module BABYLON {
  67657. /**
  67658. * Block used to test if the fragment shader is front facing
  67659. */
  67660. export class FrontFacingBlock extends NodeMaterialBlock {
  67661. /**
  67662. * Creates a new FrontFacingBlock
  67663. * @param name defines the block name
  67664. */
  67665. constructor(name: string);
  67666. /**
  67667. * Gets the current class name
  67668. * @returns the class name
  67669. */
  67670. getClassName(): string;
  67671. /**
  67672. * Gets the output component
  67673. */
  67674. get output(): NodeMaterialConnectionPoint;
  67675. protected _buildBlock(state: NodeMaterialBuildState): this;
  67676. }
  67677. }
  67678. declare module BABYLON {
  67679. /**
  67680. * Block used to get the derivative value on x and y of a given input
  67681. */
  67682. export class DerivativeBlock extends NodeMaterialBlock {
  67683. /**
  67684. * Create a new DerivativeBlock
  67685. * @param name defines the block name
  67686. */
  67687. constructor(name: string);
  67688. /**
  67689. * Gets the current class name
  67690. * @returns the class name
  67691. */
  67692. getClassName(): string;
  67693. /**
  67694. * Gets the input component
  67695. */
  67696. get input(): NodeMaterialConnectionPoint;
  67697. /**
  67698. * Gets the derivative output on x
  67699. */
  67700. get dx(): NodeMaterialConnectionPoint;
  67701. /**
  67702. * Gets the derivative output on y
  67703. */
  67704. get dy(): NodeMaterialConnectionPoint;
  67705. protected _buildBlock(state: NodeMaterialBuildState): this;
  67706. }
  67707. }
  67708. declare module BABYLON {
  67709. /**
  67710. * Block used to make gl_FragCoord available
  67711. */
  67712. export class FragCoordBlock extends NodeMaterialBlock {
  67713. /**
  67714. * Creates a new FragCoordBlock
  67715. * @param name defines the block name
  67716. */
  67717. constructor(name: string);
  67718. /**
  67719. * Gets the current class name
  67720. * @returns the class name
  67721. */
  67722. getClassName(): string;
  67723. /**
  67724. * Gets the xy component
  67725. */
  67726. get xy(): NodeMaterialConnectionPoint;
  67727. /**
  67728. * Gets the xyz component
  67729. */
  67730. get xyz(): NodeMaterialConnectionPoint;
  67731. /**
  67732. * Gets the xyzw component
  67733. */
  67734. get xyzw(): NodeMaterialConnectionPoint;
  67735. /**
  67736. * Gets the x component
  67737. */
  67738. get x(): NodeMaterialConnectionPoint;
  67739. /**
  67740. * Gets the y component
  67741. */
  67742. get y(): NodeMaterialConnectionPoint;
  67743. /**
  67744. * Gets the z component
  67745. */
  67746. get z(): NodeMaterialConnectionPoint;
  67747. /**
  67748. * Gets the w component
  67749. */
  67750. get output(): NodeMaterialConnectionPoint;
  67751. protected writeOutputs(state: NodeMaterialBuildState): string;
  67752. protected _buildBlock(state: NodeMaterialBuildState): this;
  67753. }
  67754. }
  67755. declare module BABYLON {
  67756. /**
  67757. * Block used to get the screen sizes
  67758. */
  67759. export class ScreenSizeBlock extends NodeMaterialBlock {
  67760. private _varName;
  67761. private _scene;
  67762. /**
  67763. * Creates a new ScreenSizeBlock
  67764. * @param name defines the block name
  67765. */
  67766. constructor(name: string);
  67767. /**
  67768. * Gets the current class name
  67769. * @returns the class name
  67770. */
  67771. getClassName(): string;
  67772. /**
  67773. * Gets the xy component
  67774. */
  67775. get xy(): NodeMaterialConnectionPoint;
  67776. /**
  67777. * Gets the x component
  67778. */
  67779. get x(): NodeMaterialConnectionPoint;
  67780. /**
  67781. * Gets the y component
  67782. */
  67783. get y(): NodeMaterialConnectionPoint;
  67784. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67785. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  67786. protected _buildBlock(state: NodeMaterialBuildState): this;
  67787. }
  67788. }
  67789. declare module BABYLON {
  67790. /**
  67791. * Block used to add support for scene fog
  67792. */
  67793. export class FogBlock extends NodeMaterialBlock {
  67794. private _fogDistanceName;
  67795. private _fogParameters;
  67796. /**
  67797. * Create a new FogBlock
  67798. * @param name defines the block name
  67799. */
  67800. constructor(name: string);
  67801. /**
  67802. * Gets the current class name
  67803. * @returns the class name
  67804. */
  67805. getClassName(): string;
  67806. /**
  67807. * Gets the world position input component
  67808. */
  67809. get worldPosition(): NodeMaterialConnectionPoint;
  67810. /**
  67811. * Gets the view input component
  67812. */
  67813. get view(): NodeMaterialConnectionPoint;
  67814. /**
  67815. * Gets the color input component
  67816. */
  67817. get input(): NodeMaterialConnectionPoint;
  67818. /**
  67819. * Gets the fog color input component
  67820. */
  67821. get fogColor(): NodeMaterialConnectionPoint;
  67822. /**
  67823. * Gets the output component
  67824. */
  67825. get output(): NodeMaterialConnectionPoint;
  67826. autoConfigure(material: NodeMaterial): void;
  67827. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67828. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67829. protected _buildBlock(state: NodeMaterialBuildState): this;
  67830. }
  67831. }
  67832. declare module BABYLON {
  67833. /**
  67834. * Block used to add light in the fragment shader
  67835. */
  67836. export class LightBlock extends NodeMaterialBlock {
  67837. private _lightId;
  67838. /**
  67839. * Gets or sets the light associated with this block
  67840. */
  67841. light: Nullable<Light>;
  67842. /**
  67843. * Create a new LightBlock
  67844. * @param name defines the block name
  67845. */
  67846. constructor(name: string);
  67847. /**
  67848. * Gets the current class name
  67849. * @returns the class name
  67850. */
  67851. getClassName(): string;
  67852. /**
  67853. * Gets the world position input component
  67854. */
  67855. get worldPosition(): NodeMaterialConnectionPoint;
  67856. /**
  67857. * Gets the world normal input component
  67858. */
  67859. get worldNormal(): NodeMaterialConnectionPoint;
  67860. /**
  67861. * Gets the camera (or eye) position component
  67862. */
  67863. get cameraPosition(): NodeMaterialConnectionPoint;
  67864. /**
  67865. * Gets the glossiness component
  67866. */
  67867. get glossiness(): NodeMaterialConnectionPoint;
  67868. /**
  67869. * Gets the glossiness power component
  67870. */
  67871. get glossPower(): NodeMaterialConnectionPoint;
  67872. /**
  67873. * Gets the diffuse color component
  67874. */
  67875. get diffuseColor(): NodeMaterialConnectionPoint;
  67876. /**
  67877. * Gets the specular color component
  67878. */
  67879. get specularColor(): NodeMaterialConnectionPoint;
  67880. /**
  67881. * Gets the view matrix component
  67882. */
  67883. get view(): NodeMaterialConnectionPoint;
  67884. /**
  67885. * Gets the diffuse output component
  67886. */
  67887. get diffuseOutput(): NodeMaterialConnectionPoint;
  67888. /**
  67889. * Gets the specular output component
  67890. */
  67891. get specularOutput(): NodeMaterialConnectionPoint;
  67892. /**
  67893. * Gets the shadow output component
  67894. */
  67895. get shadow(): NodeMaterialConnectionPoint;
  67896. autoConfigure(material: NodeMaterial): void;
  67897. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67898. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67899. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67900. private _injectVertexCode;
  67901. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67902. serialize(): any;
  67903. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67904. }
  67905. }
  67906. declare module BABYLON {
  67907. /**
  67908. * Block used to read a reflection texture from a sampler
  67909. */
  67910. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  67911. /**
  67912. * Create a new ReflectionTextureBlock
  67913. * @param name defines the block name
  67914. */
  67915. constructor(name: string);
  67916. /**
  67917. * Gets the current class name
  67918. * @returns the class name
  67919. */
  67920. getClassName(): string;
  67921. /**
  67922. * Gets the world position input component
  67923. */
  67924. get position(): NodeMaterialConnectionPoint;
  67925. /**
  67926. * Gets the world position input component
  67927. */
  67928. get worldPosition(): NodeMaterialConnectionPoint;
  67929. /**
  67930. * Gets the world normal input component
  67931. */
  67932. get worldNormal(): NodeMaterialConnectionPoint;
  67933. /**
  67934. * Gets the world input component
  67935. */
  67936. get world(): NodeMaterialConnectionPoint;
  67937. /**
  67938. * Gets the camera (or eye) position component
  67939. */
  67940. get cameraPosition(): NodeMaterialConnectionPoint;
  67941. /**
  67942. * Gets the view input component
  67943. */
  67944. get view(): NodeMaterialConnectionPoint;
  67945. /**
  67946. * Gets the rgb output component
  67947. */
  67948. get rgb(): NodeMaterialConnectionPoint;
  67949. /**
  67950. * Gets the rgba output component
  67951. */
  67952. get rgba(): NodeMaterialConnectionPoint;
  67953. /**
  67954. * Gets the r output component
  67955. */
  67956. get r(): NodeMaterialConnectionPoint;
  67957. /**
  67958. * Gets the g output component
  67959. */
  67960. get g(): NodeMaterialConnectionPoint;
  67961. /**
  67962. * Gets the b output component
  67963. */
  67964. get b(): NodeMaterialConnectionPoint;
  67965. /**
  67966. * Gets the a output component
  67967. */
  67968. get a(): NodeMaterialConnectionPoint;
  67969. autoConfigure(material: NodeMaterial): void;
  67970. protected _buildBlock(state: NodeMaterialBuildState): this;
  67971. }
  67972. }
  67973. declare module BABYLON {
  67974. /**
  67975. * Block used to add 2 vectors
  67976. */
  67977. export class AddBlock extends NodeMaterialBlock {
  67978. /**
  67979. * Creates a new AddBlock
  67980. * @param name defines the block name
  67981. */
  67982. constructor(name: string);
  67983. /**
  67984. * Gets the current class name
  67985. * @returns the class name
  67986. */
  67987. getClassName(): string;
  67988. /**
  67989. * Gets the left operand input component
  67990. */
  67991. get left(): NodeMaterialConnectionPoint;
  67992. /**
  67993. * Gets the right operand input component
  67994. */
  67995. get right(): NodeMaterialConnectionPoint;
  67996. /**
  67997. * Gets the output component
  67998. */
  67999. get output(): NodeMaterialConnectionPoint;
  68000. protected _buildBlock(state: NodeMaterialBuildState): this;
  68001. }
  68002. }
  68003. declare module BABYLON {
  68004. /**
  68005. * Block used to scale a vector by a float
  68006. */
  68007. export class ScaleBlock extends NodeMaterialBlock {
  68008. /**
  68009. * Creates a new ScaleBlock
  68010. * @param name defines the block name
  68011. */
  68012. constructor(name: string);
  68013. /**
  68014. * Gets the current class name
  68015. * @returns the class name
  68016. */
  68017. getClassName(): string;
  68018. /**
  68019. * Gets the input component
  68020. */
  68021. get input(): NodeMaterialConnectionPoint;
  68022. /**
  68023. * Gets the factor input component
  68024. */
  68025. get factor(): NodeMaterialConnectionPoint;
  68026. /**
  68027. * Gets the output component
  68028. */
  68029. get output(): NodeMaterialConnectionPoint;
  68030. protected _buildBlock(state: NodeMaterialBuildState): this;
  68031. }
  68032. }
  68033. declare module BABYLON {
  68034. /**
  68035. * Block used to clamp a float
  68036. */
  68037. export class ClampBlock extends NodeMaterialBlock {
  68038. /** Gets or sets the minimum range */
  68039. minimum: number;
  68040. /** Gets or sets the maximum range */
  68041. maximum: number;
  68042. /**
  68043. * Creates a new ClampBlock
  68044. * @param name defines the block name
  68045. */
  68046. constructor(name: string);
  68047. /**
  68048. * Gets the current class name
  68049. * @returns the class name
  68050. */
  68051. getClassName(): string;
  68052. /**
  68053. * Gets the value input component
  68054. */
  68055. get value(): NodeMaterialConnectionPoint;
  68056. /**
  68057. * Gets the output component
  68058. */
  68059. get output(): NodeMaterialConnectionPoint;
  68060. protected _buildBlock(state: NodeMaterialBuildState): this;
  68061. protected _dumpPropertiesCode(): string;
  68062. serialize(): any;
  68063. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68064. }
  68065. }
  68066. declare module BABYLON {
  68067. /**
  68068. * Block used to apply a cross product between 2 vectors
  68069. */
  68070. export class CrossBlock extends NodeMaterialBlock {
  68071. /**
  68072. * Creates a new CrossBlock
  68073. * @param name defines the block name
  68074. */
  68075. constructor(name: string);
  68076. /**
  68077. * Gets the current class name
  68078. * @returns the class name
  68079. */
  68080. getClassName(): string;
  68081. /**
  68082. * Gets the left operand input component
  68083. */
  68084. get left(): NodeMaterialConnectionPoint;
  68085. /**
  68086. * Gets the right operand input component
  68087. */
  68088. get right(): NodeMaterialConnectionPoint;
  68089. /**
  68090. * Gets the output component
  68091. */
  68092. get output(): NodeMaterialConnectionPoint;
  68093. protected _buildBlock(state: NodeMaterialBuildState): this;
  68094. }
  68095. }
  68096. declare module BABYLON {
  68097. /**
  68098. * Block used to apply a dot product between 2 vectors
  68099. */
  68100. export class DotBlock extends NodeMaterialBlock {
  68101. /**
  68102. * Creates a new DotBlock
  68103. * @param name defines the block name
  68104. */
  68105. constructor(name: string);
  68106. /**
  68107. * Gets the current class name
  68108. * @returns the class name
  68109. */
  68110. getClassName(): string;
  68111. /**
  68112. * Gets the left operand input component
  68113. */
  68114. get left(): NodeMaterialConnectionPoint;
  68115. /**
  68116. * Gets the right operand input component
  68117. */
  68118. get right(): NodeMaterialConnectionPoint;
  68119. /**
  68120. * Gets the output component
  68121. */
  68122. get output(): NodeMaterialConnectionPoint;
  68123. protected _buildBlock(state: NodeMaterialBuildState): this;
  68124. }
  68125. }
  68126. declare module BABYLON {
  68127. /**
  68128. * Block used to normalize a vector
  68129. */
  68130. export class NormalizeBlock extends NodeMaterialBlock {
  68131. /**
  68132. * Creates a new NormalizeBlock
  68133. * @param name defines the block name
  68134. */
  68135. constructor(name: string);
  68136. /**
  68137. * Gets the current class name
  68138. * @returns the class name
  68139. */
  68140. getClassName(): string;
  68141. /**
  68142. * Gets the input component
  68143. */
  68144. get input(): NodeMaterialConnectionPoint;
  68145. /**
  68146. * Gets the output component
  68147. */
  68148. get output(): NodeMaterialConnectionPoint;
  68149. protected _buildBlock(state: NodeMaterialBuildState): this;
  68150. }
  68151. }
  68152. declare module BABYLON {
  68153. /**
  68154. * Block used to create a Color3/4 out of individual inputs (one for each component)
  68155. */
  68156. export class ColorMergerBlock extends NodeMaterialBlock {
  68157. /**
  68158. * Create a new ColorMergerBlock
  68159. * @param name defines the block name
  68160. */
  68161. constructor(name: string);
  68162. /**
  68163. * Gets the current class name
  68164. * @returns the class name
  68165. */
  68166. getClassName(): string;
  68167. /**
  68168. * Gets the rgb component (input)
  68169. */
  68170. get rgbIn(): NodeMaterialConnectionPoint;
  68171. /**
  68172. * Gets the r component (input)
  68173. */
  68174. get r(): NodeMaterialConnectionPoint;
  68175. /**
  68176. * Gets the g component (input)
  68177. */
  68178. get g(): NodeMaterialConnectionPoint;
  68179. /**
  68180. * Gets the b component (input)
  68181. */
  68182. get b(): NodeMaterialConnectionPoint;
  68183. /**
  68184. * Gets the a component (input)
  68185. */
  68186. get a(): NodeMaterialConnectionPoint;
  68187. /**
  68188. * Gets the rgba component (output)
  68189. */
  68190. get rgba(): NodeMaterialConnectionPoint;
  68191. /**
  68192. * Gets the rgb component (output)
  68193. */
  68194. get rgbOut(): NodeMaterialConnectionPoint;
  68195. /**
  68196. * Gets the rgb component (output)
  68197. * @deprecated Please use rgbOut instead.
  68198. */
  68199. get rgb(): NodeMaterialConnectionPoint;
  68200. protected _buildBlock(state: NodeMaterialBuildState): this;
  68201. }
  68202. }
  68203. declare module BABYLON {
  68204. /**
  68205. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  68206. */
  68207. export class VectorSplitterBlock extends NodeMaterialBlock {
  68208. /**
  68209. * Create a new VectorSplitterBlock
  68210. * @param name defines the block name
  68211. */
  68212. constructor(name: string);
  68213. /**
  68214. * Gets the current class name
  68215. * @returns the class name
  68216. */
  68217. getClassName(): string;
  68218. /**
  68219. * Gets the xyzw component (input)
  68220. */
  68221. get xyzw(): NodeMaterialConnectionPoint;
  68222. /**
  68223. * Gets the xyz component (input)
  68224. */
  68225. get xyzIn(): NodeMaterialConnectionPoint;
  68226. /**
  68227. * Gets the xy component (input)
  68228. */
  68229. get xyIn(): NodeMaterialConnectionPoint;
  68230. /**
  68231. * Gets the xyz component (output)
  68232. */
  68233. get xyzOut(): NodeMaterialConnectionPoint;
  68234. /**
  68235. * Gets the xy component (output)
  68236. */
  68237. get xyOut(): NodeMaterialConnectionPoint;
  68238. /**
  68239. * Gets the x component (output)
  68240. */
  68241. get x(): NodeMaterialConnectionPoint;
  68242. /**
  68243. * Gets the y component (output)
  68244. */
  68245. get y(): NodeMaterialConnectionPoint;
  68246. /**
  68247. * Gets the z component (output)
  68248. */
  68249. get z(): NodeMaterialConnectionPoint;
  68250. /**
  68251. * Gets the w component (output)
  68252. */
  68253. get w(): NodeMaterialConnectionPoint;
  68254. protected _inputRename(name: string): string;
  68255. protected _outputRename(name: string): string;
  68256. protected _buildBlock(state: NodeMaterialBuildState): this;
  68257. }
  68258. }
  68259. declare module BABYLON {
  68260. /**
  68261. * Block used to lerp between 2 values
  68262. */
  68263. export class LerpBlock extends NodeMaterialBlock {
  68264. /**
  68265. * Creates a new LerpBlock
  68266. * @param name defines the block name
  68267. */
  68268. constructor(name: string);
  68269. /**
  68270. * Gets the current class name
  68271. * @returns the class name
  68272. */
  68273. getClassName(): string;
  68274. /**
  68275. * Gets the left operand input component
  68276. */
  68277. get left(): NodeMaterialConnectionPoint;
  68278. /**
  68279. * Gets the right operand input component
  68280. */
  68281. get right(): NodeMaterialConnectionPoint;
  68282. /**
  68283. * Gets the gradient operand input component
  68284. */
  68285. get gradient(): NodeMaterialConnectionPoint;
  68286. /**
  68287. * Gets the output component
  68288. */
  68289. get output(): NodeMaterialConnectionPoint;
  68290. protected _buildBlock(state: NodeMaterialBuildState): this;
  68291. }
  68292. }
  68293. declare module BABYLON {
  68294. /**
  68295. * Block used to divide 2 vectors
  68296. */
  68297. export class DivideBlock extends NodeMaterialBlock {
  68298. /**
  68299. * Creates a new DivideBlock
  68300. * @param name defines the block name
  68301. */
  68302. constructor(name: string);
  68303. /**
  68304. * Gets the current class name
  68305. * @returns the class name
  68306. */
  68307. getClassName(): string;
  68308. /**
  68309. * Gets the left operand input component
  68310. */
  68311. get left(): NodeMaterialConnectionPoint;
  68312. /**
  68313. * Gets the right operand input component
  68314. */
  68315. get right(): NodeMaterialConnectionPoint;
  68316. /**
  68317. * Gets the output component
  68318. */
  68319. get output(): NodeMaterialConnectionPoint;
  68320. protected _buildBlock(state: NodeMaterialBuildState): this;
  68321. }
  68322. }
  68323. declare module BABYLON {
  68324. /**
  68325. * Block used to subtract 2 vectors
  68326. */
  68327. export class SubtractBlock extends NodeMaterialBlock {
  68328. /**
  68329. * Creates a new SubtractBlock
  68330. * @param name defines the block name
  68331. */
  68332. constructor(name: string);
  68333. /**
  68334. * Gets the current class name
  68335. * @returns the class name
  68336. */
  68337. getClassName(): string;
  68338. /**
  68339. * Gets the left operand input component
  68340. */
  68341. get left(): NodeMaterialConnectionPoint;
  68342. /**
  68343. * Gets the right operand input component
  68344. */
  68345. get right(): NodeMaterialConnectionPoint;
  68346. /**
  68347. * Gets the output component
  68348. */
  68349. get output(): NodeMaterialConnectionPoint;
  68350. protected _buildBlock(state: NodeMaterialBuildState): this;
  68351. }
  68352. }
  68353. declare module BABYLON {
  68354. /**
  68355. * Block used to step a value
  68356. */
  68357. export class StepBlock extends NodeMaterialBlock {
  68358. /**
  68359. * Creates a new StepBlock
  68360. * @param name defines the block name
  68361. */
  68362. constructor(name: string);
  68363. /**
  68364. * Gets the current class name
  68365. * @returns the class name
  68366. */
  68367. getClassName(): string;
  68368. /**
  68369. * Gets the value operand input component
  68370. */
  68371. get value(): NodeMaterialConnectionPoint;
  68372. /**
  68373. * Gets the edge operand input component
  68374. */
  68375. get edge(): NodeMaterialConnectionPoint;
  68376. /**
  68377. * Gets the output component
  68378. */
  68379. get output(): NodeMaterialConnectionPoint;
  68380. protected _buildBlock(state: NodeMaterialBuildState): this;
  68381. }
  68382. }
  68383. declare module BABYLON {
  68384. /**
  68385. * Block used to get the opposite (1 - x) of a value
  68386. */
  68387. export class OneMinusBlock extends NodeMaterialBlock {
  68388. /**
  68389. * Creates a new OneMinusBlock
  68390. * @param name defines the block name
  68391. */
  68392. constructor(name: string);
  68393. /**
  68394. * Gets the current class name
  68395. * @returns the class name
  68396. */
  68397. getClassName(): string;
  68398. /**
  68399. * Gets the input component
  68400. */
  68401. get input(): NodeMaterialConnectionPoint;
  68402. /**
  68403. * Gets the output component
  68404. */
  68405. get output(): NodeMaterialConnectionPoint;
  68406. protected _buildBlock(state: NodeMaterialBuildState): this;
  68407. }
  68408. }
  68409. declare module BABYLON {
  68410. /**
  68411. * Block used to get the view direction
  68412. */
  68413. export class ViewDirectionBlock extends NodeMaterialBlock {
  68414. /**
  68415. * Creates a new ViewDirectionBlock
  68416. * @param name defines the block name
  68417. */
  68418. constructor(name: string);
  68419. /**
  68420. * Gets the current class name
  68421. * @returns the class name
  68422. */
  68423. getClassName(): string;
  68424. /**
  68425. * Gets the world position component
  68426. */
  68427. get worldPosition(): NodeMaterialConnectionPoint;
  68428. /**
  68429. * Gets the camera position component
  68430. */
  68431. get cameraPosition(): NodeMaterialConnectionPoint;
  68432. /**
  68433. * Gets the output component
  68434. */
  68435. get output(): NodeMaterialConnectionPoint;
  68436. autoConfigure(material: NodeMaterial): void;
  68437. protected _buildBlock(state: NodeMaterialBuildState): this;
  68438. }
  68439. }
  68440. declare module BABYLON {
  68441. /**
  68442. * Block used to compute fresnel value
  68443. */
  68444. export class FresnelBlock extends NodeMaterialBlock {
  68445. /**
  68446. * Create a new FresnelBlock
  68447. * @param name defines the block name
  68448. */
  68449. constructor(name: string);
  68450. /**
  68451. * Gets the current class name
  68452. * @returns the class name
  68453. */
  68454. getClassName(): string;
  68455. /**
  68456. * Gets the world normal input component
  68457. */
  68458. get worldNormal(): NodeMaterialConnectionPoint;
  68459. /**
  68460. * Gets the view direction input component
  68461. */
  68462. get viewDirection(): NodeMaterialConnectionPoint;
  68463. /**
  68464. * Gets the bias input component
  68465. */
  68466. get bias(): NodeMaterialConnectionPoint;
  68467. /**
  68468. * Gets the camera (or eye) position component
  68469. */
  68470. get power(): NodeMaterialConnectionPoint;
  68471. /**
  68472. * Gets the fresnel output component
  68473. */
  68474. get fresnel(): NodeMaterialConnectionPoint;
  68475. autoConfigure(material: NodeMaterial): void;
  68476. protected _buildBlock(state: NodeMaterialBuildState): this;
  68477. }
  68478. }
  68479. declare module BABYLON {
  68480. /**
  68481. * Block used to get the max of 2 values
  68482. */
  68483. export class MaxBlock extends NodeMaterialBlock {
  68484. /**
  68485. * Creates a new MaxBlock
  68486. * @param name defines the block name
  68487. */
  68488. constructor(name: string);
  68489. /**
  68490. * Gets the current class name
  68491. * @returns the class name
  68492. */
  68493. getClassName(): string;
  68494. /**
  68495. * Gets the left operand input component
  68496. */
  68497. get left(): NodeMaterialConnectionPoint;
  68498. /**
  68499. * Gets the right operand input component
  68500. */
  68501. get right(): NodeMaterialConnectionPoint;
  68502. /**
  68503. * Gets the output component
  68504. */
  68505. get output(): NodeMaterialConnectionPoint;
  68506. protected _buildBlock(state: NodeMaterialBuildState): this;
  68507. }
  68508. }
  68509. declare module BABYLON {
  68510. /**
  68511. * Block used to get the min of 2 values
  68512. */
  68513. export class MinBlock extends NodeMaterialBlock {
  68514. /**
  68515. * Creates a new MinBlock
  68516. * @param name defines the block name
  68517. */
  68518. constructor(name: string);
  68519. /**
  68520. * Gets the current class name
  68521. * @returns the class name
  68522. */
  68523. getClassName(): string;
  68524. /**
  68525. * Gets the left operand input component
  68526. */
  68527. get left(): NodeMaterialConnectionPoint;
  68528. /**
  68529. * Gets the right operand input component
  68530. */
  68531. get right(): NodeMaterialConnectionPoint;
  68532. /**
  68533. * Gets the output component
  68534. */
  68535. get output(): NodeMaterialConnectionPoint;
  68536. protected _buildBlock(state: NodeMaterialBuildState): this;
  68537. }
  68538. }
  68539. declare module BABYLON {
  68540. /**
  68541. * Block used to get the distance between 2 values
  68542. */
  68543. export class DistanceBlock extends NodeMaterialBlock {
  68544. /**
  68545. * Creates a new DistanceBlock
  68546. * @param name defines the block name
  68547. */
  68548. constructor(name: string);
  68549. /**
  68550. * Gets the current class name
  68551. * @returns the class name
  68552. */
  68553. getClassName(): string;
  68554. /**
  68555. * Gets the left operand input component
  68556. */
  68557. get left(): NodeMaterialConnectionPoint;
  68558. /**
  68559. * Gets the right operand input component
  68560. */
  68561. get right(): NodeMaterialConnectionPoint;
  68562. /**
  68563. * Gets the output component
  68564. */
  68565. get output(): NodeMaterialConnectionPoint;
  68566. protected _buildBlock(state: NodeMaterialBuildState): this;
  68567. }
  68568. }
  68569. declare module BABYLON {
  68570. /**
  68571. * Block used to get the length of a vector
  68572. */
  68573. export class LengthBlock extends NodeMaterialBlock {
  68574. /**
  68575. * Creates a new LengthBlock
  68576. * @param name defines the block name
  68577. */
  68578. constructor(name: string);
  68579. /**
  68580. * Gets the current class name
  68581. * @returns the class name
  68582. */
  68583. getClassName(): string;
  68584. /**
  68585. * Gets the value input component
  68586. */
  68587. get value(): NodeMaterialConnectionPoint;
  68588. /**
  68589. * Gets the output component
  68590. */
  68591. get output(): NodeMaterialConnectionPoint;
  68592. protected _buildBlock(state: NodeMaterialBuildState): this;
  68593. }
  68594. }
  68595. declare module BABYLON {
  68596. /**
  68597. * Block used to get negative version of a value (i.e. x * -1)
  68598. */
  68599. export class NegateBlock extends NodeMaterialBlock {
  68600. /**
  68601. * Creates a new NegateBlock
  68602. * @param name defines the block name
  68603. */
  68604. constructor(name: string);
  68605. /**
  68606. * Gets the current class name
  68607. * @returns the class name
  68608. */
  68609. getClassName(): string;
  68610. /**
  68611. * Gets the value input component
  68612. */
  68613. get value(): NodeMaterialConnectionPoint;
  68614. /**
  68615. * Gets the output component
  68616. */
  68617. get output(): NodeMaterialConnectionPoint;
  68618. protected _buildBlock(state: NodeMaterialBuildState): this;
  68619. }
  68620. }
  68621. declare module BABYLON {
  68622. /**
  68623. * Block used to get the value of the first parameter raised to the power of the second
  68624. */
  68625. export class PowBlock extends NodeMaterialBlock {
  68626. /**
  68627. * Creates a new PowBlock
  68628. * @param name defines the block name
  68629. */
  68630. constructor(name: string);
  68631. /**
  68632. * Gets the current class name
  68633. * @returns the class name
  68634. */
  68635. getClassName(): string;
  68636. /**
  68637. * Gets the value operand input component
  68638. */
  68639. get value(): NodeMaterialConnectionPoint;
  68640. /**
  68641. * Gets the power operand input component
  68642. */
  68643. get power(): NodeMaterialConnectionPoint;
  68644. /**
  68645. * Gets the output component
  68646. */
  68647. get output(): NodeMaterialConnectionPoint;
  68648. protected _buildBlock(state: NodeMaterialBuildState): this;
  68649. }
  68650. }
  68651. declare module BABYLON {
  68652. /**
  68653. * Block used to get a random number
  68654. */
  68655. export class RandomNumberBlock extends NodeMaterialBlock {
  68656. /**
  68657. * Creates a new RandomNumberBlock
  68658. * @param name defines the block name
  68659. */
  68660. constructor(name: string);
  68661. /**
  68662. * Gets the current class name
  68663. * @returns the class name
  68664. */
  68665. getClassName(): string;
  68666. /**
  68667. * Gets the seed input component
  68668. */
  68669. get seed(): NodeMaterialConnectionPoint;
  68670. /**
  68671. * Gets the output component
  68672. */
  68673. get output(): NodeMaterialConnectionPoint;
  68674. protected _buildBlock(state: NodeMaterialBuildState): this;
  68675. }
  68676. }
  68677. declare module BABYLON {
  68678. /**
  68679. * Block used to compute arc tangent of 2 values
  68680. */
  68681. export class ArcTan2Block extends NodeMaterialBlock {
  68682. /**
  68683. * Creates a new ArcTan2Block
  68684. * @param name defines the block name
  68685. */
  68686. constructor(name: string);
  68687. /**
  68688. * Gets the current class name
  68689. * @returns the class name
  68690. */
  68691. getClassName(): string;
  68692. /**
  68693. * Gets the x operand input component
  68694. */
  68695. get x(): NodeMaterialConnectionPoint;
  68696. /**
  68697. * Gets the y operand input component
  68698. */
  68699. get y(): NodeMaterialConnectionPoint;
  68700. /**
  68701. * Gets the output component
  68702. */
  68703. get output(): NodeMaterialConnectionPoint;
  68704. protected _buildBlock(state: NodeMaterialBuildState): this;
  68705. }
  68706. }
  68707. declare module BABYLON {
  68708. /**
  68709. * Block used to smooth step a value
  68710. */
  68711. export class SmoothStepBlock extends NodeMaterialBlock {
  68712. /**
  68713. * Creates a new SmoothStepBlock
  68714. * @param name defines the block name
  68715. */
  68716. constructor(name: string);
  68717. /**
  68718. * Gets the current class name
  68719. * @returns the class name
  68720. */
  68721. getClassName(): string;
  68722. /**
  68723. * Gets the value operand input component
  68724. */
  68725. get value(): NodeMaterialConnectionPoint;
  68726. /**
  68727. * Gets the first edge operand input component
  68728. */
  68729. get edge0(): NodeMaterialConnectionPoint;
  68730. /**
  68731. * Gets the second edge operand input component
  68732. */
  68733. get edge1(): NodeMaterialConnectionPoint;
  68734. /**
  68735. * Gets the output component
  68736. */
  68737. get output(): NodeMaterialConnectionPoint;
  68738. protected _buildBlock(state: NodeMaterialBuildState): this;
  68739. }
  68740. }
  68741. declare module BABYLON {
  68742. /**
  68743. * Block used to get the reciprocal (1 / x) of a value
  68744. */
  68745. export class ReciprocalBlock extends NodeMaterialBlock {
  68746. /**
  68747. * Creates a new ReciprocalBlock
  68748. * @param name defines the block name
  68749. */
  68750. constructor(name: string);
  68751. /**
  68752. * Gets the current class name
  68753. * @returns the class name
  68754. */
  68755. getClassName(): string;
  68756. /**
  68757. * Gets the input component
  68758. */
  68759. get input(): NodeMaterialConnectionPoint;
  68760. /**
  68761. * Gets the output component
  68762. */
  68763. get output(): NodeMaterialConnectionPoint;
  68764. protected _buildBlock(state: NodeMaterialBuildState): this;
  68765. }
  68766. }
  68767. declare module BABYLON {
  68768. /**
  68769. * Block used to replace a color by another one
  68770. */
  68771. export class ReplaceColorBlock extends NodeMaterialBlock {
  68772. /**
  68773. * Creates a new ReplaceColorBlock
  68774. * @param name defines the block name
  68775. */
  68776. constructor(name: string);
  68777. /**
  68778. * Gets the current class name
  68779. * @returns the class name
  68780. */
  68781. getClassName(): string;
  68782. /**
  68783. * Gets the value input component
  68784. */
  68785. get value(): NodeMaterialConnectionPoint;
  68786. /**
  68787. * Gets the reference input component
  68788. */
  68789. get reference(): NodeMaterialConnectionPoint;
  68790. /**
  68791. * Gets the distance input component
  68792. */
  68793. get distance(): NodeMaterialConnectionPoint;
  68794. /**
  68795. * Gets the replacement input component
  68796. */
  68797. get replacement(): NodeMaterialConnectionPoint;
  68798. /**
  68799. * Gets the output component
  68800. */
  68801. get output(): NodeMaterialConnectionPoint;
  68802. protected _buildBlock(state: NodeMaterialBuildState): this;
  68803. }
  68804. }
  68805. declare module BABYLON {
  68806. /**
  68807. * Block used to posterize a value
  68808. * @see https://en.wikipedia.org/wiki/Posterization
  68809. */
  68810. export class PosterizeBlock extends NodeMaterialBlock {
  68811. /**
  68812. * Creates a new PosterizeBlock
  68813. * @param name defines the block name
  68814. */
  68815. constructor(name: string);
  68816. /**
  68817. * Gets the current class name
  68818. * @returns the class name
  68819. */
  68820. getClassName(): string;
  68821. /**
  68822. * Gets the value input component
  68823. */
  68824. get value(): NodeMaterialConnectionPoint;
  68825. /**
  68826. * Gets the steps input component
  68827. */
  68828. get steps(): NodeMaterialConnectionPoint;
  68829. /**
  68830. * Gets the output component
  68831. */
  68832. get output(): NodeMaterialConnectionPoint;
  68833. protected _buildBlock(state: NodeMaterialBuildState): this;
  68834. }
  68835. }
  68836. declare module BABYLON {
  68837. /**
  68838. * Operations supported by the Wave block
  68839. */
  68840. export enum WaveBlockKind {
  68841. /** SawTooth */
  68842. SawTooth = 0,
  68843. /** Square */
  68844. Square = 1,
  68845. /** Triangle */
  68846. Triangle = 2
  68847. }
  68848. /**
  68849. * Block used to apply wave operation to floats
  68850. */
  68851. export class WaveBlock extends NodeMaterialBlock {
  68852. /**
  68853. * Gets or sets the kibnd of wave to be applied by the block
  68854. */
  68855. kind: WaveBlockKind;
  68856. /**
  68857. * Creates a new WaveBlock
  68858. * @param name defines the block name
  68859. */
  68860. constructor(name: string);
  68861. /**
  68862. * Gets the current class name
  68863. * @returns the class name
  68864. */
  68865. getClassName(): string;
  68866. /**
  68867. * Gets the input component
  68868. */
  68869. get input(): NodeMaterialConnectionPoint;
  68870. /**
  68871. * Gets the output component
  68872. */
  68873. get output(): NodeMaterialConnectionPoint;
  68874. protected _buildBlock(state: NodeMaterialBuildState): this;
  68875. serialize(): any;
  68876. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68877. }
  68878. }
  68879. declare module BABYLON {
  68880. /**
  68881. * Class used to store a color step for the GradientBlock
  68882. */
  68883. export class GradientBlockColorStep {
  68884. private _step;
  68885. /**
  68886. * Gets value indicating which step this color is associated with (between 0 and 1)
  68887. */
  68888. get step(): number;
  68889. /**
  68890. * Sets a value indicating which step this color is associated with (between 0 and 1)
  68891. */
  68892. set step(val: number);
  68893. private _color;
  68894. /**
  68895. * Gets the color associated with this step
  68896. */
  68897. get color(): Color3;
  68898. /**
  68899. * Sets the color associated with this step
  68900. */
  68901. set color(val: Color3);
  68902. /**
  68903. * Creates a new GradientBlockColorStep
  68904. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  68905. * @param color defines the color associated with this step
  68906. */
  68907. constructor(step: number, color: Color3);
  68908. }
  68909. /**
  68910. * Block used to return a color from a gradient based on an input value between 0 and 1
  68911. */
  68912. export class GradientBlock extends NodeMaterialBlock {
  68913. /**
  68914. * Gets or sets the list of color steps
  68915. */
  68916. colorSteps: GradientBlockColorStep[];
  68917. /** Gets an observable raised when the value is changed */
  68918. onValueChangedObservable: Observable<GradientBlock>;
  68919. /** calls observable when the value is changed*/
  68920. colorStepsUpdated(): void;
  68921. /**
  68922. * Creates a new GradientBlock
  68923. * @param name defines the block name
  68924. */
  68925. constructor(name: string);
  68926. /**
  68927. * Gets the current class name
  68928. * @returns the class name
  68929. */
  68930. getClassName(): string;
  68931. /**
  68932. * Gets the gradient input component
  68933. */
  68934. get gradient(): NodeMaterialConnectionPoint;
  68935. /**
  68936. * Gets the output component
  68937. */
  68938. get output(): NodeMaterialConnectionPoint;
  68939. private _writeColorConstant;
  68940. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68941. serialize(): any;
  68942. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68943. protected _dumpPropertiesCode(): string;
  68944. }
  68945. }
  68946. declare module BABYLON {
  68947. /**
  68948. * Block used to normalize lerp between 2 values
  68949. */
  68950. export class NLerpBlock extends NodeMaterialBlock {
  68951. /**
  68952. * Creates a new NLerpBlock
  68953. * @param name defines the block name
  68954. */
  68955. constructor(name: string);
  68956. /**
  68957. * Gets the current class name
  68958. * @returns the class name
  68959. */
  68960. getClassName(): string;
  68961. /**
  68962. * Gets the left operand input component
  68963. */
  68964. get left(): NodeMaterialConnectionPoint;
  68965. /**
  68966. * Gets the right operand input component
  68967. */
  68968. get right(): NodeMaterialConnectionPoint;
  68969. /**
  68970. * Gets the gradient operand input component
  68971. */
  68972. get gradient(): NodeMaterialConnectionPoint;
  68973. /**
  68974. * Gets the output component
  68975. */
  68976. get output(): NodeMaterialConnectionPoint;
  68977. protected _buildBlock(state: NodeMaterialBuildState): this;
  68978. }
  68979. }
  68980. declare module BABYLON {
  68981. /**
  68982. * block used to Generate a Worley Noise 3D Noise Pattern
  68983. */
  68984. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  68985. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  68986. manhattanDistance: boolean;
  68987. /**
  68988. * Creates a new WorleyNoise3DBlock
  68989. * @param name defines the block name
  68990. */
  68991. constructor(name: string);
  68992. /**
  68993. * Gets the current class name
  68994. * @returns the class name
  68995. */
  68996. getClassName(): string;
  68997. /**
  68998. * Gets the seed input component
  68999. */
  69000. get seed(): NodeMaterialConnectionPoint;
  69001. /**
  69002. * Gets the jitter input component
  69003. */
  69004. get jitter(): NodeMaterialConnectionPoint;
  69005. /**
  69006. * Gets the output component
  69007. */
  69008. get output(): NodeMaterialConnectionPoint;
  69009. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  69010. /**
  69011. * Exposes the properties to the UI?
  69012. */
  69013. protected _dumpPropertiesCode(): string;
  69014. /**
  69015. * Exposes the properties to the Serialize?
  69016. */
  69017. serialize(): any;
  69018. /**
  69019. * Exposes the properties to the deserialize?
  69020. */
  69021. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69022. }
  69023. }
  69024. declare module BABYLON {
  69025. /**
  69026. * block used to Generate a Simplex Perlin 3d Noise Pattern
  69027. */
  69028. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  69029. /**
  69030. * Creates a new SimplexPerlin3DBlock
  69031. * @param name defines the block name
  69032. */
  69033. constructor(name: string);
  69034. /**
  69035. * Gets the current class name
  69036. * @returns the class name
  69037. */
  69038. getClassName(): string;
  69039. /**
  69040. * Gets the seed operand input component
  69041. */
  69042. get seed(): NodeMaterialConnectionPoint;
  69043. /**
  69044. * Gets the output component
  69045. */
  69046. get output(): NodeMaterialConnectionPoint;
  69047. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  69048. }
  69049. }
  69050. declare module BABYLON {
  69051. /**
  69052. * Block used to blend normals
  69053. */
  69054. export class NormalBlendBlock extends NodeMaterialBlock {
  69055. /**
  69056. * Creates a new NormalBlendBlock
  69057. * @param name defines the block name
  69058. */
  69059. constructor(name: string);
  69060. /**
  69061. * Gets the current class name
  69062. * @returns the class name
  69063. */
  69064. getClassName(): string;
  69065. /**
  69066. * Gets the first input component
  69067. */
  69068. get normalMap0(): NodeMaterialConnectionPoint;
  69069. /**
  69070. * Gets the second input component
  69071. */
  69072. get normalMap1(): NodeMaterialConnectionPoint;
  69073. /**
  69074. * Gets the output component
  69075. */
  69076. get output(): NodeMaterialConnectionPoint;
  69077. protected _buildBlock(state: NodeMaterialBuildState): this;
  69078. }
  69079. }
  69080. declare module BABYLON {
  69081. /**
  69082. * Block used to rotate a 2d vector by a given angle
  69083. */
  69084. export class Rotate2dBlock extends NodeMaterialBlock {
  69085. /**
  69086. * Creates a new Rotate2dBlock
  69087. * @param name defines the block name
  69088. */
  69089. constructor(name: string);
  69090. /**
  69091. * Gets the current class name
  69092. * @returns the class name
  69093. */
  69094. getClassName(): string;
  69095. /**
  69096. * Gets the input vector
  69097. */
  69098. get input(): NodeMaterialConnectionPoint;
  69099. /**
  69100. * Gets the input angle
  69101. */
  69102. get angle(): NodeMaterialConnectionPoint;
  69103. /**
  69104. * Gets the output component
  69105. */
  69106. get output(): NodeMaterialConnectionPoint;
  69107. autoConfigure(material: NodeMaterial): void;
  69108. protected _buildBlock(state: NodeMaterialBuildState): this;
  69109. }
  69110. }
  69111. declare module BABYLON {
  69112. /**
  69113. * Block used to get the reflected vector from a direction and a normal
  69114. */
  69115. export class ReflectBlock extends NodeMaterialBlock {
  69116. /**
  69117. * Creates a new ReflectBlock
  69118. * @param name defines the block name
  69119. */
  69120. constructor(name: string);
  69121. /**
  69122. * Gets the current class name
  69123. * @returns the class name
  69124. */
  69125. getClassName(): string;
  69126. /**
  69127. * Gets the incident component
  69128. */
  69129. get incident(): NodeMaterialConnectionPoint;
  69130. /**
  69131. * Gets the normal component
  69132. */
  69133. get normal(): NodeMaterialConnectionPoint;
  69134. /**
  69135. * Gets the output component
  69136. */
  69137. get output(): NodeMaterialConnectionPoint;
  69138. protected _buildBlock(state: NodeMaterialBuildState): this;
  69139. }
  69140. }
  69141. declare module BABYLON {
  69142. /**
  69143. * Block used to get the refracted vector from a direction and a normal
  69144. */
  69145. export class RefractBlock extends NodeMaterialBlock {
  69146. /**
  69147. * Creates a new RefractBlock
  69148. * @param name defines the block name
  69149. */
  69150. constructor(name: string);
  69151. /**
  69152. * Gets the current class name
  69153. * @returns the class name
  69154. */
  69155. getClassName(): string;
  69156. /**
  69157. * Gets the incident component
  69158. */
  69159. get incident(): NodeMaterialConnectionPoint;
  69160. /**
  69161. * Gets the normal component
  69162. */
  69163. get normal(): NodeMaterialConnectionPoint;
  69164. /**
  69165. * Gets the index of refraction component
  69166. */
  69167. get ior(): NodeMaterialConnectionPoint;
  69168. /**
  69169. * Gets the output component
  69170. */
  69171. get output(): NodeMaterialConnectionPoint;
  69172. protected _buildBlock(state: NodeMaterialBuildState): this;
  69173. }
  69174. }
  69175. declare module BABYLON {
  69176. /**
  69177. * Block used to desaturate a color
  69178. */
  69179. export class DesaturateBlock extends NodeMaterialBlock {
  69180. /**
  69181. * Creates a new DesaturateBlock
  69182. * @param name defines the block name
  69183. */
  69184. constructor(name: string);
  69185. /**
  69186. * Gets the current class name
  69187. * @returns the class name
  69188. */
  69189. getClassName(): string;
  69190. /**
  69191. * Gets the color operand input component
  69192. */
  69193. get color(): NodeMaterialConnectionPoint;
  69194. /**
  69195. * Gets the level operand input component
  69196. */
  69197. get level(): NodeMaterialConnectionPoint;
  69198. /**
  69199. * Gets the output component
  69200. */
  69201. get output(): NodeMaterialConnectionPoint;
  69202. protected _buildBlock(state: NodeMaterialBuildState): this;
  69203. }
  69204. }
  69205. declare module BABYLON {
  69206. /**
  69207. * Block used to implement the reflection module of the PBR material
  69208. */
  69209. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  69210. /** @hidden */
  69211. _defineLODReflectionAlpha: string;
  69212. /** @hidden */
  69213. _defineLinearSpecularReflection: string;
  69214. private _vEnvironmentIrradianceName;
  69215. /** @hidden */
  69216. _vReflectionMicrosurfaceInfosName: string;
  69217. /** @hidden */
  69218. _vReflectionInfosName: string;
  69219. /** @hidden */
  69220. _vReflectionFilteringInfoName: string;
  69221. private _scene;
  69222. /**
  69223. * The properties below are set by the main PBR block prior to calling methods of this class.
  69224. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  69225. * It's less burden on the user side in the editor part.
  69226. */
  69227. /** @hidden */
  69228. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  69229. /** @hidden */
  69230. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  69231. /** @hidden */
  69232. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  69233. /** @hidden */
  69234. viewConnectionPoint: NodeMaterialConnectionPoint;
  69235. /**
  69236. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  69237. * diffuse part of the IBL.
  69238. */
  69239. useSphericalHarmonics: boolean;
  69240. /**
  69241. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  69242. */
  69243. forceIrradianceInFragment: boolean;
  69244. /**
  69245. * Create a new ReflectionBlock
  69246. * @param name defines the block name
  69247. */
  69248. constructor(name: string);
  69249. /**
  69250. * Gets the current class name
  69251. * @returns the class name
  69252. */
  69253. getClassName(): string;
  69254. /**
  69255. * Gets the position input component
  69256. */
  69257. get position(): NodeMaterialConnectionPoint;
  69258. /**
  69259. * Gets the world position input component
  69260. */
  69261. get worldPosition(): NodeMaterialConnectionPoint;
  69262. /**
  69263. * Gets the world normal input component
  69264. */
  69265. get worldNormal(): NodeMaterialConnectionPoint;
  69266. /**
  69267. * Gets the world input component
  69268. */
  69269. get world(): NodeMaterialConnectionPoint;
  69270. /**
  69271. * Gets the camera (or eye) position component
  69272. */
  69273. get cameraPosition(): NodeMaterialConnectionPoint;
  69274. /**
  69275. * Gets the view input component
  69276. */
  69277. get view(): NodeMaterialConnectionPoint;
  69278. /**
  69279. * Gets the color input component
  69280. */
  69281. get color(): NodeMaterialConnectionPoint;
  69282. /**
  69283. * Gets the reflection object output component
  69284. */
  69285. get reflection(): NodeMaterialConnectionPoint;
  69286. /**
  69287. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  69288. */
  69289. get hasTexture(): boolean;
  69290. /**
  69291. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  69292. */
  69293. get reflectionColor(): string;
  69294. protected _getTexture(): Nullable<BaseTexture>;
  69295. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69296. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69297. /**
  69298. * Gets the code to inject in the vertex shader
  69299. * @param state current state of the node material building
  69300. * @returns the shader code
  69301. */
  69302. handleVertexSide(state: NodeMaterialBuildState): string;
  69303. /**
  69304. * Gets the main code of the block (fragment side)
  69305. * @param state current state of the node material building
  69306. * @param normalVarName name of the existing variable corresponding to the normal
  69307. * @returns the shader code
  69308. */
  69309. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  69310. protected _buildBlock(state: NodeMaterialBuildState): this;
  69311. protected _dumpPropertiesCode(): string;
  69312. serialize(): any;
  69313. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69314. }
  69315. }
  69316. declare module BABYLON {
  69317. /**
  69318. * Block used to implement the sheen module of the PBR material
  69319. */
  69320. export class SheenBlock extends NodeMaterialBlock {
  69321. /**
  69322. * Create a new SheenBlock
  69323. * @param name defines the block name
  69324. */
  69325. constructor(name: string);
  69326. /**
  69327. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  69328. * It allows the strength of the sheen effect to not depend on the base color of the material,
  69329. * making it easier to setup and tweak the effect
  69330. */
  69331. albedoScaling: boolean;
  69332. /**
  69333. * Defines if the sheen is linked to the sheen color.
  69334. */
  69335. linkSheenWithAlbedo: boolean;
  69336. /**
  69337. * Initialize the block and prepare the context for build
  69338. * @param state defines the state that will be used for the build
  69339. */
  69340. initialize(state: NodeMaterialBuildState): void;
  69341. /**
  69342. * Gets the current class name
  69343. * @returns the class name
  69344. */
  69345. getClassName(): string;
  69346. /**
  69347. * Gets the intensity input component
  69348. */
  69349. get intensity(): NodeMaterialConnectionPoint;
  69350. /**
  69351. * Gets the color input component
  69352. */
  69353. get color(): NodeMaterialConnectionPoint;
  69354. /**
  69355. * Gets the roughness input component
  69356. */
  69357. get roughness(): NodeMaterialConnectionPoint;
  69358. /**
  69359. * Gets the sheen object output component
  69360. */
  69361. get sheen(): NodeMaterialConnectionPoint;
  69362. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69363. /**
  69364. * Gets the main code of the block (fragment side)
  69365. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69366. * @returns the shader code
  69367. */
  69368. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  69369. protected _buildBlock(state: NodeMaterialBuildState): this;
  69370. protected _dumpPropertiesCode(): string;
  69371. serialize(): any;
  69372. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69373. }
  69374. }
  69375. declare module BABYLON {
  69376. /**
  69377. * Block used to implement the anisotropy module of the PBR material
  69378. */
  69379. export class AnisotropyBlock extends NodeMaterialBlock {
  69380. /**
  69381. * The two properties below are set by the main PBR block prior to calling methods of this class.
  69382. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  69383. * It's less burden on the user side in the editor part.
  69384. */
  69385. /** @hidden */
  69386. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  69387. /** @hidden */
  69388. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  69389. /**
  69390. * Create a new AnisotropyBlock
  69391. * @param name defines the block name
  69392. */
  69393. constructor(name: string);
  69394. /**
  69395. * Initialize the block and prepare the context for build
  69396. * @param state defines the state that will be used for the build
  69397. */
  69398. initialize(state: NodeMaterialBuildState): void;
  69399. /**
  69400. * Gets the current class name
  69401. * @returns the class name
  69402. */
  69403. getClassName(): string;
  69404. /**
  69405. * Gets the intensity input component
  69406. */
  69407. get intensity(): NodeMaterialConnectionPoint;
  69408. /**
  69409. * Gets the direction input component
  69410. */
  69411. get direction(): NodeMaterialConnectionPoint;
  69412. /**
  69413. * Gets the uv input component
  69414. */
  69415. get uv(): NodeMaterialConnectionPoint;
  69416. /**
  69417. * Gets the worldTangent input component
  69418. */
  69419. get worldTangent(): NodeMaterialConnectionPoint;
  69420. /**
  69421. * Gets the anisotropy object output component
  69422. */
  69423. get anisotropy(): NodeMaterialConnectionPoint;
  69424. private _generateTBNSpace;
  69425. /**
  69426. * Gets the main code of the block (fragment side)
  69427. * @param state current state of the node material building
  69428. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69429. * @returns the shader code
  69430. */
  69431. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  69432. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69433. protected _buildBlock(state: NodeMaterialBuildState): this;
  69434. }
  69435. }
  69436. declare module BABYLON {
  69437. /**
  69438. * Block used to implement the clear coat module of the PBR material
  69439. */
  69440. export class ClearCoatBlock extends NodeMaterialBlock {
  69441. private _scene;
  69442. /**
  69443. * Create a new ClearCoatBlock
  69444. * @param name defines the block name
  69445. */
  69446. constructor(name: string);
  69447. /**
  69448. * Defines if the F0 value should be remapped to account for the interface change in the material.
  69449. */
  69450. remapF0OnInterfaceChange: boolean;
  69451. /**
  69452. * Initialize the block and prepare the context for build
  69453. * @param state defines the state that will be used for the build
  69454. */
  69455. initialize(state: NodeMaterialBuildState): void;
  69456. /**
  69457. * Gets the current class name
  69458. * @returns the class name
  69459. */
  69460. getClassName(): string;
  69461. /**
  69462. * Gets the intensity input component
  69463. */
  69464. get intensity(): NodeMaterialConnectionPoint;
  69465. /**
  69466. * Gets the roughness input component
  69467. */
  69468. get roughness(): NodeMaterialConnectionPoint;
  69469. /**
  69470. * Gets the ior input component
  69471. */
  69472. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69473. /**
  69474. * Gets the bump texture input component
  69475. */
  69476. get normalMapColor(): NodeMaterialConnectionPoint;
  69477. /**
  69478. * Gets the uv input component
  69479. */
  69480. get uv(): NodeMaterialConnectionPoint;
  69481. /**
  69482. * Gets the tint color input component
  69483. */
  69484. get tintColor(): NodeMaterialConnectionPoint;
  69485. /**
  69486. * Gets the tint "at distance" input component
  69487. */
  69488. get tintAtDistance(): NodeMaterialConnectionPoint;
  69489. /**
  69490. * Gets the tint thickness input component
  69491. */
  69492. get tintThickness(): NodeMaterialConnectionPoint;
  69493. /**
  69494. * Gets the world tangent input component
  69495. */
  69496. get worldTangent(): NodeMaterialConnectionPoint;
  69497. /**
  69498. * Gets the clear coat object output component
  69499. */
  69500. get clearcoat(): NodeMaterialConnectionPoint;
  69501. autoConfigure(material: NodeMaterial): void;
  69502. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69503. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69504. private _generateTBNSpace;
  69505. /**
  69506. * Gets the main code of the block (fragment side)
  69507. * @param state current state of the node material building
  69508. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  69509. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69510. * @param worldPosVarName name of the variable holding the world position
  69511. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69512. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  69513. * @param worldNormalVarName name of the variable holding the world normal
  69514. * @returns the shader code
  69515. */
  69516. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  69517. protected _buildBlock(state: NodeMaterialBuildState): this;
  69518. protected _dumpPropertiesCode(): string;
  69519. serialize(): any;
  69520. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69521. }
  69522. }
  69523. declare module BABYLON {
  69524. /**
  69525. * Block used to implement the sub surface module of the PBR material
  69526. */
  69527. export class SubSurfaceBlock extends NodeMaterialBlock {
  69528. /**
  69529. * Create a new SubSurfaceBlock
  69530. * @param name defines the block name
  69531. */
  69532. constructor(name: string);
  69533. /**
  69534. * Initialize the block and prepare the context for build
  69535. * @param state defines the state that will be used for the build
  69536. */
  69537. initialize(state: NodeMaterialBuildState): void;
  69538. /**
  69539. * Gets the current class name
  69540. * @returns the class name
  69541. */
  69542. getClassName(): string;
  69543. /**
  69544. * Gets the thickness component
  69545. */
  69546. get thickness(): NodeMaterialConnectionPoint;
  69547. /**
  69548. * Gets the tint color input component
  69549. */
  69550. get tintColor(): NodeMaterialConnectionPoint;
  69551. /**
  69552. * Gets the translucency intensity input component
  69553. */
  69554. get translucencyIntensity(): NodeMaterialConnectionPoint;
  69555. /**
  69556. * Gets the translucency diffusion distance input component
  69557. */
  69558. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  69559. /**
  69560. * Gets the refraction object parameters
  69561. */
  69562. get refraction(): NodeMaterialConnectionPoint;
  69563. /**
  69564. * Gets the sub surface object output component
  69565. */
  69566. get subsurface(): NodeMaterialConnectionPoint;
  69567. autoConfigure(material: NodeMaterial): void;
  69568. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69569. /**
  69570. * Gets the main code of the block (fragment side)
  69571. * @param state current state of the node material building
  69572. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  69573. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69574. * @param worldPosVarName name of the variable holding the world position
  69575. * @returns the shader code
  69576. */
  69577. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  69578. protected _buildBlock(state: NodeMaterialBuildState): this;
  69579. }
  69580. }
  69581. declare module BABYLON {
  69582. /**
  69583. * Block used to implement the PBR metallic/roughness model
  69584. */
  69585. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  69586. /**
  69587. * Gets or sets the light associated with this block
  69588. */
  69589. light: Nullable<Light>;
  69590. private _lightId;
  69591. private _scene;
  69592. private _environmentBRDFTexture;
  69593. private _environmentBrdfSamplerName;
  69594. private _vNormalWName;
  69595. private _invertNormalName;
  69596. private _metallicReflectanceColor;
  69597. private _metallicF0Factor;
  69598. private _vMetallicReflectanceFactorsName;
  69599. /**
  69600. * Create a new ReflectionBlock
  69601. * @param name defines the block name
  69602. */
  69603. constructor(name: string);
  69604. /**
  69605. * Intensity of the direct lights e.g. the four lights available in your scene.
  69606. * This impacts both the direct diffuse and specular highlights.
  69607. */
  69608. directIntensity: number;
  69609. /**
  69610. * Intensity of the environment e.g. how much the environment will light the object
  69611. * either through harmonics for rough material or through the reflection for shiny ones.
  69612. */
  69613. environmentIntensity: number;
  69614. /**
  69615. * This is a special control allowing the reduction of the specular highlights coming from the
  69616. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  69617. */
  69618. specularIntensity: number;
  69619. /**
  69620. * Defines the falloff type used in this material.
  69621. * It by default is Physical.
  69622. */
  69623. lightFalloff: number;
  69624. /**
  69625. * Specifies that alpha test should be used
  69626. */
  69627. useAlphaTest: boolean;
  69628. /**
  69629. * Defines the alpha limits in alpha test mode.
  69630. */
  69631. alphaTestCutoff: number;
  69632. /**
  69633. * Specifies that alpha blending should be used
  69634. */
  69635. useAlphaBlending: boolean;
  69636. /**
  69637. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  69638. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  69639. */
  69640. useRadianceOverAlpha: boolean;
  69641. /**
  69642. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  69643. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  69644. */
  69645. useSpecularOverAlpha: boolean;
  69646. /**
  69647. * Enables specular anti aliasing in the PBR shader.
  69648. * It will both interacts on the Geometry for analytical and IBL lighting.
  69649. * It also prefilter the roughness map based on the bump values.
  69650. */
  69651. enableSpecularAntiAliasing: boolean;
  69652. /**
  69653. * Enables realtime filtering on the texture.
  69654. */
  69655. realTimeFiltering: boolean;
  69656. /**
  69657. * Quality switch for realtime filtering
  69658. */
  69659. realTimeFilteringQuality: number;
  69660. /**
  69661. * Defines if the material uses energy conservation.
  69662. */
  69663. useEnergyConservation: boolean;
  69664. /**
  69665. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  69666. * too much the area relying on ambient texture to define their ambient occlusion.
  69667. */
  69668. useRadianceOcclusion: boolean;
  69669. /**
  69670. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  69671. * makes the reflect vector face the model (under horizon).
  69672. */
  69673. useHorizonOcclusion: boolean;
  69674. /**
  69675. * If set to true, no lighting calculations will be applied.
  69676. */
  69677. unlit: boolean;
  69678. /**
  69679. * Force normal to face away from face.
  69680. */
  69681. forceNormalForward: boolean;
  69682. /**
  69683. * Defines the material debug mode.
  69684. * It helps seeing only some components of the material while troubleshooting.
  69685. */
  69686. debugMode: number;
  69687. /**
  69688. * Specify from where on screen the debug mode should start.
  69689. * The value goes from -1 (full screen) to 1 (not visible)
  69690. * It helps with side by side comparison against the final render
  69691. * This defaults to 0
  69692. */
  69693. debugLimit: number;
  69694. /**
  69695. * As the default viewing range might not be enough (if the ambient is really small for instance)
  69696. * You can use the factor to better multiply the final value.
  69697. */
  69698. debugFactor: number;
  69699. /**
  69700. * Initialize the block and prepare the context for build
  69701. * @param state defines the state that will be used for the build
  69702. */
  69703. initialize(state: NodeMaterialBuildState): void;
  69704. /**
  69705. * Gets the current class name
  69706. * @returns the class name
  69707. */
  69708. getClassName(): string;
  69709. /**
  69710. * Gets the world position input component
  69711. */
  69712. get worldPosition(): NodeMaterialConnectionPoint;
  69713. /**
  69714. * Gets the world normal input component
  69715. */
  69716. get worldNormal(): NodeMaterialConnectionPoint;
  69717. /**
  69718. * Gets the view matrix parameter
  69719. */
  69720. get view(): NodeMaterialConnectionPoint;
  69721. /**
  69722. * Gets the camera position input component
  69723. */
  69724. get cameraPosition(): NodeMaterialConnectionPoint;
  69725. /**
  69726. * Gets the perturbed normal input component
  69727. */
  69728. get perturbedNormal(): NodeMaterialConnectionPoint;
  69729. /**
  69730. * Gets the base color input component
  69731. */
  69732. get baseColor(): NodeMaterialConnectionPoint;
  69733. /**
  69734. * Gets the metallic input component
  69735. */
  69736. get metallic(): NodeMaterialConnectionPoint;
  69737. /**
  69738. * Gets the roughness input component
  69739. */
  69740. get roughness(): NodeMaterialConnectionPoint;
  69741. /**
  69742. * Gets the ambient occlusion input component
  69743. */
  69744. get ambientOcc(): NodeMaterialConnectionPoint;
  69745. /**
  69746. * Gets the opacity input component
  69747. */
  69748. get opacity(): NodeMaterialConnectionPoint;
  69749. /**
  69750. * Gets the index of refraction input component
  69751. */
  69752. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69753. /**
  69754. * Gets the ambient color input component
  69755. */
  69756. get ambientColor(): NodeMaterialConnectionPoint;
  69757. /**
  69758. * Gets the reflection object parameters
  69759. */
  69760. get reflection(): NodeMaterialConnectionPoint;
  69761. /**
  69762. * Gets the clear coat object parameters
  69763. */
  69764. get clearcoat(): NodeMaterialConnectionPoint;
  69765. /**
  69766. * Gets the sheen object parameters
  69767. */
  69768. get sheen(): NodeMaterialConnectionPoint;
  69769. /**
  69770. * Gets the sub surface object parameters
  69771. */
  69772. get subsurface(): NodeMaterialConnectionPoint;
  69773. /**
  69774. * Gets the anisotropy object parameters
  69775. */
  69776. get anisotropy(): NodeMaterialConnectionPoint;
  69777. /**
  69778. * Gets the ambient output component
  69779. */
  69780. get ambientClr(): NodeMaterialConnectionPoint;
  69781. /**
  69782. * Gets the diffuse output component
  69783. */
  69784. get diffuseDir(): NodeMaterialConnectionPoint;
  69785. /**
  69786. * Gets the specular output component
  69787. */
  69788. get specularDir(): NodeMaterialConnectionPoint;
  69789. /**
  69790. * Gets the clear coat output component
  69791. */
  69792. get clearcoatDir(): NodeMaterialConnectionPoint;
  69793. /**
  69794. * Gets the sheen output component
  69795. */
  69796. get sheenDir(): NodeMaterialConnectionPoint;
  69797. /**
  69798. * Gets the indirect diffuse output component
  69799. */
  69800. get diffuseIndirect(): NodeMaterialConnectionPoint;
  69801. /**
  69802. * Gets the indirect specular output component
  69803. */
  69804. get specularIndirect(): NodeMaterialConnectionPoint;
  69805. /**
  69806. * Gets the indirect clear coat output component
  69807. */
  69808. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  69809. /**
  69810. * Gets the indirect sheen output component
  69811. */
  69812. get sheenIndirect(): NodeMaterialConnectionPoint;
  69813. /**
  69814. * Gets the refraction output component
  69815. */
  69816. get refraction(): NodeMaterialConnectionPoint;
  69817. /**
  69818. * Gets the global lighting output component
  69819. */
  69820. get lighting(): NodeMaterialConnectionPoint;
  69821. /**
  69822. * Gets the shadow output component
  69823. */
  69824. get shadow(): NodeMaterialConnectionPoint;
  69825. /**
  69826. * Gets the alpha output component
  69827. */
  69828. get alpha(): NodeMaterialConnectionPoint;
  69829. autoConfigure(material: NodeMaterial): void;
  69830. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69831. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  69832. isReady(): boolean;
  69833. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69834. private _injectVertexCode;
  69835. private _getAlbedoOpacityCode;
  69836. private _getAmbientOcclusionCode;
  69837. private _getReflectivityCode;
  69838. protected _buildBlock(state: NodeMaterialBuildState): this;
  69839. protected _dumpPropertiesCode(): string;
  69840. serialize(): any;
  69841. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69842. }
  69843. }
  69844. declare module BABYLON {
  69845. /**
  69846. * Block used to compute value of one parameter modulo another
  69847. */
  69848. export class ModBlock extends NodeMaterialBlock {
  69849. /**
  69850. * Creates a new ModBlock
  69851. * @param name defines the block name
  69852. */
  69853. constructor(name: string);
  69854. /**
  69855. * Gets the current class name
  69856. * @returns the class name
  69857. */
  69858. getClassName(): string;
  69859. /**
  69860. * Gets the left operand input component
  69861. */
  69862. get left(): NodeMaterialConnectionPoint;
  69863. /**
  69864. * Gets the right operand input component
  69865. */
  69866. get right(): NodeMaterialConnectionPoint;
  69867. /**
  69868. * Gets the output component
  69869. */
  69870. get output(): NodeMaterialConnectionPoint;
  69871. protected _buildBlock(state: NodeMaterialBuildState): this;
  69872. }
  69873. }
  69874. declare module BABYLON {
  69875. /**
  69876. * Configuration for Draco compression
  69877. */
  69878. export interface IDracoCompressionConfiguration {
  69879. /**
  69880. * Configuration for the decoder.
  69881. */
  69882. decoder: {
  69883. /**
  69884. * The url to the WebAssembly module.
  69885. */
  69886. wasmUrl?: string;
  69887. /**
  69888. * The url to the WebAssembly binary.
  69889. */
  69890. wasmBinaryUrl?: string;
  69891. /**
  69892. * The url to the fallback JavaScript module.
  69893. */
  69894. fallbackUrl?: string;
  69895. };
  69896. }
  69897. /**
  69898. * Draco compression (https://google.github.io/draco/)
  69899. *
  69900. * This class wraps the Draco module.
  69901. *
  69902. * **Encoder**
  69903. *
  69904. * The encoder is not currently implemented.
  69905. *
  69906. * **Decoder**
  69907. *
  69908. * 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.
  69909. *
  69910. * To update the configuration, use the following code:
  69911. * ```javascript
  69912. * DracoCompression.Configuration = {
  69913. * decoder: {
  69914. * wasmUrl: "<url to the WebAssembly library>",
  69915. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69916. * fallbackUrl: "<url to the fallback JavaScript library>",
  69917. * }
  69918. * };
  69919. * ```
  69920. *
  69921. * 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.
  69922. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69923. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69924. *
  69925. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69926. * ```javascript
  69927. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69928. * ```
  69929. *
  69930. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69931. */
  69932. export class DracoCompression implements IDisposable {
  69933. private _workerPoolPromise?;
  69934. private _decoderModulePromise?;
  69935. /**
  69936. * The configuration. Defaults to the following urls:
  69937. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69938. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69939. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69940. */
  69941. static Configuration: IDracoCompressionConfiguration;
  69942. /**
  69943. * Returns true if the decoder configuration is available.
  69944. */
  69945. static get DecoderAvailable(): boolean;
  69946. /**
  69947. * Default number of workers to create when creating the draco compression object.
  69948. */
  69949. static DefaultNumWorkers: number;
  69950. private static GetDefaultNumWorkers;
  69951. private static _Default;
  69952. /**
  69953. * Default instance for the draco compression object.
  69954. */
  69955. static get Default(): DracoCompression;
  69956. /**
  69957. * Constructor
  69958. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69959. */
  69960. constructor(numWorkers?: number);
  69961. /**
  69962. * Stop all async operations and release resources.
  69963. */
  69964. dispose(): void;
  69965. /**
  69966. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69967. * @returns a promise that resolves when ready
  69968. */
  69969. whenReadyAsync(): Promise<void>;
  69970. /**
  69971. * Decode Draco compressed mesh data to vertex data.
  69972. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69973. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69974. * @returns A promise that resolves with the decoded vertex data
  69975. */
  69976. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  69977. [kind: string]: number;
  69978. }): Promise<VertexData>;
  69979. }
  69980. }
  69981. declare module BABYLON {
  69982. /**
  69983. * Class for building Constructive Solid Geometry
  69984. */
  69985. export class CSG {
  69986. private polygons;
  69987. /**
  69988. * The world matrix
  69989. */
  69990. matrix: Matrix;
  69991. /**
  69992. * Stores the position
  69993. */
  69994. position: Vector3;
  69995. /**
  69996. * Stores the rotation
  69997. */
  69998. rotation: Vector3;
  69999. /**
  70000. * Stores the rotation quaternion
  70001. */
  70002. rotationQuaternion: Nullable<Quaternion>;
  70003. /**
  70004. * Stores the scaling vector
  70005. */
  70006. scaling: Vector3;
  70007. /**
  70008. * Convert the Mesh to CSG
  70009. * @param mesh The Mesh to convert to CSG
  70010. * @returns A new CSG from the Mesh
  70011. */
  70012. static FromMesh(mesh: Mesh): CSG;
  70013. /**
  70014. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  70015. * @param polygons Polygons used to construct a CSG solid
  70016. */
  70017. private static FromPolygons;
  70018. /**
  70019. * Clones, or makes a deep copy, of the CSG
  70020. * @returns A new CSG
  70021. */
  70022. clone(): CSG;
  70023. /**
  70024. * Unions this CSG with another CSG
  70025. * @param csg The CSG to union against this CSG
  70026. * @returns The unioned CSG
  70027. */
  70028. union(csg: CSG): CSG;
  70029. /**
  70030. * Unions this CSG with another CSG in place
  70031. * @param csg The CSG to union against this CSG
  70032. */
  70033. unionInPlace(csg: CSG): void;
  70034. /**
  70035. * Subtracts this CSG with another CSG
  70036. * @param csg The CSG to subtract against this CSG
  70037. * @returns A new CSG
  70038. */
  70039. subtract(csg: CSG): CSG;
  70040. /**
  70041. * Subtracts this CSG with another CSG in place
  70042. * @param csg The CSG to subtract against this CSG
  70043. */
  70044. subtractInPlace(csg: CSG): void;
  70045. /**
  70046. * Intersect this CSG with another CSG
  70047. * @param csg The CSG to intersect against this CSG
  70048. * @returns A new CSG
  70049. */
  70050. intersect(csg: CSG): CSG;
  70051. /**
  70052. * Intersects this CSG with another CSG in place
  70053. * @param csg The CSG to intersect against this CSG
  70054. */
  70055. intersectInPlace(csg: CSG): void;
  70056. /**
  70057. * Return a new CSG solid with solid and empty space switched. This solid is
  70058. * not modified.
  70059. * @returns A new CSG solid with solid and empty space switched
  70060. */
  70061. inverse(): CSG;
  70062. /**
  70063. * Inverses the CSG in place
  70064. */
  70065. inverseInPlace(): void;
  70066. /**
  70067. * This is used to keep meshes transformations so they can be restored
  70068. * when we build back a Babylon Mesh
  70069. * NB : All CSG operations are performed in world coordinates
  70070. * @param csg The CSG to copy the transform attributes from
  70071. * @returns This CSG
  70072. */
  70073. copyTransformAttributes(csg: CSG): CSG;
  70074. /**
  70075. * Build Raw mesh from CSG
  70076. * Coordinates here are in world space
  70077. * @param name The name of the mesh geometry
  70078. * @param scene The Scene
  70079. * @param keepSubMeshes Specifies if the submeshes should be kept
  70080. * @returns A new Mesh
  70081. */
  70082. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  70083. /**
  70084. * Build Mesh from CSG taking material and transforms into account
  70085. * @param name The name of the Mesh
  70086. * @param material The material of the Mesh
  70087. * @param scene The Scene
  70088. * @param keepSubMeshes Specifies if submeshes should be kept
  70089. * @returns The new Mesh
  70090. */
  70091. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  70092. }
  70093. }
  70094. declare module BABYLON {
  70095. /**
  70096. * Class used to create a trail following a mesh
  70097. */
  70098. export class TrailMesh extends Mesh {
  70099. private _generator;
  70100. private _autoStart;
  70101. private _running;
  70102. private _diameter;
  70103. private _length;
  70104. private _sectionPolygonPointsCount;
  70105. private _sectionVectors;
  70106. private _sectionNormalVectors;
  70107. private _beforeRenderObserver;
  70108. /**
  70109. * @constructor
  70110. * @param name The value used by scene.getMeshByName() to do a lookup.
  70111. * @param generator The mesh or transform node to generate a trail.
  70112. * @param scene The scene to add this mesh to.
  70113. * @param diameter Diameter of trailing mesh. Default is 1.
  70114. * @param length Length of trailing mesh. Default is 60.
  70115. * @param autoStart Automatically start trailing mesh. Default true.
  70116. */
  70117. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  70118. /**
  70119. * "TrailMesh"
  70120. * @returns "TrailMesh"
  70121. */
  70122. getClassName(): string;
  70123. private _createMesh;
  70124. /**
  70125. * Start trailing mesh.
  70126. */
  70127. start(): void;
  70128. /**
  70129. * Stop trailing mesh.
  70130. */
  70131. stop(): void;
  70132. /**
  70133. * Update trailing mesh geometry.
  70134. */
  70135. update(): void;
  70136. /**
  70137. * Returns a new TrailMesh object.
  70138. * @param name is a string, the name given to the new mesh
  70139. * @param newGenerator use new generator object for cloned trail mesh
  70140. * @returns a new mesh
  70141. */
  70142. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  70143. /**
  70144. * Serializes this trail mesh
  70145. * @param serializationObject object to write serialization to
  70146. */
  70147. serialize(serializationObject: any): void;
  70148. /**
  70149. * Parses a serialized trail mesh
  70150. * @param parsedMesh the serialized mesh
  70151. * @param scene the scene to create the trail mesh in
  70152. * @returns the created trail mesh
  70153. */
  70154. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  70155. }
  70156. }
  70157. declare module BABYLON {
  70158. /**
  70159. * Class containing static functions to help procedurally build meshes
  70160. */
  70161. export class TiledBoxBuilder {
  70162. /**
  70163. * Creates a box mesh
  70164. * 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)
  70165. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70167. * * 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
  70168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70169. * @param name defines the name of the mesh
  70170. * @param options defines the options used to create the mesh
  70171. * @param scene defines the hosting scene
  70172. * @returns the box mesh
  70173. */
  70174. static CreateTiledBox(name: string, options: {
  70175. pattern?: number;
  70176. width?: number;
  70177. height?: number;
  70178. depth?: number;
  70179. tileSize?: number;
  70180. tileWidth?: number;
  70181. tileHeight?: number;
  70182. alignHorizontal?: number;
  70183. alignVertical?: number;
  70184. faceUV?: Vector4[];
  70185. faceColors?: Color4[];
  70186. sideOrientation?: number;
  70187. updatable?: boolean;
  70188. }, scene?: Nullable<Scene>): Mesh;
  70189. }
  70190. }
  70191. declare module BABYLON {
  70192. /**
  70193. * Class containing static functions to help procedurally build meshes
  70194. */
  70195. export class TorusKnotBuilder {
  70196. /**
  70197. * Creates a torus knot mesh
  70198. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70199. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70200. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70201. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70202. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70203. * * 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
  70204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70205. * @param name defines the name of the mesh
  70206. * @param options defines the options used to create the mesh
  70207. * @param scene defines the hosting scene
  70208. * @returns the torus knot mesh
  70209. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70210. */
  70211. static CreateTorusKnot(name: string, options: {
  70212. radius?: number;
  70213. tube?: number;
  70214. radialSegments?: number;
  70215. tubularSegments?: number;
  70216. p?: number;
  70217. q?: number;
  70218. updatable?: boolean;
  70219. sideOrientation?: number;
  70220. frontUVs?: Vector4;
  70221. backUVs?: Vector4;
  70222. }, scene: any): Mesh;
  70223. }
  70224. }
  70225. declare module BABYLON {
  70226. /**
  70227. * Polygon
  70228. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  70229. */
  70230. export class Polygon {
  70231. /**
  70232. * Creates a rectangle
  70233. * @param xmin bottom X coord
  70234. * @param ymin bottom Y coord
  70235. * @param xmax top X coord
  70236. * @param ymax top Y coord
  70237. * @returns points that make the resulting rectangle
  70238. */
  70239. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  70240. /**
  70241. * Creates a circle
  70242. * @param radius radius of circle
  70243. * @param cx scale in x
  70244. * @param cy scale in y
  70245. * @param numberOfSides number of sides that make up the circle
  70246. * @returns points that make the resulting circle
  70247. */
  70248. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  70249. /**
  70250. * Creates a polygon from input string
  70251. * @param input Input polygon data
  70252. * @returns the parsed points
  70253. */
  70254. static Parse(input: string): Vector2[];
  70255. /**
  70256. * Starts building a polygon from x and y coordinates
  70257. * @param x x coordinate
  70258. * @param y y coordinate
  70259. * @returns the started path2
  70260. */
  70261. static StartingAt(x: number, y: number): Path2;
  70262. }
  70263. /**
  70264. * Builds a polygon
  70265. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  70266. */
  70267. export class PolygonMeshBuilder {
  70268. private _points;
  70269. private _outlinepoints;
  70270. private _holes;
  70271. private _name;
  70272. private _scene;
  70273. private _epoints;
  70274. private _eholes;
  70275. private _addToepoint;
  70276. /**
  70277. * Babylon reference to the earcut plugin.
  70278. */
  70279. bjsEarcut: any;
  70280. /**
  70281. * Creates a PolygonMeshBuilder
  70282. * @param name name of the builder
  70283. * @param contours Path of the polygon
  70284. * @param scene scene to add to when creating the mesh
  70285. * @param earcutInjection can be used to inject your own earcut reference
  70286. */
  70287. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  70288. /**
  70289. * Adds a hole within the polygon
  70290. * @param hole Array of points defining the hole
  70291. * @returns this
  70292. */
  70293. addHole(hole: Vector2[]): PolygonMeshBuilder;
  70294. /**
  70295. * Creates the polygon
  70296. * @param updatable If the mesh should be updatable
  70297. * @param depth The depth of the mesh created
  70298. * @param smoothingThreshold Dot product threshold for smoothed normals
  70299. * @returns the created mesh
  70300. */
  70301. build(updatable?: boolean, depth?: number, smoothingThreshold?: number): Mesh;
  70302. /**
  70303. * Creates the polygon
  70304. * @param depth The depth of the mesh created
  70305. * @param smoothingThreshold Dot product threshold for smoothed normals
  70306. * @returns the created VertexData
  70307. */
  70308. buildVertexData(depth?: number, smoothingThreshold?: number): VertexData;
  70309. /**
  70310. * Adds a side to the polygon
  70311. * @param positions points that make the polygon
  70312. * @param normals normals of the polygon
  70313. * @param uvs uvs of the polygon
  70314. * @param indices indices of the polygon
  70315. * @param bounds bounds of the polygon
  70316. * @param points points of the polygon
  70317. * @param depth depth of the polygon
  70318. * @param flip flip of the polygon
  70319. */
  70320. private addSide;
  70321. }
  70322. }
  70323. declare module BABYLON {
  70324. /**
  70325. * Class containing static functions to help procedurally build meshes
  70326. */
  70327. export class PolygonBuilder {
  70328. /**
  70329. * Creates a polygon mesh
  70330. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70331. * * 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
  70332. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70334. * * 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)
  70335. * * Remember you can only change the shape positions, not their number when updating a polygon
  70336. * @param name defines the name of the mesh
  70337. * @param options defines the options used to create the mesh
  70338. * @param scene defines the hosting scene
  70339. * @param earcutInjection can be used to inject your own earcut reference
  70340. * @returns the polygon mesh
  70341. */
  70342. static CreatePolygon(name: string, options: {
  70343. shape: Vector3[];
  70344. holes?: Vector3[][];
  70345. depth?: number;
  70346. smoothingThreshold?: number;
  70347. faceUV?: Vector4[];
  70348. faceColors?: Color4[];
  70349. updatable?: boolean;
  70350. sideOrientation?: number;
  70351. frontUVs?: Vector4;
  70352. backUVs?: Vector4;
  70353. wrap?: boolean;
  70354. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70355. /**
  70356. * Creates an extruded polygon mesh, with depth in the Y direction.
  70357. * * 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)
  70358. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70359. * @param name defines the name of the mesh
  70360. * @param options defines the options used to create the mesh
  70361. * @param scene defines the hosting scene
  70362. * @param earcutInjection can be used to inject your own earcut reference
  70363. * @returns the polygon mesh
  70364. */
  70365. static ExtrudePolygon(name: string, options: {
  70366. shape: Vector3[];
  70367. holes?: Vector3[][];
  70368. depth?: number;
  70369. faceUV?: Vector4[];
  70370. faceColors?: Color4[];
  70371. updatable?: boolean;
  70372. sideOrientation?: number;
  70373. frontUVs?: Vector4;
  70374. backUVs?: Vector4;
  70375. wrap?: boolean;
  70376. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70377. }
  70378. }
  70379. declare module BABYLON {
  70380. /**
  70381. * Class containing static functions to help procedurally build meshes
  70382. */
  70383. export class LatheBuilder {
  70384. /**
  70385. * Creates lathe mesh.
  70386. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe
  70387. * * 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
  70388. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70389. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70390. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70391. * * 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
  70392. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70393. * * 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
  70394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70395. * * 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
  70396. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70398. * @param name defines the name of the mesh
  70399. * @param options defines the options used to create the mesh
  70400. * @param scene defines the hosting scene
  70401. * @returns the lathe mesh
  70402. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70403. */
  70404. static CreateLathe(name: string, options: {
  70405. shape: Vector3[];
  70406. radius?: number;
  70407. tessellation?: number;
  70408. clip?: number;
  70409. arc?: number;
  70410. closed?: boolean;
  70411. updatable?: boolean;
  70412. sideOrientation?: number;
  70413. frontUVs?: Vector4;
  70414. backUVs?: Vector4;
  70415. cap?: number;
  70416. invertUV?: boolean;
  70417. }, scene?: Nullable<Scene>): Mesh;
  70418. }
  70419. }
  70420. declare module BABYLON {
  70421. /**
  70422. * Class containing static functions to help procedurally build meshes
  70423. */
  70424. export class TiledPlaneBuilder {
  70425. /**
  70426. * Creates a tiled plane mesh
  70427. * * The parameter `pattern` will, depending on value, do nothing or
  70428. * * * flip (reflect about central vertical) alternate tiles across and up
  70429. * * * flip every tile on alternate rows
  70430. * * * rotate (180 degs) alternate tiles across and up
  70431. * * * rotate every tile on alternate rows
  70432. * * * flip and rotate alternate tiles across and up
  70433. * * * flip and rotate every tile on alternate rows
  70434. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  70435. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  70436. * * 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
  70437. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70438. * * 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)
  70439. * * 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)
  70440. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70441. * @param name defines the name of the mesh
  70442. * @param options defines the options used to create the mesh
  70443. * @param scene defines the hosting scene
  70444. * @returns the box mesh
  70445. */
  70446. static CreateTiledPlane(name: string, options: {
  70447. pattern?: number;
  70448. tileSize?: number;
  70449. tileWidth?: number;
  70450. tileHeight?: number;
  70451. size?: number;
  70452. width?: number;
  70453. height?: number;
  70454. alignHorizontal?: number;
  70455. alignVertical?: number;
  70456. sideOrientation?: number;
  70457. frontUVs?: Vector4;
  70458. backUVs?: Vector4;
  70459. updatable?: boolean;
  70460. }, scene?: Nullable<Scene>): Mesh;
  70461. }
  70462. }
  70463. declare module BABYLON {
  70464. /**
  70465. * Class containing static functions to help procedurally build meshes
  70466. */
  70467. export class TubeBuilder {
  70468. /**
  70469. * Creates a tube mesh.
  70470. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70471. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70472. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70473. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70474. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overrides the parameter `radius`
  70475. * * 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)
  70476. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70477. * * 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
  70478. * * 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
  70479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70480. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70481. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70483. * @param name defines the name of the mesh
  70484. * @param options defines the options used to create the mesh
  70485. * @param scene defines the hosting scene
  70486. * @returns the tube mesh
  70487. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70488. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70489. */
  70490. static CreateTube(name: string, options: {
  70491. path: Vector3[];
  70492. radius?: number;
  70493. tessellation?: number;
  70494. radiusFunction?: {
  70495. (i: number, distance: number): number;
  70496. };
  70497. cap?: number;
  70498. arc?: number;
  70499. updatable?: boolean;
  70500. sideOrientation?: number;
  70501. frontUVs?: Vector4;
  70502. backUVs?: Vector4;
  70503. instance?: Mesh;
  70504. invertUV?: boolean;
  70505. }, scene?: Nullable<Scene>): Mesh;
  70506. }
  70507. }
  70508. declare module BABYLON {
  70509. /**
  70510. * Class containing static functions to help procedurally build meshes
  70511. */
  70512. export class IcoSphereBuilder {
  70513. /**
  70514. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70515. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70516. * * 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`)
  70517. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70518. * * 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
  70519. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70520. * * 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
  70521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70522. * @param name defines the name of the mesh
  70523. * @param options defines the options used to create the mesh
  70524. * @param scene defines the hosting scene
  70525. * @returns the icosahedron mesh
  70526. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70527. */
  70528. static CreateIcoSphere(name: string, options: {
  70529. radius?: number;
  70530. radiusX?: number;
  70531. radiusY?: number;
  70532. radiusZ?: number;
  70533. flat?: boolean;
  70534. subdivisions?: number;
  70535. sideOrientation?: number;
  70536. frontUVs?: Vector4;
  70537. backUVs?: Vector4;
  70538. updatable?: boolean;
  70539. }, scene?: Nullable<Scene>): Mesh;
  70540. }
  70541. }
  70542. declare module BABYLON {
  70543. /**
  70544. * Class containing static functions to help procedurally build meshes
  70545. */
  70546. export class DecalBuilder {
  70547. /**
  70548. * Creates a decal mesh.
  70549. * 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
  70550. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70551. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70552. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70553. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70554. * @param name defines the name of the mesh
  70555. * @param sourceMesh defines the mesh where the decal must be applied
  70556. * @param options defines the options used to create the mesh
  70557. * @param scene defines the hosting scene
  70558. * @returns the decal mesh
  70559. * @see https://doc.babylonjs.com/how_to/decals
  70560. */
  70561. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70562. position?: Vector3;
  70563. normal?: Vector3;
  70564. size?: Vector3;
  70565. angle?: number;
  70566. }): Mesh;
  70567. }
  70568. }
  70569. declare module BABYLON {
  70570. /**
  70571. * Class containing static functions to help procedurally build meshes
  70572. */
  70573. export class MeshBuilder {
  70574. /**
  70575. * Creates a box mesh
  70576. * * The parameter `size` sets the size (float) of each box side (default 1)
  70577. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  70578. * * 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)
  70579. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70580. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70581. * * 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
  70582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70583. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70584. * @param name defines the name of the mesh
  70585. * @param options defines the options used to create the mesh
  70586. * @param scene defines the hosting scene
  70587. * @returns the box mesh
  70588. */
  70589. static CreateBox(name: string, options: {
  70590. size?: number;
  70591. width?: number;
  70592. height?: number;
  70593. depth?: number;
  70594. faceUV?: Vector4[];
  70595. faceColors?: Color4[];
  70596. sideOrientation?: number;
  70597. frontUVs?: Vector4;
  70598. backUVs?: Vector4;
  70599. wrap?: boolean;
  70600. topBaseAt?: number;
  70601. bottomBaseAt?: number;
  70602. updatable?: boolean;
  70603. }, scene?: Nullable<Scene>): Mesh;
  70604. /**
  70605. * Creates a tiled box mesh
  70606. * * faceTiles sets the pattern, tile size and number of tiles for a face
  70607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70608. * @param name defines the name of the mesh
  70609. * @param options defines the options used to create the mesh
  70610. * @param scene defines the hosting scene
  70611. * @returns the tiled box mesh
  70612. */
  70613. static CreateTiledBox(name: string, options: {
  70614. pattern?: number;
  70615. size?: number;
  70616. width?: number;
  70617. height?: number;
  70618. depth: number;
  70619. tileSize?: number;
  70620. tileWidth?: number;
  70621. tileHeight?: number;
  70622. faceUV?: Vector4[];
  70623. faceColors?: Color4[];
  70624. alignHorizontal?: number;
  70625. alignVertical?: number;
  70626. sideOrientation?: number;
  70627. updatable?: boolean;
  70628. }, scene?: Nullable<Scene>): Mesh;
  70629. /**
  70630. * Creates a sphere mesh
  70631. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  70632. * * 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`)
  70633. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  70634. * * 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
  70635. * * 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)
  70636. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70637. * * 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
  70638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70639. * @param name defines the name of the mesh
  70640. * @param options defines the options used to create the mesh
  70641. * @param scene defines the hosting scene
  70642. * @returns the sphere mesh
  70643. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  70644. */
  70645. static CreateSphere(name: string, options: {
  70646. segments?: number;
  70647. diameter?: number;
  70648. diameterX?: number;
  70649. diameterY?: number;
  70650. diameterZ?: number;
  70651. arc?: number;
  70652. slice?: number;
  70653. sideOrientation?: number;
  70654. frontUVs?: Vector4;
  70655. backUVs?: Vector4;
  70656. updatable?: boolean;
  70657. }, scene?: Nullable<Scene>): Mesh;
  70658. /**
  70659. * Creates a plane polygonal mesh. By default, this is a disc
  70660. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  70661. * * 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
  70662. * * 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
  70663. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70664. * * 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
  70665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70666. * @param name defines the name of the mesh
  70667. * @param options defines the options used to create the mesh
  70668. * @param scene defines the hosting scene
  70669. * @returns the plane polygonal mesh
  70670. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  70671. */
  70672. static CreateDisc(name: string, options: {
  70673. radius?: number;
  70674. tessellation?: number;
  70675. arc?: number;
  70676. updatable?: boolean;
  70677. sideOrientation?: number;
  70678. frontUVs?: Vector4;
  70679. backUVs?: Vector4;
  70680. }, scene?: Nullable<Scene>): Mesh;
  70681. /**
  70682. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70683. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70684. * * 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`)
  70685. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70686. * * 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
  70687. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70688. * * 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
  70689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70690. * @param name defines the name of the mesh
  70691. * @param options defines the options used to create the mesh
  70692. * @param scene defines the hosting scene
  70693. * @returns the icosahedron mesh
  70694. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70695. */
  70696. static CreateIcoSphere(name: string, options: {
  70697. radius?: number;
  70698. radiusX?: number;
  70699. radiusY?: number;
  70700. radiusZ?: number;
  70701. flat?: boolean;
  70702. subdivisions?: number;
  70703. sideOrientation?: number;
  70704. frontUVs?: Vector4;
  70705. backUVs?: Vector4;
  70706. updatable?: boolean;
  70707. }, scene?: Nullable<Scene>): Mesh;
  70708. /**
  70709. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70710. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  70711. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  70712. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  70713. * * 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
  70714. * * 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
  70715. * * 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
  70716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70717. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70718. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70719. * * The 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
  70720. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  70721. * * 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
  70722. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  70723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70724. * @param name defines the name of the mesh
  70725. * @param options defines the options used to create the mesh
  70726. * @param scene defines the hosting scene
  70727. * @returns the ribbon mesh
  70728. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  70729. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70730. */
  70731. static CreateRibbon(name: string, options: {
  70732. pathArray: Vector3[][];
  70733. closeArray?: boolean;
  70734. closePath?: boolean;
  70735. offset?: number;
  70736. updatable?: boolean;
  70737. sideOrientation?: number;
  70738. frontUVs?: Vector4;
  70739. backUVs?: Vector4;
  70740. instance?: Mesh;
  70741. invertUV?: boolean;
  70742. uvs?: Vector2[];
  70743. colors?: Color4[];
  70744. }, scene?: Nullable<Scene>): Mesh;
  70745. /**
  70746. * Creates a cylinder or a cone mesh
  70747. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  70748. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  70749. * * 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.
  70750. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70751. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70752. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70753. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70754. * * 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).
  70755. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70756. * * 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).
  70757. * * 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
  70758. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70759. * * 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
  70760. * * 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.
  70761. * * If `enclose` is false, a ring surface is one element.
  70762. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70763. * * 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
  70764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70765. * * 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
  70766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70767. * @param name defines the name of the mesh
  70768. * @param options defines the options used to create the mesh
  70769. * @param scene defines the hosting scene
  70770. * @returns the cylinder mesh
  70771. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70772. */
  70773. static CreateCylinder(name: string, options: {
  70774. height?: number;
  70775. diameterTop?: number;
  70776. diameterBottom?: number;
  70777. diameter?: number;
  70778. tessellation?: number;
  70779. subdivisions?: number;
  70780. arc?: number;
  70781. faceColors?: Color4[];
  70782. faceUV?: Vector4[];
  70783. updatable?: boolean;
  70784. hasRings?: boolean;
  70785. enclose?: boolean;
  70786. cap?: number;
  70787. sideOrientation?: number;
  70788. frontUVs?: Vector4;
  70789. backUVs?: Vector4;
  70790. }, scene?: Nullable<Scene>): Mesh;
  70791. /**
  70792. * Creates a torus mesh
  70793. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70794. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70795. * * The parameter `tessellation` sets the number of torus sides (positive integer, default 16)
  70796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70797. * * 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
  70798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70799. * @param name defines the name of the mesh
  70800. * @param options defines the options used to create the mesh
  70801. * @param scene defines the hosting scene
  70802. * @returns the torus mesh
  70803. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70804. */
  70805. static CreateTorus(name: string, options: {
  70806. diameter?: number;
  70807. thickness?: number;
  70808. tessellation?: number;
  70809. updatable?: boolean;
  70810. sideOrientation?: number;
  70811. frontUVs?: Vector4;
  70812. backUVs?: Vector4;
  70813. }, scene?: Nullable<Scene>): Mesh;
  70814. /**
  70815. * Creates a torus knot mesh
  70816. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70817. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70818. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70819. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70820. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70821. * * 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
  70822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70823. * @param name defines the name of the mesh
  70824. * @param options defines the options used to create the mesh
  70825. * @param scene defines the hosting scene
  70826. * @returns the torus knot mesh
  70827. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70828. */
  70829. static CreateTorusKnot(name: string, options: {
  70830. radius?: number;
  70831. tube?: number;
  70832. radialSegments?: number;
  70833. tubularSegments?: number;
  70834. p?: number;
  70835. q?: number;
  70836. updatable?: boolean;
  70837. sideOrientation?: number;
  70838. frontUVs?: Vector4;
  70839. backUVs?: Vector4;
  70840. }, scene?: Nullable<Scene>): Mesh;
  70841. /**
  70842. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70843. * * 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
  70844. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70845. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70846. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70847. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70848. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70849. * * 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
  70850. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70851. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70852. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70853. * @param name defines the name of the new line system
  70854. * @param options defines the options used to create the line system
  70855. * @param scene defines the hosting scene
  70856. * @returns a new line system mesh
  70857. */
  70858. static CreateLineSystem(name: string, options: {
  70859. lines: Vector3[][];
  70860. updatable?: boolean;
  70861. instance?: Nullable<LinesMesh>;
  70862. colors?: Nullable<Color4[][]>;
  70863. useVertexAlpha?: boolean;
  70864. }, scene: Nullable<Scene>): LinesMesh;
  70865. /**
  70866. * Creates a line mesh
  70867. * 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
  70868. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70869. * * The parameter `points` is an array successive Vector3
  70870. * * 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
  70871. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70872. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70873. * * When updating an instance, remember that only point positions can change, not the number of points
  70874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70875. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70876. * @param name defines the name of the new line system
  70877. * @param options defines the options used to create the line system
  70878. * @param scene defines the hosting scene
  70879. * @returns a new line mesh
  70880. */
  70881. static CreateLines(name: string, options: {
  70882. points: Vector3[];
  70883. updatable?: boolean;
  70884. instance?: Nullable<LinesMesh>;
  70885. colors?: Color4[];
  70886. useVertexAlpha?: boolean;
  70887. }, scene?: Nullable<Scene>): LinesMesh;
  70888. /**
  70889. * Creates a dashed line mesh
  70890. * * 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
  70891. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70892. * * The parameter `points` is an array successive Vector3
  70893. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70894. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70895. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70896. * * 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
  70897. * * When updating an instance, remember that only point positions can change, not the number of points
  70898. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70899. * @param name defines the name of the mesh
  70900. * @param options defines the options used to create the mesh
  70901. * @param scene defines the hosting scene
  70902. * @returns the dashed line mesh
  70903. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70904. */
  70905. static CreateDashedLines(name: string, options: {
  70906. points: Vector3[];
  70907. dashSize?: number;
  70908. gapSize?: number;
  70909. dashNb?: number;
  70910. updatable?: boolean;
  70911. instance?: LinesMesh;
  70912. }, scene?: Nullable<Scene>): LinesMesh;
  70913. /**
  70914. * 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.
  70915. * * 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.
  70916. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70917. * * 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.
  70918. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70919. * * 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
  70920. * * 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
  70921. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70922. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70923. * * 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
  70924. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  70925. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70926. * @param name defines the name of the mesh
  70927. * @param options defines the options used to create the mesh
  70928. * @param scene defines the hosting scene
  70929. * @returns the extruded shape mesh
  70930. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70931. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70932. */
  70933. static ExtrudeShape(name: string, options: {
  70934. shape: Vector3[];
  70935. path: Vector3[];
  70936. scale?: number;
  70937. rotation?: number;
  70938. cap?: number;
  70939. updatable?: boolean;
  70940. sideOrientation?: number;
  70941. frontUVs?: Vector4;
  70942. backUVs?: Vector4;
  70943. instance?: Mesh;
  70944. invertUV?: boolean;
  70945. }, scene?: Nullable<Scene>): Mesh;
  70946. /**
  70947. * Creates an custom extruded shape mesh.
  70948. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  70949. * * 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.
  70950. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70951. * * 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
  70952. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  70953. * * 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
  70954. * * It must returns a float value that will be the scale value applied to the shape on each path point
  70955. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  70956. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  70957. * * 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
  70958. * * 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
  70959. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  70960. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70961. * * 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
  70962. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70963. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70964. * @param name defines the name of the mesh
  70965. * @param options defines the options used to create the mesh
  70966. * @param scene defines the hosting scene
  70967. * @returns the custom extruded shape mesh
  70968. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  70969. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70970. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70971. */
  70972. static ExtrudeShapeCustom(name: string, options: {
  70973. shape: Vector3[];
  70974. path: Vector3[];
  70975. scaleFunction?: any;
  70976. rotationFunction?: any;
  70977. ribbonCloseArray?: boolean;
  70978. ribbonClosePath?: boolean;
  70979. cap?: number;
  70980. updatable?: boolean;
  70981. sideOrientation?: number;
  70982. frontUVs?: Vector4;
  70983. backUVs?: Vector4;
  70984. instance?: Mesh;
  70985. invertUV?: boolean;
  70986. }, scene?: Nullable<Scene>): Mesh;
  70987. /**
  70988. * Creates lathe mesh.
  70989. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe
  70990. * * 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
  70991. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70992. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70993. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70994. * * 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
  70995. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70996. * * 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
  70997. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70998. * * 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
  70999. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71001. * @param name defines the name of the mesh
  71002. * @param options defines the options used to create the mesh
  71003. * @param scene defines the hosting scene
  71004. * @returns the lathe mesh
  71005. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  71006. */
  71007. static CreateLathe(name: string, options: {
  71008. shape: Vector3[];
  71009. radius?: number;
  71010. tessellation?: number;
  71011. clip?: number;
  71012. arc?: number;
  71013. closed?: boolean;
  71014. updatable?: boolean;
  71015. sideOrientation?: number;
  71016. frontUVs?: Vector4;
  71017. backUVs?: Vector4;
  71018. cap?: number;
  71019. invertUV?: boolean;
  71020. }, scene?: Nullable<Scene>): Mesh;
  71021. /**
  71022. * Creates a tiled plane mesh
  71023. * * You can set a limited pattern arrangement with the tiles
  71024. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71025. * * 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
  71026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71027. * @param name defines the name of the mesh
  71028. * @param options defines the options used to create the mesh
  71029. * @param scene defines the hosting scene
  71030. * @returns the plane mesh
  71031. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  71032. */
  71033. static CreateTiledPlane(name: string, options: {
  71034. pattern?: number;
  71035. tileSize?: number;
  71036. tileWidth?: number;
  71037. tileHeight?: number;
  71038. size?: number;
  71039. width?: number;
  71040. height?: number;
  71041. alignHorizontal?: number;
  71042. alignVertical?: number;
  71043. sideOrientation?: number;
  71044. frontUVs?: Vector4;
  71045. backUVs?: Vector4;
  71046. updatable?: boolean;
  71047. }, scene?: Nullable<Scene>): Mesh;
  71048. /**
  71049. * Creates a plane mesh
  71050. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  71051. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  71052. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  71053. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71054. * * 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
  71055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71056. * @param name defines the name of the mesh
  71057. * @param options defines the options used to create the mesh
  71058. * @param scene defines the hosting scene
  71059. * @returns the plane mesh
  71060. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  71061. */
  71062. static CreatePlane(name: string, options: {
  71063. size?: number;
  71064. width?: number;
  71065. height?: number;
  71066. sideOrientation?: number;
  71067. frontUVs?: Vector4;
  71068. backUVs?: Vector4;
  71069. updatable?: boolean;
  71070. sourcePlane?: Plane;
  71071. }, scene?: Nullable<Scene>): Mesh;
  71072. /**
  71073. * Creates a ground mesh
  71074. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  71075. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  71076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71077. * @param name defines the name of the mesh
  71078. * @param options defines the options used to create the mesh
  71079. * @param scene defines the hosting scene
  71080. * @returns the ground mesh
  71081. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  71082. */
  71083. static CreateGround(name: string, options: {
  71084. width?: number;
  71085. height?: number;
  71086. subdivisions?: number;
  71087. subdivisionsX?: number;
  71088. subdivisionsY?: number;
  71089. updatable?: boolean;
  71090. }, scene?: Nullable<Scene>): Mesh;
  71091. /**
  71092. * Creates a tiled ground mesh
  71093. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  71094. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  71095. * * 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
  71096. * * 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
  71097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71098. * @param name defines the name of the mesh
  71099. * @param options defines the options used to create the mesh
  71100. * @param scene defines the hosting scene
  71101. * @returns the tiled ground mesh
  71102. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  71103. */
  71104. static CreateTiledGround(name: string, options: {
  71105. xmin: number;
  71106. zmin: number;
  71107. xmax: number;
  71108. zmax: number;
  71109. subdivisions?: {
  71110. w: number;
  71111. h: number;
  71112. };
  71113. precision?: {
  71114. w: number;
  71115. h: number;
  71116. };
  71117. updatable?: boolean;
  71118. }, scene?: Nullable<Scene>): Mesh;
  71119. /**
  71120. * Creates a ground mesh from a height map
  71121. * * The parameter `url` sets the URL of the height map image resource.
  71122. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  71123. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  71124. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  71125. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  71126. * * 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.
  71127. * * 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).
  71128. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  71129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71130. * @param name defines the name of the mesh
  71131. * @param url defines the url to the height map
  71132. * @param options defines the options used to create the mesh
  71133. * @param scene defines the hosting scene
  71134. * @returns the ground mesh
  71135. * @see https://doc.babylonjs.com/babylon101/height_map
  71136. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  71137. */
  71138. static CreateGroundFromHeightMap(name: string, url: string, options: {
  71139. width?: number;
  71140. height?: number;
  71141. subdivisions?: number;
  71142. minHeight?: number;
  71143. maxHeight?: number;
  71144. colorFilter?: Color3;
  71145. alphaFilter?: number;
  71146. updatable?: boolean;
  71147. onReady?: (mesh: GroundMesh) => void;
  71148. }, scene?: Nullable<Scene>): GroundMesh;
  71149. /**
  71150. * Creates a polygon mesh
  71151. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  71152. * * 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
  71153. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  71154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71155. * * 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)
  71156. * * Remember you can only change the shape positions, not their number when updating a polygon
  71157. * @param name defines the name of the mesh
  71158. * @param options defines the options used to create the mesh
  71159. * @param scene defines the hosting scene
  71160. * @param earcutInjection can be used to inject your own earcut reference
  71161. * @returns the polygon mesh
  71162. */
  71163. static CreatePolygon(name: string, options: {
  71164. shape: Vector3[];
  71165. holes?: Vector3[][];
  71166. depth?: number;
  71167. faceUV?: Vector4[];
  71168. faceColors?: Color4[];
  71169. updatable?: boolean;
  71170. sideOrientation?: number;
  71171. frontUVs?: Vector4;
  71172. backUVs?: Vector4;
  71173. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  71174. /**
  71175. * Creates an extruded polygon mesh, with depth in the Y direction.
  71176. * * 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)
  71177. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  71178. * @param name defines the name of the mesh
  71179. * @param options defines the options used to create the mesh
  71180. * @param scene defines the hosting scene
  71181. * @param earcutInjection can be used to inject your own earcut reference
  71182. * @returns the polygon mesh
  71183. */
  71184. static ExtrudePolygon(name: string, options: {
  71185. shape: Vector3[];
  71186. holes?: Vector3[][];
  71187. depth?: number;
  71188. faceUV?: Vector4[];
  71189. faceColors?: Color4[];
  71190. updatable?: boolean;
  71191. sideOrientation?: number;
  71192. frontUVs?: Vector4;
  71193. backUVs?: Vector4;
  71194. wrap?: boolean;
  71195. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  71196. /**
  71197. * Creates a tube mesh.
  71198. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  71199. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  71200. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  71201. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  71202. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overrides the parameter `radius`
  71203. * * 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)
  71204. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  71205. * * 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
  71206. * * 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
  71207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71208. * * 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
  71209. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71211. * @param name defines the name of the mesh
  71212. * @param options defines the options used to create the mesh
  71213. * @param scene defines the hosting scene
  71214. * @returns the tube mesh
  71215. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71216. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  71217. */
  71218. static CreateTube(name: string, options: {
  71219. path: Vector3[];
  71220. radius?: number;
  71221. tessellation?: number;
  71222. radiusFunction?: {
  71223. (i: number, distance: number): number;
  71224. };
  71225. cap?: number;
  71226. arc?: number;
  71227. updatable?: boolean;
  71228. sideOrientation?: number;
  71229. frontUVs?: Vector4;
  71230. backUVs?: Vector4;
  71231. instance?: Mesh;
  71232. invertUV?: boolean;
  71233. }, scene?: Nullable<Scene>): Mesh;
  71234. /**
  71235. * Creates a polyhedron mesh
  71236. * * 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
  71237. * * The parameter `size` (positive float, default 1) sets the polygon size
  71238. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  71239. * * 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`
  71240. * * 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
  71241. * * 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)`)
  71242. * * 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
  71243. * * 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
  71244. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71245. * * 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
  71246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71247. * @param name defines the name of the mesh
  71248. * @param options defines the options used to create the mesh
  71249. * @param scene defines the hosting scene
  71250. * @returns the polyhedron mesh
  71251. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  71252. */
  71253. static CreatePolyhedron(name: string, options: {
  71254. type?: number;
  71255. size?: number;
  71256. sizeX?: number;
  71257. sizeY?: number;
  71258. sizeZ?: number;
  71259. custom?: any;
  71260. faceUV?: Vector4[];
  71261. faceColors?: Color4[];
  71262. flat?: boolean;
  71263. updatable?: boolean;
  71264. sideOrientation?: number;
  71265. frontUVs?: Vector4;
  71266. backUVs?: Vector4;
  71267. }, scene?: Nullable<Scene>): Mesh;
  71268. /**
  71269. * Creates a decal mesh.
  71270. * 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
  71271. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  71272. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  71273. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  71274. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  71275. * @param name defines the name of the mesh
  71276. * @param sourceMesh defines the mesh where the decal must be applied
  71277. * @param options defines the options used to create the mesh
  71278. * @param scene defines the hosting scene
  71279. * @returns the decal mesh
  71280. * @see https://doc.babylonjs.com/how_to/decals
  71281. */
  71282. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  71283. position?: Vector3;
  71284. normal?: Vector3;
  71285. size?: Vector3;
  71286. angle?: number;
  71287. }): Mesh;
  71288. /**
  71289. * Creates a Capsule Mesh
  71290. * @param name defines the name of the mesh.
  71291. * @param options the constructors options used to shape the mesh.
  71292. * @param scene defines the scene the mesh is scoped to.
  71293. * @returns the capsule mesh
  71294. * @see https://doc.babylonjs.com/how_to/capsule_shape
  71295. */
  71296. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  71297. }
  71298. }
  71299. declare module BABYLON {
  71300. /**
  71301. * A simplifier interface for future simplification implementations
  71302. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71303. */
  71304. export interface ISimplifier {
  71305. /**
  71306. * Simplification of a given mesh according to the given settings.
  71307. * Since this requires computation, it is assumed that the function runs async.
  71308. * @param settings The settings of the simplification, including quality and distance
  71309. * @param successCallback A callback that will be called after the mesh was simplified.
  71310. * @param errorCallback in case of an error, this callback will be called. optional.
  71311. */
  71312. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  71313. }
  71314. /**
  71315. * Expected simplification settings.
  71316. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  71317. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71318. */
  71319. export interface ISimplificationSettings {
  71320. /**
  71321. * Gets or sets the expected quality
  71322. */
  71323. quality: number;
  71324. /**
  71325. * Gets or sets the distance when this optimized version should be used
  71326. */
  71327. distance: number;
  71328. /**
  71329. * Gets an already optimized mesh
  71330. */
  71331. optimizeMesh?: boolean;
  71332. }
  71333. /**
  71334. * Class used to specify simplification options
  71335. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71336. */
  71337. export class SimplificationSettings implements ISimplificationSettings {
  71338. /** expected quality */
  71339. quality: number;
  71340. /** distance when this optimized version should be used */
  71341. distance: number;
  71342. /** already optimized mesh */
  71343. optimizeMesh?: boolean | undefined;
  71344. /**
  71345. * Creates a SimplificationSettings
  71346. * @param quality expected quality
  71347. * @param distance distance when this optimized version should be used
  71348. * @param optimizeMesh already optimized mesh
  71349. */
  71350. constructor(
  71351. /** expected quality */
  71352. quality: number,
  71353. /** distance when this optimized version should be used */
  71354. distance: number,
  71355. /** already optimized mesh */
  71356. optimizeMesh?: boolean | undefined);
  71357. }
  71358. /**
  71359. * Interface used to define a simplification task
  71360. */
  71361. export interface ISimplificationTask {
  71362. /**
  71363. * Array of settings
  71364. */
  71365. settings: Array<ISimplificationSettings>;
  71366. /**
  71367. * Simplification type
  71368. */
  71369. simplificationType: SimplificationType;
  71370. /**
  71371. * Mesh to simplify
  71372. */
  71373. mesh: Mesh;
  71374. /**
  71375. * Callback called on success
  71376. */
  71377. successCallback?: () => void;
  71378. /**
  71379. * Defines if parallel processing can be used
  71380. */
  71381. parallelProcessing: boolean;
  71382. }
  71383. /**
  71384. * Queue used to order the simplification tasks
  71385. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71386. */
  71387. export class SimplificationQueue {
  71388. private _simplificationArray;
  71389. /**
  71390. * Gets a boolean indicating that the process is still running
  71391. */
  71392. running: boolean;
  71393. /**
  71394. * Creates a new queue
  71395. */
  71396. constructor();
  71397. /**
  71398. * Adds a new simplification task
  71399. * @param task defines a task to add
  71400. */
  71401. addTask(task: ISimplificationTask): void;
  71402. /**
  71403. * Execute next task
  71404. */
  71405. executeNext(): void;
  71406. /**
  71407. * Execute a simplification task
  71408. * @param task defines the task to run
  71409. */
  71410. runSimplification(task: ISimplificationTask): void;
  71411. private getSimplifier;
  71412. }
  71413. /**
  71414. * The implemented types of simplification
  71415. * At the moment only Quadratic Error Decimation is implemented
  71416. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71417. */
  71418. export enum SimplificationType {
  71419. /** Quadratic error decimation */
  71420. QUADRATIC = 0
  71421. }
  71422. /**
  71423. * An implementation of the Quadratic Error simplification algorithm.
  71424. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  71425. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  71426. * @author RaananW
  71427. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71428. */
  71429. export class QuadraticErrorSimplification implements ISimplifier {
  71430. private _mesh;
  71431. private triangles;
  71432. private vertices;
  71433. private references;
  71434. private _reconstructedMesh;
  71435. /** Gets or sets the number pf sync iterations */
  71436. syncIterations: number;
  71437. /** Gets or sets the aggressiveness of the simplifier */
  71438. aggressiveness: number;
  71439. /** Gets or sets the number of allowed iterations for decimation */
  71440. decimationIterations: number;
  71441. /** Gets or sets the espilon to use for bounding box computation */
  71442. boundingBoxEpsilon: number;
  71443. /**
  71444. * Creates a new QuadraticErrorSimplification
  71445. * @param _mesh defines the target mesh
  71446. */
  71447. constructor(_mesh: Mesh);
  71448. /**
  71449. * Simplification of a given mesh according to the given settings.
  71450. * Since this requires computation, it is assumed that the function runs async.
  71451. * @param settings The settings of the simplification, including quality and distance
  71452. * @param successCallback A callback that will be called after the mesh was simplified.
  71453. */
  71454. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  71455. private runDecimation;
  71456. private initWithMesh;
  71457. private init;
  71458. private reconstructMesh;
  71459. private initDecimatedMesh;
  71460. private isFlipped;
  71461. private updateTriangles;
  71462. private identifyBorder;
  71463. private updateMesh;
  71464. private vertexError;
  71465. private calculateError;
  71466. }
  71467. }
  71468. declare module BABYLON {
  71469. interface Scene {
  71470. /** @hidden (Backing field) */
  71471. _simplificationQueue: SimplificationQueue;
  71472. /**
  71473. * Gets or sets the simplification queue attached to the scene
  71474. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71475. */
  71476. simplificationQueue: SimplificationQueue;
  71477. }
  71478. interface Mesh {
  71479. /**
  71480. * Simplify the mesh according to the given array of settings.
  71481. * Function will return immediately and will simplify async
  71482. * @param settings a collection of simplification settings
  71483. * @param parallelProcessing should all levels calculate parallel or one after the other
  71484. * @param simplificationType the type of simplification to run
  71485. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  71486. * @returns the current mesh
  71487. */
  71488. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  71489. }
  71490. /**
  71491. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  71492. * created in a scene
  71493. */
  71494. export class SimplicationQueueSceneComponent implements ISceneComponent {
  71495. /**
  71496. * The component name helpfull to identify the component in the list of scene components.
  71497. */
  71498. readonly name: string;
  71499. /**
  71500. * The scene the component belongs to.
  71501. */
  71502. scene: Scene;
  71503. /**
  71504. * Creates a new instance of the component for the given scene
  71505. * @param scene Defines the scene to register the component in
  71506. */
  71507. constructor(scene: Scene);
  71508. /**
  71509. * Registers the component in a given scene
  71510. */
  71511. register(): void;
  71512. /**
  71513. * Rebuilds the elements related to this component in case of
  71514. * context lost for instance.
  71515. */
  71516. rebuild(): void;
  71517. /**
  71518. * Disposes the component and the associated resources
  71519. */
  71520. dispose(): void;
  71521. private _beforeCameraUpdate;
  71522. }
  71523. }
  71524. declare module BABYLON {
  71525. interface Mesh {
  71526. /**
  71527. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  71528. */
  71529. thinInstanceEnablePicking: boolean;
  71530. /**
  71531. * Creates a new thin instance
  71532. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  71533. * @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
  71534. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  71535. */
  71536. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  71537. /**
  71538. * Adds the transformation (matrix) of the current mesh as a thin instance
  71539. * @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
  71540. * @returns the thin instance index number
  71541. */
  71542. thinInstanceAddSelf(refresh: boolean): number;
  71543. /**
  71544. * Registers a custom attribute to be used with thin instances
  71545. * @param kind name of the attribute
  71546. * @param stride size in floats of the attribute
  71547. */
  71548. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  71549. /**
  71550. * Sets the matrix of a thin instance
  71551. * @param index index of the thin instance
  71552. * @param matrix matrix to set
  71553. * @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
  71554. */
  71555. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  71556. /**
  71557. * Sets the value of a custom attribute for a thin instance
  71558. * @param kind name of the attribute
  71559. * @param index index of the thin instance
  71560. * @param value value to set
  71561. * @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
  71562. */
  71563. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  71564. /**
  71565. * 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.
  71566. */
  71567. thinInstanceCount: number;
  71568. /**
  71569. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  71570. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  71571. * @param buffer buffer to set
  71572. * @param stride size in floats of each value of the buffer
  71573. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  71574. */
  71575. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  71576. /**
  71577. * Gets the list of world matrices
  71578. * @return an array containing all the world matrices from the thin instances
  71579. */
  71580. thinInstanceGetWorldMatrices(): Matrix[];
  71581. /**
  71582. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  71583. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71584. */
  71585. thinInstanceBufferUpdated(kind: string): void;
  71586. /**
  71587. * Applies a partial update to a buffer directly on the GPU
  71588. * 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
  71589. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71590. * @param data the data to set in the GPU buffer
  71591. * @param offset the offset in the GPU buffer where to update the data
  71592. */
  71593. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  71594. /**
  71595. * Refreshes the bounding info, taking into account all the thin instances defined
  71596. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  71597. */
  71598. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  71599. /** @hidden */
  71600. _thinInstanceInitializeUserStorage(): void;
  71601. /** @hidden */
  71602. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  71603. /** @hidden */
  71604. _userThinInstanceBuffersStorage: {
  71605. data: {
  71606. [key: string]: Float32Array;
  71607. };
  71608. sizes: {
  71609. [key: string]: number;
  71610. };
  71611. vertexBuffers: {
  71612. [key: string]: Nullable<VertexBuffer>;
  71613. };
  71614. strides: {
  71615. [key: string]: number;
  71616. };
  71617. };
  71618. }
  71619. }
  71620. declare module BABYLON {
  71621. /**
  71622. * Navigation plugin interface to add navigation constrained by a navigation mesh
  71623. */
  71624. export interface INavigationEnginePlugin {
  71625. /**
  71626. * plugin name
  71627. */
  71628. name: string;
  71629. /**
  71630. * Creates a navigation mesh
  71631. * @param meshes array of all the geometry used to compute the navigation mesh
  71632. * @param parameters bunch of parameters used to filter geometry
  71633. */
  71634. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71635. /**
  71636. * Create a navigation mesh debug mesh
  71637. * @param scene is where the mesh will be added
  71638. * @returns debug display mesh
  71639. */
  71640. createDebugNavMesh(scene: Scene): Mesh;
  71641. /**
  71642. * Get a navigation mesh constrained position, closest to the parameter position
  71643. * @param position world position
  71644. * @returns the closest point to position constrained by the navigation mesh
  71645. */
  71646. getClosestPoint(position: Vector3): Vector3;
  71647. /**
  71648. * Get a navigation mesh constrained position, closest to the parameter position
  71649. * @param position world position
  71650. * @param result output the closest point to position constrained by the navigation mesh
  71651. */
  71652. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71653. /**
  71654. * Get a navigation mesh constrained position, within a particular radius
  71655. * @param position world position
  71656. * @param maxRadius the maximum distance to the constrained world position
  71657. * @returns the closest point to position constrained by the navigation mesh
  71658. */
  71659. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71660. /**
  71661. * Get a navigation mesh constrained position, within a particular radius
  71662. * @param position world position
  71663. * @param maxRadius the maximum distance to the constrained world position
  71664. * @param result output the closest point to position constrained by the navigation mesh
  71665. */
  71666. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71667. /**
  71668. * Compute the final position from a segment made of destination-position
  71669. * @param position world position
  71670. * @param destination world position
  71671. * @returns the resulting point along the navmesh
  71672. */
  71673. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71674. /**
  71675. * Compute the final position from a segment made of destination-position
  71676. * @param position world position
  71677. * @param destination world position
  71678. * @param result output the resulting point along the navmesh
  71679. */
  71680. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71681. /**
  71682. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71683. * @param start world position
  71684. * @param end world position
  71685. * @returns array containing world position composing the path
  71686. */
  71687. computePath(start: Vector3, end: Vector3): Vector3[];
  71688. /**
  71689. * If this plugin is supported
  71690. * @returns true if plugin is supported
  71691. */
  71692. isSupported(): boolean;
  71693. /**
  71694. * Create a new Crowd so you can add agents
  71695. * @param maxAgents the maximum agent count in the crowd
  71696. * @param maxAgentRadius the maximum radius an agent can have
  71697. * @param scene to attach the crowd to
  71698. * @returns the crowd you can add agents to
  71699. */
  71700. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71701. /**
  71702. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71703. * The queries will try to find a solution within those bounds
  71704. * default is (1,1,1)
  71705. * @param extent x,y,z value that define the extent around the queries point of reference
  71706. */
  71707. setDefaultQueryExtent(extent: Vector3): void;
  71708. /**
  71709. * Get the Bounding box extent specified by setDefaultQueryExtent
  71710. * @returns the box extent values
  71711. */
  71712. getDefaultQueryExtent(): Vector3;
  71713. /**
  71714. * build the navmesh from a previously saved state using getNavmeshData
  71715. * @param data the Uint8Array returned by getNavmeshData
  71716. */
  71717. buildFromNavmeshData(data: Uint8Array): void;
  71718. /**
  71719. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71720. * @returns data the Uint8Array that can be saved and reused
  71721. */
  71722. getNavmeshData(): Uint8Array;
  71723. /**
  71724. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71725. * @param result output the box extent values
  71726. */
  71727. getDefaultQueryExtentToRef(result: Vector3): void;
  71728. /**
  71729. * Set the time step of the navigation tick update.
  71730. * Default is 1/60.
  71731. * A value of 0 will disable fixed time update
  71732. * @param newTimeStep the new timestep to apply to this world.
  71733. */
  71734. setTimeStep(newTimeStep: number): void;
  71735. /**
  71736. * Get the time step of the navigation tick update.
  71737. * @returns the current time step
  71738. */
  71739. getTimeStep(): number;
  71740. /**
  71741. * If delta time in navigation tick update is greater than the time step
  71742. * a number of sub iterations are done. If more iterations are need to reach deltatime
  71743. * they will be discarded.
  71744. * A value of 0 will set to no maximum and update will use as many substeps as needed
  71745. * @param newStepCount the maximum number of iterations
  71746. */
  71747. setMaximumSubStepCount(newStepCount: number): void;
  71748. /**
  71749. * Get the maximum number of iterations per navigation tick update
  71750. * @returns the maximum number of iterations
  71751. */
  71752. getMaximumSubStepCount(): number;
  71753. /**
  71754. * Release all resources
  71755. */
  71756. dispose(): void;
  71757. }
  71758. /**
  71759. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71760. */
  71761. export interface ICrowd {
  71762. /**
  71763. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71764. * You can attach anything to that node. The node position is updated in the scene update tick.
  71765. * @param pos world position that will be constrained by the navigation mesh
  71766. * @param parameters agent parameters
  71767. * @param transform hooked to the agent that will be update by the scene
  71768. * @returns agent index
  71769. */
  71770. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71771. /**
  71772. * Returns the agent position in world space
  71773. * @param index agent index returned by addAgent
  71774. * @returns world space position
  71775. */
  71776. getAgentPosition(index: number): Vector3;
  71777. /**
  71778. * Gets the agent position result in world space
  71779. * @param index agent index returned by addAgent
  71780. * @param result output world space position
  71781. */
  71782. getAgentPositionToRef(index: number, result: Vector3): void;
  71783. /**
  71784. * Gets the agent velocity in world space
  71785. * @param index agent index returned by addAgent
  71786. * @returns world space velocity
  71787. */
  71788. getAgentVelocity(index: number): Vector3;
  71789. /**
  71790. * Gets the agent velocity result in world space
  71791. * @param index agent index returned by addAgent
  71792. * @param result output world space velocity
  71793. */
  71794. getAgentVelocityToRef(index: number, result: Vector3): void;
  71795. /**
  71796. * Gets the agent next target point on the path
  71797. * @param index agent index returned by addAgent
  71798. * @returns world space position
  71799. */
  71800. getAgentNextTargetPath(index: number): Vector3;
  71801. /**
  71802. * Gets the agent state
  71803. * @param index agent index returned by addAgent
  71804. * @returns agent state
  71805. */
  71806. getAgentState(index: number): number;
  71807. /**
  71808. * returns true if the agent in over an off mesh link connection
  71809. * @param index agent index returned by addAgent
  71810. * @returns true if over an off mesh link connection
  71811. */
  71812. overOffmeshConnection(index: number): boolean;
  71813. /**
  71814. * Gets the agent next target point on the path
  71815. * @param index agent index returned by addAgent
  71816. * @param result output world space position
  71817. */
  71818. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71819. /**
  71820. * remove a particular agent previously created
  71821. * @param index agent index returned by addAgent
  71822. */
  71823. removeAgent(index: number): void;
  71824. /**
  71825. * get the list of all agents attached to this crowd
  71826. * @returns list of agent indices
  71827. */
  71828. getAgents(): number[];
  71829. /**
  71830. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71831. * @param deltaTime in seconds
  71832. */
  71833. update(deltaTime: number): void;
  71834. /**
  71835. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71836. * @param index agent index returned by addAgent
  71837. * @param destination targeted world position
  71838. */
  71839. agentGoto(index: number, destination: Vector3): void;
  71840. /**
  71841. * Teleport the agent to a new position
  71842. * @param index agent index returned by addAgent
  71843. * @param destination targeted world position
  71844. */
  71845. agentTeleport(index: number, destination: Vector3): void;
  71846. /**
  71847. * Update agent parameters
  71848. * @param index agent index returned by addAgent
  71849. * @param parameters agent parameters
  71850. */
  71851. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71852. /**
  71853. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71854. * The queries will try to find a solution within those bounds
  71855. * default is (1,1,1)
  71856. * @param extent x,y,z value that define the extent around the queries point of reference
  71857. */
  71858. setDefaultQueryExtent(extent: Vector3): void;
  71859. /**
  71860. * Get the Bounding box extent specified by setDefaultQueryExtent
  71861. * @returns the box extent values
  71862. */
  71863. getDefaultQueryExtent(): Vector3;
  71864. /**
  71865. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71866. * @param result output the box extent values
  71867. */
  71868. getDefaultQueryExtentToRef(result: Vector3): void;
  71869. /**
  71870. * Release all resources
  71871. */
  71872. dispose(): void;
  71873. }
  71874. /**
  71875. * Configures an agent
  71876. */
  71877. export interface IAgentParameters {
  71878. /**
  71879. * Agent radius. [Limit: >= 0]
  71880. */
  71881. radius: number;
  71882. /**
  71883. * Agent height. [Limit: > 0]
  71884. */
  71885. height: number;
  71886. /**
  71887. * Maximum allowed acceleration. [Limit: >= 0]
  71888. */
  71889. maxAcceleration: number;
  71890. /**
  71891. * Maximum allowed speed. [Limit: >= 0]
  71892. */
  71893. maxSpeed: number;
  71894. /**
  71895. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  71896. */
  71897. collisionQueryRange: number;
  71898. /**
  71899. * The path visibility optimization range. [Limit: > 0]
  71900. */
  71901. pathOptimizationRange: number;
  71902. /**
  71903. * How aggressive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  71904. */
  71905. separationWeight: number;
  71906. }
  71907. /**
  71908. * Configures the navigation mesh creation
  71909. */
  71910. export interface INavMeshParameters {
  71911. /**
  71912. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  71913. */
  71914. cs: number;
  71915. /**
  71916. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  71917. */
  71918. ch: number;
  71919. /**
  71920. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  71921. */
  71922. walkableSlopeAngle: number;
  71923. /**
  71924. * Minimum floor to 'ceiling' height that will still allow the floor area to
  71925. * be considered walkable. [Limit: >= 3] [Units: vx]
  71926. */
  71927. walkableHeight: number;
  71928. /**
  71929. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  71930. */
  71931. walkableClimb: number;
  71932. /**
  71933. * The distance to erode/shrink the walkable area of the heightfield away from
  71934. * obstructions. [Limit: >=0] [Units: vx]
  71935. */
  71936. walkableRadius: number;
  71937. /**
  71938. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  71939. */
  71940. maxEdgeLen: number;
  71941. /**
  71942. * The maximum distance a simplified contour's border edges should deviate
  71943. * the original raw contour. [Limit: >=0] [Units: vx]
  71944. */
  71945. maxSimplificationError: number;
  71946. /**
  71947. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  71948. */
  71949. minRegionArea: number;
  71950. /**
  71951. * Any regions with a span count smaller than this value will, if possible,
  71952. * be merged with larger regions. [Limit: >=0] [Units: vx]
  71953. */
  71954. mergeRegionArea: number;
  71955. /**
  71956. * The maximum number of vertices allowed for polygons generated during the
  71957. * contour to polygon conversion process. [Limit: >= 3]
  71958. */
  71959. maxVertsPerPoly: number;
  71960. /**
  71961. * Sets the sampling distance to use when generating the detail mesh.
  71962. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  71963. */
  71964. detailSampleDist: number;
  71965. /**
  71966. * The maximum distance the detail mesh surface should deviate from heightfield
  71967. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  71968. */
  71969. detailSampleMaxError: number;
  71970. }
  71971. }
  71972. declare module BABYLON {
  71973. /**
  71974. * RecastJS navigation plugin
  71975. */
  71976. export class RecastJSPlugin implements INavigationEnginePlugin {
  71977. /**
  71978. * Reference to the Recast library
  71979. */
  71980. bjsRECAST: any;
  71981. /**
  71982. * plugin name
  71983. */
  71984. name: string;
  71985. /**
  71986. * the first navmesh created. We might extend this to support multiple navmeshes
  71987. */
  71988. navMesh: any;
  71989. private _maximumSubStepCount;
  71990. private _timeStep;
  71991. /**
  71992. * Initializes the recastJS plugin
  71993. * @param recastInjection can be used to inject your own recast reference
  71994. */
  71995. constructor(recastInjection?: any);
  71996. /**
  71997. * Set the time step of the navigation tick update.
  71998. * Default is 1/60.
  71999. * A value of 0 will disable fixed time update
  72000. * @param newTimeStep the new timestep to apply to this world.
  72001. */
  72002. setTimeStep(newTimeStep?: number): void;
  72003. /**
  72004. * Get the time step of the navigation tick update.
  72005. * @returns the current time step
  72006. */
  72007. getTimeStep(): number;
  72008. /**
  72009. * If delta time in navigation tick update is greater than the time step
  72010. * a number of sub iterations are done. If more iterations are need to reach deltatime
  72011. * they will be discarded.
  72012. * A value of 0 will set to no maximum and update will use as many substeps as needed
  72013. * @param newStepCount the maximum number of iterations
  72014. */
  72015. setMaximumSubStepCount(newStepCount?: number): void;
  72016. /**
  72017. * Get the maximum number of iterations per navigation tick update
  72018. * @returns the maximum number of iterations
  72019. */
  72020. getMaximumSubStepCount(): number;
  72021. /**
  72022. * Creates a navigation mesh
  72023. * @param meshes array of all the geometry used to compute the navigation mesh
  72024. * @param parameters bunch of parameters used to filter geometry
  72025. */
  72026. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  72027. /**
  72028. * Create a navigation mesh debug mesh
  72029. * @param scene is where the mesh will be added
  72030. * @returns debug display mesh
  72031. */
  72032. createDebugNavMesh(scene: Scene): Mesh;
  72033. /**
  72034. * Get a navigation mesh constrained position, closest to the parameter position
  72035. * @param position world position
  72036. * @returns the closest point to position constrained by the navigation mesh
  72037. */
  72038. getClosestPoint(position: Vector3): Vector3;
  72039. /**
  72040. * Get a navigation mesh constrained position, closest to the parameter position
  72041. * @param position world position
  72042. * @param result output the closest point to position constrained by the navigation mesh
  72043. */
  72044. getClosestPointToRef(position: Vector3, result: Vector3): void;
  72045. /**
  72046. * Get a navigation mesh constrained position, within a particular radius
  72047. * @param position world position
  72048. * @param maxRadius the maximum distance to the constrained world position
  72049. * @returns the closest point to position constrained by the navigation mesh
  72050. */
  72051. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  72052. /**
  72053. * Get a navigation mesh constrained position, within a particular radius
  72054. * @param position world position
  72055. * @param maxRadius the maximum distance to the constrained world position
  72056. * @param result output the closest point to position constrained by the navigation mesh
  72057. */
  72058. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  72059. /**
  72060. * Compute the final position from a segment made of destination-position
  72061. * @param position world position
  72062. * @param destination world position
  72063. * @returns the resulting point along the navmesh
  72064. */
  72065. moveAlong(position: Vector3, destination: Vector3): Vector3;
  72066. /**
  72067. * Compute the final position from a segment made of destination-position
  72068. * @param position world position
  72069. * @param destination world position
  72070. * @param result output the resulting point along the navmesh
  72071. */
  72072. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  72073. /**
  72074. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  72075. * @param start world position
  72076. * @param end world position
  72077. * @returns array containing world position composing the path
  72078. */
  72079. computePath(start: Vector3, end: Vector3): Vector3[];
  72080. /**
  72081. * Create a new Crowd so you can add agents
  72082. * @param maxAgents the maximum agent count in the crowd
  72083. * @param maxAgentRadius the maximum radius an agent can have
  72084. * @param scene to attach the crowd to
  72085. * @returns the crowd you can add agents to
  72086. */
  72087. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  72088. /**
  72089. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72090. * The queries will try to find a solution within those bounds
  72091. * default is (1,1,1)
  72092. * @param extent x,y,z value that define the extent around the queries point of reference
  72093. */
  72094. setDefaultQueryExtent(extent: Vector3): void;
  72095. /**
  72096. * Get the Bounding box extent specified by setDefaultQueryExtent
  72097. * @returns the box extent values
  72098. */
  72099. getDefaultQueryExtent(): Vector3;
  72100. /**
  72101. * build the navmesh from a previously saved state using getNavmeshData
  72102. * @param data the Uint8Array returned by getNavmeshData
  72103. */
  72104. buildFromNavmeshData(data: Uint8Array): void;
  72105. /**
  72106. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  72107. * @returns data the Uint8Array that can be saved and reused
  72108. */
  72109. getNavmeshData(): Uint8Array;
  72110. /**
  72111. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72112. * @param result output the box extent values
  72113. */
  72114. getDefaultQueryExtentToRef(result: Vector3): void;
  72115. /**
  72116. * Disposes
  72117. */
  72118. dispose(): void;
  72119. /**
  72120. * If this plugin is supported
  72121. * @returns true if plugin is supported
  72122. */
  72123. isSupported(): boolean;
  72124. }
  72125. /**
  72126. * Recast detour crowd implementation
  72127. */
  72128. export class RecastJSCrowd implements ICrowd {
  72129. /**
  72130. * Recast/detour plugin
  72131. */
  72132. bjsRECASTPlugin: RecastJSPlugin;
  72133. /**
  72134. * Link to the detour crowd
  72135. */
  72136. recastCrowd: any;
  72137. /**
  72138. * One transform per agent
  72139. */
  72140. transforms: TransformNode[];
  72141. /**
  72142. * All agents created
  72143. */
  72144. agents: number[];
  72145. /**
  72146. * Link to the scene is kept to unregister the crowd from the scene
  72147. */
  72148. private _scene;
  72149. /**
  72150. * Observer for crowd updates
  72151. */
  72152. private _onBeforeAnimationsObserver;
  72153. /**
  72154. * Constructor
  72155. * @param plugin recastJS plugin
  72156. * @param maxAgents the maximum agent count in the crowd
  72157. * @param maxAgentRadius the maximum radius an agent can have
  72158. * @param scene to attach the crowd to
  72159. * @returns the crowd you can add agents to
  72160. */
  72161. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  72162. /**
  72163. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  72164. * You can attach anything to that node. The node position is updated in the scene update tick.
  72165. * @param pos world position that will be constrained by the navigation mesh
  72166. * @param parameters agent parameters
  72167. * @param transform hooked to the agent that will be update by the scene
  72168. * @returns agent index
  72169. */
  72170. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  72171. /**
  72172. * Returns the agent position in world space
  72173. * @param index agent index returned by addAgent
  72174. * @returns world space position
  72175. */
  72176. getAgentPosition(index: number): Vector3;
  72177. /**
  72178. * Returns the agent position result in world space
  72179. * @param index agent index returned by addAgent
  72180. * @param result output world space position
  72181. */
  72182. getAgentPositionToRef(index: number, result: Vector3): void;
  72183. /**
  72184. * Returns the agent velocity in world space
  72185. * @param index agent index returned by addAgent
  72186. * @returns world space velocity
  72187. */
  72188. getAgentVelocity(index: number): Vector3;
  72189. /**
  72190. * Returns the agent velocity result in world space
  72191. * @param index agent index returned by addAgent
  72192. * @param result output world space velocity
  72193. */
  72194. getAgentVelocityToRef(index: number, result: Vector3): void;
  72195. /**
  72196. * Returns the agent next target point on the path
  72197. * @param index agent index returned by addAgent
  72198. * @returns world space position
  72199. */
  72200. getAgentNextTargetPath(index: number): Vector3;
  72201. /**
  72202. * Returns the agent next target point on the path
  72203. * @param index agent index returned by addAgent
  72204. * @param result output world space position
  72205. */
  72206. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  72207. /**
  72208. * Gets the agent state
  72209. * @param index agent index returned by addAgent
  72210. * @returns agent state
  72211. */
  72212. getAgentState(index: number): number;
  72213. /**
  72214. * returns true if the agent in over an off mesh link connection
  72215. * @param index agent index returned by addAgent
  72216. * @returns true if over an off mesh link connection
  72217. */
  72218. overOffmeshConnection(index: number): boolean;
  72219. /**
  72220. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  72221. * @param index agent index returned by addAgent
  72222. * @param destination targeted world position
  72223. */
  72224. agentGoto(index: number, destination: Vector3): void;
  72225. /**
  72226. * Teleport the agent to a new position
  72227. * @param index agent index returned by addAgent
  72228. * @param destination targeted world position
  72229. */
  72230. agentTeleport(index: number, destination: Vector3): void;
  72231. /**
  72232. * Update agent parameters
  72233. * @param index agent index returned by addAgent
  72234. * @param parameters agent parameters
  72235. */
  72236. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  72237. /**
  72238. * remove a particular agent previously created
  72239. * @param index agent index returned by addAgent
  72240. */
  72241. removeAgent(index: number): void;
  72242. /**
  72243. * get the list of all agents attached to this crowd
  72244. * @returns list of agent indices
  72245. */
  72246. getAgents(): number[];
  72247. /**
  72248. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  72249. * @param deltaTime in seconds
  72250. */
  72251. update(deltaTime: number): void;
  72252. /**
  72253. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72254. * The queries will try to find a solution within those bounds
  72255. * default is (1,1,1)
  72256. * @param extent x,y,z value that define the extent around the queries point of reference
  72257. */
  72258. setDefaultQueryExtent(extent: Vector3): void;
  72259. /**
  72260. * Get the Bounding box extent specified by setDefaultQueryExtent
  72261. * @returns the box extent values
  72262. */
  72263. getDefaultQueryExtent(): Vector3;
  72264. /**
  72265. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72266. * @param result output the box extent values
  72267. */
  72268. getDefaultQueryExtentToRef(result: Vector3): void;
  72269. /**
  72270. * Release all resources
  72271. */
  72272. dispose(): void;
  72273. }
  72274. }
  72275. declare module BABYLON {
  72276. /**
  72277. * Class used to enable access to IndexedDB
  72278. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  72279. */
  72280. export class Database implements IOfflineProvider {
  72281. private _callbackManifestChecked;
  72282. private _currentSceneUrl;
  72283. private _db;
  72284. private _enableSceneOffline;
  72285. private _enableTexturesOffline;
  72286. private _manifestVersionFound;
  72287. private _mustUpdateRessources;
  72288. private _hasReachedQuota;
  72289. private _isSupported;
  72290. private _idbFactory;
  72291. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  72292. private static IsUASupportingBlobStorage;
  72293. /**
  72294. * Gets a boolean indicating if Database storage is enabled (off by default)
  72295. */
  72296. static IDBStorageEnabled: boolean;
  72297. /**
  72298. * Gets a boolean indicating if scene must be saved in the database
  72299. */
  72300. get enableSceneOffline(): boolean;
  72301. /**
  72302. * Gets a boolean indicating if textures must be saved in the database
  72303. */
  72304. get enableTexturesOffline(): boolean;
  72305. /**
  72306. * Creates a new Database
  72307. * @param urlToScene defines the url to load the scene
  72308. * @param callbackManifestChecked defines the callback to use when manifest is checked
  72309. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  72310. */
  72311. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  72312. private static _ParseURL;
  72313. private static _ReturnFullUrlLocation;
  72314. private _checkManifestFile;
  72315. /**
  72316. * Open the database and make it available
  72317. * @param successCallback defines the callback to call on success
  72318. * @param errorCallback defines the callback to call on error
  72319. */
  72320. open(successCallback: () => void, errorCallback: () => void): void;
  72321. /**
  72322. * Loads an image from the database
  72323. * @param url defines the url to load from
  72324. * @param image defines the target DOM image
  72325. */
  72326. loadImage(url: string, image: HTMLImageElement): void;
  72327. private _loadImageFromDBAsync;
  72328. private _saveImageIntoDBAsync;
  72329. private _checkVersionFromDB;
  72330. private _loadVersionFromDBAsync;
  72331. private _saveVersionIntoDBAsync;
  72332. /**
  72333. * Loads a file from database
  72334. * @param url defines the URL to load from
  72335. * @param sceneLoaded defines a callback to call on success
  72336. * @param progressCallBack defines a callback to call when progress changed
  72337. * @param errorCallback defines a callback to call on error
  72338. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  72339. */
  72340. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  72341. private _loadFileAsync;
  72342. private _saveFileAsync;
  72343. /**
  72344. * Validates if xhr data is correct
  72345. * @param xhr defines the request to validate
  72346. * @param dataType defines the expected data type
  72347. * @returns true if data is correct
  72348. */
  72349. private static _ValidateXHRData;
  72350. }
  72351. }
  72352. declare module BABYLON {
  72353. /** @hidden */
  72354. export var gpuUpdateParticlesPixelShader: {
  72355. name: string;
  72356. shader: string;
  72357. };
  72358. }
  72359. declare module BABYLON {
  72360. /** @hidden */
  72361. export var gpuUpdateParticlesVertexShader: {
  72362. name: string;
  72363. shader: string;
  72364. };
  72365. }
  72366. declare module BABYLON {
  72367. /** @hidden */
  72368. export var clipPlaneFragmentDeclaration2: {
  72369. name: string;
  72370. shader: string;
  72371. };
  72372. }
  72373. declare module BABYLON {
  72374. /** @hidden */
  72375. export var gpuRenderParticlesPixelShader: {
  72376. name: string;
  72377. shader: string;
  72378. };
  72379. }
  72380. declare module BABYLON {
  72381. /** @hidden */
  72382. export var clipPlaneVertexDeclaration2: {
  72383. name: string;
  72384. shader: string;
  72385. };
  72386. }
  72387. declare module BABYLON {
  72388. /** @hidden */
  72389. export var gpuRenderParticlesVertexShader: {
  72390. name: string;
  72391. shader: string;
  72392. };
  72393. }
  72394. declare module BABYLON {
  72395. /**
  72396. * This represents a GPU particle system in Babylon
  72397. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  72398. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  72399. */
  72400. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  72401. /**
  72402. * The layer mask we are rendering the particles through.
  72403. */
  72404. layerMask: number;
  72405. private _capacity;
  72406. private _activeCount;
  72407. private _currentActiveCount;
  72408. private _accumulatedCount;
  72409. private _renderEffect;
  72410. private _updateEffect;
  72411. private _buffer0;
  72412. private _buffer1;
  72413. private _spriteBuffer;
  72414. private _updateVAO;
  72415. private _renderVAO;
  72416. private _targetIndex;
  72417. private _sourceBuffer;
  72418. private _targetBuffer;
  72419. private _currentRenderId;
  72420. private _started;
  72421. private _stopped;
  72422. private _timeDelta;
  72423. private _randomTexture;
  72424. private _randomTexture2;
  72425. private _attributesStrideSize;
  72426. private _updateEffectOptions;
  72427. private _randomTextureSize;
  72428. private _actualFrame;
  72429. private _customEffect;
  72430. private readonly _rawTextureWidth;
  72431. /**
  72432. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  72433. */
  72434. static get IsSupported(): boolean;
  72435. /**
  72436. * An event triggered when the system is disposed.
  72437. */
  72438. onDisposeObservable: Observable<IParticleSystem>;
  72439. /**
  72440. * An event triggered when the system is stopped
  72441. */
  72442. onStoppedObservable: Observable<IParticleSystem>;
  72443. /**
  72444. * Gets the maximum number of particles active at the same time.
  72445. * @returns The max number of active particles.
  72446. */
  72447. getCapacity(): number;
  72448. /**
  72449. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  72450. * to override the particles.
  72451. */
  72452. forceDepthWrite: boolean;
  72453. /**
  72454. * Gets or set the number of active particles
  72455. */
  72456. get activeParticleCount(): number;
  72457. set activeParticleCount(value: number);
  72458. private _preWarmDone;
  72459. /**
  72460. * Specifies if the particles are updated in emitter local space or world space.
  72461. */
  72462. isLocal: boolean;
  72463. /** Gets or sets a matrix to use to compute projection */
  72464. defaultProjectionMatrix: Matrix;
  72465. /**
  72466. * Is this system ready to be used/rendered
  72467. * @return true if the system is ready
  72468. */
  72469. isReady(): boolean;
  72470. /**
  72471. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72472. * @returns True if it has been started, otherwise false.
  72473. */
  72474. isStarted(): boolean;
  72475. /**
  72476. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  72477. * @returns True if it has been stopped, otherwise false.
  72478. */
  72479. isStopped(): boolean;
  72480. /**
  72481. * Gets a boolean indicating that the system is stopping
  72482. * @returns true if the system is currently stopping
  72483. */
  72484. isStopping(): boolean;
  72485. /**
  72486. * Gets the number of particles active at the same time.
  72487. * @returns The number of active particles.
  72488. */
  72489. getActiveCount(): number;
  72490. /**
  72491. * Starts the particle system and begins to emit
  72492. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72493. */
  72494. start(delay?: number): void;
  72495. /**
  72496. * Stops the particle system.
  72497. */
  72498. stop(): void;
  72499. /**
  72500. * Remove all active particles
  72501. */
  72502. reset(): void;
  72503. /**
  72504. * Returns the string "GPUParticleSystem"
  72505. * @returns a string containing the class name
  72506. */
  72507. getClassName(): string;
  72508. /**
  72509. * Gets the custom effect used to render the particles
  72510. * @param blendMode Blend mode for which the effect should be retrieved
  72511. * @returns The effect
  72512. */
  72513. getCustomEffect(blendMode?: number): Nullable<Effect>;
  72514. /**
  72515. * Sets the custom effect used to render the particles
  72516. * @param effect The effect to set
  72517. * @param blendMode Blend mode for which the effect should be set
  72518. */
  72519. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  72520. /** @hidden */
  72521. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  72522. /**
  72523. * Observable that will be called just before the particles are drawn
  72524. */
  72525. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  72526. /**
  72527. * Gets the name of the particle vertex shader
  72528. */
  72529. get vertexShaderName(): string;
  72530. private _colorGradientsTexture;
  72531. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  72532. /**
  72533. * Adds a new color gradient
  72534. * @param gradient defines the gradient to use (between 0 and 1)
  72535. * @param color1 defines the color to affect to the specified gradient
  72536. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72537. * @returns the current particle system
  72538. */
  72539. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  72540. private _refreshColorGradient;
  72541. /** Force the system to rebuild all gradients that need to be resync */
  72542. forceRefreshGradients(): void;
  72543. /**
  72544. * Remove a specific color gradient
  72545. * @param gradient defines the gradient to remove
  72546. * @returns the current particle system
  72547. */
  72548. removeColorGradient(gradient: number): GPUParticleSystem;
  72549. private _angularSpeedGradientsTexture;
  72550. private _sizeGradientsTexture;
  72551. private _velocityGradientsTexture;
  72552. private _limitVelocityGradientsTexture;
  72553. private _dragGradientsTexture;
  72554. private _addFactorGradient;
  72555. /**
  72556. * Adds a new size gradient
  72557. * @param gradient defines the gradient to use (between 0 and 1)
  72558. * @param factor defines the size factor to affect to the specified gradient
  72559. * @returns the current particle system
  72560. */
  72561. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  72562. /**
  72563. * Remove a specific size gradient
  72564. * @param gradient defines the gradient to remove
  72565. * @returns the current particle system
  72566. */
  72567. removeSizeGradient(gradient: number): GPUParticleSystem;
  72568. private _refreshFactorGradient;
  72569. /**
  72570. * Adds a new angular speed gradient
  72571. * @param gradient defines the gradient to use (between 0 and 1)
  72572. * @param factor defines the angular speed to affect to the specified gradient
  72573. * @returns the current particle system
  72574. */
  72575. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  72576. /**
  72577. * Remove a specific angular speed gradient
  72578. * @param gradient defines the gradient to remove
  72579. * @returns the current particle system
  72580. */
  72581. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  72582. /**
  72583. * Adds a new velocity gradient
  72584. * @param gradient defines the gradient to use (between 0 and 1)
  72585. * @param factor defines the velocity to affect to the specified gradient
  72586. * @returns the current particle system
  72587. */
  72588. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72589. /**
  72590. * Remove a specific velocity gradient
  72591. * @param gradient defines the gradient to remove
  72592. * @returns the current particle system
  72593. */
  72594. removeVelocityGradient(gradient: number): GPUParticleSystem;
  72595. /**
  72596. * Adds a new limit velocity gradient
  72597. * @param gradient defines the gradient to use (between 0 and 1)
  72598. * @param factor defines the limit velocity value to affect to the specified gradient
  72599. * @returns the current particle system
  72600. */
  72601. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72602. /**
  72603. * Remove a specific limit velocity gradient
  72604. * @param gradient defines the gradient to remove
  72605. * @returns the current particle system
  72606. */
  72607. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  72608. /**
  72609. * Adds a new drag gradient
  72610. * @param gradient defines the gradient to use (between 0 and 1)
  72611. * @param factor defines the drag value to affect to the specified gradient
  72612. * @returns the current particle system
  72613. */
  72614. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  72615. /**
  72616. * Remove a specific drag gradient
  72617. * @param gradient defines the gradient to remove
  72618. * @returns the current particle system
  72619. */
  72620. removeDragGradient(gradient: number): GPUParticleSystem;
  72621. /**
  72622. * Not supported by GPUParticleSystem
  72623. * @param gradient defines the gradient to use (between 0 and 1)
  72624. * @param factor defines the emit rate value to affect to the specified gradient
  72625. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72626. * @returns the current particle system
  72627. */
  72628. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72629. /**
  72630. * Not supported by GPUParticleSystem
  72631. * @param gradient defines the gradient to remove
  72632. * @returns the current particle system
  72633. */
  72634. removeEmitRateGradient(gradient: number): IParticleSystem;
  72635. /**
  72636. * Not supported by GPUParticleSystem
  72637. * @param gradient defines the gradient to use (between 0 and 1)
  72638. * @param factor defines the start size value to affect to the specified gradient
  72639. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72640. * @returns the current particle system
  72641. */
  72642. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72643. /**
  72644. * Not supported by GPUParticleSystem
  72645. * @param gradient defines the gradient to remove
  72646. * @returns the current particle system
  72647. */
  72648. removeStartSizeGradient(gradient: number): IParticleSystem;
  72649. /**
  72650. * Not supported by GPUParticleSystem
  72651. * @param gradient defines the gradient to use (between 0 and 1)
  72652. * @param min defines the color remap minimal range
  72653. * @param max defines the color remap maximal range
  72654. * @returns the current particle system
  72655. */
  72656. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72657. /**
  72658. * Not supported by GPUParticleSystem
  72659. * @param gradient defines the gradient to remove
  72660. * @returns the current particle system
  72661. */
  72662. removeColorRemapGradient(): IParticleSystem;
  72663. /**
  72664. * Not supported by GPUParticleSystem
  72665. * @param gradient defines the gradient to use (between 0 and 1)
  72666. * @param min defines the alpha remap minimal range
  72667. * @param max defines the alpha remap maximal range
  72668. * @returns the current particle system
  72669. */
  72670. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72671. /**
  72672. * Not supported by GPUParticleSystem
  72673. * @param gradient defines the gradient to remove
  72674. * @returns the current particle system
  72675. */
  72676. removeAlphaRemapGradient(): IParticleSystem;
  72677. /**
  72678. * Not supported by GPUParticleSystem
  72679. * @param gradient defines the gradient to use (between 0 and 1)
  72680. * @param color defines the color to affect to the specified gradient
  72681. * @returns the current particle system
  72682. */
  72683. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72684. /**
  72685. * Not supported by GPUParticleSystem
  72686. * @param gradient defines the gradient to remove
  72687. * @returns the current particle system
  72688. */
  72689. removeRampGradient(): IParticleSystem;
  72690. /**
  72691. * Not supported by GPUParticleSystem
  72692. * @returns the list of ramp gradients
  72693. */
  72694. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72695. /**
  72696. * Not supported by GPUParticleSystem
  72697. * Gets or sets a boolean indicating that ramp gradients must be used
  72698. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72699. */
  72700. get useRampGradients(): boolean;
  72701. set useRampGradients(value: boolean);
  72702. /**
  72703. * Not supported by GPUParticleSystem
  72704. * @param gradient defines the gradient to use (between 0 and 1)
  72705. * @param factor defines the life time factor to affect to the specified gradient
  72706. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72707. * @returns the current particle system
  72708. */
  72709. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72710. /**
  72711. * Not supported by GPUParticleSystem
  72712. * @param gradient defines the gradient to remove
  72713. * @returns the current particle system
  72714. */
  72715. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72716. /**
  72717. * Instantiates a GPU particle system.
  72718. * 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.
  72719. * @param name The name of the particle system
  72720. * @param options The options used to create the system
  72721. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  72722. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72723. * @param customEffect a custom effect used to change the way particles are rendered by default
  72724. */
  72725. constructor(name: string, options: Partial<{
  72726. capacity: number;
  72727. randomTextureSize: number;
  72728. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  72729. protected _reset(): void;
  72730. private _createUpdateVAO;
  72731. private _createRenderVAO;
  72732. private _initialize;
  72733. /** @hidden */
  72734. _recreateUpdateEffect(): void;
  72735. private _getEffect;
  72736. /**
  72737. * Fill the defines array according to the current settings of the particle system
  72738. * @param defines Array to be updated
  72739. * @param blendMode blend mode to take into account when updating the array
  72740. */
  72741. fillDefines(defines: Array<string>, blendMode?: number): void;
  72742. /**
  72743. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72744. * @param uniforms Uniforms array to fill
  72745. * @param attributes Attributes array to fill
  72746. * @param samplers Samplers array to fill
  72747. */
  72748. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72749. /** @hidden */
  72750. _recreateRenderEffect(): Effect;
  72751. /**
  72752. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72753. * @param preWarm defines if we are in the pre-warmimg phase
  72754. */
  72755. animate(preWarm?: boolean): void;
  72756. private _createFactorGradientTexture;
  72757. private _createSizeGradientTexture;
  72758. private _createAngularSpeedGradientTexture;
  72759. private _createVelocityGradientTexture;
  72760. private _createLimitVelocityGradientTexture;
  72761. private _createDragGradientTexture;
  72762. private _createColorGradientTexture;
  72763. /**
  72764. * Renders the particle system in its current state
  72765. * @param preWarm defines if the system should only update the particles but not render them
  72766. * @returns the current number of particles
  72767. */
  72768. render(preWarm?: boolean): number;
  72769. /**
  72770. * Rebuilds the particle system
  72771. */
  72772. rebuild(): void;
  72773. private _releaseBuffers;
  72774. private _releaseVAOs;
  72775. /**
  72776. * Disposes the particle system and free the associated resources
  72777. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72778. */
  72779. dispose(disposeTexture?: boolean): void;
  72780. /**
  72781. * Clones the particle system.
  72782. * @param name The name of the cloned object
  72783. * @param newEmitter The new emitter to use
  72784. * @returns the cloned particle system
  72785. */
  72786. clone(name: string, newEmitter: any): GPUParticleSystem;
  72787. /**
  72788. * Serializes the particle system to a JSON object
  72789. * @param serializeTexture defines if the texture must be serialized as well
  72790. * @returns the JSON object
  72791. */
  72792. serialize(serializeTexture?: boolean): any;
  72793. /**
  72794. * Parses a JSON object to create a GPU particle system.
  72795. * @param parsedParticleSystem The JSON object to parse
  72796. * @param sceneOrEngine The scene or the engine to create the particle system in
  72797. * @param rootUrl The root url to use to load external dependencies like texture
  72798. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72799. * @returns the parsed GPU particle system
  72800. */
  72801. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  72802. }
  72803. }
  72804. declare module BABYLON {
  72805. /**
  72806. * Represents a set of particle systems working together to create a specific effect
  72807. */
  72808. export class ParticleSystemSet implements IDisposable {
  72809. /**
  72810. * Gets or sets base Assets URL
  72811. */
  72812. static BaseAssetsUrl: string;
  72813. private _emitterCreationOptions;
  72814. private _emitterNode;
  72815. /**
  72816. * Gets the particle system list
  72817. */
  72818. systems: IParticleSystem[];
  72819. /**
  72820. * Gets the emitter node used with this set
  72821. */
  72822. get emitterNode(): Nullable<TransformNode>;
  72823. /**
  72824. * Creates a new emitter mesh as a sphere
  72825. * @param options defines the options used to create the sphere
  72826. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72827. * @param scene defines the hosting scene
  72828. */
  72829. setEmitterAsSphere(options: {
  72830. diameter: number;
  72831. segments: number;
  72832. color: Color3;
  72833. }, renderingGroupId: number, scene: Scene): void;
  72834. /**
  72835. * Starts all particle systems of the set
  72836. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72837. */
  72838. start(emitter?: AbstractMesh): void;
  72839. /**
  72840. * Release all associated resources
  72841. */
  72842. dispose(): void;
  72843. /**
  72844. * Serialize the set into a JSON compatible object
  72845. * @param serializeTexture defines if the texture must be serialized as well
  72846. * @returns a JSON compatible representation of the set
  72847. */
  72848. serialize(serializeTexture?: boolean): any;
  72849. /**
  72850. * Parse a new ParticleSystemSet from a serialized source
  72851. * @param data defines a JSON compatible representation of the set
  72852. * @param scene defines the hosting scene
  72853. * @param gpu defines if we want GPU particles or CPU particles
  72854. * @returns a new ParticleSystemSet
  72855. */
  72856. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72857. }
  72858. }
  72859. declare module BABYLON {
  72860. /**
  72861. * This class is made for on one-liner static method to help creating particle system set.
  72862. */
  72863. export class ParticleHelper {
  72864. /**
  72865. * Gets or sets base Assets URL
  72866. */
  72867. static BaseAssetsUrl: string;
  72868. /** Define the Url to load snippets */
  72869. static SnippetUrl: string;
  72870. /**
  72871. * Create a default particle system that you can tweak
  72872. * @param emitter defines the emitter to use
  72873. * @param capacity defines the system capacity (default is 500 particles)
  72874. * @param scene defines the hosting scene
  72875. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  72876. * @returns the new Particle system
  72877. */
  72878. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  72879. /**
  72880. * This is the main static method (one-liner) of this helper to create different particle systems
  72881. * @param type This string represents the type to the particle system to create
  72882. * @param scene The scene where the particle system should live
  72883. * @param gpu If the system will use gpu
  72884. * @returns the ParticleSystemSet created
  72885. */
  72886. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  72887. /**
  72888. * Static function used to export a particle system to a ParticleSystemSet variable.
  72889. * Please note that the emitter shape is not exported
  72890. * @param systems defines the particle systems to export
  72891. * @returns the created particle system set
  72892. */
  72893. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  72894. /**
  72895. * Creates a particle system from a snippet saved in a remote file
  72896. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  72897. * @param url defines the url to load from
  72898. * @param scene defines the hosting scene
  72899. * @param gpu If the system will use gpu
  72900. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72901. * @returns a promise that will resolve to the new particle system
  72902. */
  72903. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72904. /**
  72905. * Creates a particle system from a snippet saved by the particle system editor
  72906. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  72907. * @param scene defines the hosting scene
  72908. * @param gpu If the system will use gpu
  72909. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72910. * @returns a promise that will resolve to the new particle system
  72911. */
  72912. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72913. }
  72914. }
  72915. declare module BABYLON {
  72916. interface Engine {
  72917. /**
  72918. * Create an effect to use with particle systems.
  72919. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  72920. * the particle system for which you want to create a custom effect in the last parameter
  72921. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  72922. * @param uniformsNames defines a list of attribute names
  72923. * @param samplers defines an array of string used to represent textures
  72924. * @param defines defines the string containing the defines to use to compile the shaders
  72925. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  72926. * @param onCompiled defines a function to call when the effect creation is successful
  72927. * @param onError defines a function to call when the effect creation has failed
  72928. * @param particleSystem the particle system you want to create the effect for
  72929. * @returns the new Effect
  72930. */
  72931. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  72932. }
  72933. interface Mesh {
  72934. /**
  72935. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  72936. * @returns an array of IParticleSystem
  72937. */
  72938. getEmittedParticleSystems(): IParticleSystem[];
  72939. /**
  72940. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  72941. * @returns an array of IParticleSystem
  72942. */
  72943. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  72944. }
  72945. }
  72946. declare module BABYLON {
  72947. /** Defines the 4 color options */
  72948. export enum PointColor {
  72949. /** color value */
  72950. Color = 2,
  72951. /** uv value */
  72952. UV = 1,
  72953. /** random value */
  72954. Random = 0,
  72955. /** stated value */
  72956. Stated = 3
  72957. }
  72958. /**
  72959. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  72960. * 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.
  72961. * The PointCloudSystem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  72962. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  72963. *
  72964. * Full documentation here : TO BE ENTERED
  72965. */
  72966. export class PointsCloudSystem implements IDisposable {
  72967. /**
  72968. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  72969. * Example : var p = SPS.particles[i];
  72970. */
  72971. particles: CloudPoint[];
  72972. /**
  72973. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  72974. */
  72975. nbParticles: number;
  72976. /**
  72977. * This a counter for your own usage. It's not set by any SPS functions.
  72978. */
  72979. counter: number;
  72980. /**
  72981. * The PCS name. This name is also given to the underlying mesh.
  72982. */
  72983. name: string;
  72984. /**
  72985. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are available.
  72986. */
  72987. mesh: Mesh;
  72988. /**
  72989. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  72990. * Please read :
  72991. */
  72992. vars: any;
  72993. /**
  72994. * @hidden
  72995. */
  72996. _size: number;
  72997. private _scene;
  72998. private _promises;
  72999. private _positions;
  73000. private _indices;
  73001. private _normals;
  73002. private _colors;
  73003. private _uvs;
  73004. private _indices32;
  73005. private _positions32;
  73006. private _colors32;
  73007. private _uvs32;
  73008. private _updatable;
  73009. private _isVisibilityBoxLocked;
  73010. private _alwaysVisible;
  73011. private _groups;
  73012. private _groupCounter;
  73013. private _computeParticleColor;
  73014. private _computeParticleTexture;
  73015. private _computeParticleRotation;
  73016. private _computeBoundingBox;
  73017. private _isReady;
  73018. /**
  73019. * Creates a PCS (Points Cloud System) object
  73020. * @param name (String) is the PCS name, this will be the underlying mesh name
  73021. * @param pointSize (number) is the size for each point
  73022. * @param scene (Scene) is the scene in which the PCS is added
  73023. * @param options defines the options of the PCS e.g.
  73024. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  73025. */
  73026. constructor(name: string, pointSize: number, scene: Scene, options?: {
  73027. updatable?: boolean;
  73028. });
  73029. /**
  73030. * Builds the PCS underlying mesh. Returns a standard Mesh.
  73031. * If no points were added to the PCS, the returned mesh is just a single point.
  73032. * @returns a promise for the created mesh
  73033. */
  73034. buildMeshAsync(): Promise<Mesh>;
  73035. /**
  73036. * @hidden
  73037. */
  73038. private _buildMesh;
  73039. private _addParticle;
  73040. private _randomUnitVector;
  73041. private _getColorIndicesForCoord;
  73042. private _setPointsColorOrUV;
  73043. private _colorFromTexture;
  73044. private _calculateDensity;
  73045. /**
  73046. * Adds points to the PCS in random positions within a unit sphere
  73047. * @param nb (positive integer) the number of particles to be created from this model
  73048. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  73049. * @returns the number of groups in the system
  73050. */
  73051. addPoints(nb: number, pointFunction?: any): number;
  73052. /**
  73053. * Adds points to the PCS from the surface of the model shape
  73054. * @param mesh is any Mesh object that will be used as a surface model for the points
  73055. * @param nb (positive integer) the number of particles to be created from this model
  73056. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  73057. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  73058. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  73059. * @returns the number of groups in the system
  73060. */
  73061. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  73062. /**
  73063. * Adds points to the PCS inside the model shape
  73064. * @param mesh is any Mesh object that will be used as a surface model for the points
  73065. * @param nb (positive integer) the number of particles to be created from this model
  73066. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  73067. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  73068. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  73069. * @returns the number of groups in the system
  73070. */
  73071. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  73072. /**
  73073. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  73074. * This method calls `updateParticle()` for each particle of the SPS.
  73075. * For an animated SPS, it is usually called within the render loop.
  73076. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  73077. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  73078. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  73079. * @returns the PCS.
  73080. */
  73081. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  73082. /**
  73083. * Disposes the PCS.
  73084. */
  73085. dispose(): void;
  73086. /**
  73087. * Visibility helper : Recomputes the visible size according to the mesh bounding box
  73088. * doc :
  73089. * @returns the PCS.
  73090. */
  73091. refreshVisibleSize(): PointsCloudSystem;
  73092. /**
  73093. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  73094. * @param size the size (float) of the visibility box
  73095. * note : this doesn't lock the PCS mesh bounding box.
  73096. * doc :
  73097. */
  73098. setVisibilityBox(size: number): void;
  73099. /**
  73100. * Gets whether the PCS is always visible or not
  73101. * doc :
  73102. */
  73103. get isAlwaysVisible(): boolean;
  73104. /**
  73105. * Sets the PCS as always visible or not
  73106. * doc :
  73107. */
  73108. set isAlwaysVisible(val: boolean);
  73109. /**
  73110. * Tells to `setParticles()` to compute the particle rotations or not
  73111. * Default value : false. The PCS is faster when it's set to false
  73112. * Note : particle rotations are only applied to parent particles
  73113. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  73114. */
  73115. set computeParticleRotation(val: boolean);
  73116. /**
  73117. * Tells to `setParticles()` to compute the particle colors or not.
  73118. * Default value : true. The PCS is faster when it's set to false.
  73119. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  73120. */
  73121. set computeParticleColor(val: boolean);
  73122. set computeParticleTexture(val: boolean);
  73123. /**
  73124. * Gets if `setParticles()` computes the particle colors or not.
  73125. * Default value : false. The PCS is faster when it's set to false.
  73126. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  73127. */
  73128. get computeParticleColor(): boolean;
  73129. /**
  73130. * Gets if `setParticles()` computes the particle textures or not.
  73131. * Default value : false. The PCS is faster when it's set to false.
  73132. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  73133. */
  73134. get computeParticleTexture(): boolean;
  73135. /**
  73136. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  73137. */
  73138. set computeBoundingBox(val: boolean);
  73139. /**
  73140. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  73141. */
  73142. get computeBoundingBox(): boolean;
  73143. /**
  73144. * This function does nothing. It may be overwritten to set all the particle first values.
  73145. * The PCS doesn't call this function, you may have to call it by your own.
  73146. * doc :
  73147. */
  73148. initParticles(): void;
  73149. /**
  73150. * This function does nothing. It may be overwritten to recycle a particle
  73151. * The PCS doesn't call this function, you can to call it
  73152. * doc :
  73153. * @param particle The particle to recycle
  73154. * @returns the recycled particle
  73155. */
  73156. recycleParticle(particle: CloudPoint): CloudPoint;
  73157. /**
  73158. * Updates a particle : this function should be overwritten by the user.
  73159. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  73160. * doc :
  73161. * @example : just set a particle position or velocity and recycle conditions
  73162. * @param particle The particle to update
  73163. * @returns the updated particle
  73164. */
  73165. updateParticle(particle: CloudPoint): CloudPoint;
  73166. /**
  73167. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  73168. * This does nothing and may be overwritten by the user.
  73169. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  73170. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  73171. * @param update the boolean update value actually passed to setParticles()
  73172. */
  73173. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  73174. /**
  73175. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  73176. * This will be passed three parameters.
  73177. * This does nothing and may be overwritten by the user.
  73178. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  73179. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  73180. * @param update the boolean update value actually passed to setParticles()
  73181. */
  73182. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  73183. }
  73184. }
  73185. declare module BABYLON {
  73186. /**
  73187. * Represents one particle of a points cloud system.
  73188. */
  73189. export class CloudPoint {
  73190. /**
  73191. * particle global index
  73192. */
  73193. idx: number;
  73194. /**
  73195. * The color of the particle
  73196. */
  73197. color: Nullable<Color4>;
  73198. /**
  73199. * The world space position of the particle.
  73200. */
  73201. position: Vector3;
  73202. /**
  73203. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  73204. */
  73205. rotation: Vector3;
  73206. /**
  73207. * The world space rotation quaternion of the particle.
  73208. */
  73209. rotationQuaternion: Nullable<Quaternion>;
  73210. /**
  73211. * The uv of the particle.
  73212. */
  73213. uv: Nullable<Vector2>;
  73214. /**
  73215. * The current speed of the particle.
  73216. */
  73217. velocity: Vector3;
  73218. /**
  73219. * The pivot point in the particle local space.
  73220. */
  73221. pivot: Vector3;
  73222. /**
  73223. * Must the particle be translated from its pivot point in its local space ?
  73224. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  73225. * Default : false
  73226. */
  73227. translateFromPivot: boolean;
  73228. /**
  73229. * Index of this particle in the global "positions" array (Internal use)
  73230. * @hidden
  73231. */
  73232. _pos: number;
  73233. /**
  73234. * @hidden Index of this particle in the global "indices" array (Internal use)
  73235. */
  73236. _ind: number;
  73237. /**
  73238. * Group this particle belongs to
  73239. */
  73240. _group: PointsGroup;
  73241. /**
  73242. * Group id of this particle
  73243. */
  73244. groupId: number;
  73245. /**
  73246. * Index of the particle in its group id (Internal use)
  73247. */
  73248. idxInGroup: number;
  73249. /**
  73250. * @hidden Particle BoundingInfo object (Internal use)
  73251. */
  73252. _boundingInfo: BoundingInfo;
  73253. /**
  73254. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  73255. */
  73256. _pcs: PointsCloudSystem;
  73257. /**
  73258. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  73259. */
  73260. _stillInvisible: boolean;
  73261. /**
  73262. * @hidden Last computed particle rotation matrix
  73263. */
  73264. _rotationMatrix: number[];
  73265. /**
  73266. * Parent particle Id, if any.
  73267. * Default null.
  73268. */
  73269. parentId: Nullable<number>;
  73270. /**
  73271. * @hidden Internal global position in the PCS.
  73272. */
  73273. _globalPosition: Vector3;
  73274. /**
  73275. * Creates a Point Cloud object.
  73276. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  73277. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  73278. * @param group (PointsGroup) is the group the particle belongs to
  73279. * @param groupId (integer) is the group identifier in the PCS.
  73280. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  73281. * @param pcs defines the PCS it is associated to
  73282. */
  73283. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  73284. /**
  73285. * get point size
  73286. */
  73287. get size(): Vector3;
  73288. /**
  73289. * Set point size
  73290. */
  73291. set size(scale: Vector3);
  73292. /**
  73293. * Legacy support, changed quaternion to rotationQuaternion
  73294. */
  73295. get quaternion(): Nullable<Quaternion>;
  73296. /**
  73297. * Legacy support, changed quaternion to rotationQuaternion
  73298. */
  73299. set quaternion(q: Nullable<Quaternion>);
  73300. /**
  73301. * Returns a boolean. True if the particle intersects a mesh, else false
  73302. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  73303. * @param target is the object (point or mesh) what the intersection is computed against
  73304. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bounding sphere is used
  73305. * @returns true if it intersects
  73306. */
  73307. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  73308. /**
  73309. * get the rotation matrix of the particle
  73310. * @hidden
  73311. */
  73312. getRotationMatrix(m: Matrix): void;
  73313. }
  73314. /**
  73315. * Represents a group of points in a points cloud system
  73316. * * PCS internal tool, don't use it manually.
  73317. */
  73318. export class PointsGroup {
  73319. /**
  73320. * The group id
  73321. * @hidden
  73322. */
  73323. groupID: number;
  73324. /**
  73325. * image data for group (internal use)
  73326. * @hidden
  73327. */
  73328. _groupImageData: Nullable<ArrayBufferView>;
  73329. /**
  73330. * Image Width (internal use)
  73331. * @hidden
  73332. */
  73333. _groupImgWidth: number;
  73334. /**
  73335. * Image Height (internal use)
  73336. * @hidden
  73337. */
  73338. _groupImgHeight: number;
  73339. /**
  73340. * Custom position function (internal use)
  73341. * @hidden
  73342. */
  73343. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  73344. /**
  73345. * density per facet for surface points
  73346. * @hidden
  73347. */
  73348. _groupDensity: number[];
  73349. /**
  73350. * Only when points are colored by texture carries pointer to texture list array
  73351. * @hidden
  73352. */
  73353. _textureNb: number;
  73354. /**
  73355. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  73356. * PCS internal tool, don't use it manually.
  73357. * @hidden
  73358. */
  73359. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  73360. }
  73361. }
  73362. declare module BABYLON {
  73363. interface Scene {
  73364. /** @hidden (Backing field) */
  73365. _physicsEngine: Nullable<IPhysicsEngine>;
  73366. /** @hidden */
  73367. _physicsTimeAccumulator: number;
  73368. /**
  73369. * Gets the current physics engine
  73370. * @returns a IPhysicsEngine or null if none attached
  73371. */
  73372. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  73373. /**
  73374. * Enables physics to the current scene
  73375. * @param gravity defines the scene's gravity for the physics engine
  73376. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  73377. * @return a boolean indicating if the physics engine was initialized
  73378. */
  73379. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  73380. /**
  73381. * Disables and disposes the physics engine associated with the scene
  73382. */
  73383. disablePhysicsEngine(): void;
  73384. /**
  73385. * Gets a boolean indicating if there is an active physics engine
  73386. * @returns a boolean indicating if there is an active physics engine
  73387. */
  73388. isPhysicsEnabled(): boolean;
  73389. /**
  73390. * Deletes a physics compound impostor
  73391. * @param compound defines the compound to delete
  73392. */
  73393. deleteCompoundImpostor(compound: any): void;
  73394. /**
  73395. * An event triggered when physic simulation is about to be run
  73396. */
  73397. onBeforePhysicsObservable: Observable<Scene>;
  73398. /**
  73399. * An event triggered when physic simulation has been done
  73400. */
  73401. onAfterPhysicsObservable: Observable<Scene>;
  73402. }
  73403. interface AbstractMesh {
  73404. /** @hidden */
  73405. _physicsImpostor: Nullable<PhysicsImpostor>;
  73406. /**
  73407. * Gets or sets impostor used for physic simulation
  73408. * @see https://doc.babylonjs.com/features/physics_engine
  73409. */
  73410. physicsImpostor: Nullable<PhysicsImpostor>;
  73411. /**
  73412. * Gets the current physics impostor
  73413. * @see https://doc.babylonjs.com/features/physics_engine
  73414. * @returns a physics impostor or null
  73415. */
  73416. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  73417. /** Apply a physic impulse to the mesh
  73418. * @param force defines the force to apply
  73419. * @param contactPoint defines where to apply the force
  73420. * @returns the current mesh
  73421. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73422. */
  73423. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  73424. /**
  73425. * Creates a physic joint between two meshes
  73426. * @param otherMesh defines the other mesh to use
  73427. * @param pivot1 defines the pivot to use on this mesh
  73428. * @param pivot2 defines the pivot to use on the other mesh
  73429. * @param options defines additional options (can be plugin dependent)
  73430. * @returns the current mesh
  73431. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  73432. */
  73433. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  73434. /** @hidden */
  73435. _disposePhysicsObserver: Nullable<Observer<Node>>;
  73436. }
  73437. /**
  73438. * Defines the physics engine scene component responsible to manage a physics engine
  73439. */
  73440. export class PhysicsEngineSceneComponent implements ISceneComponent {
  73441. /**
  73442. * The component name helpful to identify the component in the list of scene components.
  73443. */
  73444. readonly name: string;
  73445. /**
  73446. * The scene the component belongs to.
  73447. */
  73448. scene: Scene;
  73449. /**
  73450. * Creates a new instance of the component for the given scene
  73451. * @param scene Defines the scene to register the component in
  73452. */
  73453. constructor(scene: Scene);
  73454. /**
  73455. * Registers the component in a given scene
  73456. */
  73457. register(): void;
  73458. /**
  73459. * Rebuilds the elements related to this component in case of
  73460. * context lost for instance.
  73461. */
  73462. rebuild(): void;
  73463. /**
  73464. * Disposes the component and the associated resources
  73465. */
  73466. dispose(): void;
  73467. }
  73468. }
  73469. declare module BABYLON {
  73470. /**
  73471. * A helper for physics simulations
  73472. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73473. */
  73474. export class PhysicsHelper {
  73475. private _scene;
  73476. private _physicsEngine;
  73477. /**
  73478. * Initializes the Physics helper
  73479. * @param scene Babylon.js scene
  73480. */
  73481. constructor(scene: Scene);
  73482. /**
  73483. * Applies a radial explosion impulse
  73484. * @param origin the origin of the explosion
  73485. * @param radiusOrEventOptions the radius or the options of radial explosion
  73486. * @param strength the explosion strength
  73487. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73488. * @returns A physics radial explosion event, or null
  73489. */
  73490. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73491. /**
  73492. * Applies a radial explosion force
  73493. * @param origin the origin of the explosion
  73494. * @param radiusOrEventOptions the radius or the options of radial explosion
  73495. * @param strength the explosion strength
  73496. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73497. * @returns A physics radial explosion event, or null
  73498. */
  73499. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73500. /**
  73501. * Creates a gravitational field
  73502. * @param origin the origin of the explosion
  73503. * @param radiusOrEventOptions the radius or the options of radial explosion
  73504. * @param strength the explosion strength
  73505. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73506. * @returns A physics gravitational field event, or null
  73507. */
  73508. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  73509. /**
  73510. * Creates a physics updraft event
  73511. * @param origin the origin of the updraft
  73512. * @param radiusOrEventOptions the radius or the options of the updraft
  73513. * @param strength the strength of the updraft
  73514. * @param height the height of the updraft
  73515. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  73516. * @returns A physics updraft event, or null
  73517. */
  73518. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  73519. /**
  73520. * Creates a physics vortex event
  73521. * @param origin the of the vortex
  73522. * @param radiusOrEventOptions the radius or the options of the vortex
  73523. * @param strength the strength of the vortex
  73524. * @param height the height of the vortex
  73525. * @returns a Physics vortex event, or null
  73526. * A physics vortex event or null
  73527. */
  73528. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  73529. }
  73530. /**
  73531. * Represents a physics radial explosion event
  73532. */
  73533. class PhysicsRadialExplosionEvent {
  73534. private _scene;
  73535. private _options;
  73536. private _sphere;
  73537. private _dataFetched;
  73538. /**
  73539. * Initializes a radial explosion event
  73540. * @param _scene BabylonJS scene
  73541. * @param _options The options for the vortex event
  73542. */
  73543. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  73544. /**
  73545. * Returns the data related to the radial explosion event (sphere).
  73546. * @returns The radial explosion event data
  73547. */
  73548. getData(): PhysicsRadialExplosionEventData;
  73549. /**
  73550. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  73551. * @param impostor A physics imposter
  73552. * @param origin the origin of the explosion
  73553. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  73554. */
  73555. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  73556. /**
  73557. * Triggers affected impostors callbacks
  73558. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  73559. */
  73560. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  73561. /**
  73562. * Disposes the sphere.
  73563. * @param force Specifies if the sphere should be disposed by force
  73564. */
  73565. dispose(force?: boolean): void;
  73566. /*** Helpers ***/
  73567. private _prepareSphere;
  73568. private _intersectsWithSphere;
  73569. }
  73570. /**
  73571. * Represents a gravitational field event
  73572. */
  73573. class PhysicsGravitationalFieldEvent {
  73574. private _physicsHelper;
  73575. private _scene;
  73576. private _origin;
  73577. private _options;
  73578. private _tickCallback;
  73579. private _sphere;
  73580. private _dataFetched;
  73581. /**
  73582. * Initializes the physics gravitational field event
  73583. * @param _physicsHelper A physics helper
  73584. * @param _scene BabylonJS scene
  73585. * @param _origin The origin position of the gravitational field event
  73586. * @param _options The options for the vortex event
  73587. */
  73588. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  73589. /**
  73590. * Returns the data related to the gravitational field event (sphere).
  73591. * @returns A gravitational field event
  73592. */
  73593. getData(): PhysicsGravitationalFieldEventData;
  73594. /**
  73595. * Enables the gravitational field.
  73596. */
  73597. enable(): void;
  73598. /**
  73599. * Disables the gravitational field.
  73600. */
  73601. disable(): void;
  73602. /**
  73603. * Disposes the sphere.
  73604. * @param force The force to dispose from the gravitational field event
  73605. */
  73606. dispose(force?: boolean): void;
  73607. private _tick;
  73608. }
  73609. /**
  73610. * Represents a physics updraft event
  73611. */
  73612. class PhysicsUpdraftEvent {
  73613. private _scene;
  73614. private _origin;
  73615. private _options;
  73616. private _physicsEngine;
  73617. private _originTop;
  73618. private _originDirection;
  73619. private _tickCallback;
  73620. private _cylinder;
  73621. private _cylinderPosition;
  73622. private _dataFetched;
  73623. /**
  73624. * Initializes the physics updraft event
  73625. * @param _scene BabylonJS scene
  73626. * @param _origin The origin position of the updraft
  73627. * @param _options The options for the updraft event
  73628. */
  73629. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  73630. /**
  73631. * Returns the data related to the updraft event (cylinder).
  73632. * @returns A physics updraft event
  73633. */
  73634. getData(): PhysicsUpdraftEventData;
  73635. /**
  73636. * Enables the updraft.
  73637. */
  73638. enable(): void;
  73639. /**
  73640. * Disables the updraft.
  73641. */
  73642. disable(): void;
  73643. /**
  73644. * Disposes the cylinder.
  73645. * @param force Specifies if the updraft should be disposed by force
  73646. */
  73647. dispose(force?: boolean): void;
  73648. private getImpostorHitData;
  73649. private _tick;
  73650. /*** Helpers ***/
  73651. private _prepareCylinder;
  73652. private _intersectsWithCylinder;
  73653. }
  73654. /**
  73655. * Represents a physics vortex event
  73656. */
  73657. class PhysicsVortexEvent {
  73658. private _scene;
  73659. private _origin;
  73660. private _options;
  73661. private _physicsEngine;
  73662. private _originTop;
  73663. private _tickCallback;
  73664. private _cylinder;
  73665. private _cylinderPosition;
  73666. private _dataFetched;
  73667. /**
  73668. * Initializes the physics vortex event
  73669. * @param _scene The BabylonJS scene
  73670. * @param _origin The origin position of the vortex
  73671. * @param _options The options for the vortex event
  73672. */
  73673. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  73674. /**
  73675. * Returns the data related to the vortex event (cylinder).
  73676. * @returns The physics vortex event data
  73677. */
  73678. getData(): PhysicsVortexEventData;
  73679. /**
  73680. * Enables the vortex.
  73681. */
  73682. enable(): void;
  73683. /**
  73684. * Disables the cortex.
  73685. */
  73686. disable(): void;
  73687. /**
  73688. * Disposes the sphere.
  73689. * @param force
  73690. */
  73691. dispose(force?: boolean): void;
  73692. private getImpostorHitData;
  73693. private _tick;
  73694. /*** Helpers ***/
  73695. private _prepareCylinder;
  73696. private _intersectsWithCylinder;
  73697. }
  73698. /**
  73699. * Options fot the radial explosion event
  73700. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73701. */
  73702. export class PhysicsRadialExplosionEventOptions {
  73703. /**
  73704. * The radius of the sphere for the radial explosion.
  73705. */
  73706. radius: number;
  73707. /**
  73708. * The strength of the explosion.
  73709. */
  73710. strength: number;
  73711. /**
  73712. * The strength of the force in correspondence to the distance of the affected object
  73713. */
  73714. falloff: PhysicsRadialImpulseFalloff;
  73715. /**
  73716. * Sphere options for the radial explosion.
  73717. */
  73718. sphere: {
  73719. segments: number;
  73720. diameter: number;
  73721. };
  73722. /**
  73723. * Sphere options for the radial explosion.
  73724. */
  73725. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  73726. }
  73727. /**
  73728. * Options fot the updraft event
  73729. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73730. */
  73731. export class PhysicsUpdraftEventOptions {
  73732. /**
  73733. * The radius of the cylinder for the vortex
  73734. */
  73735. radius: number;
  73736. /**
  73737. * The strength of the updraft.
  73738. */
  73739. strength: number;
  73740. /**
  73741. * The height of the cylinder for the updraft.
  73742. */
  73743. height: number;
  73744. /**
  73745. * The mode for the the updraft.
  73746. */
  73747. updraftMode: PhysicsUpdraftMode;
  73748. }
  73749. /**
  73750. * Options fot the vortex event
  73751. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73752. */
  73753. export class PhysicsVortexEventOptions {
  73754. /**
  73755. * The radius of the cylinder for the vortex
  73756. */
  73757. radius: number;
  73758. /**
  73759. * The strength of the vortex.
  73760. */
  73761. strength: number;
  73762. /**
  73763. * The height of the cylinder for the vortex.
  73764. */
  73765. height: number;
  73766. /**
  73767. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  73768. */
  73769. centripetalForceThreshold: number;
  73770. /**
  73771. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the threshold.
  73772. */
  73773. centripetalForceMultiplier: number;
  73774. /**
  73775. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the threshold.
  73776. */
  73777. centrifugalForceMultiplier: number;
  73778. /**
  73779. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  73780. */
  73781. updraftForceMultiplier: number;
  73782. }
  73783. /**
  73784. * The strength of the force in correspondence to the distance of the affected object
  73785. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73786. */
  73787. export enum PhysicsRadialImpulseFalloff {
  73788. /** Defines that impulse is constant in strength across it's whole radius */
  73789. Constant = 0,
  73790. /** Defines that impulse gets weaker if it's further from the origin */
  73791. Linear = 1
  73792. }
  73793. /**
  73794. * The strength of the force in correspondence to the distance of the affected object
  73795. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73796. */
  73797. export enum PhysicsUpdraftMode {
  73798. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  73799. Center = 0,
  73800. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  73801. Perpendicular = 1
  73802. }
  73803. /**
  73804. * Interface for a physics hit data
  73805. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73806. */
  73807. export interface PhysicsHitData {
  73808. /**
  73809. * The force applied at the contact point
  73810. */
  73811. force: Vector3;
  73812. /**
  73813. * The contact point
  73814. */
  73815. contactPoint: Vector3;
  73816. /**
  73817. * The distance from the origin to the contact point
  73818. */
  73819. distanceFromOrigin: number;
  73820. }
  73821. /**
  73822. * Interface for radial explosion event data
  73823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73824. */
  73825. export interface PhysicsRadialExplosionEventData {
  73826. /**
  73827. * A sphere used for the radial explosion event
  73828. */
  73829. sphere: Mesh;
  73830. }
  73831. /**
  73832. * Interface for gravitational field event data
  73833. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73834. */
  73835. export interface PhysicsGravitationalFieldEventData {
  73836. /**
  73837. * A sphere mesh used for the gravitational field event
  73838. */
  73839. sphere: Mesh;
  73840. }
  73841. /**
  73842. * Interface for updraft event data
  73843. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73844. */
  73845. export interface PhysicsUpdraftEventData {
  73846. /**
  73847. * A cylinder used for the updraft event
  73848. */
  73849. cylinder: Mesh;
  73850. }
  73851. /**
  73852. * Interface for vortex event data
  73853. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73854. */
  73855. export interface PhysicsVortexEventData {
  73856. /**
  73857. * A cylinder used for the vortex event
  73858. */
  73859. cylinder: Mesh;
  73860. }
  73861. /**
  73862. * Interface for an affected physics impostor
  73863. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73864. */
  73865. export interface PhysicsAffectedImpostorWithData {
  73866. /**
  73867. * The impostor affected by the effect
  73868. */
  73869. impostor: PhysicsImpostor;
  73870. /**
  73871. * The data about the hit/force from the explosion
  73872. */
  73873. hitData: PhysicsHitData;
  73874. }
  73875. }
  73876. declare module BABYLON {
  73877. /** @hidden */
  73878. export var blackAndWhitePixelShader: {
  73879. name: string;
  73880. shader: string;
  73881. };
  73882. }
  73883. declare module BABYLON {
  73884. /**
  73885. * Post process used to render in black and white
  73886. */
  73887. export class BlackAndWhitePostProcess extends PostProcess {
  73888. /**
  73889. * Linear about to convert he result to black and white (default: 1)
  73890. */
  73891. degree: number;
  73892. /**
  73893. * Gets a string identifying the name of the class
  73894. * @returns "BlackAndWhitePostProcess" string
  73895. */
  73896. getClassName(): string;
  73897. /**
  73898. * Creates a black and white post process
  73899. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  73900. * @param name The name of the effect.
  73901. * @param options The required width/height ratio to downsize to before computing the render pass.
  73902. * @param camera The camera to apply the render pass to.
  73903. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73904. * @param engine The engine which the post process will be applied. (default: current engine)
  73905. * @param reusable If the post process can be reused on the same frame. (default: false)
  73906. */
  73907. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73908. /** @hidden */
  73909. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  73910. }
  73911. }
  73912. declare module BABYLON {
  73913. /**
  73914. * This represents a set of one or more post processes in Babylon.
  73915. * A post process can be used to apply a shader to a texture after it is rendered.
  73916. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73917. */
  73918. export class PostProcessRenderEffect {
  73919. private _postProcesses;
  73920. private _getPostProcesses;
  73921. private _singleInstance;
  73922. private _cameras;
  73923. private _indicesForCamera;
  73924. /**
  73925. * Name of the effect
  73926. * @hidden
  73927. */
  73928. _name: string;
  73929. /**
  73930. * Instantiates a post process render effect.
  73931. * A post process can be used to apply a shader to a texture after it is rendered.
  73932. * @param engine The engine the effect is tied to
  73933. * @param name The name of the effect
  73934. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  73935. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  73936. */
  73937. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  73938. /**
  73939. * Checks if all the post processes in the effect are supported.
  73940. */
  73941. get isSupported(): boolean;
  73942. /**
  73943. * Updates the current state of the effect
  73944. * @hidden
  73945. */
  73946. _update(): void;
  73947. /**
  73948. * Attaches the effect on cameras
  73949. * @param cameras The camera to attach to.
  73950. * @hidden
  73951. */
  73952. _attachCameras(cameras: Camera): void;
  73953. /**
  73954. * Attaches the effect on cameras
  73955. * @param cameras The camera to attach to.
  73956. * @hidden
  73957. */
  73958. _attachCameras(cameras: Camera[]): void;
  73959. /**
  73960. * Detaches the effect on cameras
  73961. * @param cameras The camera to detach from.
  73962. * @hidden
  73963. */
  73964. _detachCameras(cameras: Camera): void;
  73965. /**
  73966. * Detaches the effect on cameras
  73967. * @param cameras The camera to detach from.
  73968. * @hidden
  73969. */
  73970. _detachCameras(cameras: Camera[]): void;
  73971. /**
  73972. * Enables the effect on given cameras
  73973. * @param cameras The camera to enable.
  73974. * @hidden
  73975. */
  73976. _enable(cameras: Camera): void;
  73977. /**
  73978. * Enables the effect on given cameras
  73979. * @param cameras The camera to enable.
  73980. * @hidden
  73981. */
  73982. _enable(cameras: Nullable<Camera[]>): void;
  73983. /**
  73984. * Disables the effect on the given cameras
  73985. * @param cameras The camera to disable.
  73986. * @hidden
  73987. */
  73988. _disable(cameras: Camera): void;
  73989. /**
  73990. * Disables the effect on the given cameras
  73991. * @param cameras The camera to disable.
  73992. * @hidden
  73993. */
  73994. _disable(cameras: Nullable<Camera[]>): void;
  73995. /**
  73996. * Gets a list of the post processes contained in the effect.
  73997. * @param camera The camera to get the post processes on.
  73998. * @returns The list of the post processes in the effect.
  73999. */
  74000. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  74001. }
  74002. }
  74003. declare module BABYLON {
  74004. /** @hidden */
  74005. export var extractHighlightsPixelShader: {
  74006. name: string;
  74007. shader: string;
  74008. };
  74009. }
  74010. declare module BABYLON {
  74011. /**
  74012. * 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.
  74013. */
  74014. export class ExtractHighlightsPostProcess extends PostProcess {
  74015. /**
  74016. * The luminance threshold, pixels below this value will be set to black.
  74017. */
  74018. threshold: number;
  74019. /** @hidden */
  74020. _exposure: number;
  74021. /**
  74022. * Post process which has the input texture to be used when performing highlight extraction
  74023. * @hidden
  74024. */
  74025. _inputPostProcess: Nullable<PostProcess>;
  74026. /**
  74027. * Gets a string identifying the name of the class
  74028. * @returns "ExtractHighlightsPostProcess" string
  74029. */
  74030. getClassName(): string;
  74031. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74032. }
  74033. }
  74034. declare module BABYLON {
  74035. /** @hidden */
  74036. export var bloomMergePixelShader: {
  74037. name: string;
  74038. shader: string;
  74039. };
  74040. }
  74041. declare module BABYLON {
  74042. /**
  74043. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74044. */
  74045. export class BloomMergePostProcess extends PostProcess {
  74046. /** Weight of the bloom to be added to the original input. */
  74047. weight: number;
  74048. /**
  74049. * Gets a string identifying the name of the class
  74050. * @returns "BloomMergePostProcess" string
  74051. */
  74052. getClassName(): string;
  74053. /**
  74054. * Creates a new instance of @see BloomMergePostProcess
  74055. * @param name The name of the effect.
  74056. * @param originalFromInput Post process which's input will be used for the merge.
  74057. * @param blurred Blurred highlights post process which's output will be used.
  74058. * @param weight Weight of the bloom to be added to the original input.
  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, originalFromInput: PostProcess, blurred: PostProcess,
  74068. /** Weight of the bloom to be added to the original input. */
  74069. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74070. }
  74071. }
  74072. declare module BABYLON {
  74073. /**
  74074. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  74075. */
  74076. export class BloomEffect extends PostProcessRenderEffect {
  74077. private bloomScale;
  74078. /**
  74079. * @hidden Internal
  74080. */
  74081. _effects: Array<PostProcess>;
  74082. /**
  74083. * @hidden Internal
  74084. */
  74085. _downscale: ExtractHighlightsPostProcess;
  74086. private _blurX;
  74087. private _blurY;
  74088. private _merge;
  74089. /**
  74090. * The luminance threshold to find bright areas of the image to bloom.
  74091. */
  74092. get threshold(): number;
  74093. set threshold(value: number);
  74094. /**
  74095. * The strength of the bloom.
  74096. */
  74097. get weight(): number;
  74098. set weight(value: number);
  74099. /**
  74100. * Specifies the size of the bloom blur kernel, relative to the final output size
  74101. */
  74102. get kernel(): number;
  74103. set kernel(value: number);
  74104. /**
  74105. * Creates a new instance of @see BloomEffect
  74106. * @param scene The scene the effect belongs to.
  74107. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  74108. * @param bloomKernel The size of the kernel to be used when applying the blur.
  74109. * @param bloomWeight The the strength of bloom.
  74110. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74111. * @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)
  74112. */
  74113. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  74114. /**
  74115. * Disposes each of the internal effects for a given camera.
  74116. * @param camera The camera to dispose the effect on.
  74117. */
  74118. disposeEffects(camera: Camera): void;
  74119. /**
  74120. * @hidden Internal
  74121. */
  74122. _updateEffects(): void;
  74123. /**
  74124. * Internal
  74125. * @returns if all the contained post processes are ready.
  74126. * @hidden
  74127. */
  74128. _isReady(): boolean;
  74129. }
  74130. }
  74131. declare module BABYLON {
  74132. /** @hidden */
  74133. export var chromaticAberrationPixelShader: {
  74134. name: string;
  74135. shader: string;
  74136. };
  74137. }
  74138. declare module BABYLON {
  74139. /**
  74140. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  74141. */
  74142. export class ChromaticAberrationPostProcess extends PostProcess {
  74143. /**
  74144. * The amount of separation of rgb channels (default: 30)
  74145. */
  74146. aberrationAmount: number;
  74147. /**
  74148. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  74149. */
  74150. radialIntensity: number;
  74151. /**
  74152. * 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))
  74153. */
  74154. direction: Vector2;
  74155. /**
  74156. * 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))
  74157. */
  74158. centerPosition: Vector2;
  74159. /** The width of the screen to apply the effect on */
  74160. screenWidth: number;
  74161. /** The height of the screen to apply the effect on */
  74162. screenHeight: number;
  74163. /**
  74164. * Gets a string identifying the name of the class
  74165. * @returns "ChromaticAberrationPostProcess" string
  74166. */
  74167. getClassName(): string;
  74168. /**
  74169. * Creates a new instance ChromaticAberrationPostProcess
  74170. * @param name The name of the effect.
  74171. * @param screenWidth The width of the screen to apply the effect on.
  74172. * @param screenHeight The height of the screen to apply the effect on.
  74173. * @param options The required width/height ratio to downsize to before computing the render pass.
  74174. * @param camera The camera to apply the render pass to.
  74175. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74176. * @param engine The engine which the post process will be applied. (default: current engine)
  74177. * @param reusable If the post process can be reused on the same frame. (default: false)
  74178. * @param textureType Type of textures used when performing the post process. (default: 0)
  74179. * @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)
  74180. */
  74181. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74182. /** @hidden */
  74183. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  74184. }
  74185. }
  74186. declare module BABYLON {
  74187. /** @hidden */
  74188. export var circleOfConfusionPixelShader: {
  74189. name: string;
  74190. shader: string;
  74191. };
  74192. }
  74193. declare module BABYLON {
  74194. /**
  74195. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  74196. */
  74197. export class CircleOfConfusionPostProcess extends PostProcess {
  74198. /**
  74199. * 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.
  74200. */
  74201. lensSize: number;
  74202. /**
  74203. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74204. */
  74205. fStop: number;
  74206. /**
  74207. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74208. */
  74209. focusDistance: number;
  74210. /**
  74211. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  74212. */
  74213. focalLength: number;
  74214. /**
  74215. * Gets a string identifying the name of the class
  74216. * @returns "CircleOfConfusionPostProcess" string
  74217. */
  74218. getClassName(): string;
  74219. private _depthTexture;
  74220. /**
  74221. * Creates a new instance CircleOfConfusionPostProcess
  74222. * @param name The name of the effect.
  74223. * @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.
  74224. * @param options The required width/height ratio to downsize to before computing the render pass.
  74225. * @param camera The camera to apply the render pass to.
  74226. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74227. * @param engine The engine which the post process will be applied. (default: current engine)
  74228. * @param reusable If the post process can be reused on the same frame. (default: false)
  74229. * @param textureType Type of textures used when performing the post process. (default: 0)
  74230. * @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)
  74231. */
  74232. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74233. /**
  74234. * 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.
  74235. */
  74236. set depthTexture(value: RenderTargetTexture);
  74237. }
  74238. }
  74239. declare module BABYLON {
  74240. /** @hidden */
  74241. export var colorCorrectionPixelShader: {
  74242. name: string;
  74243. shader: string;
  74244. };
  74245. }
  74246. declare module BABYLON {
  74247. /**
  74248. *
  74249. * This post-process allows the modification of rendered colors by using
  74250. * a 'look-up table' (LUT). This effect is also called Color Grading.
  74251. *
  74252. * The object needs to be provided an url to a texture containing the color
  74253. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  74254. * Use an image editing software to tweak the LUT to match your needs.
  74255. *
  74256. * For an example of a color LUT, see here:
  74257. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  74258. * For explanations on color grading, see here:
  74259. * @see http://udn.epicgames.com/Three/ColorGrading.html
  74260. *
  74261. */
  74262. export class ColorCorrectionPostProcess extends PostProcess {
  74263. private _colorTableTexture;
  74264. /**
  74265. * Gets the color table url used to create the LUT texture
  74266. */
  74267. colorTableUrl: string;
  74268. /**
  74269. * Gets a string identifying the name of the class
  74270. * @returns "ColorCorrectionPostProcess" string
  74271. */
  74272. getClassName(): string;
  74273. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74274. /** @hidden */
  74275. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  74276. }
  74277. }
  74278. declare module BABYLON {
  74279. /** @hidden */
  74280. export var convolutionPixelShader: {
  74281. name: string;
  74282. shader: string;
  74283. };
  74284. }
  74285. declare module BABYLON {
  74286. /**
  74287. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  74288. * input texture to perform effects such as edge detection or sharpening
  74289. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74290. */
  74291. export class ConvolutionPostProcess extends PostProcess {
  74292. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  74293. kernel: number[];
  74294. /**
  74295. * Gets a string identifying the name of the class
  74296. * @returns "ConvolutionPostProcess" string
  74297. */
  74298. getClassName(): string;
  74299. /**
  74300. * Creates a new instance ConvolutionPostProcess
  74301. * @param name The name of the effect.
  74302. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  74303. * @param options The required width/height ratio to downsize to before computing the render pass.
  74304. * @param camera The camera to apply the render pass to.
  74305. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74306. * @param engine The engine which the post process will be applied. (default: current engine)
  74307. * @param reusable If the post process can be reused on the same frame. (default: false)
  74308. * @param textureType Type of textures used when performing the post process. (default: 0)
  74309. */
  74310. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74311. /** @hidden */
  74312. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  74313. /**
  74314. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74315. */
  74316. static EdgeDetect0Kernel: number[];
  74317. /**
  74318. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74319. */
  74320. static EdgeDetect1Kernel: number[];
  74321. /**
  74322. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74323. */
  74324. static EdgeDetect2Kernel: number[];
  74325. /**
  74326. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74327. */
  74328. static SharpenKernel: number[];
  74329. /**
  74330. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74331. */
  74332. static EmbossKernel: number[];
  74333. /**
  74334. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74335. */
  74336. static GaussianKernel: number[];
  74337. }
  74338. }
  74339. declare module BABYLON {
  74340. /**
  74341. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  74342. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  74343. * based on samples that have a large difference in distance than the center pixel.
  74344. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  74345. */
  74346. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  74347. /**
  74348. * The direction the blur should be applied
  74349. */
  74350. direction: Vector2;
  74351. /**
  74352. * Gets a string identifying the name of the class
  74353. * @returns "DepthOfFieldBlurPostProcess" string
  74354. */
  74355. getClassName(): string;
  74356. /**
  74357. * Creates a new instance CircleOfConfusionPostProcess
  74358. * @param name The name of the effect.
  74359. * @param scene The scene the effect belongs to.
  74360. * @param direction The direction the blur should be applied.
  74361. * @param kernel The size of the kernel used to blur.
  74362. * @param options The required width/height ratio to downsize to before computing the render pass.
  74363. * @param camera The camera to apply the render pass to.
  74364. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring across edges
  74365. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  74366. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74367. * @param engine The engine which the post process will be applied. (default: current engine)
  74368. * @param reusable If the post process can be reused on the same frame. (default: false)
  74369. * @param textureType Type of textures used when performing the post process. (default: 0)
  74370. * @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)
  74371. */
  74372. 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);
  74373. }
  74374. }
  74375. declare module BABYLON {
  74376. /** @hidden */
  74377. export var depthOfFieldMergePixelShader: {
  74378. name: string;
  74379. shader: string;
  74380. };
  74381. }
  74382. declare module BABYLON {
  74383. /**
  74384. * Options to be set when merging outputs from the default pipeline.
  74385. */
  74386. export class DepthOfFieldMergePostProcessOptions {
  74387. /**
  74388. * The original image to merge on top of
  74389. */
  74390. originalFromInput: PostProcess;
  74391. /**
  74392. * Parameters to perform the merge of the depth of field effect
  74393. */
  74394. depthOfField?: {
  74395. circleOfConfusion: PostProcess;
  74396. blurSteps: Array<PostProcess>;
  74397. };
  74398. /**
  74399. * Parameters to perform the merge of bloom effect
  74400. */
  74401. bloom?: {
  74402. blurred: PostProcess;
  74403. weight: number;
  74404. };
  74405. }
  74406. /**
  74407. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74408. */
  74409. export class DepthOfFieldMergePostProcess extends PostProcess {
  74410. private blurSteps;
  74411. /**
  74412. * Gets a string identifying the name of the class
  74413. * @returns "DepthOfFieldMergePostProcess" string
  74414. */
  74415. getClassName(): string;
  74416. /**
  74417. * Creates a new instance of DepthOfFieldMergePostProcess
  74418. * @param name The name of the effect.
  74419. * @param originalFromInput Post process which's input will be used for the merge.
  74420. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  74421. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  74422. * @param options The required width/height ratio to downsize to before computing the render pass.
  74423. * @param camera The camera to apply the render pass to.
  74424. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74425. * @param engine The engine which the post process will be applied. (default: current engine)
  74426. * @param reusable If the post process can be reused on the same frame. (default: false)
  74427. * @param textureType Type of textures used when performing the post process. (default: 0)
  74428. * @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)
  74429. */
  74430. 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);
  74431. /**
  74432. * Updates the effect with the current post process compile time values and recompiles the shader.
  74433. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  74434. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  74435. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  74436. * @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
  74437. * @param onCompiled Called when the shader has been compiled.
  74438. * @param onError Called if there is an error when compiling a shader.
  74439. */
  74440. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  74441. }
  74442. }
  74443. declare module BABYLON {
  74444. /**
  74445. * Specifies the level of max blur that should be applied when using the depth of field effect
  74446. */
  74447. export enum DepthOfFieldEffectBlurLevel {
  74448. /**
  74449. * Subtle blur
  74450. */
  74451. Low = 0,
  74452. /**
  74453. * Medium blur
  74454. */
  74455. Medium = 1,
  74456. /**
  74457. * Large blur
  74458. */
  74459. High = 2
  74460. }
  74461. /**
  74462. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  74463. */
  74464. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  74465. private _circleOfConfusion;
  74466. /**
  74467. * @hidden Internal, blurs from high to low
  74468. */
  74469. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  74470. private _depthOfFieldBlurY;
  74471. private _dofMerge;
  74472. /**
  74473. * @hidden Internal post processes in depth of field effect
  74474. */
  74475. _effects: Array<PostProcess>;
  74476. /**
  74477. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  74478. */
  74479. set focalLength(value: number);
  74480. get focalLength(): number;
  74481. /**
  74482. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74483. */
  74484. set fStop(value: number);
  74485. get fStop(): number;
  74486. /**
  74487. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74488. */
  74489. set focusDistance(value: number);
  74490. get focusDistance(): number;
  74491. /**
  74492. * 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.
  74493. */
  74494. set lensSize(value: number);
  74495. get lensSize(): number;
  74496. /**
  74497. * Creates a new instance DepthOfFieldEffect
  74498. * @param scene The scene the effect belongs to.
  74499. * @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.
  74500. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74501. * @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)
  74502. */
  74503. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  74504. /**
  74505. * Get the current class name of the current effect
  74506. * @returns "DepthOfFieldEffect"
  74507. */
  74508. getClassName(): string;
  74509. /**
  74510. * 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.
  74511. */
  74512. set depthTexture(value: RenderTargetTexture);
  74513. /**
  74514. * Disposes each of the internal effects for a given camera.
  74515. * @param camera The camera to dispose the effect on.
  74516. */
  74517. disposeEffects(camera: Camera): void;
  74518. /**
  74519. * @hidden Internal
  74520. */
  74521. _updateEffects(): void;
  74522. /**
  74523. * Internal
  74524. * @returns if all the contained post processes are ready.
  74525. * @hidden
  74526. */
  74527. _isReady(): boolean;
  74528. }
  74529. }
  74530. declare module BABYLON {
  74531. /** @hidden */
  74532. export var displayPassPixelShader: {
  74533. name: string;
  74534. shader: string;
  74535. };
  74536. }
  74537. declare module BABYLON {
  74538. /**
  74539. * DisplayPassPostProcess which produces an output the same as it's input
  74540. */
  74541. export class DisplayPassPostProcess extends PostProcess {
  74542. /**
  74543. * Gets a string identifying the name of the class
  74544. * @returns "DisplayPassPostProcess" string
  74545. */
  74546. getClassName(): string;
  74547. /**
  74548. * Creates the DisplayPassPostProcess
  74549. * @param name The name of the effect.
  74550. * @param options The required width/height ratio to downsize to before computing the render pass.
  74551. * @param camera The camera to apply the render pass to.
  74552. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74553. * @param engine The engine which the post process will be applied. (default: current engine)
  74554. * @param reusable If the post process can be reused on the same frame. (default: false)
  74555. */
  74556. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74557. /** @hidden */
  74558. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  74559. }
  74560. }
  74561. declare module BABYLON {
  74562. /** @hidden */
  74563. export var filterPixelShader: {
  74564. name: string;
  74565. shader: string;
  74566. };
  74567. }
  74568. declare module BABYLON {
  74569. /**
  74570. * Applies a kernel filter to the image
  74571. */
  74572. export class FilterPostProcess extends PostProcess {
  74573. /** The matrix to be applied to the image */
  74574. kernelMatrix: Matrix;
  74575. /**
  74576. * Gets a string identifying the name of the class
  74577. * @returns "FilterPostProcess" string
  74578. */
  74579. getClassName(): string;
  74580. /**
  74581. *
  74582. * @param name The name of the effect.
  74583. * @param kernelMatrix The matrix to be applied to the image
  74584. * @param options The required width/height ratio to downsize to before computing the render pass.
  74585. * @param camera The camera to apply the render pass to.
  74586. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74587. * @param engine The engine which the post process will be applied. (default: current engine)
  74588. * @param reusable If the post process can be reused on the same frame. (default: false)
  74589. */
  74590. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74591. /** @hidden */
  74592. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74593. }
  74594. }
  74595. declare module BABYLON {
  74596. /** @hidden */
  74597. export var fxaaPixelShader: {
  74598. name: string;
  74599. shader: string;
  74600. };
  74601. }
  74602. declare module BABYLON {
  74603. /** @hidden */
  74604. export var fxaaVertexShader: {
  74605. name: string;
  74606. shader: string;
  74607. };
  74608. }
  74609. declare module BABYLON {
  74610. /**
  74611. * Fxaa post process
  74612. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  74613. */
  74614. export class FxaaPostProcess extends PostProcess {
  74615. /**
  74616. * Gets a string identifying the name of the class
  74617. * @returns "FxaaPostProcess" string
  74618. */
  74619. getClassName(): string;
  74620. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74621. private _getDefines;
  74622. /** @hidden */
  74623. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  74624. }
  74625. }
  74626. declare module BABYLON {
  74627. /** @hidden */
  74628. export var grainPixelShader: {
  74629. name: string;
  74630. shader: string;
  74631. };
  74632. }
  74633. declare module BABYLON {
  74634. /**
  74635. * The GrainPostProcess adds noise to the image at mid luminance levels
  74636. */
  74637. export class GrainPostProcess extends PostProcess {
  74638. /**
  74639. * The intensity of the grain added (default: 30)
  74640. */
  74641. intensity: number;
  74642. /**
  74643. * If the grain should be randomized on every frame
  74644. */
  74645. animated: boolean;
  74646. /**
  74647. * Gets a string identifying the name of the class
  74648. * @returns "GrainPostProcess" string
  74649. */
  74650. getClassName(): string;
  74651. /**
  74652. * Creates a new instance of @see GrainPostProcess
  74653. * @param name The name of the effect.
  74654. * @param options The required width/height ratio to downsize to before computing the render pass.
  74655. * @param camera The camera to apply the render pass to.
  74656. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74657. * @param engine The engine which the post process will be applied. (default: current engine)
  74658. * @param reusable If the post process can be reused on the same frame. (default: false)
  74659. * @param textureType Type of textures used when performing the post process. (default: 0)
  74660. * @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)
  74661. */
  74662. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74663. /** @hidden */
  74664. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  74665. }
  74666. }
  74667. declare module BABYLON {
  74668. /** @hidden */
  74669. export var highlightsPixelShader: {
  74670. name: string;
  74671. shader: string;
  74672. };
  74673. }
  74674. declare module BABYLON {
  74675. /**
  74676. * Extracts highlights from the image
  74677. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74678. */
  74679. export class HighlightsPostProcess extends PostProcess {
  74680. /**
  74681. * Gets a string identifying the name of the class
  74682. * @returns "HighlightsPostProcess" string
  74683. */
  74684. getClassName(): string;
  74685. /**
  74686. * Extracts highlights from the image
  74687. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74688. * @param name The name of the effect.
  74689. * @param options The required width/height ratio to downsize to before computing the render pass.
  74690. * @param camera The camera to apply the render pass to.
  74691. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74692. * @param engine The engine which the post process will be applied. (default: current engine)
  74693. * @param reusable If the post process can be reused on the same frame. (default: false)
  74694. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  74695. */
  74696. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74697. }
  74698. }
  74699. declare module BABYLON {
  74700. /**
  74701. * Contains all parameters needed for the prepass to perform
  74702. * motion blur
  74703. */
  74704. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  74705. /**
  74706. * Is motion blur enabled
  74707. */
  74708. enabled: boolean;
  74709. /**
  74710. * Name of the configuration
  74711. */
  74712. name: string;
  74713. /**
  74714. * Textures that should be present in the MRT for this effect to work
  74715. */
  74716. readonly texturesRequired: number[];
  74717. }
  74718. }
  74719. declare module BABYLON {
  74720. interface Scene {
  74721. /** @hidden (Backing field) */
  74722. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74723. /**
  74724. * Gets or Sets the current geometry buffer associated to the scene.
  74725. */
  74726. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74727. /**
  74728. * Enables a GeometryBufferRender and associates it with the scene
  74729. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  74730. * @returns the GeometryBufferRenderer
  74731. */
  74732. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  74733. /**
  74734. * Disables the GeometryBufferRender associated with the scene
  74735. */
  74736. disableGeometryBufferRenderer(): void;
  74737. }
  74738. /**
  74739. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74740. * in several rendering techniques.
  74741. */
  74742. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  74743. /**
  74744. * The component name helpful to identify the component in the list of scene components.
  74745. */
  74746. readonly name: string;
  74747. /**
  74748. * The scene the component belongs to.
  74749. */
  74750. scene: Scene;
  74751. /**
  74752. * Creates a new instance of the component for the given scene
  74753. * @param scene Defines the scene to register the component in
  74754. */
  74755. constructor(scene: Scene);
  74756. /**
  74757. * Registers the component in a given scene
  74758. */
  74759. register(): void;
  74760. /**
  74761. * Rebuilds the elements related to this component in case of
  74762. * context lost for instance.
  74763. */
  74764. rebuild(): void;
  74765. /**
  74766. * Disposes the component and the associated resources
  74767. */
  74768. dispose(): void;
  74769. private _gatherRenderTargets;
  74770. }
  74771. }
  74772. declare module BABYLON {
  74773. /** @hidden */
  74774. export var motionBlurPixelShader: {
  74775. name: string;
  74776. shader: string;
  74777. };
  74778. }
  74779. declare module BABYLON {
  74780. /**
  74781. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  74782. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  74783. * As an example, all you have to do is to create the post-process:
  74784. * var mb = new BABYLON.MotionBlurPostProcess(
  74785. * 'mb', // The name of the effect.
  74786. * scene, // The scene containing the objects to blur according to their velocity.
  74787. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  74788. * camera // The camera to apply the render pass to.
  74789. * );
  74790. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  74791. */
  74792. export class MotionBlurPostProcess extends PostProcess {
  74793. /**
  74794. * Defines how much the image is blurred by the movement. Default value is equal to 1
  74795. */
  74796. motionStrength: number;
  74797. /**
  74798. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  74799. */
  74800. get motionBlurSamples(): number;
  74801. /**
  74802. * Sets the number of iterations to be used for motion blur quality
  74803. */
  74804. set motionBlurSamples(samples: number);
  74805. private _motionBlurSamples;
  74806. /**
  74807. * Gets whether or not the motion blur post-process is in object based mode.
  74808. */
  74809. get isObjectBased(): boolean;
  74810. /**
  74811. * Sets whether or not the motion blur post-process is in object based mode.
  74812. */
  74813. set isObjectBased(value: boolean);
  74814. private _isObjectBased;
  74815. private _forceGeometryBuffer;
  74816. private _geometryBufferRenderer;
  74817. private _prePassRenderer;
  74818. private _invViewProjection;
  74819. private _previousViewProjection;
  74820. /**
  74821. * Gets a string identifying the name of the class
  74822. * @returns "MotionBlurPostProcess" string
  74823. */
  74824. getClassName(): string;
  74825. /**
  74826. * Creates a new instance MotionBlurPostProcess
  74827. * @param name The name of the effect.
  74828. * @param scene The scene containing the objects to blur according to their velocity.
  74829. * @param options The required width/height ratio to downsize to before computing the render pass.
  74830. * @param camera The camera to apply the render pass to.
  74831. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74832. * @param engine The engine which the post process will be applied. (default: current engine)
  74833. * @param reusable If the post process can be reused on the same frame. (default: false)
  74834. * @param textureType Type of textures used when performing the post process. (default: 0)
  74835. * @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)
  74836. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74837. */
  74838. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74839. /**
  74840. * Excludes the given skinned mesh from computing bones velocities.
  74841. * 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.
  74842. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74843. */
  74844. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74845. /**
  74846. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74847. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74848. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74849. */
  74850. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74851. /**
  74852. * Disposes the post process.
  74853. * @param camera The camera to dispose the post process on.
  74854. */
  74855. dispose(camera?: Camera): void;
  74856. /**
  74857. * Called on the mode changed (object based or screen based).
  74858. */
  74859. private _applyMode;
  74860. /**
  74861. * Called on the effect is applied when the motion blur post-process is in object based mode.
  74862. */
  74863. private _onApplyObjectBased;
  74864. /**
  74865. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  74866. */
  74867. private _onApplyScreenBased;
  74868. /**
  74869. * Called on the effect must be updated (changed mode, samples count, etc.).
  74870. */
  74871. private _updateEffect;
  74872. /** @hidden */
  74873. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74874. }
  74875. }
  74876. declare module BABYLON {
  74877. /** @hidden */
  74878. export var refractionPixelShader: {
  74879. name: string;
  74880. shader: string;
  74881. };
  74882. }
  74883. declare module BABYLON {
  74884. /**
  74885. * Post process which applies a refraction texture
  74886. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74887. */
  74888. export class RefractionPostProcess extends PostProcess {
  74889. private _refTexture;
  74890. private _ownRefractionTexture;
  74891. /** the base color of the refraction (used to taint the rendering) */
  74892. color: Color3;
  74893. /** simulated refraction depth */
  74894. depth: number;
  74895. /** the coefficient of the base color (0 to remove base color tainting) */
  74896. colorLevel: number;
  74897. /** Gets the url used to load the refraction texture */
  74898. refractionTextureUrl: string;
  74899. /**
  74900. * Gets or sets the refraction texture
  74901. * Please note that you are responsible for disposing the texture if you set it manually
  74902. */
  74903. get refractionTexture(): Texture;
  74904. set refractionTexture(value: Texture);
  74905. /**
  74906. * Gets a string identifying the name of the class
  74907. * @returns "RefractionPostProcess" string
  74908. */
  74909. getClassName(): string;
  74910. /**
  74911. * Initializes the RefractionPostProcess
  74912. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74913. * @param name The name of the effect.
  74914. * @param refractionTextureUrl Url of the refraction texture to use
  74915. * @param color the base color of the refraction (used to taint the rendering)
  74916. * @param depth simulated refraction depth
  74917. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74918. * @param camera The camera to apply the render pass to.
  74919. * @param options The required width/height ratio to downsize to before computing the render pass.
  74920. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74921. * @param engine The engine which the post process will be applied. (default: current engine)
  74922. * @param reusable If the post process can be reused on the same frame. (default: false)
  74923. */
  74924. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74925. /**
  74926. * Disposes of the post process
  74927. * @param camera Camera to dispose post process on
  74928. */
  74929. dispose(camera: Camera): void;
  74930. /** @hidden */
  74931. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74932. }
  74933. }
  74934. declare module BABYLON {
  74935. /** @hidden */
  74936. export var sharpenPixelShader: {
  74937. name: string;
  74938. shader: string;
  74939. };
  74940. }
  74941. declare module BABYLON {
  74942. /**
  74943. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74944. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74945. */
  74946. export class SharpenPostProcess extends PostProcess {
  74947. /**
  74948. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74949. */
  74950. colorAmount: number;
  74951. /**
  74952. * How much sharpness should be applied (default: 0.3)
  74953. */
  74954. edgeAmount: number;
  74955. /**
  74956. * Gets a string identifying the name of the class
  74957. * @returns "SharpenPostProcess" string
  74958. */
  74959. getClassName(): string;
  74960. /**
  74961. * Creates a new instance ConvolutionPostProcess
  74962. * @param name The name of the effect.
  74963. * @param options The required width/height ratio to downsize to before computing the render pass.
  74964. * @param camera The camera to apply the render pass to.
  74965. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74966. * @param engine The engine which the post process will be applied. (default: current engine)
  74967. * @param reusable If the post process can be reused on the same frame. (default: false)
  74968. * @param textureType Type of textures used when performing the post process. (default: 0)
  74969. * @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)
  74970. */
  74971. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74972. /** @hidden */
  74973. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74974. }
  74975. }
  74976. declare module BABYLON {
  74977. /**
  74978. * PostProcessRenderPipeline
  74979. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74980. */
  74981. export class PostProcessRenderPipeline {
  74982. private engine;
  74983. private _renderEffects;
  74984. private _renderEffectsForIsolatedPass;
  74985. /**
  74986. * List of inspectable custom properties (used by the Inspector)
  74987. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74988. */
  74989. inspectableCustomProperties: IInspectable[];
  74990. /**
  74991. * @hidden
  74992. */
  74993. protected _cameras: Camera[];
  74994. /** @hidden */
  74995. _name: string;
  74996. /**
  74997. * Gets pipeline name
  74998. */
  74999. get name(): string;
  75000. /** Gets the list of attached cameras */
  75001. get cameras(): Camera[];
  75002. /**
  75003. * Initializes a PostProcessRenderPipeline
  75004. * @param engine engine to add the pipeline to
  75005. * @param name name of the pipeline
  75006. */
  75007. constructor(engine: Engine, name: string);
  75008. /**
  75009. * Gets the class name
  75010. * @returns "PostProcessRenderPipeline"
  75011. */
  75012. getClassName(): string;
  75013. /**
  75014. * If all the render effects in the pipeline are supported
  75015. */
  75016. get isSupported(): boolean;
  75017. /**
  75018. * Adds an effect to the pipeline
  75019. * @param renderEffect the effect to add
  75020. */
  75021. addEffect(renderEffect: PostProcessRenderEffect): void;
  75022. /** @hidden */
  75023. _rebuild(): void;
  75024. /** @hidden */
  75025. _enableEffect(renderEffectName: string, cameras: Camera): void;
  75026. /** @hidden */
  75027. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  75028. /** @hidden */
  75029. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  75030. /** @hidden */
  75031. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  75032. /** @hidden */
  75033. _attachCameras(cameras: Camera, unique: boolean): void;
  75034. /** @hidden */
  75035. _attachCameras(cameras: Camera[], unique: boolean): void;
  75036. /** @hidden */
  75037. _detachCameras(cameras: Camera): void;
  75038. /** @hidden */
  75039. _detachCameras(cameras: Nullable<Camera[]>): void;
  75040. /** @hidden */
  75041. _update(): void;
  75042. /** @hidden */
  75043. _reset(): void;
  75044. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  75045. /**
  75046. * Sets the required values to the prepass renderer.
  75047. * @param prePassRenderer defines the prepass renderer to setup.
  75048. * @returns true if the pre pass is needed.
  75049. */
  75050. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  75051. /**
  75052. * Disposes of the pipeline
  75053. */
  75054. dispose(): void;
  75055. }
  75056. }
  75057. declare module BABYLON {
  75058. /**
  75059. * PostProcessRenderPipelineManager class
  75060. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75061. */
  75062. export class PostProcessRenderPipelineManager {
  75063. private _renderPipelines;
  75064. /**
  75065. * Initializes a PostProcessRenderPipelineManager
  75066. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75067. */
  75068. constructor();
  75069. /**
  75070. * Gets the list of supported render pipelines
  75071. */
  75072. get supportedPipelines(): PostProcessRenderPipeline[];
  75073. /**
  75074. * Adds a pipeline to the manager
  75075. * @param renderPipeline The pipeline to add
  75076. */
  75077. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  75078. /**
  75079. * Attaches a camera to the pipeline
  75080. * @param renderPipelineName The name of the pipeline to attach to
  75081. * @param cameras the camera to attach
  75082. * @param unique if the camera can be attached multiple times to the pipeline
  75083. */
  75084. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  75085. /**
  75086. * Detaches a camera from the pipeline
  75087. * @param renderPipelineName The name of the pipeline to detach from
  75088. * @param cameras the camera to detach
  75089. */
  75090. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  75091. /**
  75092. * Enables an effect by name on a pipeline
  75093. * @param renderPipelineName the name of the pipeline to enable the effect in
  75094. * @param renderEffectName the name of the effect to enable
  75095. * @param cameras the cameras that the effect should be enabled on
  75096. */
  75097. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75098. /**
  75099. * Disables an effect by name on a pipeline
  75100. * @param renderPipelineName the name of the pipeline to disable the effect in
  75101. * @param renderEffectName the name of the effect to disable
  75102. * @param cameras the cameras that the effect should be disabled on
  75103. */
  75104. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75105. /**
  75106. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  75107. */
  75108. update(): void;
  75109. /** @hidden */
  75110. _rebuild(): void;
  75111. /**
  75112. * Disposes of the manager and pipelines
  75113. */
  75114. dispose(): void;
  75115. }
  75116. }
  75117. declare module BABYLON {
  75118. interface Scene {
  75119. /** @hidden (Backing field) */
  75120. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75121. /**
  75122. * Gets the postprocess render pipeline manager
  75123. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75124. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75125. */
  75126. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75127. }
  75128. /**
  75129. * Defines the Render Pipeline scene component responsible to rendering pipelines
  75130. */
  75131. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  75132. /**
  75133. * The component name helpful to identify the component in the list of scene components.
  75134. */
  75135. readonly name: string;
  75136. /**
  75137. * The scene the component belongs to.
  75138. */
  75139. scene: Scene;
  75140. /**
  75141. * Creates a new instance of the component for the given scene
  75142. * @param scene Defines the scene to register the component in
  75143. */
  75144. constructor(scene: Scene);
  75145. /**
  75146. * Registers the component in a given scene
  75147. */
  75148. register(): void;
  75149. /**
  75150. * Rebuilds the elements related to this component in case of
  75151. * context lost for instance.
  75152. */
  75153. rebuild(): void;
  75154. /**
  75155. * Disposes the component and the associated resources
  75156. */
  75157. dispose(): void;
  75158. private _gatherRenderTargets;
  75159. }
  75160. }
  75161. declare module BABYLON {
  75162. /**
  75163. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  75164. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75165. */
  75166. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75167. private _scene;
  75168. private _camerasToBeAttached;
  75169. /**
  75170. * ID of the sharpen post process,
  75171. */
  75172. private readonly SharpenPostProcessId;
  75173. /**
  75174. * @ignore
  75175. * ID of the image processing post process;
  75176. */
  75177. readonly ImageProcessingPostProcessId: string;
  75178. /**
  75179. * @ignore
  75180. * ID of the Fast Approximate Anti-Aliasing post process;
  75181. */
  75182. readonly FxaaPostProcessId: string;
  75183. /**
  75184. * ID of the chromatic aberration post process,
  75185. */
  75186. private readonly ChromaticAberrationPostProcessId;
  75187. /**
  75188. * ID of the grain post process
  75189. */
  75190. private readonly GrainPostProcessId;
  75191. /**
  75192. * Sharpen post process which will apply a sharpen convolution to enhance edges
  75193. */
  75194. sharpen: SharpenPostProcess;
  75195. private _sharpenEffect;
  75196. private bloom;
  75197. /**
  75198. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  75199. */
  75200. depthOfField: DepthOfFieldEffect;
  75201. /**
  75202. * The Fast Approximate Anti-Aliasing post process which attempts to remove aliasing from an image.
  75203. */
  75204. fxaa: FxaaPostProcess;
  75205. /**
  75206. * Image post processing pass used to perform operations such as tone mapping or color grading.
  75207. */
  75208. imageProcessing: ImageProcessingPostProcess;
  75209. /**
  75210. * Chromatic aberration post process which will shift rgb colors in the image
  75211. */
  75212. chromaticAberration: ChromaticAberrationPostProcess;
  75213. private _chromaticAberrationEffect;
  75214. /**
  75215. * Grain post process which add noise to the image
  75216. */
  75217. grain: GrainPostProcess;
  75218. private _grainEffect;
  75219. /**
  75220. * Glow post process which adds a glow to emissive areas of the image
  75221. */
  75222. private _glowLayer;
  75223. /**
  75224. * Animations which can be used to tweak settings over a period of time
  75225. */
  75226. animations: Animation[];
  75227. private _imageProcessingConfigurationObserver;
  75228. private _sharpenEnabled;
  75229. private _bloomEnabled;
  75230. private _depthOfFieldEnabled;
  75231. private _depthOfFieldBlurLevel;
  75232. private _fxaaEnabled;
  75233. private _imageProcessingEnabled;
  75234. private _defaultPipelineTextureType;
  75235. private _bloomScale;
  75236. private _chromaticAberrationEnabled;
  75237. private _grainEnabled;
  75238. private _buildAllowed;
  75239. /**
  75240. * This is triggered each time the pipeline has been built.
  75241. */
  75242. onBuildObservable: Observable<DefaultRenderingPipeline>;
  75243. /**
  75244. * Gets active scene
  75245. */
  75246. get scene(): Scene;
  75247. /**
  75248. * Enable or disable the sharpen process from the pipeline
  75249. */
  75250. set sharpenEnabled(enabled: boolean);
  75251. get sharpenEnabled(): boolean;
  75252. private _resizeObserver;
  75253. private _hardwareScaleLevel;
  75254. private _bloomKernel;
  75255. /**
  75256. * Specifies the size of the bloom blur kernel, relative to the final output size
  75257. */
  75258. get bloomKernel(): number;
  75259. set bloomKernel(value: number);
  75260. /**
  75261. * Specifies the weight of the bloom in the final rendering
  75262. */
  75263. private _bloomWeight;
  75264. /**
  75265. * Specifies the luma threshold for the area that will be blurred by the bloom
  75266. */
  75267. private _bloomThreshold;
  75268. private _hdr;
  75269. /**
  75270. * The strength of the bloom.
  75271. */
  75272. set bloomWeight(value: number);
  75273. get bloomWeight(): number;
  75274. /**
  75275. * The strength of the bloom.
  75276. */
  75277. set bloomThreshold(value: number);
  75278. get bloomThreshold(): number;
  75279. /**
  75280. * The scale of the bloom, lower value will provide better performance.
  75281. */
  75282. set bloomScale(value: number);
  75283. get bloomScale(): number;
  75284. /**
  75285. * Enable or disable the bloom from the pipeline
  75286. */
  75287. set bloomEnabled(enabled: boolean);
  75288. get bloomEnabled(): boolean;
  75289. private _rebuildBloom;
  75290. /**
  75291. * If the depth of field is enabled.
  75292. */
  75293. get depthOfFieldEnabled(): boolean;
  75294. set depthOfFieldEnabled(enabled: boolean);
  75295. /**
  75296. * Blur level of the depth of field effect. (Higher blur will effect performance)
  75297. */
  75298. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  75299. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  75300. /**
  75301. * If the anti aliasing is enabled.
  75302. */
  75303. set fxaaEnabled(enabled: boolean);
  75304. get fxaaEnabled(): boolean;
  75305. private _samples;
  75306. /**
  75307. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75308. */
  75309. set samples(sampleCount: number);
  75310. get samples(): number;
  75311. /**
  75312. * If image processing is enabled.
  75313. */
  75314. set imageProcessingEnabled(enabled: boolean);
  75315. get imageProcessingEnabled(): boolean;
  75316. /**
  75317. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  75318. */
  75319. set glowLayerEnabled(enabled: boolean);
  75320. get glowLayerEnabled(): boolean;
  75321. /**
  75322. * Gets the glow layer (or null if not defined)
  75323. */
  75324. get glowLayer(): Nullable<GlowLayer>;
  75325. /**
  75326. * Enable or disable the chromaticAberration process from the pipeline
  75327. */
  75328. set chromaticAberrationEnabled(enabled: boolean);
  75329. get chromaticAberrationEnabled(): boolean;
  75330. /**
  75331. * Enable or disable the grain process from the pipeline
  75332. */
  75333. set grainEnabled(enabled: boolean);
  75334. get grainEnabled(): boolean;
  75335. /**
  75336. * @constructor
  75337. * @param name - The rendering pipeline name (default: "")
  75338. * @param hdr - If high dynamic range textures should be used (default: true)
  75339. * @param scene - The scene linked to this pipeline (default: the last created scene)
  75340. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  75341. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  75342. */
  75343. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  75344. /**
  75345. * Get the class name
  75346. * @returns "DefaultRenderingPipeline"
  75347. */
  75348. getClassName(): string;
  75349. /**
  75350. * Force the compilation of the entire pipeline.
  75351. */
  75352. prepare(): void;
  75353. private _hasCleared;
  75354. private _prevPostProcess;
  75355. private _prevPrevPostProcess;
  75356. private _setAutoClearAndTextureSharing;
  75357. private _depthOfFieldSceneObserver;
  75358. private _buildPipeline;
  75359. private _disposePostProcesses;
  75360. /**
  75361. * Adds a camera to the pipeline
  75362. * @param camera the camera to be added
  75363. */
  75364. addCamera(camera: Camera): void;
  75365. /**
  75366. * Removes a camera from the pipeline
  75367. * @param camera the camera to remove
  75368. */
  75369. removeCamera(camera: Camera): void;
  75370. /**
  75371. * Dispose of the pipeline and stop all post processes
  75372. */
  75373. dispose(): void;
  75374. /**
  75375. * Serialize the rendering pipeline (Used when exporting)
  75376. * @returns the serialized object
  75377. */
  75378. serialize(): any;
  75379. /**
  75380. * Parse the serialized pipeline
  75381. * @param source Source pipeline.
  75382. * @param scene The scene to load the pipeline to.
  75383. * @param rootUrl The URL of the serialized pipeline.
  75384. * @returns An instantiated pipeline from the serialized object.
  75385. */
  75386. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  75387. }
  75388. }
  75389. declare module BABYLON {
  75390. /** @hidden */
  75391. export var lensHighlightsPixelShader: {
  75392. name: string;
  75393. shader: string;
  75394. };
  75395. }
  75396. declare module BABYLON {
  75397. /** @hidden */
  75398. export var depthOfFieldPixelShader: {
  75399. name: string;
  75400. shader: string;
  75401. };
  75402. }
  75403. declare module BABYLON {
  75404. /**
  75405. * BABYLON.JS Chromatic Aberration GLSL Shader
  75406. * Author: Olivier Guyot
  75407. * Separates very slightly R, G and B colors on the edges of the screen
  75408. * Inspired by Francois Tarlier & Martins Upitis
  75409. */
  75410. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  75411. /**
  75412. * @ignore
  75413. * The chromatic aberration PostProcess id in the pipeline
  75414. */
  75415. LensChromaticAberrationEffect: string;
  75416. /**
  75417. * @ignore
  75418. * The highlights enhancing PostProcess id in the pipeline
  75419. */
  75420. HighlightsEnhancingEffect: string;
  75421. /**
  75422. * @ignore
  75423. * The depth-of-field PostProcess id in the pipeline
  75424. */
  75425. LensDepthOfFieldEffect: string;
  75426. private _scene;
  75427. private _depthTexture;
  75428. private _grainTexture;
  75429. private _chromaticAberrationPostProcess;
  75430. private _highlightsPostProcess;
  75431. private _depthOfFieldPostProcess;
  75432. private _edgeBlur;
  75433. private _grainAmount;
  75434. private _chromaticAberration;
  75435. private _distortion;
  75436. private _highlightsGain;
  75437. private _highlightsThreshold;
  75438. private _dofDistance;
  75439. private _dofAperture;
  75440. private _dofDarken;
  75441. private _dofPentagon;
  75442. private _blurNoise;
  75443. /**
  75444. * @constructor
  75445. *
  75446. * Effect parameters are as follow:
  75447. * {
  75448. * chromatic_aberration: number; // from 0 to x (1 for realism)
  75449. * edge_blur: number; // from 0 to x (1 for realism)
  75450. * distortion: number; // from 0 to x (1 for realism)
  75451. * grain_amount: number; // from 0 to 1
  75452. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  75453. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  75454. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  75455. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  75456. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  75457. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  75458. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  75459. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  75460. * }
  75461. * Note: if an effect parameter is unset, effect is disabled
  75462. *
  75463. * @param name The rendering pipeline name
  75464. * @param parameters - An object containing all parameters (see above)
  75465. * @param scene The scene linked to this pipeline
  75466. * @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)
  75467. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75468. */
  75469. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  75470. /**
  75471. * Get the class name
  75472. * @returns "LensRenderingPipeline"
  75473. */
  75474. getClassName(): string;
  75475. /**
  75476. * Gets associated scene
  75477. */
  75478. get scene(): Scene;
  75479. /**
  75480. * Gets or sets the edge blur
  75481. */
  75482. get edgeBlur(): number;
  75483. set edgeBlur(value: number);
  75484. /**
  75485. * Gets or sets the grain amount
  75486. */
  75487. get grainAmount(): number;
  75488. set grainAmount(value: number);
  75489. /**
  75490. * Gets or sets the chromatic aberration amount
  75491. */
  75492. get chromaticAberration(): number;
  75493. set chromaticAberration(value: number);
  75494. /**
  75495. * Gets or sets the depth of field aperture
  75496. */
  75497. get dofAperture(): number;
  75498. set dofAperture(value: number);
  75499. /**
  75500. * Gets or sets the edge distortion
  75501. */
  75502. get edgeDistortion(): number;
  75503. set edgeDistortion(value: number);
  75504. /**
  75505. * Gets or sets the depth of field distortion
  75506. */
  75507. get dofDistortion(): number;
  75508. set dofDistortion(value: number);
  75509. /**
  75510. * Gets or sets the darken out of focus amount
  75511. */
  75512. get darkenOutOfFocus(): number;
  75513. set darkenOutOfFocus(value: number);
  75514. /**
  75515. * Gets or sets a boolean indicating if blur noise is enabled
  75516. */
  75517. get blurNoise(): boolean;
  75518. set blurNoise(value: boolean);
  75519. /**
  75520. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  75521. */
  75522. get pentagonBokeh(): boolean;
  75523. set pentagonBokeh(value: boolean);
  75524. /**
  75525. * Gets or sets the highlight grain amount
  75526. */
  75527. get highlightsGain(): number;
  75528. set highlightsGain(value: number);
  75529. /**
  75530. * Gets or sets the highlight threshold
  75531. */
  75532. get highlightsThreshold(): number;
  75533. set highlightsThreshold(value: number);
  75534. /**
  75535. * Sets the amount of blur at the edges
  75536. * @param amount blur amount
  75537. */
  75538. setEdgeBlur(amount: number): void;
  75539. /**
  75540. * Sets edge blur to 0
  75541. */
  75542. disableEdgeBlur(): void;
  75543. /**
  75544. * Sets the amount of grain
  75545. * @param amount Amount of grain
  75546. */
  75547. setGrainAmount(amount: number): void;
  75548. /**
  75549. * Set grain amount to 0
  75550. */
  75551. disableGrain(): void;
  75552. /**
  75553. * Sets the chromatic aberration amount
  75554. * @param amount amount of chromatic aberration
  75555. */
  75556. setChromaticAberration(amount: number): void;
  75557. /**
  75558. * Sets chromatic aberration amount to 0
  75559. */
  75560. disableChromaticAberration(): void;
  75561. /**
  75562. * Sets the EdgeDistortion amount
  75563. * @param amount amount of EdgeDistortion
  75564. */
  75565. setEdgeDistortion(amount: number): void;
  75566. /**
  75567. * Sets edge distortion to 0
  75568. */
  75569. disableEdgeDistortion(): void;
  75570. /**
  75571. * Sets the FocusDistance amount
  75572. * @param amount amount of FocusDistance
  75573. */
  75574. setFocusDistance(amount: number): void;
  75575. /**
  75576. * Disables depth of field
  75577. */
  75578. disableDepthOfField(): void;
  75579. /**
  75580. * Sets the Aperture amount
  75581. * @param amount amount of Aperture
  75582. */
  75583. setAperture(amount: number): void;
  75584. /**
  75585. * Sets the DarkenOutOfFocus amount
  75586. * @param amount amount of DarkenOutOfFocus
  75587. */
  75588. setDarkenOutOfFocus(amount: number): void;
  75589. private _pentagonBokehIsEnabled;
  75590. /**
  75591. * Creates a pentagon bokeh effect
  75592. */
  75593. enablePentagonBokeh(): void;
  75594. /**
  75595. * Disables the pentagon bokeh effect
  75596. */
  75597. disablePentagonBokeh(): void;
  75598. /**
  75599. * Enables noise blur
  75600. */
  75601. enableNoiseBlur(): void;
  75602. /**
  75603. * Disables noise blur
  75604. */
  75605. disableNoiseBlur(): void;
  75606. /**
  75607. * Sets the HighlightsGain amount
  75608. * @param amount amount of HighlightsGain
  75609. */
  75610. setHighlightsGain(amount: number): void;
  75611. /**
  75612. * Sets the HighlightsThreshold amount
  75613. * @param amount amount of HighlightsThreshold
  75614. */
  75615. setHighlightsThreshold(amount: number): void;
  75616. /**
  75617. * Disables highlights
  75618. */
  75619. disableHighlights(): void;
  75620. /**
  75621. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75622. * @param disableDepthRender If the scene's depth rendering should be disabled (default: false)
  75623. */
  75624. dispose(disableDepthRender?: boolean): void;
  75625. private _createChromaticAberrationPostProcess;
  75626. private _createHighlightsPostProcess;
  75627. private _createDepthOfFieldPostProcess;
  75628. private _createGrainTexture;
  75629. }
  75630. }
  75631. declare module BABYLON {
  75632. /**
  75633. * Contains all parameters needed for the prepass to perform
  75634. * screen space subsurface scattering
  75635. */
  75636. export class SSAO2Configuration implements PrePassEffectConfiguration {
  75637. /**
  75638. * Is subsurface enabled
  75639. */
  75640. enabled: boolean;
  75641. /**
  75642. * Name of the configuration
  75643. */
  75644. name: string;
  75645. /**
  75646. * Textures that should be present in the MRT for this effect to work
  75647. */
  75648. readonly texturesRequired: number[];
  75649. }
  75650. }
  75651. declare module BABYLON {
  75652. /** @hidden */
  75653. export var ssao2PixelShader: {
  75654. name: string;
  75655. shader: string;
  75656. };
  75657. }
  75658. declare module BABYLON {
  75659. /** @hidden */
  75660. export var ssaoCombinePixelShader: {
  75661. name: string;
  75662. shader: string;
  75663. };
  75664. }
  75665. declare module BABYLON {
  75666. /**
  75667. * Render pipeline to produce ssao effect
  75668. */
  75669. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  75670. /**
  75671. * @ignore
  75672. * The PassPostProcess id in the pipeline that contains the original scene color
  75673. */
  75674. SSAOOriginalSceneColorEffect: string;
  75675. /**
  75676. * @ignore
  75677. * The SSAO PostProcess id in the pipeline
  75678. */
  75679. SSAORenderEffect: string;
  75680. /**
  75681. * @ignore
  75682. * The horizontal blur PostProcess id in the pipeline
  75683. */
  75684. SSAOBlurHRenderEffect: string;
  75685. /**
  75686. * @ignore
  75687. * The vertical blur PostProcess id in the pipeline
  75688. */
  75689. SSAOBlurVRenderEffect: string;
  75690. /**
  75691. * @ignore
  75692. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75693. */
  75694. SSAOCombineRenderEffect: string;
  75695. /**
  75696. * The output strength of the SSAO post-process. Default value is 1.0.
  75697. */
  75698. totalStrength: number;
  75699. /**
  75700. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  75701. */
  75702. maxZ: number;
  75703. /**
  75704. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  75705. */
  75706. minZAspect: number;
  75707. private _samples;
  75708. /**
  75709. * Number of samples used for the SSAO calculations. Default value is 8
  75710. */
  75711. set samples(n: number);
  75712. get samples(): number;
  75713. private _textureSamples;
  75714. /**
  75715. * Number of samples to use for antialiasing
  75716. */
  75717. set textureSamples(n: number);
  75718. get textureSamples(): number;
  75719. /**
  75720. * Force rendering the geometry through geometry buffer
  75721. */
  75722. private _forceGeometryBuffer;
  75723. /**
  75724. * Ratio object used for SSAO ratio and blur ratio
  75725. */
  75726. private _ratio;
  75727. /**
  75728. * Dynamically generated sphere sampler.
  75729. */
  75730. private _sampleSphere;
  75731. /**
  75732. * Blur filter offsets
  75733. */
  75734. private _samplerOffsets;
  75735. private _expensiveBlur;
  75736. /**
  75737. * If bilateral blur should be used
  75738. */
  75739. set expensiveBlur(b: boolean);
  75740. get expensiveBlur(): boolean;
  75741. /**
  75742. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  75743. */
  75744. radius: number;
  75745. /**
  75746. * The base color of the SSAO post-process
  75747. * The final result is "base + ssao" between [0, 1]
  75748. */
  75749. base: number;
  75750. /**
  75751. * Support test.
  75752. */
  75753. static get IsSupported(): boolean;
  75754. private _scene;
  75755. private _randomTexture;
  75756. private _originalColorPostProcess;
  75757. private _ssaoPostProcess;
  75758. private _blurHPostProcess;
  75759. private _blurVPostProcess;
  75760. private _ssaoCombinePostProcess;
  75761. private _prePassRenderer;
  75762. /**
  75763. * Gets active scene
  75764. */
  75765. get scene(): Scene;
  75766. /**
  75767. * @constructor
  75768. * @param name The rendering pipeline name
  75769. * @param scene The scene linked to this pipeline
  75770. * @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 }
  75771. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75772. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  75773. */
  75774. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  75775. /**
  75776. * Get the class name
  75777. * @returns "SSAO2RenderingPipeline"
  75778. */
  75779. getClassName(): string;
  75780. /**
  75781. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75782. */
  75783. dispose(disableGeometryBufferRenderer?: boolean): void;
  75784. private _createBlurPostProcess;
  75785. /** @hidden */
  75786. _rebuild(): void;
  75787. private _bits;
  75788. private _radicalInverse_VdC;
  75789. private _hammersley;
  75790. private _hemisphereSample_uniform;
  75791. private _generateHemisphere;
  75792. private _getDefinesForSSAO;
  75793. private static readonly ORTHO_DEPTH_PROJECTION;
  75794. private static readonly PERSPECTIVE_DEPTH_PROJECTION;
  75795. private _createSSAOPostProcess;
  75796. private _createSSAOCombinePostProcess;
  75797. private _createRandomTexture;
  75798. /**
  75799. * Serialize the rendering pipeline (Used when exporting)
  75800. * @returns the serialized object
  75801. */
  75802. serialize(): any;
  75803. /**
  75804. * Parse the serialized pipeline
  75805. * @param source Source pipeline.
  75806. * @param scene The scene to load the pipeline to.
  75807. * @param rootUrl The URL of the serialized pipeline.
  75808. * @returns An instantiated pipeline from the serialized object.
  75809. */
  75810. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75811. }
  75812. }
  75813. declare module BABYLON {
  75814. /** @hidden */
  75815. export var ssaoPixelShader: {
  75816. name: string;
  75817. shader: string;
  75818. };
  75819. }
  75820. declare module BABYLON {
  75821. /**
  75822. * Render pipeline to produce ssao effect
  75823. */
  75824. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75825. /**
  75826. * @ignore
  75827. * The PassPostProcess id in the pipeline that contains the original scene color
  75828. */
  75829. SSAOOriginalSceneColorEffect: string;
  75830. /**
  75831. * @ignore
  75832. * The SSAO PostProcess id in the pipeline
  75833. */
  75834. SSAORenderEffect: string;
  75835. /**
  75836. * @ignore
  75837. * The horizontal blur PostProcess id in the pipeline
  75838. */
  75839. SSAOBlurHRenderEffect: string;
  75840. /**
  75841. * @ignore
  75842. * The vertical blur PostProcess id in the pipeline
  75843. */
  75844. SSAOBlurVRenderEffect: string;
  75845. /**
  75846. * @ignore
  75847. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75848. */
  75849. SSAOCombineRenderEffect: string;
  75850. /**
  75851. * The output strength of the SSAO post-process. Default value is 1.0.
  75852. */
  75853. totalStrength: number;
  75854. /**
  75855. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75856. */
  75857. radius: number;
  75858. /**
  75859. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75860. * Must not be equal to fallOff and superior to fallOff.
  75861. * Default value is 0.0075
  75862. */
  75863. area: number;
  75864. /**
  75865. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75866. * Must not be equal to area and inferior to area.
  75867. * Default value is 0.000001
  75868. */
  75869. fallOff: number;
  75870. /**
  75871. * The base color of the SSAO post-process
  75872. * The final result is "base + ssao" between [0, 1]
  75873. */
  75874. base: number;
  75875. private _scene;
  75876. private _depthTexture;
  75877. private _randomTexture;
  75878. private _originalColorPostProcess;
  75879. private _ssaoPostProcess;
  75880. private _blurHPostProcess;
  75881. private _blurVPostProcess;
  75882. private _ssaoCombinePostProcess;
  75883. private _firstUpdate;
  75884. /**
  75885. * Gets active scene
  75886. */
  75887. get scene(): Scene;
  75888. /**
  75889. * @constructor
  75890. * @param name - The rendering pipeline name
  75891. * @param scene - The scene linked to this pipeline
  75892. * @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 }
  75893. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75894. */
  75895. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75896. /**
  75897. * Get the class name
  75898. * @returns "SSAORenderingPipeline"
  75899. */
  75900. getClassName(): string;
  75901. /**
  75902. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75903. */
  75904. dispose(disableDepthRender?: boolean): void;
  75905. private _createBlurPostProcess;
  75906. /** @hidden */
  75907. _rebuild(): void;
  75908. private _createSSAOPostProcess;
  75909. private _createSSAOCombinePostProcess;
  75910. private _createRandomTexture;
  75911. }
  75912. }
  75913. declare module BABYLON {
  75914. /**
  75915. * Contains all parameters needed for the prepass to perform
  75916. * screen space reflections
  75917. */
  75918. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75919. /**
  75920. * Is ssr enabled
  75921. */
  75922. enabled: boolean;
  75923. /**
  75924. * Name of the configuration
  75925. */
  75926. name: string;
  75927. /**
  75928. * Textures that should be present in the MRT for this effect to work
  75929. */
  75930. readonly texturesRequired: number[];
  75931. }
  75932. }
  75933. declare module BABYLON {
  75934. /** @hidden */
  75935. export var screenSpaceReflectionPixelShader: {
  75936. name: string;
  75937. shader: string;
  75938. };
  75939. }
  75940. declare module BABYLON {
  75941. /**
  75942. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75943. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75944. */
  75945. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75946. /**
  75947. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75948. */
  75949. threshold: number;
  75950. /**
  75951. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75952. */
  75953. strength: number;
  75954. /**
  75955. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75956. */
  75957. reflectionSpecularFalloffExponent: number;
  75958. /**
  75959. * 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]
  75960. */
  75961. step: number;
  75962. /**
  75963. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75964. */
  75965. roughnessFactor: number;
  75966. private _forceGeometryBuffer;
  75967. private _geometryBufferRenderer;
  75968. private _prePassRenderer;
  75969. private _enableSmoothReflections;
  75970. private _reflectionSamples;
  75971. private _smoothSteps;
  75972. /**
  75973. * Gets a string identifying the name of the class
  75974. * @returns "ScreenSpaceReflectionPostProcess" string
  75975. */
  75976. getClassName(): string;
  75977. /**
  75978. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75979. * @param name The name of the effect.
  75980. * @param scene The scene containing the objects to calculate reflections.
  75981. * @param options The required width/height ratio to downsize to before computing the render pass.
  75982. * @param camera The camera to apply the render pass to.
  75983. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75984. * @param engine The engine which the post process will be applied. (default: current engine)
  75985. * @param reusable If the post process can be reused on the same frame. (default: false)
  75986. * @param textureType Type of textures used when performing the post process. (default: 0)
  75987. * @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)
  75988. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75989. */
  75990. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75991. /**
  75992. * Gets whether or not smoothing reflections is enabled.
  75993. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75994. */
  75995. get enableSmoothReflections(): boolean;
  75996. /**
  75997. * Sets whether or not smoothing reflections is enabled.
  75998. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75999. */
  76000. set enableSmoothReflections(enabled: boolean);
  76001. /**
  76002. * Gets the number of samples taken while computing reflections. More samples count is high,
  76003. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76004. */
  76005. get reflectionSamples(): number;
  76006. /**
  76007. * Sets the number of samples taken while computing reflections. More samples count is high,
  76008. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76009. */
  76010. set reflectionSamples(samples: number);
  76011. /**
  76012. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  76013. * more the post-process will require GPU power and can generate a drop in FPS.
  76014. * Default value (5.0) work pretty well in all cases but can be adjusted.
  76015. */
  76016. get smoothSteps(): number;
  76017. set smoothSteps(steps: number);
  76018. private _updateEffectDefines;
  76019. /** @hidden */
  76020. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  76021. }
  76022. }
  76023. declare module BABYLON {
  76024. /** @hidden */
  76025. export var standardPixelShader: {
  76026. name: string;
  76027. shader: string;
  76028. };
  76029. }
  76030. declare module BABYLON {
  76031. /**
  76032. * Standard rendering pipeline
  76033. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76034. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  76035. */
  76036. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  76037. /**
  76038. * Public members
  76039. */
  76040. /**
  76041. * Post-process which contains the original scene color before the pipeline applies all the effects
  76042. */
  76043. originalPostProcess: Nullable<PostProcess>;
  76044. /**
  76045. * Post-process used to down scale an image x4
  76046. */
  76047. downSampleX4PostProcess: Nullable<PostProcess>;
  76048. /**
  76049. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  76050. */
  76051. brightPassPostProcess: Nullable<PostProcess>;
  76052. /**
  76053. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  76054. */
  76055. blurHPostProcesses: PostProcess[];
  76056. /**
  76057. * Post-process array storing all the vertical blur post-processes used by the pipeline
  76058. */
  76059. blurVPostProcesses: PostProcess[];
  76060. /**
  76061. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  76062. */
  76063. textureAdderPostProcess: Nullable<PostProcess>;
  76064. /**
  76065. * Post-process used to create volumetric lighting effect
  76066. */
  76067. volumetricLightPostProcess: Nullable<PostProcess>;
  76068. /**
  76069. * Post-process used to smooth the previous volumetric light post-process on the X axis
  76070. */
  76071. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  76072. /**
  76073. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  76074. */
  76075. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  76076. /**
  76077. * Post-process used to merge the volumetric light effect and the real scene color
  76078. */
  76079. volumetricLightMergePostProces: Nullable<PostProcess>;
  76080. /**
  76081. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  76082. */
  76083. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  76084. /**
  76085. * Base post-process used to calculate the average luminance of the final image for HDR
  76086. */
  76087. luminancePostProcess: Nullable<PostProcess>;
  76088. /**
  76089. * Post-processes used to create down sample post-processes in order to get
  76090. * the average luminance of the final image for HDR
  76091. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  76092. */
  76093. luminanceDownSamplePostProcesses: PostProcess[];
  76094. /**
  76095. * Post-process used to create a HDR effect (light adaptation)
  76096. */
  76097. hdrPostProcess: Nullable<PostProcess>;
  76098. /**
  76099. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  76100. */
  76101. textureAdderFinalPostProcess: Nullable<PostProcess>;
  76102. /**
  76103. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  76104. */
  76105. lensFlareFinalPostProcess: Nullable<PostProcess>;
  76106. /**
  76107. * Post-process used to merge the final HDR post-process and the real scene color
  76108. */
  76109. hdrFinalPostProcess: Nullable<PostProcess>;
  76110. /**
  76111. * Post-process used to create a lens flare effect
  76112. */
  76113. lensFlarePostProcess: Nullable<PostProcess>;
  76114. /**
  76115. * Post-process that merges the result of the lens flare post-process and the real scene color
  76116. */
  76117. lensFlareComposePostProcess: Nullable<PostProcess>;
  76118. /**
  76119. * Post-process used to create a motion blur effect
  76120. */
  76121. motionBlurPostProcess: Nullable<PostProcess>;
  76122. /**
  76123. * Post-process used to create a depth of field effect
  76124. */
  76125. depthOfFieldPostProcess: Nullable<PostProcess>;
  76126. /**
  76127. * The Fast Approximate Anti-Aliasing post process which attempts to remove aliasing from an image.
  76128. */
  76129. fxaaPostProcess: Nullable<FxaaPostProcess>;
  76130. /**
  76131. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  76132. */
  76133. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  76134. /**
  76135. * Represents the brightness threshold in order to configure the illuminated surfaces
  76136. */
  76137. brightThreshold: number;
  76138. /**
  76139. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  76140. */
  76141. blurWidth: number;
  76142. /**
  76143. * Sets if the blur for highlighted surfaces must be only horizontal
  76144. */
  76145. horizontalBlur: boolean;
  76146. /**
  76147. * Gets the overall exposure used by the pipeline
  76148. */
  76149. get exposure(): number;
  76150. /**
  76151. * Sets the overall exposure used by the pipeline
  76152. */
  76153. set exposure(value: number);
  76154. /**
  76155. * Texture used typically to simulate "dirty" on camera lens
  76156. */
  76157. lensTexture: Nullable<Texture>;
  76158. /**
  76159. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  76160. */
  76161. volumetricLightCoefficient: number;
  76162. /**
  76163. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  76164. */
  76165. volumetricLightPower: number;
  76166. /**
  76167. * Used the set the blur intensity to smooth the volumetric lights
  76168. */
  76169. volumetricLightBlurScale: number;
  76170. /**
  76171. * Light (spot or directional) used to generate the volumetric lights rays
  76172. * The source light must have a shadow generate so the pipeline can get its
  76173. * depth map
  76174. */
  76175. sourceLight: Nullable<SpotLight | DirectionalLight>;
  76176. /**
  76177. * For eye adaptation, represents the minimum luminance the eye can see
  76178. */
  76179. hdrMinimumLuminance: number;
  76180. /**
  76181. * For eye adaptation, represents the decrease luminance speed
  76182. */
  76183. hdrDecreaseRate: number;
  76184. /**
  76185. * For eye adaptation, represents the increase luminance speed
  76186. */
  76187. hdrIncreaseRate: number;
  76188. /**
  76189. * Gets whether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76190. */
  76191. get hdrAutoExposure(): boolean;
  76192. /**
  76193. * Sets whether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76194. */
  76195. set hdrAutoExposure(value: boolean);
  76196. /**
  76197. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  76198. */
  76199. lensColorTexture: Nullable<Texture>;
  76200. /**
  76201. * The overall strengh for the lens flare effect
  76202. */
  76203. lensFlareStrength: number;
  76204. /**
  76205. * Dispersion coefficient for lens flare ghosts
  76206. */
  76207. lensFlareGhostDispersal: number;
  76208. /**
  76209. * Main lens flare halo width
  76210. */
  76211. lensFlareHaloWidth: number;
  76212. /**
  76213. * Based on the lens distortion effect, defines how much the lens flare result
  76214. * is distorted
  76215. */
  76216. lensFlareDistortionStrength: number;
  76217. /**
  76218. * Configures the blur intensity used for for lens flare (halo)
  76219. */
  76220. lensFlareBlurWidth: number;
  76221. /**
  76222. * Lens star texture must be used to simulate rays on the flares and is available
  76223. * in the documentation
  76224. */
  76225. lensStarTexture: Nullable<Texture>;
  76226. /**
  76227. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  76228. * flare effect by taking account of the dirt texture
  76229. */
  76230. lensFlareDirtTexture: Nullable<Texture>;
  76231. /**
  76232. * Represents the focal length for the depth of field effect
  76233. */
  76234. depthOfFieldDistance: number;
  76235. /**
  76236. * Represents the blur intensity for the blurred part of the depth of field effect
  76237. */
  76238. depthOfFieldBlurWidth: number;
  76239. /**
  76240. * Gets how much the image is blurred by the movement while using the motion blur post-process
  76241. */
  76242. get motionStrength(): number;
  76243. /**
  76244. * Sets how much the image is blurred by the movement while using the motion blur post-process
  76245. */
  76246. set motionStrength(strength: number);
  76247. /**
  76248. * Gets whether or not the motion blur post-process is object based or screen based.
  76249. */
  76250. get objectBasedMotionBlur(): boolean;
  76251. /**
  76252. * Sets whether or not the motion blur post-process should be object based or screen based
  76253. */
  76254. set objectBasedMotionBlur(value: boolean);
  76255. /**
  76256. * List of animations for the pipeline (IAnimatable implementation)
  76257. */
  76258. animations: Animation[];
  76259. /**
  76260. * Private members
  76261. */
  76262. private _scene;
  76263. private _currentDepthOfFieldSource;
  76264. private _basePostProcess;
  76265. private _fixedExposure;
  76266. private _currentExposure;
  76267. private _hdrAutoExposure;
  76268. private _hdrCurrentLuminance;
  76269. private _motionStrength;
  76270. private _isObjectBasedMotionBlur;
  76271. private _floatTextureType;
  76272. private _camerasToBeAttached;
  76273. private _ratio;
  76274. private _bloomEnabled;
  76275. private _depthOfFieldEnabled;
  76276. private _vlsEnabled;
  76277. private _lensFlareEnabled;
  76278. private _hdrEnabled;
  76279. private _motionBlurEnabled;
  76280. private _fxaaEnabled;
  76281. private _screenSpaceReflectionsEnabled;
  76282. private _motionBlurSamples;
  76283. private _volumetricLightStepsCount;
  76284. private _samples;
  76285. /**
  76286. * @ignore
  76287. * Specifies if the bloom pipeline is enabled
  76288. */
  76289. get BloomEnabled(): boolean;
  76290. set BloomEnabled(enabled: boolean);
  76291. /**
  76292. * @ignore
  76293. * Specifies if the depth of field pipeline is enabled
  76294. */
  76295. get DepthOfFieldEnabled(): boolean;
  76296. set DepthOfFieldEnabled(enabled: boolean);
  76297. /**
  76298. * @ignore
  76299. * Specifies if the lens flare pipeline is enabled
  76300. */
  76301. get LensFlareEnabled(): boolean;
  76302. set LensFlareEnabled(enabled: boolean);
  76303. /**
  76304. * @ignore
  76305. * Specifies if the HDR pipeline is enabled
  76306. */
  76307. get HDREnabled(): boolean;
  76308. set HDREnabled(enabled: boolean);
  76309. /**
  76310. * @ignore
  76311. * Specifies if the volumetric lights scattering effect is enabled
  76312. */
  76313. get VLSEnabled(): boolean;
  76314. set VLSEnabled(enabled: boolean);
  76315. /**
  76316. * @ignore
  76317. * Specifies if the motion blur effect is enabled
  76318. */
  76319. get MotionBlurEnabled(): boolean;
  76320. set MotionBlurEnabled(enabled: boolean);
  76321. /**
  76322. * Specifies if anti-aliasing is enabled
  76323. */
  76324. get fxaaEnabled(): boolean;
  76325. set fxaaEnabled(enabled: boolean);
  76326. /**
  76327. * Specifies if screen space reflections are enabled.
  76328. */
  76329. get screenSpaceReflectionsEnabled(): boolean;
  76330. set screenSpaceReflectionsEnabled(enabled: boolean);
  76331. /**
  76332. * Specifies the number of steps used to calculate the volumetric lights
  76333. * Typically in interval [50, 200]
  76334. */
  76335. get volumetricLightStepsCount(): number;
  76336. set volumetricLightStepsCount(count: number);
  76337. /**
  76338. * Specifies the number of samples used for the motion blur effect
  76339. * Typically in interval [16, 64]
  76340. */
  76341. get motionBlurSamples(): number;
  76342. set motionBlurSamples(samples: number);
  76343. /**
  76344. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  76345. */
  76346. get samples(): number;
  76347. set samples(sampleCount: number);
  76348. /**
  76349. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76350. * @constructor
  76351. * @param name The rendering pipeline name
  76352. * @param scene The scene linked to this pipeline
  76353. * @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)
  76354. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  76355. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76356. */
  76357. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  76358. private _buildPipeline;
  76359. private _createDownSampleX4PostProcess;
  76360. private _createBrightPassPostProcess;
  76361. private _createBlurPostProcesses;
  76362. private _createTextureAdderPostProcess;
  76363. private _createVolumetricLightPostProcess;
  76364. private _createLuminancePostProcesses;
  76365. private _createHdrPostProcess;
  76366. private _createLensFlarePostProcess;
  76367. private _createDepthOfFieldPostProcess;
  76368. private _createMotionBlurPostProcess;
  76369. private _getDepthTexture;
  76370. private _disposePostProcesses;
  76371. /**
  76372. * Dispose of the pipeline and stop all post processes
  76373. */
  76374. dispose(): void;
  76375. /**
  76376. * Serialize the rendering pipeline (Used when exporting)
  76377. * @returns the serialized object
  76378. */
  76379. serialize(): any;
  76380. /**
  76381. * Parse the serialized pipeline
  76382. * @param source Source pipeline.
  76383. * @param scene The scene to load the pipeline to.
  76384. * @param rootUrl The URL of the serialized pipeline.
  76385. * @returns An instantiated pipeline from the serialized object.
  76386. */
  76387. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  76388. /**
  76389. * Luminance steps
  76390. */
  76391. static LuminanceSteps: number;
  76392. }
  76393. }
  76394. declare module BABYLON {
  76395. /** @hidden */
  76396. export var tonemapPixelShader: {
  76397. name: string;
  76398. shader: string;
  76399. };
  76400. }
  76401. declare module BABYLON {
  76402. /** Defines operator used for tonemapping */
  76403. export enum TonemappingOperator {
  76404. /** Hable */
  76405. Hable = 0,
  76406. /** Reinhard */
  76407. Reinhard = 1,
  76408. /** HejiDawson */
  76409. HejiDawson = 2,
  76410. /** Photographic */
  76411. Photographic = 3
  76412. }
  76413. /**
  76414. * Defines a post process to apply tone mapping
  76415. */
  76416. export class TonemapPostProcess extends PostProcess {
  76417. private _operator;
  76418. /** Defines the required exposure adjustment */
  76419. exposureAdjustment: number;
  76420. /**
  76421. * Gets a string identifying the name of the class
  76422. * @returns "TonemapPostProcess" string
  76423. */
  76424. getClassName(): string;
  76425. /**
  76426. * Creates a new TonemapPostProcess
  76427. * @param name defines the name of the postprocess
  76428. * @param _operator defines the operator to use
  76429. * @param exposureAdjustment defines the required exposure adjustement
  76430. * @param camera defines the camera to use (can be null)
  76431. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  76432. * @param engine defines the hosting engine (can be ignore if camera is set)
  76433. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76434. */
  76435. constructor(name: string, _operator: TonemappingOperator,
  76436. /** Defines the required exposure adjustment */
  76437. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  76438. }
  76439. }
  76440. declare module BABYLON {
  76441. /** @hidden */
  76442. export var volumetricLightScatteringPixelShader: {
  76443. name: string;
  76444. shader: string;
  76445. };
  76446. }
  76447. declare module BABYLON {
  76448. /** @hidden */
  76449. export var volumetricLightScatteringPassVertexShader: {
  76450. name: string;
  76451. shader: string;
  76452. };
  76453. }
  76454. declare module BABYLON {
  76455. /** @hidden */
  76456. export var volumetricLightScatteringPassPixelShader: {
  76457. name: string;
  76458. shader: string;
  76459. };
  76460. }
  76461. declare module BABYLON {
  76462. /**
  76463. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  76464. */
  76465. export class VolumetricLightScatteringPostProcess extends PostProcess {
  76466. private _volumetricLightScatteringPass;
  76467. private _volumetricLightScatteringRTT;
  76468. private _viewPort;
  76469. private _screenCoordinates;
  76470. private _cachedDefines;
  76471. /**
  76472. * If not undefined, the mesh position is computed from the attached node position
  76473. */
  76474. attachedNode: {
  76475. position: Vector3;
  76476. };
  76477. /**
  76478. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  76479. */
  76480. customMeshPosition: Vector3;
  76481. /**
  76482. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  76483. */
  76484. useCustomMeshPosition: boolean;
  76485. /**
  76486. * If the post-process should inverse the light scattering direction
  76487. */
  76488. invert: boolean;
  76489. /**
  76490. * The internal mesh used by the post-process
  76491. */
  76492. mesh: Mesh;
  76493. /**
  76494. * @hidden
  76495. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  76496. */
  76497. get useDiffuseColor(): boolean;
  76498. set useDiffuseColor(useDiffuseColor: boolean);
  76499. /**
  76500. * Array containing the excluded meshes not rendered in the internal pass
  76501. */
  76502. excludedMeshes: AbstractMesh[];
  76503. /**
  76504. * Controls the overall intensity of the post-process
  76505. */
  76506. exposure: number;
  76507. /**
  76508. * Dissipates each sample's contribution in range [0, 1]
  76509. */
  76510. decay: number;
  76511. /**
  76512. * Controls the overall intensity of each sample
  76513. */
  76514. weight: number;
  76515. /**
  76516. * Controls the density of each sample
  76517. */
  76518. density: number;
  76519. /**
  76520. * @constructor
  76521. * @param name The post-process name
  76522. * @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)
  76523. * @param camera The camera that the post-process will be attached to
  76524. * @param mesh The mesh used to create the light scattering
  76525. * @param samples The post-process quality, default 100
  76526. * @param samplingModeThe post-process filtering mode
  76527. * @param engine The babylon engine
  76528. * @param reusable If the post-process is reusable
  76529. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  76530. */
  76531. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  76532. /**
  76533. * Returns the string "VolumetricLightScatteringPostProcess"
  76534. * @returns "VolumetricLightScatteringPostProcess"
  76535. */
  76536. getClassName(): string;
  76537. private _isReady;
  76538. /**
  76539. * Sets the new light position for light scattering effect
  76540. * @param position The new custom light position
  76541. */
  76542. setCustomMeshPosition(position: Vector3): void;
  76543. /**
  76544. * Returns the light position for light scattering effect
  76545. * @return Vector3 The custom light position
  76546. */
  76547. getCustomMeshPosition(): Vector3;
  76548. /**
  76549. * Disposes the internal assets and detaches the post-process from the camera
  76550. */
  76551. dispose(camera: Camera): void;
  76552. /**
  76553. * Returns the render target texture used by the post-process
  76554. * @return the render target texture used by the post-process
  76555. */
  76556. getPass(): RenderTargetTexture;
  76557. private _meshExcluded;
  76558. private _createPass;
  76559. private _updateMeshScreenCoordinates;
  76560. /**
  76561. * Creates a default mesh for the Volumeric Light Scattering post-process
  76562. * @param name The mesh name
  76563. * @param scene The scene where to create the mesh
  76564. * @return the default mesh
  76565. */
  76566. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  76567. }
  76568. }
  76569. declare module BABYLON {
  76570. /** @hidden */
  76571. export var screenSpaceCurvaturePixelShader: {
  76572. name: string;
  76573. shader: string;
  76574. };
  76575. }
  76576. declare module BABYLON {
  76577. /**
  76578. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  76579. */
  76580. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  76581. /**
  76582. * Defines how much ridge the curvature effect displays.
  76583. */
  76584. ridge: number;
  76585. /**
  76586. * Defines how much valley the curvature effect displays.
  76587. */
  76588. valley: number;
  76589. private _geometryBufferRenderer;
  76590. /**
  76591. * Gets a string identifying the name of the class
  76592. * @returns "ScreenSpaceCurvaturePostProcess" string
  76593. */
  76594. getClassName(): string;
  76595. /**
  76596. * Creates a new instance ScreenSpaceCurvaturePostProcess
  76597. * @param name The name of the effect.
  76598. * @param scene The scene containing the objects to blur according to their velocity.
  76599. * @param options The required width/height ratio to downsize to before computing the render pass.
  76600. * @param camera The camera to apply the render pass to.
  76601. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76602. * @param engine The engine which the post process will be applied. (default: current engine)
  76603. * @param reusable If the post process can be reused on the same frame. (default: false)
  76604. * @param textureType Type of textures used when performing the post process. (default: 0)
  76605. * @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)
  76606. */
  76607. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  76608. /**
  76609. * Support test.
  76610. */
  76611. static get IsSupported(): boolean;
  76612. /** @hidden */
  76613. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  76614. }
  76615. }
  76616. declare module BABYLON {
  76617. interface Scene {
  76618. /** @hidden (Backing field) */
  76619. _boundingBoxRenderer: BoundingBoxRenderer;
  76620. /** @hidden (Backing field) */
  76621. _forceShowBoundingBoxes: boolean;
  76622. /**
  76623. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  76624. */
  76625. forceShowBoundingBoxes: boolean;
  76626. /**
  76627. * Gets the bounding box renderer associated with the scene
  76628. * @returns a BoundingBoxRenderer
  76629. */
  76630. getBoundingBoxRenderer(): BoundingBoxRenderer;
  76631. }
  76632. interface AbstractMesh {
  76633. /** @hidden (Backing field) */
  76634. _showBoundingBox: boolean;
  76635. /**
  76636. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  76637. */
  76638. showBoundingBox: boolean;
  76639. }
  76640. /**
  76641. * Component responsible of rendering the bounding box of the meshes in a scene.
  76642. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  76643. */
  76644. export class BoundingBoxRenderer implements ISceneComponent {
  76645. /**
  76646. * The component name helpful to identify the component in the list of scene components.
  76647. */
  76648. readonly name: string;
  76649. /**
  76650. * The scene the component belongs to.
  76651. */
  76652. scene: Scene;
  76653. /**
  76654. * Color of the bounding box lines placed in front of an object
  76655. */
  76656. frontColor: Color3;
  76657. /**
  76658. * Color of the bounding box lines placed behind an object
  76659. */
  76660. backColor: Color3;
  76661. /**
  76662. * Defines if the renderer should show the back lines or not
  76663. */
  76664. showBackLines: boolean;
  76665. /**
  76666. * Observable raised before rendering a bounding box
  76667. */
  76668. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76669. /**
  76670. * Observable raised after rendering a bounding box
  76671. */
  76672. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76673. /**
  76674. * Observable raised after resources are created
  76675. */
  76676. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  76677. /**
  76678. * When false, no bounding boxes will be rendered
  76679. */
  76680. enabled: boolean;
  76681. /**
  76682. * @hidden
  76683. */
  76684. renderList: SmartArray<BoundingBox>;
  76685. private _colorShader;
  76686. private _vertexBuffers;
  76687. private _indexBuffer;
  76688. private _fillIndexBuffer;
  76689. private _fillIndexData;
  76690. /**
  76691. * Instantiates a new bounding box renderer in a scene.
  76692. * @param scene the scene the renderer renders in
  76693. */
  76694. constructor(scene: Scene);
  76695. /**
  76696. * Registers the component in a given scene
  76697. */
  76698. register(): void;
  76699. private _evaluateSubMesh;
  76700. private _preActiveMesh;
  76701. private _prepareResources;
  76702. private _createIndexBuffer;
  76703. /**
  76704. * Rebuilds the elements related to this component in case of
  76705. * context lost for instance.
  76706. */
  76707. rebuild(): void;
  76708. /**
  76709. * @hidden
  76710. */
  76711. reset(): void;
  76712. /**
  76713. * Render the bounding boxes of a specific rendering group
  76714. * @param renderingGroupId defines the rendering group to render
  76715. */
  76716. render(renderingGroupId: number): void;
  76717. /**
  76718. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76719. * @param mesh Define the mesh to render the occlusion bounding box for
  76720. */
  76721. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76722. /**
  76723. * Dispose and release the resources attached to this renderer.
  76724. */
  76725. dispose(): void;
  76726. }
  76727. }
  76728. declare module BABYLON {
  76729. interface Scene {
  76730. /** @hidden (Backing field) */
  76731. _depthRenderer: {
  76732. [id: string]: DepthRenderer;
  76733. };
  76734. /**
  76735. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76736. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76737. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76738. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76739. * @returns the created depth renderer
  76740. */
  76741. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76742. /**
  76743. * Disables a depth renderer for a given camera
  76744. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76745. */
  76746. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76747. }
  76748. /**
  76749. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76750. * in several rendering techniques.
  76751. */
  76752. export class DepthRendererSceneComponent implements ISceneComponent {
  76753. /**
  76754. * The component name helpful to identify the component in the list of scene components.
  76755. */
  76756. readonly name: string;
  76757. /**
  76758. * The scene the component belongs to.
  76759. */
  76760. scene: Scene;
  76761. /**
  76762. * Creates a new instance of the component for the given scene
  76763. * @param scene Defines the scene to register the component in
  76764. */
  76765. constructor(scene: Scene);
  76766. /**
  76767. * Registers the component in a given scene
  76768. */
  76769. register(): void;
  76770. /**
  76771. * Rebuilds the elements related to this component in case of
  76772. * context lost for instance.
  76773. */
  76774. rebuild(): void;
  76775. /**
  76776. * Disposes the component and the associated resources
  76777. */
  76778. dispose(): void;
  76779. private _gatherRenderTargets;
  76780. private _gatherActiveCameraRenderTargets;
  76781. }
  76782. }
  76783. declare module BABYLON {
  76784. interface AbstractScene {
  76785. /** @hidden (Backing field) */
  76786. _prePassRenderer: Nullable<PrePassRenderer>;
  76787. /**
  76788. * Gets or Sets the current prepass renderer associated to the scene.
  76789. */
  76790. prePassRenderer: Nullable<PrePassRenderer>;
  76791. /**
  76792. * Enables the prepass and associates it with the scene
  76793. * @returns the PrePassRenderer
  76794. */
  76795. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76796. /**
  76797. * Disables the prepass associated with the scene
  76798. */
  76799. disablePrePassRenderer(): void;
  76800. }
  76801. interface RenderTargetTexture {
  76802. /** @hidden */
  76803. _prePassRenderTarget: PrePassRenderTarget;
  76804. }
  76805. /**
  76806. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76807. * in several rendering techniques.
  76808. */
  76809. export class PrePassRendererSceneComponent implements ISceneComponent {
  76810. /**
  76811. * The component name helpful to identify the component in the list of scene components.
  76812. */
  76813. readonly name: string;
  76814. /**
  76815. * The scene the component belongs to.
  76816. */
  76817. scene: Scene;
  76818. /**
  76819. * Creates a new instance of the component for the given scene
  76820. * @param scene Defines the scene to register the component in
  76821. */
  76822. constructor(scene: Scene);
  76823. /**
  76824. * Registers the component in a given scene
  76825. */
  76826. register(): void;
  76827. private _beforeRenderTargetDraw;
  76828. private _afterRenderTargetDraw;
  76829. private _beforeRenderTargetClearStage;
  76830. private _beforeCameraDraw;
  76831. private _afterCameraDraw;
  76832. private _beforeClearStage;
  76833. private _beforeRenderingMeshStage;
  76834. private _afterRenderingMeshStage;
  76835. /**
  76836. * Rebuilds the elements related to this component in case of
  76837. * context lost for instance.
  76838. */
  76839. rebuild(): void;
  76840. /**
  76841. * Disposes the component and the associated resources
  76842. */
  76843. dispose(): void;
  76844. }
  76845. }
  76846. declare module BABYLON {
  76847. /** @hidden */
  76848. export var fibonacci: {
  76849. name: string;
  76850. shader: string;
  76851. };
  76852. }
  76853. declare module BABYLON {
  76854. /** @hidden */
  76855. export var diffusionProfile: {
  76856. name: string;
  76857. shader: string;
  76858. };
  76859. }
  76860. declare module BABYLON {
  76861. /** @hidden */
  76862. export var subSurfaceScatteringPixelShader: {
  76863. name: string;
  76864. shader: string;
  76865. };
  76866. }
  76867. declare module BABYLON {
  76868. /**
  76869. * Sub surface scattering post process
  76870. */
  76871. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76872. /**
  76873. * Gets a string identifying the name of the class
  76874. * @returns "SubSurfaceScatteringPostProcess" string
  76875. */
  76876. getClassName(): string;
  76877. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76878. }
  76879. }
  76880. declare module BABYLON {
  76881. /**
  76882. * Contains all parameters needed for the prepass to perform
  76883. * screen space subsurface scattering
  76884. */
  76885. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76886. /** @hidden */
  76887. static _SceneComponentInitialization: (scene: Scene) => void;
  76888. private _ssDiffusionS;
  76889. private _ssFilterRadii;
  76890. private _ssDiffusionD;
  76891. /**
  76892. * Post process to attach for screen space subsurface scattering
  76893. */
  76894. postProcess: SubSurfaceScatteringPostProcess;
  76895. /**
  76896. * Diffusion profile color for subsurface scattering
  76897. */
  76898. get ssDiffusionS(): number[];
  76899. /**
  76900. * Diffusion profile max color channel value for subsurface scattering
  76901. */
  76902. get ssDiffusionD(): number[];
  76903. /**
  76904. * Diffusion profile filter radius for subsurface scattering
  76905. */
  76906. get ssFilterRadii(): number[];
  76907. /**
  76908. * Is subsurface enabled
  76909. */
  76910. enabled: boolean;
  76911. /**
  76912. * Does the output of this prepass need to go through imageprocessing
  76913. */
  76914. needsImageProcessing: boolean;
  76915. /**
  76916. * Name of the configuration
  76917. */
  76918. name: string;
  76919. /**
  76920. * Diffusion profile colors for subsurface scattering
  76921. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76922. * See ...
  76923. * Note that you can only store up to 5 of them
  76924. */
  76925. ssDiffusionProfileColors: Color3[];
  76926. /**
  76927. * Defines the ratio real world => scene units.
  76928. * Used for subsurface scattering
  76929. */
  76930. metersPerUnit: number;
  76931. /**
  76932. * Textures that should be present in the MRT for this effect to work
  76933. */
  76934. readonly texturesRequired: number[];
  76935. private _scene;
  76936. /**
  76937. * Builds a subsurface configuration object
  76938. * @param scene The scene
  76939. */
  76940. constructor(scene: Scene);
  76941. /**
  76942. * Adds a new diffusion profile.
  76943. * Useful for more realistic subsurface scattering on diverse materials.
  76944. * @param color The color of the diffusion profile. Should be the average color of the material.
  76945. * @return The index of the diffusion profile for the material subsurface configuration
  76946. */
  76947. addDiffusionProfile(color: Color3): number;
  76948. /**
  76949. * Creates the sss post process
  76950. * @return The created post process
  76951. */
  76952. createPostProcess(): SubSurfaceScatteringPostProcess;
  76953. /**
  76954. * Deletes all diffusion profiles.
  76955. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76956. */
  76957. clearAllDiffusionProfiles(): void;
  76958. /**
  76959. * Disposes this object
  76960. */
  76961. dispose(): void;
  76962. /**
  76963. * @hidden
  76964. * https://zero-radiance.github.io/post/sampling-diffusion/
  76965. *
  76966. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76967. * ------------------------------------------------------------------------------------
  76968. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76969. * PDF[r, phi, s] = r * R[r, phi, s]
  76970. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76971. * ------------------------------------------------------------------------------------
  76972. * We importance sample the color channel with the widest scattering distance.
  76973. */
  76974. getDiffusionProfileParameters(color: Color3): number;
  76975. /**
  76976. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76977. * 'u' is the random number (the value of the CDF): [0, 1).
  76978. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76979. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76980. */
  76981. private _sampleBurleyDiffusionProfile;
  76982. }
  76983. }
  76984. declare module BABYLON {
  76985. interface AbstractScene {
  76986. /** @hidden (Backing field) */
  76987. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76988. /**
  76989. * Gets or Sets the current prepass renderer associated to the scene.
  76990. */
  76991. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76992. /**
  76993. * Enables the subsurface effect for prepass
  76994. * @returns the SubSurfaceConfiguration
  76995. */
  76996. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76997. /**
  76998. * Disables the subsurface effect for prepass
  76999. */
  77000. disableSubSurfaceForPrePass(): void;
  77001. }
  77002. /**
  77003. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  77004. * in several rendering techniques.
  77005. */
  77006. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  77007. /**
  77008. * The component name helpful to identify the component in the list of scene components.
  77009. */
  77010. readonly name: string;
  77011. /**
  77012. * The scene the component belongs to.
  77013. */
  77014. scene: Scene;
  77015. /**
  77016. * Creates a new instance of the component for the given scene
  77017. * @param scene Defines the scene to register the component in
  77018. */
  77019. constructor(scene: Scene);
  77020. /**
  77021. * Registers the component in a given scene
  77022. */
  77023. register(): void;
  77024. /**
  77025. * Serializes the component data to the specified json object
  77026. * @param serializationObject The object to serialize to
  77027. */
  77028. serialize(serializationObject: any): void;
  77029. /**
  77030. * Adds all the elements from the container to the scene
  77031. * @param container the container holding the elements
  77032. */
  77033. addFromContainer(container: AbstractScene): void;
  77034. /**
  77035. * Removes all the elements in the container from the scene
  77036. * @param container contains the elements to remove
  77037. * @param dispose if the removed element should be disposed (default: false)
  77038. */
  77039. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77040. /**
  77041. * Rebuilds the elements related to this component in case of
  77042. * context lost for instance.
  77043. */
  77044. rebuild(): void;
  77045. /**
  77046. * Disposes the component and the associated resources
  77047. */
  77048. dispose(): void;
  77049. }
  77050. }
  77051. declare module BABYLON {
  77052. /** @hidden */
  77053. export var outlinePixelShader: {
  77054. name: string;
  77055. shader: string;
  77056. };
  77057. }
  77058. declare module BABYLON {
  77059. /** @hidden */
  77060. export var outlineVertexShader: {
  77061. name: string;
  77062. shader: string;
  77063. };
  77064. }
  77065. declare module BABYLON {
  77066. interface Scene {
  77067. /** @hidden */
  77068. _outlineRenderer: OutlineRenderer;
  77069. /**
  77070. * Gets the outline renderer associated with the scene
  77071. * @returns a OutlineRenderer
  77072. */
  77073. getOutlineRenderer(): OutlineRenderer;
  77074. }
  77075. interface AbstractMesh {
  77076. /** @hidden (Backing field) */
  77077. _renderOutline: boolean;
  77078. /**
  77079. * Gets or sets a boolean indicating if the outline must be rendered as well
  77080. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  77081. */
  77082. renderOutline: boolean;
  77083. /** @hidden (Backing field) */
  77084. _renderOverlay: boolean;
  77085. /**
  77086. * Gets or sets a boolean indicating if the overlay must be rendered as well
  77087. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  77088. */
  77089. renderOverlay: boolean;
  77090. }
  77091. /**
  77092. * This class is responsible to draw the outline/overlay of meshes.
  77093. * It should not be used directly but through the available method on mesh.
  77094. */
  77095. export class OutlineRenderer implements ISceneComponent {
  77096. /**
  77097. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  77098. */
  77099. private static _StencilReference;
  77100. /**
  77101. * The name of the component. Each component must have a unique name.
  77102. */
  77103. name: string;
  77104. /**
  77105. * The scene the component belongs to.
  77106. */
  77107. scene: Scene;
  77108. /**
  77109. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  77110. */
  77111. zOffset: number;
  77112. private _engine;
  77113. private _effect;
  77114. private _cachedDefines;
  77115. private _savedDepthWrite;
  77116. /**
  77117. * Instantiates a new outline renderer. (There could be only one per scene).
  77118. * @param scene Defines the scene it belongs to
  77119. */
  77120. constructor(scene: Scene);
  77121. /**
  77122. * Register the component to one instance of a scene.
  77123. */
  77124. register(): void;
  77125. /**
  77126. * Rebuilds the elements related to this component in case of
  77127. * context lost for instance.
  77128. */
  77129. rebuild(): void;
  77130. /**
  77131. * Disposes the component and the associated resources.
  77132. */
  77133. dispose(): void;
  77134. /**
  77135. * Renders the outline in the canvas.
  77136. * @param subMesh Defines the sumesh to render
  77137. * @param batch Defines the batch of meshes in case of instances
  77138. * @param useOverlay Defines if the rendering is for the overlay or the outline
  77139. */
  77140. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  77141. /**
  77142. * Returns whether or not the outline renderer is ready for a given submesh.
  77143. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  77144. * @param subMesh Defines the submesh to check readiness for
  77145. * @param useInstances Defines whether wee are trying to render instances or not
  77146. * @returns true if ready otherwise false
  77147. */
  77148. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77149. private _beforeRenderingMesh;
  77150. private _afterRenderingMesh;
  77151. }
  77152. }
  77153. declare module BABYLON {
  77154. /**
  77155. * Defines the basic options interface of a Sprite Frame Source Size.
  77156. */
  77157. export interface ISpriteJSONSpriteSourceSize {
  77158. /**
  77159. * number of the original width of the Frame
  77160. */
  77161. w: number;
  77162. /**
  77163. * number of the original height of the Frame
  77164. */
  77165. h: number;
  77166. }
  77167. /**
  77168. * Defines the basic options interface of a Sprite Frame Data.
  77169. */
  77170. export interface ISpriteJSONSpriteFrameData {
  77171. /**
  77172. * number of the x offset of the Frame
  77173. */
  77174. x: number;
  77175. /**
  77176. * number of the y offset of the Frame
  77177. */
  77178. y: number;
  77179. /**
  77180. * number of the width of the Frame
  77181. */
  77182. w: number;
  77183. /**
  77184. * number of the height of the Frame
  77185. */
  77186. h: number;
  77187. }
  77188. /**
  77189. * Defines the basic options interface of a JSON Sprite.
  77190. */
  77191. export interface ISpriteJSONSprite {
  77192. /**
  77193. * string name of the Frame
  77194. */
  77195. filename: string;
  77196. /**
  77197. * ISpriteJSONSpriteFrame basic object of the frame data
  77198. */
  77199. frame: ISpriteJSONSpriteFrameData;
  77200. /**
  77201. * boolean to flag is the frame was rotated.
  77202. */
  77203. rotated: boolean;
  77204. /**
  77205. * boolean to flag is the frame was trimmed.
  77206. */
  77207. trimmed: boolean;
  77208. /**
  77209. * ISpriteJSONSpriteFrame basic object of the source data
  77210. */
  77211. spriteSourceSize: ISpriteJSONSpriteFrameData;
  77212. /**
  77213. * ISpriteJSONSpriteFrame basic object of the source data
  77214. */
  77215. sourceSize: ISpriteJSONSpriteSourceSize;
  77216. }
  77217. /**
  77218. * Defines the basic options interface of a JSON atlas.
  77219. */
  77220. export interface ISpriteJSONAtlas {
  77221. /**
  77222. * Array of objects that contain the frame data.
  77223. */
  77224. frames: Array<ISpriteJSONSprite>;
  77225. /**
  77226. * object basic object containing the sprite meta data.
  77227. */
  77228. meta?: object;
  77229. }
  77230. }
  77231. declare module BABYLON {
  77232. /** @hidden */
  77233. export var spriteMapPixelShader: {
  77234. name: string;
  77235. shader: string;
  77236. };
  77237. }
  77238. declare module BABYLON {
  77239. /** @hidden */
  77240. export var spriteMapVertexShader: {
  77241. name: string;
  77242. shader: string;
  77243. };
  77244. }
  77245. declare module BABYLON {
  77246. /**
  77247. * Defines the basic options interface of a SpriteMap
  77248. */
  77249. export interface ISpriteMapOptions {
  77250. /**
  77251. * Vector2 of the number of cells in the grid.
  77252. */
  77253. stageSize?: Vector2;
  77254. /**
  77255. * Vector2 of the size of the output plane in World Units.
  77256. */
  77257. outputSize?: Vector2;
  77258. /**
  77259. * Vector3 of the position of the output plane in World Units.
  77260. */
  77261. outputPosition?: Vector3;
  77262. /**
  77263. * Vector3 of the rotation of the output plane.
  77264. */
  77265. outputRotation?: Vector3;
  77266. /**
  77267. * number of layers that the system will reserve in resources.
  77268. */
  77269. layerCount?: number;
  77270. /**
  77271. * number of max animation frames a single cell will reserve in resources.
  77272. */
  77273. maxAnimationFrames?: number;
  77274. /**
  77275. * number cell index of the base tile when the system compiles.
  77276. */
  77277. baseTile?: number;
  77278. /**
  77279. * boolean flip the sprite after its been repositioned by the framing data.
  77280. */
  77281. flipU?: boolean;
  77282. /**
  77283. * Vector3 scalar of the global RGB values of the SpriteMap.
  77284. */
  77285. colorMultiply?: Vector3;
  77286. }
  77287. /**
  77288. * Defines the IDisposable interface in order to be cleanable from resources.
  77289. */
  77290. export interface ISpriteMap extends IDisposable {
  77291. /**
  77292. * String name of the SpriteMap.
  77293. */
  77294. name: string;
  77295. /**
  77296. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  77297. */
  77298. atlasJSON: ISpriteJSONAtlas;
  77299. /**
  77300. * Texture of the SpriteMap.
  77301. */
  77302. spriteSheet: Texture;
  77303. /**
  77304. * The parameters to initialize the SpriteMap with.
  77305. */
  77306. options: ISpriteMapOptions;
  77307. }
  77308. /**
  77309. * Class used to manage a grid restricted sprite deployment on an Output plane.
  77310. */
  77311. export class SpriteMap implements ISpriteMap {
  77312. /** The Name of the spriteMap */
  77313. name: string;
  77314. /** The JSON file with the frame and meta data */
  77315. atlasJSON: ISpriteJSONAtlas;
  77316. /** The systems Sprite Sheet Texture */
  77317. spriteSheet: Texture;
  77318. /** Arguments passed with the Constructor */
  77319. options: ISpriteMapOptions;
  77320. /** Public Sprite Storage array, parsed from atlasJSON */
  77321. sprites: Array<ISpriteJSONSprite>;
  77322. /** Returns the Number of Sprites in the System */
  77323. get spriteCount(): number;
  77324. /** Returns the Position of Output Plane*/
  77325. get position(): Vector3;
  77326. /** Returns the Position of Output Plane*/
  77327. set position(v: Vector3);
  77328. /** Returns the Rotation of Output Plane*/
  77329. get rotation(): Vector3;
  77330. /** Returns the Rotation of Output Plane*/
  77331. set rotation(v: Vector3);
  77332. /** Sets the AnimationMap*/
  77333. get animationMap(): RawTexture;
  77334. /** Sets the AnimationMap*/
  77335. set animationMap(v: RawTexture);
  77336. /** Scene that the SpriteMap was created in */
  77337. private _scene;
  77338. /** Texture Buffer of Float32 that holds tile frame data*/
  77339. private _frameMap;
  77340. /** Texture Buffers of Float32 that holds tileMap data*/
  77341. private _tileMaps;
  77342. /** Texture Buffer of Float32 that holds Animation Data*/
  77343. private _animationMap;
  77344. /** Custom ShaderMaterial Central to the System*/
  77345. private _material;
  77346. /** Custom ShaderMaterial Central to the System*/
  77347. private _output;
  77348. /** Systems Time Ticker*/
  77349. private _time;
  77350. /**
  77351. * Creates a new SpriteMap
  77352. * @param name defines the SpriteMaps Name
  77353. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  77354. * @param spriteSheet is the Texture that the Sprites are on.
  77355. * @param options a basic deployment configuration
  77356. * @param scene The Scene that the map is deployed on
  77357. */
  77358. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  77359. /**
  77360. * Returns tileID location
  77361. * @returns Vector2 the cell position ID
  77362. */
  77363. getTileID(): Vector2;
  77364. /**
  77365. * Gets the UV location of the mouse over the SpriteMap.
  77366. * @returns Vector2 the UV position of the mouse interaction
  77367. */
  77368. getMousePosition(): Vector2;
  77369. /**
  77370. * Creates the "frame" texture Buffer
  77371. * -------------------------------------
  77372. * Structure of frames
  77373. * "filename": "Falling-Water-2.png",
  77374. * "frame": {"x":69,"y":103,"w":24,"h":32},
  77375. * "rotated": true,
  77376. * "trimmed": true,
  77377. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  77378. * "sourceSize": {"w":32,"h":32}
  77379. * @returns RawTexture of the frameMap
  77380. */
  77381. private _createFrameBuffer;
  77382. /**
  77383. * Creates the tileMap texture Buffer
  77384. * @param buffer normally and array of numbers, or a false to generate from scratch
  77385. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  77386. * @returns RawTexture of the tileMap
  77387. */
  77388. private _createTileBuffer;
  77389. /**
  77390. * Modifies the data of the tileMaps
  77391. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  77392. * @param pos is the iVector2 Coordinates of the Tile
  77393. * @param tile The SpriteIndex of the new Tile
  77394. */
  77395. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  77396. /**
  77397. * Creates the animationMap texture Buffer
  77398. * @param buffer normally and array of numbers, or a false to generate from scratch
  77399. * @returns RawTexture of the animationMap
  77400. */
  77401. private _createTileAnimationBuffer;
  77402. /**
  77403. * Modifies the data of the animationMap
  77404. * @param cellID is the Index of the Sprite
  77405. * @param _frame is the target Animation frame
  77406. * @param toCell is the Target Index of the next frame of the animation
  77407. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  77408. * @param speed is a global scalar of the time variable on the map.
  77409. */
  77410. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  77411. /**
  77412. * Exports the .tilemaps file
  77413. */
  77414. saveTileMaps(): void;
  77415. /**
  77416. * Imports the .tilemaps file
  77417. * @param url of the .tilemaps file
  77418. */
  77419. loadTileMaps(url: string): void;
  77420. /**
  77421. * Release associated resources
  77422. */
  77423. dispose(): void;
  77424. }
  77425. }
  77426. declare module BABYLON {
  77427. /**
  77428. * Class used to manage multiple sprites of different sizes on the same spritesheet
  77429. * @see https://doc.babylonjs.com/babylon101/sprites
  77430. */
  77431. export class SpritePackedManager extends SpriteManager {
  77432. /** defines the packed manager's name */
  77433. name: string;
  77434. /**
  77435. * Creates a new sprite manager from a packed sprite sheet
  77436. * @param name defines the manager's name
  77437. * @param imgUrl defines the sprite sheet url
  77438. * @param capacity defines the maximum allowed number of sprites
  77439. * @param scene defines the hosting scene
  77440. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  77441. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77442. * @param samplingMode defines the sampling mode to use with spritesheet
  77443. * @param fromPacked set to true; do not alter
  77444. */
  77445. constructor(
  77446. /** defines the packed manager's name */
  77447. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  77448. }
  77449. }
  77450. declare module BABYLON {
  77451. /**
  77452. * Defines the list of states available for a task inside a AssetsManager
  77453. */
  77454. export enum AssetTaskState {
  77455. /**
  77456. * Initialization
  77457. */
  77458. INIT = 0,
  77459. /**
  77460. * Running
  77461. */
  77462. RUNNING = 1,
  77463. /**
  77464. * Done
  77465. */
  77466. DONE = 2,
  77467. /**
  77468. * Error
  77469. */
  77470. ERROR = 3
  77471. }
  77472. /**
  77473. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  77474. */
  77475. export abstract class AbstractAssetTask {
  77476. /**
  77477. * Task name
  77478. */ name: string;
  77479. /**
  77480. * Callback called when the task is successful
  77481. */
  77482. onSuccess: (task: any) => void;
  77483. /**
  77484. * Callback called when the task is not successful
  77485. */
  77486. onError: (task: any, message?: string, exception?: any) => void;
  77487. /**
  77488. * Creates a new AssetsManager
  77489. * @param name defines the name of the task
  77490. */
  77491. constructor(
  77492. /**
  77493. * Task name
  77494. */ name: string);
  77495. private _isCompleted;
  77496. private _taskState;
  77497. private _errorObject;
  77498. /**
  77499. * Get if the task is completed
  77500. */
  77501. get isCompleted(): boolean;
  77502. /**
  77503. * Gets the current state of the task
  77504. */
  77505. get taskState(): AssetTaskState;
  77506. /**
  77507. * Gets the current error object (if task is in error)
  77508. */
  77509. get errorObject(): {
  77510. message?: string;
  77511. exception?: any;
  77512. };
  77513. /**
  77514. * Internal only
  77515. * @hidden
  77516. */
  77517. _setErrorObject(message?: string, exception?: any): void;
  77518. /**
  77519. * Execute the current task
  77520. * @param scene defines the scene where you want your assets to be loaded
  77521. * @param onSuccess is a callback called when the task is successfully executed
  77522. * @param onError is a callback called if an error occurs
  77523. */
  77524. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77525. /**
  77526. * Execute the current task
  77527. * @param scene defines the scene where you want your assets to be loaded
  77528. * @param onSuccess is a callback called when the task is successfully executed
  77529. * @param onError is a callback called if an error occurs
  77530. */
  77531. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77532. /**
  77533. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  77534. * This can be used with failed tasks that have the reason for failure fixed.
  77535. */
  77536. reset(): void;
  77537. private onErrorCallback;
  77538. private onDoneCallback;
  77539. }
  77540. /**
  77541. * Define the interface used by progress events raised during assets loading
  77542. */
  77543. export interface IAssetsProgressEvent {
  77544. /**
  77545. * Defines the number of remaining tasks to process
  77546. */
  77547. remainingCount: number;
  77548. /**
  77549. * Defines the total number of tasks
  77550. */
  77551. totalCount: number;
  77552. /**
  77553. * Defines the task that was just processed
  77554. */
  77555. task: AbstractAssetTask;
  77556. }
  77557. /**
  77558. * Class used to share progress information about assets loading
  77559. */
  77560. export class AssetsProgressEvent implements IAssetsProgressEvent {
  77561. /**
  77562. * Defines the number of remaining tasks to process
  77563. */
  77564. remainingCount: number;
  77565. /**
  77566. * Defines the total number of tasks
  77567. */
  77568. totalCount: number;
  77569. /**
  77570. * Defines the task that was just processed
  77571. */
  77572. task: AbstractAssetTask;
  77573. /**
  77574. * Creates a AssetsProgressEvent
  77575. * @param remainingCount defines the number of remaining tasks to process
  77576. * @param totalCount defines the total number of tasks
  77577. * @param task defines the task that was just processed
  77578. */
  77579. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  77580. }
  77581. /**
  77582. * Define a task used by AssetsManager to load assets into a container
  77583. */
  77584. export class ContainerAssetTask extends AbstractAssetTask {
  77585. /**
  77586. * Defines the name of the task
  77587. */
  77588. name: string;
  77589. /**
  77590. * Defines the list of mesh's names you want to load
  77591. */
  77592. meshesNames: any;
  77593. /**
  77594. * Defines the root url to use as a base to load your meshes and associated resources
  77595. */
  77596. rootUrl: string;
  77597. /**
  77598. * Defines the filename or File of the scene to load from
  77599. */
  77600. sceneFilename: string | File;
  77601. /**
  77602. * Get the loaded asset container
  77603. */
  77604. loadedContainer: AssetContainer;
  77605. /**
  77606. * Gets the list of loaded meshes
  77607. */
  77608. loadedMeshes: Array<AbstractMesh>;
  77609. /**
  77610. * Gets the list of loaded particle systems
  77611. */
  77612. loadedParticleSystems: Array<IParticleSystem>;
  77613. /**
  77614. * Gets the list of loaded skeletons
  77615. */
  77616. loadedSkeletons: Array<Skeleton>;
  77617. /**
  77618. * Gets the list of loaded animation groups
  77619. */
  77620. loadedAnimationGroups: Array<AnimationGroup>;
  77621. /**
  77622. * Callback called when the task is successful
  77623. */
  77624. onSuccess: (task: ContainerAssetTask) => void;
  77625. /**
  77626. * Callback called when the task is successful
  77627. */
  77628. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77629. /**
  77630. * Creates a new ContainerAssetTask
  77631. * @param name defines the name of the task
  77632. * @param meshesNames defines the list of mesh's names you want to load
  77633. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77634. * @param sceneFilename defines the filename or File of the scene to load from
  77635. */
  77636. constructor(
  77637. /**
  77638. * Defines the name of the task
  77639. */
  77640. name: string,
  77641. /**
  77642. * Defines the list of mesh's names you want to load
  77643. */
  77644. meshesNames: any,
  77645. /**
  77646. * Defines the root url to use as a base to load your meshes and associated resources
  77647. */
  77648. rootUrl: string,
  77649. /**
  77650. * Defines the filename or File of the scene to load from
  77651. */
  77652. sceneFilename: string | File);
  77653. /**
  77654. * Execute the current task
  77655. * @param scene defines the scene where you want your assets to be loaded
  77656. * @param onSuccess is a callback called when the task is successfully executed
  77657. * @param onError is a callback called if an error occurs
  77658. */
  77659. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77660. }
  77661. /**
  77662. * Define a task used by AssetsManager to load meshes
  77663. */
  77664. export class MeshAssetTask extends AbstractAssetTask {
  77665. /**
  77666. * Defines the name of the task
  77667. */
  77668. name: string;
  77669. /**
  77670. * Defines the list of mesh's names you want to load
  77671. */
  77672. meshesNames: any;
  77673. /**
  77674. * Defines the root url to use as a base to load your meshes and associated resources
  77675. */
  77676. rootUrl: string;
  77677. /**
  77678. * Defines the filename or File of the scene to load from
  77679. */
  77680. sceneFilename: string | File;
  77681. /**
  77682. * Gets the list of loaded meshes
  77683. */
  77684. loadedMeshes: Array<AbstractMesh>;
  77685. /**
  77686. * Gets the list of loaded particle systems
  77687. */
  77688. loadedParticleSystems: Array<IParticleSystem>;
  77689. /**
  77690. * Gets the list of loaded skeletons
  77691. */
  77692. loadedSkeletons: Array<Skeleton>;
  77693. /**
  77694. * Gets the list of loaded animation groups
  77695. */
  77696. loadedAnimationGroups: Array<AnimationGroup>;
  77697. /**
  77698. * Callback called when the task is successful
  77699. */
  77700. onSuccess: (task: MeshAssetTask) => void;
  77701. /**
  77702. * Callback called when the task is successful
  77703. */
  77704. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77705. /**
  77706. * Creates a new MeshAssetTask
  77707. * @param name defines the name of the task
  77708. * @param meshesNames defines the list of mesh's names you want to load
  77709. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77710. * @param sceneFilename defines the filename or File of the scene to load from
  77711. */
  77712. constructor(
  77713. /**
  77714. * Defines the name of the task
  77715. */
  77716. name: string,
  77717. /**
  77718. * Defines the list of mesh's names you want to load
  77719. */
  77720. meshesNames: any,
  77721. /**
  77722. * Defines the root url to use as a base to load your meshes and associated resources
  77723. */
  77724. rootUrl: string,
  77725. /**
  77726. * Defines the filename or File of the scene to load from
  77727. */
  77728. sceneFilename: string | File);
  77729. /**
  77730. * Execute the current task
  77731. * @param scene defines the scene where you want your assets to be loaded
  77732. * @param onSuccess is a callback called when the task is successfully executed
  77733. * @param onError is a callback called if an error occurs
  77734. */
  77735. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77736. }
  77737. /**
  77738. * Define a task used by AssetsManager to load text content
  77739. */
  77740. export class TextFileAssetTask extends AbstractAssetTask {
  77741. /**
  77742. * Defines the name of the task
  77743. */
  77744. name: string;
  77745. /**
  77746. * Defines the location of the file to load
  77747. */
  77748. url: string;
  77749. /**
  77750. * Gets the loaded text string
  77751. */
  77752. text: string;
  77753. /**
  77754. * Callback called when the task is successful
  77755. */
  77756. onSuccess: (task: TextFileAssetTask) => void;
  77757. /**
  77758. * Callback called when the task is successful
  77759. */
  77760. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77761. /**
  77762. * Creates a new TextFileAssetTask object
  77763. * @param name defines the name of the task
  77764. * @param url defines the location of the file to load
  77765. */
  77766. constructor(
  77767. /**
  77768. * Defines the name of the task
  77769. */
  77770. name: string,
  77771. /**
  77772. * Defines the location of the file to load
  77773. */
  77774. url: string);
  77775. /**
  77776. * Execute the current task
  77777. * @param scene defines the scene where you want your assets to be loaded
  77778. * @param onSuccess is a callback called when the task is successfully executed
  77779. * @param onError is a callback called if an error occurs
  77780. */
  77781. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77782. }
  77783. /**
  77784. * Define a task used by AssetsManager to load binary data
  77785. */
  77786. export class BinaryFileAssetTask extends AbstractAssetTask {
  77787. /**
  77788. * Defines the name of the task
  77789. */
  77790. name: string;
  77791. /**
  77792. * Defines the location of the file to load
  77793. */
  77794. url: string;
  77795. /**
  77796. * Gets the lodaded data (as an array buffer)
  77797. */
  77798. data: ArrayBuffer;
  77799. /**
  77800. * Callback called when the task is successful
  77801. */
  77802. onSuccess: (task: BinaryFileAssetTask) => void;
  77803. /**
  77804. * Callback called when the task is successful
  77805. */
  77806. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77807. /**
  77808. * Creates a new BinaryFileAssetTask object
  77809. * @param name defines the name of the new task
  77810. * @param url defines the location of the file to load
  77811. */
  77812. constructor(
  77813. /**
  77814. * Defines the name of the task
  77815. */
  77816. name: string,
  77817. /**
  77818. * Defines the location of the file to load
  77819. */
  77820. url: string);
  77821. /**
  77822. * Execute the current task
  77823. * @param scene defines the scene where you want your assets to be loaded
  77824. * @param onSuccess is a callback called when the task is successfully executed
  77825. * @param onError is a callback called if an error occurs
  77826. */
  77827. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77828. }
  77829. /**
  77830. * Define a task used by AssetsManager to load images
  77831. */
  77832. export class ImageAssetTask extends AbstractAssetTask {
  77833. /**
  77834. * Defines the name of the task
  77835. */
  77836. name: string;
  77837. /**
  77838. * Defines the location of the image to load
  77839. */
  77840. url: string;
  77841. /**
  77842. * Gets the loaded images
  77843. */
  77844. image: HTMLImageElement;
  77845. /**
  77846. * Callback called when the task is successful
  77847. */
  77848. onSuccess: (task: ImageAssetTask) => void;
  77849. /**
  77850. * Callback called when the task is successful
  77851. */
  77852. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77853. /**
  77854. * Creates a new ImageAssetTask
  77855. * @param name defines the name of the task
  77856. * @param url defines the location of the image to load
  77857. */
  77858. constructor(
  77859. /**
  77860. * Defines the name of the task
  77861. */
  77862. name: string,
  77863. /**
  77864. * Defines the location of the image to load
  77865. */
  77866. url: string);
  77867. /**
  77868. * Execute the current task
  77869. * @param scene defines the scene where you want your assets to be loaded
  77870. * @param onSuccess is a callback called when the task is successfully executed
  77871. * @param onError is a callback called if an error occurs
  77872. */
  77873. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77874. }
  77875. /**
  77876. * Defines the interface used by texture loading tasks
  77877. */
  77878. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77879. /**
  77880. * Gets the loaded texture
  77881. */
  77882. texture: TEX;
  77883. }
  77884. /**
  77885. * Define a task used by AssetsManager to load 2D textures
  77886. */
  77887. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77888. /**
  77889. * Defines the name of the task
  77890. */
  77891. name: string;
  77892. /**
  77893. * Defines the location of the file to load
  77894. */
  77895. url: string;
  77896. /**
  77897. * Defines if mipmap should not be generated (default is false)
  77898. */
  77899. noMipmap?: boolean | undefined;
  77900. /**
  77901. * Defines if texture must be inverted on Y axis (default is true)
  77902. */
  77903. invertY: boolean;
  77904. /**
  77905. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77906. */
  77907. samplingMode: number;
  77908. /**
  77909. * Gets the loaded texture
  77910. */
  77911. texture: Texture;
  77912. /**
  77913. * Callback called when the task is successful
  77914. */
  77915. onSuccess: (task: TextureAssetTask) => void;
  77916. /**
  77917. * Callback called when the task is successful
  77918. */
  77919. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77920. /**
  77921. * Creates a new TextureAssetTask object
  77922. * @param name defines the name of the task
  77923. * @param url defines the location of the file to load
  77924. * @param noMipmap defines if mipmap should not be generated (default is false)
  77925. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77926. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77927. */
  77928. constructor(
  77929. /**
  77930. * Defines the name of the task
  77931. */
  77932. name: string,
  77933. /**
  77934. * Defines the location of the file to load
  77935. */
  77936. url: string,
  77937. /**
  77938. * Defines if mipmap should not be generated (default is false)
  77939. */
  77940. noMipmap?: boolean | undefined,
  77941. /**
  77942. * Defines if texture must be inverted on Y axis (default is true)
  77943. */
  77944. invertY?: boolean,
  77945. /**
  77946. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77947. */
  77948. samplingMode?: number);
  77949. /**
  77950. * Execute the current task
  77951. * @param scene defines the scene where you want your assets to be loaded
  77952. * @param onSuccess is a callback called when the task is successfully executed
  77953. * @param onError is a callback called if an error occurs
  77954. */
  77955. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77956. }
  77957. /**
  77958. * Define a task used by AssetsManager to load cube textures
  77959. */
  77960. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77961. /**
  77962. * Defines the name of the task
  77963. */
  77964. name: string;
  77965. /**
  77966. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77967. */
  77968. url: string;
  77969. /**
  77970. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77971. */
  77972. extensions?: string[] | undefined;
  77973. /**
  77974. * Defines if mipmaps should not be generated (default is false)
  77975. */
  77976. noMipmap?: boolean | undefined;
  77977. /**
  77978. * Defines the explicit list of files (undefined by default)
  77979. */
  77980. files?: string[] | undefined;
  77981. /**
  77982. * Gets the loaded texture
  77983. */
  77984. texture: CubeTexture;
  77985. /**
  77986. * Callback called when the task is successful
  77987. */
  77988. onSuccess: (task: CubeTextureAssetTask) => void;
  77989. /**
  77990. * Callback called when the task is successful
  77991. */
  77992. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77993. /**
  77994. * Creates a new CubeTextureAssetTask
  77995. * @param name defines the name of the task
  77996. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77997. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77998. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77999. * @param files defines the explicit list of files (undefined by default)
  78000. */
  78001. constructor(
  78002. /**
  78003. * Defines the name of the task
  78004. */
  78005. name: string,
  78006. /**
  78007. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78008. */
  78009. url: string,
  78010. /**
  78011. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78012. */
  78013. extensions?: string[] | undefined,
  78014. /**
  78015. * Defines if mipmaps should not be generated (default is false)
  78016. */
  78017. noMipmap?: boolean | undefined,
  78018. /**
  78019. * Defines the explicit list of files (undefined by default)
  78020. */
  78021. files?: string[] | undefined);
  78022. /**
  78023. * Execute the current task
  78024. * @param scene defines the scene where you want your assets to be loaded
  78025. * @param onSuccess is a callback called when the task is successfully executed
  78026. * @param onError is a callback called if an error occurs
  78027. */
  78028. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78029. }
  78030. /**
  78031. * Define a task used by AssetsManager to load HDR cube textures
  78032. */
  78033. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  78034. /**
  78035. * Defines the name of the task
  78036. */
  78037. name: string;
  78038. /**
  78039. * Defines the location of the file to load
  78040. */
  78041. url: string;
  78042. /**
  78043. * Defines the desired size (the more it increases the longer the generation will be)
  78044. */
  78045. size: number;
  78046. /**
  78047. * Defines if mipmaps should not be generated (default is false)
  78048. */
  78049. noMipmap: boolean;
  78050. /**
  78051. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78052. */
  78053. generateHarmonics: boolean;
  78054. /**
  78055. * 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)
  78056. */
  78057. gammaSpace: boolean;
  78058. /**
  78059. * Internal Use Only
  78060. */
  78061. reserved: boolean;
  78062. /**
  78063. * Gets the loaded texture
  78064. */
  78065. texture: HDRCubeTexture;
  78066. /**
  78067. * Callback called when the task is successful
  78068. */
  78069. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  78070. /**
  78071. * Callback called when the task is successful
  78072. */
  78073. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  78074. /**
  78075. * Creates a new HDRCubeTextureAssetTask object
  78076. * @param name defines the name of the task
  78077. * @param url defines the location of the file to load
  78078. * @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.
  78079. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78080. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78081. * @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)
  78082. * @param reserved Internal use only
  78083. */
  78084. constructor(
  78085. /**
  78086. * Defines the name of the task
  78087. */
  78088. name: string,
  78089. /**
  78090. * Defines the location of the file to load
  78091. */
  78092. url: string,
  78093. /**
  78094. * Defines the desired size (the more it increases the longer the generation will be)
  78095. */
  78096. size: number,
  78097. /**
  78098. * Defines if mipmaps should not be generated (default is false)
  78099. */
  78100. noMipmap?: boolean,
  78101. /**
  78102. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78103. */
  78104. generateHarmonics?: boolean,
  78105. /**
  78106. * 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)
  78107. */
  78108. gammaSpace?: boolean,
  78109. /**
  78110. * Internal Use Only
  78111. */
  78112. reserved?: boolean);
  78113. /**
  78114. * Execute the current task
  78115. * @param scene defines the scene where you want your assets to be loaded
  78116. * @param onSuccess is a callback called when the task is successfully executed
  78117. * @param onError is a callback called if an error occurs
  78118. */
  78119. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78120. }
  78121. /**
  78122. * Define a task used by AssetsManager to load Equirectangular cube textures
  78123. */
  78124. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  78125. /**
  78126. * Defines the name of the task
  78127. */
  78128. name: string;
  78129. /**
  78130. * Defines the location of the file to load
  78131. */
  78132. url: string;
  78133. /**
  78134. * Defines the desired size (the more it increases the longer the generation will be)
  78135. */
  78136. size: number;
  78137. /**
  78138. * Defines if mipmaps should not be generated (default is false)
  78139. */
  78140. noMipmap: boolean;
  78141. /**
  78142. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78143. * but the standard material would require them in Gamma space) (default is true)
  78144. */
  78145. gammaSpace: boolean;
  78146. /**
  78147. * Gets the loaded texture
  78148. */
  78149. texture: EquiRectangularCubeTexture;
  78150. /**
  78151. * Callback called when the task is successful
  78152. */
  78153. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  78154. /**
  78155. * Callback called when the task is successful
  78156. */
  78157. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  78158. /**
  78159. * Creates a new EquiRectangularCubeTextureAssetTask object
  78160. * @param name defines the name of the task
  78161. * @param url defines the location of the file to load
  78162. * @param size defines the desired size (the more it increases the longer the generation will be)
  78163. * If the size is omitted this implies you are using a preprocessed cubemap.
  78164. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78165. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  78166. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  78167. * (default is true)
  78168. */
  78169. constructor(
  78170. /**
  78171. * Defines the name of the task
  78172. */
  78173. name: string,
  78174. /**
  78175. * Defines the location of the file to load
  78176. */
  78177. url: string,
  78178. /**
  78179. * Defines the desired size (the more it increases the longer the generation will be)
  78180. */
  78181. size: number,
  78182. /**
  78183. * Defines if mipmaps should not be generated (default is false)
  78184. */
  78185. noMipmap?: boolean,
  78186. /**
  78187. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78188. * but the standard material would require them in Gamma space) (default is true)
  78189. */
  78190. gammaSpace?: boolean);
  78191. /**
  78192. * Execute the current task
  78193. * @param scene defines the scene where you want your assets to be loaded
  78194. * @param onSuccess is a callback called when the task is successfully executed
  78195. * @param onError is a callback called if an error occurs
  78196. */
  78197. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78198. }
  78199. /**
  78200. * This class can be used to easily import assets into a scene
  78201. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  78202. */
  78203. export class AssetsManager {
  78204. private _scene;
  78205. private _isLoading;
  78206. protected _tasks: AbstractAssetTask[];
  78207. protected _waitingTasksCount: number;
  78208. protected _totalTasksCount: number;
  78209. /**
  78210. * Callback called when all tasks are processed
  78211. */
  78212. onFinish: (tasks: AbstractAssetTask[]) => void;
  78213. /**
  78214. * Callback called when a task is successful
  78215. */
  78216. onTaskSuccess: (task: AbstractAssetTask) => void;
  78217. /**
  78218. * Callback called when a task had an error
  78219. */
  78220. onTaskError: (task: AbstractAssetTask) => void;
  78221. /**
  78222. * Callback called when a task is done (whatever the result is)
  78223. */
  78224. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  78225. /**
  78226. * Observable called when all tasks are processed
  78227. */
  78228. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  78229. /**
  78230. * Observable called when a task had an error
  78231. */
  78232. onTaskErrorObservable: Observable<AbstractAssetTask>;
  78233. /**
  78234. * Observable called when all tasks were executed
  78235. */
  78236. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  78237. /**
  78238. * Observable called when a task is done (whatever the result is)
  78239. */
  78240. onProgressObservable: Observable<IAssetsProgressEvent>;
  78241. /**
  78242. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  78243. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  78244. */
  78245. useDefaultLoadingScreen: boolean;
  78246. /**
  78247. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  78248. * when all assets have been downloaded.
  78249. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  78250. */
  78251. autoHideLoadingUI: boolean;
  78252. /**
  78253. * Creates a new AssetsManager
  78254. * @param scene defines the scene to work on
  78255. */
  78256. constructor(scene: Scene);
  78257. /**
  78258. * Add a ContainerAssetTask to the list of active tasks
  78259. * @param taskName defines the name of the new task
  78260. * @param meshesNames defines the name of meshes to load
  78261. * @param rootUrl defines the root url to use to locate files
  78262. * @param sceneFilename defines the filename of the scene file
  78263. * @returns a new ContainerAssetTask object
  78264. */
  78265. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  78266. /**
  78267. * Add a MeshAssetTask to the list of active tasks
  78268. * @param taskName defines the name of the new task
  78269. * @param meshesNames defines the name of meshes to load
  78270. * @param rootUrl defines the root url to use to locate files
  78271. * @param sceneFilename defines the filename of the scene file
  78272. * @returns a new MeshAssetTask object
  78273. */
  78274. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  78275. /**
  78276. * Add a TextFileAssetTask to the list of active tasks
  78277. * @param taskName defines the name of the new task
  78278. * @param url defines the url of the file to load
  78279. * @returns a new TextFileAssetTask object
  78280. */
  78281. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  78282. /**
  78283. * Add a BinaryFileAssetTask to the list of active tasks
  78284. * @param taskName defines the name of the new task
  78285. * @param url defines the url of the file to load
  78286. * @returns a new BinaryFileAssetTask object
  78287. */
  78288. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  78289. /**
  78290. * Add a ImageAssetTask to the list of active tasks
  78291. * @param taskName defines the name of the new task
  78292. * @param url defines the url of the file to load
  78293. * @returns a new ImageAssetTask object
  78294. */
  78295. addImageTask(taskName: string, url: string): ImageAssetTask;
  78296. /**
  78297. * Add a TextureAssetTask to the list of active tasks
  78298. * @param taskName defines the name of the new task
  78299. * @param url defines the url of the file to load
  78300. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78301. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  78302. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  78303. * @returns a new TextureAssetTask object
  78304. */
  78305. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  78306. /**
  78307. * Add a CubeTextureAssetTask to the list of active tasks
  78308. * @param taskName defines the name of the new task
  78309. * @param url defines the url of the file to load
  78310. * @param extensions defines the extension to use to load the cube map (can be null)
  78311. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78312. * @param files defines the list of files to load (can be null)
  78313. * @returns a new CubeTextureAssetTask object
  78314. */
  78315. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  78316. /**
  78317. *
  78318. * Add a HDRCubeTextureAssetTask to the list of active tasks
  78319. * @param taskName defines the name of the new task
  78320. * @param url defines the url of the file to load
  78321. * @param size defines the size you want for the cubemap (can be null)
  78322. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78323. * @param generateHarmonics defines if you want to automatically generate (true by default)
  78324. * @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)
  78325. * @param reserved Internal use only
  78326. * @returns a new HDRCubeTextureAssetTask object
  78327. */
  78328. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  78329. /**
  78330. *
  78331. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  78332. * @param taskName defines the name of the new task
  78333. * @param url defines the url of the file to load
  78334. * @param size defines the size you want for the cubemap (can be null)
  78335. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78336. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  78337. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  78338. * @returns a new EquiRectangularCubeTextureAssetTask object
  78339. */
  78340. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  78341. /**
  78342. * Remove a task from the assets manager.
  78343. * @param task the task to remove
  78344. */
  78345. removeTask(task: AbstractAssetTask): void;
  78346. private _decreaseWaitingTasksCount;
  78347. private _runTask;
  78348. /**
  78349. * Reset the AssetsManager and remove all tasks
  78350. * @return the current instance of the AssetsManager
  78351. */
  78352. reset(): AssetsManager;
  78353. /**
  78354. * Start the loading process
  78355. * @return the current instance of the AssetsManager
  78356. */
  78357. load(): AssetsManager;
  78358. /**
  78359. * Start the loading process as an async operation
  78360. * @return a promise returning the list of failed tasks
  78361. */
  78362. loadAsync(): Promise<void>;
  78363. }
  78364. }
  78365. declare module BABYLON {
  78366. /**
  78367. * Wrapper class for promise with external resolve and reject.
  78368. */
  78369. export class Deferred<T> {
  78370. /**
  78371. * The promise associated with this deferred object.
  78372. */
  78373. readonly promise: Promise<T>;
  78374. private _resolve;
  78375. private _reject;
  78376. /**
  78377. * The resolve method of the promise associated with this deferred object.
  78378. */
  78379. get resolve(): (value: T | PromiseLike<T>) => void;
  78380. /**
  78381. * The reject method of the promise associated with this deferred object.
  78382. */
  78383. get reject(): (reason?: any) => void;
  78384. /**
  78385. * Constructor for this deferred object.
  78386. */
  78387. constructor();
  78388. }
  78389. }
  78390. declare module BABYLON {
  78391. /**
  78392. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  78393. */
  78394. export class MeshExploder {
  78395. private _centerMesh;
  78396. private _meshes;
  78397. private _meshesOrigins;
  78398. private _toCenterVectors;
  78399. private _scaledDirection;
  78400. private _newPosition;
  78401. private _centerPosition;
  78402. /**
  78403. * Explodes meshes from a center mesh.
  78404. * @param meshes The meshes to explode.
  78405. * @param centerMesh The mesh to be center of explosion.
  78406. */
  78407. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  78408. private _setCenterMesh;
  78409. /**
  78410. * Get class name
  78411. * @returns "MeshExploder"
  78412. */
  78413. getClassName(): string;
  78414. /**
  78415. * "Exploded meshes"
  78416. * @returns Array of meshes with the centerMesh at index 0.
  78417. */
  78418. getMeshes(): Array<Mesh>;
  78419. /**
  78420. * Explodes meshes giving a specific direction
  78421. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  78422. */
  78423. explode(direction?: number): void;
  78424. }
  78425. }
  78426. declare module BABYLON {
  78427. /**
  78428. * Class used to help managing file picking and drag'n'drop
  78429. */
  78430. export class FilesInput {
  78431. /**
  78432. * List of files ready to be loaded
  78433. */
  78434. static get FilesToLoad(): {
  78435. [key: string]: File;
  78436. };
  78437. /**
  78438. * Callback called when a file is processed
  78439. */
  78440. onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean;
  78441. /**
  78442. * Function used when loading the scene file
  78443. */
  78444. loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene>;
  78445. private _engine;
  78446. private _currentScene;
  78447. private _sceneLoadedCallback;
  78448. private _progressCallback;
  78449. private _additionalRenderLoopLogicCallback;
  78450. private _textureLoadingCallback;
  78451. private _startingProcessingFilesCallback;
  78452. private _onReloadCallback;
  78453. private _errorCallback;
  78454. private _elementToMonitor;
  78455. private _sceneFileToLoad;
  78456. private _filesToLoad;
  78457. /**
  78458. * Creates a new FilesInput
  78459. * @param engine defines the rendering engine
  78460. * @param scene defines the hosting scene
  78461. * @param sceneLoadedCallback callback called when scene is loaded
  78462. * @param progressCallback callback called to track progress
  78463. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  78464. * @param textureLoadingCallback callback called when a texture is loading
  78465. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  78466. * @param onReloadCallback callback called when a reload is requested
  78467. * @param errorCallback callback call if an error occurs
  78468. */
  78469. 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>);
  78470. private _dragEnterHandler;
  78471. private _dragOverHandler;
  78472. private _dropHandler;
  78473. /**
  78474. * Calls this function to listen to drag'n'drop events on a specific DOM element
  78475. * @param elementToMonitor defines the DOM element to track
  78476. */
  78477. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  78478. /** Gets the current list of files to load */
  78479. get filesToLoad(): File[];
  78480. /**
  78481. * Release all associated resources
  78482. */
  78483. dispose(): void;
  78484. private renderFunction;
  78485. private drag;
  78486. private drop;
  78487. private _traverseFolder;
  78488. private _processFiles;
  78489. /**
  78490. * Load files from a drop event
  78491. * @param event defines the drop event to use as source
  78492. */
  78493. loadFiles(event: any): void;
  78494. private _processReload;
  78495. /**
  78496. * Reload the current scene from the loaded files
  78497. */
  78498. reload(): void;
  78499. }
  78500. }
  78501. declare module BABYLON {
  78502. /**
  78503. * Defines the root class used to create scene optimization to use with SceneOptimizer
  78504. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78505. */
  78506. export class SceneOptimization {
  78507. /**
  78508. * Defines the priority of this optimization (0 by default which means first in the list)
  78509. */
  78510. priority: number;
  78511. /**
  78512. * Gets a string describing the action executed by the current optimization
  78513. * @returns description string
  78514. */
  78515. getDescription(): string;
  78516. /**
  78517. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78518. * @param scene defines the current scene where to apply this optimization
  78519. * @param optimizer defines the current optimizer
  78520. * @returns true if everything that can be done was applied
  78521. */
  78522. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78523. /**
  78524. * Creates the SceneOptimization object
  78525. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78526. * @param desc defines the description associated with the optimization
  78527. */
  78528. constructor(
  78529. /**
  78530. * Defines the priority of this optimization (0 by default which means first in the list)
  78531. */
  78532. priority?: number);
  78533. }
  78534. /**
  78535. * Defines an optimization used to reduce the size of render target textures
  78536. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78537. */
  78538. export class TextureOptimization extends SceneOptimization {
  78539. /**
  78540. * Defines the priority of this optimization (0 by default which means first in the list)
  78541. */
  78542. priority: number;
  78543. /**
  78544. * 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
  78545. */
  78546. maximumSize: number;
  78547. /**
  78548. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78549. */
  78550. step: number;
  78551. /**
  78552. * Gets a string describing the action executed by the current optimization
  78553. * @returns description string
  78554. */
  78555. getDescription(): string;
  78556. /**
  78557. * Creates the TextureOptimization object
  78558. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78559. * @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
  78560. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78561. */
  78562. constructor(
  78563. /**
  78564. * Defines the priority of this optimization (0 by default which means first in the list)
  78565. */
  78566. priority?: number,
  78567. /**
  78568. * 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
  78569. */
  78570. maximumSize?: number,
  78571. /**
  78572. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78573. */
  78574. step?: number);
  78575. /**
  78576. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78577. * @param scene defines the current scene where to apply this optimization
  78578. * @param optimizer defines the current optimizer
  78579. * @returns true if everything that can be done was applied
  78580. */
  78581. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78582. }
  78583. /**
  78584. * Defines an optimization used to increase or decrease the rendering resolution
  78585. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78586. */
  78587. export class HardwareScalingOptimization extends SceneOptimization {
  78588. /**
  78589. * Defines the priority of this optimization (0 by default which means first in the list)
  78590. */
  78591. priority: number;
  78592. /**
  78593. * Defines the maximum scale to use (2 by default)
  78594. */
  78595. maximumScale: number;
  78596. /**
  78597. * Defines the step to use between two passes (0.5 by default)
  78598. */
  78599. step: number;
  78600. private _currentScale;
  78601. private _directionOffset;
  78602. /**
  78603. * Gets a string describing the action executed by the current optimization
  78604. * @return description string
  78605. */
  78606. getDescription(): string;
  78607. /**
  78608. * Creates the HardwareScalingOptimization object
  78609. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78610. * @param maximumScale defines the maximum scale to use (2 by default)
  78611. * @param step defines the step to use between two passes (0.5 by default)
  78612. */
  78613. constructor(
  78614. /**
  78615. * Defines the priority of this optimization (0 by default which means first in the list)
  78616. */
  78617. priority?: number,
  78618. /**
  78619. * Defines the maximum scale to use (2 by default)
  78620. */
  78621. maximumScale?: number,
  78622. /**
  78623. * Defines the step to use between two passes (0.5 by default)
  78624. */
  78625. step?: number);
  78626. /**
  78627. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78628. * @param scene defines the current scene where to apply this optimization
  78629. * @param optimizer defines the current optimizer
  78630. * @returns true if everything that can be done was applied
  78631. */
  78632. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78633. }
  78634. /**
  78635. * Defines an optimization used to remove shadows
  78636. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78637. */
  78638. export class ShadowsOptimization extends SceneOptimization {
  78639. /**
  78640. * Gets a string describing the action executed by the current optimization
  78641. * @return description string
  78642. */
  78643. getDescription(): string;
  78644. /**
  78645. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78646. * @param scene defines the current scene where to apply this optimization
  78647. * @param optimizer defines the current optimizer
  78648. * @returns true if everything that can be done was applied
  78649. */
  78650. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78651. }
  78652. /**
  78653. * Defines an optimization used to turn post-processes off
  78654. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78655. */
  78656. export class PostProcessesOptimization extends SceneOptimization {
  78657. /**
  78658. * Gets a string describing the action executed by the current optimization
  78659. * @return description string
  78660. */
  78661. getDescription(): string;
  78662. /**
  78663. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78664. * @param scene defines the current scene where to apply this optimization
  78665. * @param optimizer defines the current optimizer
  78666. * @returns true if everything that can be done was applied
  78667. */
  78668. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78669. }
  78670. /**
  78671. * Defines an optimization used to turn lens flares off
  78672. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78673. */
  78674. export class LensFlaresOptimization extends SceneOptimization {
  78675. /**
  78676. * Gets a string describing the action executed by the current optimization
  78677. * @return description string
  78678. */
  78679. getDescription(): string;
  78680. /**
  78681. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78682. * @param scene defines the current scene where to apply this optimization
  78683. * @param optimizer defines the current optimizer
  78684. * @returns true if everything that can be done was applied
  78685. */
  78686. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78687. }
  78688. /**
  78689. * Defines an optimization based on user defined callback.
  78690. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78691. */
  78692. export class CustomOptimization extends SceneOptimization {
  78693. /**
  78694. * Callback called to apply the custom optimization.
  78695. */
  78696. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78697. /**
  78698. * Callback called to get custom description
  78699. */
  78700. onGetDescription: () => string;
  78701. /**
  78702. * Gets a string describing the action executed by the current optimization
  78703. * @returns description string
  78704. */
  78705. getDescription(): string;
  78706. /**
  78707. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78708. * @param scene defines the current scene where to apply this optimization
  78709. * @param optimizer defines the current optimizer
  78710. * @returns true if everything that can be done was applied
  78711. */
  78712. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78713. }
  78714. /**
  78715. * Defines an optimization used to turn particles off
  78716. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78717. */
  78718. export class ParticlesOptimization extends SceneOptimization {
  78719. /**
  78720. * Gets a string describing the action executed by the current optimization
  78721. * @return description string
  78722. */
  78723. getDescription(): string;
  78724. /**
  78725. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78726. * @param scene defines the current scene where to apply this optimization
  78727. * @param optimizer defines the current optimizer
  78728. * @returns true if everything that can be done was applied
  78729. */
  78730. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78731. }
  78732. /**
  78733. * Defines an optimization used to turn render targets off
  78734. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78735. */
  78736. export class RenderTargetsOptimization extends SceneOptimization {
  78737. /**
  78738. * Gets a string describing the action executed by the current optimization
  78739. * @return description string
  78740. */
  78741. getDescription(): string;
  78742. /**
  78743. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78744. * @param scene defines the current scene where to apply this optimization
  78745. * @param optimizer defines the current optimizer
  78746. * @returns true if everything that can be done was applied
  78747. */
  78748. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78749. }
  78750. /**
  78751. * Defines an optimization used to merge meshes with compatible materials
  78752. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78753. */
  78754. export class MergeMeshesOptimization extends SceneOptimization {
  78755. private static _UpdateSelectionTree;
  78756. /**
  78757. * Gets or sets a boolean which defines if optimization octree has to be updated
  78758. */
  78759. static get UpdateSelectionTree(): boolean;
  78760. /**
  78761. * Gets or sets a boolean which defines if optimization octree has to be updated
  78762. */
  78763. static set UpdateSelectionTree(value: boolean);
  78764. /**
  78765. * Gets a string describing the action executed by the current optimization
  78766. * @return description string
  78767. */
  78768. getDescription(): string;
  78769. private _canBeMerged;
  78770. /**
  78771. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78772. * @param scene defines the current scene where to apply this optimization
  78773. * @param optimizer defines the current optimizer
  78774. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78775. * @returns true if everything that can be done was applied
  78776. */
  78777. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78778. }
  78779. /**
  78780. * Defines a list of options used by SceneOptimizer
  78781. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78782. */
  78783. export class SceneOptimizerOptions {
  78784. /**
  78785. * Defines the target frame rate to reach (60 by default)
  78786. */
  78787. targetFrameRate: number;
  78788. /**
  78789. * Defines the interval between two checks (2000ms by default)
  78790. */
  78791. trackerDuration: number;
  78792. /**
  78793. * Gets the list of optimizations to apply
  78794. */
  78795. optimizations: SceneOptimization[];
  78796. /**
  78797. * Creates a new list of options used by SceneOptimizer
  78798. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78799. * @param trackerDuration defines the interval between two checks (2000ms by default)
  78800. */
  78801. constructor(
  78802. /**
  78803. * Defines the target frame rate to reach (60 by default)
  78804. */
  78805. targetFrameRate?: number,
  78806. /**
  78807. * Defines the interval between two checks (2000ms by default)
  78808. */
  78809. trackerDuration?: number);
  78810. /**
  78811. * Add a new optimization
  78812. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78813. * @returns the current SceneOptimizerOptions
  78814. */
  78815. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78816. /**
  78817. * Add a new custom optimization
  78818. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78819. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78820. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78821. * @returns the current SceneOptimizerOptions
  78822. */
  78823. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78824. /**
  78825. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78826. * @param targetFrameRate defines the target frame rate (60 by default)
  78827. * @returns a SceneOptimizerOptions object
  78828. */
  78829. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78830. /**
  78831. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78832. * @param targetFrameRate defines the target frame rate (60 by default)
  78833. * @returns a SceneOptimizerOptions object
  78834. */
  78835. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78836. /**
  78837. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78838. * @param targetFrameRate defines the target frame rate (60 by default)
  78839. * @returns a SceneOptimizerOptions object
  78840. */
  78841. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78842. }
  78843. /**
  78844. * Class used to run optimizations in order to reach a target frame rate
  78845. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78846. */
  78847. export class SceneOptimizer implements IDisposable {
  78848. private _isRunning;
  78849. private _options;
  78850. private _scene;
  78851. private _currentPriorityLevel;
  78852. private _targetFrameRate;
  78853. private _trackerDuration;
  78854. private _currentFrameRate;
  78855. private _sceneDisposeObserver;
  78856. private _improvementMode;
  78857. /**
  78858. * Defines an observable called when the optimizer reaches the target frame rate
  78859. */
  78860. onSuccessObservable: Observable<SceneOptimizer>;
  78861. /**
  78862. * Defines an observable called when the optimizer enables an optimization
  78863. */
  78864. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78865. /**
  78866. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78867. */
  78868. onFailureObservable: Observable<SceneOptimizer>;
  78869. /**
  78870. * Gets a boolean indicating if the optimizer is in improvement mode
  78871. */
  78872. get isInImprovementMode(): boolean;
  78873. /**
  78874. * Gets the current priority level (0 at start)
  78875. */
  78876. get currentPriorityLevel(): number;
  78877. /**
  78878. * Gets the current frame rate checked by the SceneOptimizer
  78879. */
  78880. get currentFrameRate(): number;
  78881. /**
  78882. * Gets or sets the current target frame rate (60 by default)
  78883. */
  78884. get targetFrameRate(): number;
  78885. /**
  78886. * Gets or sets the current target frame rate (60 by default)
  78887. */
  78888. set targetFrameRate(value: number);
  78889. /**
  78890. * Gets or sets the current interval between two checks (every 2000ms by default)
  78891. */
  78892. get trackerDuration(): number;
  78893. /**
  78894. * Gets or sets the current interval between two checks (every 2000ms by default)
  78895. */
  78896. set trackerDuration(value: number);
  78897. /**
  78898. * Gets the list of active optimizations
  78899. */
  78900. get optimizations(): SceneOptimization[];
  78901. /**
  78902. * Creates a new SceneOptimizer
  78903. * @param scene defines the scene to work on
  78904. * @param options defines the options to use with the SceneOptimizer
  78905. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78906. * @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)
  78907. */
  78908. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78909. /**
  78910. * Stops the current optimizer
  78911. */
  78912. stop(): void;
  78913. /**
  78914. * Reset the optimizer to initial step (current priority level = 0)
  78915. */
  78916. reset(): void;
  78917. /**
  78918. * Start the optimizer. By default it will try to reach a specific framerate
  78919. * but if the optimizer is set with improvementMode === true then it will run all optimization while frame rate is above the target frame rate
  78920. */
  78921. start(): void;
  78922. private _checkCurrentState;
  78923. /**
  78924. * Release all resources
  78925. */
  78926. dispose(): void;
  78927. /**
  78928. * Helper function to create a SceneOptimizer with one single line of code
  78929. * @param scene defines the scene to work on
  78930. * @param options defines the options to use with the SceneOptimizer
  78931. * @param onSuccess defines a callback to call on success
  78932. * @param onFailure defines a callback to call on failure
  78933. * @returns the new SceneOptimizer object
  78934. */
  78935. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78936. }
  78937. }
  78938. declare module BABYLON {
  78939. /**
  78940. * Class used to serialize a scene into a string
  78941. */
  78942. export class SceneSerializer {
  78943. /**
  78944. * Clear cache used by a previous serialization
  78945. */
  78946. static ClearCache(): void;
  78947. /**
  78948. * Serialize a scene into a JSON compatible object
  78949. * Note that if the current engine does not support synchronous texture reading (like WebGPU), you should use SerializeAsync instead
  78950. * as else you may not retrieve the proper base64 encoded texture data (when using the Texture.ForceSerializeBuffers flag)
  78951. * @param scene defines the scene to serialize
  78952. * @returns a JSON compatible object
  78953. */
  78954. static Serialize(scene: Scene): any;
  78955. private static _Serialize;
  78956. /**
  78957. * Serialize a scene into a JSON compatible object
  78958. * @param scene defines the scene to serialize
  78959. * @returns a JSON promise compatible object
  78960. */
  78961. static SerializeAsync(scene: Scene): Promise<any>;
  78962. private static _CollectPromises;
  78963. /**
  78964. * Serialize a mesh into a JSON compatible object
  78965. * @param toSerialize defines the mesh to serialize
  78966. * @param withParents defines if parents must be serialized as well
  78967. * @param withChildren defines if children must be serialized as well
  78968. * @returns a JSON compatible object
  78969. */
  78970. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78971. }
  78972. }
  78973. declare module BABYLON {
  78974. /**
  78975. * This represents the different options available for the video capture.
  78976. */
  78977. export interface VideoRecorderOptions {
  78978. /** Defines the mime type of the video. */
  78979. mimeType: string;
  78980. /** Defines the FPS the video should be recorded at. */
  78981. fps: number;
  78982. /** Defines the chunk size for the recording data. */
  78983. recordChunckSize: number;
  78984. /** The audio tracks to attach to the recording. */
  78985. audioTracks?: MediaStreamTrack[];
  78986. }
  78987. /**
  78988. * This can help with recording videos from BabylonJS.
  78989. * This is based on the available WebRTC functionalities of the browser.
  78990. *
  78991. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78992. */
  78993. export class VideoRecorder {
  78994. private static readonly _defaultOptions;
  78995. /**
  78996. * Returns whether or not the VideoRecorder is available in your browser.
  78997. * @param engine Defines the Babylon Engine.
  78998. * @returns true if supported otherwise false.
  78999. */
  79000. static IsSupported(engine: Engine): boolean;
  79001. private readonly _options;
  79002. private _canvas;
  79003. private _mediaRecorder;
  79004. private _recordedChunks;
  79005. private _fileName;
  79006. private _resolve;
  79007. private _reject;
  79008. /**
  79009. * True when a recording is already in progress.
  79010. */
  79011. get isRecording(): boolean;
  79012. /**
  79013. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  79014. * @param engine Defines the BabylonJS Engine you wish to record.
  79015. * @param options Defines options that can be used to customize the capture.
  79016. */
  79017. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  79018. /**
  79019. * Stops the current recording before the default capture timeout passed in the startRecording function.
  79020. */
  79021. stopRecording(): void;
  79022. /**
  79023. * Starts recording the canvas for a max duration specified in parameters.
  79024. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  79025. * If null no automatic download will start and you can rely on the promise to get the data back.
  79026. * @param maxDuration Defines the maximum recording time in seconds.
  79027. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  79028. * @return A promise callback at the end of the recording with the video data in Blob.
  79029. */
  79030. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  79031. /**
  79032. * Releases internal resources used during the recording.
  79033. */
  79034. dispose(): void;
  79035. private _handleDataAvailable;
  79036. private _handleError;
  79037. private _handleStop;
  79038. }
  79039. }
  79040. declare module BABYLON {
  79041. /**
  79042. * Class containing a set of static utilities functions for screenshots
  79043. */
  79044. export class ScreenshotTools {
  79045. /**
  79046. * Captures a screenshot of the current rendering
  79047. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79048. * @param engine defines the rendering engine
  79049. * @param camera defines the source camera
  79050. * @param size This parameter can be set to a single number or to an object with the
  79051. * following (optional) properties: precision, width, height. If a single number is passed,
  79052. * it will be used for both width and height. If an object is passed, the screenshot size
  79053. * will be derived from the parameters. The precision property is a multiplier allowing
  79054. * rendering at a higher or lower resolution
  79055. * @param successCallback defines the callback receives a single parameter which contains the
  79056. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79057. * src parameter of an <img> to display it
  79058. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79059. * Check your browser for supported MIME types
  79060. * @param forceDownload force the system to download the image even if a successCallback is provided
  79061. */
  79062. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, forceDownload?: boolean): void;
  79063. /**
  79064. * Captures a screenshot of the current rendering
  79065. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79066. * @param engine defines the rendering engine
  79067. * @param camera defines the source camera
  79068. * @param size This parameter can be set to a single number or to an object with the
  79069. * following (optional) properties: precision, width, height. If a single number is passed,
  79070. * it will be used for both width and height. If an object is passed, the screenshot size
  79071. * will be derived from the parameters. The precision property is a multiplier allowing
  79072. * rendering at a higher or lower resolution
  79073. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79074. * Check your browser for supported MIME types
  79075. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79076. * to the src parameter of an <img> to display it
  79077. */
  79078. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  79079. /**
  79080. * 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)
  79081. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79082. * @param engine defines the rendering engine
  79083. * @param camera defines the source camera
  79084. * @param width defines the expected width
  79085. * @param height defines the expected height
  79086. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79087. * Check your browser for supported MIME types
  79088. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79089. * to the src parameter of an <img> to display it
  79090. */
  79091. static CreateScreenshotWithResizeAsync(engine: Engine, camera: Camera, width: number, height: number, mimeType?: string): Promise<void>;
  79092. /**
  79093. * Generates an image screenshot from the specified camera.
  79094. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79095. * @param engine The engine to use for rendering
  79096. * @param camera The camera to use for rendering
  79097. * @param size This parameter can be set to a single number or to an object with the
  79098. * following (optional) properties: precision, width, height. If a single number is passed,
  79099. * it will be used for both width and height. If an object is passed, the screenshot size
  79100. * will be derived from the parameters. The precision property is a multiplier allowing
  79101. * rendering at a higher or lower resolution
  79102. * @param successCallback The callback receives a single parameter which contains the
  79103. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79104. * src parameter of an <img> to display it
  79105. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79106. * Check your browser for supported MIME types
  79107. * @param samples Texture samples (default: 1)
  79108. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79109. * @param fileName A name for for the downloaded file.
  79110. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79111. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  79112. */
  79113. 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;
  79114. /**
  79115. * Generates an image screenshot from the specified camera.
  79116. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79117. * @param engine The engine to use for rendering
  79118. * @param camera The camera to use for rendering
  79119. * @param size This parameter can be set to a single number or to an object with the
  79120. * following (optional) properties: precision, width, height. If a single number is passed,
  79121. * it will be used for both width and height. If an object is passed, the screenshot size
  79122. * will be derived from the parameters. The precision property is a multiplier allowing
  79123. * rendering at a higher or lower resolution
  79124. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79125. * Check your browser for supported MIME types
  79126. * @param samples Texture samples (default: 1)
  79127. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79128. * @param fileName A name for for the downloaded file.
  79129. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79130. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79131. * to the src parameter of an <img> to display it
  79132. */
  79133. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  79134. /**
  79135. * Gets height and width for screenshot size
  79136. * @private
  79137. */
  79138. private static _getScreenshotSize;
  79139. }
  79140. }
  79141. declare module BABYLON {
  79142. /**
  79143. * Interface for a data buffer
  79144. */
  79145. export interface IDataBuffer {
  79146. /**
  79147. * Reads bytes from the data buffer.
  79148. * @param byteOffset The byte offset to read
  79149. * @param byteLength The byte length to read
  79150. * @returns A promise that resolves when the bytes are read
  79151. */
  79152. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  79153. /**
  79154. * The byte length of the buffer.
  79155. */
  79156. readonly byteLength: number;
  79157. }
  79158. /**
  79159. * Utility class for reading from a data buffer
  79160. */
  79161. export class DataReader {
  79162. /**
  79163. * The data buffer associated with this data reader.
  79164. */
  79165. readonly buffer: IDataBuffer;
  79166. /**
  79167. * The current byte offset from the beginning of the data buffer.
  79168. */
  79169. byteOffset: number;
  79170. private _dataView;
  79171. private _dataByteOffset;
  79172. /**
  79173. * Constructor
  79174. * @param buffer The buffer to read
  79175. */
  79176. constructor(buffer: IDataBuffer);
  79177. /**
  79178. * Loads the given byte length.
  79179. * @param byteLength The byte length to load
  79180. * @returns A promise that resolves when the load is complete
  79181. */
  79182. loadAsync(byteLength: number): Promise<void>;
  79183. /**
  79184. * Read a unsigned 32-bit integer from the currently loaded data range.
  79185. * @returns The 32-bit integer read
  79186. */
  79187. readUint32(): number;
  79188. /**
  79189. * Read a byte array from the currently loaded data range.
  79190. * @param byteLength The byte length to read
  79191. * @returns The byte array read
  79192. */
  79193. readUint8Array(byteLength: number): Uint8Array;
  79194. /**
  79195. * Read a string from the currently loaded data range.
  79196. * @param byteLength The byte length to read
  79197. * @returns The string read
  79198. */
  79199. readString(byteLength: number): string;
  79200. /**
  79201. * Skips the given byte length the currently loaded data range.
  79202. * @param byteLength The byte length to skip
  79203. */
  79204. skipBytes(byteLength: number): void;
  79205. }
  79206. }
  79207. declare module BABYLON {
  79208. /**
  79209. * Class for storing data to local storage if available or in-memory storage otherwise
  79210. */
  79211. export class DataStorage {
  79212. private static _Storage;
  79213. private static _GetStorage;
  79214. /**
  79215. * Reads a string from the data storage
  79216. * @param key The key to read
  79217. * @param defaultValue The value if the key doesn't exist
  79218. * @returns The string value
  79219. */
  79220. static ReadString(key: string, defaultValue: string): string;
  79221. /**
  79222. * Writes a string to the data storage
  79223. * @param key The key to write
  79224. * @param value The value to write
  79225. */
  79226. static WriteString(key: string, value: string): void;
  79227. /**
  79228. * Reads a boolean from the data storage
  79229. * @param key The key to read
  79230. * @param defaultValue The value if the key doesn't exist
  79231. * @returns The boolean value
  79232. */
  79233. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  79234. /**
  79235. * Writes a boolean to the data storage
  79236. * @param key The key to write
  79237. * @param value The value to write
  79238. */
  79239. static WriteBoolean(key: string, value: boolean): void;
  79240. /**
  79241. * Reads a number from the data storage
  79242. * @param key The key to read
  79243. * @param defaultValue The value if the key doesn't exist
  79244. * @returns The number value
  79245. */
  79246. static ReadNumber(key: string, defaultValue: number): number;
  79247. /**
  79248. * Writes a number to the data storage
  79249. * @param key The key to write
  79250. * @param value The value to write
  79251. */
  79252. static WriteNumber(key: string, value: number): void;
  79253. }
  79254. }
  79255. declare module BABYLON {
  79256. /**
  79257. * Class used to record delta files between 2 scene states
  79258. */
  79259. export class SceneRecorder {
  79260. private _trackedScene;
  79261. private _savedJSON;
  79262. /**
  79263. * Track a given scene. This means the current scene state will be considered the original state
  79264. * @param scene defines the scene to track
  79265. */
  79266. track(scene: Scene): void;
  79267. /**
  79268. * Get the delta between current state and original state
  79269. * @returns a any containing the delta
  79270. */
  79271. getDelta(): any;
  79272. private _compareArray;
  79273. private _compareObjects;
  79274. private _compareCollections;
  79275. private static GetShadowGeneratorById;
  79276. /**
  79277. * Apply a given delta to a given scene
  79278. * @param deltaJSON defines the JSON containing the delta
  79279. * @param scene defines the scene to apply the delta to
  79280. */
  79281. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  79282. private static _ApplyPropertiesToEntity;
  79283. private static _ApplyDeltaForEntity;
  79284. }
  79285. }
  79286. declare module BABYLON {
  79287. /**
  79288. * A 3D trajectory consisting of an order list of vectors describing a
  79289. * path of motion through 3D space.
  79290. */
  79291. export class Trajectory {
  79292. private _points;
  79293. private readonly _segmentLength;
  79294. /**
  79295. * Serialize to JSON.
  79296. * @returns serialized JSON string
  79297. */
  79298. serialize(): string;
  79299. /**
  79300. * Deserialize from JSON.
  79301. * @param json serialized JSON string
  79302. * @returns deserialized Trajectory
  79303. */
  79304. static Deserialize(json: string): Trajectory;
  79305. /**
  79306. * Create a new empty Trajectory.
  79307. * @param segmentLength radius of discretization for Trajectory points
  79308. */
  79309. constructor(segmentLength?: number);
  79310. /**
  79311. * Get the length of the Trajectory.
  79312. * @returns length of the Trajectory
  79313. */
  79314. getLength(): number;
  79315. /**
  79316. * Append a new point to the Trajectory.
  79317. * NOTE: This implementation has many allocations.
  79318. * @param point point to append to the Trajectory
  79319. */
  79320. add(point: DeepImmutable<Vector3>): void;
  79321. /**
  79322. * Create a new Trajectory with a segment length chosen to make it
  79323. * probable that the new Trajectory will have a specified number of
  79324. * segments. This operation is imprecise.
  79325. * @param targetResolution number of segments desired
  79326. * @returns new Trajectory with approximately the requested number of segments
  79327. */
  79328. resampleAtTargetResolution(targetResolution: number): Trajectory;
  79329. /**
  79330. * Convert Trajectory segments into tokenized representation. This
  79331. * representation is an array of numbers where each nth number is the
  79332. * index of the token which is most similar to the nth segment of the
  79333. * Trajectory.
  79334. * @param tokens list of vectors which serve as discrete tokens
  79335. * @returns list of indices of most similar token per segment
  79336. */
  79337. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  79338. private static _forwardDir;
  79339. private static _inverseFromVec;
  79340. private static _upDir;
  79341. private static _fromToVec;
  79342. private static _lookMatrix;
  79343. /**
  79344. * Transform the rotation (i.e., direction) of a segment to isolate
  79345. * the relative transformation represented by the segment. This operation
  79346. * may or may not succeed due to singularities in the equations that define
  79347. * motion relativity in this context.
  79348. * @param priorVec the origin of the prior segment
  79349. * @param fromVec the origin of the current segment
  79350. * @param toVec the destination of the current segment
  79351. * @param result reference to output variable
  79352. * @returns whether or not transformation was successful
  79353. */
  79354. private static _transformSegmentDirToRef;
  79355. private static _bestMatch;
  79356. private static _score;
  79357. private static _bestScore;
  79358. /**
  79359. * Determine which token vector is most similar to the
  79360. * segment vector.
  79361. * @param segment segment vector
  79362. * @param tokens token vector list
  79363. * @returns index of the most similar token to the segment
  79364. */
  79365. private static _tokenizeSegment;
  79366. }
  79367. /**
  79368. * Class representing a set of known, named trajectories to which Trajectories can be
  79369. * added and using which Trajectories can be recognized.
  79370. */
  79371. export class TrajectoryClassifier {
  79372. private _maximumAllowableMatchCost;
  79373. private _vector3Alphabet;
  79374. private _levenshteinAlphabet;
  79375. private _nameToDescribedTrajectory;
  79376. /**
  79377. * Serialize to JSON.
  79378. * @returns JSON serialization
  79379. */
  79380. serialize(): string;
  79381. /**
  79382. * Deserialize from JSON.
  79383. * @param json JSON serialization
  79384. * @returns deserialized TrajectorySet
  79385. */
  79386. static Deserialize(json: string): TrajectoryClassifier;
  79387. /**
  79388. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  79389. * VERY naive, need to be generating these things from known
  79390. * sets. Better version later, probably eliminating this one.
  79391. * @returns auto-generated TrajectorySet
  79392. */
  79393. static Generate(): TrajectoryClassifier;
  79394. private constructor();
  79395. /**
  79396. * Add a new Trajectory to the set with a given name.
  79397. * @param trajectory new Trajectory to be added
  79398. * @param classification name to which to add the Trajectory
  79399. */
  79400. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  79401. /**
  79402. * Remove a known named trajectory and all Trajectories associated with it.
  79403. * @param classification name to remove
  79404. * @returns whether anything was removed
  79405. */
  79406. deleteClassification(classification: string): boolean;
  79407. /**
  79408. * Attempt to recognize a Trajectory from among all the classifications
  79409. * already known to the classifier.
  79410. * @param trajectory Trajectory to be recognized
  79411. * @returns classification of Trajectory if recognized, null otherwise
  79412. */
  79413. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  79414. }
  79415. }
  79416. declare module BABYLON {
  79417. /**
  79418. * An interface for all Hit test features
  79419. */
  79420. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  79421. /**
  79422. * Triggered when new babylon (transformed) hit test results are available
  79423. */
  79424. onHitTestResultObservable: Observable<T[]>;
  79425. }
  79426. /**
  79427. * Options used for hit testing
  79428. */
  79429. export interface IWebXRLegacyHitTestOptions {
  79430. /**
  79431. * Only test when user interacted with the scene. Default - hit test every frame
  79432. */
  79433. testOnPointerDownOnly?: boolean;
  79434. /**
  79435. * The node to use to transform the local results to world coordinates
  79436. */
  79437. worldParentNode?: TransformNode;
  79438. }
  79439. /**
  79440. * Interface defining the babylon result of raycasting/hit-test
  79441. */
  79442. export interface IWebXRLegacyHitResult {
  79443. /**
  79444. * Transformation matrix that can be applied to a node that will put it in the hit point location
  79445. */
  79446. transformationMatrix: Matrix;
  79447. /**
  79448. * The native hit test result
  79449. */
  79450. xrHitResult: XRHitResult | XRHitTestResult;
  79451. }
  79452. /**
  79453. * The currently-working hit-test module.
  79454. * Hit test (or Ray-casting) is used to interact with the real world.
  79455. * For further information read here - https://github.com/immersive-web/hit-test
  79456. */
  79457. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  79458. /**
  79459. * options to use when constructing this feature
  79460. */
  79461. readonly options: IWebXRLegacyHitTestOptions;
  79462. private _direction;
  79463. private _mat;
  79464. private _onSelectEnabled;
  79465. private _origin;
  79466. /**
  79467. * The module's name
  79468. */
  79469. static readonly Name: string;
  79470. /**
  79471. * The (Babylon) version of this module.
  79472. * This is an integer representing the implementation version.
  79473. * This number does not correspond to the WebXR specs version
  79474. */
  79475. static readonly Version: number;
  79476. /**
  79477. * Populated with the last native XR Hit Results
  79478. */
  79479. lastNativeXRHitResults: XRHitResult[];
  79480. /**
  79481. * Triggered when new babylon (transformed) hit test results are available
  79482. */
  79483. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  79484. /**
  79485. * Creates a new instance of the (legacy version) hit test feature
  79486. * @param _xrSessionManager an instance of WebXRSessionManager
  79487. * @param options options to use when constructing this feature
  79488. */
  79489. constructor(_xrSessionManager: WebXRSessionManager,
  79490. /**
  79491. * options to use when constructing this feature
  79492. */
  79493. options?: IWebXRLegacyHitTestOptions);
  79494. /**
  79495. * execute a hit test with an XR Ray
  79496. *
  79497. * @param xrSession a native xrSession that will execute this hit test
  79498. * @param xrRay the ray (position and direction) to use for ray-casting
  79499. * @param referenceSpace native XR reference space to use for the hit-test
  79500. * @param filter filter function that will filter the results
  79501. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79502. */
  79503. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  79504. /**
  79505. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  79506. * @param event the (select) event to use to select with
  79507. * @param referenceSpace the reference space to use for this hit test
  79508. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79509. */
  79510. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79511. /**
  79512. * attach this feature
  79513. * Will usually be called by the features manager
  79514. *
  79515. * @returns true if successful.
  79516. */
  79517. attach(): boolean;
  79518. /**
  79519. * detach this feature.
  79520. * Will usually be called by the features manager
  79521. *
  79522. * @returns true if successful.
  79523. */
  79524. detach(): boolean;
  79525. /**
  79526. * Dispose this feature and all of the resources attached
  79527. */
  79528. dispose(): void;
  79529. protected _onXRFrame(frame: XRFrame): void;
  79530. private _onHitTestResults;
  79531. private _onSelect;
  79532. }
  79533. }
  79534. declare module BABYLON {
  79535. /**
  79536. * Options used for hit testing (version 2)
  79537. */
  79538. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79539. /**
  79540. * Do not create a permanent hit test. Will usually be used when only
  79541. * transient inputs are needed.
  79542. */
  79543. disablePermanentHitTest?: boolean;
  79544. /**
  79545. * Enable transient (for example touch-based) hit test inspections
  79546. */
  79547. enableTransientHitTest?: boolean;
  79548. /**
  79549. * Offset ray for the permanent hit test
  79550. */
  79551. offsetRay?: Vector3;
  79552. /**
  79553. * Offset ray for the transient hit test
  79554. */
  79555. transientOffsetRay?: Vector3;
  79556. /**
  79557. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79558. */
  79559. useReferenceSpace?: boolean;
  79560. /**
  79561. * Override the default entity type(s) of the hit-test result
  79562. */
  79563. entityTypes?: XRHitTestTrackableType[];
  79564. }
  79565. /**
  79566. * Interface defining the babylon result of hit-test
  79567. */
  79568. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79569. /**
  79570. * The input source that generated this hit test (if transient)
  79571. */
  79572. inputSource?: XRInputSource;
  79573. /**
  79574. * Is this a transient hit test
  79575. */
  79576. isTransient?: boolean;
  79577. /**
  79578. * Position of the hit test result
  79579. */
  79580. position: Vector3;
  79581. /**
  79582. * Rotation of the hit test result
  79583. */
  79584. rotationQuaternion: Quaternion;
  79585. /**
  79586. * The native hit test result
  79587. */
  79588. xrHitResult: XRHitTestResult;
  79589. }
  79590. /**
  79591. * The currently-working hit-test module.
  79592. * Hit test (or Ray-casting) is used to interact with the real world.
  79593. * For further information read here - https://github.com/immersive-web/hit-test
  79594. *
  79595. * Tested on chrome (mobile) 80.
  79596. */
  79597. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79598. /**
  79599. * options to use when constructing this feature
  79600. */
  79601. readonly options: IWebXRHitTestOptions;
  79602. private _tmpMat;
  79603. private _tmpPos;
  79604. private _tmpQuat;
  79605. private _transientXrHitTestSource;
  79606. private _xrHitTestSource;
  79607. private initHitTestSource;
  79608. /**
  79609. * The module's name
  79610. */
  79611. static readonly Name: string;
  79612. /**
  79613. * The (Babylon) version of this module.
  79614. * This is an integer representing the implementation version.
  79615. * This number does not correspond to the WebXR specs version
  79616. */
  79617. static readonly Version: number;
  79618. /**
  79619. * When set to true, each hit test will have its own position/rotation objects
  79620. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79621. * the developers will clone them or copy them as they see fit.
  79622. */
  79623. autoCloneTransformation: boolean;
  79624. /**
  79625. * Triggered when new babylon (transformed) hit test results are available
  79626. * Note - this will be called when results come back from the device. It can be an empty array!!
  79627. */
  79628. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79629. /**
  79630. * Use this to temporarily pause hit test checks.
  79631. */
  79632. paused: boolean;
  79633. /**
  79634. * Creates a new instance of the hit test feature
  79635. * @param _xrSessionManager an instance of WebXRSessionManager
  79636. * @param options options to use when constructing this feature
  79637. */
  79638. constructor(_xrSessionManager: WebXRSessionManager,
  79639. /**
  79640. * options to use when constructing this feature
  79641. */
  79642. options?: IWebXRHitTestOptions);
  79643. /**
  79644. * attach this feature
  79645. * Will usually be called by the features manager
  79646. *
  79647. * @returns true if successful.
  79648. */
  79649. attach(): boolean;
  79650. /**
  79651. * detach this feature.
  79652. * Will usually be called by the features manager
  79653. *
  79654. * @returns true if successful.
  79655. */
  79656. detach(): boolean;
  79657. /**
  79658. * Dispose this feature and all of the resources attached
  79659. */
  79660. dispose(): void;
  79661. protected _onXRFrame(frame: XRFrame): void;
  79662. private _processWebXRHitTestResult;
  79663. }
  79664. }
  79665. declare module BABYLON {
  79666. /**
  79667. * Configuration options of the anchor system
  79668. */
  79669. export interface IWebXRAnchorSystemOptions {
  79670. /**
  79671. * a node that will be used to convert local to world coordinates
  79672. */
  79673. worldParentNode?: TransformNode;
  79674. /**
  79675. * If set to true a reference of the created anchors will be kept until the next session starts
  79676. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79677. */
  79678. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79679. }
  79680. /**
  79681. * A babylon container for an XR Anchor
  79682. */
  79683. export interface IWebXRAnchor {
  79684. /**
  79685. * A babylon-assigned ID for this anchor
  79686. */
  79687. id: number;
  79688. /**
  79689. * Transformation matrix to apply to an object attached to this anchor
  79690. */
  79691. transformationMatrix: Matrix;
  79692. /**
  79693. * The native anchor object
  79694. */
  79695. xrAnchor: XRAnchor;
  79696. /**
  79697. * if defined, this object will be constantly updated by the anchor's position and rotation
  79698. */
  79699. attachedNode?: TransformNode;
  79700. /**
  79701. * Remove this anchor from the scene
  79702. */
  79703. remove(): void;
  79704. }
  79705. /**
  79706. * An implementation of the anchor system for WebXR.
  79707. * For further information see https://github.com/immersive-web/anchors/
  79708. */
  79709. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79710. private _options;
  79711. private _lastFrameDetected;
  79712. private _trackedAnchors;
  79713. private _referenceSpaceForFrameAnchors;
  79714. private _futureAnchors;
  79715. /**
  79716. * The module's name
  79717. */
  79718. static readonly Name: string;
  79719. /**
  79720. * The (Babylon) version of this module.
  79721. * This is an integer representing the implementation version.
  79722. * This number does not correspond to the WebXR specs version
  79723. */
  79724. static readonly Version: number;
  79725. /**
  79726. * Observers registered here will be executed when a new anchor was added to the session
  79727. */
  79728. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79729. /**
  79730. * Observers registered here will be executed when an anchor was removed from the session
  79731. */
  79732. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79733. /**
  79734. * Observers registered here will be executed when an existing anchor updates
  79735. * This can execute N times every frame
  79736. */
  79737. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79738. /**
  79739. * Set the reference space to use for anchor creation, when not using a hit test.
  79740. * Will default to the session's reference space if not defined
  79741. */
  79742. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79743. /**
  79744. * constructs a new anchor system
  79745. * @param _xrSessionManager an instance of WebXRSessionManager
  79746. * @param _options configuration object for this feature
  79747. */
  79748. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79749. private _tmpVector;
  79750. private _tmpQuaternion;
  79751. private _populateTmpTransformation;
  79752. /**
  79753. * Create a new anchor point using a hit test result at a specific point in the scene
  79754. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79755. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79756. *
  79757. * @param hitTestResult The hit test result to use for this anchor creation
  79758. * @param position an optional position offset for this anchor
  79759. * @param rotationQuaternion an optional rotation offset for this anchor
  79760. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  79761. */
  79762. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  79763. /**
  79764. * Add a new anchor at a specific position and rotation
  79765. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79766. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79767. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79768. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79769. *
  79770. * @param position the position in which to add an anchor
  79771. * @param rotationQuaternion an optional rotation for the anchor transformation
  79772. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79773. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  79774. */
  79775. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  79776. /**
  79777. * Get the list of anchors currently being tracked by the system
  79778. */
  79779. get anchors(): IWebXRAnchor[];
  79780. /**
  79781. * detach this feature.
  79782. * Will usually be called by the features manager
  79783. *
  79784. * @returns true if successful.
  79785. */
  79786. detach(): boolean;
  79787. /**
  79788. * Dispose this feature and all of the resources attached
  79789. */
  79790. dispose(): void;
  79791. protected _onXRFrame(frame: XRFrame): void;
  79792. /**
  79793. * avoiding using Array.find for global support.
  79794. * @param xrAnchor the plane to find in the array
  79795. */
  79796. private _findIndexInAnchorArray;
  79797. private _updateAnchorWithXRFrame;
  79798. private _createAnchorAtTransformation;
  79799. }
  79800. }
  79801. declare module BABYLON {
  79802. /**
  79803. * Options used in the plane detector module
  79804. */
  79805. export interface IWebXRPlaneDetectorOptions {
  79806. /**
  79807. * The node to use to transform the local results to world coordinates
  79808. */
  79809. worldParentNode?: TransformNode;
  79810. /**
  79811. * If set to true a reference of the created planes will be kept until the next session starts
  79812. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79813. */
  79814. doNotRemovePlanesOnSessionEnded?: boolean;
  79815. /**
  79816. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  79817. */
  79818. preferredDetectorOptions?: XRGeometryDetectorOptions;
  79819. }
  79820. /**
  79821. * A babylon interface for a WebXR plane.
  79822. * A Plane is actually a polygon, built from N points in space
  79823. *
  79824. * Supported in chrome 79, not supported in canary 81 ATM
  79825. */
  79826. export interface IWebXRPlane {
  79827. /**
  79828. * a babylon-assigned ID for this polygon
  79829. */
  79830. id: number;
  79831. /**
  79832. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79833. */
  79834. polygonDefinition: Array<Vector3>;
  79835. /**
  79836. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79837. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79838. */
  79839. transformationMatrix: Matrix;
  79840. /**
  79841. * the native xr-plane object
  79842. */
  79843. xrPlane: XRPlane;
  79844. }
  79845. /**
  79846. * The plane detector is used to detect planes in the real world when in AR
  79847. * For more information see https://github.com/immersive-web/real-world-geometry/
  79848. */
  79849. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79850. private _options;
  79851. private _detectedPlanes;
  79852. private _enabled;
  79853. private _lastFrameDetected;
  79854. /**
  79855. * The module's name
  79856. */
  79857. static readonly Name: string;
  79858. /**
  79859. * The (Babylon) version of this module.
  79860. * This is an integer representing the implementation version.
  79861. * This number does not correspond to the WebXR specs version
  79862. */
  79863. static readonly Version: number;
  79864. /**
  79865. * Observers registered here will be executed when a new plane was added to the session
  79866. */
  79867. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79868. /**
  79869. * Observers registered here will be executed when a plane is no longer detected in the session
  79870. */
  79871. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79872. /**
  79873. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79874. * This can execute N times every frame
  79875. */
  79876. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79877. /**
  79878. * construct a new Plane Detector
  79879. * @param _xrSessionManager an instance of xr Session manager
  79880. * @param _options configuration to use when constructing this feature
  79881. */
  79882. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79883. /**
  79884. * detach this feature.
  79885. * Will usually be called by the features manager
  79886. *
  79887. * @returns true if successful.
  79888. */
  79889. detach(): boolean;
  79890. /**
  79891. * Dispose this feature and all of the resources attached
  79892. */
  79893. dispose(): void;
  79894. /**
  79895. * Check if the needed objects are defined.
  79896. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79897. */
  79898. isCompatible(): boolean;
  79899. protected _onXRFrame(frame: XRFrame): void;
  79900. private _init;
  79901. private _updatePlaneWithXRPlane;
  79902. /**
  79903. * avoiding using Array.find for global support.
  79904. * @param xrPlane the plane to find in the array
  79905. */
  79906. private _findIndexInPlaneArray;
  79907. }
  79908. }
  79909. declare module BABYLON {
  79910. /**
  79911. * Options interface for the background remover plugin
  79912. */
  79913. export interface IWebXRBackgroundRemoverOptions {
  79914. /**
  79915. * Further background meshes to disable when entering AR
  79916. */
  79917. backgroundMeshes?: AbstractMesh[];
  79918. /**
  79919. * flags to configure the removal of the environment helper.
  79920. * If not set, the entire background will be removed. If set, flags should be set as well.
  79921. */
  79922. environmentHelperRemovalFlags?: {
  79923. /**
  79924. * Should the skybox be removed (default false)
  79925. */
  79926. skyBox?: boolean;
  79927. /**
  79928. * Should the ground be removed (default false)
  79929. */
  79930. ground?: boolean;
  79931. };
  79932. /**
  79933. * don't disable the environment helper
  79934. */
  79935. ignoreEnvironmentHelper?: boolean;
  79936. }
  79937. /**
  79938. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79939. */
  79940. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79941. /**
  79942. * read-only options to be used in this module
  79943. */
  79944. readonly options: IWebXRBackgroundRemoverOptions;
  79945. /**
  79946. * The module's name
  79947. */
  79948. static readonly Name: string;
  79949. /**
  79950. * The (Babylon) version of this module.
  79951. * This is an integer representing the implementation version.
  79952. * This number does not correspond to the WebXR specs version
  79953. */
  79954. static readonly Version: number;
  79955. /**
  79956. * registered observers will be triggered when the background state changes
  79957. */
  79958. onBackgroundStateChangedObservable: Observable<boolean>;
  79959. /**
  79960. * constructs a new background remover module
  79961. * @param _xrSessionManager the session manager for this module
  79962. * @param options read-only options to be used in this module
  79963. */
  79964. constructor(_xrSessionManager: WebXRSessionManager,
  79965. /**
  79966. * read-only options to be used in this module
  79967. */
  79968. options?: IWebXRBackgroundRemoverOptions);
  79969. /**
  79970. * attach this feature
  79971. * Will usually be called by the features manager
  79972. *
  79973. * @returns true if successful.
  79974. */
  79975. attach(): boolean;
  79976. /**
  79977. * detach this feature.
  79978. * Will usually be called by the features manager
  79979. *
  79980. * @returns true if successful.
  79981. */
  79982. detach(): boolean;
  79983. /**
  79984. * Dispose this feature and all of the resources attached
  79985. */
  79986. dispose(): void;
  79987. protected _onXRFrame(_xrFrame: XRFrame): void;
  79988. private _setBackgroundState;
  79989. }
  79990. }
  79991. declare module BABYLON {
  79992. /**
  79993. * Options for the controller physics feature
  79994. */
  79995. export class IWebXRControllerPhysicsOptions {
  79996. /**
  79997. * Should the headset get its own impostor
  79998. */
  79999. enableHeadsetImpostor?: boolean;
  80000. /**
  80001. * Optional parameters for the headset impostor
  80002. */
  80003. headsetImpostorParams?: {
  80004. /**
  80005. * The type of impostor to create. Default is sphere
  80006. */
  80007. impostorType: number;
  80008. /**
  80009. * the size of the impostor. Defaults to 10cm
  80010. */
  80011. impostorSize?: number | {
  80012. width: number;
  80013. height: number;
  80014. depth: number;
  80015. };
  80016. /**
  80017. * Friction definitions
  80018. */
  80019. friction?: number;
  80020. /**
  80021. * Restitution
  80022. */
  80023. restitution?: number;
  80024. };
  80025. /**
  80026. * The physics properties of the future impostors
  80027. */
  80028. physicsProperties?: {
  80029. /**
  80030. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  80031. * Note that this requires a physics engine that supports mesh impostors!
  80032. */
  80033. useControllerMesh?: boolean;
  80034. /**
  80035. * The type of impostor to create. Default is sphere
  80036. */
  80037. impostorType?: number;
  80038. /**
  80039. * the size of the impostor. Defaults to 10cm
  80040. */
  80041. impostorSize?: number | {
  80042. width: number;
  80043. height: number;
  80044. depth: number;
  80045. };
  80046. /**
  80047. * Friction definitions
  80048. */
  80049. friction?: number;
  80050. /**
  80051. * Restitution
  80052. */
  80053. restitution?: number;
  80054. };
  80055. /**
  80056. * the xr input to use with this pointer selection
  80057. */
  80058. xrInput: WebXRInput;
  80059. }
  80060. /**
  80061. * Add physics impostor to your webxr controllers,
  80062. * including naive calculation of their linear and angular velocity
  80063. */
  80064. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  80065. private readonly _options;
  80066. private _attachController;
  80067. private _controllers;
  80068. private _debugMode;
  80069. private _delta;
  80070. private _headsetImpostor?;
  80071. private _headsetMesh?;
  80072. private _lastTimestamp;
  80073. private _tmpQuaternion;
  80074. private _tmpVector;
  80075. /**
  80076. * The module's name
  80077. */
  80078. static readonly Name: string;
  80079. /**
  80080. * The (Babylon) version of this module.
  80081. * This is an integer representing the implementation version.
  80082. * This number does not correspond to the webxr specs version
  80083. */
  80084. static readonly Version: number;
  80085. /**
  80086. * Construct a new Controller Physics Feature
  80087. * @param _xrSessionManager the corresponding xr session manager
  80088. * @param _options options to create this feature with
  80089. */
  80090. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  80091. /**
  80092. * @hidden
  80093. * enable debugging - will show console outputs and the impostor mesh
  80094. */
  80095. _enablePhysicsDebug(): void;
  80096. /**
  80097. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  80098. * @param xrController the controller to add
  80099. */
  80100. addController(xrController: WebXRInputSource): void;
  80101. /**
  80102. * attach this feature
  80103. * Will usually be called by the features manager
  80104. *
  80105. * @returns true if successful.
  80106. */
  80107. attach(): boolean;
  80108. /**
  80109. * detach this feature.
  80110. * Will usually be called by the features manager
  80111. *
  80112. * @returns true if successful.
  80113. */
  80114. detach(): boolean;
  80115. /**
  80116. * Get the headset impostor, if enabled
  80117. * @returns the impostor
  80118. */
  80119. getHeadsetImpostor(): PhysicsImpostor | undefined;
  80120. /**
  80121. * Get the physics impostor of a specific controller.
  80122. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  80123. * @param controller the controller or the controller id of which to get the impostor
  80124. * @returns the impostor or null
  80125. */
  80126. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  80127. /**
  80128. * Update the physics properties provided in the constructor
  80129. * @param newProperties the new properties object
  80130. */
  80131. setPhysicsProperties(newProperties: {
  80132. impostorType?: number;
  80133. impostorSize?: number | {
  80134. width: number;
  80135. height: number;
  80136. depth: number;
  80137. };
  80138. friction?: number;
  80139. restitution?: number;
  80140. }): void;
  80141. protected _onXRFrame(_xrFrame: any): void;
  80142. private _detachController;
  80143. }
  80144. }
  80145. declare module BABYLON {
  80146. /**
  80147. * A babylon interface for a "WebXR" feature point.
  80148. * Represents the position and confidence value of a given feature point.
  80149. */
  80150. export interface IWebXRFeaturePoint {
  80151. /**
  80152. * Represents the position of the feature point in world space.
  80153. */
  80154. position: Vector3;
  80155. /**
  80156. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  80157. */
  80158. confidenceValue: number;
  80159. }
  80160. /**
  80161. * The feature point system is used to detect feature points from real world geometry.
  80162. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  80163. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  80164. */
  80165. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  80166. private _enabled;
  80167. private _featurePointCloud;
  80168. /**
  80169. * The module's name
  80170. */
  80171. static readonly Name: string;
  80172. /**
  80173. * The (Babylon) version of this module.
  80174. * This is an integer representing the implementation version.
  80175. * This number does not correspond to the WebXR specs version
  80176. */
  80177. static readonly Version: number;
  80178. /**
  80179. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  80180. * Will notify the observers about which feature points have been added.
  80181. */
  80182. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  80183. /**
  80184. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  80185. * Will notify the observers about which feature points have been updated.
  80186. */
  80187. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  80188. /**
  80189. * The current feature point cloud maintained across frames.
  80190. */
  80191. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  80192. /**
  80193. * construct the feature point system
  80194. * @param _xrSessionManager an instance of xr Session manager
  80195. */
  80196. constructor(_xrSessionManager: WebXRSessionManager);
  80197. /**
  80198. * Detach this feature.
  80199. * Will usually be called by the features manager
  80200. *
  80201. * @returns true if successful.
  80202. */
  80203. detach(): boolean;
  80204. /**
  80205. * Dispose this feature and all of the resources attached
  80206. */
  80207. dispose(): void;
  80208. /**
  80209. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  80210. */
  80211. protected _onXRFrame(frame: XRFrame): void;
  80212. /**
  80213. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  80214. */
  80215. private _init;
  80216. }
  80217. }
  80218. declare module BABYLON {
  80219. /**
  80220. * Configuration interface for the hand tracking feature
  80221. */
  80222. export interface IWebXRHandTrackingOptions {
  80223. /**
  80224. * The xrInput that will be used as source for new hands
  80225. */
  80226. xrInput: WebXRInput;
  80227. /**
  80228. * Configuration object for the joint meshes
  80229. */
  80230. jointMeshes?: {
  80231. /**
  80232. * Should the meshes created be invisible (defaults to false)
  80233. */
  80234. invisible?: boolean;
  80235. /**
  80236. * A source mesh to be used to create instances. Defaults to a sphere.
  80237. * This mesh will be the source for all other (25) meshes.
  80238. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  80239. */
  80240. sourceMesh?: Mesh;
  80241. /**
  80242. * This function will be called after a mesh was created for a specific joint.
  80243. * Using this function you can either manipulate the instance or return a new mesh.
  80244. * When returning a new mesh the instance created before will be disposed
  80245. */
  80246. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  80247. /**
  80248. * Should the source mesh stay visible. Defaults to false
  80249. */
  80250. keepOriginalVisible?: boolean;
  80251. /**
  80252. * Scale factor for all instances (defaults to 2)
  80253. */
  80254. scaleFactor?: number;
  80255. /**
  80256. * Should each instance have its own physics impostor
  80257. */
  80258. enablePhysics?: boolean;
  80259. /**
  80260. * If enabled, override default physics properties
  80261. */
  80262. physicsProps?: {
  80263. friction?: number;
  80264. restitution?: number;
  80265. impostorType?: number;
  80266. };
  80267. /**
  80268. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  80269. */
  80270. disableDefaultHandMesh?: boolean;
  80271. /**
  80272. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  80273. */
  80274. handMeshes?: {
  80275. right: AbstractMesh;
  80276. left: AbstractMesh;
  80277. };
  80278. /**
  80279. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  80280. */
  80281. rigMapping?: {
  80282. right: string[];
  80283. left: string[];
  80284. };
  80285. };
  80286. }
  80287. /**
  80288. * Parts of the hands divided to writs and finger names
  80289. */
  80290. export const enum HandPart {
  80291. /**
  80292. * HandPart - Wrist
  80293. */
  80294. WRIST = "wrist",
  80295. /**
  80296. * HandPart - The Thumb
  80297. */
  80298. THUMB = "thumb",
  80299. /**
  80300. * HandPart - Index finger
  80301. */
  80302. INDEX = "index",
  80303. /**
  80304. * HandPart - Middle finger
  80305. */
  80306. MIDDLE = "middle",
  80307. /**
  80308. * HandPart - Ring finger
  80309. */
  80310. RING = "ring",
  80311. /**
  80312. * HandPart - Little finger
  80313. */
  80314. LITTLE = "little"
  80315. }
  80316. /**
  80317. * Representing a single hand (with its corresponding native XRHand object)
  80318. */
  80319. export class WebXRHand implements IDisposable {
  80320. /** the controller to which the hand correlates */
  80321. readonly xrController: WebXRInputSource;
  80322. /** the meshes to be used to track the hand joints */
  80323. readonly trackedMeshes: AbstractMesh[];
  80324. private _handMesh?;
  80325. private _rigMapping?;
  80326. private _scene;
  80327. private _defaultHandMesh;
  80328. private _transformNodeMapping;
  80329. /**
  80330. * Hand-parts definition (key is HandPart)
  80331. */
  80332. handPartsDefinition: {
  80333. [key: string]: number[];
  80334. };
  80335. /**
  80336. * Observers will be triggered when the mesh for this hand was initialized.
  80337. */
  80338. onHandMeshReadyObservable: Observable<WebXRHand>;
  80339. /**
  80340. * Populate the HandPartsDefinition object.
  80341. * This is called as a side effect since certain browsers don't have XRHand defined.
  80342. */
  80343. private generateHandPartsDefinition;
  80344. /**
  80345. * Construct a new hand object
  80346. * @param xrController the controller to which the hand correlates
  80347. * @param trackedMeshes the meshes to be used to track the hand joints
  80348. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  80349. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  80350. * @param disableDefaultHandMesh should the default mesh creation be disabled
  80351. */
  80352. constructor(
  80353. /** the controller to which the hand correlates */
  80354. xrController: WebXRInputSource,
  80355. /** the meshes to be used to track the hand joints */
  80356. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean);
  80357. /**
  80358. * Get the hand mesh. It is possible that the hand mesh is not yet ready!
  80359. */
  80360. get handMesh(): AbstractMesh | undefined;
  80361. /**
  80362. * Update this hand from the latest xr frame
  80363. * @param xrFrame xrFrame to update from
  80364. * @param referenceSpace The current viewer reference space
  80365. * @param scaleFactor optional scale factor for the meshes
  80366. */
  80367. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  80368. /**
  80369. * Get meshes of part of the hand
  80370. * @param part the part of hand to get
  80371. * @returns An array of meshes that correlate to the hand part requested
  80372. */
  80373. getHandPartMeshes(part: HandPart): AbstractMesh[];
  80374. /**
  80375. * Dispose this Hand object
  80376. */
  80377. dispose(): void;
  80378. private _generateDefaultHandMesh;
  80379. }
  80380. /**
  80381. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  80382. */
  80383. export class WebXRHandTracking extends WebXRAbstractFeature {
  80384. /**
  80385. * options to use when constructing this feature
  80386. */
  80387. readonly options: IWebXRHandTrackingOptions;
  80388. private static _idCounter;
  80389. /**
  80390. * The module's name
  80391. */
  80392. static readonly Name: string;
  80393. /**
  80394. * The (Babylon) version of this module.
  80395. * This is an integer representing the implementation version.
  80396. * This number does not correspond to the WebXR specs version
  80397. */
  80398. static readonly Version: number;
  80399. /**
  80400. * This observable will notify registered observers when a new hand object was added and initialized
  80401. */
  80402. onHandAddedObservable: Observable<WebXRHand>;
  80403. /**
  80404. * This observable will notify its observers right before the hand object is disposed
  80405. */
  80406. onHandRemovedObservable: Observable<WebXRHand>;
  80407. private _hands;
  80408. /**
  80409. * Creates a new instance of the hit test feature
  80410. * @param _xrSessionManager an instance of WebXRSessionManager
  80411. * @param options options to use when constructing this feature
  80412. */
  80413. constructor(_xrSessionManager: WebXRSessionManager,
  80414. /**
  80415. * options to use when constructing this feature
  80416. */
  80417. options: IWebXRHandTrackingOptions);
  80418. /**
  80419. * Check if the needed objects are defined.
  80420. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80421. */
  80422. isCompatible(): boolean;
  80423. /**
  80424. * attach this feature
  80425. * Will usually be called by the features manager
  80426. *
  80427. * @returns true if successful.
  80428. */
  80429. attach(): boolean;
  80430. /**
  80431. * detach this feature.
  80432. * Will usually be called by the features manager
  80433. *
  80434. * @returns true if successful.
  80435. */
  80436. detach(): boolean;
  80437. /**
  80438. * Dispose this feature and all of the resources attached
  80439. */
  80440. dispose(): void;
  80441. /**
  80442. * Get the hand object according to the controller id
  80443. * @param controllerId the controller id to which we want to get the hand
  80444. * @returns null if not found or the WebXRHand object if found
  80445. */
  80446. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  80447. /**
  80448. * Get a hand object according to the requested handedness
  80449. * @param handedness the handedness to request
  80450. * @returns null if not found or the WebXRHand object if found
  80451. */
  80452. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  80453. protected _onXRFrame(_xrFrame: XRFrame): void;
  80454. private _attachHand;
  80455. private _detachHand;
  80456. }
  80457. }
  80458. declare module BABYLON {
  80459. /**
  80460. * Options used in the mesh detector module
  80461. */
  80462. export interface IWebXRMeshDetectorOptions {
  80463. /**
  80464. * The node to use to transform the local results to world coordinates
  80465. */
  80466. worldParentNode?: TransformNode;
  80467. /**
  80468. * If set to true a reference of the created meshes will be kept until the next session starts
  80469. * If not defined, meshes will be removed from the array when the feature is detached or the session ended.
  80470. */
  80471. doNotRemoveMeshesOnSessionEnded?: boolean;
  80472. /**
  80473. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  80474. */
  80475. preferredDetectorOptions?: XRGeometryDetectorOptions;
  80476. /**
  80477. * If set to true, WebXRMeshDetector will convert coordinate systems for meshes.
  80478. * If not defined, mesh conversions from right handed to left handed coordinate systems won't be conducted.
  80479. * Right handed mesh data will be available through IWebXRVertexData.xrMesh.
  80480. */
  80481. convertCoordinateSystems?: boolean;
  80482. }
  80483. /**
  80484. * A babylon interface for a XR mesh's vertex data.
  80485. *
  80486. * Currently not supported by WebXR, available only with BabylonNative
  80487. */
  80488. export interface IWebXRVertexData {
  80489. /**
  80490. * A babylon-assigned ID for this mesh
  80491. */
  80492. id: number;
  80493. /**
  80494. * Data required for constructing a mesh in Babylon.js.
  80495. */
  80496. xrMesh: XRMesh;
  80497. /**
  80498. * The node to use to transform the local results to world coordinates.
  80499. * WorldParentNode will only exist if it was declared in the IWebXRMeshDetectorOptions.
  80500. */
  80501. worldParentNode?: TransformNode;
  80502. /**
  80503. * An array of vertex positions in babylon space. right/left hand system is taken into account.
  80504. * Positions will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80505. */
  80506. positions?: Float32Array;
  80507. /**
  80508. * An array of indices in babylon space. Indices have a counterclockwise winding order.
  80509. * Indices will only be populated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80510. */
  80511. indices?: Uint32Array;
  80512. /**
  80513. * An array of vertex normals in babylon space. right/left hand system is taken into account.
  80514. * Normals will not be calculated if convertCoordinateSystems is undefined in the IWebXRMeshDetectorOptions.
  80515. * Different platforms may or may not support mesh normals when convertCoordinateSystems is set to true.
  80516. */
  80517. normals?: Float32Array;
  80518. /**
  80519. * A transformation matrix to apply on the mesh that will be built using the meshDefinition.
  80520. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module.
  80521. * TransformationMatrix will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80522. */
  80523. transformationMatrix?: Matrix;
  80524. }
  80525. /**
  80526. * The mesh detector is used to detect meshes in the real world when in AR
  80527. */
  80528. export class WebXRMeshDetector extends WebXRAbstractFeature {
  80529. private _options;
  80530. private _detectedMeshes;
  80531. /**
  80532. * The module's name
  80533. */
  80534. static readonly Name: string;
  80535. /**
  80536. * The (Babylon) version of this module.
  80537. * This is an integer representing the implementation version.
  80538. * This number does not correspond to the WebXR specs version
  80539. */
  80540. static readonly Version: number;
  80541. /**
  80542. * Observers registered here will be executed when a new mesh was added to the session
  80543. */
  80544. onMeshAddedObservable: Observable<IWebXRVertexData>;
  80545. /**
  80546. * Observers registered here will be executed when a mesh is no longer detected in the session
  80547. */
  80548. onMeshRemovedObservable: Observable<IWebXRVertexData>;
  80549. /**
  80550. * Observers registered here will be executed when an existing mesh updates
  80551. */
  80552. onMeshUpdatedObservable: Observable<IWebXRVertexData>;
  80553. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRMeshDetectorOptions);
  80554. detach(): boolean;
  80555. dispose(): void;
  80556. protected _onXRFrame(frame: XRFrame): void;
  80557. private _init;
  80558. private _updateVertexDataWithXRMesh;
  80559. }
  80560. }
  80561. declare module BABYLON {
  80562. /**
  80563. * Options interface for the background remover plugin
  80564. */
  80565. export interface IWebXRImageTrackingOptions {
  80566. /**
  80567. * A required array with images to track
  80568. */
  80569. images: {
  80570. /**
  80571. * The source of the image. can be a URL or an image bitmap
  80572. */
  80573. src: string | ImageBitmap;
  80574. /**
  80575. * The estimated width in the real world (in meters)
  80576. */
  80577. estimatedRealWorldWidth: number;
  80578. }[];
  80579. }
  80580. /**
  80581. * An object representing an image tracked by the system
  80582. */
  80583. export interface IWebXRTrackedImage {
  80584. /**
  80585. * The ID of this image (which is the same as the position in the array that was used to initialize the feature)
  80586. */
  80587. id: number;
  80588. /**
  80589. * Is the transformation provided emulated. If it is, the system "guesses" its real position. Otherwise it can be considered as exact position.
  80590. */
  80591. emulated?: boolean;
  80592. /**
  80593. * Just in case it is needed - the image bitmap that is being tracked
  80594. */
  80595. originalBitmap: ImageBitmap;
  80596. /**
  80597. * The native XR result image tracking result, untouched
  80598. */
  80599. xrTrackingResult?: XRImageTrackingResult;
  80600. /**
  80601. * Width in real world (meters)
  80602. */
  80603. realWorldWidth?: number;
  80604. /**
  80605. * A transformation matrix of this current image in the current reference space.
  80606. */
  80607. transformationMatrix: Matrix;
  80608. /**
  80609. * The width/height ratio of this image. can be used to calculate the size of the detected object/image
  80610. */
  80611. ratio?: number;
  80612. }
  80613. /**
  80614. * Image tracking for immersive AR sessions.
  80615. * Providing a list of images and their estimated widths will enable tracking those images in the real world.
  80616. */
  80617. export class WebXRImageTracking extends WebXRAbstractFeature {
  80618. /**
  80619. * read-only options to be used in this module
  80620. */
  80621. readonly options: IWebXRImageTrackingOptions;
  80622. /**
  80623. * The module's name
  80624. */
  80625. static readonly Name: string;
  80626. /**
  80627. * The (Babylon) version of this module.
  80628. * This is an integer representing the implementation version.
  80629. * This number does not correspond to the WebXR specs version
  80630. */
  80631. static readonly Version: number;
  80632. /**
  80633. * This will be triggered if the underlying system deems an image untrackable.
  80634. * The index is the index of the image from the array used to initialize the feature.
  80635. */
  80636. onUntrackableImageFoundObservable: Observable<number>;
  80637. /**
  80638. * An image was deemed trackable, and the system will start tracking it.
  80639. */
  80640. onTrackableImageFoundObservable: Observable<IWebXRTrackedImage>;
  80641. /**
  80642. * The image was found and its state was updated.
  80643. */
  80644. onTrackedImageUpdatedObservable: Observable<IWebXRTrackedImage>;
  80645. private _trackedImages;
  80646. private _originalTrackingRequest;
  80647. /**
  80648. * constructs the image tracking feature
  80649. * @param _xrSessionManager the session manager for this module
  80650. * @param options read-only options to be used in this module
  80651. */
  80652. constructor(_xrSessionManager: WebXRSessionManager,
  80653. /**
  80654. * read-only options to be used in this module
  80655. */
  80656. options: IWebXRImageTrackingOptions);
  80657. /**
  80658. * attach this feature
  80659. * Will usually be called by the features manager
  80660. *
  80661. * @returns true if successful.
  80662. */
  80663. attach(): boolean;
  80664. /**
  80665. * detach this feature.
  80666. * Will usually be called by the features manager
  80667. *
  80668. * @returns true if successful.
  80669. */
  80670. detach(): boolean;
  80671. /**
  80672. * Check if the needed objects are defined.
  80673. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80674. */
  80675. isCompatible(): boolean;
  80676. /**
  80677. * Get a tracked image by its ID.
  80678. *
  80679. * @param id the id of the image to load (position in the init array)
  80680. * @returns a trackable image, if exists in this location
  80681. */
  80682. getTrackedImageById(id: number): Nullable<IWebXRTrackedImage>;
  80683. /**
  80684. * Dispose this feature and all of the resources attached
  80685. */
  80686. dispose(): void;
  80687. /**
  80688. * Extends the session init object if needed
  80689. * @returns augmentation object fo the xr session init object.
  80690. */
  80691. getXRSessionInitExtension(): Promise<Partial<XRSessionInit>>;
  80692. protected _onXRFrame(_xrFrame: XRFrame): void;
  80693. private _init;
  80694. }
  80695. }
  80696. declare module BABYLON {
  80697. /**
  80698. * The motion controller class for all microsoft mixed reality controllers
  80699. */
  80700. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  80701. protected readonly _mapping: {
  80702. defaultButton: {
  80703. valueNodeName: string;
  80704. unpressedNodeName: string;
  80705. pressedNodeName: string;
  80706. };
  80707. defaultAxis: {
  80708. valueNodeName: string;
  80709. minNodeName: string;
  80710. maxNodeName: string;
  80711. };
  80712. buttons: {
  80713. "xr-standard-trigger": {
  80714. rootNodeName: string;
  80715. componentProperty: string;
  80716. states: string[];
  80717. };
  80718. "xr-standard-squeeze": {
  80719. rootNodeName: string;
  80720. componentProperty: string;
  80721. states: string[];
  80722. };
  80723. "xr-standard-touchpad": {
  80724. rootNodeName: string;
  80725. labelAnchorNodeName: string;
  80726. touchPointNodeName: string;
  80727. };
  80728. "xr-standard-thumbstick": {
  80729. rootNodeName: string;
  80730. componentProperty: string;
  80731. states: string[];
  80732. };
  80733. };
  80734. axes: {
  80735. "xr-standard-touchpad": {
  80736. "x-axis": {
  80737. rootNodeName: string;
  80738. };
  80739. "y-axis": {
  80740. rootNodeName: string;
  80741. };
  80742. };
  80743. "xr-standard-thumbstick": {
  80744. "x-axis": {
  80745. rootNodeName: string;
  80746. };
  80747. "y-axis": {
  80748. rootNodeName: string;
  80749. };
  80750. };
  80751. };
  80752. };
  80753. /**
  80754. * The base url used to load the left and right controller models
  80755. */
  80756. static MODEL_BASE_URL: string;
  80757. /**
  80758. * The name of the left controller model file
  80759. */
  80760. static MODEL_LEFT_FILENAME: string;
  80761. /**
  80762. * The name of the right controller model file
  80763. */
  80764. static MODEL_RIGHT_FILENAME: string;
  80765. profileId: string;
  80766. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80767. protected _getFilenameAndPath(): {
  80768. filename: string;
  80769. path: string;
  80770. };
  80771. protected _getModelLoadingConstraints(): boolean;
  80772. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80773. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80774. protected _updateModel(): void;
  80775. }
  80776. }
  80777. declare module BABYLON {
  80778. /**
  80779. * The motion controller class for oculus touch (quest, rift).
  80780. * This class supports legacy mapping as well the standard xr mapping
  80781. */
  80782. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80783. private _forceLegacyControllers;
  80784. private _modelRootNode;
  80785. /**
  80786. * The base url used to load the left and right controller models
  80787. */
  80788. static MODEL_BASE_URL: string;
  80789. /**
  80790. * The name of the left controller model file
  80791. */
  80792. static MODEL_LEFT_FILENAME: string;
  80793. /**
  80794. * The name of the right controller model file
  80795. */
  80796. static MODEL_RIGHT_FILENAME: string;
  80797. /**
  80798. * Base Url for the Quest controller model.
  80799. */
  80800. static QUEST_MODEL_BASE_URL: string;
  80801. profileId: string;
  80802. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80803. protected _getFilenameAndPath(): {
  80804. filename: string;
  80805. path: string;
  80806. };
  80807. protected _getModelLoadingConstraints(): boolean;
  80808. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80809. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80810. protected _updateModel(): void;
  80811. /**
  80812. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80813. * between the touch and touch 2.
  80814. */
  80815. private _isQuest;
  80816. }
  80817. }
  80818. declare module BABYLON {
  80819. /**
  80820. * The motion controller class for the standard HTC-Vive controllers
  80821. */
  80822. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80823. private _modelRootNode;
  80824. /**
  80825. * The base url used to load the left and right controller models
  80826. */
  80827. static MODEL_BASE_URL: string;
  80828. /**
  80829. * File name for the controller model.
  80830. */
  80831. static MODEL_FILENAME: string;
  80832. profileId: string;
  80833. /**
  80834. * Create a new Vive motion controller object
  80835. * @param scene the scene to use to create this controller
  80836. * @param gamepadObject the corresponding gamepad object
  80837. * @param handedness the handedness of the controller
  80838. */
  80839. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80840. protected _getFilenameAndPath(): {
  80841. filename: string;
  80842. path: string;
  80843. };
  80844. protected _getModelLoadingConstraints(): boolean;
  80845. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80846. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80847. protected _updateModel(): void;
  80848. }
  80849. }
  80850. declare module BABYLON {
  80851. /** @hidden */
  80852. export class WebGPUCacheRenderPipelineString extends WebGPUCacheRenderPipeline {
  80853. private static _Cache;
  80854. protected _getRenderPipeline(param: {
  80855. token: any;
  80856. pipeline: Nullable<GPURenderPipeline>;
  80857. }): void;
  80858. protected _setRenderPipeline(param: {
  80859. token: any;
  80860. pipeline: Nullable<GPURenderPipeline>;
  80861. }): void;
  80862. }
  80863. }
  80864. declare module BABYLON {
  80865. /** @hidden */
  80866. export var blurPixelShader: {
  80867. name: string;
  80868. shader: string;
  80869. };
  80870. }
  80871. declare module BABYLON {
  80872. /** @hidden */
  80873. export var pointCloudVertexDeclaration: {
  80874. name: string;
  80875. shader: string;
  80876. };
  80877. }
  80878. // Mixins
  80879. interface Window {
  80880. mozIndexedDB: IDBFactory;
  80881. webkitIndexedDB: IDBFactory;
  80882. msIndexedDB: IDBFactory;
  80883. webkitURL: typeof URL;
  80884. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  80885. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  80886. WebGLRenderingContext: WebGLRenderingContext;
  80887. MSGesture: MSGesture;
  80888. CANNON: any;
  80889. AudioContext: AudioContext;
  80890. webkitAudioContext: AudioContext;
  80891. PointerEvent: any;
  80892. Math: Math;
  80893. Uint8Array: Uint8ArrayConstructor;
  80894. Float32Array: Float32ArrayConstructor;
  80895. mozURL: typeof URL;
  80896. msURL: typeof URL;
  80897. VRFrameData: any; // WebVR, from specs 1.1
  80898. DracoDecoderModule: any;
  80899. setImmediate(handler: (...args: any[]) => void): number;
  80900. }
  80901. interface HTMLCanvasElement {
  80902. requestPointerLock(): void;
  80903. msRequestPointerLock?(): void;
  80904. mozRequestPointerLock?(): void;
  80905. webkitRequestPointerLock?(): void;
  80906. /** Track whether a record is in progress */
  80907. isRecording: boolean;
  80908. /** Capture Stream method defined by some browsers */
  80909. captureStream(fps?: number): MediaStream;
  80910. }
  80911. interface CanvasRenderingContext2D {
  80912. msImageSmoothingEnabled: boolean;
  80913. }
  80914. interface MouseEvent {
  80915. mozMovementX: number;
  80916. mozMovementY: number;
  80917. webkitMovementX: number;
  80918. webkitMovementY: number;
  80919. msMovementX: number;
  80920. msMovementY: number;
  80921. }
  80922. interface Navigator {
  80923. mozGetVRDevices: (any: any) => any;
  80924. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80925. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80926. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80927. webkitGetGamepads(): Gamepad[];
  80928. msGetGamepads(): Gamepad[];
  80929. webkitGamepads(): Gamepad[];
  80930. }
  80931. interface HTMLVideoElement {
  80932. mozSrcObject: any;
  80933. }
  80934. interface Math {
  80935. fround(x: number): number;
  80936. imul(a: number, b: number): number;
  80937. log2(x: number): number;
  80938. }
  80939. interface WebGLRenderingContext {
  80940. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  80941. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  80942. vertexAttribDivisor(index: number, divisor: number): void;
  80943. createVertexArray(): any;
  80944. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  80945. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  80946. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  80947. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  80948. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  80949. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  80950. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  80951. // Queries
  80952. createQuery(): WebGLQuery;
  80953. deleteQuery(query: WebGLQuery): void;
  80954. beginQuery(target: number, query: WebGLQuery): void;
  80955. endQuery(target: number): void;
  80956. getQueryParameter(query: WebGLQuery, pname: number): any;
  80957. getQuery(target: number, pname: number): any;
  80958. MAX_SAMPLES: number;
  80959. RGBA8: number;
  80960. READ_FRAMEBUFFER: number;
  80961. DRAW_FRAMEBUFFER: number;
  80962. UNIFORM_BUFFER: number;
  80963. HALF_FLOAT_OES: number;
  80964. RGBA16F: number;
  80965. RGBA32F: number;
  80966. R32F: number;
  80967. RG32F: number;
  80968. RGB32F: number;
  80969. R16F: number;
  80970. RG16F: number;
  80971. RGB16F: number;
  80972. RED: number;
  80973. RG: number;
  80974. R8: number;
  80975. RG8: number;
  80976. UNSIGNED_INT_24_8: number;
  80977. DEPTH24_STENCIL8: number;
  80978. MIN: number;
  80979. MAX: number;
  80980. /* Multiple Render Targets */
  80981. drawBuffers(buffers: number[]): void;
  80982. readBuffer(src: number): void;
  80983. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  80984. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  80985. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  80986. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  80987. // Occlusion Query
  80988. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  80989. ANY_SAMPLES_PASSED: number;
  80990. QUERY_RESULT_AVAILABLE: number;
  80991. QUERY_RESULT: number;
  80992. }
  80993. interface WebGLProgram {
  80994. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  80995. }
  80996. interface EXT_disjoint_timer_query {
  80997. QUERY_COUNTER_BITS_EXT: number;
  80998. TIME_ELAPSED_EXT: number;
  80999. TIMESTAMP_EXT: number;
  81000. GPU_DISJOINT_EXT: number;
  81001. QUERY_RESULT_EXT: number;
  81002. QUERY_RESULT_AVAILABLE_EXT: number;
  81003. queryCounterEXT(query: WebGLQuery, target: number): void;
  81004. createQueryEXT(): WebGLQuery;
  81005. beginQueryEXT(target: number, query: WebGLQuery): void;
  81006. endQueryEXT(target: number): void;
  81007. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  81008. deleteQueryEXT(query: WebGLQuery): void;
  81009. }
  81010. interface WebGLUniformLocation {
  81011. _currentState: any;
  81012. }
  81013. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  81014. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  81015. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  81016. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  81017. interface WebGLRenderingContext {
  81018. readonly RASTERIZER_DISCARD: number;
  81019. readonly DEPTH_COMPONENT24: number;
  81020. readonly TEXTURE_3D: number;
  81021. readonly TEXTURE_2D_ARRAY: number;
  81022. readonly TEXTURE_COMPARE_FUNC: number;
  81023. readonly TEXTURE_COMPARE_MODE: number;
  81024. readonly COMPARE_REF_TO_TEXTURE: number;
  81025. readonly TEXTURE_WRAP_R: number;
  81026. readonly HALF_FLOAT: number;
  81027. readonly RGB8: number;
  81028. readonly RED_INTEGER: number;
  81029. readonly RG_INTEGER: number;
  81030. readonly RGB_INTEGER: number;
  81031. readonly RGBA_INTEGER: number;
  81032. readonly R8_SNORM: number;
  81033. readonly RG8_SNORM: number;
  81034. readonly RGB8_SNORM: number;
  81035. readonly RGBA8_SNORM: number;
  81036. readonly R8I: number;
  81037. readonly RG8I: number;
  81038. readonly RGB8I: number;
  81039. readonly RGBA8I: number;
  81040. readonly R8UI: number;
  81041. readonly RG8UI: number;
  81042. readonly RGB8UI: number;
  81043. readonly RGBA8UI: number;
  81044. readonly R16I: number;
  81045. readonly RG16I: number;
  81046. readonly RGB16I: number;
  81047. readonly RGBA16I: number;
  81048. readonly R16UI: number;
  81049. readonly RG16UI: number;
  81050. readonly RGB16UI: number;
  81051. readonly RGBA16UI: number;
  81052. readonly R32I: number;
  81053. readonly RG32I: number;
  81054. readonly RGB32I: number;
  81055. readonly RGBA32I: number;
  81056. readonly R32UI: number;
  81057. readonly RG32UI: number;
  81058. readonly RGB32UI: number;
  81059. readonly RGBA32UI: number;
  81060. readonly RGB10_A2UI: number;
  81061. readonly R11F_G11F_B10F: number;
  81062. readonly RGB9_E5: number;
  81063. readonly RGB10_A2: number;
  81064. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  81065. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  81066. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  81067. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  81068. readonly DEPTH_COMPONENT32F: number;
  81069. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  81070. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  81071. 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;
  81072. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  81073. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  81074. readonly TRANSFORM_FEEDBACK: number;
  81075. readonly INTERLEAVED_ATTRIBS: number;
  81076. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  81077. createTransformFeedback(): WebGLTransformFeedback;
  81078. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  81079. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  81080. beginTransformFeedback(primitiveMode: number): void;
  81081. endTransformFeedback(): void;
  81082. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  81083. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  81084. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  81085. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  81086. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  81087. }
  81088. interface ImageBitmap {
  81089. readonly width: number;
  81090. readonly height: number;
  81091. close(): void;
  81092. }
  81093. interface WebGLQuery extends WebGLObject {
  81094. }
  81095. declare var WebGLQuery: {
  81096. prototype: WebGLQuery;
  81097. new(): WebGLQuery;
  81098. };
  81099. interface WebGLSampler extends WebGLObject {
  81100. }
  81101. declare var WebGLSampler: {
  81102. prototype: WebGLSampler;
  81103. new(): WebGLSampler;
  81104. };
  81105. interface WebGLSync extends WebGLObject {
  81106. }
  81107. declare var WebGLSync: {
  81108. prototype: WebGLSync;
  81109. new(): WebGLSync;
  81110. };
  81111. interface WebGLTransformFeedback extends WebGLObject {
  81112. }
  81113. declare var WebGLTransformFeedback: {
  81114. prototype: WebGLTransformFeedback;
  81115. new(): WebGLTransformFeedback;
  81116. };
  81117. interface WebGLVertexArrayObject extends WebGLObject {
  81118. }
  81119. declare var WebGLVertexArrayObject: {
  81120. prototype: WebGLVertexArrayObject;
  81121. new(): WebGLVertexArrayObject;
  81122. };
  81123. interface Navigator {
  81124. readonly gpu: GPU | undefined;
  81125. }
  81126. interface GPUColorDict {
  81127. a: number;
  81128. b: number;
  81129. g: number;
  81130. r: number;
  81131. }
  81132. type GPUColor = [number, number, number, number] | GPUColorDict;
  81133. interface GPUOrigin2DDict {
  81134. x?: number;
  81135. y?: number;
  81136. }
  81137. type GPUOrigin2D = [number, number] | GPUOrigin2DDict;
  81138. interface GPUOrigin3DDict {
  81139. x?: number;
  81140. y?: number;
  81141. z?: number;
  81142. }
  81143. type GPUOrigin3D = [number, number, number] | GPUOrigin3DDict;
  81144. interface GPUExtent3DDict {
  81145. width: number;
  81146. height: number;
  81147. depth: number;
  81148. }
  81149. type GPUExtent3D = [number, number, number] | GPUExtent3DDict;
  81150. type GPUBindingResource =
  81151. | GPUSampler
  81152. | GPUTextureView
  81153. | GPUBufferBinding;
  81154. type GPUExtensionName =
  81155. | "texture-compression-bc"
  81156. | "timestamp-query"
  81157. | "pipeline-statistics-query"
  81158. | "depth-clamping"
  81159. | "depth24unorm-stencil8"
  81160. | "depth32float-stencil8";
  81161. type GPUAddressMode = "clamp-to-edge" | "repeat" | "mirror-repeat";
  81162. type GPUBindingType =
  81163. | "uniform-buffer"
  81164. | "storage-buffer"
  81165. | "readonly-storage-buffer"
  81166. | "sampler"
  81167. | "comparison-sampler"
  81168. | "sampled-texture"
  81169. | "readonly-storage-texture"
  81170. | "writeonly-storage-texture";
  81171. type GPUBlendFactor =
  81172. | "zero"
  81173. | "one"
  81174. | "src-color"
  81175. | "one-minus-src-color"
  81176. | "src-alpha"
  81177. | "one-minus-src-alpha"
  81178. | "dst-color"
  81179. | "one-minus-dst-color"
  81180. | "dst-alpha"
  81181. | "one-minus-dst-alpha"
  81182. | "src-alpha-saturated"
  81183. | "blend-color"
  81184. | "one-minus-blend-color";
  81185. type GPUBlendOperation =
  81186. | "add"
  81187. | "subtract"
  81188. | "reverse-subtract"
  81189. | "min"
  81190. | "max";
  81191. type GPUCompareFunction =
  81192. | "never"
  81193. | "less"
  81194. | "equal"
  81195. | "less-equal"
  81196. | "greater"
  81197. | "not-equal"
  81198. | "greater-equal"
  81199. | "always";
  81200. type GPUCullMode = "none" | "front" | "back";
  81201. type GPUFilterMode = "nearest" | "linear";
  81202. type GPUFrontFace = "ccw" | "cw";
  81203. type GPUIndexFormat = "uint16" | "uint32";
  81204. type GPUInputStepMode = "vertex" | "instance";
  81205. type GPULoadOp = "load";
  81206. type GPUPrimitiveTopology =
  81207. | "point-list"
  81208. | "line-list"
  81209. | "line-strip"
  81210. | "triangle-list"
  81211. | "triangle-strip";
  81212. type GPUStencilOperation =
  81213. | "keep"
  81214. | "zero"
  81215. | "replace"
  81216. | "invert"
  81217. | "increment-clamp"
  81218. | "decrement-clamp"
  81219. | "increment-wrap"
  81220. | "decrement-wrap";
  81221. type GPUStoreOp = "store" | "clear";
  81222. type GPUTextureDimension = "1d" | "2d" | "3d";
  81223. type GPUTextureFormat =
  81224. | "r8unorm"
  81225. | "r8snorm"
  81226. | "r8uint"
  81227. | "r8sint"
  81228. | "r16uint"
  81229. | "r16sint"
  81230. | "r16float"
  81231. | "rg8unorm"
  81232. | "rg8snorm"
  81233. | "rg8uint"
  81234. | "rg8sint"
  81235. | "r32uint"
  81236. | "r32sint"
  81237. | "r32float"
  81238. | "rg16uint"
  81239. | "rg16sint"
  81240. | "rg16float"
  81241. | "rgba8unorm"
  81242. | "rgba8unorm-srgb"
  81243. | "rgba8snorm"
  81244. | "rgba8uint"
  81245. | "rgba8sint"
  81246. | "bgra8unorm"
  81247. | "bgra8unorm-srgb"
  81248. | "rgb9e5ufloat"
  81249. | "rgb10a2unorm"
  81250. | "rg11b10ufloat"
  81251. | "rg32uint"
  81252. | "rg32sint"
  81253. | "rg32float"
  81254. | "rgba16uint"
  81255. | "rgba16sint"
  81256. | "rgba16float"
  81257. | "rgba32uint"
  81258. | "rgba32sint"
  81259. | "rgba32float"
  81260. | "stencil8"
  81261. | "depth16unorm"
  81262. | "depth24plus"
  81263. | "depth24plus-stencil8"
  81264. | "depth32float"
  81265. | "bc1-rgba-unorm"
  81266. | "bc1-rgba-unorm-srgb"
  81267. | "bc2-rgba-unorm"
  81268. | "bc2-rgba-unorm-srgb"
  81269. | "bc3-rgba-unorm"
  81270. | "bc3-rgba-unorm-srgb"
  81271. | "bc4-r-unorm"
  81272. | "bc4-r-snorm"
  81273. | "bc5-rg-unorm"
  81274. | "bc5-rg-snorm"
  81275. | "bc6h-rgb-ufloat"
  81276. | "bc6h-rgb-float"
  81277. | "bc7-rgba-unorm"
  81278. | "bc7-rgba-unorm-srgb"
  81279. | "depth24unorm-stencil8"
  81280. | "depth32float-stencil8";
  81281. type GPUTextureComponentType = "float" | "sint" | "uint" | "depth-comparison";
  81282. type GPUTextureViewDimension =
  81283. | "1d"
  81284. | "2d"
  81285. | "2d-array"
  81286. | "cube"
  81287. | "cube-array"
  81288. | "3d";
  81289. type GPUVertexFormat =
  81290. | "uchar2"
  81291. | "uchar4"
  81292. | "char2"
  81293. | "char4"
  81294. | "uchar2norm"
  81295. | "uchar4norm"
  81296. | "char2norm"
  81297. | "char4norm"
  81298. | "ushort2"
  81299. | "ushort4"
  81300. | "short2"
  81301. | "short4"
  81302. | "ushort2norm"
  81303. | "ushort4norm"
  81304. | "short2norm"
  81305. | "short4norm"
  81306. | "half2"
  81307. | "half4"
  81308. | "float"
  81309. | "float2"
  81310. | "float3"
  81311. | "float4"
  81312. | "uint"
  81313. | "uint2"
  81314. | "uint3"
  81315. | "uint4"
  81316. | "int"
  81317. | "int2"
  81318. | "int3"
  81319. | "int4";
  81320. type GPUTextureAspect = "all" | "stencil-only" | "depth-only";
  81321. type GPUBufferUsageFlags = number;
  81322. type GPUColorWriteFlags = number;
  81323. type GPUShaderStageFlags = number;
  81324. type GPUTextureUsageFlags = number;
  81325. type GPUMapModeFlags = number;
  81326. interface GPUBindGroupEntry {
  81327. binding: number;
  81328. resource: GPUBindingResource;
  81329. }
  81330. interface GPUBindGroupDescriptor extends GPUObjectDescriptorBase {
  81331. layout: GPUBindGroupLayout;
  81332. entries: Iterable<GPUBindGroupEntry>;
  81333. }
  81334. interface GPUBindGroupLayoutEntry {
  81335. binding: number;
  81336. visibility: GPUShaderStageFlags;
  81337. type: GPUBindingType;
  81338. hasDynamicOffset?: boolean;
  81339. minBufferBindingSize?: number;
  81340. viewDimension?: GPUTextureViewDimension;
  81341. textureComponentType?: GPUTextureComponentType;
  81342. storageTextureFormat?: GPUTextureFormat;
  81343. }
  81344. interface GPUBindGroupLayoutDescriptor
  81345. extends GPUObjectDescriptorBase {
  81346. entries: Iterable<GPUBindGroupLayoutEntry>;
  81347. }
  81348. interface GPUBlendDescriptor {
  81349. dstFactor?: GPUBlendFactor;
  81350. operation?: GPUBlendOperation;
  81351. srcFactor?: GPUBlendFactor;
  81352. }
  81353. interface GPUColorStateDescriptor {
  81354. format: GPUTextureFormat;
  81355. alphaBlend?: GPUBlendDescriptor;
  81356. colorBlend?: GPUBlendDescriptor;
  81357. writeMask?: GPUColorWriteFlags;
  81358. }
  81359. interface GPUBufferBinding {
  81360. buffer: GPUBuffer;
  81361. offset?: number;
  81362. size?: number;
  81363. }
  81364. interface GPUTextureDataLayout {
  81365. offset?: number;
  81366. bytesPerRow: number;
  81367. rowsPerImage?: number;
  81368. }
  81369. interface GPUBufferCopyView extends GPUTextureDataLayout {
  81370. buffer: GPUBuffer;
  81371. }
  81372. interface GPUTextureCopyView {
  81373. texture: GPUTexture;
  81374. mipLevel?: number;
  81375. origin?: GPUOrigin3D;
  81376. }
  81377. interface GPUImageBitmapCopyView {
  81378. imageBitmap: ImageBitmap;
  81379. origin?: GPUOrigin2D;
  81380. }
  81381. interface GPUBufferDescriptor extends GPUObjectDescriptorBase {
  81382. size: number;
  81383. usage: GPUBufferUsageFlags;
  81384. mappedAtCreation?: boolean;
  81385. }
  81386. interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {
  81387. label?: string;
  81388. measureExecutionTime?: boolean;
  81389. }
  81390. interface GPUComputePipelineDescriptor
  81391. extends GPUPipelineDescriptorBase {
  81392. computeStage: GPUProgrammableStageDescriptor;
  81393. }
  81394. interface GPUDepthStencilStateDescriptor {
  81395. format: GPUTextureFormat;
  81396. depthWriteEnabled?: boolean;
  81397. depthCompare?: GPUCompareFunction;
  81398. stencilFront?: GPUStencilStateFaceDescriptor;
  81399. stencilBack?: GPUStencilStateFaceDescriptor;
  81400. stencilReadMask?: number;
  81401. stencilWriteMask?: number;
  81402. }
  81403. interface GPUDeviceDescriptor extends GPUObjectDescriptorBase {
  81404. extensions?: Iterable<GPUExtensionName>;
  81405. limits?: GPULimits;
  81406. }
  81407. interface GPUFenceDescriptor extends GPUObjectDescriptorBase {
  81408. initialValue?: number;
  81409. label?: string;
  81410. signalQueue?: GPUQueue;
  81411. }
  81412. interface GPUVertexAttributeDescriptor {
  81413. format: GPUVertexFormat;
  81414. offset: number;
  81415. shaderLocation: number;
  81416. }
  81417. interface GPUVertexBufferLayoutDescriptor {
  81418. arrayStride: number;
  81419. stepMode?: GPUInputStepMode;
  81420. attributes: Iterable<GPUVertexAttributeDescriptor>;
  81421. }
  81422. interface GPUVertexStateDescriptor {
  81423. indexFormat?: GPUIndexFormat;
  81424. vertexBuffers?: Iterable<GPUVertexBufferLayoutDescriptor>;
  81425. }
  81426. interface GPULimits {
  81427. maxBindGroups?: number;
  81428. maxDynamicUniformBuffersPerPipelineLayout?: number;
  81429. maxDynamicStorageBuffersPerPipelineLayout?: number;
  81430. maxSampledTexturesPerShaderStage?: number;
  81431. maxSamplersPerShaderStage?: number;
  81432. maxStorageBuffersPerShaderStage?: number;
  81433. maxStorageTexturesPerShaderStage?: number;
  81434. maxUniformBuffersPerShaderStage?: number;
  81435. maxUniformBufferBindingSize?: number;
  81436. }
  81437. interface GPUPipelineDescriptorBase {
  81438. label?: string;
  81439. layout?: GPUPipelineLayout;
  81440. }
  81441. interface GPUPipelineLayoutDescriptor extends GPUObjectDescriptorBase {
  81442. bindGroupLayouts: Iterable<GPUBindGroupLayout>;
  81443. }
  81444. interface GPUProgrammableStageDescriptor {
  81445. module: GPUShaderModule;
  81446. entryPoint: string;
  81447. }
  81448. interface GPURasterizationStateDescriptor {
  81449. frontFace?: GPUFrontFace;
  81450. cullMode?: GPUCullMode;
  81451. clampDepth?: boolean;
  81452. depthBias?: number;
  81453. depthBiasSlopeScale?: number;
  81454. depthBiasClamp?: number;
  81455. }
  81456. interface GPURenderPassColorAttachmentDescriptor {
  81457. attachment: GPUTextureView;
  81458. resolveTarget?: GPUTextureView;
  81459. loadValue: GPULoadOp | GPUColor;
  81460. storeOp?: GPUStoreOp;
  81461. }
  81462. interface GPURenderPassDepthStencilAttachmentDescriptor {
  81463. attachment: GPUTextureView;
  81464. depthLoadValue: GPULoadOp | number;
  81465. depthStoreOp: GPUStoreOp;
  81466. depthReadOnly?: boolean;
  81467. stencilLoadValue: GPULoadOp | number;
  81468. stencilStoreOp: GPUStoreOp;
  81469. stencilReadOnly?: boolean;
  81470. }
  81471. interface GPURenderPassDescriptor extends GPUObjectDescriptorBase {
  81472. colorAttachments: Iterable<GPURenderPassColorAttachmentDescriptor>;
  81473. depthStencilAttachment?: GPURenderPassDepthStencilAttachmentDescriptor;
  81474. }
  81475. interface GPURenderPipelineDescriptor
  81476. extends GPUPipelineDescriptorBase {
  81477. vertexStage: GPUProgrammableStageDescriptor;
  81478. fragmentStage?: GPUProgrammableStageDescriptor;
  81479. primitiveTopology: GPUPrimitiveTopology;
  81480. rasterizationState?: GPURasterizationStateDescriptor;
  81481. colorStates: Iterable<GPUColorStateDescriptor>;
  81482. depthStencilState?: GPUDepthStencilStateDescriptor;
  81483. vertexState?: GPUVertexStateDescriptor;
  81484. sampleCount?: number;
  81485. sampleMask?: number;
  81486. alphaToCoverageEnabled?: boolean;
  81487. }
  81488. interface GPUSamplerDescriptor extends GPUObjectDescriptorBase {
  81489. addressModeU?: GPUAddressMode;
  81490. addressModeV?: GPUAddressMode;
  81491. addressModeW?: GPUAddressMode;
  81492. magFilter?: GPUFilterMode;
  81493. minFilter?: GPUFilterMode;
  81494. mipmapFilter?: GPUFilterMode;
  81495. lodMinClamp?: number;
  81496. lodMaxClamp?: number;
  81497. compare?: GPUCompareFunction;
  81498. maxAnisotropy?: number;
  81499. }
  81500. interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase {
  81501. code: Uint32Array | string;
  81502. label?: string;
  81503. sourceMap?: object;
  81504. }
  81505. interface GPUStencilStateFaceDescriptor {
  81506. compare?: GPUCompareFunction;
  81507. depthFailOp?: GPUStencilOperation;
  81508. passOp?: GPUStencilOperation;
  81509. failOp?: GPUStencilOperation;
  81510. }
  81511. interface GPUSwapChainDescriptor extends GPUObjectDescriptorBase {
  81512. device: GPUDevice;
  81513. format: GPUTextureFormat;
  81514. usage?: GPUTextureUsageFlags;
  81515. }
  81516. interface GPUTextureDescriptor extends GPUObjectDescriptorBase {
  81517. size: GPUExtent3D;
  81518. mipLevelCount?: number;
  81519. sampleCount?: number;
  81520. dimension?: GPUTextureDimension;
  81521. format: GPUTextureFormat;
  81522. usage: GPUTextureUsageFlags;
  81523. }
  81524. interface GPUTextureViewDescriptor extends GPUObjectDescriptorBase {
  81525. format?: GPUTextureFormat;
  81526. dimension?: GPUTextureViewDimension;
  81527. aspect?: GPUTextureAspect;
  81528. baseArrayLayer?: number;
  81529. baseMipLevel?: number;
  81530. arrayLayerCount?: number;
  81531. mipLevelCount?: number;
  81532. }
  81533. declare class GPUAdapter {
  81534. // https://michalzalecki.com/nominal-typing-in-typescript/#approach-1-class-with-a-private-property
  81535. private __brand: void;
  81536. readonly name: string;
  81537. readonly extensions: GPUExtensionName[];
  81538. readonly limits: Required<GPULimits>;
  81539. requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice | null>;
  81540. }
  81541. declare class GPUBindGroup implements GPUObjectBase {
  81542. private __brand: void;
  81543. label: string | undefined;
  81544. }
  81545. declare class GPUBindGroupLayout implements GPUObjectBase {
  81546. private __brand: void;
  81547. label: string | undefined;
  81548. }
  81549. declare class GPUBuffer implements GPUObjectBase {
  81550. private __brand: void;
  81551. label: string | undefined;
  81552. destroy(): void;
  81553. unmap(): void;
  81554. mapAsync(mode: GPUMapModeFlags, offset?: number, size?: number): Promise<void>;
  81555. getMappedRange(offset?: number, size?: number): ArrayBuffer;
  81556. }
  81557. declare class GPUCommandBuffer implements GPUObjectBase {
  81558. private __brand: void;
  81559. label: string | undefined;
  81560. readonly executionTime: Promise<number>;
  81561. }
  81562. interface GPUCommandBufferDescriptor extends GPUObjectDescriptorBase { }
  81563. declare class GPUCommandEncoder implements GPUObjectBase {
  81564. private __brand: void;
  81565. label: string | undefined;
  81566. beginComputePass(
  81567. descriptor?: GPUComputePassDescriptor
  81568. ): GPUComputePassEncoder;
  81569. beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder;
  81570. copyBufferToBuffer(
  81571. source: GPUBuffer,
  81572. sourceOffset: number,
  81573. destination: GPUBuffer,
  81574. destinationOffset: number,
  81575. size: number
  81576. ): void;
  81577. copyBufferToTexture(
  81578. source: GPUBufferCopyView,
  81579. destination: GPUTextureCopyView,
  81580. copySize: GPUExtent3D
  81581. ): void;
  81582. copyTextureToBuffer(
  81583. source: GPUTextureCopyView,
  81584. destination: GPUBufferCopyView,
  81585. copySize: GPUExtent3D
  81586. ): void;
  81587. copyTextureToTexture(
  81588. source: GPUTextureCopyView,
  81589. destination: GPUTextureCopyView,
  81590. copySize: GPUExtent3D
  81591. ): void;
  81592. finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer;
  81593. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81594. popDebugGroup(): void;
  81595. pushDebugGroup(groupLabel: string): void;
  81596. insertDebugMarker(markerLabel: string): void;
  81597. }
  81598. interface GPUComputePassDescriptor extends GPUObjectDescriptorBase { }
  81599. declare class GPUComputePassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder {
  81600. private __brand: void;
  81601. label: string | undefined;
  81602. setBindGroup(
  81603. index: number,
  81604. bindGroup: GPUBindGroup,
  81605. dynamicOffsets?: Iterable<number>
  81606. ): void;
  81607. popDebugGroup(): void;
  81608. pushDebugGroup(groupLabel: string): void;
  81609. insertDebugMarker(markerLabel: string): void;
  81610. setPipeline(pipeline: GPUComputePipeline): void;
  81611. dispatch(x: number, y?: number, z?: number): void;
  81612. dispatchIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81613. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81614. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81615. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81616. endPass(): void;
  81617. }
  81618. declare class GPUComputePipeline implements GPUPipelineBase {
  81619. private __brand: void;
  81620. label: string | undefined;
  81621. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81622. }
  81623. interface GPUObjectBase {
  81624. label: string | undefined;
  81625. }
  81626. interface GPUObjectDescriptorBase {
  81627. label?: string;
  81628. }
  81629. // SwapChain / CanvasContext
  81630. declare class GPUCanvasContext {
  81631. private __brand: void;
  81632. configureSwapChain(descriptor: GPUSwapChainDescriptor): GPUSwapChain;
  81633. getSwapChainPreferredFormat(device: GPUDevice): Promise<GPUTextureFormat>;
  81634. }
  81635. declare class GPUDevice extends EventTarget implements GPUObjectBase {
  81636. private __brand: void;
  81637. label: string | undefined;
  81638. readonly adapter: GPUAdapter;
  81639. readonly extensions: GPUExtensionName[];
  81640. readonly limits: Required<GPULimits>;
  81641. createBindGroup(descriptor: GPUBindGroupDescriptor): GPUBindGroup;
  81642. createBindGroupLayout(
  81643. descriptor: GPUBindGroupLayoutDescriptor
  81644. ): GPUBindGroupLayout;
  81645. createBuffer(descriptor: GPUBufferDescriptor): GPUBuffer;
  81646. createPipelineLayout(
  81647. descriptor: GPUPipelineLayoutDescriptor
  81648. ): GPUPipelineLayout;
  81649. createSampler(descriptor?: GPUSamplerDescriptor): GPUSampler;
  81650. createShaderModule(descriptor: GPUShaderModuleDescriptor): GPUShaderModule;
  81651. createTexture(descriptor: GPUTextureDescriptor): GPUTexture;
  81652. createComputePipeline(
  81653. descriptor: GPUComputePipelineDescriptor
  81654. ): GPUComputePipeline;
  81655. createRenderPipeline(
  81656. descriptor: GPURenderPipelineDescriptor
  81657. ): GPURenderPipeline;
  81658. createReadyComputePipeline(
  81659. descriptor: GPUComputePipelineDescriptor
  81660. ): Promise<GPUComputePipeline>;
  81661. createReadyRenderPipeline(
  81662. descriptor: GPURenderPipelineDescriptor
  81663. ): Promise<GPURenderPipeline>;
  81664. createCommandEncoder(
  81665. descriptor?: GPUCommandEncoderDescriptor
  81666. ): GPUCommandEncoder;
  81667. createRenderBundleEncoder(
  81668. descriptor: GPURenderBundleEncoderDescriptor
  81669. ): GPURenderBundleEncoder;
  81670. createQuerySet(descriptor: GPUQuerySetDescriptor): GPUQuerySet;
  81671. defaultQueue: GPUQueue;
  81672. pushErrorScope(filter: GPUErrorFilter): void;
  81673. popErrorScope(): Promise<GPUError | null>;
  81674. onuncapturederror: Event | undefined;
  81675. readonly lost: Promise<GPUDeviceLostInfo>;
  81676. }
  81677. declare class GPUFence implements GPUObjectBase {
  81678. private __brand: void;
  81679. label: string | undefined;
  81680. getCompletedValue(): number;
  81681. onCompletion(completionValue: number): Promise<void>;
  81682. }
  81683. interface GPUPipelineBase extends GPUObjectBase {
  81684. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81685. }
  81686. declare class GPUPipelineLayout implements GPUObjectBase {
  81687. private __brand: void;
  81688. label: string | undefined;
  81689. }
  81690. interface GPUProgrammablePassEncoder {
  81691. setBindGroup(
  81692. index: number,
  81693. bindGroup: GPUBindGroup,
  81694. dynamicOffsets?: Iterable<number>
  81695. ): void;
  81696. popDebugGroup(): void;
  81697. pushDebugGroup(groupLabel: string): void;
  81698. insertDebugMarker(markerLabel: string): void;
  81699. }
  81700. declare class GPUQueue implements GPUObjectBase {
  81701. private __brand: void;
  81702. label: string | undefined;
  81703. signal(fence: GPUFence, signalValue: number): void;
  81704. submit(commandBuffers: Iterable<GPUCommandBuffer>): void;
  81705. createFence(descriptor?: GPUFenceDescriptor): GPUFence;
  81706. writeBuffer(buffer: GPUBuffer,
  81707. bufferOffset: number,
  81708. data: BufferSource | ArrayBuffer,
  81709. dataOffset?: number,
  81710. size?: number): void;
  81711. writeTexture(destination: GPUTextureCopyView,
  81712. data: BufferSource | ArrayBuffer,
  81713. dataLayout: GPUTextureDataLayout,
  81714. size: GPUExtent3D): void;
  81715. copyImageBitmapToTexture(
  81716. source: GPUImageBitmapCopyView,
  81717. destination: GPUTextureCopyView,
  81718. copySize: GPUExtent3D
  81719. ): void;
  81720. }
  81721. type GPUQueryType =
  81722. | "occlusion"
  81723. | "timestamp"
  81724. | "pipeline-statistics";
  81725. type GPUPipelineStatisticName =
  81726. | "vertex-shader-invocations"
  81727. | "clipper-invocations"
  81728. | "clipper-primitives-out"
  81729. | "fragment-shader-invocations"
  81730. | "compute-shader-invocations";
  81731. interface GPUQuerySetDescriptor extends GPUObjectDescriptorBase {
  81732. type: GPUQueryType;
  81733. count: number;
  81734. pipelineStatistics?: Iterable<GPUPipelineStatisticName>;
  81735. }
  81736. declare class GPUQuerySet implements GPUObjectBase {
  81737. private __brand: void;
  81738. label: string | undefined;
  81739. destroy(): void;
  81740. }
  81741. interface GPURenderEncoderBase {
  81742. setPipeline(pipeline: GPURenderPipeline): void;
  81743. setIndexBuffer(buffer: GPUBuffer, offset?: number, size?: number): void;
  81744. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81745. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number, size?: number): void;
  81746. draw(
  81747. vertexCount: number,
  81748. instanceCount?: number,
  81749. firstVertex?: number,
  81750. firstInstance?: number
  81751. ): void;
  81752. drawIndexed(
  81753. indexCount: number,
  81754. instanceCount?: number,
  81755. firstIndex?: number,
  81756. baseVertex?: number,
  81757. firstInstance?: number
  81758. ): void;
  81759. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81760. drawIndexedIndirect(
  81761. indirectBuffer: GPUBuffer,
  81762. indirectOffset: number
  81763. ): void;
  81764. }
  81765. declare class GPURenderPassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder, GPURenderEncoderBase {
  81766. private __brand: void;
  81767. label: string | undefined;
  81768. setBindGroup(
  81769. index: number,
  81770. bindGroup: GPUBindGroup,
  81771. dynamicOffsets?: Iterable<number>
  81772. ): void;
  81773. popDebugGroup(): void;
  81774. pushDebugGroup(groupLabel: string): void;
  81775. insertDebugMarker(markerLabel: string): void;
  81776. setPipeline(pipeline: GPURenderPipeline): void;
  81777. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  81778. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81779. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  81780. draw(
  81781. vertexCount: number,
  81782. instanceCount?: number,
  81783. firstVertex?: number,
  81784. firstInstance?: number
  81785. ): void;
  81786. drawIndexed(
  81787. indexCount: number,
  81788. instanceCount?: number,
  81789. firstIndex?: number,
  81790. baseVertex?: number,
  81791. firstInstance?: number
  81792. ): void;
  81793. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81794. drawIndexedIndirect(
  81795. indirectBuffer: GPUBuffer,
  81796. indirectOffset: number
  81797. ): void;
  81798. setViewport(
  81799. x: number,
  81800. y: number,
  81801. width: number,
  81802. height: number,
  81803. minDepth: number,
  81804. maxDepth: number
  81805. ): void;
  81806. setScissorRect(x: number, y: number, width: number, height: number): void;
  81807. setBlendColor(color: GPUColor): void;
  81808. setStencilReference(reference: number): void;
  81809. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81810. beginOcclusionQuery(queryIndex: number): void;
  81811. endOcclusionQuery(): void;
  81812. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81813. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81814. executeBundles(bundles: Iterable<GPURenderBundle>): void;
  81815. endPass(): void;
  81816. }
  81817. interface GPURenderBundleDescriptor extends GPUObjectDescriptorBase { }
  81818. declare class GPURenderBundle implements GPUObjectBase {
  81819. private __brand: void;
  81820. label: string | undefined;
  81821. }
  81822. declare class GPURenderBundleEncoder implements GPURenderEncoderBase {
  81823. private __brand: void;
  81824. label: string | undefined;
  81825. setBindGroup(
  81826. index: number,
  81827. bindGroup: GPUBindGroup,
  81828. dynamicOffsets?: Iterable<number>
  81829. ): void;
  81830. popDebugGroup(): void;
  81831. pushDebugGroup(groupLabel: string): void;
  81832. insertDebugMarker(markerLabel: string): void;
  81833. setPipeline(pipeline: GPURenderPipeline): void;
  81834. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  81835. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81836. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  81837. draw(
  81838. vertexCount: number,
  81839. instanceCount?: number,
  81840. firstVertex?: number,
  81841. firstInstance?: number
  81842. ): void;
  81843. drawIndexed(
  81844. indexCount: number,
  81845. instanceCount?: number,
  81846. firstIndex?: number,
  81847. baseVertex?: number,
  81848. firstInstance?: number
  81849. ): void;
  81850. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81851. drawIndexedIndirect(
  81852. indirectBuffer: GPUBuffer,
  81853. indirectOffset: number
  81854. ): void;
  81855. finish(descriptor?: GPURenderBundleDescriptor): GPURenderBundle;
  81856. }
  81857. interface GPURenderBundleEncoderDescriptor
  81858. extends GPUObjectDescriptorBase {
  81859. colorFormats: Iterable<GPUTextureFormat>;
  81860. depthStencilFormat?: GPUTextureFormat;
  81861. sampleCount?: number;
  81862. }
  81863. declare class GPURenderPipeline implements GPUPipelineBase {
  81864. private __brand: void;
  81865. label: string | undefined;
  81866. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81867. }
  81868. declare class GPUSampler implements GPUObjectBase {
  81869. private __brand: void;
  81870. label: string | undefined;
  81871. }
  81872. type GPUCompilationMessageType =
  81873. | "error"
  81874. | "warning"
  81875. | "info";
  81876. interface GPUCompilationMessage {
  81877. readonly message: string;
  81878. readonly type: GPUCompilationMessageType;
  81879. readonly lineNum: number;
  81880. readonly linePos: number;
  81881. }
  81882. interface GPUCompilationInfo {
  81883. readonly messages: readonly GPUCompilationMessage[];
  81884. }
  81885. declare class GPUShaderModule implements GPUObjectBase {
  81886. private __brand: void;
  81887. label: string | undefined;
  81888. compilationInfo(): Promise<GPUCompilationInfo>;
  81889. }
  81890. declare class GPUSwapChain implements GPUObjectBase {
  81891. private __brand: void;
  81892. label: string | undefined;
  81893. getCurrentTexture(): GPUTexture;
  81894. }
  81895. declare class GPUTexture implements GPUObjectBase {
  81896. private __brand: void;
  81897. label: string | undefined;
  81898. createView(descriptor?: GPUTextureViewDescriptor): GPUTextureView;
  81899. destroy(): void;
  81900. }
  81901. declare class GPUTextureView implements GPUObjectBase {
  81902. private __brand: void;
  81903. label: string | undefined;
  81904. }
  81905. type GPUPowerPreference = "low-power" | "high-performance";
  81906. interface GPURequestAdapterOptions {
  81907. powerPreference?: GPUPowerPreference;
  81908. }
  81909. declare class GPU {
  81910. private __brand: void;
  81911. requestAdapter(options?: GPURequestAdapterOptions): Promise<GPUAdapter | null>;
  81912. }
  81913. // ****************************************************************************
  81914. // ERROR SCOPES
  81915. // ****************************************************************************
  81916. type GPUErrorFilter = "out-of-memory" | "validation";
  81917. declare class GPUOutOfMemoryError {
  81918. private __brand: void;
  81919. constructor();
  81920. }
  81921. declare class GPUValidationError {
  81922. private __brand: void;
  81923. constructor(message: string);
  81924. readonly message: string;
  81925. }
  81926. type GPUError = GPUOutOfMemoryError | GPUValidationError;
  81927. // ****************************************************************************
  81928. // TELEMETRY
  81929. // ****************************************************************************
  81930. declare class GPUUncapturedErrorEvent extends Event {
  81931. private __brand: void;
  81932. constructor(
  81933. type: string,
  81934. gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit
  81935. );
  81936. readonly error: GPUError;
  81937. }
  81938. interface GPUUncapturedErrorEventInit extends EventInit {
  81939. error: GPUError;
  81940. }
  81941. declare class GPUDeviceLostInfo {
  81942. private __brand: void;
  81943. readonly message: string;
  81944. }
  81945. // Type definitions for WebVR API
  81946. // Project: https://w3c.github.io/webvr/
  81947. // Definitions by: six a <https://github.com/lostfictions>
  81948. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  81949. interface VRDisplay extends EventTarget {
  81950. /**
  81951. * Dictionary of capabilities describing the VRDisplay.
  81952. */
  81953. readonly capabilities: VRDisplayCapabilities;
  81954. /**
  81955. * z-depth defining the far plane of the eye view frustum
  81956. * enables mapping of values in the render target depth
  81957. * attachment to scene coordinates. Initially set to 10000.0.
  81958. */
  81959. depthFar: number;
  81960. /**
  81961. * z-depth defining the near plane of the eye view frustum
  81962. * enables mapping of values in the render target depth
  81963. * attachment to scene coordinates. Initially set to 0.01.
  81964. */
  81965. depthNear: number;
  81966. /**
  81967. * An identifier for this distinct VRDisplay. Used as an
  81968. * association point in the Gamepad API.
  81969. */
  81970. readonly displayId: number;
  81971. /**
  81972. * A display name, a user-readable name identifying it.
  81973. */
  81974. readonly displayName: string;
  81975. readonly isConnected: boolean;
  81976. readonly isPresenting: boolean;
  81977. /**
  81978. * If this VRDisplay supports room-scale experiences, the optional
  81979. * stage attribute contains details on the room-scale parameters.
  81980. */
  81981. readonly stageParameters: VRStageParameters | null;
  81982. /**
  81983. * Passing the value returned by `requestAnimationFrame` to
  81984. * `cancelAnimationFrame` will unregister the callback.
  81985. * @param handle Define the hanle of the request to cancel
  81986. */
  81987. cancelAnimationFrame(handle: number): void;
  81988. /**
  81989. * Stops presenting to the VRDisplay.
  81990. * @returns a promise to know when it stopped
  81991. */
  81992. exitPresent(): Promise<void>;
  81993. /**
  81994. * Return the current VREyeParameters for the given eye.
  81995. * @param whichEye Define the eye we want the parameter for
  81996. * @returns the eye parameters
  81997. */
  81998. getEyeParameters(whichEye: string): VREyeParameters;
  81999. /**
  82000. * Populates the passed VRFrameData with the information required to render
  82001. * the current frame.
  82002. * @param frameData Define the data structure to populate
  82003. * @returns true if ok otherwise false
  82004. */
  82005. getFrameData(frameData: VRFrameData): boolean;
  82006. /**
  82007. * Get the layers currently being presented.
  82008. * @returns the list of VR layers
  82009. */
  82010. getLayers(): VRLayer[];
  82011. /**
  82012. * Return a VRPose containing the future predicted pose of the VRDisplay
  82013. * when the current frame will be presented. The value returned will not
  82014. * change until JavaScript has returned control to the browser.
  82015. *
  82016. * The VRPose will contain the position, orientation, velocity,
  82017. * and acceleration of each of these properties.
  82018. * @returns the pose object
  82019. */
  82020. getPose(): VRPose;
  82021. /**
  82022. * Return the current instantaneous pose of the VRDisplay, with no
  82023. * prediction applied.
  82024. * @returns the current instantaneous pose
  82025. */
  82026. getImmediatePose(): VRPose;
  82027. /**
  82028. * The callback passed to `requestAnimationFrame` will be called
  82029. * any time a new frame should be rendered. When the VRDisplay is
  82030. * presenting the callback will be called at the native refresh
  82031. * rate of the HMD. When not presenting this function acts
  82032. * identically to how window.requestAnimationFrame acts. Content should
  82033. * make no assumptions of frame rate or vsync behavior as the HMD runs
  82034. * asynchronously from other displays and at differing refresh rates.
  82035. * @param callback Define the action to run next frame
  82036. * @returns the request handle it
  82037. */
  82038. requestAnimationFrame(callback: FrameRequestCallback): number;
  82039. /**
  82040. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  82041. * Repeat calls while already presenting will update the VRLayers being displayed.
  82042. * @param layers Define the list of layer to present
  82043. * @returns a promise to know when the request has been fulfilled
  82044. */
  82045. requestPresent(layers: VRLayer[]): Promise<void>;
  82046. /**
  82047. * Reset the pose for this display, treating its current position and
  82048. * orientation as the "origin/zero" values. VRPose.position,
  82049. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  82050. * updated when calling resetPose(). This should be called in only
  82051. * sitting-space experiences.
  82052. */
  82053. resetPose(): void;
  82054. /**
  82055. * The VRLayer provided to the VRDisplay will be captured and presented
  82056. * in the HMD. Calling this function has the same effect on the source
  82057. * canvas as any other operation that uses its source image, and canvases
  82058. * created without preserveDrawingBuffer set to true will be cleared.
  82059. * @param pose Define the pose to submit
  82060. */
  82061. submitFrame(pose?: VRPose): void;
  82062. }
  82063. declare var VRDisplay: {
  82064. prototype: VRDisplay;
  82065. new(): VRDisplay;
  82066. };
  82067. interface VRLayer {
  82068. leftBounds?: number[] | Float32Array | null;
  82069. rightBounds?: number[] | Float32Array | null;
  82070. source?: HTMLCanvasElement | null;
  82071. }
  82072. interface VRDisplayCapabilities {
  82073. readonly canPresent: boolean;
  82074. readonly hasExternalDisplay: boolean;
  82075. readonly hasOrientation: boolean;
  82076. readonly hasPosition: boolean;
  82077. readonly maxLayers: number;
  82078. }
  82079. interface VREyeParameters {
  82080. /** @deprecated */
  82081. readonly fieldOfView: VRFieldOfView;
  82082. readonly offset: Float32Array;
  82083. readonly renderHeight: number;
  82084. readonly renderWidth: number;
  82085. }
  82086. interface VRFieldOfView {
  82087. readonly downDegrees: number;
  82088. readonly leftDegrees: number;
  82089. readonly rightDegrees: number;
  82090. readonly upDegrees: number;
  82091. }
  82092. interface VRFrameData {
  82093. readonly leftProjectionMatrix: Float32Array;
  82094. readonly leftViewMatrix: Float32Array;
  82095. readonly pose: VRPose;
  82096. readonly rightProjectionMatrix: Float32Array;
  82097. readonly rightViewMatrix: Float32Array;
  82098. readonly timestamp: number;
  82099. }
  82100. interface VRPose {
  82101. readonly angularAcceleration: Float32Array | null;
  82102. readonly angularVelocity: Float32Array | null;
  82103. readonly linearAcceleration: Float32Array | null;
  82104. readonly linearVelocity: Float32Array | null;
  82105. readonly orientation: Float32Array | null;
  82106. readonly position: Float32Array | null;
  82107. readonly timestamp: number;
  82108. }
  82109. interface VRStageParameters {
  82110. sittingToStandingTransform?: Float32Array;
  82111. sizeX?: number;
  82112. sizeY?: number;
  82113. }
  82114. interface Navigator {
  82115. getVRDisplays(): Promise<VRDisplay[]>;
  82116. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  82117. }
  82118. interface Window {
  82119. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  82120. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  82121. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  82122. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  82123. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  82124. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  82125. }
  82126. interface Gamepad {
  82127. readonly displayId: number;
  82128. }
  82129. /**
  82130. * Available session modes
  82131. */
  82132. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  82133. /**
  82134. * Reference space types
  82135. */
  82136. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  82137. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  82138. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  82139. /**
  82140. * Handedness types
  82141. */
  82142. type XRHandedness = "none" | "left" | "right";
  82143. /**
  82144. * InputSource target ray modes
  82145. */
  82146. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  82147. /**
  82148. * Eye types
  82149. */
  82150. type XREye = "none" | "left" | "right";
  82151. /**
  82152. * Type of XR events available
  82153. */
  82154. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  82155. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  82156. type XRPlaneSet = Set<XRPlane>;
  82157. type XRAnchorSet = Set<XRAnchor>;
  82158. type XREventHandler = (callback: any) => void;
  82159. interface XRLayer extends EventTarget {}
  82160. interface XRSessionInit {
  82161. optionalFeatures?: string[];
  82162. requiredFeatures?: string[];
  82163. trackedImages?: XRTrackedImageInit[];
  82164. }
  82165. interface XRSessionEvent extends Event {
  82166. readonly session: XRSession;
  82167. }
  82168. interface XRSystem {
  82169. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  82170. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  82171. }
  82172. interface XRViewport {
  82173. readonly x: number;
  82174. readonly y: number;
  82175. readonly width: number;
  82176. readonly height: number;
  82177. }
  82178. interface XRWebGLLayerInit {
  82179. antialias?: boolean;
  82180. depth?: boolean;
  82181. stencil?: boolean;
  82182. alpha?: boolean;
  82183. multiview?: boolean;
  82184. framebufferScaleFactor?: number;
  82185. }
  82186. declare class XRWebGLLayer {
  82187. static getNativeFramebufferScaleFactor(session: XRSession): number;
  82188. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  82189. readonly antialias: boolean;
  82190. readonly framebuffer: WebGLFramebuffer;
  82191. readonly framebufferWidth: number;
  82192. readonly framebufferHeight: number;
  82193. readonly ignoreDepthValues: boolean;
  82194. getViewport: (view: XRView) => XRViewport;
  82195. }
  82196. // tslint:disable-next-line no-empty-interface
  82197. interface XRSpace extends EventTarget {}
  82198. interface XRRenderState {
  82199. readonly baseLayer?: XRWebGLLayer;
  82200. readonly depthFar: number;
  82201. readonly depthNear: number;
  82202. readonly inlineVerticalFieldOfView?: number;
  82203. }
  82204. interface XRRenderStateInit extends XRRenderState {
  82205. baseLayer: XRWebGLLayer;
  82206. depthFar: number;
  82207. depthNear: number;
  82208. inlineVerticalFieldOfView?: number;
  82209. layers?: XRLayer[];
  82210. }
  82211. interface XRReferenceSpace extends XRSpace {
  82212. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  82213. onreset: XREventHandler;
  82214. }
  82215. interface XRBoundedReferenceSpace extends XRSpace {
  82216. readonly boundsGeometry: DOMPointReadOnly[];
  82217. }
  82218. interface XRInputSource {
  82219. readonly handedness: XRHandedness;
  82220. readonly targetRayMode: XRTargetRayMode;
  82221. readonly targetRaySpace: XRSpace;
  82222. readonly gripSpace?: XRSpace;
  82223. readonly gamepad?: Gamepad;
  82224. readonly profiles: Array<string>;
  82225. readonly hand?: XRHand;
  82226. }
  82227. interface XRPose {
  82228. readonly transform: XRRigidTransform;
  82229. readonly emulatedPosition: boolean;
  82230. }
  82231. interface XRWorldInformation {
  82232. detectedPlanes?: XRPlaneSet;
  82233. }
  82234. interface XRFrame {
  82235. readonly session: XRSession;
  82236. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  82237. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  82238. // AR
  82239. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  82240. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  82241. // Anchors
  82242. trackedAnchors?: XRAnchorSet;
  82243. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  82244. // World geometries
  82245. worldInformation?: XRWorldInformation;
  82246. // Hand tracking
  82247. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  82248. // Image tracking
  82249. getImageTrackingResults?(): Array<XRImageTrackingResult>;
  82250. }
  82251. interface XRInputSourceEvent extends Event {
  82252. readonly frame: XRFrame;
  82253. readonly inputSource: XRInputSource;
  82254. }
  82255. type XRInputSourceArray = XRInputSource[];
  82256. interface XRSession {
  82257. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  82258. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  82259. /**
  82260. * Returns a list of this session's XRInputSources, each representing an input device
  82261. * used to control the camera and/or scene.
  82262. */
  82263. readonly inputSources: Array<XRInputSource>;
  82264. /**
  82265. * object which contains options affecting how the imagery is rendered.
  82266. * This includes things such as the near and far clipping planes
  82267. */
  82268. readonly renderState: XRRenderState;
  82269. readonly visibilityState: XRVisibilityState;
  82270. /**
  82271. * Removes a callback from the animation frame painting callback from
  82272. * XRSession's set of animation frame rendering callbacks, given the
  82273. * identifying handle returned by a previous call to requestAnimationFrame().
  82274. */
  82275. cancelAnimationFrame: (handle: number) => void;
  82276. /**
  82277. * Ends the WebXR session. Returns a promise which resolves when the
  82278. * session has been shut down.
  82279. */
  82280. end(): Promise<void>;
  82281. /**
  82282. * Schedules the specified method to be called the next time the user agent
  82283. * is working on rendering an animation frame for the WebXR device. Returns an
  82284. * integer value which can be used to identify the request for the purposes of
  82285. * canceling the callback using cancelAnimationFrame(). This method is comparable
  82286. * to the Window.requestAnimationFrame() method.
  82287. */
  82288. requestAnimationFrame: XRFrameRequestCallback;
  82289. /**
  82290. * Requests that a new XRReferenceSpace of the specified type be created.
  82291. * Returns a promise which resolves with the XRReferenceSpace or
  82292. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  82293. * the requested space type isn't supported by the device.
  82294. */
  82295. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  82296. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  82297. onend: XREventHandler;
  82298. oninputsourceschange: XREventHandler;
  82299. onselect: XREventHandler;
  82300. onselectstart: XREventHandler;
  82301. onselectend: XREventHandler;
  82302. onsqueeze: XREventHandler;
  82303. onsqueezestart: XREventHandler;
  82304. onsqueezeend: XREventHandler;
  82305. onvisibilitychange: XREventHandler;
  82306. // hit test
  82307. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  82308. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  82309. // legacy AR hit test
  82310. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  82311. // legacy plane detection
  82312. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  82313. // image tracking
  82314. getTrackedImageScores?(): XRImageTrackingScore[];
  82315. }
  82316. interface XRViewerPose extends XRPose {
  82317. readonly views: Array<XRView>;
  82318. }
  82319. declare class XRRigidTransform {
  82320. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  82321. position: DOMPointReadOnly;
  82322. orientation: DOMPointReadOnly;
  82323. matrix: Float32Array;
  82324. inverse: XRRigidTransform;
  82325. }
  82326. interface XRView {
  82327. readonly eye: XREye;
  82328. readonly projectionMatrix: Float32Array;
  82329. readonly transform: XRRigidTransform;
  82330. readonly recommendedViewportScale?: number;
  82331. requestViewportScale(scale: number): void;
  82332. }
  82333. interface XRInputSourceChangeEvent extends Event {
  82334. session: XRSession;
  82335. removed: Array<XRInputSource>;
  82336. added: Array<XRInputSource>;
  82337. }
  82338. // Experimental/Draft features
  82339. declare class XRRay {
  82340. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  82341. origin: DOMPointReadOnly;
  82342. direction: DOMPointReadOnly;
  82343. matrix: Float32Array;
  82344. }
  82345. declare enum XRHitTestTrackableType {
  82346. "point",
  82347. "plane",
  82348. "mesh",
  82349. }
  82350. interface XRHitResult {
  82351. hitMatrix: Float32Array;
  82352. }
  82353. interface XRTransientInputHitTestResult {
  82354. readonly inputSource: XRInputSource;
  82355. readonly results: Array<XRHitTestResult>;
  82356. }
  82357. interface XRHitTestResult {
  82358. getPose(baseSpace: XRSpace): XRPose | undefined;
  82359. // When anchor system is enabled
  82360. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  82361. }
  82362. interface XRHitTestSource {
  82363. cancel(): void;
  82364. }
  82365. interface XRTransientInputHitTestSource {
  82366. cancel(): void;
  82367. }
  82368. interface XRHitTestOptionsInit {
  82369. space: XRSpace;
  82370. entityTypes?: Array<XRHitTestTrackableType>;
  82371. offsetRay?: XRRay;
  82372. }
  82373. interface XRTransientInputHitTestOptionsInit {
  82374. profile: string;
  82375. entityTypes?: Array<XRHitTestTrackableType>;
  82376. offsetRay?: XRRay;
  82377. }
  82378. interface XRAnchor {
  82379. anchorSpace: XRSpace;
  82380. delete(): void;
  82381. }
  82382. interface XRPlane {
  82383. orientation: "Horizontal" | "Vertical";
  82384. planeSpace: XRSpace;
  82385. polygon: Array<DOMPointReadOnly>;
  82386. lastChangedTime: number;
  82387. }
  82388. interface XRJointSpace extends XRSpace {}
  82389. interface XRJointPose extends XRPose {
  82390. radius: number | undefined;
  82391. }
  82392. interface XRHand extends Iterable<XRJointSpace> {
  82393. readonly length: number;
  82394. [index: number]: XRJointSpace;
  82395. readonly WRIST: number;
  82396. readonly THUMB_METACARPAL: number;
  82397. readonly THUMB_PHALANX_PROXIMAL: number;
  82398. readonly THUMB_PHALANX_DISTAL: number;
  82399. readonly THUMB_PHALANX_TIP: number;
  82400. readonly INDEX_METACARPAL: number;
  82401. readonly INDEX_PHALANX_PROXIMAL: number;
  82402. readonly INDEX_PHALANX_INTERMEDIATE: number;
  82403. readonly INDEX_PHALANX_DISTAL: number;
  82404. readonly INDEX_PHALANX_TIP: number;
  82405. readonly MIDDLE_METACARPAL: number;
  82406. readonly MIDDLE_PHALANX_PROXIMAL: number;
  82407. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  82408. readonly MIDDLE_PHALANX_DISTAL: number;
  82409. readonly MIDDLE_PHALANX_TIP: number;
  82410. readonly RING_METACARPAL: number;
  82411. readonly RING_PHALANX_PROXIMAL: number;
  82412. readonly RING_PHALANX_INTERMEDIATE: number;
  82413. readonly RING_PHALANX_DISTAL: number;
  82414. readonly RING_PHALANX_TIP: number;
  82415. readonly LITTLE_METACARPAL: number;
  82416. readonly LITTLE_PHALANX_PROXIMAL: number;
  82417. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  82418. readonly LITTLE_PHALANX_DISTAL: number;
  82419. readonly LITTLE_PHALANX_TIP: number;
  82420. }
  82421. type XRImageTrackingState = "tracked" | "emulated";
  82422. type XRImageTrackingScore = "untrackable" | "trackable";
  82423. interface XRTrackedImageInit {
  82424. image: ImageBitmap;
  82425. widthInMeters: number;
  82426. }
  82427. interface XRImageTrackingResult {
  82428. readonly imageSpace: XRSpace;
  82429. readonly index: number;
  82430. readonly trackingState: XRImageTrackingState;
  82431. readonly measuredWidthInMeters: number;
  82432. }
  82433. // This file contains native only extensions for WebXR. These APIs are not supported in the browser yet.
  82434. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  82435. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  82436. type XRSceneObjectType = "unknown" | "background" | "wall" | "floor" | "ceiling" | "platform";
  82437. interface XRSceneObject {
  82438. type: XRSceneObjectType;
  82439. }
  82440. interface XRFieldOfView {
  82441. angleLeft: number;
  82442. angleRight: number;
  82443. angleUp: number;
  82444. angleDown: number;
  82445. }
  82446. interface XRFrustum {
  82447. position: DOMPointReadOnly;
  82448. orientation: DOMPointReadOnly;
  82449. fieldOfView: XRFieldOfView;
  82450. farDistance: number;
  82451. }
  82452. interface XRPlane {
  82453. parentSceneObject?: XRSceneObject;
  82454. }
  82455. interface XRMesh {
  82456. meshSpace: XRSpace;
  82457. positions: Float32Array;
  82458. indices: Uint32Array;
  82459. normals?: Float32Array;
  82460. lastChangedTime: number;
  82461. parentSceneObject?: XRSceneObject;
  82462. }
  82463. interface XRFrustumDetectionBoundary {
  82464. type: "frustum";
  82465. frustum: XRFrustum;
  82466. }
  82467. interface XRSphereDetectionBoundary {
  82468. type: "sphere";
  82469. radius: number;
  82470. }
  82471. interface XRBoxDetectionBoundary {
  82472. type: "box";
  82473. extent: DOMPointReadOnly;
  82474. }
  82475. type XRDetectionBoundary = XRFrustumDetectionBoundary | XRSphereDetectionBoundary | XRBoxDetectionBoundary;
  82476. interface XRGeometryDetectorOptions {
  82477. detectionBoundary?: XRDetectionBoundary;
  82478. updateInterval?: number;
  82479. }
  82480. interface XRSession {
  82481. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  82482. trySetPreferredPlaneDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  82483. trySetMeshDetectorEnabled(enabled: boolean): boolean;
  82484. trySetPreferredMeshDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  82485. }
  82486. interface XRFrame {
  82487. featurePointCloud?: Array<number>;
  82488. }
  82489. type XRMeshSet = Set<XRMesh>;
  82490. interface XRWorldInformation {
  82491. detectedMeshes?: XRMeshSet;
  82492. }
  82493. /**
  82494. * @ignore
  82495. */
  82496. declare module BABYLON.GLTF2.Exporter {
  82497. }
  82498. /**
  82499. * @ignore
  82500. */
  82501. declare module BABYLON.GLTF1 {
  82502. }
  82503. declare module BABYLON.GUI {
  82504. /**
  82505. * Interface used to define a control that can receive focus
  82506. */
  82507. export interface IFocusableControl {
  82508. /**
  82509. * Function called when the control receives the focus
  82510. */
  82511. onFocus(): void;
  82512. /**
  82513. * Function called when the control loses the focus
  82514. */
  82515. onBlur(): void;
  82516. /**
  82517. * Function called to let the control handle keyboard events
  82518. * @param evt defines the current keyboard event
  82519. */
  82520. processKeyboard(evt: KeyboardEvent): void;
  82521. /**
  82522. * Function called to get the list of controls that should not steal the focus from this control
  82523. * @returns an array of controls
  82524. */
  82525. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  82526. /**
  82527. * Function to focus the control programmatically
  82528. */
  82529. focus(): void;
  82530. /**
  82531. * Function to unfocus the control programmatically
  82532. */
  82533. blur(): void;
  82534. }
  82535. }
  82536. declare module BABYLON.GUI {
  82537. /**
  82538. * Class used to specific a value and its associated unit
  82539. */
  82540. export class ValueAndUnit {
  82541. /** defines the unit to store */
  82542. unit: number;
  82543. /** defines a boolean indicating if the value can be negative */
  82544. negativeValueAllowed: boolean;
  82545. private _value;
  82546. private _originalUnit;
  82547. /**
  82548. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  82549. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82550. */
  82551. ignoreAdaptiveScaling: boolean;
  82552. /**
  82553. * Creates a new ValueAndUnit
  82554. * @param value defines the value to store
  82555. * @param unit defines the unit to store
  82556. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  82557. */
  82558. constructor(value: number,
  82559. /** defines the unit to store */
  82560. unit?: number,
  82561. /** defines a boolean indicating if the value can be negative */
  82562. negativeValueAllowed?: boolean);
  82563. /** Gets a boolean indicating if the value is a percentage */
  82564. get isPercentage(): boolean;
  82565. /** Gets a boolean indicating if the value is store as pixel */
  82566. get isPixel(): boolean;
  82567. /** Gets direct internal value */
  82568. get internalValue(): number;
  82569. /**
  82570. * Gets value as pixel
  82571. * @param host defines the root host
  82572. * @param refValue defines the reference value for percentages
  82573. * @returns the value as pixel
  82574. */
  82575. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  82576. /**
  82577. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  82578. * @param value defines the value to store
  82579. * @param unit defines the unit to store
  82580. * @returns the current ValueAndUnit
  82581. */
  82582. updateInPlace(value: number, unit?: number): ValueAndUnit;
  82583. /**
  82584. * Gets the value accordingly to its unit
  82585. * @param host defines the root host
  82586. * @returns the value
  82587. */
  82588. getValue(host: AdvancedDynamicTexture): number;
  82589. /**
  82590. * Gets a string representation of the value
  82591. * @param host defines the root host
  82592. * @param decimals defines an optional number of decimals to display
  82593. * @returns a string
  82594. */
  82595. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  82596. /**
  82597. * Store a value parsed from a string
  82598. * @param source defines the source string
  82599. * @returns true if the value was successfully parsed
  82600. */
  82601. fromString(source: string | number): boolean;
  82602. private static _Regex;
  82603. private static _UNITMODE_PERCENTAGE;
  82604. private static _UNITMODE_PIXEL;
  82605. /** UNITMODE_PERCENTAGE */
  82606. static get UNITMODE_PERCENTAGE(): number;
  82607. /** UNITMODE_PIXEL */
  82608. static get UNITMODE_PIXEL(): number;
  82609. }
  82610. }
  82611. declare module BABYLON.GUI {
  82612. /**
  82613. * Define a style used by control to automatically setup properties based on a template.
  82614. * Only support font related properties so far
  82615. */
  82616. export class Style implements BABYLON.IDisposable {
  82617. private _fontFamily;
  82618. private _fontStyle;
  82619. private _fontWeight;
  82620. /** @hidden */
  82621. _host: AdvancedDynamicTexture;
  82622. /** @hidden */
  82623. _fontSize: ValueAndUnit;
  82624. /**
  82625. * BABYLON.Observable raised when the style values are changed
  82626. */
  82627. onChangedObservable: BABYLON.Observable<Style>;
  82628. /**
  82629. * Creates a new style object
  82630. * @param host defines the AdvancedDynamicTexture which hosts this style
  82631. */
  82632. constructor(host: AdvancedDynamicTexture);
  82633. /**
  82634. * Gets or sets the font size
  82635. */
  82636. get fontSize(): string | number;
  82637. set fontSize(value: string | number);
  82638. /**
  82639. * Gets or sets the font family
  82640. */
  82641. get fontFamily(): string;
  82642. set fontFamily(value: string);
  82643. /**
  82644. * Gets or sets the font style
  82645. */
  82646. get fontStyle(): string;
  82647. set fontStyle(value: string);
  82648. /** Gets or sets font weight */
  82649. get fontWeight(): string;
  82650. set fontWeight(value: string);
  82651. /** Dispose all associated resources */
  82652. dispose(): void;
  82653. }
  82654. }
  82655. declare module BABYLON.GUI {
  82656. /**
  82657. * Class used to transport BABYLON.Vector2 information for pointer events
  82658. */
  82659. export class Vector2WithInfo extends BABYLON.Vector2 {
  82660. /** defines the current mouse button index */
  82661. buttonIndex: number;
  82662. /**
  82663. * Creates a new Vector2WithInfo
  82664. * @param source defines the vector2 data to transport
  82665. * @param buttonIndex defines the current mouse button index
  82666. */
  82667. constructor(source: BABYLON.Vector2,
  82668. /** defines the current mouse button index */
  82669. buttonIndex?: number);
  82670. }
  82671. /** Class used to provide 2D matrix features */
  82672. export class Matrix2D {
  82673. /** Gets the internal array of 6 floats used to store matrix data */
  82674. m: Float32Array;
  82675. /**
  82676. * Creates a new matrix
  82677. * @param m00 defines value for (0, 0)
  82678. * @param m01 defines value for (0, 1)
  82679. * @param m10 defines value for (1, 0)
  82680. * @param m11 defines value for (1, 1)
  82681. * @param m20 defines value for (2, 0)
  82682. * @param m21 defines value for (2, 1)
  82683. */
  82684. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  82685. /**
  82686. * Fills the matrix from direct values
  82687. * @param m00 defines value for (0, 0)
  82688. * @param m01 defines value for (0, 1)
  82689. * @param m10 defines value for (1, 0)
  82690. * @param m11 defines value for (1, 1)
  82691. * @param m20 defines value for (2, 0)
  82692. * @param m21 defines value for (2, 1)
  82693. * @returns the current modified matrix
  82694. */
  82695. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  82696. /**
  82697. * Gets matrix determinant
  82698. * @returns the determinant
  82699. */
  82700. determinant(): number;
  82701. /**
  82702. * Inverses the matrix and stores it in a target matrix
  82703. * @param result defines the target matrix
  82704. * @returns the current matrix
  82705. */
  82706. invertToRef(result: Matrix2D): Matrix2D;
  82707. /**
  82708. * Multiplies the current matrix with another one
  82709. * @param other defines the second operand
  82710. * @param result defines the target matrix
  82711. * @returns the current matrix
  82712. */
  82713. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  82714. /**
  82715. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  82716. * @param x defines the x coordinate to transform
  82717. * @param y defines the x coordinate to transform
  82718. * @param result defines the target vector2
  82719. * @returns the current matrix
  82720. */
  82721. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  82722. /**
  82723. * Creates an identity matrix
  82724. * @returns a new matrix
  82725. */
  82726. static Identity(): Matrix2D;
  82727. /**
  82728. * Creates a translation matrix and stores it in a target matrix
  82729. * @param x defines the x coordinate of the translation
  82730. * @param y defines the y coordinate of the translation
  82731. * @param result defines the target matrix
  82732. */
  82733. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  82734. /**
  82735. * Creates a scaling matrix and stores it in a target matrix
  82736. * @param x defines the x coordinate of the scaling
  82737. * @param y defines the y coordinate of the scaling
  82738. * @param result defines the target matrix
  82739. */
  82740. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  82741. /**
  82742. * Creates a rotation matrix and stores it in a target matrix
  82743. * @param angle defines the rotation angle
  82744. * @param result defines the target matrix
  82745. */
  82746. static RotationToRef(angle: number, result: Matrix2D): void;
  82747. private static _TempPreTranslationMatrix;
  82748. private static _TempPostTranslationMatrix;
  82749. private static _TempRotationMatrix;
  82750. private static _TempScalingMatrix;
  82751. private static _TempCompose0;
  82752. private static _TempCompose1;
  82753. private static _TempCompose2;
  82754. /**
  82755. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  82756. * @param tx defines the x coordinate of the translation
  82757. * @param ty defines the y coordinate of the translation
  82758. * @param angle defines the rotation angle
  82759. * @param scaleX defines the x coordinate of the scaling
  82760. * @param scaleY defines the y coordinate of the scaling
  82761. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  82762. * @param result defines the target matrix
  82763. */
  82764. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  82765. }
  82766. }
  82767. declare module BABYLON.GUI {
  82768. /**
  82769. * Class used to store 2D control sizes
  82770. */
  82771. export class Measure {
  82772. /** defines left coordinate */
  82773. left: number;
  82774. /** defines top coordinate */
  82775. top: number;
  82776. /** defines width dimension */
  82777. width: number;
  82778. /** defines height dimension */
  82779. height: number;
  82780. /**
  82781. * Creates a new measure
  82782. * @param left defines left coordinate
  82783. * @param top defines top coordinate
  82784. * @param width defines width dimension
  82785. * @param height defines height dimension
  82786. */
  82787. constructor(
  82788. /** defines left coordinate */
  82789. left: number,
  82790. /** defines top coordinate */
  82791. top: number,
  82792. /** defines width dimension */
  82793. width: number,
  82794. /** defines height dimension */
  82795. height: number);
  82796. /**
  82797. * Copy from another measure
  82798. * @param other defines the other measure to copy from
  82799. */
  82800. copyFrom(other: Measure): void;
  82801. /**
  82802. * Copy from a group of 4 floats
  82803. * @param left defines left coordinate
  82804. * @param top defines top coordinate
  82805. * @param width defines width dimension
  82806. * @param height defines height dimension
  82807. */
  82808. copyFromFloats(left: number, top: number, width: number, height: number): void;
  82809. /**
  82810. * Computes the axis aligned bounding box measure for two given measures
  82811. * @param a Input measure
  82812. * @param b Input measure
  82813. * @param result the resulting bounding measure
  82814. */
  82815. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  82816. /**
  82817. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  82818. * @param transform the matrix to transform the measure before computing the AABB
  82819. * @param addX number to add to left
  82820. * @param addY number to add to top
  82821. * @param addWidth number to add to width
  82822. * @param addHeight number to add to height
  82823. * @param result the resulting AABB
  82824. */
  82825. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  82826. /**
  82827. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  82828. * @param transform the matrix to transform the measure before computing the AABB
  82829. * @param result the resulting AABB
  82830. */
  82831. transformToRef(transform: Matrix2D, result: Measure): void;
  82832. /**
  82833. * Check equality between this measure and another one
  82834. * @param other defines the other measures
  82835. * @returns true if both measures are equals
  82836. */
  82837. isEqualsTo(other: Measure): boolean;
  82838. /**
  82839. * Creates an empty measure
  82840. * @returns a new measure
  82841. */
  82842. static Empty(): Measure;
  82843. }
  82844. }
  82845. declare module BABYLON.GUI {
  82846. /**
  82847. * Class used to create texture to support 2D GUI elements
  82848. * @see https://doc.babylonjs.com/how_to/gui
  82849. */
  82850. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  82851. /** Define the Uurl to load snippets */
  82852. static SnippetUrl: string;
  82853. /** Snippet ID if the content was created from the snippet server */
  82854. snippetId: string;
  82855. private _isDirty;
  82856. private _renderObserver;
  82857. private _resizeObserver;
  82858. private _preKeyboardObserver;
  82859. private _pointerMoveObserver;
  82860. private _pointerObserver;
  82861. private _canvasPointerOutObserver;
  82862. private _canvasBlurObserver;
  82863. private _background;
  82864. /** @hidden */
  82865. _rootContainer: Container;
  82866. /** @hidden */
  82867. _lastPickedControl: Control;
  82868. /** @hidden */
  82869. _lastControlOver: {
  82870. [pointerId: number]: Control;
  82871. };
  82872. /** @hidden */
  82873. _lastControlDown: {
  82874. [pointerId: number]: Control;
  82875. };
  82876. /** @hidden */
  82877. _capturingControl: {
  82878. [pointerId: number]: Control;
  82879. };
  82880. /** @hidden */
  82881. _shouldBlockPointer: boolean;
  82882. /** @hidden */
  82883. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  82884. /** @hidden */
  82885. _linkedControls: Control[];
  82886. private _isFullscreen;
  82887. private _fullscreenViewport;
  82888. private _idealWidth;
  82889. private _idealHeight;
  82890. private _useSmallestIdeal;
  82891. private _renderAtIdealSize;
  82892. private _focusedControl;
  82893. private _blockNextFocusCheck;
  82894. private _renderScale;
  82895. private _rootElement;
  82896. private _cursorChanged;
  82897. private _defaultMousePointerId;
  82898. /** @hidden */
  82899. _numLayoutCalls: number;
  82900. /** Gets the number of layout calls made the last time the ADT has been rendered */
  82901. get numLayoutCalls(): number;
  82902. /** @hidden */
  82903. _numRenderCalls: number;
  82904. /** Gets the number of render calls made the last time the ADT has been rendered */
  82905. get numRenderCalls(): number;
  82906. /**
  82907. * Define type to string to ensure compatibility across browsers
  82908. * Safari doesn't support DataTransfer constructor
  82909. */
  82910. private _clipboardData;
  82911. /**
  82912. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  82913. */
  82914. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  82915. /**
  82916. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  82917. */
  82918. onControlPickedObservable: BABYLON.Observable<Control>;
  82919. /**
  82920. * BABYLON.Observable event triggered before layout is evaluated
  82921. */
  82922. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82923. /**
  82924. * BABYLON.Observable event triggered after the layout was evaluated
  82925. */
  82926. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82927. /**
  82928. * BABYLON.Observable event triggered before the texture is rendered
  82929. */
  82930. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82931. /**
  82932. * BABYLON.Observable event triggered after the texture was rendered
  82933. */
  82934. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82935. /**
  82936. * Gets or sets a boolean defining if alpha is stored as premultiplied
  82937. */
  82938. premulAlpha: boolean;
  82939. /**
  82940. * Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
  82941. */
  82942. applyYInversionOnUpdate: boolean;
  82943. /**
  82944. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  82945. * Useful when you want more antialiasing
  82946. */
  82947. get renderScale(): number;
  82948. set renderScale(value: number);
  82949. /** Gets or sets the background color */
  82950. get background(): string;
  82951. set background(value: string);
  82952. /**
  82953. * Gets or sets the ideal width used to design controls.
  82954. * The GUI will then rescale everything accordingly
  82955. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82956. */
  82957. get idealWidth(): number;
  82958. set idealWidth(value: number);
  82959. /**
  82960. * Gets or sets the ideal height used to design controls.
  82961. * The GUI will then rescale everything accordingly
  82962. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82963. */
  82964. get idealHeight(): number;
  82965. set idealHeight(value: number);
  82966. /**
  82967. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  82968. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82969. */
  82970. get useSmallestIdeal(): boolean;
  82971. set useSmallestIdeal(value: boolean);
  82972. /**
  82973. * Gets or sets a boolean indicating if adaptive scaling must be used
  82974. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82975. */
  82976. get renderAtIdealSize(): boolean;
  82977. set renderAtIdealSize(value: boolean);
  82978. /**
  82979. * Gets the ratio used when in "ideal mode"
  82980. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82981. * */
  82982. get idealRatio(): number;
  82983. /**
  82984. * Gets the underlying layer used to render the texture when in fullscreen mode
  82985. */
  82986. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  82987. /**
  82988. * Gets the root container control
  82989. */
  82990. get rootContainer(): Container;
  82991. /**
  82992. * Returns an array containing the root container.
  82993. * This is mostly used to let the Inspector introspects the ADT
  82994. * @returns an array containing the rootContainer
  82995. */
  82996. getChildren(): Array<Container>;
  82997. /**
  82998. * Will return all controls that are inside this texture
  82999. * @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
  83000. * @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
  83001. * @return all child controls
  83002. */
  83003. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  83004. /**
  83005. * Gets or sets the current focused control
  83006. */
  83007. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  83008. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  83009. /**
  83010. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  83011. */
  83012. get isForeground(): boolean;
  83013. set isForeground(value: boolean);
  83014. /**
  83015. * Gets or set information about clipboardData
  83016. */
  83017. get clipboardData(): string;
  83018. set clipboardData(value: string);
  83019. /**
  83020. * Creates a new AdvancedDynamicTexture
  83021. * @param name defines the name of the texture
  83022. * @param width defines the width of the texture
  83023. * @param height defines the height of the texture
  83024. * @param scene defines the hosting scene
  83025. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  83026. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83027. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  83028. */
  83029. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  83030. /**
  83031. * Get the current class name of the texture useful for serialization or dynamic coding.
  83032. * @returns "AdvancedDynamicTexture"
  83033. */
  83034. getClassName(): string;
  83035. /**
  83036. * Function used to execute a function on all controls
  83037. * @param func defines the function to execute
  83038. * @param container defines the container where controls belong. If null the root container will be used
  83039. */
  83040. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  83041. private _useInvalidateRectOptimization;
  83042. /**
  83043. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  83044. */
  83045. get useInvalidateRectOptimization(): boolean;
  83046. set useInvalidateRectOptimization(value: boolean);
  83047. private _invalidatedRectangle;
  83048. /**
  83049. * Invalidates a rectangle area on the gui texture
  83050. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  83051. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  83052. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  83053. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  83054. */
  83055. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  83056. /**
  83057. * Marks the texture as dirty forcing a complete update
  83058. */
  83059. markAsDirty(): void;
  83060. /**
  83061. * Helper function used to create a new style
  83062. * @returns a new style
  83063. * @see https://doc.babylonjs.com/how_to/gui#styles
  83064. */
  83065. createStyle(): Style;
  83066. /**
  83067. * Adds a new control to the root container
  83068. * @param control defines the control to add
  83069. * @returns the current texture
  83070. */
  83071. addControl(control: Control): AdvancedDynamicTexture;
  83072. /**
  83073. * Removes a control from the root container
  83074. * @param control defines the control to remove
  83075. * @returns the current texture
  83076. */
  83077. removeControl(control: Control): AdvancedDynamicTexture;
  83078. /**
  83079. * Release all resources
  83080. */
  83081. dispose(): void;
  83082. private _onResize;
  83083. /** @hidden */
  83084. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  83085. /**
  83086. * Get screen coordinates for a vector3
  83087. * @param position defines the position to project
  83088. * @param worldMatrix defines the world matrix to use
  83089. * @returns the projected position
  83090. */
  83091. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  83092. /**
  83093. * Get screen coordinates for a vector3
  83094. * @param position defines the position to project
  83095. * @param worldMatrix defines the world matrix to use
  83096. * @returns the projected position with Z
  83097. */
  83098. getProjectedPositionWithZ(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector3;
  83099. private _checkUpdate;
  83100. private _clearMeasure;
  83101. private _render;
  83102. /** @hidden */
  83103. _changeCursor(cursor: string): void;
  83104. /** @hidden */
  83105. _registerLastControlDown(control: Control, pointerId: number): void;
  83106. private _doPicking;
  83107. /** @hidden */
  83108. _cleanControlAfterRemovalFromList(list: {
  83109. [pointerId: number]: Control;
  83110. }, control: Control): void;
  83111. /** @hidden */
  83112. _cleanControlAfterRemoval(control: Control): void;
  83113. /** Attach to all scene events required to support pointer events */
  83114. attach(): void;
  83115. /** @hidden */
  83116. private onClipboardCopy;
  83117. /** @hidden */
  83118. private onClipboardCut;
  83119. /** @hidden */
  83120. private onClipboardPaste;
  83121. /**
  83122. * Register the clipboard Events onto the canvas
  83123. */
  83124. registerClipboardEvents(): void;
  83125. /**
  83126. * Unregister the clipboard Events from the canvas
  83127. */
  83128. unRegisterClipboardEvents(): void;
  83129. /**
  83130. * Connect the texture to a hosting mesh to enable interactions
  83131. * @param mesh defines the mesh to attach to
  83132. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  83133. */
  83134. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  83135. /**
  83136. * Move the focus to a specific control
  83137. * @param control defines the control which will receive the focus
  83138. */
  83139. moveFocusToControl(control: IFocusableControl): void;
  83140. private _manageFocus;
  83141. private _attachToOnPointerOut;
  83142. private _attachToOnBlur;
  83143. /**
  83144. * Serializes the entire GUI system
  83145. * @returns an object with the JSON serialized data
  83146. */
  83147. serializeContent(): any;
  83148. /**
  83149. * Recreate the content of the ADT from a JSON object
  83150. * @param serializedObject define the JSON serialized object to restore from
  83151. */
  83152. parseContent(serializedObject: any): void;
  83153. /**
  83154. * Recreate the content of the ADT from a snippet saved by the GUI editor
  83155. * @param snippetId defines the snippet to load
  83156. * @returns a promise that will resolve on success
  83157. */
  83158. parseFromSnippetAsync(snippetId: string): Promise<void>;
  83159. /**
  83160. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  83161. * @param mesh defines the mesh which will receive the texture
  83162. * @param width defines the texture width (1024 by default)
  83163. * @param height defines the texture height (1024 by default)
  83164. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  83165. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  83166. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  83167. * @returns a new AdvancedDynamicTexture
  83168. */
  83169. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  83170. /**
  83171. * 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
  83172. * @param mesh defines the mesh which will receive the texture
  83173. * @param width defines the texture width (1024 by default)
  83174. * @param height defines the texture height (1024 by default)
  83175. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  83176. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  83177. * @returns a new AdvancedDynamicTexture
  83178. */
  83179. static CreateForMeshTexture(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  83180. /**
  83181. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  83182. * In this mode the texture will rely on a layer for its rendering.
  83183. * This allows it to be treated like any other layer.
  83184. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  83185. * LayerMask is set through advancedTexture.layer.layerMask
  83186. * @param name defines name for the texture
  83187. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  83188. * @param scene defines the hsoting scene
  83189. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  83190. * @returns a new AdvancedDynamicTexture
  83191. */
  83192. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  83193. }
  83194. }
  83195. declare module BABYLON.GUI {
  83196. /**
  83197. * Root class used for all 2D controls
  83198. * @see https://doc.babylonjs.com/how_to/gui#controls
  83199. */
  83200. export class Control {
  83201. /** defines the name of the control */
  83202. name?: string | undefined;
  83203. /**
  83204. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  83205. */
  83206. static AllowAlphaInheritance: boolean;
  83207. private _alpha;
  83208. private _alphaSet;
  83209. private _zIndex;
  83210. /** @hidden */
  83211. _host: AdvancedDynamicTexture;
  83212. /** Gets or sets the control parent */
  83213. parent: BABYLON.Nullable<Container>;
  83214. /** @hidden */
  83215. _currentMeasure: Measure;
  83216. private _fontFamily;
  83217. private _fontStyle;
  83218. private _fontWeight;
  83219. private _fontSize;
  83220. private _font;
  83221. /** @hidden */
  83222. _width: ValueAndUnit;
  83223. /** @hidden */
  83224. _height: ValueAndUnit;
  83225. /** @hidden */
  83226. protected _fontOffset: {
  83227. ascent: number;
  83228. height: number;
  83229. descent: number;
  83230. };
  83231. private _color;
  83232. private _style;
  83233. private _styleObserver;
  83234. /** @hidden */
  83235. protected _horizontalAlignment: number;
  83236. /** @hidden */
  83237. protected _verticalAlignment: number;
  83238. /** @hidden */
  83239. protected _isDirty: boolean;
  83240. /** @hidden */
  83241. protected _wasDirty: boolean;
  83242. /** @hidden */
  83243. _tempParentMeasure: Measure;
  83244. /** @hidden */
  83245. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  83246. /** @hidden */
  83247. protected _cachedParentMeasure: Measure;
  83248. private _paddingLeft;
  83249. private _paddingRight;
  83250. private _paddingTop;
  83251. private _paddingBottom;
  83252. /** @hidden */
  83253. _left: ValueAndUnit;
  83254. /** @hidden */
  83255. _top: ValueAndUnit;
  83256. private _scaleX;
  83257. private _scaleY;
  83258. private _rotation;
  83259. private _transformCenterX;
  83260. private _transformCenterY;
  83261. /** @hidden */
  83262. _transformMatrix: Matrix2D;
  83263. /** @hidden */
  83264. protected _invertTransformMatrix: Matrix2D;
  83265. /** @hidden */
  83266. protected _transformedPosition: BABYLON.Vector2;
  83267. private _isMatrixDirty;
  83268. private _cachedOffsetX;
  83269. private _cachedOffsetY;
  83270. private _isVisible;
  83271. private _isHighlighted;
  83272. /** @hidden */
  83273. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  83274. private _fontSet;
  83275. private _dummyVector2;
  83276. private _downCount;
  83277. private _enterCount;
  83278. private _doNotRender;
  83279. private _downPointerIds;
  83280. protected _isEnabled: boolean;
  83281. protected _disabledColor: string;
  83282. protected _disabledColorItem: string;
  83283. /** @hidden */
  83284. protected _rebuildLayout: boolean;
  83285. /** @hidden */
  83286. _customData: any;
  83287. /** @hidden */
  83288. _isClipped: boolean;
  83289. /** @hidden */
  83290. _automaticSize: boolean;
  83291. /** @hidden */
  83292. _tag: any;
  83293. /**
  83294. * 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
  83295. */
  83296. uniqueId: number;
  83297. /**
  83298. * Gets or sets an object used to store user defined information for the node
  83299. */
  83300. metadata: any;
  83301. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  83302. isHitTestVisible: boolean;
  83303. /** Gets or sets a boolean indicating if the control can block pointer events */
  83304. isPointerBlocker: boolean;
  83305. /** Gets or sets a boolean indicating if the control can be focusable */
  83306. isFocusInvisible: boolean;
  83307. /**
  83308. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  83309. * 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
  83310. */
  83311. clipChildren: boolean;
  83312. /**
  83313. * Gets or sets a boolean indicating that control content must be clipped
  83314. * 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
  83315. */
  83316. clipContent: boolean;
  83317. /**
  83318. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  83319. */
  83320. useBitmapCache: boolean;
  83321. private _cacheData;
  83322. private _shadowOffsetX;
  83323. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  83324. get shadowOffsetX(): number;
  83325. set shadowOffsetX(value: number);
  83326. private _shadowOffsetY;
  83327. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  83328. get shadowOffsetY(): number;
  83329. set shadowOffsetY(value: number);
  83330. private _shadowBlur;
  83331. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  83332. get shadowBlur(): number;
  83333. set shadowBlur(value: number);
  83334. private _shadowColor;
  83335. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  83336. get shadowColor(): string;
  83337. set shadowColor(value: string);
  83338. /** Gets or sets the cursor to use when the control is hovered */
  83339. hoverCursor: string;
  83340. /** @hidden */
  83341. protected _linkOffsetX: ValueAndUnit;
  83342. /** @hidden */
  83343. protected _linkOffsetY: ValueAndUnit;
  83344. /** Gets the control type name */
  83345. get typeName(): string;
  83346. /**
  83347. * Get the current class name of the control.
  83348. * @returns current class name
  83349. */
  83350. getClassName(): string;
  83351. /**
  83352. * An event triggered when pointer wheel is scrolled
  83353. */
  83354. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  83355. /**
  83356. * An event triggered when the pointer move over the control.
  83357. */
  83358. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  83359. /**
  83360. * An event triggered when the pointer move out of the control.
  83361. */
  83362. onPointerOutObservable: BABYLON.Observable<Control>;
  83363. /**
  83364. * An event triggered when the pointer taps the control
  83365. */
  83366. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  83367. /**
  83368. * An event triggered when pointer up
  83369. */
  83370. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  83371. /**
  83372. * An event triggered when a control is clicked on
  83373. */
  83374. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  83375. /**
  83376. * An event triggered when pointer enters the control
  83377. */
  83378. onPointerEnterObservable: BABYLON.Observable<Control>;
  83379. /**
  83380. * An event triggered when the control is marked as dirty
  83381. */
  83382. onDirtyObservable: BABYLON.Observable<Control>;
  83383. /**
  83384. * An event triggered before drawing the control
  83385. */
  83386. onBeforeDrawObservable: BABYLON.Observable<Control>;
  83387. /**
  83388. * An event triggered after the control was drawn
  83389. */
  83390. onAfterDrawObservable: BABYLON.Observable<Control>;
  83391. /**
  83392. * An event triggered when the control has been disposed
  83393. */
  83394. onDisposeObservable: BABYLON.Observable<Control>;
  83395. /**
  83396. * Get the hosting AdvancedDynamicTexture
  83397. */
  83398. get host(): AdvancedDynamicTexture;
  83399. /** Gets or set information about font offsets (used to render and align text) */
  83400. get fontOffset(): {
  83401. ascent: number;
  83402. height: number;
  83403. descent: number;
  83404. };
  83405. set fontOffset(offset: {
  83406. ascent: number;
  83407. height: number;
  83408. descent: number;
  83409. });
  83410. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  83411. get alpha(): number;
  83412. set alpha(value: number);
  83413. /**
  83414. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  83415. */
  83416. get isHighlighted(): boolean;
  83417. set isHighlighted(value: boolean);
  83418. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  83419. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83420. */
  83421. get scaleX(): number;
  83422. set scaleX(value: number);
  83423. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  83424. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83425. */
  83426. get scaleY(): number;
  83427. set scaleY(value: number);
  83428. /** Gets or sets the rotation angle (0 by default)
  83429. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83430. */
  83431. get rotation(): number;
  83432. set rotation(value: number);
  83433. /** Gets or sets the transformation center on Y axis (0 by default)
  83434. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83435. */
  83436. get transformCenterY(): number;
  83437. set transformCenterY(value: number);
  83438. /** Gets or sets the transformation center on X axis (0 by default)
  83439. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83440. */
  83441. get transformCenterX(): number;
  83442. set transformCenterX(value: number);
  83443. /**
  83444. * Gets or sets the horizontal alignment
  83445. * @see https://doc.babylonjs.com/how_to/gui#alignments
  83446. */
  83447. get horizontalAlignment(): number;
  83448. set horizontalAlignment(value: number);
  83449. /**
  83450. * Gets or sets the vertical alignment
  83451. * @see https://doc.babylonjs.com/how_to/gui#alignments
  83452. */
  83453. get verticalAlignment(): number;
  83454. set verticalAlignment(value: number);
  83455. /**
  83456. * Gets or sets a fixed ratio for this control.
  83457. * When different from 0, the ratio is used to compute the "second" dimension.
  83458. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  83459. * second dimension is computed as first dimension * fixedRatio
  83460. */
  83461. fixedRatio: number;
  83462. private _fixedRatioMasterIsWidth;
  83463. /**
  83464. * Gets or sets control width
  83465. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83466. */
  83467. get width(): string | number;
  83468. set width(value: string | number);
  83469. /**
  83470. * Gets or sets the control width in pixel
  83471. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83472. */
  83473. get widthInPixels(): number;
  83474. set widthInPixels(value: number);
  83475. /**
  83476. * Gets or sets control height
  83477. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83478. */
  83479. get height(): string | number;
  83480. set height(value: string | number);
  83481. /**
  83482. * Gets or sets control height in pixel
  83483. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83484. */
  83485. get heightInPixels(): number;
  83486. set heightInPixels(value: number);
  83487. /** Gets or set font family */
  83488. get fontFamily(): string;
  83489. set fontFamily(value: string);
  83490. /** Gets or sets font style */
  83491. get fontStyle(): string;
  83492. set fontStyle(value: string);
  83493. /** Gets or sets font weight */
  83494. get fontWeight(): string;
  83495. set fontWeight(value: string);
  83496. /**
  83497. * Gets or sets style
  83498. * @see https://doc.babylonjs.com/how_to/gui#styles
  83499. */
  83500. get style(): BABYLON.Nullable<Style>;
  83501. set style(value: BABYLON.Nullable<Style>);
  83502. /** @hidden */
  83503. get _isFontSizeInPercentage(): boolean;
  83504. /** Gets or sets font size in pixels */
  83505. get fontSizeInPixels(): number;
  83506. set fontSizeInPixels(value: number);
  83507. /** Gets or sets font size */
  83508. get fontSize(): string | number;
  83509. set fontSize(value: string | number);
  83510. /** Gets or sets foreground color */
  83511. get color(): string;
  83512. set color(value: string);
  83513. /** Gets or sets z index which is used to reorder controls on the z axis */
  83514. get zIndex(): number;
  83515. set zIndex(value: number);
  83516. /** Gets or sets a boolean indicating if the control can be rendered */
  83517. get notRenderable(): boolean;
  83518. set notRenderable(value: boolean);
  83519. /** Gets or sets a boolean indicating if the control is visible */
  83520. get isVisible(): boolean;
  83521. set isVisible(value: boolean);
  83522. /** Gets a boolean indicating that the control needs to update its rendering */
  83523. get isDirty(): boolean;
  83524. /**
  83525. * Gets the current linked mesh (or null if none)
  83526. */
  83527. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  83528. /**
  83529. * Gets or sets a value indicating the padding to use on the left of the control
  83530. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83531. */
  83532. get paddingLeft(): string | number;
  83533. set paddingLeft(value: string | number);
  83534. /**
  83535. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  83536. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83537. */
  83538. get paddingLeftInPixels(): number;
  83539. set paddingLeftInPixels(value: number);
  83540. /**
  83541. * Gets or sets a value indicating the padding to use on the right of the control
  83542. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83543. */
  83544. get paddingRight(): string | number;
  83545. set paddingRight(value: string | number);
  83546. /**
  83547. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  83548. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83549. */
  83550. get paddingRightInPixels(): number;
  83551. set paddingRightInPixels(value: number);
  83552. /**
  83553. * Gets or sets a value indicating the padding to use on the top of the control
  83554. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83555. */
  83556. get paddingTop(): string | number;
  83557. set paddingTop(value: string | number);
  83558. /**
  83559. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  83560. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83561. */
  83562. get paddingTopInPixels(): number;
  83563. set paddingTopInPixels(value: number);
  83564. /**
  83565. * Gets or sets a value indicating the padding to use on the bottom of the control
  83566. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83567. */
  83568. get paddingBottom(): string | number;
  83569. set paddingBottom(value: string | number);
  83570. /**
  83571. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  83572. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83573. */
  83574. get paddingBottomInPixels(): number;
  83575. set paddingBottomInPixels(value: number);
  83576. /**
  83577. * Gets or sets a value indicating the left coordinate of the control
  83578. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83579. */
  83580. get left(): string | number;
  83581. set left(value: string | number);
  83582. /**
  83583. * Gets or sets a value indicating the left coordinate in pixels of the control
  83584. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83585. */
  83586. get leftInPixels(): number;
  83587. set leftInPixels(value: number);
  83588. /**
  83589. * Gets or sets a value indicating the top coordinate of the control
  83590. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83591. */
  83592. get top(): string | number;
  83593. set top(value: string | number);
  83594. /**
  83595. * Gets or sets a value indicating the top coordinate in pixels of the control
  83596. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83597. */
  83598. get topInPixels(): number;
  83599. set topInPixels(value: number);
  83600. /**
  83601. * Gets or sets a value indicating the offset on X axis to the linked mesh
  83602. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83603. */
  83604. get linkOffsetX(): string | number;
  83605. set linkOffsetX(value: string | number);
  83606. /**
  83607. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  83608. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83609. */
  83610. get linkOffsetXInPixels(): number;
  83611. set linkOffsetXInPixels(value: number);
  83612. /**
  83613. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  83614. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83615. */
  83616. get linkOffsetY(): string | number;
  83617. set linkOffsetY(value: string | number);
  83618. /**
  83619. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  83620. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83621. */
  83622. get linkOffsetYInPixels(): number;
  83623. set linkOffsetYInPixels(value: number);
  83624. /** Gets the center coordinate on X axis */
  83625. get centerX(): number;
  83626. /** Gets the center coordinate on Y axis */
  83627. get centerY(): number;
  83628. /** Gets or sets if control is Enabled */
  83629. get isEnabled(): boolean;
  83630. set isEnabled(value: boolean);
  83631. /** Gets or sets background color of control if it's disabled */
  83632. get disabledColor(): string;
  83633. set disabledColor(value: string);
  83634. /** Gets or sets front color of control if it's disabled */
  83635. get disabledColorItem(): string;
  83636. set disabledColorItem(value: string);
  83637. /**
  83638. * Creates a new control
  83639. * @param name defines the name of the control
  83640. */
  83641. constructor(
  83642. /** defines the name of the control */
  83643. name?: string | undefined);
  83644. /** @hidden */
  83645. protected _getTypeName(): string;
  83646. /**
  83647. * Gets the first ascendant in the hierarchy of the given type
  83648. * @param className defines the required type
  83649. * @returns the ascendant or null if not found
  83650. */
  83651. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  83652. /** @hidden */
  83653. _resetFontCache(): void;
  83654. /**
  83655. * Determines if a container is an ascendant of the current control
  83656. * @param container defines the container to look for
  83657. * @returns true if the container is one of the ascendant of the control
  83658. */
  83659. isAscendant(container: Control): boolean;
  83660. /**
  83661. * Gets coordinates in local control space
  83662. * @param globalCoordinates defines the coordinates to transform
  83663. * @returns the new coordinates in local space
  83664. */
  83665. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  83666. /**
  83667. * Gets coordinates in local control space
  83668. * @param globalCoordinates defines the coordinates to transform
  83669. * @param result defines the target vector2 where to store the result
  83670. * @returns the current control
  83671. */
  83672. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  83673. /**
  83674. * Gets coordinates in parent local control space
  83675. * @param globalCoordinates defines the coordinates to transform
  83676. * @returns the new coordinates in parent local space
  83677. */
  83678. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  83679. /**
  83680. * Move the current control to a vector3 position projected onto the screen.
  83681. * @param position defines the target position
  83682. * @param scene defines the hosting scene
  83683. */
  83684. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  83685. /**
  83686. * Will store all controls that have this control as ascendant in a given array
  83687. * @param results defines the array where to store the descendants
  83688. * @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
  83689. * @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
  83690. */
  83691. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  83692. /**
  83693. * Will return all controls that have this control as ascendant
  83694. * @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
  83695. * @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
  83696. * @return all child controls
  83697. */
  83698. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  83699. /**
  83700. * Link current control with a target mesh
  83701. * @param mesh defines the mesh to link with
  83702. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83703. */
  83704. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  83705. /**
  83706. * Shorthand funtion to set the top, right, bottom, and left padding values on the control.
  83707. * @param { string | number} paddingTop - The value of the top padding.
  83708. * @param { string | number} paddingRight - The value of the right padding. If omitted, top is used.
  83709. * @param { string | number} paddingBottom - The value of the bottom padding. If omitted, top is used.
  83710. * @param { string | number} paddingLeft - The value of the left padding. If omitted, right is used.
  83711. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83712. */
  83713. setPadding(paddingTop: string | number, paddingRight?: string | number, paddingBottom?: string | number, paddingLeft?: string | number): void;
  83714. /**
  83715. * Shorthand funtion to set the top, right, bottom, and left padding values in pixels on the control.
  83716. * @param { number} paddingTop - The value in pixels of the top padding.
  83717. * @param { number} paddingRight - The value in pixels of the right padding. If omitted, top is used.
  83718. * @param { number} paddingBottom - The value in pixels of the bottom padding. If omitted, top is used.
  83719. * @param { number} paddingLeft - The value in pixels of the left padding. If omitted, right is used.
  83720. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83721. */
  83722. setPaddingInPixels(paddingTop: number, paddingRight?: number, paddingBottom?: number, paddingLeft?: number): void;
  83723. /** @hidden */
  83724. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  83725. /** @hidden */
  83726. _offsetLeft(offset: number): void;
  83727. /** @hidden */
  83728. _offsetTop(offset: number): void;
  83729. /** @hidden */
  83730. _markMatrixAsDirty(): void;
  83731. /** @hidden */
  83732. _flagDescendantsAsMatrixDirty(): void;
  83733. /** @hidden */
  83734. _intersectsRect(rect: Measure): boolean;
  83735. /** @hidden */
  83736. protected invalidateRect(): void;
  83737. /** @hidden */
  83738. _markAsDirty(force?: boolean): void;
  83739. /** @hidden */
  83740. _markAllAsDirty(): void;
  83741. /** @hidden */
  83742. _link(host: AdvancedDynamicTexture): void;
  83743. /** @hidden */
  83744. protected _transform(context?: CanvasRenderingContext2D): void;
  83745. /** @hidden */
  83746. _renderHighlight(context: CanvasRenderingContext2D): void;
  83747. /** @hidden */
  83748. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  83749. /** @hidden */
  83750. protected _applyStates(context: CanvasRenderingContext2D): void;
  83751. /** @hidden */
  83752. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  83753. /** @hidden */
  83754. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83755. protected _evaluateClippingState(parentMeasure: Measure): void;
  83756. /** @hidden */
  83757. _measure(): void;
  83758. /** @hidden */
  83759. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83760. /** @hidden */
  83761. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83762. /** @hidden */
  83763. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83764. /** @hidden */
  83765. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  83766. private static _ClipMeasure;
  83767. private _tmpMeasureA;
  83768. private _clip;
  83769. /** @hidden */
  83770. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  83771. /** @hidden */
  83772. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  83773. /**
  83774. * Tests if a given coordinates belong to the current control
  83775. * @param x defines x coordinate to test
  83776. * @param y defines y coordinate to test
  83777. * @returns true if the coordinates are inside the control
  83778. */
  83779. contains(x: number, y: number): boolean;
  83780. /** @hidden */
  83781. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83782. /** @hidden */
  83783. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  83784. /** @hidden */
  83785. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  83786. /** @hidden */
  83787. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  83788. /** @hidden */
  83789. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  83790. /** @hidden */
  83791. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  83792. /** @hidden */
  83793. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  83794. /** @hidden */
  83795. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  83796. /** @hidden */
  83797. _onCanvasBlur(): void;
  83798. /** @hidden */
  83799. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83800. private _prepareFont;
  83801. /**
  83802. * Serializes the current control
  83803. * @param serializationObject defined the JSON serialized object
  83804. */
  83805. serialize(serializationObject: any): void;
  83806. /** @hidden */
  83807. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  83808. /** Releases associated resources */
  83809. dispose(): void;
  83810. private static _HORIZONTAL_ALIGNMENT_LEFT;
  83811. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  83812. private static _HORIZONTAL_ALIGNMENT_CENTER;
  83813. private static _VERTICAL_ALIGNMENT_TOP;
  83814. private static _VERTICAL_ALIGNMENT_BOTTOM;
  83815. private static _VERTICAL_ALIGNMENT_CENTER;
  83816. /** HORIZONTAL_ALIGNMENT_LEFT */
  83817. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  83818. /** HORIZONTAL_ALIGNMENT_RIGHT */
  83819. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  83820. /** HORIZONTAL_ALIGNMENT_CENTER */
  83821. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  83822. /** VERTICAL_ALIGNMENT_TOP */
  83823. static get VERTICAL_ALIGNMENT_TOP(): number;
  83824. /** VERTICAL_ALIGNMENT_BOTTOM */
  83825. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  83826. /** VERTICAL_ALIGNMENT_CENTER */
  83827. static get VERTICAL_ALIGNMENT_CENTER(): number;
  83828. private static _FontHeightSizes;
  83829. /** @hidden */
  83830. static _GetFontOffset(font: string): {
  83831. ascent: number;
  83832. height: number;
  83833. descent: number;
  83834. };
  83835. /**
  83836. * Creates a Control from parsed data
  83837. * @param serializedObject defines parsed data
  83838. * @param host defines the hosting AdvancedDynamicTexture
  83839. * @returns a new Control
  83840. */
  83841. static Parse(serializedObject: any, host: AdvancedDynamicTexture): Control;
  83842. /**
  83843. * Creates a stack panel that can be used to render headers
  83844. * @param control defines the control to associate with the header
  83845. * @param text defines the text of the header
  83846. * @param size defines the size of the header
  83847. * @param options defines options used to configure the header
  83848. * @returns a new StackPanel
  83849. * @ignore
  83850. * @hidden
  83851. */
  83852. static AddHeader: (control: Control, text: string, size: string | number, options: {
  83853. isHorizontal: boolean;
  83854. controlFirst: boolean;
  83855. }) => any;
  83856. /** @hidden */
  83857. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  83858. }
  83859. }
  83860. declare module BABYLON.GUI {
  83861. /**
  83862. * Root class for 2D containers
  83863. * @see https://doc.babylonjs.com/how_to/gui#containers
  83864. */
  83865. export class Container extends Control {
  83866. name?: string | undefined;
  83867. /** @hidden */
  83868. _children: Control[];
  83869. /** @hidden */
  83870. protected _measureForChildren: Measure;
  83871. /** @hidden */
  83872. protected _background: string;
  83873. /** @hidden */
  83874. protected _adaptWidthToChildren: boolean;
  83875. /** @hidden */
  83876. protected _adaptHeightToChildren: boolean;
  83877. /**
  83878. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  83879. */
  83880. logLayoutCycleErrors: boolean;
  83881. /**
  83882. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  83883. */
  83884. maxLayoutCycle: number;
  83885. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  83886. get adaptHeightToChildren(): boolean;
  83887. set adaptHeightToChildren(value: boolean);
  83888. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  83889. get adaptWidthToChildren(): boolean;
  83890. set adaptWidthToChildren(value: boolean);
  83891. /** Gets or sets background color */
  83892. get background(): string;
  83893. set background(value: string);
  83894. /** Gets the list of children */
  83895. get children(): Control[];
  83896. /**
  83897. * Creates a new Container
  83898. * @param name defines the name of the container
  83899. */
  83900. constructor(name?: string | undefined);
  83901. protected _getTypeName(): string;
  83902. _flagDescendantsAsMatrixDirty(): void;
  83903. /**
  83904. * Gets a child using its name
  83905. * @param name defines the child name to look for
  83906. * @returns the child control if found
  83907. */
  83908. getChildByName(name: string): BABYLON.Nullable<Control>;
  83909. /**
  83910. * Gets a child using its type and its name
  83911. * @param name defines the child name to look for
  83912. * @param type defines the child type to look for
  83913. * @returns the child control if found
  83914. */
  83915. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  83916. /**
  83917. * Search for a specific control in children
  83918. * @param control defines the control to look for
  83919. * @returns true if the control is in child list
  83920. */
  83921. containsControl(control: Control): boolean;
  83922. /**
  83923. * Adds a new control to the current container
  83924. * @param control defines the control to add
  83925. * @returns the current container
  83926. */
  83927. addControl(control: BABYLON.Nullable<Control>): Container;
  83928. /**
  83929. * Removes all controls from the current container
  83930. * @returns the current container
  83931. */
  83932. clearControls(): Container;
  83933. /**
  83934. * Removes a control from the current container
  83935. * @param control defines the control to remove
  83936. * @returns the current container
  83937. */
  83938. removeControl(control: Control): Container;
  83939. /** @hidden */
  83940. _reOrderControl(control: Control): void;
  83941. /** @hidden */
  83942. _offsetLeft(offset: number): void;
  83943. /** @hidden */
  83944. _offsetTop(offset: number): void;
  83945. /** @hidden */
  83946. _markAllAsDirty(): void;
  83947. /** @hidden */
  83948. protected _localDraw(context: CanvasRenderingContext2D): void;
  83949. /** @hidden */
  83950. _link(host: AdvancedDynamicTexture): void;
  83951. /** @hidden */
  83952. protected _beforeLayout(): void;
  83953. /** @hidden */
  83954. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83955. /** @hidden */
  83956. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  83957. protected _postMeasure(): void;
  83958. /** @hidden */
  83959. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  83960. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  83961. /** @hidden */
  83962. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83963. /** @hidden */
  83964. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83965. /**
  83966. * Serializes the current control
  83967. * @param serializationObject defined the JSON serialized object
  83968. */
  83969. serialize(serializationObject: any): void;
  83970. /** Releases associated resources */
  83971. dispose(): void;
  83972. /** @hidden */
  83973. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  83974. }
  83975. }
  83976. declare module BABYLON.GUI {
  83977. /** Class used to create rectangle container */
  83978. export class Rectangle extends Container {
  83979. name?: string | undefined;
  83980. private _thickness;
  83981. private _cornerRadius;
  83982. /** Gets or sets border thickness */
  83983. get thickness(): number;
  83984. set thickness(value: number);
  83985. /** Gets or sets the corner radius angle */
  83986. get cornerRadius(): number;
  83987. set cornerRadius(value: number);
  83988. /**
  83989. * Creates a new Rectangle
  83990. * @param name defines the control name
  83991. */
  83992. constructor(name?: string | undefined);
  83993. protected _getTypeName(): string;
  83994. protected _localDraw(context: CanvasRenderingContext2D): void;
  83995. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83996. private _drawRoundedRect;
  83997. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  83998. }
  83999. }
  84000. declare module BABYLON.GUI {
  84001. /**
  84002. * Enum that determines the text-wrapping mode to use.
  84003. */
  84004. export enum TextWrapping {
  84005. /**
  84006. * Clip the text when it's larger than Control.width; this is the default mode.
  84007. */
  84008. Clip = 0,
  84009. /**
  84010. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  84011. */
  84012. WordWrap = 1,
  84013. /**
  84014. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  84015. */
  84016. Ellipsis = 2
  84017. }
  84018. /**
  84019. * Class used to create text block control
  84020. */
  84021. export class TextBlock extends Control {
  84022. /**
  84023. * Defines the name of the control
  84024. */
  84025. name?: string | undefined;
  84026. private _text;
  84027. private _textWrapping;
  84028. private _textHorizontalAlignment;
  84029. private _textVerticalAlignment;
  84030. private _lines;
  84031. private _resizeToFit;
  84032. private _lineSpacing;
  84033. private _outlineWidth;
  84034. private _outlineColor;
  84035. private _underline;
  84036. private _lineThrough;
  84037. /**
  84038. * An event triggered after the text is changed
  84039. */
  84040. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  84041. /**
  84042. * An event triggered after the text was broken up into lines
  84043. */
  84044. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  84045. /**
  84046. * Function used to split a string into words. By default, a string is split at each space character found
  84047. */
  84048. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  84049. /**
  84050. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  84051. */
  84052. get lines(): any[];
  84053. /**
  84054. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  84055. */
  84056. get resizeToFit(): boolean;
  84057. /**
  84058. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  84059. */
  84060. set resizeToFit(value: boolean);
  84061. /**
  84062. * Gets or sets a boolean indicating if text must be wrapped
  84063. */
  84064. get textWrapping(): TextWrapping | boolean;
  84065. /**
  84066. * Gets or sets a boolean indicating if text must be wrapped
  84067. */
  84068. set textWrapping(value: TextWrapping | boolean);
  84069. /**
  84070. * Gets or sets text to display
  84071. */
  84072. get text(): string;
  84073. /**
  84074. * Gets or sets text to display
  84075. */
  84076. set text(value: string);
  84077. /**
  84078. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  84079. */
  84080. get textHorizontalAlignment(): number;
  84081. /**
  84082. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  84083. */
  84084. set textHorizontalAlignment(value: number);
  84085. /**
  84086. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  84087. */
  84088. get textVerticalAlignment(): number;
  84089. /**
  84090. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  84091. */
  84092. set textVerticalAlignment(value: number);
  84093. /**
  84094. * Gets or sets line spacing value
  84095. */
  84096. set lineSpacing(value: string | number);
  84097. /**
  84098. * Gets or sets line spacing value
  84099. */
  84100. get lineSpacing(): string | number;
  84101. /**
  84102. * Gets or sets outlineWidth of the text to display
  84103. */
  84104. get outlineWidth(): number;
  84105. /**
  84106. * Gets or sets outlineWidth of the text to display
  84107. */
  84108. set outlineWidth(value: number);
  84109. /**
  84110. * Gets or sets a boolean indicating that text must have underline
  84111. */
  84112. get underline(): boolean;
  84113. /**
  84114. * Gets or sets a boolean indicating that text must have underline
  84115. */
  84116. set underline(value: boolean);
  84117. /**
  84118. * Gets or sets an boolean indicating that text must be crossed out
  84119. */
  84120. get lineThrough(): boolean;
  84121. /**
  84122. * Gets or sets an boolean indicating that text must be crossed out
  84123. */
  84124. set lineThrough(value: boolean);
  84125. /**
  84126. * Gets or sets outlineColor of the text to display
  84127. */
  84128. get outlineColor(): string;
  84129. /**
  84130. * Gets or sets outlineColor of the text to display
  84131. */
  84132. set outlineColor(value: string);
  84133. /**
  84134. * Creates a new TextBlock object
  84135. * @param name defines the name of the control
  84136. * @param text defines the text to display (emptry string by default)
  84137. */
  84138. constructor(
  84139. /**
  84140. * Defines the name of the control
  84141. */
  84142. name?: string | undefined, text?: string);
  84143. protected _getTypeName(): string;
  84144. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84145. private _drawText;
  84146. /** @hidden */
  84147. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84148. protected _applyStates(context: CanvasRenderingContext2D): void;
  84149. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  84150. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  84151. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  84152. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  84153. protected _renderLines(context: CanvasRenderingContext2D): void;
  84154. /**
  84155. * Given a width constraint applied on the text block, find the expected height
  84156. * @returns expected height
  84157. */
  84158. computeExpectedHeight(): number;
  84159. dispose(): void;
  84160. }
  84161. }
  84162. declare module BABYLON.GUI {
  84163. /**
  84164. * Class used to create 2D images
  84165. */
  84166. export class Image extends Control {
  84167. name?: string | undefined;
  84168. private _workingCanvas;
  84169. private _domImage;
  84170. private _imageWidth;
  84171. private _imageHeight;
  84172. private _loaded;
  84173. private _stretch;
  84174. private _source;
  84175. private _autoScale;
  84176. private _sourceLeft;
  84177. private _sourceTop;
  84178. private _sourceWidth;
  84179. private _sourceHeight;
  84180. private _svgAttributesComputationCompleted;
  84181. private _isSVG;
  84182. private _cellWidth;
  84183. private _cellHeight;
  84184. private _cellId;
  84185. private _populateNinePatchSlicesFromImage;
  84186. private _sliceLeft;
  84187. private _sliceRight;
  84188. private _sliceTop;
  84189. private _sliceBottom;
  84190. private _detectPointerOnOpaqueOnly;
  84191. private _imageDataCache;
  84192. /**
  84193. * BABYLON.Observable notified when the content is loaded
  84194. */
  84195. onImageLoadedObservable: BABYLON.Observable<Image>;
  84196. /**
  84197. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  84198. */
  84199. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  84200. /**
  84201. * Gets a boolean indicating that the content is loaded
  84202. */
  84203. get isLoaded(): boolean;
  84204. /**
  84205. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  84206. */
  84207. get populateNinePatchSlicesFromImage(): boolean;
  84208. set populateNinePatchSlicesFromImage(value: boolean);
  84209. /**
  84210. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  84211. * Beware using this as this will comsume more memory as the image has to be stored twice
  84212. */
  84213. get detectPointerOnOpaqueOnly(): boolean;
  84214. set detectPointerOnOpaqueOnly(value: boolean);
  84215. /**
  84216. * Gets or sets the left value for slicing (9-patch)
  84217. */
  84218. get sliceLeft(): number;
  84219. set sliceLeft(value: number);
  84220. /**
  84221. * Gets or sets the right value for slicing (9-patch)
  84222. */
  84223. get sliceRight(): number;
  84224. set sliceRight(value: number);
  84225. /**
  84226. * Gets or sets the top value for slicing (9-patch)
  84227. */
  84228. get sliceTop(): number;
  84229. set sliceTop(value: number);
  84230. /**
  84231. * Gets or sets the bottom value for slicing (9-patch)
  84232. */
  84233. get sliceBottom(): number;
  84234. set sliceBottom(value: number);
  84235. /**
  84236. * Gets or sets the left coordinate in the source image
  84237. */
  84238. get sourceLeft(): number;
  84239. set sourceLeft(value: number);
  84240. /**
  84241. * Gets or sets the top coordinate in the source image
  84242. */
  84243. get sourceTop(): number;
  84244. set sourceTop(value: number);
  84245. /**
  84246. * Gets or sets the width to capture in the source image
  84247. */
  84248. get sourceWidth(): number;
  84249. set sourceWidth(value: number);
  84250. /**
  84251. * Gets or sets the height to capture in the source image
  84252. */
  84253. get sourceHeight(): number;
  84254. set sourceHeight(value: number);
  84255. /** Indicates if the format of the image is SVG */
  84256. get isSVG(): boolean;
  84257. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  84258. get svgAttributesComputationCompleted(): boolean;
  84259. /**
  84260. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  84261. * @see https://doc.babylonjs.com/how_to/gui#image
  84262. */
  84263. get autoScale(): boolean;
  84264. set autoScale(value: boolean);
  84265. /** Gets or sets the streching mode used by the image */
  84266. get stretch(): number;
  84267. set stretch(value: number);
  84268. /** @hidden */
  84269. _rotate90(n: number, preserveProperties?: boolean): Image;
  84270. private _handleRotationForSVGImage;
  84271. private _rotate90SourceProperties;
  84272. /**
  84273. * Gets or sets the internal DOM image used to render the control
  84274. */
  84275. set domImage(value: HTMLImageElement);
  84276. get domImage(): HTMLImageElement;
  84277. private _onImageLoaded;
  84278. private _extractNinePatchSliceDataFromImage;
  84279. /**
  84280. * Gets the image source url
  84281. */
  84282. get source(): BABYLON.Nullable<string>;
  84283. /**
  84284. * Gets or sets image source url
  84285. */
  84286. set source(value: BABYLON.Nullable<string>);
  84287. /**
  84288. * Checks for svg document with icon id present
  84289. */
  84290. private _svgCheck;
  84291. /**
  84292. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  84293. * given external svg file and icon id
  84294. */
  84295. private _getSVGAttribs;
  84296. /**
  84297. * Gets or sets the cell width to use when animation sheet is enabled
  84298. * @see https://doc.babylonjs.com/how_to/gui#image
  84299. */
  84300. get cellWidth(): number;
  84301. set cellWidth(value: number);
  84302. /**
  84303. * Gets or sets the cell height to use when animation sheet is enabled
  84304. * @see https://doc.babylonjs.com/how_to/gui#image
  84305. */
  84306. get cellHeight(): number;
  84307. set cellHeight(value: number);
  84308. /**
  84309. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  84310. * @see https://doc.babylonjs.com/how_to/gui#image
  84311. */
  84312. get cellId(): number;
  84313. set cellId(value: number);
  84314. /**
  84315. * Creates a new Image
  84316. * @param name defines the control name
  84317. * @param url defines the image url
  84318. */
  84319. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  84320. /**
  84321. * Tests if a given coordinates belong to the current control
  84322. * @param x defines x coordinate to test
  84323. * @param y defines y coordinate to test
  84324. * @returns true if the coordinates are inside the control
  84325. */
  84326. contains(x: number, y: number): boolean;
  84327. protected _getTypeName(): string;
  84328. /** Force the control to synchronize with its content */
  84329. synchronizeSizeWithContent(): void;
  84330. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84331. private _prepareWorkingCanvasForOpaqueDetection;
  84332. private _drawImage;
  84333. _draw(context: CanvasRenderingContext2D): void;
  84334. private _renderCornerPatch;
  84335. private _renderNinePatch;
  84336. dispose(): void;
  84337. /** STRETCH_NONE */
  84338. static readonly STRETCH_NONE: number;
  84339. /** STRETCH_FILL */
  84340. static readonly STRETCH_FILL: number;
  84341. /** STRETCH_UNIFORM */
  84342. static readonly STRETCH_UNIFORM: number;
  84343. /** STRETCH_EXTEND */
  84344. static readonly STRETCH_EXTEND: number;
  84345. /** NINE_PATCH */
  84346. static readonly STRETCH_NINE_PATCH: number;
  84347. }
  84348. }
  84349. declare module BABYLON.GUI {
  84350. /**
  84351. * Class used to create 2D buttons
  84352. */
  84353. export class Button extends Rectangle {
  84354. name?: string | undefined;
  84355. /**
  84356. * Function called to generate a pointer enter animation
  84357. */
  84358. pointerEnterAnimation: () => void;
  84359. /**
  84360. * Function called to generate a pointer out animation
  84361. */
  84362. pointerOutAnimation: () => void;
  84363. /**
  84364. * Function called to generate a pointer down animation
  84365. */
  84366. pointerDownAnimation: () => void;
  84367. /**
  84368. * Function called to generate a pointer up animation
  84369. */
  84370. pointerUpAnimation: () => void;
  84371. /**
  84372. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  84373. */
  84374. delegatePickingToChildren: boolean;
  84375. private _image;
  84376. /**
  84377. * Returns the image part of the button (if any)
  84378. */
  84379. get image(): BABYLON.Nullable<Image>;
  84380. private _textBlock;
  84381. /**
  84382. * Returns the image part of the button (if any)
  84383. */
  84384. get textBlock(): BABYLON.Nullable<TextBlock>;
  84385. /**
  84386. * Creates a new Button
  84387. * @param name defines the name of the button
  84388. */
  84389. constructor(name?: string | undefined);
  84390. protected _getTypeName(): string;
  84391. /** @hidden */
  84392. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  84393. /** @hidden */
  84394. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  84395. /** @hidden */
  84396. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  84397. /** @hidden */
  84398. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84399. /** @hidden */
  84400. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  84401. /**
  84402. * Creates a new button made with an image and a text
  84403. * @param name defines the name of the button
  84404. * @param text defines the text of the button
  84405. * @param imageUrl defines the url of the image
  84406. * @returns a new Button
  84407. */
  84408. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  84409. /**
  84410. * Creates a new button made with an image
  84411. * @param name defines the name of the button
  84412. * @param imageUrl defines the url of the image
  84413. * @returns a new Button
  84414. */
  84415. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  84416. /**
  84417. * Creates a new button made with a text
  84418. * @param name defines the name of the button
  84419. * @param text defines the text of the button
  84420. * @returns a new Button
  84421. */
  84422. static CreateSimpleButton(name: string, text: string): Button;
  84423. /**
  84424. * Creates a new button made with an image and a centered text
  84425. * @param name defines the name of the button
  84426. * @param text defines the text of the button
  84427. * @param imageUrl defines the url of the image
  84428. * @returns a new Button
  84429. */
  84430. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  84431. }
  84432. }
  84433. declare module BABYLON.GUI {
  84434. /**
  84435. * Class used to create a 2D stack panel container
  84436. */
  84437. export class StackPanel extends Container {
  84438. name?: string | undefined;
  84439. private _isVertical;
  84440. private _manualWidth;
  84441. private _manualHeight;
  84442. private _doNotTrackManualChanges;
  84443. /**
  84444. * Gets or sets a boolean indicating that layou warnings should be ignored
  84445. */
  84446. ignoreLayoutWarnings: boolean;
  84447. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  84448. get isVertical(): boolean;
  84449. set isVertical(value: boolean);
  84450. /**
  84451. * Gets or sets panel width.
  84452. * This value should not be set when in horizontal mode as it will be computed automatically
  84453. */
  84454. set width(value: string | number);
  84455. get width(): string | number;
  84456. /**
  84457. * Gets or sets panel height.
  84458. * This value should not be set when in vertical mode as it will be computed automatically
  84459. */
  84460. set height(value: string | number);
  84461. get height(): string | number;
  84462. /**
  84463. * Creates a new StackPanel
  84464. * @param name defines control name
  84465. */
  84466. constructor(name?: string | undefined);
  84467. protected _getTypeName(): string;
  84468. /** @hidden */
  84469. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84470. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84471. protected _postMeasure(): void;
  84472. /**
  84473. * Serializes the current control
  84474. * @param serializationObject defined the JSON serialized object
  84475. */
  84476. serialize(serializationObject: any): void;
  84477. /** @hidden */
  84478. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  84479. }
  84480. }
  84481. declare module BABYLON.GUI {
  84482. /**
  84483. * Class used to represent a 2D checkbox
  84484. */
  84485. export class Checkbox extends Control {
  84486. name?: string | undefined;
  84487. private _isChecked;
  84488. private _background;
  84489. private _checkSizeRatio;
  84490. private _thickness;
  84491. /** Gets or sets border thickness */
  84492. get thickness(): number;
  84493. set thickness(value: number);
  84494. /**
  84495. * BABYLON.Observable raised when isChecked property changes
  84496. */
  84497. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  84498. /** Gets or sets a value indicating the ratio between overall size and check size */
  84499. get checkSizeRatio(): number;
  84500. set checkSizeRatio(value: number);
  84501. /** Gets or sets background color */
  84502. get background(): string;
  84503. set background(value: string);
  84504. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  84505. get isChecked(): boolean;
  84506. set isChecked(value: boolean);
  84507. /**
  84508. * Creates a new CheckBox
  84509. * @param name defines the control name
  84510. */
  84511. constructor(name?: string | undefined);
  84512. protected _getTypeName(): string;
  84513. /** @hidden */
  84514. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84515. /** @hidden */
  84516. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84517. /**
  84518. * Utility function to easily create a checkbox with a header
  84519. * @param title defines the label to use for the header
  84520. * @param onValueChanged defines the callback to call when value changes
  84521. * @returns a StackPanel containing the checkbox and a textBlock
  84522. */
  84523. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  84524. }
  84525. }
  84526. declare module BABYLON.GUI {
  84527. /**
  84528. * Class used to store key control properties
  84529. */
  84530. export class KeyPropertySet {
  84531. /** Width */
  84532. width?: string;
  84533. /** Height */
  84534. height?: string;
  84535. /** Left padding */
  84536. paddingLeft?: string;
  84537. /** Right padding */
  84538. paddingRight?: string;
  84539. /** Top padding */
  84540. paddingTop?: string;
  84541. /** Bottom padding */
  84542. paddingBottom?: string;
  84543. /** Foreground color */
  84544. color?: string;
  84545. /** Background color */
  84546. background?: string;
  84547. }
  84548. /**
  84549. * Class used to create virtual keyboard
  84550. */
  84551. export class VirtualKeyboard extends StackPanel {
  84552. /** BABYLON.Observable raised when a key is pressed */
  84553. onKeyPressObservable: BABYLON.Observable<string>;
  84554. /** Gets or sets default key button width */
  84555. defaultButtonWidth: string;
  84556. /** Gets or sets default key button height */
  84557. defaultButtonHeight: string;
  84558. /** Gets or sets default key button left padding */
  84559. defaultButtonPaddingLeft: string;
  84560. /** Gets or sets default key button right padding */
  84561. defaultButtonPaddingRight: string;
  84562. /** Gets or sets default key button top padding */
  84563. defaultButtonPaddingTop: string;
  84564. /** Gets or sets default key button bottom padding */
  84565. defaultButtonPaddingBottom: string;
  84566. /** Gets or sets default key button foreground color */
  84567. defaultButtonColor: string;
  84568. /** Gets or sets default key button background color */
  84569. defaultButtonBackground: string;
  84570. /** Gets or sets shift button foreground color */
  84571. shiftButtonColor: string;
  84572. /** Gets or sets shift button thickness*/
  84573. selectedShiftThickness: number;
  84574. /** Gets shift key state */
  84575. shiftState: number;
  84576. protected _getTypeName(): string;
  84577. private _createKey;
  84578. /**
  84579. * Adds a new row of keys
  84580. * @param keys defines the list of keys to add
  84581. * @param propertySets defines the associated property sets
  84582. */
  84583. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  84584. /**
  84585. * Set the shift key to a specific state
  84586. * @param shiftState defines the new shift state
  84587. */
  84588. applyShiftState(shiftState: number): void;
  84589. private _currentlyConnectedInputText;
  84590. private _connectedInputTexts;
  84591. private _onKeyPressObserver;
  84592. /** Gets the input text control currently attached to the keyboard */
  84593. get connectedInputText(): BABYLON.Nullable<InputText>;
  84594. /**
  84595. * Connects the keyboard with an input text control
  84596. *
  84597. * @param input defines the target control
  84598. */
  84599. connect(input: InputText): void;
  84600. /**
  84601. * Disconnects the keyboard from connected InputText controls
  84602. *
  84603. * @param input optionally defines a target control, otherwise all are disconnected
  84604. */
  84605. disconnect(input?: InputText): void;
  84606. private _removeConnectedInputObservables;
  84607. /**
  84608. * Release all resources
  84609. */
  84610. dispose(): void;
  84611. /**
  84612. * Creates a new keyboard using a default layout
  84613. *
  84614. * @param name defines control name
  84615. * @returns a new VirtualKeyboard
  84616. */
  84617. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  84618. }
  84619. }
  84620. declare module BABYLON.GUI {
  84621. /** @hidden */
  84622. export class TextWrapper {
  84623. private _text;
  84624. private _characters;
  84625. get text(): string;
  84626. set text(txt: string);
  84627. get length(): number;
  84628. removePart(idxStart: number, idxEnd: number, insertTxt?: string): void;
  84629. charAt(idx: number): string;
  84630. substr(from: number, length?: number): string;
  84631. substring(from: number, to?: number): string;
  84632. isWord(index: number): boolean;
  84633. }
  84634. }
  84635. declare module BABYLON.GUI {
  84636. /**
  84637. * Class used to create input text control
  84638. */
  84639. export class InputText extends Control implements IFocusableControl {
  84640. name?: string | undefined;
  84641. private _textWrapper;
  84642. private _placeholderText;
  84643. private _background;
  84644. private _focusedBackground;
  84645. private _focusedColor;
  84646. private _placeholderColor;
  84647. private _thickness;
  84648. private _margin;
  84649. private _autoStretchWidth;
  84650. private _maxWidth;
  84651. private _isFocused;
  84652. private _blinkTimeout;
  84653. private _blinkIsEven;
  84654. private _cursorOffset;
  84655. private _scrollLeft;
  84656. private _textWidth;
  84657. private _clickedCoordinate;
  84658. private _deadKey;
  84659. private _addKey;
  84660. private _currentKey;
  84661. private _isTextHighlightOn;
  84662. private _textHighlightColor;
  84663. private _highligherOpacity;
  84664. private _highlightedText;
  84665. private _startHighlightIndex;
  84666. private _endHighlightIndex;
  84667. private _cursorIndex;
  84668. private _onFocusSelectAll;
  84669. private _isPointerDown;
  84670. private _onClipboardObserver;
  84671. private _onPointerDblTapObserver;
  84672. /** @hidden */
  84673. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  84674. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  84675. promptMessage: string;
  84676. /** Force disable prompt on mobile device */
  84677. disableMobilePrompt: boolean;
  84678. /** BABYLON.Observable raised when the text changes */
  84679. onTextChangedObservable: BABYLON.Observable<InputText>;
  84680. /** BABYLON.Observable raised just before an entered character is to be added */
  84681. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  84682. /** BABYLON.Observable raised when the control gets the focus */
  84683. onFocusObservable: BABYLON.Observable<InputText>;
  84684. /** BABYLON.Observable raised when the control loses the focus */
  84685. onBlurObservable: BABYLON.Observable<InputText>;
  84686. /**Observable raised when the text is highlighted */
  84687. onTextHighlightObservable: BABYLON.Observable<InputText>;
  84688. /**Observable raised when copy event is triggered */
  84689. onTextCopyObservable: BABYLON.Observable<InputText>;
  84690. /** BABYLON.Observable raised when cut event is triggered */
  84691. onTextCutObservable: BABYLON.Observable<InputText>;
  84692. /** BABYLON.Observable raised when paste event is triggered */
  84693. onTextPasteObservable: BABYLON.Observable<InputText>;
  84694. /** BABYLON.Observable raised when a key event was processed */
  84695. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  84696. /** Gets or sets the maximum width allowed by the control */
  84697. get maxWidth(): string | number;
  84698. /** Gets the maximum width allowed by the control in pixels */
  84699. get maxWidthInPixels(): number;
  84700. set maxWidth(value: string | number);
  84701. /** Gets or sets the text highlighter transparency; default: 0.4 */
  84702. get highligherOpacity(): number;
  84703. set highligherOpacity(value: number);
  84704. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  84705. get onFocusSelectAll(): boolean;
  84706. set onFocusSelectAll(value: boolean);
  84707. /** Gets or sets the text hightlight color */
  84708. get textHighlightColor(): string;
  84709. set textHighlightColor(value: string);
  84710. /** Gets or sets control margin */
  84711. get margin(): string;
  84712. /** Gets control margin in pixels */
  84713. get marginInPixels(): number;
  84714. set margin(value: string);
  84715. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  84716. get autoStretchWidth(): boolean;
  84717. set autoStretchWidth(value: boolean);
  84718. /** Gets or sets border thickness */
  84719. get thickness(): number;
  84720. set thickness(value: number);
  84721. /** Gets or sets the background color when focused */
  84722. get focusedBackground(): string;
  84723. set focusedBackground(value: string);
  84724. /** Gets or sets the background color when focused */
  84725. get focusedColor(): string;
  84726. set focusedColor(value: string);
  84727. /** Gets or sets the background color */
  84728. get background(): string;
  84729. set background(value: string);
  84730. /** Gets or sets the placeholder color */
  84731. get placeholderColor(): string;
  84732. set placeholderColor(value: string);
  84733. /** Gets or sets the text displayed when the control is empty */
  84734. get placeholderText(): string;
  84735. set placeholderText(value: string);
  84736. /** Gets or sets the dead key flag */
  84737. get deadKey(): boolean;
  84738. set deadKey(flag: boolean);
  84739. /** Gets or sets the highlight text */
  84740. get highlightedText(): string;
  84741. set highlightedText(text: string);
  84742. /** Gets or sets if the current key should be added */
  84743. get addKey(): boolean;
  84744. set addKey(flag: boolean);
  84745. /** Gets or sets the value of the current key being entered */
  84746. get currentKey(): string;
  84747. set currentKey(key: string);
  84748. /** Gets or sets the text displayed in the control */
  84749. get text(): string;
  84750. set text(value: string);
  84751. private _textHasChanged;
  84752. /** Gets or sets control width */
  84753. get width(): string | number;
  84754. set width(value: string | number);
  84755. /**
  84756. * Creates a new InputText
  84757. * @param name defines the control name
  84758. * @param text defines the text of the control
  84759. */
  84760. constructor(name?: string | undefined, text?: string);
  84761. /** @hidden */
  84762. onBlur(): void;
  84763. /** @hidden */
  84764. onFocus(): void;
  84765. /**
  84766. * Function to focus an inputText programmatically
  84767. */
  84768. focus(): void;
  84769. /**
  84770. * Function to unfocus an inputText programmatically
  84771. */
  84772. blur(): void;
  84773. protected _getTypeName(): string;
  84774. /**
  84775. * Function called to get the list of controls that should not steal the focus from this control
  84776. * @returns an array of controls
  84777. */
  84778. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  84779. /** @hidden */
  84780. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  84781. /** @hidden */
  84782. private _updateValueFromCursorIndex;
  84783. /** @hidden */
  84784. private _processDblClick;
  84785. /** @hidden */
  84786. private _selectAllText;
  84787. /**
  84788. * Handles the keyboard event
  84789. * @param evt Defines the KeyboardEvent
  84790. */
  84791. processKeyboard(evt: KeyboardEvent): void;
  84792. /** @hidden */
  84793. private _onCopyText;
  84794. /** @hidden */
  84795. private _onCutText;
  84796. /** @hidden */
  84797. private _onPasteText;
  84798. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84799. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84800. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84801. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  84802. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  84803. dispose(): void;
  84804. }
  84805. }
  84806. declare module BABYLON.GUI {
  84807. /**
  84808. * Class used to create a 2D grid container
  84809. */
  84810. export class Grid extends Container {
  84811. name?: string | undefined;
  84812. private _rowDefinitions;
  84813. private _columnDefinitions;
  84814. private _cells;
  84815. private _childControls;
  84816. /**
  84817. * Gets the number of columns
  84818. */
  84819. get columnCount(): number;
  84820. /**
  84821. * Gets the number of rows
  84822. */
  84823. get rowCount(): number;
  84824. /** Gets the list of children */
  84825. get children(): Control[];
  84826. /** Gets the list of cells (e.g. the containers) */
  84827. get cells(): {
  84828. [key: string]: Container;
  84829. };
  84830. /**
  84831. * Gets the definition of a specific row
  84832. * @param index defines the index of the row
  84833. * @returns the row definition
  84834. */
  84835. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  84836. /**
  84837. * Gets the definition of a specific column
  84838. * @param index defines the index of the column
  84839. * @returns the column definition
  84840. */
  84841. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  84842. /**
  84843. * Adds a new row to the grid
  84844. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  84845. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  84846. * @returns the current grid
  84847. */
  84848. addRowDefinition(height: number, isPixel?: boolean): Grid;
  84849. /**
  84850. * Adds a new column to the grid
  84851. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  84852. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  84853. * @returns the current grid
  84854. */
  84855. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  84856. /**
  84857. * Update a row definition
  84858. * @param index defines the index of the row to update
  84859. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  84860. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  84861. * @returns the current grid
  84862. */
  84863. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  84864. /**
  84865. * Update a column definition
  84866. * @param index defines the index of the column to update
  84867. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  84868. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  84869. * @returns the current grid
  84870. */
  84871. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  84872. /**
  84873. * Gets the list of children stored in a specific cell
  84874. * @param row defines the row to check
  84875. * @param column defines the column to check
  84876. * @returns the list of controls
  84877. */
  84878. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  84879. /**
  84880. * Gets a string representing the child cell info (row x column)
  84881. * @param child defines the control to get info from
  84882. * @returns a string containing the child cell info (row x column)
  84883. */
  84884. getChildCellInfo(child: Control): string;
  84885. private _removeCell;
  84886. private _offsetCell;
  84887. /**
  84888. * Remove a column definition at specified index
  84889. * @param index defines the index of the column to remove
  84890. * @returns the current grid
  84891. */
  84892. removeColumnDefinition(index: number): Grid;
  84893. /**
  84894. * Remove a row definition at specified index
  84895. * @param index defines the index of the row to remove
  84896. * @returns the current grid
  84897. */
  84898. removeRowDefinition(index: number): Grid;
  84899. /**
  84900. * Adds a new control to the current grid
  84901. * @param control defines the control to add
  84902. * @param row defines the row where to add the control (0 by default)
  84903. * @param column defines the column where to add the control (0 by default)
  84904. * @returns the current grid
  84905. */
  84906. addControl(control: Control, row?: number, column?: number): Grid;
  84907. /**
  84908. * Removes a control from the current container
  84909. * @param control defines the control to remove
  84910. * @returns the current container
  84911. */
  84912. removeControl(control: Control): Container;
  84913. /**
  84914. * Creates a new Grid
  84915. * @param name defines control name
  84916. */
  84917. constructor(name?: string | undefined);
  84918. protected _getTypeName(): string;
  84919. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  84920. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84921. _flagDescendantsAsMatrixDirty(): void;
  84922. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  84923. /** Releases associated resources */
  84924. dispose(): void;
  84925. }
  84926. }
  84927. declare module BABYLON.GUI {
  84928. /** Class used to create color pickers */
  84929. export class ColorPicker extends Control {
  84930. name?: string | undefined;
  84931. private static _Epsilon;
  84932. private _colorWheelCanvas;
  84933. private _value;
  84934. private _tmpColor;
  84935. private _pointerStartedOnSquare;
  84936. private _pointerStartedOnWheel;
  84937. private _squareLeft;
  84938. private _squareTop;
  84939. private _squareSize;
  84940. private _h;
  84941. private _s;
  84942. private _v;
  84943. private _lastPointerDownID;
  84944. /**
  84945. * BABYLON.Observable raised when the value changes
  84946. */
  84947. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  84948. /** Gets or sets the color of the color picker */
  84949. get value(): BABYLON.Color3;
  84950. set value(value: BABYLON.Color3);
  84951. /**
  84952. * Gets or sets control width
  84953. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84954. */
  84955. get width(): string | number;
  84956. set width(value: string | number);
  84957. /**
  84958. * Gets or sets control height
  84959. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84960. */
  84961. get height(): string | number;
  84962. /** Gets or sets control height */
  84963. set height(value: string | number);
  84964. /** Gets or sets control size */
  84965. get size(): string | number;
  84966. set size(value: string | number);
  84967. /**
  84968. * Creates a new ColorPicker
  84969. * @param name defines the control name
  84970. */
  84971. constructor(name?: string | undefined);
  84972. protected _getTypeName(): string;
  84973. /** @hidden */
  84974. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84975. private _updateSquareProps;
  84976. private _drawGradientSquare;
  84977. private _drawCircle;
  84978. private _createColorWheelCanvas;
  84979. /** @hidden */
  84980. _draw(context: CanvasRenderingContext2D): void;
  84981. private _pointerIsDown;
  84982. private _updateValueFromPointer;
  84983. private _isPointOnSquare;
  84984. private _isPointOnWheel;
  84985. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84986. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84987. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  84988. _onCanvasBlur(): void;
  84989. /**
  84990. * This function expands the color picker by creating a color picker dialog with manual
  84991. * color value input and the ability to save colors into an array to be used later in
  84992. * subsequent launches of the dialogue.
  84993. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  84994. * @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.
  84995. * @returns picked color as a hex string and the saved colors array as hex strings.
  84996. */
  84997. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  84998. pickerWidth?: string;
  84999. pickerHeight?: string;
  85000. headerHeight?: string;
  85001. lastColor?: string;
  85002. swatchLimit?: number;
  85003. numSwatchesPerLine?: number;
  85004. savedColors?: Array<string>;
  85005. }): Promise<{
  85006. savedColors?: string[];
  85007. pickedColor: string;
  85008. }>;
  85009. }
  85010. }
  85011. declare module BABYLON.GUI {
  85012. /** Class used to create 2D ellipse containers */
  85013. export class Ellipse extends Container {
  85014. name?: string | undefined;
  85015. private _thickness;
  85016. /** Gets or sets border thickness */
  85017. get thickness(): number;
  85018. set thickness(value: number);
  85019. /**
  85020. * Creates a new Ellipse
  85021. * @param name defines the control name
  85022. */
  85023. constructor(name?: string | undefined);
  85024. protected _getTypeName(): string;
  85025. protected _localDraw(context: CanvasRenderingContext2D): void;
  85026. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85027. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  85028. }
  85029. }
  85030. declare module BABYLON.GUI {
  85031. /**
  85032. * Class used to create a focusable button that can easily handle keyboard events
  85033. */
  85034. export class FocusableButton extends Button implements IFocusableControl {
  85035. name?: string | undefined;
  85036. /** Highlight color when button is focused */
  85037. focusedColor: BABYLON.Nullable<string>;
  85038. private _isFocused;
  85039. private _unfocusedColor;
  85040. /** BABYLON.Observable raised when the control gets the focus */
  85041. onFocusObservable: BABYLON.Observable<Button>;
  85042. /** BABYLON.Observable raised when the control loses the focus */
  85043. onBlurObservable: BABYLON.Observable<Button>;
  85044. /** BABYLON.Observable raised when a key event was processed */
  85045. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  85046. constructor(name?: string | undefined);
  85047. /** @hidden */
  85048. onBlur(): void;
  85049. /** @hidden */
  85050. onFocus(): void;
  85051. /**
  85052. * Function called to get the list of controls that should not steal the focus from this control
  85053. * @returns an array of controls
  85054. */
  85055. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  85056. /**
  85057. * Function to focus a button programmatically
  85058. */
  85059. focus(): void;
  85060. /**
  85061. * Function to unfocus a button programmatically
  85062. */
  85063. blur(): void;
  85064. /**
  85065. * Handles the keyboard event
  85066. * @param evt Defines the KeyboardEvent
  85067. */
  85068. processKeyboard(evt: KeyboardEvent): void;
  85069. /** @hidden */
  85070. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85071. /** @hidden */
  85072. displose(): void;
  85073. }
  85074. }
  85075. declare module BABYLON.GUI {
  85076. /**
  85077. * Class used to create a password control
  85078. */
  85079. export class InputPassword extends InputText {
  85080. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  85081. }
  85082. }
  85083. declare module BABYLON.GUI {
  85084. /** Class used to render 2D lines */
  85085. export class Line extends Control {
  85086. name?: string | undefined;
  85087. private _lineWidth;
  85088. private _x1;
  85089. private _y1;
  85090. private _x2;
  85091. private _y2;
  85092. private _dash;
  85093. private _connectedControl;
  85094. private _connectedControlDirtyObserver;
  85095. /** Gets or sets the dash pattern */
  85096. get dash(): Array<number>;
  85097. set dash(value: Array<number>);
  85098. /** Gets or sets the control connected with the line end */
  85099. get connectedControl(): Control;
  85100. set connectedControl(value: Control);
  85101. /** Gets or sets start coordinates on X axis */
  85102. get x1(): string | number;
  85103. set x1(value: string | number);
  85104. /** Gets or sets start coordinates on Y axis */
  85105. get y1(): string | number;
  85106. set y1(value: string | number);
  85107. /** Gets or sets end coordinates on X axis */
  85108. get x2(): string | number;
  85109. set x2(value: string | number);
  85110. /** Gets or sets end coordinates on Y axis */
  85111. get y2(): string | number;
  85112. set y2(value: string | number);
  85113. /** Gets or sets line width */
  85114. get lineWidth(): number;
  85115. set lineWidth(value: number);
  85116. /** Gets or sets horizontal alignment */
  85117. set horizontalAlignment(value: number);
  85118. /** Gets or sets vertical alignment */
  85119. set verticalAlignment(value: number);
  85120. private get _effectiveX2();
  85121. private get _effectiveY2();
  85122. /**
  85123. * Creates a new Line
  85124. * @param name defines the control name
  85125. */
  85126. constructor(name?: string | undefined);
  85127. protected _getTypeName(): string;
  85128. _draw(context: CanvasRenderingContext2D): void;
  85129. _measure(): void;
  85130. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85131. /**
  85132. * Move one end of the line given 3D cartesian coordinates.
  85133. * @param position Targeted world position
  85134. * @param scene BABYLON.Scene
  85135. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  85136. */
  85137. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  85138. /**
  85139. * Move one end of the line to a position in screen absolute space.
  85140. * @param projectedPosition Position in screen absolute space (X, Y)
  85141. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  85142. */
  85143. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  85144. }
  85145. }
  85146. declare module BABYLON.GUI {
  85147. /**
  85148. * Class used to store a point for a MultiLine object.
  85149. * The point can be pure 2D coordinates, a mesh or a control
  85150. */
  85151. export class MultiLinePoint {
  85152. private _multiLine;
  85153. private _x;
  85154. private _y;
  85155. private _control;
  85156. private _mesh;
  85157. private _controlObserver;
  85158. private _meshObserver;
  85159. /** @hidden */
  85160. _point: BABYLON.Vector3;
  85161. /**
  85162. * Creates a new MultiLinePoint
  85163. * @param multiLine defines the source MultiLine object
  85164. */
  85165. constructor(multiLine: MultiLine);
  85166. /** Gets or sets x coordinate */
  85167. get x(): string | number;
  85168. set x(value: string | number);
  85169. /** Gets or sets y coordinate */
  85170. get y(): string | number;
  85171. set y(value: string | number);
  85172. /** Gets or sets the control associated with this point */
  85173. get control(): BABYLON.Nullable<Control>;
  85174. set control(value: BABYLON.Nullable<Control>);
  85175. /** Gets or sets the mesh associated with this point */
  85176. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  85177. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  85178. /** Resets links */
  85179. resetLinks(): void;
  85180. /**
  85181. * Gets a translation vector with Z component
  85182. * @returns the translation vector
  85183. */
  85184. translate(): BABYLON.Vector3;
  85185. private _translatePoint;
  85186. /** Release associated resources */
  85187. dispose(): void;
  85188. }
  85189. }
  85190. declare module BABYLON.GUI {
  85191. /**
  85192. * Class used to create multi line control
  85193. */
  85194. export class MultiLine extends Control {
  85195. name?: string | undefined;
  85196. private _lineWidth;
  85197. private _dash;
  85198. private _points;
  85199. private _minX;
  85200. private _minY;
  85201. private _maxX;
  85202. private _maxY;
  85203. /**
  85204. * Creates a new MultiLine
  85205. * @param name defines the control name
  85206. */
  85207. constructor(name?: string | undefined);
  85208. /** Gets or sets dash pattern */
  85209. get dash(): Array<number>;
  85210. set dash(value: Array<number>);
  85211. /**
  85212. * Gets point stored at specified index
  85213. * @param index defines the index to look for
  85214. * @returns the requested point if found
  85215. */
  85216. getAt(index: number): MultiLinePoint;
  85217. /** Function called when a point is updated */
  85218. onPointUpdate: () => void;
  85219. /**
  85220. * Adds new points to the point collection
  85221. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  85222. * @returns the list of created MultiLinePoint
  85223. */
  85224. add(...items: (AbstractMesh | Control | {
  85225. x: string | number;
  85226. y: string | number;
  85227. })[]): MultiLinePoint[];
  85228. /**
  85229. * Adds a new point to the point collection
  85230. * @param item defines the item (mesh, control or 2d coordiantes) to add
  85231. * @returns the created MultiLinePoint
  85232. */
  85233. push(item?: (AbstractMesh | Control | {
  85234. x: string | number;
  85235. y: string | number;
  85236. })): MultiLinePoint;
  85237. /**
  85238. * Remove a specific value or point from the active point collection
  85239. * @param value defines the value or point to remove
  85240. */
  85241. remove(value: number | MultiLinePoint): void;
  85242. /**
  85243. * Resets this object to initial state (no point)
  85244. */
  85245. reset(): void;
  85246. /**
  85247. * Resets all links
  85248. */
  85249. resetLinks(): void;
  85250. /** Gets or sets line width */
  85251. get lineWidth(): number;
  85252. set lineWidth(value: number);
  85253. set horizontalAlignment(value: number);
  85254. set verticalAlignment(value: number);
  85255. protected _getTypeName(): string;
  85256. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85257. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85258. _measure(): void;
  85259. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85260. dispose(): void;
  85261. }
  85262. }
  85263. declare module BABYLON.GUI {
  85264. /**
  85265. * Class used to create radio button controls
  85266. */
  85267. export class RadioButton extends Control {
  85268. name?: string | undefined;
  85269. private _isChecked;
  85270. private _background;
  85271. private _checkSizeRatio;
  85272. private _thickness;
  85273. /** Gets or sets border thickness */
  85274. get thickness(): number;
  85275. set thickness(value: number);
  85276. /** Gets or sets group name */
  85277. group: string;
  85278. /** BABYLON.Observable raised when isChecked is changed */
  85279. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  85280. /** Gets or sets a value indicating the ratio between overall size and check size */
  85281. get checkSizeRatio(): number;
  85282. set checkSizeRatio(value: number);
  85283. /** Gets or sets background color */
  85284. get background(): string;
  85285. set background(value: string);
  85286. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  85287. get isChecked(): boolean;
  85288. set isChecked(value: boolean);
  85289. /**
  85290. * Creates a new RadioButton
  85291. * @param name defines the control name
  85292. */
  85293. constructor(name?: string | undefined);
  85294. protected _getTypeName(): string;
  85295. _draw(context: CanvasRenderingContext2D): void;
  85296. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85297. /**
  85298. * Utility function to easily create a radio button with a header
  85299. * @param title defines the label to use for the header
  85300. * @param group defines the group to use for the radio button
  85301. * @param isChecked defines the initial state of the radio button
  85302. * @param onValueChanged defines the callback to call when value changes
  85303. * @returns a StackPanel containing the radio button and a textBlock
  85304. */
  85305. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  85306. }
  85307. }
  85308. declare module BABYLON.GUI {
  85309. /**
  85310. * Class used to create slider controls
  85311. */
  85312. export class BaseSlider extends Control {
  85313. name?: string | undefined;
  85314. protected _thumbWidth: ValueAndUnit;
  85315. private _minimum;
  85316. private _maximum;
  85317. private _value;
  85318. private _isVertical;
  85319. protected _barOffset: ValueAndUnit;
  85320. private _isThumbClamped;
  85321. protected _displayThumb: boolean;
  85322. private _step;
  85323. private _lastPointerDownID;
  85324. protected _effectiveBarOffset: number;
  85325. protected _renderLeft: number;
  85326. protected _renderTop: number;
  85327. protected _renderWidth: number;
  85328. protected _renderHeight: number;
  85329. protected _backgroundBoxLength: number;
  85330. protected _backgroundBoxThickness: number;
  85331. protected _effectiveThumbThickness: number;
  85332. /** BABYLON.Observable raised when the sldier value changes */
  85333. onValueChangedObservable: BABYLON.Observable<number>;
  85334. /** Gets or sets a boolean indicating if the thumb must be rendered */
  85335. get displayThumb(): boolean;
  85336. set displayThumb(value: boolean);
  85337. /** Gets or sets a step to apply to values (0 by default) */
  85338. get step(): number;
  85339. set step(value: number);
  85340. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  85341. get barOffset(): string | number;
  85342. /** Gets main bar offset in pixels*/
  85343. get barOffsetInPixels(): number;
  85344. set barOffset(value: string | number);
  85345. /** Gets or sets thumb width */
  85346. get thumbWidth(): string | number;
  85347. /** Gets thumb width in pixels */
  85348. get thumbWidthInPixels(): number;
  85349. set thumbWidth(value: string | number);
  85350. /** Gets or sets minimum value */
  85351. get minimum(): number;
  85352. set minimum(value: number);
  85353. /** Gets or sets maximum value */
  85354. get maximum(): number;
  85355. set maximum(value: number);
  85356. /** Gets or sets current value */
  85357. get value(): number;
  85358. set value(value: number);
  85359. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  85360. get isVertical(): boolean;
  85361. set isVertical(value: boolean);
  85362. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  85363. get isThumbClamped(): boolean;
  85364. set isThumbClamped(value: boolean);
  85365. /**
  85366. * Creates a new BaseSlider
  85367. * @param name defines the control name
  85368. */
  85369. constructor(name?: string | undefined);
  85370. protected _getTypeName(): string;
  85371. protected _getThumbPosition(): number;
  85372. protected _getThumbThickness(type: string): number;
  85373. protected _prepareRenderingData(type: string): void;
  85374. private _pointerIsDown;
  85375. /** @hidden */
  85376. protected _updateValueFromPointer(x: number, y: number): void;
  85377. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85378. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  85379. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  85380. _onCanvasBlur(): void;
  85381. }
  85382. }
  85383. declare module BABYLON.GUI {
  85384. /**
  85385. * Class used to create slider controls
  85386. */
  85387. export class Slider extends BaseSlider {
  85388. name?: string | undefined;
  85389. private _background;
  85390. private _borderColor;
  85391. private _thumbColor;
  85392. private _isThumbCircle;
  85393. protected _displayValueBar: boolean;
  85394. /** Gets or sets a boolean indicating if the value bar must be rendered */
  85395. get displayValueBar(): boolean;
  85396. set displayValueBar(value: boolean);
  85397. /** Gets or sets border color */
  85398. get borderColor(): string;
  85399. set borderColor(value: string);
  85400. /** Gets or sets background color */
  85401. get background(): string;
  85402. set background(value: string);
  85403. /** Gets or sets thumb's color */
  85404. get thumbColor(): string;
  85405. set thumbColor(value: string);
  85406. /** Gets or sets a boolean indicating if the thumb should be round or square */
  85407. get isThumbCircle(): boolean;
  85408. set isThumbCircle(value: boolean);
  85409. /**
  85410. * Creates a new Slider
  85411. * @param name defines the control name
  85412. */
  85413. constructor(name?: string | undefined);
  85414. protected _getTypeName(): string;
  85415. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85416. }
  85417. }
  85418. declare module BABYLON.GUI {
  85419. /** Class used to create a RadioGroup
  85420. * which contains groups of radio buttons
  85421. */
  85422. export class SelectorGroup {
  85423. /** name of SelectorGroup */
  85424. name: string;
  85425. private _groupPanel;
  85426. private _selectors;
  85427. private _groupHeader;
  85428. /**
  85429. * Creates a new SelectorGroup
  85430. * @param name of group, used as a group heading
  85431. */
  85432. constructor(
  85433. /** name of SelectorGroup */
  85434. name: string);
  85435. /** Gets the groupPanel of the SelectorGroup */
  85436. get groupPanel(): StackPanel;
  85437. /** Gets the selectors array */
  85438. get selectors(): StackPanel[];
  85439. /** Gets and sets the group header */
  85440. get header(): string;
  85441. set header(label: string);
  85442. /** @hidden */
  85443. private _addGroupHeader;
  85444. /** @hidden*/
  85445. _getSelector(selectorNb: number): StackPanel | undefined;
  85446. /** Removes the selector at the given position
  85447. * @param selectorNb the position of the selector within the group
  85448. */
  85449. removeSelector(selectorNb: number): void;
  85450. }
  85451. /** Class used to create a CheckboxGroup
  85452. * which contains groups of checkbox buttons
  85453. */
  85454. export class CheckboxGroup extends SelectorGroup {
  85455. /** Adds a checkbox as a control
  85456. * @param text is the label for the selector
  85457. * @param func is the function called when the Selector is checked
  85458. * @param checked is true when Selector is checked
  85459. */
  85460. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  85461. /** @hidden */
  85462. _setSelectorLabel(selectorNb: number, label: string): void;
  85463. /** @hidden */
  85464. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85465. /** @hidden */
  85466. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85467. /** @hidden */
  85468. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85469. }
  85470. /** Class used to create a RadioGroup
  85471. * which contains groups of radio buttons
  85472. */
  85473. export class RadioGroup extends SelectorGroup {
  85474. private _selectNb;
  85475. /** Adds a radio button as a control
  85476. * @param label is the label for the selector
  85477. * @param func is the function called when the Selector is checked
  85478. * @param checked is true when Selector is checked
  85479. */
  85480. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  85481. /** @hidden */
  85482. _setSelectorLabel(selectorNb: number, label: string): void;
  85483. /** @hidden */
  85484. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85485. /** @hidden */
  85486. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85487. /** @hidden */
  85488. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85489. }
  85490. /** Class used to create a SliderGroup
  85491. * which contains groups of slider buttons
  85492. */
  85493. export class SliderGroup extends SelectorGroup {
  85494. /**
  85495. * Adds a slider to the SelectorGroup
  85496. * @param label is the label for the SliderBar
  85497. * @param func is the function called when the Slider moves
  85498. * @param unit is a string describing the units used, eg degrees or metres
  85499. * @param min is the minimum value for the Slider
  85500. * @param max is the maximum value for the Slider
  85501. * @param value is the start value for the Slider between min and max
  85502. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  85503. */
  85504. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  85505. /** @hidden */
  85506. _setSelectorLabel(selectorNb: number, label: string): void;
  85507. /** @hidden */
  85508. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85509. /** @hidden */
  85510. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85511. /** @hidden */
  85512. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85513. }
  85514. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  85515. * @see https://doc.babylonjs.com/how_to/selector
  85516. */
  85517. export class SelectionPanel extends Rectangle {
  85518. /** name of SelectionPanel */
  85519. name: string;
  85520. /** an array of SelectionGroups */
  85521. groups: SelectorGroup[];
  85522. private _panel;
  85523. private _buttonColor;
  85524. private _buttonBackground;
  85525. private _headerColor;
  85526. private _barColor;
  85527. private _barHeight;
  85528. private _spacerHeight;
  85529. private _labelColor;
  85530. private _groups;
  85531. private _bars;
  85532. /**
  85533. * Creates a new SelectionPanel
  85534. * @param name of SelectionPanel
  85535. * @param groups is an array of SelectionGroups
  85536. */
  85537. constructor(
  85538. /** name of SelectionPanel */
  85539. name: string,
  85540. /** an array of SelectionGroups */
  85541. groups?: SelectorGroup[]);
  85542. protected _getTypeName(): string;
  85543. /** Gets the (stack) panel of the SelectionPanel */
  85544. get panel(): StackPanel;
  85545. /** Gets or sets the headerColor */
  85546. get headerColor(): string;
  85547. set headerColor(color: string);
  85548. private _setHeaderColor;
  85549. /** Gets or sets the button color */
  85550. get buttonColor(): string;
  85551. set buttonColor(color: string);
  85552. private _setbuttonColor;
  85553. /** Gets or sets the label color */
  85554. get labelColor(): string;
  85555. set labelColor(color: string);
  85556. private _setLabelColor;
  85557. /** Gets or sets the button background */
  85558. get buttonBackground(): string;
  85559. set buttonBackground(color: string);
  85560. private _setButtonBackground;
  85561. /** Gets or sets the color of separator bar */
  85562. get barColor(): string;
  85563. set barColor(color: string);
  85564. private _setBarColor;
  85565. /** Gets or sets the height of separator bar */
  85566. get barHeight(): string;
  85567. set barHeight(value: string);
  85568. private _setBarHeight;
  85569. /** Gets or sets the height of spacers*/
  85570. get spacerHeight(): string;
  85571. set spacerHeight(value: string);
  85572. private _setSpacerHeight;
  85573. /** Adds a bar between groups */
  85574. private _addSpacer;
  85575. /** Add a group to the selection panel
  85576. * @param group is the selector group to add
  85577. */
  85578. addGroup(group: SelectorGroup): void;
  85579. /** Remove the group from the given position
  85580. * @param groupNb is the position of the group in the list
  85581. */
  85582. removeGroup(groupNb: number): void;
  85583. /** Change a group header label
  85584. * @param label is the new group header label
  85585. * @param groupNb is the number of the group to relabel
  85586. * */
  85587. setHeaderName(label: string, groupNb: number): void;
  85588. /** Change selector label to the one given
  85589. * @param label is the new selector label
  85590. * @param groupNb is the number of the groupcontaining the selector
  85591. * @param selectorNb is the number of the selector within a group to relabel
  85592. * */
  85593. relabel(label: string, groupNb: number, selectorNb: number): void;
  85594. /** For a given group position remove the selector at the given position
  85595. * @param groupNb is the number of the group to remove the selector from
  85596. * @param selectorNb is the number of the selector within the group
  85597. */
  85598. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  85599. /** For a given group position of correct type add a checkbox button
  85600. * @param groupNb is the number of the group to remove the selector from
  85601. * @param label is the label for the selector
  85602. * @param func is the function called when the Selector is checked
  85603. * @param checked is true when Selector is checked
  85604. */
  85605. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  85606. /** For a given group position of correct type add a radio button
  85607. * @param groupNb is the number of the group to remove the selector from
  85608. * @param label is the label for the selector
  85609. * @param func is the function called when the Selector is checked
  85610. * @param checked is true when Selector is checked
  85611. */
  85612. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  85613. /**
  85614. * For a given slider group add a slider
  85615. * @param groupNb is the number of the group to add the slider to
  85616. * @param label is the label for the Slider
  85617. * @param func is the function called when the Slider moves
  85618. * @param unit is a string describing the units used, eg degrees or metres
  85619. * @param min is the minimum value for the Slider
  85620. * @param max is the maximum value for the Slider
  85621. * @param value is the start value for the Slider between min and max
  85622. * @param onVal is the function used to format the value displayed, eg radians to degrees
  85623. */
  85624. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  85625. }
  85626. }
  85627. declare module BABYLON.GUI {
  85628. /**
  85629. * Class used to hold a the container for ScrollViewer
  85630. * @hidden
  85631. */
  85632. export class _ScrollViewerWindow extends Container {
  85633. parentClientWidth: number;
  85634. parentClientHeight: number;
  85635. private _freezeControls;
  85636. private _parentMeasure;
  85637. private _oldLeft;
  85638. private _oldTop;
  85639. get freezeControls(): boolean;
  85640. set freezeControls(value: boolean);
  85641. private _bucketWidth;
  85642. private _bucketHeight;
  85643. private _buckets;
  85644. private _bucketLen;
  85645. get bucketWidth(): number;
  85646. get bucketHeight(): number;
  85647. setBucketSizes(width: number, height: number): void;
  85648. private _useBuckets;
  85649. private _makeBuckets;
  85650. private _dispatchInBuckets;
  85651. private _updateMeasures;
  85652. private _updateChildrenMeasures;
  85653. private _restoreMeasures;
  85654. /**
  85655. * Creates a new ScrollViewerWindow
  85656. * @param name of ScrollViewerWindow
  85657. */
  85658. constructor(name?: string);
  85659. protected _getTypeName(): string;
  85660. /** @hidden */
  85661. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85662. /** @hidden */
  85663. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  85664. private _scrollChildren;
  85665. private _scrollChildrenWithBuckets;
  85666. /** @hidden */
  85667. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  85668. protected _postMeasure(): void;
  85669. }
  85670. }
  85671. declare module BABYLON.GUI {
  85672. /**
  85673. * Class used to create slider controls
  85674. */
  85675. export class ScrollBar extends BaseSlider {
  85676. name?: string | undefined;
  85677. private _background;
  85678. private _borderColor;
  85679. private _tempMeasure;
  85680. /** Gets or sets border color */
  85681. get borderColor(): string;
  85682. set borderColor(value: string);
  85683. /** Gets or sets background color */
  85684. get background(): string;
  85685. set background(value: string);
  85686. /**
  85687. * Creates a new Slider
  85688. * @param name defines the control name
  85689. */
  85690. constructor(name?: string | undefined);
  85691. protected _getTypeName(): string;
  85692. protected _getThumbThickness(): number;
  85693. _draw(context: CanvasRenderingContext2D): void;
  85694. private _first;
  85695. private _originX;
  85696. private _originY;
  85697. /** @hidden */
  85698. protected _updateValueFromPointer(x: number, y: number): void;
  85699. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85700. }
  85701. }
  85702. declare module BABYLON.GUI {
  85703. /**
  85704. * Class used to create slider controls
  85705. */
  85706. export class ImageScrollBar extends BaseSlider {
  85707. name?: string | undefined;
  85708. private _backgroundBaseImage;
  85709. private _backgroundImage;
  85710. private _thumbImage;
  85711. private _thumbBaseImage;
  85712. private _thumbLength;
  85713. private _thumbHeight;
  85714. private _barImageHeight;
  85715. private _tempMeasure;
  85716. /** Number of 90° rotation to apply on the images when in vertical mode */
  85717. num90RotationInVerticalMode: number;
  85718. /**
  85719. * Gets or sets the image used to render the background for horizontal bar
  85720. */
  85721. get backgroundImage(): Image;
  85722. set backgroundImage(value: Image);
  85723. /**
  85724. * Gets or sets the image used to render the thumb
  85725. */
  85726. get thumbImage(): Image;
  85727. set thumbImage(value: Image);
  85728. /**
  85729. * Gets or sets the length of the thumb
  85730. */
  85731. get thumbLength(): number;
  85732. set thumbLength(value: number);
  85733. /**
  85734. * Gets or sets the height of the thumb
  85735. */
  85736. get thumbHeight(): number;
  85737. set thumbHeight(value: number);
  85738. /**
  85739. * Gets or sets the height of the bar image
  85740. */
  85741. get barImageHeight(): number;
  85742. set barImageHeight(value: number);
  85743. /**
  85744. * Creates a new ImageScrollBar
  85745. * @param name defines the control name
  85746. */
  85747. constructor(name?: string | undefined);
  85748. protected _getTypeName(): string;
  85749. protected _getThumbThickness(): number;
  85750. _draw(context: CanvasRenderingContext2D): void;
  85751. private _first;
  85752. private _originX;
  85753. private _originY;
  85754. /** @hidden */
  85755. protected _updateValueFromPointer(x: number, y: number): void;
  85756. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85757. }
  85758. }
  85759. declare module BABYLON.GUI {
  85760. /**
  85761. * Class used to hold a viewer window and sliders in a grid
  85762. */
  85763. export class ScrollViewer extends Rectangle {
  85764. private _grid;
  85765. private _horizontalBarSpace;
  85766. private _verticalBarSpace;
  85767. private _dragSpace;
  85768. private _horizontalBar;
  85769. private _verticalBar;
  85770. private _barColor;
  85771. private _barBackground;
  85772. private _barImage;
  85773. private _horizontalBarImage;
  85774. private _verticalBarImage;
  85775. private _barBackgroundImage;
  85776. private _horizontalBarBackgroundImage;
  85777. private _verticalBarBackgroundImage;
  85778. private _barSize;
  85779. private _window;
  85780. private _pointerIsOver;
  85781. private _wheelPrecision;
  85782. private _onWheelObserver;
  85783. private _clientWidth;
  85784. private _clientHeight;
  85785. private _useImageBar;
  85786. private _thumbLength;
  85787. private _thumbHeight;
  85788. private _barImageHeight;
  85789. private _horizontalBarImageHeight;
  85790. private _verticalBarImageHeight;
  85791. private _oldWindowContentsWidth;
  85792. private _oldWindowContentsHeight;
  85793. /**
  85794. * Gets the horizontal scrollbar
  85795. */
  85796. get horizontalBar(): ScrollBar | ImageScrollBar;
  85797. /**
  85798. * Gets the vertical scrollbar
  85799. */
  85800. get verticalBar(): ScrollBar | ImageScrollBar;
  85801. /**
  85802. * Adds a new control to the current container
  85803. * @param control defines the control to add
  85804. * @returns the current container
  85805. */
  85806. addControl(control: BABYLON.Nullable<Control>): Container;
  85807. /**
  85808. * Removes a control from the current container
  85809. * @param control defines the control to remove
  85810. * @returns the current container
  85811. */
  85812. removeControl(control: Control): Container;
  85813. /** Gets the list of children */
  85814. get children(): Control[];
  85815. _flagDescendantsAsMatrixDirty(): void;
  85816. /**
  85817. * Freezes or unfreezes the controls in the window.
  85818. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  85819. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  85820. */
  85821. get freezeControls(): boolean;
  85822. set freezeControls(value: boolean);
  85823. /** Gets the bucket width */
  85824. get bucketWidth(): number;
  85825. /** Gets the bucket height */
  85826. get bucketHeight(): number;
  85827. /**
  85828. * Sets the bucket sizes.
  85829. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  85830. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  85831. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  85832. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  85833. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  85834. * used), that's why it is not enabled by default.
  85835. * @param width width of the bucket
  85836. * @param height height of the bucket
  85837. */
  85838. setBucketSizes(width: number, height: number): void;
  85839. private _forceHorizontalBar;
  85840. private _forceVerticalBar;
  85841. /**
  85842. * Forces the horizontal scroll bar to be displayed
  85843. */
  85844. get forceHorizontalBar(): boolean;
  85845. set forceHorizontalBar(value: boolean);
  85846. /**
  85847. * Forces the vertical scroll bar to be displayed
  85848. */
  85849. get forceVerticalBar(): boolean;
  85850. set forceVerticalBar(value: boolean);
  85851. /**
  85852. * Creates a new ScrollViewer
  85853. * @param name of ScrollViewer
  85854. */
  85855. constructor(name?: string, isImageBased?: boolean);
  85856. /** Reset the scroll viewer window to initial size */
  85857. resetWindow(): void;
  85858. protected _getTypeName(): string;
  85859. private _buildClientSizes;
  85860. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85861. protected _postMeasure(): void;
  85862. /**
  85863. * Gets or sets the mouse wheel precision
  85864. * from 0 to 1 with a default value of 0.05
  85865. * */
  85866. get wheelPrecision(): number;
  85867. set wheelPrecision(value: number);
  85868. /** Gets or sets the scroll bar container background color */
  85869. get scrollBackground(): string;
  85870. set scrollBackground(color: string);
  85871. /** Gets or sets the bar color */
  85872. get barColor(): string;
  85873. set barColor(color: string);
  85874. /** Gets or sets the bar image */
  85875. get thumbImage(): Image;
  85876. set thumbImage(value: Image);
  85877. /** Gets or sets the horizontal bar image */
  85878. get horizontalThumbImage(): Image;
  85879. set horizontalThumbImage(value: Image);
  85880. /** Gets or sets the vertical bar image */
  85881. get verticalThumbImage(): Image;
  85882. set verticalThumbImage(value: Image);
  85883. /** Gets or sets the size of the bar */
  85884. get barSize(): number;
  85885. set barSize(value: number);
  85886. /** Gets or sets the length of the thumb */
  85887. get thumbLength(): number;
  85888. set thumbLength(value: number);
  85889. /** Gets or sets the height of the thumb */
  85890. get thumbHeight(): number;
  85891. set thumbHeight(value: number);
  85892. /** Gets or sets the height of the bar image */
  85893. get barImageHeight(): number;
  85894. set barImageHeight(value: number);
  85895. /** Gets or sets the height of the horizontal bar image */
  85896. get horizontalBarImageHeight(): number;
  85897. set horizontalBarImageHeight(value: number);
  85898. /** Gets or sets the height of the vertical bar image */
  85899. get verticalBarImageHeight(): number;
  85900. set verticalBarImageHeight(value: number);
  85901. /** Gets or sets the bar background */
  85902. get barBackground(): string;
  85903. set barBackground(color: string);
  85904. /** Gets or sets the bar background image */
  85905. get barImage(): Image;
  85906. set barImage(value: Image);
  85907. /** Gets or sets the horizontal bar background image */
  85908. get horizontalBarImage(): Image;
  85909. set horizontalBarImage(value: Image);
  85910. /** Gets or sets the vertical bar background image */
  85911. get verticalBarImage(): Image;
  85912. set verticalBarImage(value: Image);
  85913. private _setWindowPosition;
  85914. /** @hidden */
  85915. private _updateScroller;
  85916. _link(host: AdvancedDynamicTexture): void;
  85917. /** @hidden */
  85918. private _addBar;
  85919. /** @hidden */
  85920. private _attachWheel;
  85921. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  85922. /** Releases associated resources */
  85923. dispose(): void;
  85924. }
  85925. }
  85926. declare module BABYLON.GUI {
  85927. /**
  85928. * Class used to create toggle buttons
  85929. */
  85930. export class ToggleButton extends Rectangle {
  85931. name?: string | undefined;
  85932. /**
  85933. * Function called to generate the toActive animation
  85934. */
  85935. toActiveAnimation: () => void;
  85936. /**
  85937. * Function called to generate the toInactive animation
  85938. */
  85939. toInactiveAnimation: () => void;
  85940. /**
  85941. * Function called to generate a pointer enter animation when the toggle button is active.
  85942. */
  85943. pointerEnterActiveAnimation: () => void;
  85944. /**
  85945. * Function called to generate a pointer out animation when the toggle button is active.
  85946. */
  85947. pointerOutActiveAnimation: () => void;
  85948. /**
  85949. * Function called to generate a pointer down animation when the toggle button is active.
  85950. */
  85951. pointerDownActiveAnimation: () => void;
  85952. /**
  85953. * Function called to generate a pointer up animation when the toggle button is active.
  85954. */
  85955. pointerUpActiveAnimation: () => void;
  85956. /**
  85957. * Function called to generate a pointer enter animation when the toggle button is inactive.
  85958. */
  85959. pointerEnterInactiveAnimation: () => void;
  85960. /**
  85961. * Function called to generate a pointer out animation when the toggle button is inactive.
  85962. */
  85963. pointerOutInactiveAnimation: () => void;
  85964. /**
  85965. * Function called to generate a pointer down animation when the toggle button is inactive.
  85966. */
  85967. pointerDownInactiveAnimation: () => void;
  85968. /**
  85969. * Function called to generate a pointer up animation when the toggle button is inactive.
  85970. */
  85971. pointerUpInactiveAnimation: () => void;
  85972. /** BABYLON.Observable raised when isActive is changed */
  85973. onIsActiveChangedObservable: BABYLON.Observable<boolean>;
  85974. /**
  85975. * 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
  85976. */
  85977. delegatePickingToChildren: boolean;
  85978. private _image;
  85979. /**
  85980. * Returns the ToggleButton's image control if it exists
  85981. */
  85982. get image(): BABYLON.Nullable<Image>;
  85983. private _textBlock;
  85984. /**
  85985. * Returns the ToggleButton's child TextBlock control if it exists
  85986. */
  85987. get textBlock(): BABYLON.Nullable<TextBlock>;
  85988. private _group;
  85989. /** Gets or sets group name this toggle button belongs to */
  85990. get group(): string;
  85991. set group(value: string);
  85992. private _isActive;
  85993. /** Gets or sets a boolean indicating if the toogle button is active or not */
  85994. get isActive(): boolean;
  85995. set isActive(value: boolean);
  85996. /**
  85997. * Creates a new ToggleButton
  85998. * @param name defines the control name
  85999. * @param group defines the toggle group this toggle belongs to
  86000. */
  86001. constructor(name?: string | undefined, group?: string);
  86002. protected _getTypeName(): string;
  86003. /** @hidden */
  86004. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  86005. /** @hidden */
  86006. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  86007. /** @hidden */
  86008. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  86009. /** @hidden */
  86010. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  86011. /** @hidden */
  86012. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  86013. }
  86014. }
  86015. declare module BABYLON.GUI {
  86016. /** Class used to render a grid */
  86017. export class DisplayGrid extends Control {
  86018. name?: string | undefined;
  86019. private _cellWidth;
  86020. private _cellHeight;
  86021. private _minorLineTickness;
  86022. private _minorLineColor;
  86023. private _majorLineTickness;
  86024. private _majorLineColor;
  86025. private _majorLineFrequency;
  86026. private _background;
  86027. private _displayMajorLines;
  86028. private _displayMinorLines;
  86029. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  86030. get displayMinorLines(): boolean;
  86031. set displayMinorLines(value: boolean);
  86032. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  86033. get displayMajorLines(): boolean;
  86034. set displayMajorLines(value: boolean);
  86035. /** Gets or sets background color (Black by default) */
  86036. get background(): string;
  86037. set background(value: string);
  86038. /** Gets or sets the width of each cell (20 by default) */
  86039. get cellWidth(): number;
  86040. set cellWidth(value: number);
  86041. /** Gets or sets the height of each cell (20 by default) */
  86042. get cellHeight(): number;
  86043. set cellHeight(value: number);
  86044. /** Gets or sets the tickness of minor lines (1 by default) */
  86045. get minorLineTickness(): number;
  86046. set minorLineTickness(value: number);
  86047. /** Gets or sets the color of minor lines (DarkGray by default) */
  86048. get minorLineColor(): string;
  86049. set minorLineColor(value: string);
  86050. /** Gets or sets the tickness of major lines (2 by default) */
  86051. get majorLineTickness(): number;
  86052. set majorLineTickness(value: number);
  86053. /** Gets or sets the color of major lines (White by default) */
  86054. get majorLineColor(): string;
  86055. set majorLineColor(value: string);
  86056. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  86057. get majorLineFrequency(): number;
  86058. set majorLineFrequency(value: number);
  86059. /**
  86060. * Creates a new GridDisplayRectangle
  86061. * @param name defines the control name
  86062. */
  86063. constructor(name?: string | undefined);
  86064. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  86065. protected _getTypeName(): string;
  86066. }
  86067. }
  86068. declare module BABYLON.GUI {
  86069. /**
  86070. * Class used to create slider controls based on images
  86071. */
  86072. export class ImageBasedSlider extends BaseSlider {
  86073. name?: string | undefined;
  86074. private _backgroundImage;
  86075. private _thumbImage;
  86076. private _valueBarImage;
  86077. private _tempMeasure;
  86078. get displayThumb(): boolean;
  86079. set displayThumb(value: boolean);
  86080. /**
  86081. * Gets or sets the image used to render the background
  86082. */
  86083. get backgroundImage(): Image;
  86084. set backgroundImage(value: Image);
  86085. /**
  86086. * Gets or sets the image used to render the value bar
  86087. */
  86088. get valueBarImage(): Image;
  86089. set valueBarImage(value: Image);
  86090. /**
  86091. * Gets or sets the image used to render the thumb
  86092. */
  86093. get thumbImage(): Image;
  86094. set thumbImage(value: Image);
  86095. /**
  86096. * Creates a new ImageBasedSlider
  86097. * @param name defines the control name
  86098. */
  86099. constructor(name?: string | undefined);
  86100. protected _getTypeName(): string;
  86101. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  86102. }
  86103. }
  86104. declare module BABYLON.GUI {
  86105. /**
  86106. * Forcing an export so that this code will execute
  86107. * @hidden
  86108. */
  86109. const name = "Statics";
  86110. }
  86111. declare module BABYLON.GUI {
  86112. /**
  86113. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  86114. */
  86115. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  86116. /**
  86117. * Define the instrumented AdvancedDynamicTexture.
  86118. */
  86119. texture: AdvancedDynamicTexture;
  86120. private _captureRenderTime;
  86121. private _renderTime;
  86122. private _captureLayoutTime;
  86123. private _layoutTime;
  86124. private _onBeginRenderObserver;
  86125. private _onEndRenderObserver;
  86126. private _onBeginLayoutObserver;
  86127. private _onEndLayoutObserver;
  86128. /**
  86129. * Gets the perf counter used to capture render time
  86130. */
  86131. get renderTimeCounter(): BABYLON.PerfCounter;
  86132. /**
  86133. * Gets the perf counter used to capture layout time
  86134. */
  86135. get layoutTimeCounter(): BABYLON.PerfCounter;
  86136. /**
  86137. * Enable or disable the render time capture
  86138. */
  86139. get captureRenderTime(): boolean;
  86140. set captureRenderTime(value: boolean);
  86141. /**
  86142. * Enable or disable the layout time capture
  86143. */
  86144. get captureLayoutTime(): boolean;
  86145. set captureLayoutTime(value: boolean);
  86146. /**
  86147. * Instantiates a new advanced dynamic texture instrumentation.
  86148. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  86149. * @param texture Defines the AdvancedDynamicTexture to instrument
  86150. */
  86151. constructor(
  86152. /**
  86153. * Define the instrumented AdvancedDynamicTexture.
  86154. */
  86155. texture: AdvancedDynamicTexture);
  86156. /**
  86157. * Dispose and release associated resources.
  86158. */
  86159. dispose(): void;
  86160. }
  86161. }
  86162. declare module BABYLON.GUI {
  86163. /**
  86164. * Class used to load GUI via XML.
  86165. */
  86166. export class XmlLoader {
  86167. private _nodes;
  86168. private _nodeTypes;
  86169. private _isLoaded;
  86170. private _objectAttributes;
  86171. private _parentClass;
  86172. /**
  86173. * Create a new xml loader
  86174. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  86175. */
  86176. constructor(parentClass?: null);
  86177. private _getChainElement;
  86178. private _getClassAttribute;
  86179. private _createGuiElement;
  86180. private _parseGrid;
  86181. private _parseElement;
  86182. private _prepareSourceElement;
  86183. private _parseElementsFromSource;
  86184. private _parseXml;
  86185. /**
  86186. * Gets if the loading has finished.
  86187. * @returns whether the loading has finished or not
  86188. */
  86189. isLoaded(): boolean;
  86190. /**
  86191. * Gets a loaded node / control by id.
  86192. * @param id the Controls id set in the xml
  86193. * @returns element of type Control
  86194. */
  86195. getNodeById(id: string): any;
  86196. /**
  86197. * Gets all loaded nodes / controls
  86198. * @returns Array of controls
  86199. */
  86200. getNodes(): any;
  86201. /**
  86202. * Initiates the xml layout loading
  86203. * @param xmlFile defines the xml layout to load
  86204. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  86205. * @param callback defines the callback called on layout load.
  86206. */
  86207. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  86208. }
  86209. }
  86210. declare module BABYLON.GUI {
  86211. /**
  86212. * Class used to create containers for controls
  86213. */
  86214. export class Container3D extends Control3D {
  86215. private _blockLayout;
  86216. /**
  86217. * Gets the list of child controls
  86218. */
  86219. protected _children: Control3D[];
  86220. /**
  86221. * Gets the list of child controls
  86222. */
  86223. get children(): Array<Control3D>;
  86224. /**
  86225. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  86226. * This is helpful to optimize layout operation when adding multiple children in a row
  86227. */
  86228. get blockLayout(): boolean;
  86229. set blockLayout(value: boolean);
  86230. /**
  86231. * Creates a new container
  86232. * @param name defines the container name
  86233. */
  86234. constructor(name?: string);
  86235. /**
  86236. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  86237. * @returns the current container
  86238. */
  86239. updateLayout(): Container3D;
  86240. /**
  86241. * Gets a boolean indicating if the given control is in the children of this control
  86242. * @param control defines the control to check
  86243. * @returns true if the control is in the child list
  86244. */
  86245. containsControl(control: Control3D): boolean;
  86246. /**
  86247. * Adds a control to the children of this control
  86248. * @param control defines the control to add
  86249. * @returns the current container
  86250. */
  86251. addControl(control: Control3D): Container3D;
  86252. /**
  86253. * This function will be called everytime a new control is added
  86254. */
  86255. protected _arrangeChildren(): void;
  86256. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  86257. /**
  86258. * Removes a control from the children of this control
  86259. * @param control defines the control to remove
  86260. * @returns the current container
  86261. */
  86262. removeControl(control: Control3D): Container3D;
  86263. protected _getTypeName(): string;
  86264. /**
  86265. * Releases all associated resources
  86266. */
  86267. dispose(): void;
  86268. /** Control rotation will remain unchanged */
  86269. static readonly UNSET_ORIENTATION: number;
  86270. /** Control will rotate to make it look at sphere central axis */
  86271. static readonly FACEORIGIN_ORIENTATION: number;
  86272. /** Control will rotate to make it look back at sphere central axis */
  86273. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  86274. /** Control will rotate to look at z axis (0, 0, 1) */
  86275. static readonly FACEFORWARD_ORIENTATION: number;
  86276. /** Control will rotate to look at negative z axis (0, 0, -1) */
  86277. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  86278. }
  86279. }
  86280. declare module BABYLON.GUI {
  86281. /**
  86282. * Class used to manage 3D user interface
  86283. * @see https://doc.babylonjs.com/how_to/gui3d
  86284. */
  86285. export class GUI3DManager implements BABYLON.IDisposable {
  86286. private _scene;
  86287. private _sceneDisposeObserver;
  86288. private _utilityLayer;
  86289. private _rootContainer;
  86290. private _pointerObserver;
  86291. private _pointerOutObserver;
  86292. /** @hidden */
  86293. _lastPickedControl: Control3D;
  86294. /** @hidden */
  86295. _lastControlOver: {
  86296. [pointerId: number]: Control3D;
  86297. };
  86298. /** @hidden */
  86299. _lastControlDown: {
  86300. [pointerId: number]: Control3D;
  86301. };
  86302. /**
  86303. * BABYLON.Observable raised when the point picked by the pointer events changed
  86304. */
  86305. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  86306. /** @hidden */
  86307. _sharedMaterials: {
  86308. [key: string]: BABYLON.Material;
  86309. };
  86310. /** Gets the hosting scene */
  86311. get scene(): BABYLON.Scene;
  86312. /** Gets associated utility layer */
  86313. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  86314. /**
  86315. * Creates a new GUI3DManager
  86316. * @param scene
  86317. */
  86318. constructor(scene?: BABYLON.Scene);
  86319. private _handlePointerOut;
  86320. private _doPicking;
  86321. /**
  86322. * Gets the root container
  86323. */
  86324. get rootContainer(): Container3D;
  86325. /**
  86326. * Gets a boolean indicating if the given control is in the root child list
  86327. * @param control defines the control to check
  86328. * @returns true if the control is in the root child list
  86329. */
  86330. containsControl(control: Control3D): boolean;
  86331. /**
  86332. * Adds a control to the root child list
  86333. * @param control defines the control to add
  86334. * @returns the current manager
  86335. */
  86336. addControl(control: Control3D): GUI3DManager;
  86337. /**
  86338. * Removes a control from the root child list
  86339. * @param control defines the control to remove
  86340. * @returns the current container
  86341. */
  86342. removeControl(control: Control3D): GUI3DManager;
  86343. /**
  86344. * Releases all associated resources
  86345. */
  86346. dispose(): void;
  86347. }
  86348. }
  86349. declare module BABYLON.GUI {
  86350. /**
  86351. * Class used to transport BABYLON.Vector3 information for pointer events
  86352. */
  86353. export class Vector3WithInfo extends BABYLON.Vector3 {
  86354. /** defines the current mouse button index */
  86355. buttonIndex: number;
  86356. /**
  86357. * Creates a new Vector3WithInfo
  86358. * @param source defines the vector3 data to transport
  86359. * @param buttonIndex defines the current mouse button index
  86360. */
  86361. constructor(source: BABYLON.Vector3,
  86362. /** defines the current mouse button index */
  86363. buttonIndex?: number);
  86364. }
  86365. }
  86366. declare module BABYLON.GUI {
  86367. /**
  86368. * Class used as base class for controls
  86369. */
  86370. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  86371. /** Defines the control name */
  86372. name?: string | undefined;
  86373. /** @hidden */
  86374. _host: GUI3DManager;
  86375. private _node;
  86376. private _downCount;
  86377. private _enterCount;
  86378. private _downPointerIds;
  86379. private _isVisible;
  86380. /** Gets or sets the control position in world space */
  86381. get position(): BABYLON.Vector3;
  86382. set position(value: BABYLON.Vector3);
  86383. /** Gets or sets the control scaling in world space */
  86384. get scaling(): BABYLON.Vector3;
  86385. set scaling(value: BABYLON.Vector3);
  86386. /** Callback used to start pointer enter animation */
  86387. pointerEnterAnimation: () => void;
  86388. /** Callback used to start pointer out animation */
  86389. pointerOutAnimation: () => void;
  86390. /** Callback used to start pointer down animation */
  86391. pointerDownAnimation: () => void;
  86392. /** Callback used to start pointer up animation */
  86393. pointerUpAnimation: () => void;
  86394. /**
  86395. * An event triggered when the pointer move over the control
  86396. */
  86397. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  86398. /**
  86399. * An event triggered when the pointer move out of the control
  86400. */
  86401. onPointerOutObservable: BABYLON.Observable<Control3D>;
  86402. /**
  86403. * An event triggered when the pointer taps the control
  86404. */
  86405. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  86406. /**
  86407. * An event triggered when pointer is up
  86408. */
  86409. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  86410. /**
  86411. * An event triggered when a control is clicked on (with a mouse)
  86412. */
  86413. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  86414. /**
  86415. * An event triggered when pointer enters the control
  86416. */
  86417. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  86418. /**
  86419. * Gets or sets the parent container
  86420. */
  86421. parent: BABYLON.Nullable<Container3D>;
  86422. private _behaviors;
  86423. /**
  86424. * Gets the list of attached behaviors
  86425. * @see https://doc.babylonjs.com/features/behaviour
  86426. */
  86427. get behaviors(): BABYLON.Behavior<Control3D>[];
  86428. /**
  86429. * Attach a behavior to the control
  86430. * @see https://doc.babylonjs.com/features/behaviour
  86431. * @param behavior defines the behavior to attach
  86432. * @returns the current control
  86433. */
  86434. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  86435. /**
  86436. * Remove an attached behavior
  86437. * @see https://doc.babylonjs.com/features/behaviour
  86438. * @param behavior defines the behavior to attach
  86439. * @returns the current control
  86440. */
  86441. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  86442. /**
  86443. * Gets an attached behavior by name
  86444. * @param name defines the name of the behavior to look for
  86445. * @see https://doc.babylonjs.com/features/behaviour
  86446. * @returns null if behavior was not found else the requested behavior
  86447. */
  86448. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  86449. /** Gets or sets a boolean indicating if the control is visible */
  86450. get isVisible(): boolean;
  86451. set isVisible(value: boolean);
  86452. /**
  86453. * Creates a new control
  86454. * @param name defines the control name
  86455. */
  86456. constructor(
  86457. /** Defines the control name */
  86458. name?: string | undefined);
  86459. /**
  86460. * Gets a string representing the class name
  86461. */
  86462. get typeName(): string;
  86463. /**
  86464. * Get the current class name of the control.
  86465. * @returns current class name
  86466. */
  86467. getClassName(): string;
  86468. protected _getTypeName(): string;
  86469. /**
  86470. * Gets the transform node used by this control
  86471. */
  86472. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  86473. /**
  86474. * Gets the mesh used to render this control
  86475. */
  86476. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  86477. /**
  86478. * Link the control as child of the given node
  86479. * @param node defines the node to link to. Use null to unlink the control
  86480. * @returns the current control
  86481. */
  86482. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  86483. /** @hidden **/
  86484. _prepareNode(scene: BABYLON.Scene): void;
  86485. protected _injectGUI3DMetadata(node: BABYLON.TransformNode): any;
  86486. /**
  86487. * Node creation.
  86488. * Can be overriden by children
  86489. * @param scene defines the scene where the node must be attached
  86490. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  86491. */
  86492. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  86493. /**
  86494. * Affect a material to the given mesh
  86495. * @param mesh defines the mesh which will represent the control
  86496. */
  86497. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86498. /** @hidden */
  86499. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  86500. /** @hidden */
  86501. _onPointerEnter(target: Control3D): boolean;
  86502. /** @hidden */
  86503. _onPointerOut(target: Control3D): void;
  86504. /** @hidden */
  86505. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  86506. /** @hidden */
  86507. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  86508. /** @hidden */
  86509. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  86510. /** @hidden */
  86511. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  86512. /** @hidden */
  86513. _disposeNode(): void;
  86514. /**
  86515. * Releases all associated resources
  86516. */
  86517. dispose(): void;
  86518. }
  86519. }
  86520. declare module BABYLON.GUI {
  86521. /**
  86522. * Class used as a root to all buttons
  86523. */
  86524. export class AbstractButton3D extends Control3D {
  86525. /**
  86526. * Creates a new button
  86527. * @param name defines the control name
  86528. */
  86529. constructor(name?: string);
  86530. protected _getTypeName(): string;
  86531. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86532. }
  86533. }
  86534. declare module BABYLON.GUI {
  86535. /**
  86536. * Class used to create a button in 3D
  86537. */
  86538. export class Button3D extends AbstractButton3D {
  86539. /** @hidden */
  86540. protected _currentMaterial: BABYLON.Material;
  86541. private _facadeTexture;
  86542. private _content;
  86543. private _contentResolution;
  86544. private _contentScaleRatio;
  86545. /**
  86546. * Gets or sets the texture resolution used to render content (512 by default)
  86547. */
  86548. get contentResolution(): BABYLON.int;
  86549. set contentResolution(value: BABYLON.int);
  86550. /**
  86551. * Gets or sets the texture scale ratio used to render content (2 by default)
  86552. */
  86553. get contentScaleRatio(): number;
  86554. set contentScaleRatio(value: number);
  86555. protected _disposeFacadeTexture(): void;
  86556. protected _resetContent(): void;
  86557. /**
  86558. * Creates a new button
  86559. * @param name defines the control name
  86560. */
  86561. constructor(name?: string);
  86562. /**
  86563. * Gets or sets the GUI 2D content used to display the button's facade
  86564. */
  86565. get content(): Control;
  86566. set content(value: Control);
  86567. /**
  86568. * Apply the facade texture (created from the content property).
  86569. * This function can be overloaded by child classes
  86570. * @param facadeTexture defines the AdvancedDynamicTexture to use
  86571. */
  86572. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  86573. protected _getTypeName(): string;
  86574. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86575. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86576. /**
  86577. * Releases all associated resources
  86578. */
  86579. dispose(): void;
  86580. }
  86581. }
  86582. declare module BABYLON.GUI {
  86583. /**
  86584. * Abstract class used to create a container panel deployed on the surface of a volume
  86585. */
  86586. export abstract class VolumeBasedPanel extends Container3D {
  86587. private _columns;
  86588. private _rows;
  86589. private _rowThenColum;
  86590. private _orientation;
  86591. protected _cellWidth: number;
  86592. protected _cellHeight: number;
  86593. /**
  86594. * Gets or sets the distance between elements
  86595. */
  86596. margin: number;
  86597. /**
  86598. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  86599. * | Value | Type | Description |
  86600. * | ----- | ----------------------------------- | ----------- |
  86601. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  86602. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  86603. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  86604. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  86605. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  86606. */
  86607. get orientation(): number;
  86608. set orientation(value: number);
  86609. /**
  86610. * Gets or sets the number of columns requested (10 by default).
  86611. * The panel will automatically compute the number of rows based on number of child controls.
  86612. */
  86613. get columns(): BABYLON.int;
  86614. set columns(value: BABYLON.int);
  86615. /**
  86616. * Gets or sets a the number of rows requested.
  86617. * The panel will automatically compute the number of columns based on number of child controls.
  86618. */
  86619. get rows(): BABYLON.int;
  86620. set rows(value: BABYLON.int);
  86621. /**
  86622. * Creates new VolumeBasedPanel
  86623. */
  86624. constructor();
  86625. protected _arrangeChildren(): void;
  86626. /** Child classes must implement this function to provide correct control positioning */
  86627. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86628. /** Child classes can implement this function to provide additional processing */
  86629. protected _finalProcessing(): void;
  86630. }
  86631. }
  86632. declare module BABYLON.GUI {
  86633. /**
  86634. * Class used to create a container panel deployed on the surface of a cylinder
  86635. */
  86636. export class CylinderPanel extends VolumeBasedPanel {
  86637. private _radius;
  86638. /**
  86639. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  86640. */
  86641. get radius(): BABYLON.float;
  86642. set radius(value: BABYLON.float);
  86643. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86644. private _cylindricalMapping;
  86645. }
  86646. }
  86647. declare module BABYLON.GUI {
  86648. /** @hidden */
  86649. export var fluentVertexShader: {
  86650. name: string;
  86651. shader: string;
  86652. };
  86653. }
  86654. declare module BABYLON.GUI {
  86655. /** @hidden */
  86656. export var fluentPixelShader: {
  86657. name: string;
  86658. shader: string;
  86659. };
  86660. }
  86661. declare module BABYLON.GUI {
  86662. /** @hidden */
  86663. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  86664. INNERGLOW: boolean;
  86665. BORDER: boolean;
  86666. HOVERLIGHT: boolean;
  86667. TEXTURE: boolean;
  86668. constructor();
  86669. }
  86670. /**
  86671. * Class used to render controls with fluent desgin
  86672. */
  86673. export class FluentMaterial extends BABYLON.PushMaterial {
  86674. /**
  86675. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  86676. */
  86677. innerGlowColorIntensity: number;
  86678. /**
  86679. * Gets or sets the inner glow color (white by default)
  86680. */
  86681. innerGlowColor: BABYLON.Color3;
  86682. /**
  86683. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  86684. */
  86685. albedoColor: BABYLON.Color3;
  86686. /**
  86687. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  86688. */
  86689. renderBorders: boolean;
  86690. /**
  86691. * Gets or sets border width (default is 0.5)
  86692. */
  86693. borderWidth: number;
  86694. /**
  86695. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  86696. */
  86697. edgeSmoothingValue: number;
  86698. /**
  86699. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  86700. */
  86701. borderMinValue: number;
  86702. /**
  86703. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  86704. */
  86705. renderHoverLight: boolean;
  86706. /**
  86707. * Gets or sets the radius used to render the hover light (default is 1.0)
  86708. */
  86709. hoverRadius: number;
  86710. /**
  86711. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  86712. */
  86713. hoverColor: BABYLON.Color4;
  86714. /**
  86715. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  86716. */
  86717. hoverPosition: BABYLON.Vector3;
  86718. private _albedoTexture;
  86719. /** Gets or sets the texture to use for albedo color */
  86720. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86721. /**
  86722. * Creates a new Fluent material
  86723. * @param name defines the name of the material
  86724. * @param scene defines the hosting scene
  86725. */
  86726. constructor(name: string, scene: BABYLON.Scene);
  86727. needAlphaBlending(): boolean;
  86728. needAlphaTesting(): boolean;
  86729. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86730. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86731. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86732. getActiveTextures(): BABYLON.BaseTexture[];
  86733. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86734. dispose(forceDisposeEffect?: boolean): void;
  86735. clone(name: string): FluentMaterial;
  86736. serialize(): any;
  86737. getClassName(): string;
  86738. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  86739. }
  86740. }
  86741. declare module BABYLON.GUI {
  86742. /**
  86743. * Class used to create a holographic button in 3D
  86744. */
  86745. export class HolographicButton extends Button3D {
  86746. private _backPlate;
  86747. private _textPlate;
  86748. private _frontPlate;
  86749. private _text;
  86750. private _imageUrl;
  86751. private _shareMaterials;
  86752. private _frontMaterial;
  86753. private _backMaterial;
  86754. private _plateMaterial;
  86755. private _pickedPointObserver;
  86756. private _tooltipFade;
  86757. private _tooltipTextBlock;
  86758. private _tooltipTexture;
  86759. private _tooltipMesh;
  86760. private _tooltipHoverObserver;
  86761. private _tooltipOutObserver;
  86762. private _disposeTooltip;
  86763. /**
  86764. * Rendering ground id of all the mesh in the button
  86765. */
  86766. set renderingGroupId(id: number);
  86767. get renderingGroupId(): number;
  86768. /**
  86769. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  86770. */
  86771. set tooltipText(text: BABYLON.Nullable<string>);
  86772. get tooltipText(): BABYLON.Nullable<string>;
  86773. /**
  86774. * Gets or sets text for the button
  86775. */
  86776. get text(): string;
  86777. set text(value: string);
  86778. /**
  86779. * Gets or sets the image url for the button
  86780. */
  86781. get imageUrl(): string;
  86782. set imageUrl(value: string);
  86783. /**
  86784. * Gets the back material used by this button
  86785. */
  86786. get backMaterial(): FluentMaterial;
  86787. /**
  86788. * Gets the front material used by this button
  86789. */
  86790. get frontMaterial(): FluentMaterial;
  86791. /**
  86792. * Gets the plate material used by this button
  86793. */
  86794. get plateMaterial(): BABYLON.StandardMaterial;
  86795. /**
  86796. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  86797. */
  86798. get shareMaterials(): boolean;
  86799. /**
  86800. * Creates a new button
  86801. * @param name defines the control name
  86802. */
  86803. constructor(name?: string, shareMaterials?: boolean);
  86804. protected _getTypeName(): string;
  86805. private _rebuildContent;
  86806. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86807. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  86808. private _createBackMaterial;
  86809. private _createFrontMaterial;
  86810. private _createPlateMaterial;
  86811. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  86812. /**
  86813. * Releases all associated resources
  86814. */
  86815. dispose(): void;
  86816. }
  86817. }
  86818. declare module BABYLON.GUI {
  86819. /**
  86820. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  86821. */
  86822. export class MeshButton3D extends Button3D {
  86823. /** @hidden */
  86824. protected _currentMesh: BABYLON.Mesh;
  86825. /**
  86826. * Creates a new 3D button based on a mesh
  86827. * @param mesh mesh to become a 3D button
  86828. * @param name defines the control name
  86829. */
  86830. constructor(mesh: BABYLON.Mesh, name?: string);
  86831. protected _getTypeName(): string;
  86832. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86833. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86834. }
  86835. }
  86836. declare module BABYLON.GUI {
  86837. /**
  86838. * Class used to create a container panel deployed on the surface of a plane
  86839. */
  86840. export class PlanePanel extends VolumeBasedPanel {
  86841. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86842. }
  86843. }
  86844. declare module BABYLON.GUI {
  86845. /**
  86846. * Class used to create a container panel where items get randomized planar mapping
  86847. */
  86848. export class ScatterPanel extends VolumeBasedPanel {
  86849. private _iteration;
  86850. /**
  86851. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  86852. */
  86853. get iteration(): BABYLON.float;
  86854. set iteration(value: BABYLON.float);
  86855. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86856. private _scatterMapping;
  86857. protected _finalProcessing(): void;
  86858. }
  86859. }
  86860. declare module BABYLON.GUI {
  86861. /**
  86862. * Class used to create a container panel deployed on the surface of a sphere
  86863. */
  86864. export class SpherePanel extends VolumeBasedPanel {
  86865. private _radius;
  86866. /**
  86867. * Gets or sets the radius of the sphere where to project controls (5 by default)
  86868. */
  86869. get radius(): BABYLON.float;
  86870. set radius(value: BABYLON.float);
  86871. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86872. private _sphericalMapping;
  86873. }
  86874. }
  86875. declare module BABYLON.GUI {
  86876. /**
  86877. * Class used to create a stack panel in 3D on XY plane
  86878. */
  86879. export class StackPanel3D extends Container3D {
  86880. private _isVertical;
  86881. /**
  86882. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  86883. */
  86884. get isVertical(): boolean;
  86885. set isVertical(value: boolean);
  86886. /**
  86887. * Gets or sets the distance between elements
  86888. */
  86889. margin: number;
  86890. /**
  86891. * Creates new StackPanel
  86892. * @param isVertical
  86893. */
  86894. constructor(isVertical?: boolean);
  86895. protected _arrangeChildren(): void;
  86896. }
  86897. }
  86898. declare module BABYLON {
  86899. /**
  86900. * Configuration for glTF validation
  86901. */
  86902. export interface IGLTFValidationConfiguration {
  86903. /**
  86904. * The url of the glTF validator.
  86905. */
  86906. url: string;
  86907. }
  86908. /**
  86909. * glTF validation
  86910. */
  86911. export class GLTFValidation {
  86912. /**
  86913. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  86914. */
  86915. static Configuration: IGLTFValidationConfiguration;
  86916. private static _LoadScriptPromise;
  86917. /**
  86918. * Validate a glTF asset using the glTF-Validator.
  86919. * @param data The JSON of a glTF or the array buffer of a binary glTF
  86920. * @param rootUrl The root url for the glTF
  86921. * @param fileName The file name for the glTF
  86922. * @param getExternalResource The callback to get external resources for the glTF validator
  86923. * @returns A promise that resolves with the glTF validation results once complete
  86924. */
  86925. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  86926. }
  86927. }
  86928. declare module BABYLON {
  86929. /**
  86930. * Mode that determines the coordinate system to use.
  86931. */
  86932. export enum GLTFLoaderCoordinateSystemMode {
  86933. /**
  86934. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  86935. */
  86936. AUTO = 0,
  86937. /**
  86938. * Sets the useRightHandedSystem flag on the scene.
  86939. */
  86940. FORCE_RIGHT_HANDED = 1
  86941. }
  86942. /**
  86943. * Mode that determines what animations will start.
  86944. */
  86945. export enum GLTFLoaderAnimationStartMode {
  86946. /**
  86947. * No animation will start.
  86948. */
  86949. NONE = 0,
  86950. /**
  86951. * The first animation will start.
  86952. */
  86953. FIRST = 1,
  86954. /**
  86955. * All animations will start.
  86956. */
  86957. ALL = 2
  86958. }
  86959. /**
  86960. * Interface that contains the data for the glTF asset.
  86961. */
  86962. export interface IGLTFLoaderData {
  86963. /**
  86964. * The object that represents the glTF JSON.
  86965. */
  86966. json: Object;
  86967. /**
  86968. * The BIN chunk of a binary glTF.
  86969. */
  86970. bin: Nullable<IDataBuffer>;
  86971. }
  86972. /**
  86973. * Interface for extending the loader.
  86974. */
  86975. export interface IGLTFLoaderExtension {
  86976. /**
  86977. * The name of this extension.
  86978. */
  86979. readonly name: string;
  86980. /**
  86981. * Defines whether this extension is enabled.
  86982. */
  86983. enabled: boolean;
  86984. /**
  86985. * Defines the order of this extension.
  86986. * The loader sorts the extensions using these values when loading.
  86987. */
  86988. order?: number;
  86989. }
  86990. /**
  86991. * Loader state.
  86992. */
  86993. export enum GLTFLoaderState {
  86994. /**
  86995. * The asset is loading.
  86996. */
  86997. LOADING = 0,
  86998. /**
  86999. * The asset is ready for rendering.
  87000. */
  87001. READY = 1,
  87002. /**
  87003. * The asset is completely loaded.
  87004. */
  87005. COMPLETE = 2
  87006. }
  87007. /** @hidden */
  87008. export interface IGLTFLoader extends IDisposable {
  87009. readonly state: Nullable<GLTFLoaderState>;
  87010. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<ISceneLoaderAsyncResult>;
  87011. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  87012. }
  87013. /**
  87014. * File loader for loading glTF files into a scene.
  87015. */
  87016. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  87017. /** @hidden */
  87018. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  87019. /** @hidden */
  87020. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  87021. /**
  87022. * Raised when the asset has been parsed
  87023. */
  87024. onParsedObservable: Observable<IGLTFLoaderData>;
  87025. private _onParsedObserver;
  87026. /**
  87027. * Raised when the asset has been parsed
  87028. */
  87029. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  87030. /**
  87031. * 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.
  87032. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  87033. * Defaults to true.
  87034. * @hidden
  87035. */
  87036. static IncrementalLoading: boolean;
  87037. /**
  87038. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  87039. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  87040. * @hidden
  87041. */
  87042. static HomogeneousCoordinates: boolean;
  87043. /**
  87044. * The coordinate system mode. Defaults to AUTO.
  87045. */
  87046. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  87047. /**
  87048. * The animation start mode. Defaults to FIRST.
  87049. */
  87050. animationStartMode: GLTFLoaderAnimationStartMode;
  87051. /**
  87052. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  87053. */
  87054. compileMaterials: boolean;
  87055. /**
  87056. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  87057. */
  87058. useClipPlane: boolean;
  87059. /**
  87060. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  87061. */
  87062. compileShadowGenerators: boolean;
  87063. /**
  87064. * Defines if the Alpha blended materials are only applied as coverage.
  87065. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  87066. * If true, no extra effects are applied to transparent pixels.
  87067. */
  87068. transparencyAsCoverage: boolean;
  87069. /**
  87070. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  87071. * Enabling will disable offline support and glTF validator.
  87072. * Defaults to false.
  87073. */
  87074. useRangeRequests: boolean;
  87075. /**
  87076. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  87077. */
  87078. createInstances: boolean;
  87079. /**
  87080. * 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.
  87081. */
  87082. alwaysComputeBoundingBox: boolean;
  87083. /**
  87084. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  87085. */
  87086. loadAllMaterials: boolean;
  87087. /**
  87088. * Function called before loading a url referenced by the asset.
  87089. */
  87090. preprocessUrlAsync: (url: string) => Promise<string>;
  87091. /**
  87092. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  87093. * 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, ...)
  87094. */
  87095. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  87096. private _onMeshLoadedObserver;
  87097. /**
  87098. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  87099. * 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, ...)
  87100. */
  87101. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  87102. /**
  87103. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  87104. */
  87105. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  87106. private _onTextureLoadedObserver;
  87107. /**
  87108. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  87109. */
  87110. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  87111. /**
  87112. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  87113. */
  87114. readonly onMaterialLoadedObservable: Observable<Material>;
  87115. private _onMaterialLoadedObserver;
  87116. /**
  87117. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  87118. */
  87119. set onMaterialLoaded(callback: (material: Material) => void);
  87120. /**
  87121. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  87122. */
  87123. readonly onCameraLoadedObservable: Observable<Camera>;
  87124. private _onCameraLoadedObserver;
  87125. /**
  87126. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  87127. */
  87128. set onCameraLoaded(callback: (camera: Camera) => void);
  87129. /**
  87130. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  87131. * For assets with LODs, raised when all of the LODs are complete.
  87132. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  87133. */
  87134. readonly onCompleteObservable: Observable<void>;
  87135. private _onCompleteObserver;
  87136. /**
  87137. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  87138. * For assets with LODs, raised when all of the LODs are complete.
  87139. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  87140. */
  87141. set onComplete(callback: () => void);
  87142. /**
  87143. * Observable raised when an error occurs.
  87144. */
  87145. readonly onErrorObservable: Observable<any>;
  87146. private _onErrorObserver;
  87147. /**
  87148. * Callback raised when an error occurs.
  87149. */
  87150. set onError(callback: (reason: any) => void);
  87151. /**
  87152. * Observable raised after the loader is disposed.
  87153. */
  87154. readonly onDisposeObservable: Observable<void>;
  87155. private _onDisposeObserver;
  87156. /**
  87157. * Callback raised after the loader is disposed.
  87158. */
  87159. set onDispose(callback: () => void);
  87160. /**
  87161. * Observable raised after a loader extension is created.
  87162. * Set additional options for a loader extension in this event.
  87163. */
  87164. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  87165. private _onExtensionLoadedObserver;
  87166. /**
  87167. * Callback raised after a loader extension is created.
  87168. */
  87169. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  87170. /**
  87171. * Defines if the loader logging is enabled.
  87172. */
  87173. get loggingEnabled(): boolean;
  87174. set loggingEnabled(value: boolean);
  87175. /**
  87176. * Defines if the loader should capture performance counters.
  87177. */
  87178. get capturePerformanceCounters(): boolean;
  87179. set capturePerformanceCounters(value: boolean);
  87180. /**
  87181. * Defines if the loader should validate the asset.
  87182. */
  87183. validate: boolean;
  87184. /**
  87185. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  87186. */
  87187. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  87188. private _onValidatedObserver;
  87189. /**
  87190. * Callback raised after a loader extension is created.
  87191. */
  87192. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  87193. private _loader;
  87194. private _progressCallback?;
  87195. private _requests;
  87196. private static magicBase64Encoded;
  87197. /**
  87198. * Name of the loader ("gltf")
  87199. */
  87200. name: string;
  87201. /** @hidden */
  87202. extensions: ISceneLoaderPluginExtensions;
  87203. /**
  87204. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  87205. */
  87206. dispose(): void;
  87207. /** @hidden */
  87208. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  87209. /** @hidden */
  87210. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  87211. /** @hidden */
  87212. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  87213. /** @hidden */
  87214. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  87215. /** @hidden */
  87216. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  87217. /** @hidden */
  87218. canDirectLoad(data: string): boolean;
  87219. /** @hidden */
  87220. directLoad(scene: Scene, data: string): Promise<any>;
  87221. /**
  87222. * The callback that allows custom handling of the root url based on the response url.
  87223. * @param rootUrl the original root url
  87224. * @param responseURL the response url if available
  87225. * @returns the new root url
  87226. */
  87227. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  87228. /** @hidden */
  87229. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  87230. /**
  87231. * The loader state or null if the loader is not active.
  87232. */
  87233. get loaderState(): Nullable<GLTFLoaderState>;
  87234. /**
  87235. * Returns a promise that resolves when the asset is completely loaded.
  87236. * @returns a promise that resolves when the asset is completely loaded.
  87237. */
  87238. whenCompleteAsync(): Promise<void>;
  87239. /** @hidden */
  87240. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  87241. /** @hidden */
  87242. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  87243. private _onProgress;
  87244. private _validate;
  87245. private _getLoader;
  87246. private _parseJson;
  87247. private _unpackBinaryAsync;
  87248. private _unpackBinaryV1Async;
  87249. private _unpackBinaryV2Async;
  87250. private static _parseVersion;
  87251. private static _compareVersion;
  87252. private static readonly _logSpaces;
  87253. private _logIndentLevel;
  87254. private _loggingEnabled;
  87255. /** @hidden */
  87256. _log: (message: string) => void;
  87257. /** @hidden */
  87258. _logOpen(message: string): void;
  87259. /** @hidden */
  87260. _logClose(): void;
  87261. private _logEnabled;
  87262. private _logDisabled;
  87263. private _capturePerformanceCounters;
  87264. /** @hidden */
  87265. _startPerformanceCounter: (counterName: string) => void;
  87266. /** @hidden */
  87267. _endPerformanceCounter: (counterName: string) => void;
  87268. private _startPerformanceCounterEnabled;
  87269. private _startPerformanceCounterDisabled;
  87270. private _endPerformanceCounterEnabled;
  87271. private _endPerformanceCounterDisabled;
  87272. }
  87273. }
  87274. declare module BABYLON.GLTF1 {
  87275. /**
  87276. * Enums
  87277. * @hidden
  87278. */
  87279. export enum EComponentType {
  87280. BYTE = 5120,
  87281. UNSIGNED_BYTE = 5121,
  87282. SHORT = 5122,
  87283. UNSIGNED_SHORT = 5123,
  87284. FLOAT = 5126
  87285. }
  87286. /** @hidden */
  87287. export enum EShaderType {
  87288. FRAGMENT = 35632,
  87289. VERTEX = 35633
  87290. }
  87291. /** @hidden */
  87292. export enum EParameterType {
  87293. BYTE = 5120,
  87294. UNSIGNED_BYTE = 5121,
  87295. SHORT = 5122,
  87296. UNSIGNED_SHORT = 5123,
  87297. INT = 5124,
  87298. UNSIGNED_INT = 5125,
  87299. FLOAT = 5126,
  87300. FLOAT_VEC2 = 35664,
  87301. FLOAT_VEC3 = 35665,
  87302. FLOAT_VEC4 = 35666,
  87303. INT_VEC2 = 35667,
  87304. INT_VEC3 = 35668,
  87305. INT_VEC4 = 35669,
  87306. BOOL = 35670,
  87307. BOOL_VEC2 = 35671,
  87308. BOOL_VEC3 = 35672,
  87309. BOOL_VEC4 = 35673,
  87310. FLOAT_MAT2 = 35674,
  87311. FLOAT_MAT3 = 35675,
  87312. FLOAT_MAT4 = 35676,
  87313. SAMPLER_2D = 35678
  87314. }
  87315. /** @hidden */
  87316. export enum ETextureWrapMode {
  87317. CLAMP_TO_EDGE = 33071,
  87318. MIRRORED_REPEAT = 33648,
  87319. REPEAT = 10497
  87320. }
  87321. /** @hidden */
  87322. export enum ETextureFilterType {
  87323. NEAREST = 9728,
  87324. LINEAR = 9728,
  87325. NEAREST_MIPMAP_NEAREST = 9984,
  87326. LINEAR_MIPMAP_NEAREST = 9985,
  87327. NEAREST_MIPMAP_LINEAR = 9986,
  87328. LINEAR_MIPMAP_LINEAR = 9987
  87329. }
  87330. /** @hidden */
  87331. export enum ETextureFormat {
  87332. ALPHA = 6406,
  87333. RGB = 6407,
  87334. RGBA = 6408,
  87335. LUMINANCE = 6409,
  87336. LUMINANCE_ALPHA = 6410
  87337. }
  87338. /** @hidden */
  87339. export enum ECullingType {
  87340. FRONT = 1028,
  87341. BACK = 1029,
  87342. FRONT_AND_BACK = 1032
  87343. }
  87344. /** @hidden */
  87345. export enum EBlendingFunction {
  87346. ZERO = 0,
  87347. ONE = 1,
  87348. SRC_COLOR = 768,
  87349. ONE_MINUS_SRC_COLOR = 769,
  87350. DST_COLOR = 774,
  87351. ONE_MINUS_DST_COLOR = 775,
  87352. SRC_ALPHA = 770,
  87353. ONE_MINUS_SRC_ALPHA = 771,
  87354. DST_ALPHA = 772,
  87355. ONE_MINUS_DST_ALPHA = 773,
  87356. CONSTANT_COLOR = 32769,
  87357. ONE_MINUS_CONSTANT_COLOR = 32770,
  87358. CONSTANT_ALPHA = 32771,
  87359. ONE_MINUS_CONSTANT_ALPHA = 32772,
  87360. SRC_ALPHA_SATURATE = 776
  87361. }
  87362. /** @hidden */
  87363. export interface IGLTFProperty {
  87364. extensions?: {
  87365. [key: string]: any;
  87366. };
  87367. extras?: Object;
  87368. }
  87369. /** @hidden */
  87370. export interface IGLTFChildRootProperty extends IGLTFProperty {
  87371. name?: string;
  87372. }
  87373. /** @hidden */
  87374. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  87375. bufferView: string;
  87376. byteOffset: number;
  87377. byteStride: number;
  87378. count: number;
  87379. type: string;
  87380. componentType: EComponentType;
  87381. max?: number[];
  87382. min?: number[];
  87383. name?: string;
  87384. }
  87385. /** @hidden */
  87386. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  87387. buffer: string;
  87388. byteOffset: number;
  87389. byteLength: number;
  87390. byteStride: number;
  87391. target?: number;
  87392. }
  87393. /** @hidden */
  87394. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  87395. uri: string;
  87396. byteLength?: number;
  87397. type?: string;
  87398. }
  87399. /** @hidden */
  87400. export interface IGLTFShader extends IGLTFChildRootProperty {
  87401. uri: string;
  87402. type: EShaderType;
  87403. }
  87404. /** @hidden */
  87405. export interface IGLTFProgram extends IGLTFChildRootProperty {
  87406. attributes: string[];
  87407. fragmentShader: string;
  87408. vertexShader: string;
  87409. }
  87410. /** @hidden */
  87411. export interface IGLTFTechniqueParameter {
  87412. type: number;
  87413. count?: number;
  87414. semantic?: string;
  87415. node?: string;
  87416. value?: number | boolean | string | Array<any>;
  87417. source?: string;
  87418. babylonValue?: any;
  87419. }
  87420. /** @hidden */
  87421. export interface IGLTFTechniqueCommonProfile {
  87422. lightingModel: string;
  87423. texcoordBindings: Object;
  87424. parameters?: Array<any>;
  87425. }
  87426. /** @hidden */
  87427. export interface IGLTFTechniqueStatesFunctions {
  87428. blendColor?: number[];
  87429. blendEquationSeparate?: number[];
  87430. blendFuncSeparate?: number[];
  87431. colorMask: boolean[];
  87432. cullFace: number[];
  87433. }
  87434. /** @hidden */
  87435. export interface IGLTFTechniqueStates {
  87436. enable: number[];
  87437. functions: IGLTFTechniqueStatesFunctions;
  87438. }
  87439. /** @hidden */
  87440. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  87441. parameters: {
  87442. [key: string]: IGLTFTechniqueParameter;
  87443. };
  87444. program: string;
  87445. attributes: {
  87446. [key: string]: string;
  87447. };
  87448. uniforms: {
  87449. [key: string]: string;
  87450. };
  87451. states: IGLTFTechniqueStates;
  87452. }
  87453. /** @hidden */
  87454. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  87455. technique?: string;
  87456. values: string[];
  87457. }
  87458. /** @hidden */
  87459. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  87460. attributes: {
  87461. [key: string]: string;
  87462. };
  87463. indices: string;
  87464. material: string;
  87465. mode?: number;
  87466. }
  87467. /** @hidden */
  87468. export interface IGLTFMesh extends IGLTFChildRootProperty {
  87469. primitives: IGLTFMeshPrimitive[];
  87470. }
  87471. /** @hidden */
  87472. export interface IGLTFImage extends IGLTFChildRootProperty {
  87473. uri: string;
  87474. }
  87475. /** @hidden */
  87476. export interface IGLTFSampler extends IGLTFChildRootProperty {
  87477. magFilter?: number;
  87478. minFilter?: number;
  87479. wrapS?: number;
  87480. wrapT?: number;
  87481. }
  87482. /** @hidden */
  87483. export interface IGLTFTexture extends IGLTFChildRootProperty {
  87484. sampler: string;
  87485. source: string;
  87486. format?: ETextureFormat;
  87487. internalFormat?: ETextureFormat;
  87488. target?: number;
  87489. type?: number;
  87490. babylonTexture?: Texture;
  87491. }
  87492. /** @hidden */
  87493. export interface IGLTFAmbienLight {
  87494. color?: number[];
  87495. }
  87496. /** @hidden */
  87497. export interface IGLTFDirectionalLight {
  87498. color?: number[];
  87499. }
  87500. /** @hidden */
  87501. export interface IGLTFPointLight {
  87502. color?: number[];
  87503. constantAttenuation?: number;
  87504. linearAttenuation?: number;
  87505. quadraticAttenuation?: number;
  87506. }
  87507. /** @hidden */
  87508. export interface IGLTFSpotLight {
  87509. color?: number[];
  87510. constantAttenuation?: number;
  87511. fallOfAngle?: number;
  87512. fallOffExponent?: number;
  87513. linearAttenuation?: number;
  87514. quadraticAttenuation?: number;
  87515. }
  87516. /** @hidden */
  87517. export interface IGLTFLight extends IGLTFChildRootProperty {
  87518. type: string;
  87519. }
  87520. /** @hidden */
  87521. export interface IGLTFCameraOrthographic {
  87522. xmag: number;
  87523. ymag: number;
  87524. zfar: number;
  87525. znear: number;
  87526. }
  87527. /** @hidden */
  87528. export interface IGLTFCameraPerspective {
  87529. aspectRatio: number;
  87530. yfov: number;
  87531. zfar: number;
  87532. znear: number;
  87533. }
  87534. /** @hidden */
  87535. export interface IGLTFCamera extends IGLTFChildRootProperty {
  87536. type: string;
  87537. }
  87538. /** @hidden */
  87539. export interface IGLTFAnimationChannelTarget {
  87540. id: string;
  87541. path: string;
  87542. }
  87543. /** @hidden */
  87544. export interface IGLTFAnimationChannel {
  87545. sampler: string;
  87546. target: IGLTFAnimationChannelTarget;
  87547. }
  87548. /** @hidden */
  87549. export interface IGLTFAnimationSampler {
  87550. input: string;
  87551. output: string;
  87552. interpolation?: string;
  87553. }
  87554. /** @hidden */
  87555. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  87556. channels?: IGLTFAnimationChannel[];
  87557. parameters?: {
  87558. [key: string]: string;
  87559. };
  87560. samplers?: {
  87561. [key: string]: IGLTFAnimationSampler;
  87562. };
  87563. }
  87564. /** @hidden */
  87565. export interface IGLTFNodeInstanceSkin {
  87566. skeletons: string[];
  87567. skin: string;
  87568. meshes: string[];
  87569. }
  87570. /** @hidden */
  87571. export interface IGLTFSkins extends IGLTFChildRootProperty {
  87572. bindShapeMatrix: number[];
  87573. inverseBindMatrices: string;
  87574. jointNames: string[];
  87575. babylonSkeleton?: Skeleton;
  87576. }
  87577. /** @hidden */
  87578. export interface IGLTFNode extends IGLTFChildRootProperty {
  87579. camera?: string;
  87580. children: string[];
  87581. skin?: string;
  87582. jointName?: string;
  87583. light?: string;
  87584. matrix: number[];
  87585. mesh?: string;
  87586. meshes?: string[];
  87587. rotation?: number[];
  87588. scale?: number[];
  87589. translation?: number[];
  87590. babylonNode?: Node;
  87591. }
  87592. /** @hidden */
  87593. export interface IGLTFScene extends IGLTFChildRootProperty {
  87594. nodes: string[];
  87595. }
  87596. /** @hidden */
  87597. export interface IGLTFRuntime {
  87598. extensions: {
  87599. [key: string]: any;
  87600. };
  87601. accessors: {
  87602. [key: string]: IGLTFAccessor;
  87603. };
  87604. buffers: {
  87605. [key: string]: IGLTFBuffer;
  87606. };
  87607. bufferViews: {
  87608. [key: string]: IGLTFBufferView;
  87609. };
  87610. meshes: {
  87611. [key: string]: IGLTFMesh;
  87612. };
  87613. lights: {
  87614. [key: string]: IGLTFLight;
  87615. };
  87616. cameras: {
  87617. [key: string]: IGLTFCamera;
  87618. };
  87619. nodes: {
  87620. [key: string]: IGLTFNode;
  87621. };
  87622. images: {
  87623. [key: string]: IGLTFImage;
  87624. };
  87625. textures: {
  87626. [key: string]: IGLTFTexture;
  87627. };
  87628. shaders: {
  87629. [key: string]: IGLTFShader;
  87630. };
  87631. programs: {
  87632. [key: string]: IGLTFProgram;
  87633. };
  87634. samplers: {
  87635. [key: string]: IGLTFSampler;
  87636. };
  87637. techniques: {
  87638. [key: string]: IGLTFTechnique;
  87639. };
  87640. materials: {
  87641. [key: string]: IGLTFMaterial;
  87642. };
  87643. animations: {
  87644. [key: string]: IGLTFAnimation;
  87645. };
  87646. skins: {
  87647. [key: string]: IGLTFSkins;
  87648. };
  87649. currentScene?: Object;
  87650. scenes: {
  87651. [key: string]: IGLTFScene;
  87652. };
  87653. extensionsUsed: string[];
  87654. extensionsRequired?: string[];
  87655. buffersCount: number;
  87656. shaderscount: number;
  87657. scene: Scene;
  87658. rootUrl: string;
  87659. loadedBufferCount: number;
  87660. loadedBufferViews: {
  87661. [name: string]: ArrayBufferView;
  87662. };
  87663. loadedShaderCount: number;
  87664. importOnlyMeshes: boolean;
  87665. importMeshesNames?: string[];
  87666. dummyNodes: Node[];
  87667. forAssetContainer: boolean;
  87668. }
  87669. /** @hidden */
  87670. export interface INodeToRoot {
  87671. bone: Bone;
  87672. node: IGLTFNode;
  87673. id: string;
  87674. }
  87675. /** @hidden */
  87676. export interface IJointNode {
  87677. node: IGLTFNode;
  87678. id: string;
  87679. }
  87680. }
  87681. declare module BABYLON.GLTF1 {
  87682. /**
  87683. * Utils functions for GLTF
  87684. * @hidden
  87685. */
  87686. export class GLTFUtils {
  87687. /**
  87688. * Sets the given "parameter" matrix
  87689. * @param scene: the Scene object
  87690. * @param source: the source node where to pick the matrix
  87691. * @param parameter: the GLTF technique parameter
  87692. * @param uniformName: the name of the shader's uniform
  87693. * @param shaderMaterial: the shader material
  87694. */
  87695. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  87696. /**
  87697. * Sets the given "parameter" matrix
  87698. * @param shaderMaterial: the shader material
  87699. * @param uniform: the name of the shader's uniform
  87700. * @param value: the value of the uniform
  87701. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  87702. */
  87703. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  87704. /**
  87705. * Returns the wrap mode of the texture
  87706. * @param mode: the mode value
  87707. */
  87708. static GetWrapMode(mode: number): number;
  87709. /**
  87710. * Returns the byte stride giving an accessor
  87711. * @param accessor: the GLTF accessor objet
  87712. */
  87713. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  87714. /**
  87715. * Returns the texture filter mode giving a mode value
  87716. * @param mode: the filter mode value
  87717. */
  87718. static GetTextureFilterMode(mode: number): ETextureFilterType;
  87719. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  87720. /**
  87721. * Returns a buffer from its accessor
  87722. * @param gltfRuntime: the GLTF runtime
  87723. * @param accessor: the GLTF accessor
  87724. */
  87725. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  87726. /**
  87727. * Decodes a buffer view into a string
  87728. * @param view: the buffer view
  87729. */
  87730. static DecodeBufferToText(view: ArrayBufferView): string;
  87731. /**
  87732. * Returns the default material of gltf. Related to
  87733. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  87734. * @param scene: the Babylon.js scene
  87735. */
  87736. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  87737. private static _DefaultMaterial;
  87738. }
  87739. }
  87740. declare module BABYLON.GLTF1 {
  87741. /**
  87742. * Implementation of the base glTF spec
  87743. * @hidden
  87744. */
  87745. export class GLTFLoaderBase {
  87746. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  87747. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  87748. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  87749. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  87750. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  87751. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  87752. }
  87753. /**
  87754. * glTF V1 Loader
  87755. * @hidden
  87756. */
  87757. export class GLTFLoader implements IGLTFLoader {
  87758. static Extensions: {
  87759. [name: string]: GLTFLoaderExtension;
  87760. };
  87761. static RegisterExtension(extension: GLTFLoaderExtension): void;
  87762. state: Nullable<GLTFLoaderState>;
  87763. dispose(): void;
  87764. private _importMeshAsync;
  87765. /**
  87766. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  87767. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  87768. * @param scene the scene the meshes should be added to
  87769. * @param forAssetContainer defines if the entities must be stored in the scene
  87770. * @param data gltf data containing information of the meshes in a loaded file
  87771. * @param rootUrl root url to load from
  87772. * @param onProgress event that fires when loading progress has occured
  87773. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  87774. */
  87775. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
  87776. private _loadAsync;
  87777. /**
  87778. * Imports all objects from a loaded gltf file and adds them to the scene
  87779. * @param scene the scene the objects should be added to
  87780. * @param data gltf data containing information of the meshes in a loaded file
  87781. * @param rootUrl root url to load from
  87782. * @param onProgress event that fires when loading progress has occured
  87783. * @returns a promise which completes when objects have been loaded to the scene
  87784. */
  87785. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  87786. private _loadShadersAsync;
  87787. private _loadBuffersAsync;
  87788. private _createNodes;
  87789. }
  87790. /** @hidden */
  87791. export abstract class GLTFLoaderExtension {
  87792. private _name;
  87793. constructor(name: string);
  87794. get name(): string;
  87795. /**
  87796. * Defines an override for loading the runtime
  87797. * Return true to stop further extensions from loading the runtime
  87798. */
  87799. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  87800. /**
  87801. * Defines an onverride for creating gltf runtime
  87802. * Return true to stop further extensions from creating the runtime
  87803. */
  87804. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  87805. /**
  87806. * Defines an override for loading buffers
  87807. * Return true to stop further extensions from loading this buffer
  87808. */
  87809. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  87810. /**
  87811. * Defines an override for loading texture buffers
  87812. * Return true to stop further extensions from loading this texture data
  87813. */
  87814. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87815. /**
  87816. * Defines an override for creating textures
  87817. * Return true to stop further extensions from loading this texture
  87818. */
  87819. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  87820. /**
  87821. * Defines an override for loading shader strings
  87822. * Return true to stop further extensions from loading this shader data
  87823. */
  87824. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  87825. /**
  87826. * Defines an override for loading materials
  87827. * Return true to stop further extensions from loading this material
  87828. */
  87829. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  87830. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  87831. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  87832. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  87833. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  87834. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  87835. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  87836. private static LoadTextureBufferAsync;
  87837. private static CreateTextureAsync;
  87838. private static ApplyExtensions;
  87839. }
  87840. }
  87841. declare module BABYLON.GLTF1 {
  87842. /** @hidden */
  87843. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  87844. private _bin;
  87845. constructor();
  87846. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  87847. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87848. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87849. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  87850. }
  87851. }
  87852. declare module BABYLON.GLTF1 {
  87853. /** @hidden */
  87854. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  87855. constructor();
  87856. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  87857. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  87858. private _loadTexture;
  87859. }
  87860. }
  87861. declare module BABYLON.GLTF2.Loader {
  87862. /**
  87863. * Loader interface with an index field.
  87864. */
  87865. export interface IArrayItem {
  87866. /**
  87867. * The index of this item in the array.
  87868. */
  87869. index: number;
  87870. }
  87871. /**
  87872. * Loader interface with additional members.
  87873. */
  87874. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  87875. /** @hidden */
  87876. _data?: Promise<ArrayBufferView>;
  87877. /** @hidden */
  87878. _babylonVertexBuffer?: Promise<VertexBuffer>;
  87879. }
  87880. /**
  87881. * Loader interface with additional members.
  87882. */
  87883. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  87884. }
  87885. /** @hidden */
  87886. export interface _IAnimationSamplerData {
  87887. input: Float32Array;
  87888. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  87889. output: Float32Array;
  87890. }
  87891. /**
  87892. * Loader interface with additional members.
  87893. */
  87894. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  87895. /** @hidden */
  87896. _data?: Promise<_IAnimationSamplerData>;
  87897. }
  87898. /**
  87899. * Loader interface with additional members.
  87900. */
  87901. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  87902. channels: IAnimationChannel[];
  87903. samplers: IAnimationSampler[];
  87904. /** @hidden */
  87905. _babylonAnimationGroup?: AnimationGroup;
  87906. }
  87907. /**
  87908. * Loader interface with additional members.
  87909. */
  87910. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  87911. /** @hidden */
  87912. _data?: Promise<ArrayBufferView>;
  87913. }
  87914. /**
  87915. * Loader interface with additional members.
  87916. */
  87917. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  87918. /** @hidden */
  87919. _data?: Promise<ArrayBufferView>;
  87920. /** @hidden */
  87921. _babylonBuffer?: Promise<Buffer>;
  87922. }
  87923. /**
  87924. * Loader interface with additional members.
  87925. */
  87926. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  87927. }
  87928. /**
  87929. * Loader interface with additional members.
  87930. */
  87931. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  87932. /** @hidden */
  87933. _data?: Promise<ArrayBufferView>;
  87934. }
  87935. /**
  87936. * Loader interface with additional members.
  87937. */
  87938. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  87939. }
  87940. /**
  87941. * Loader interface with additional members.
  87942. */
  87943. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  87944. }
  87945. /**
  87946. * Loader interface with additional members.
  87947. */
  87948. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  87949. baseColorTexture?: ITextureInfo;
  87950. metallicRoughnessTexture?: ITextureInfo;
  87951. }
  87952. /**
  87953. * Loader interface with additional members.
  87954. */
  87955. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  87956. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  87957. normalTexture?: IMaterialNormalTextureInfo;
  87958. occlusionTexture?: IMaterialOcclusionTextureInfo;
  87959. emissiveTexture?: ITextureInfo;
  87960. /** @hidden */
  87961. _data?: {
  87962. [babylonDrawMode: number]: {
  87963. babylonMaterial: Material;
  87964. babylonMeshes: AbstractMesh[];
  87965. promise: Promise<void>;
  87966. };
  87967. };
  87968. }
  87969. /**
  87970. * Loader interface with additional members.
  87971. */
  87972. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  87973. primitives: IMeshPrimitive[];
  87974. }
  87975. /**
  87976. * Loader interface with additional members.
  87977. */
  87978. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  87979. /** @hidden */
  87980. _instanceData?: {
  87981. babylonSourceMesh: Mesh;
  87982. promise: Promise<any>;
  87983. };
  87984. }
  87985. /**
  87986. * Loader interface with additional members.
  87987. */
  87988. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  87989. /**
  87990. * The parent glTF node.
  87991. */
  87992. parent?: INode;
  87993. /** @hidden */
  87994. _babylonTransformNode?: TransformNode;
  87995. /** @hidden */
  87996. _primitiveBabylonMeshes?: AbstractMesh[];
  87997. /** @hidden */
  87998. _babylonBones?: Bone[];
  87999. /** @hidden */
  88000. _numMorphTargets?: number;
  88001. }
  88002. /** @hidden */
  88003. export interface _ISamplerData {
  88004. noMipMaps: boolean;
  88005. samplingMode: number;
  88006. wrapU: number;
  88007. wrapV: number;
  88008. }
  88009. /**
  88010. * Loader interface with additional members.
  88011. */
  88012. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  88013. /** @hidden */
  88014. _data?: _ISamplerData;
  88015. }
  88016. /**
  88017. * Loader interface with additional members.
  88018. */
  88019. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  88020. }
  88021. /**
  88022. * Loader interface with additional members.
  88023. */
  88024. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  88025. /** @hidden */
  88026. _data?: {
  88027. babylonSkeleton: Skeleton;
  88028. promise: Promise<void>;
  88029. };
  88030. }
  88031. /**
  88032. * Loader interface with additional members.
  88033. */
  88034. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  88035. /** @hidden */
  88036. _textureInfo: ITextureInfo;
  88037. }
  88038. /**
  88039. * Loader interface with additional members.
  88040. */
  88041. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  88042. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  88043. nonColorData?: boolean;
  88044. }
  88045. /**
  88046. * Loader interface with additional members.
  88047. */
  88048. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  88049. accessors?: IAccessor[];
  88050. animations?: IAnimation[];
  88051. buffers?: IBuffer[];
  88052. bufferViews?: IBufferView[];
  88053. cameras?: ICamera[];
  88054. images?: IImage[];
  88055. materials?: IMaterial[];
  88056. meshes?: IMesh[];
  88057. nodes?: INode[];
  88058. samplers?: ISampler[];
  88059. scenes?: IScene[];
  88060. skins?: ISkin[];
  88061. textures?: ITexture[];
  88062. }
  88063. }
  88064. declare module BABYLON.GLTF2 {
  88065. /**
  88066. * Interface for a glTF loader extension.
  88067. */
  88068. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  88069. /**
  88070. * Called after the loader state changes to LOADING.
  88071. */
  88072. onLoading?(): void;
  88073. /**
  88074. * Called after the loader state changes to READY.
  88075. */
  88076. onReady?(): void;
  88077. /**
  88078. * Define this method to modify the default behavior when loading scenes.
  88079. * @param context The context when loading the asset
  88080. * @param scene The glTF scene property
  88081. * @returns A promise that resolves when the load is complete or null if not handled
  88082. */
  88083. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  88084. /**
  88085. * Define this method to modify the default behavior when loading nodes.
  88086. * @param context The context when loading the asset
  88087. * @param node The glTF node property
  88088. * @param assign A function called synchronously after parsing the glTF properties
  88089. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  88090. */
  88091. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88092. /**
  88093. * Define this method to modify the default behavior when loading cameras.
  88094. * @param context The context when loading the asset
  88095. * @param camera The glTF camera property
  88096. * @param assign A function called synchronously after parsing the glTF properties
  88097. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  88098. */
  88099. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  88100. /**
  88101. * @hidden
  88102. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  88103. * @param context The context when loading the asset
  88104. * @param primitive The glTF mesh primitive property
  88105. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  88106. */
  88107. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  88108. /**
  88109. * @hidden
  88110. * Define this method to modify the default behavior when loading data for mesh primitives.
  88111. * @param context The context when loading the asset
  88112. * @param name The mesh name when loading the asset
  88113. * @param node The glTF node when loading the asset
  88114. * @param mesh The glTF mesh when loading the asset
  88115. * @param primitive The glTF mesh primitive property
  88116. * @param assign A function called synchronously after parsing the glTF properties
  88117. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  88118. */
  88119. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  88120. /**
  88121. * @hidden
  88122. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  88123. * @param context The context when loading the asset
  88124. * @param material The glTF material property
  88125. * @param assign A function called synchronously after parsing the glTF properties
  88126. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  88127. */
  88128. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  88129. /**
  88130. * Define this method to modify the default behavior when creating materials.
  88131. * @param context The context when loading the asset
  88132. * @param material The glTF material property
  88133. * @param babylonDrawMode The draw mode for the Babylon material
  88134. * @returns The Babylon material or null if not handled
  88135. */
  88136. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  88137. /**
  88138. * Define this method to modify the default behavior when loading material properties.
  88139. * @param context The context when loading the asset
  88140. * @param material The glTF material property
  88141. * @param babylonMaterial The Babylon material
  88142. * @returns A promise that resolves when the load is complete or null if not handled
  88143. */
  88144. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88145. /**
  88146. * Define this method to modify the default behavior when loading texture infos.
  88147. * @param context The context when loading the asset
  88148. * @param textureInfo The glTF texture info property
  88149. * @param assign A function called synchronously after parsing the glTF properties
  88150. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  88151. */
  88152. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88153. /**
  88154. * @hidden
  88155. * Define this method to modify the default behavior when loading textures.
  88156. * @param context The context when loading the asset
  88157. * @param texture The glTF texture property
  88158. * @param assign A function called synchronously after parsing the glTF properties
  88159. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  88160. */
  88161. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88162. /**
  88163. * Define this method to modify the default behavior when loading animations.
  88164. * @param context The context when loading the asset
  88165. * @param animation The glTF animation property
  88166. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  88167. */
  88168. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  88169. /**
  88170. * @hidden
  88171. * Define this method to modify the default behavior when loading skins.
  88172. * @param context The context when loading the asset
  88173. * @param node The glTF node property
  88174. * @param skin The glTF skin property
  88175. * @returns A promise that resolves when the load is complete or null if not handled
  88176. */
  88177. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  88178. /**
  88179. * @hidden
  88180. * Define this method to modify the default behavior when loading uris.
  88181. * @param context The context when loading the asset
  88182. * @param property The glTF property associated with the uri
  88183. * @param uri The uri to load
  88184. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  88185. */
  88186. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  88187. /**
  88188. * Define this method to modify the default behavior when loading buffer views.
  88189. * @param context The context when loading the asset
  88190. * @param bufferView The glTF buffer view property
  88191. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  88192. */
  88193. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  88194. /**
  88195. * Define this method to modify the default behavior when loading buffers.
  88196. * @param context The context when loading the asset
  88197. * @param buffer The glTF buffer property
  88198. * @param byteOffset The byte offset to load
  88199. * @param byteLength The byte length to load
  88200. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  88201. */
  88202. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  88203. }
  88204. }
  88205. declare module BABYLON.GLTF2 {
  88206. /**
  88207. * Helper class for working with arrays when loading the glTF asset
  88208. */
  88209. export class ArrayItem {
  88210. /**
  88211. * Gets an item from the given array.
  88212. * @param context The context when loading the asset
  88213. * @param array The array to get the item from
  88214. * @param index The index to the array
  88215. * @returns The array item
  88216. */
  88217. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  88218. /**
  88219. * Assign an `index` field to each item of the given array.
  88220. * @param array The array of items
  88221. */
  88222. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  88223. }
  88224. /**
  88225. * The glTF 2.0 loader
  88226. */
  88227. export class GLTFLoader implements IGLTFLoader {
  88228. /** @hidden */
  88229. _completePromises: Promise<any>[];
  88230. /** @hidden */
  88231. _forAssetContainer: boolean;
  88232. /** Storage */
  88233. _babylonLights: Light[];
  88234. /** @hidden */
  88235. _disableInstancedMesh: number;
  88236. private _disposed;
  88237. private _parent;
  88238. private _state;
  88239. private _extensions;
  88240. private _rootUrl;
  88241. private _fileName;
  88242. private _uniqueRootUrl;
  88243. private _gltf;
  88244. private _bin;
  88245. private _babylonScene;
  88246. private _rootBabylonMesh;
  88247. private _defaultBabylonMaterialData;
  88248. private static _RegisteredExtensions;
  88249. /**
  88250. * The default glTF sampler.
  88251. */
  88252. static readonly DefaultSampler: ISampler;
  88253. /**
  88254. * Registers a loader extension.
  88255. * @param name The name of the loader extension.
  88256. * @param factory The factory function that creates the loader extension.
  88257. */
  88258. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  88259. /**
  88260. * Unregisters a loader extension.
  88261. * @param name The name of the loader extension.
  88262. * @returns A boolean indicating whether the extension has been unregistered
  88263. */
  88264. static UnregisterExtension(name: string): boolean;
  88265. /**
  88266. * The loader state.
  88267. */
  88268. get state(): Nullable<GLTFLoaderState>;
  88269. /**
  88270. * The object that represents the glTF JSON.
  88271. */
  88272. get gltf(): IGLTF;
  88273. /**
  88274. * The BIN chunk of a binary glTF.
  88275. */
  88276. get bin(): Nullable<IDataBuffer>;
  88277. /**
  88278. * The parent file loader.
  88279. */
  88280. get parent(): GLTFFileLoader;
  88281. /**
  88282. * The Babylon scene when loading the asset.
  88283. */
  88284. get babylonScene(): Scene;
  88285. /**
  88286. * The root Babylon mesh when loading the asset.
  88287. */
  88288. get rootBabylonMesh(): Mesh;
  88289. /** @hidden */
  88290. constructor(parent: GLTFFileLoader);
  88291. /** @hidden */
  88292. dispose(): void;
  88293. /** @hidden */
  88294. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  88295. /** @hidden */
  88296. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  88297. private _loadAsync;
  88298. private _loadData;
  88299. private _setupData;
  88300. private _loadExtensions;
  88301. private _checkExtensions;
  88302. private _setState;
  88303. private _createRootNode;
  88304. /**
  88305. * Loads a glTF scene.
  88306. * @param context The context when loading the asset
  88307. * @param scene The glTF scene property
  88308. * @returns A promise that resolves when the load is complete
  88309. */
  88310. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  88311. private _forEachPrimitive;
  88312. private _getGeometries;
  88313. private _getMeshes;
  88314. private _getTransformNodes;
  88315. private _getSkeletons;
  88316. private _getAnimationGroups;
  88317. private _startAnimations;
  88318. /**
  88319. * Loads a glTF node.
  88320. * @param context The context when loading the asset
  88321. * @param node The glTF node property
  88322. * @param assign A function called synchronously after parsing the glTF properties
  88323. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  88324. */
  88325. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  88326. private _loadMeshAsync;
  88327. /**
  88328. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  88329. * @param context The context when loading the asset
  88330. * @param name The mesh name when loading the asset
  88331. * @param node The glTF node when loading the asset
  88332. * @param mesh The glTF mesh when loading the asset
  88333. * @param primitive The glTF mesh primitive property
  88334. * @param assign A function called synchronously after parsing the glTF properties
  88335. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  88336. */
  88337. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  88338. private _loadVertexDataAsync;
  88339. private _createMorphTargets;
  88340. private _loadMorphTargetsAsync;
  88341. private _loadMorphTargetVertexDataAsync;
  88342. private static _LoadTransform;
  88343. private _loadSkinAsync;
  88344. private _loadBones;
  88345. private _loadBone;
  88346. private _loadSkinInverseBindMatricesDataAsync;
  88347. private _updateBoneMatrices;
  88348. private _getNodeMatrix;
  88349. /**
  88350. * Loads a glTF camera.
  88351. * @param context The context when loading the asset
  88352. * @param camera The glTF camera property
  88353. * @param assign A function called synchronously after parsing the glTF properties
  88354. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  88355. */
  88356. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  88357. private _loadAnimationsAsync;
  88358. /**
  88359. * Loads a glTF animation.
  88360. * @param context The context when loading the asset
  88361. * @param animation The glTF animation property
  88362. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  88363. */
  88364. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  88365. /**
  88366. * @hidden Loads a glTF animation channel.
  88367. * @param context The context when loading the asset
  88368. * @param animationContext The context of the animation when loading the asset
  88369. * @param animation The glTF animation property
  88370. * @param channel The glTF animation channel property
  88371. * @param babylonAnimationGroup The babylon animation group property
  88372. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  88373. * @returns A void promise when the channel load is complete
  88374. */
  88375. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  88376. private _loadAnimationSamplerAsync;
  88377. /**
  88378. * Loads a glTF buffer.
  88379. * @param context The context when loading the asset
  88380. * @param buffer The glTF buffer property
  88381. * @param byteOffset The byte offset to use
  88382. * @param byteLength The byte length to use
  88383. * @returns A promise that resolves with the loaded data when the load is complete
  88384. */
  88385. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  88386. /**
  88387. * Loads a glTF buffer view.
  88388. * @param context The context when loading the asset
  88389. * @param bufferView The glTF buffer view property
  88390. * @returns A promise that resolves with the loaded data when the load is complete
  88391. */
  88392. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  88393. private _loadAccessorAsync;
  88394. /** @hidden */
  88395. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  88396. private _loadIndicesAccessorAsync;
  88397. private _loadVertexBufferViewAsync;
  88398. private _loadVertexAccessorAsync;
  88399. private _loadMaterialMetallicRoughnessPropertiesAsync;
  88400. /** @hidden */
  88401. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  88402. private _createDefaultMaterial;
  88403. /**
  88404. * Creates a Babylon material from a glTF material.
  88405. * @param context The context when loading the asset
  88406. * @param material The glTF material property
  88407. * @param babylonDrawMode The draw mode for the Babylon material
  88408. * @returns The Babylon material
  88409. */
  88410. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  88411. /**
  88412. * Loads properties from a glTF material into a Babylon material.
  88413. * @param context The context when loading the asset
  88414. * @param material The glTF material property
  88415. * @param babylonMaterial The Babylon material
  88416. * @returns A promise that resolves when the load is complete
  88417. */
  88418. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  88419. /**
  88420. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  88421. * @param context The context when loading the asset
  88422. * @param material The glTF material property
  88423. * @param babylonMaterial The Babylon material
  88424. * @returns A promise that resolves when the load is complete
  88425. */
  88426. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  88427. /**
  88428. * Loads the alpha properties from a glTF material into a Babylon material.
  88429. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  88430. * @param context The context when loading the asset
  88431. * @param material The glTF material property
  88432. * @param babylonMaterial The Babylon material
  88433. */
  88434. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  88435. /**
  88436. * Loads a glTF texture info.
  88437. * @param context The context when loading the asset
  88438. * @param textureInfo The glTF texture info property
  88439. * @param assign A function called synchronously after parsing the glTF properties
  88440. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  88441. */
  88442. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  88443. /** @hidden */
  88444. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  88445. /** @hidden */
  88446. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  88447. private _loadSampler;
  88448. /**
  88449. * Loads a glTF image.
  88450. * @param context The context when loading the asset
  88451. * @param image The glTF image property
  88452. * @returns A promise that resolves with the loaded data when the load is complete
  88453. */
  88454. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  88455. /**
  88456. * Loads a glTF uri.
  88457. * @param context The context when loading the asset
  88458. * @param property The glTF property associated with the uri
  88459. * @param uri The base64 or relative uri
  88460. * @returns A promise that resolves with the loaded data when the load is complete
  88461. */
  88462. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  88463. /**
  88464. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  88465. * @param babylonObject the Babylon object with metadata
  88466. * @param pointer the JSON pointer
  88467. */
  88468. static AddPointerMetadata(babylonObject: {
  88469. metadata: any;
  88470. }, pointer: string): void;
  88471. private static _GetTextureWrapMode;
  88472. private static _GetTextureSamplingMode;
  88473. private static _GetTypedArrayConstructor;
  88474. private static _GetTypedArray;
  88475. private static _GetNumComponents;
  88476. private static _ValidateUri;
  88477. /** @hidden */
  88478. static _GetDrawMode(context: string, mode: number | undefined): number;
  88479. private _compileMaterialsAsync;
  88480. private _compileShadowGeneratorsAsync;
  88481. private _forEachExtensions;
  88482. private _applyExtensions;
  88483. private _extensionsOnLoading;
  88484. private _extensionsOnReady;
  88485. private _extensionsLoadSceneAsync;
  88486. private _extensionsLoadNodeAsync;
  88487. private _extensionsLoadCameraAsync;
  88488. private _extensionsLoadVertexDataAsync;
  88489. private _extensionsLoadMeshPrimitiveAsync;
  88490. private _extensionsLoadMaterialAsync;
  88491. private _extensionsCreateMaterial;
  88492. private _extensionsLoadMaterialPropertiesAsync;
  88493. private _extensionsLoadTextureInfoAsync;
  88494. private _extensionsLoadTextureAsync;
  88495. private _extensionsLoadAnimationAsync;
  88496. private _extensionsLoadSkinAsync;
  88497. private _extensionsLoadUriAsync;
  88498. private _extensionsLoadBufferViewAsync;
  88499. private _extensionsLoadBufferAsync;
  88500. /**
  88501. * Helper method called by a loader extension to load an glTF extension.
  88502. * @param context The context when loading the asset
  88503. * @param property The glTF property to load the extension from
  88504. * @param extensionName The name of the extension to load
  88505. * @param actionAsync The action to run
  88506. * @returns The promise returned by actionAsync or null if the extension does not exist
  88507. */
  88508. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  88509. /**
  88510. * Helper method called by a loader extension to load a glTF extra.
  88511. * @param context The context when loading the asset
  88512. * @param property The glTF property to load the extra from
  88513. * @param extensionName The name of the extension to load
  88514. * @param actionAsync The action to run
  88515. * @returns The promise returned by actionAsync or null if the extra does not exist
  88516. */
  88517. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  88518. /**
  88519. * Checks for presence of an extension.
  88520. * @param name The name of the extension to check
  88521. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  88522. */
  88523. isExtensionUsed(name: string): boolean;
  88524. /**
  88525. * Increments the indentation level and logs a message.
  88526. * @param message The message to log
  88527. */
  88528. logOpen(message: string): void;
  88529. /**
  88530. * Decrements the indentation level.
  88531. */
  88532. logClose(): void;
  88533. /**
  88534. * Logs a message
  88535. * @param message The message to log
  88536. */
  88537. log(message: string): void;
  88538. /**
  88539. * Starts a performance counter.
  88540. * @param counterName The name of the performance counter
  88541. */
  88542. startPerformanceCounter(counterName: string): void;
  88543. /**
  88544. * Ends a performance counter.
  88545. * @param counterName The name of the performance counter
  88546. */
  88547. endPerformanceCounter(counterName: string): void;
  88548. }
  88549. }
  88550. declare module BABYLON.GLTF2.Loader.Extensions {
  88551. /** @hidden */
  88552. interface IEXTLightsImageBased_LightImageBased {
  88553. _babylonTexture?: BaseTexture;
  88554. _loaded?: Promise<void>;
  88555. }
  88556. /**
  88557. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  88558. */
  88559. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  88560. /**
  88561. * The name of this extension.
  88562. */
  88563. readonly name: string;
  88564. /**
  88565. * Defines whether this extension is enabled.
  88566. */
  88567. enabled: boolean;
  88568. private _loader;
  88569. private _lights?;
  88570. /** @hidden */
  88571. constructor(loader: GLTFLoader);
  88572. /** @hidden */
  88573. dispose(): void;
  88574. /** @hidden */
  88575. onLoading(): void;
  88576. /** @hidden */
  88577. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  88578. private _loadLightAsync;
  88579. }
  88580. }
  88581. declare module BABYLON.GLTF2.Loader.Extensions {
  88582. /**
  88583. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  88584. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  88585. * !!! Experimental Extension Subject to Changes !!!
  88586. */
  88587. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  88588. /**
  88589. * The name of this extension.
  88590. */
  88591. readonly name: string;
  88592. /**
  88593. * Defines whether this extension is enabled.
  88594. */
  88595. enabled: boolean;
  88596. private _loader;
  88597. /** @hidden */
  88598. constructor(loader: GLTFLoader);
  88599. /** @hidden */
  88600. dispose(): void;
  88601. /** @hidden */
  88602. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88603. }
  88604. }
  88605. declare module BABYLON.GLTF2.Loader.Extensions {
  88606. /**
  88607. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression)
  88608. *
  88609. * This extension uses a WebAssembly decoder module from https://github.com/zeux/meshoptimizer/tree/master/js
  88610. */
  88611. export class EXT_meshopt_compression implements IGLTFLoaderExtension {
  88612. /**
  88613. * The name of this extension.
  88614. */
  88615. readonly name: string;
  88616. /**
  88617. * Defines whether this extension is enabled.
  88618. */
  88619. enabled: boolean;
  88620. /**
  88621. * Path to decoder module; defaults to https://preview.babylonjs.com/meshopt_decoder.js
  88622. */
  88623. static DecoderPath: string;
  88624. private _loader;
  88625. private _decoderPromise?;
  88626. /** @hidden */
  88627. constructor(loader: GLTFLoader);
  88628. /** @hidden */
  88629. dispose(): void;
  88630. /** @hidden */
  88631. loadBufferViewAsync(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  88632. }
  88633. }
  88634. declare module BABYLON.GLTF2.Loader.Extensions {
  88635. /**
  88636. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  88637. */
  88638. export class EXT_texture_webp implements IGLTFLoaderExtension {
  88639. /** The name of this extension. */
  88640. readonly name: string;
  88641. /** Defines whether this extension is enabled. */
  88642. enabled: boolean;
  88643. private _loader;
  88644. /** @hidden */
  88645. constructor(loader: GLTFLoader);
  88646. /** @hidden */
  88647. dispose(): void;
  88648. /** @hidden */
  88649. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88650. }
  88651. }
  88652. declare module BABYLON.GLTF2.Loader.Extensions {
  88653. /**
  88654. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  88655. */
  88656. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  88657. /**
  88658. * The name of this extension.
  88659. */
  88660. readonly name: string;
  88661. /**
  88662. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  88663. */
  88664. dracoCompression?: DracoCompression;
  88665. /**
  88666. * Defines whether this extension is enabled.
  88667. */
  88668. enabled: boolean;
  88669. private _loader;
  88670. /** @hidden */
  88671. constructor(loader: GLTFLoader);
  88672. /** @hidden */
  88673. dispose(): void;
  88674. /** @hidden */
  88675. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  88676. }
  88677. }
  88678. declare module BABYLON.GLTF2.Loader.Extensions {
  88679. /**
  88680. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  88681. */
  88682. export class KHR_lights implements IGLTFLoaderExtension {
  88683. /**
  88684. * The name of this extension.
  88685. */
  88686. readonly name: string;
  88687. /**
  88688. * Defines whether this extension is enabled.
  88689. */
  88690. enabled: boolean;
  88691. private _loader;
  88692. private _lights?;
  88693. /** @hidden */
  88694. constructor(loader: GLTFLoader);
  88695. /** @hidden */
  88696. dispose(): void;
  88697. /** @hidden */
  88698. onLoading(): void;
  88699. /** @hidden */
  88700. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88701. }
  88702. }
  88703. declare module BABYLON.GLTF2.Loader.Extensions {
  88704. /**
  88705. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  88706. */
  88707. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  88708. /**
  88709. * The name of this extension.
  88710. */
  88711. readonly name: string;
  88712. /**
  88713. * Defines whether this extension is enabled.
  88714. */
  88715. enabled: boolean;
  88716. /**
  88717. * Defines a number that determines the order the extensions are applied.
  88718. */
  88719. order: number;
  88720. private _loader;
  88721. /** @hidden */
  88722. constructor(loader: GLTFLoader);
  88723. /** @hidden */
  88724. dispose(): void;
  88725. /** @hidden */
  88726. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88727. private _loadSpecularGlossinessPropertiesAsync;
  88728. }
  88729. }
  88730. declare module BABYLON.GLTF2.Loader.Extensions {
  88731. /**
  88732. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  88733. */
  88734. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  88735. /**
  88736. * The name of this extension.
  88737. */
  88738. readonly name: string;
  88739. /**
  88740. * Defines whether this extension is enabled.
  88741. */
  88742. enabled: boolean;
  88743. /**
  88744. * Defines a number that determines the order the extensions are applied.
  88745. */
  88746. order: number;
  88747. private _loader;
  88748. /** @hidden */
  88749. constructor(loader: GLTFLoader);
  88750. /** @hidden */
  88751. dispose(): void;
  88752. /** @hidden */
  88753. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88754. private _loadUnlitPropertiesAsync;
  88755. }
  88756. }
  88757. declare module BABYLON.GLTF2.Loader.Extensions {
  88758. /**
  88759. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  88760. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  88761. */
  88762. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  88763. /**
  88764. * The name of this extension.
  88765. */
  88766. readonly name: string;
  88767. /**
  88768. * Defines whether this extension is enabled.
  88769. */
  88770. enabled: boolean;
  88771. /**
  88772. * Defines a number that determines the order the extensions are applied.
  88773. */
  88774. order: number;
  88775. private _loader;
  88776. /** @hidden */
  88777. constructor(loader: GLTFLoader);
  88778. /** @hidden */
  88779. dispose(): void;
  88780. /** @hidden */
  88781. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88782. private _loadClearCoatPropertiesAsync;
  88783. }
  88784. }
  88785. declare module BABYLON.GLTF2.Loader.Extensions {
  88786. /**
  88787. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_sheen/README.md)
  88788. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  88789. * !!! Experimental Extension Subject to Changes !!!
  88790. */
  88791. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  88792. /**
  88793. * The name of this extension.
  88794. */
  88795. readonly name: string;
  88796. /**
  88797. * Defines whether this extension is enabled.
  88798. */
  88799. enabled: boolean;
  88800. /**
  88801. * Defines a number that determines the order the extensions are applied.
  88802. */
  88803. order: number;
  88804. private _loader;
  88805. /** @hidden */
  88806. constructor(loader: GLTFLoader);
  88807. /** @hidden */
  88808. dispose(): void;
  88809. /** @hidden */
  88810. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88811. private _loadSheenPropertiesAsync;
  88812. }
  88813. }
  88814. declare module BABYLON.GLTF2.Loader.Extensions {
  88815. /**
  88816. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  88817. * !!! Experimental Extension Subject to Changes !!!
  88818. */
  88819. export class KHR_materials_specular implements IGLTFLoaderExtension {
  88820. /**
  88821. * The name of this extension.
  88822. */
  88823. readonly name: string;
  88824. /**
  88825. * Defines whether this extension is enabled.
  88826. */
  88827. enabled: boolean;
  88828. /**
  88829. * Defines a number that determines the order the extensions are applied.
  88830. */
  88831. order: number;
  88832. private _loader;
  88833. /** @hidden */
  88834. constructor(loader: GLTFLoader);
  88835. /** @hidden */
  88836. dispose(): void;
  88837. /** @hidden */
  88838. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88839. private _loadSpecularPropertiesAsync;
  88840. }
  88841. }
  88842. declare module BABYLON.GLTF2.Loader.Extensions {
  88843. /**
  88844. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  88845. * !!! Experimental Extension Subject to Changes !!!
  88846. */
  88847. export class KHR_materials_ior implements IGLTFLoaderExtension {
  88848. /**
  88849. * Default ior Value from the spec.
  88850. */
  88851. private static readonly _DEFAULT_IOR;
  88852. /**
  88853. * The name of this extension.
  88854. */
  88855. readonly name: string;
  88856. /**
  88857. * Defines whether this extension is enabled.
  88858. */
  88859. enabled: boolean;
  88860. /**
  88861. * Defines a number that determines the order the extensions are applied.
  88862. */
  88863. order: number;
  88864. private _loader;
  88865. /** @hidden */
  88866. constructor(loader: GLTFLoader);
  88867. /** @hidden */
  88868. dispose(): void;
  88869. /** @hidden */
  88870. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88871. private _loadIorPropertiesAsync;
  88872. }
  88873. }
  88874. declare module BABYLON.GLTF2.Loader.Extensions {
  88875. /**
  88876. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_variants/README.md)
  88877. */
  88878. export class KHR_materials_variants implements IGLTFLoaderExtension {
  88879. /**
  88880. * The name of this extension.
  88881. */
  88882. readonly name: string;
  88883. /**
  88884. * Defines whether this extension is enabled.
  88885. */
  88886. enabled: boolean;
  88887. private _loader;
  88888. private _variants?;
  88889. /** @hidden */
  88890. constructor(loader: GLTFLoader);
  88891. /** @hidden */
  88892. dispose(): void;
  88893. /**
  88894. * Gets the list of available variant names for this asset.
  88895. * @param rootMesh The glTF root mesh
  88896. * @returns the list of all the variant names for this model
  88897. */
  88898. static GetAvailableVariants(rootMesh: Mesh): string[];
  88899. /**
  88900. * Gets the list of available variant names for this asset.
  88901. * @param rootMesh The glTF root mesh
  88902. * @returns the list of all the variant names for this model
  88903. */
  88904. getAvailableVariants(rootMesh: Mesh): string[];
  88905. /**
  88906. * Select a variant given a variant name or a list of variant names.
  88907. * @param rootMesh The glTF root mesh
  88908. * @param variantName The variant name(s) to select.
  88909. */
  88910. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  88911. /**
  88912. * Select a variant given a variant name or a list of variant names.
  88913. * @param rootMesh The glTF root mesh
  88914. * @param variantName The variant name(s) to select.
  88915. */
  88916. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  88917. /**
  88918. * Reset back to the original before selecting a variant.
  88919. * @param rootMesh The glTF root mesh
  88920. */
  88921. static Reset(rootMesh: Mesh): void;
  88922. /**
  88923. * Reset back to the original before selecting a variant.
  88924. * @param rootMesh The glTF root mesh
  88925. */
  88926. reset(rootMesh: Mesh): void;
  88927. /**
  88928. * Gets the last selected variant name(s) or null if original.
  88929. * @param rootMesh The glTF root mesh
  88930. * @returns The selected variant name(s).
  88931. */
  88932. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  88933. /**
  88934. * Gets the last selected variant name(s) or null if original.
  88935. * @param rootMesh The glTF root mesh
  88936. * @returns The selected variant name(s).
  88937. */
  88938. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  88939. private static _GetExtensionMetadata;
  88940. /** @hidden */
  88941. onLoading(): void;
  88942. /** @hidden */
  88943. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  88944. }
  88945. }
  88946. declare module BABYLON.GLTF2.Loader.Extensions {
  88947. /**
  88948. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_transmission/README.md)
  88949. */
  88950. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  88951. /**
  88952. * The name of this extension.
  88953. */
  88954. readonly name: string;
  88955. /**
  88956. * Defines whether this extension is enabled.
  88957. */
  88958. enabled: boolean;
  88959. /**
  88960. * Defines a number that determines the order the extensions are applied.
  88961. */
  88962. order: number;
  88963. private _loader;
  88964. /** @hidden */
  88965. constructor(loader: GLTFLoader);
  88966. /** @hidden */
  88967. dispose(): void;
  88968. /** @hidden */
  88969. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88970. private _loadTransparentPropertiesAsync;
  88971. }
  88972. }
  88973. declare module BABYLON.GLTF2.Loader.Extensions {
  88974. /**
  88975. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
  88976. * !!! Experimental Extension Subject to Changes !!!
  88977. */
  88978. export class KHR_materials_translucency implements IGLTFLoaderExtension {
  88979. /**
  88980. * The name of this extension.
  88981. */
  88982. readonly name: string;
  88983. /**
  88984. * Defines whether this extension is enabled.
  88985. */
  88986. enabled: boolean;
  88987. /**
  88988. * Defines a number that determines the order the extensions are applied.
  88989. */
  88990. order: number;
  88991. private _loader;
  88992. /** @hidden */
  88993. constructor(loader: GLTFLoader);
  88994. /** @hidden */
  88995. dispose(): void;
  88996. /** @hidden */
  88997. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88998. private _loadTranslucentPropertiesAsync;
  88999. }
  89000. }
  89001. declare module BABYLON.GLTF2.Loader.Extensions {
  89002. /**
  89003. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  89004. */
  89005. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  89006. /**
  89007. * The name of this extension.
  89008. */
  89009. readonly name: string;
  89010. /**
  89011. * Defines whether this extension is enabled.
  89012. */
  89013. enabled: boolean;
  89014. /** @hidden */
  89015. constructor(loader: GLTFLoader);
  89016. /** @hidden */
  89017. dispose(): void;
  89018. }
  89019. }
  89020. declare module BABYLON.GLTF2.Loader.Extensions {
  89021. /**
  89022. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  89023. * !!! Experimental Extension Subject to Changes !!!
  89024. */
  89025. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  89026. /** The name of this extension. */
  89027. readonly name: string;
  89028. /** Defines whether this extension is enabled. */
  89029. enabled: boolean;
  89030. private _loader;
  89031. /** @hidden */
  89032. constructor(loader: GLTFLoader);
  89033. /** @hidden */
  89034. dispose(): void;
  89035. /** @hidden */
  89036. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  89037. }
  89038. }
  89039. declare module BABYLON.GLTF2.Loader.Extensions {
  89040. /**
  89041. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  89042. */
  89043. export class KHR_texture_transform implements IGLTFLoaderExtension {
  89044. /**
  89045. * The name of this extension.
  89046. */
  89047. readonly name: string;
  89048. /**
  89049. * Defines whether this extension is enabled.
  89050. */
  89051. enabled: boolean;
  89052. private _loader;
  89053. /** @hidden */
  89054. constructor(loader: GLTFLoader);
  89055. /** @hidden */
  89056. dispose(): void;
  89057. /** @hidden */
  89058. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  89059. }
  89060. }
  89061. declare module BABYLON.GLTF2.Loader.Extensions {
  89062. /**
  89063. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1893)
  89064. * !!! Experimental Extension Subject to Changes !!!
  89065. */
  89066. export class KHR_xmp_json_ld implements IGLTFLoaderExtension {
  89067. /**
  89068. * The name of this extension.
  89069. */
  89070. readonly name: string;
  89071. /**
  89072. * Defines whether this extension is enabled.
  89073. */
  89074. enabled: boolean;
  89075. /**
  89076. * Defines a number that determines the order the extensions are applied.
  89077. */
  89078. order: number;
  89079. private _loader;
  89080. /** @hidden */
  89081. constructor(loader: GLTFLoader);
  89082. /** @hidden */
  89083. dispose(): void;
  89084. /**
  89085. * Called after the loader state changes to LOADING.
  89086. */
  89087. onLoading(): void;
  89088. }
  89089. }
  89090. declare module BABYLON.GLTF2.Loader.Extensions {
  89091. /**
  89092. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  89093. */
  89094. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  89095. /**
  89096. * The name of this extension.
  89097. */
  89098. readonly name: string;
  89099. /**
  89100. * Defines whether this extension is enabled.
  89101. */
  89102. enabled: boolean;
  89103. private _loader;
  89104. private _clips;
  89105. private _emitters;
  89106. /** @hidden */
  89107. constructor(loader: GLTFLoader);
  89108. /** @hidden */
  89109. dispose(): void;
  89110. /** @hidden */
  89111. onLoading(): void;
  89112. /** @hidden */
  89113. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  89114. /** @hidden */
  89115. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89116. /** @hidden */
  89117. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  89118. private _loadClipAsync;
  89119. private _loadEmitterAsync;
  89120. private _getEventAction;
  89121. private _loadAnimationEventAsync;
  89122. }
  89123. }
  89124. declare module BABYLON.GLTF2.Loader.Extensions {
  89125. /**
  89126. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  89127. */
  89128. export class MSFT_lod implements IGLTFLoaderExtension {
  89129. /**
  89130. * The name of this extension.
  89131. */
  89132. readonly name: string;
  89133. /**
  89134. * Defines whether this extension is enabled.
  89135. */
  89136. enabled: boolean;
  89137. /**
  89138. * Defines a number that determines the order the extensions are applied.
  89139. */
  89140. order: number;
  89141. /**
  89142. * Maximum number of LODs to load, starting from the lowest LOD.
  89143. */
  89144. maxLODsToLoad: number;
  89145. /**
  89146. * Observable raised when all node LODs of one level are loaded.
  89147. * The event data is the index of the loaded LOD starting from zero.
  89148. * Dispose the loader to cancel the loading of the next level of LODs.
  89149. */
  89150. onNodeLODsLoadedObservable: Observable<number>;
  89151. /**
  89152. * Observable raised when all material LODs of one level are loaded.
  89153. * The event data is the index of the loaded LOD starting from zero.
  89154. * Dispose the loader to cancel the loading of the next level of LODs.
  89155. */
  89156. onMaterialLODsLoadedObservable: Observable<number>;
  89157. private _loader;
  89158. private _bufferLODs;
  89159. private _nodeIndexLOD;
  89160. private _nodeSignalLODs;
  89161. private _nodePromiseLODs;
  89162. private _nodeBufferLODs;
  89163. private _materialIndexLOD;
  89164. private _materialSignalLODs;
  89165. private _materialPromiseLODs;
  89166. private _materialBufferLODs;
  89167. /** @hidden */
  89168. constructor(loader: GLTFLoader);
  89169. /** @hidden */
  89170. dispose(): void;
  89171. /** @hidden */
  89172. onReady(): void;
  89173. /** @hidden */
  89174. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  89175. /** @hidden */
  89176. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89177. /** @hidden */
  89178. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  89179. /** @hidden */
  89180. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  89181. /** @hidden */
  89182. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  89183. private _loadBufferLOD;
  89184. /**
  89185. * Gets an array of LOD properties from lowest to highest.
  89186. */
  89187. private _getLODs;
  89188. private _disposeTransformNode;
  89189. private _disposeMaterials;
  89190. }
  89191. }
  89192. declare module BABYLON.GLTF2.Loader.Extensions {
  89193. /** @hidden */
  89194. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  89195. readonly name: string;
  89196. enabled: boolean;
  89197. private _loader;
  89198. constructor(loader: GLTFLoader);
  89199. dispose(): void;
  89200. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89201. }
  89202. }
  89203. declare module BABYLON.GLTF2.Loader.Extensions {
  89204. /** @hidden */
  89205. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  89206. readonly name: string;
  89207. enabled: boolean;
  89208. private _loader;
  89209. constructor(loader: GLTFLoader);
  89210. dispose(): void;
  89211. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89212. }
  89213. }
  89214. declare module BABYLON.GLTF2.Loader.Extensions {
  89215. /**
  89216. * Store glTF extras (if present) in BJS objects' metadata
  89217. */
  89218. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  89219. /**
  89220. * The name of this extension.
  89221. */
  89222. readonly name: string;
  89223. /**
  89224. * Defines whether this extension is enabled.
  89225. */
  89226. enabled: boolean;
  89227. private _loader;
  89228. private _assignExtras;
  89229. /** @hidden */
  89230. constructor(loader: GLTFLoader);
  89231. /** @hidden */
  89232. dispose(): void;
  89233. /** @hidden */
  89234. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89235. /** @hidden */
  89236. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  89237. /** @hidden */
  89238. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  89239. }
  89240. }
  89241. declare module BABYLON {
  89242. /**
  89243. * Class reading and parsing the MTL file bundled with the obj file.
  89244. */
  89245. export class MTLFileLoader {
  89246. /**
  89247. * Invert Y-Axis of referenced textures on load
  89248. */
  89249. static INVERT_TEXTURE_Y: boolean;
  89250. /**
  89251. * All material loaded from the mtl will be set here
  89252. */
  89253. materials: StandardMaterial[];
  89254. /**
  89255. * This function will read the mtl file and create each material described inside
  89256. * This function could be improve by adding :
  89257. * -some component missing (Ni, Tf...)
  89258. * -including the specific options available
  89259. *
  89260. * @param scene defines the scene the material will be created in
  89261. * @param data defines the mtl data to parse
  89262. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  89263. * @param forAssetContainer defines if the material should be registered in the scene
  89264. */
  89265. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  89266. /**
  89267. * Gets the texture for the material.
  89268. *
  89269. * If the material is imported from input file,
  89270. * We sanitize the url to ensure it takes the textre from aside the material.
  89271. *
  89272. * @param rootUrl The root url to load from
  89273. * @param value The value stored in the mtl
  89274. * @return The Texture
  89275. */
  89276. private static _getTexture;
  89277. }
  89278. }
  89279. declare module BABYLON {
  89280. /**
  89281. * Options for loading OBJ/MTL files
  89282. */
  89283. type MeshLoadOptions = {
  89284. /**
  89285. * Defines if UVs are optimized by default during load.
  89286. */
  89287. OptimizeWithUV: boolean;
  89288. /**
  89289. * Defines custom scaling of UV coordinates of loaded meshes.
  89290. */
  89291. UVScaling: Vector2;
  89292. /**
  89293. * Invert model on y-axis (does a model scaling inversion)
  89294. */
  89295. InvertY: boolean;
  89296. /**
  89297. * Invert Y-Axis of referenced textures on load
  89298. */
  89299. InvertTextureY: boolean;
  89300. /**
  89301. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  89302. */
  89303. ImportVertexColors: boolean;
  89304. /**
  89305. * Compute the normals for the model, even if normals are present in the file.
  89306. */
  89307. ComputeNormals: boolean;
  89308. /**
  89309. * 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.
  89310. * Using OptimizehNormals = true will help smoothing the lighting by averaging the normals of those vertices.
  89311. */
  89312. OptimizeNormals: boolean;
  89313. /**
  89314. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  89315. */
  89316. SkipMaterials: boolean;
  89317. /**
  89318. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  89319. */
  89320. MaterialLoadingFailsSilently: boolean;
  89321. };
  89322. /**
  89323. * OBJ file type loader.
  89324. * This is a babylon scene loader plugin.
  89325. */
  89326. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  89327. /**
  89328. * Defines if UVs are optimized by default during load.
  89329. */
  89330. static OPTIMIZE_WITH_UV: boolean;
  89331. /**
  89332. * Invert model on y-axis (does a model scaling inversion)
  89333. */
  89334. static INVERT_Y: boolean;
  89335. /**
  89336. * Invert Y-Axis of referenced textures on load
  89337. */
  89338. static get INVERT_TEXTURE_Y(): boolean;
  89339. static set INVERT_TEXTURE_Y(value: boolean);
  89340. /**
  89341. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  89342. */
  89343. static IMPORT_VERTEX_COLORS: boolean;
  89344. /**
  89345. * Compute the normals for the model, even if normals are present in the file.
  89346. */
  89347. static COMPUTE_NORMALS: boolean;
  89348. /**
  89349. * 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.
  89350. * Using OptimizehNormals = true will help smoothing the lighting by averaging the normals of those vertices.
  89351. */
  89352. static OPTIMIZE_NORMALS: boolean;
  89353. /**
  89354. * Defines custom scaling of UV coordinates of loaded meshes.
  89355. */
  89356. static UV_SCALING: Vector2;
  89357. /**
  89358. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  89359. */
  89360. static SKIP_MATERIALS: boolean;
  89361. /**
  89362. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  89363. *
  89364. * Defaults to true for backwards compatibility.
  89365. */
  89366. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  89367. /**
  89368. * Defines the name of the plugin.
  89369. */
  89370. name: string;
  89371. /**
  89372. * Defines the extension the plugin is able to load.
  89373. */
  89374. extensions: string;
  89375. /** @hidden */
  89376. obj: RegExp;
  89377. /** @hidden */
  89378. group: RegExp;
  89379. /** @hidden */
  89380. mtllib: RegExp;
  89381. /** @hidden */
  89382. usemtl: RegExp;
  89383. /** @hidden */
  89384. smooth: RegExp;
  89385. /** @hidden */
  89386. vertexPattern: RegExp;
  89387. /** @hidden */
  89388. normalPattern: RegExp;
  89389. /** @hidden */
  89390. uvPattern: RegExp;
  89391. /** @hidden */
  89392. facePattern1: RegExp;
  89393. /** @hidden */
  89394. facePattern2: RegExp;
  89395. /** @hidden */
  89396. facePattern3: RegExp;
  89397. /** @hidden */
  89398. facePattern4: RegExp;
  89399. /** @hidden */
  89400. facePattern5: RegExp;
  89401. private _forAssetContainer;
  89402. private _meshLoadOptions;
  89403. /**
  89404. * Creates loader for .OBJ files
  89405. *
  89406. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  89407. */
  89408. constructor(meshLoadOptions?: MeshLoadOptions);
  89409. private static get currentMeshLoadOptions();
  89410. /**
  89411. * Calls synchronously the MTL file attached to this obj.
  89412. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  89413. * Without this function materials are not displayed in the first frame (but displayed after).
  89414. * In consequence it is impossible to get material information in your HTML file
  89415. *
  89416. * @param url The URL of the MTL file
  89417. * @param rootUrl
  89418. * @param onSuccess Callback function to be called when the MTL file is loaded
  89419. * @private
  89420. */
  89421. private _loadMTL;
  89422. /**
  89423. * Instantiates a OBJ file loader plugin.
  89424. * @returns the created plugin
  89425. */
  89426. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  89427. /**
  89428. * If the data string can be loaded directly.
  89429. *
  89430. * @param data string containing the file data
  89431. * @returns if the data can be loaded directly
  89432. */
  89433. canDirectLoad(data: string): boolean;
  89434. /**
  89435. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  89436. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  89437. * @param scene the scene the meshes should be added to
  89438. * @param data the OBJ data to load
  89439. * @param rootUrl root url to load from
  89440. * @param onProgress event that fires when loading progress has occured
  89441. * @param fileName Defines the name of the file to load
  89442. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  89443. */
  89444. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  89445. /**
  89446. * Imports all objects from the loaded OBJ data and adds them to the scene
  89447. * @param scene the scene the objects should be added to
  89448. * @param data the OBJ data to load
  89449. * @param rootUrl root url to load from
  89450. * @param onProgress event that fires when loading progress has occured
  89451. * @param fileName Defines the name of the file to load
  89452. * @returns a promise which completes when objects have been loaded to the scene
  89453. */
  89454. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  89455. /**
  89456. * Load into an asset container.
  89457. * @param scene The scene to load into
  89458. * @param data The data to import
  89459. * @param rootUrl The root url for scene and resources
  89460. * @param onProgress The callback when the load progresses
  89461. * @param fileName Defines the name of the file to load
  89462. * @returns The loaded asset container
  89463. */
  89464. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  89465. private _optimizeNormals;
  89466. /**
  89467. * Read the OBJ file and create an Array of meshes.
  89468. * Each mesh contains all information given by the OBJ and the MTL file.
  89469. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  89470. *
  89471. * @param meshesNames
  89472. * @param scene Scene The scene where are displayed the data
  89473. * @param data String The content of the obj file
  89474. * @param rootUrl String The path to the folder
  89475. * @returns Array<AbstractMesh>
  89476. * @private
  89477. */
  89478. private _parseSolid;
  89479. }
  89480. }
  89481. declare module BABYLON {
  89482. /**
  89483. * STL file type loader.
  89484. * This is a babylon scene loader plugin.
  89485. */
  89486. export class STLFileLoader implements ISceneLoaderPlugin {
  89487. /** @hidden */
  89488. solidPattern: RegExp;
  89489. /** @hidden */
  89490. facetsPattern: RegExp;
  89491. /** @hidden */
  89492. normalPattern: RegExp;
  89493. /** @hidden */
  89494. vertexPattern: RegExp;
  89495. /**
  89496. * Defines the name of the plugin.
  89497. */
  89498. name: string;
  89499. /**
  89500. * Defines the extensions the stl loader is able to load.
  89501. * force data to come in as an ArrayBuffer
  89502. * we'll convert to string if it looks like it's an ASCII .stl
  89503. */
  89504. extensions: ISceneLoaderPluginExtensions;
  89505. /**
  89506. * Import meshes into a scene.
  89507. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  89508. * @param scene The scene to import into
  89509. * @param data The data to import
  89510. * @param rootUrl The root url for scene and resources
  89511. * @param meshes The meshes array to import into
  89512. * @param particleSystems The particle systems array to import into
  89513. * @param skeletons The skeletons array to import into
  89514. * @param onError The callback when import fails
  89515. * @returns True if successful or false otherwise
  89516. */
  89517. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  89518. /**
  89519. * Load into a scene.
  89520. * @param scene The scene to load into
  89521. * @param data The data to import
  89522. * @param rootUrl The root url for scene and resources
  89523. * @param onError The callback when import fails
  89524. * @returns true if successful or false otherwise
  89525. */
  89526. load(scene: Scene, data: any, rootUrl: string): boolean;
  89527. /**
  89528. * Load into an asset container.
  89529. * @param scene The scene to load into
  89530. * @param data The data to import
  89531. * @param rootUrl The root url for scene and resources
  89532. * @param onError The callback when import fails
  89533. * @returns The loaded asset container
  89534. */
  89535. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  89536. private _isBinary;
  89537. private _parseBinary;
  89538. private _parseASCII;
  89539. }
  89540. }
  89541. declare module BABYLON {
  89542. /**
  89543. * Class for generating OBJ data from a Babylon scene.
  89544. */
  89545. export class OBJExport {
  89546. /**
  89547. * Exports the geometry of a Mesh array in .OBJ file format (text)
  89548. * @param mesh defines the list of meshes to serialize
  89549. * @param materials defines if materials should be exported
  89550. * @param matlibname defines the name of the associated mtl file
  89551. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  89552. * @returns the OBJ content
  89553. */
  89554. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  89555. /**
  89556. * Exports the material(s) of a mesh in .MTL file format (text)
  89557. * @param mesh defines the mesh to extract the material from
  89558. * @returns the mtl content
  89559. */
  89560. static MTL(mesh: Mesh): string;
  89561. }
  89562. }
  89563. declare module BABYLON {
  89564. /** @hidden */
  89565. export var __IGLTFExporterExtension: number;
  89566. /**
  89567. * Interface for extending the exporter
  89568. * @hidden
  89569. */
  89570. export interface IGLTFExporterExtension {
  89571. /**
  89572. * The name of this extension
  89573. */
  89574. readonly name: string;
  89575. /**
  89576. * Defines whether this extension is enabled
  89577. */
  89578. enabled: boolean;
  89579. /**
  89580. * Defines whether this extension is required
  89581. */
  89582. required: boolean;
  89583. }
  89584. }
  89585. declare module BABYLON.GLTF2.Exporter {
  89586. /** @hidden */
  89587. export var __IGLTFExporterExtensionV2: number;
  89588. /**
  89589. * Interface for a glTF exporter extension
  89590. * @hidden
  89591. */
  89592. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  89593. /**
  89594. * Define this method to modify the default behavior before exporting a texture
  89595. * @param context The context when loading the asset
  89596. * @param babylonTexture The Babylon.js texture
  89597. * @param mimeType The mime-type of the generated image
  89598. * @returns A promise that resolves with the exported texture
  89599. */
  89600. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  89601. /**
  89602. * Define this method to get notified when a texture info is created
  89603. * @param context The context when loading the asset
  89604. * @param textureInfo The glTF texture info
  89605. * @param babylonTexture The Babylon.js texture
  89606. */
  89607. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  89608. /**
  89609. * Define this method to modify the default behavior when exporting texture info
  89610. * @param context The context when loading the asset
  89611. * @param meshPrimitive glTF mesh primitive
  89612. * @param babylonSubMesh Babylon submesh
  89613. * @param binaryWriter glTF serializer binary writer instance
  89614. * @returns nullable IMeshPrimitive promise
  89615. */
  89616. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  89617. /**
  89618. * Define this method to modify the default behavior when exporting a node
  89619. * @param context The context when exporting the node
  89620. * @param node glTF node
  89621. * @param babylonNode BabylonJS node
  89622. * @returns nullable INode promise
  89623. */
  89624. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  89625. [key: number]: number;
  89626. }): Promise<Nullable<INode>>;
  89627. /**
  89628. * Define this method to modify the default behavior when exporting a material
  89629. * @param material glTF material
  89630. * @param babylonMaterial BabylonJS material
  89631. * @returns nullable IMaterial promise
  89632. */
  89633. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  89634. /**
  89635. * Define this method to return additional textures to export from a material
  89636. * @param material glTF material
  89637. * @param babylonMaterial BabylonJS material
  89638. * @returns List of textures
  89639. */
  89640. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  89641. /** Gets a boolean indicating that this extension was used */
  89642. wasUsed: boolean;
  89643. /** Gets a boolean indicating that this extension is required for the file to work */
  89644. required: boolean;
  89645. /**
  89646. * Called after the exporter state changes to EXPORTING
  89647. */
  89648. onExporting?(): void;
  89649. }
  89650. }
  89651. declare module BABYLON.GLTF2.Exporter {
  89652. /**
  89653. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  89654. * @hidden
  89655. */
  89656. export class _GLTFMaterialExporter {
  89657. /**
  89658. * Represents the dielectric specular values for R, G and B
  89659. */
  89660. private static readonly _DielectricSpecular;
  89661. /**
  89662. * Allows the maximum specular power to be defined for material calculations
  89663. */
  89664. private static readonly _MaxSpecularPower;
  89665. /**
  89666. * Mapping to store textures
  89667. */
  89668. private _textureMap;
  89669. /**
  89670. * Numeric tolerance value
  89671. */
  89672. private static readonly _Epsilon;
  89673. /**
  89674. * Reference to the glTF Exporter
  89675. */
  89676. private _exporter;
  89677. constructor(exporter: _Exporter);
  89678. /**
  89679. * Specifies if two colors are approximately equal in value
  89680. * @param color1 first color to compare to
  89681. * @param color2 second color to compare to
  89682. * @param epsilon threshold value
  89683. */
  89684. private static FuzzyEquals;
  89685. /**
  89686. * Gets the materials from a Babylon scene and converts them to glTF materials
  89687. * @param scene babylonjs scene
  89688. * @param mimeType texture mime type
  89689. * @param images array of images
  89690. * @param textures array of textures
  89691. * @param materials array of materials
  89692. * @param imageData mapping of texture names to base64 textures
  89693. * @param hasTextureCoords specifies if texture coordinates are present on the material
  89694. */
  89695. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  89696. /**
  89697. * Makes a copy of the glTF material without the texture parameters
  89698. * @param originalMaterial original glTF material
  89699. * @returns glTF material without texture parameters
  89700. */
  89701. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  89702. /**
  89703. * Specifies if the material has any texture parameters present
  89704. * @param material glTF Material
  89705. * @returns boolean specifying if texture parameters are present
  89706. */
  89707. _hasTexturesPresent(material: IMaterial): boolean;
  89708. /**
  89709. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  89710. * @param babylonStandardMaterial
  89711. * @returns glTF Metallic Roughness Material representation
  89712. */
  89713. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  89714. /**
  89715. * Computes the metallic factor
  89716. * @param diffuse diffused value
  89717. * @param specular specular value
  89718. * @param oneMinusSpecularStrength one minus the specular strength
  89719. * @returns metallic value
  89720. */
  89721. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  89722. /**
  89723. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  89724. * @param glTFMaterial glTF material
  89725. * @param babylonMaterial Babylon material
  89726. */
  89727. private static _SetAlphaMode;
  89728. /**
  89729. * Converts a Babylon Standard Material to a glTF Material
  89730. * @param babylonStandardMaterial BJS Standard Material
  89731. * @param mimeType mime type to use for the textures
  89732. * @param images array of glTF image interfaces
  89733. * @param textures array of glTF texture interfaces
  89734. * @param materials array of glTF material interfaces
  89735. * @param imageData map of image file name to data
  89736. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89737. */
  89738. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89739. private _finishMaterial;
  89740. /**
  89741. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  89742. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  89743. * @param mimeType mime type to use for the textures
  89744. * @param images array of glTF image interfaces
  89745. * @param textures array of glTF texture interfaces
  89746. * @param materials array of glTF material interfaces
  89747. * @param imageData map of image file name to data
  89748. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89749. */
  89750. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89751. /**
  89752. * Converts an image typed array buffer to a base64 image
  89753. * @param buffer typed array buffer
  89754. * @param width width of the image
  89755. * @param height height of the image
  89756. * @param mimeType mimetype of the image
  89757. * @returns base64 image string
  89758. */
  89759. private _createBase64FromCanvasAsync;
  89760. /**
  89761. * Generates a white texture based on the specified width and height
  89762. * @param width width of the texture in pixels
  89763. * @param height height of the texture in pixels
  89764. * @param scene babylonjs scene
  89765. * @returns white texture
  89766. */
  89767. private _createWhiteTexture;
  89768. /**
  89769. * 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
  89770. * @param texture1 first texture to resize
  89771. * @param texture2 second texture to resize
  89772. * @param scene babylonjs scene
  89773. * @returns resized textures or null
  89774. */
  89775. private _resizeTexturesToSameDimensions;
  89776. /**
  89777. * Converts an array of pixels to a Float32Array
  89778. * Throws an error if the pixel format is not supported
  89779. * @param pixels - array buffer containing pixel values
  89780. * @returns Float32 of pixels
  89781. */
  89782. private _convertPixelArrayToFloat32;
  89783. /**
  89784. * Convert Specular Glossiness Textures to Metallic Roughness
  89785. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  89786. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  89787. * @param diffuseTexture texture used to store diffuse information
  89788. * @param specularGlossinessTexture texture used to store specular and glossiness information
  89789. * @param factors specular glossiness material factors
  89790. * @param mimeType the mime type to use for the texture
  89791. * @returns pbr metallic roughness interface or null
  89792. */
  89793. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  89794. /**
  89795. * Converts specular glossiness material properties to metallic roughness
  89796. * @param specularGlossiness interface with specular glossiness material properties
  89797. * @returns interface with metallic roughness material properties
  89798. */
  89799. private _convertSpecularGlossinessToMetallicRoughness;
  89800. /**
  89801. * Calculates the surface reflectance, independent of lighting conditions
  89802. * @param color Color source to calculate brightness from
  89803. * @returns number representing the perceived brightness, or zero if color is undefined
  89804. */
  89805. private _getPerceivedBrightness;
  89806. /**
  89807. * Returns the maximum color component value
  89808. * @param color
  89809. * @returns maximum color component value, or zero if color is null or undefined
  89810. */
  89811. private _getMaxComponent;
  89812. /**
  89813. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  89814. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  89815. * @param mimeType mime type to use for the textures
  89816. * @param images array of glTF image interfaces
  89817. * @param textures array of glTF texture interfaces
  89818. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  89819. * @param imageData map of image file name to data
  89820. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89821. * @returns glTF PBR Metallic Roughness factors
  89822. */
  89823. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  89824. private _getGLTFTextureSampler;
  89825. private _getGLTFTextureWrapMode;
  89826. private _getGLTFTextureWrapModesSampler;
  89827. /**
  89828. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  89829. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  89830. * @param mimeType mime type to use for the textures
  89831. * @param images array of glTF image interfaces
  89832. * @param textures array of glTF texture interfaces
  89833. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  89834. * @param imageData map of image file name to data
  89835. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89836. * @returns glTF PBR Metallic Roughness factors
  89837. */
  89838. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  89839. /**
  89840. * Converts a Babylon PBR Base Material to a glTF Material
  89841. * @param babylonPBRMaterial BJS PBR Base Material
  89842. * @param mimeType mime type to use for the textures
  89843. * @param images array of glTF image interfaces
  89844. * @param textures array of glTF texture interfaces
  89845. * @param materials array of glTF material interfaces
  89846. * @param imageData map of image file name to data
  89847. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89848. */
  89849. _convertPBRMaterialAsync(babylonPBRMaterial: PBRBaseMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89850. private setMetallicRoughnessPbrMaterial;
  89851. private getPixelsFromTexture;
  89852. /**
  89853. * Extracts a texture from a Babylon texture into file data and glTF data
  89854. * @param babylonTexture Babylon texture to extract
  89855. * @param mimeType Mime Type of the babylonTexture
  89856. * @return glTF texture info, or null if the texture format is not supported
  89857. */
  89858. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  89859. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  89860. /**
  89861. * Builds a texture from base64 string
  89862. * @param base64Texture base64 texture string
  89863. * @param baseTextureName Name to use for the texture
  89864. * @param mimeType image mime type for the texture
  89865. * @param images array of images
  89866. * @param textures array of textures
  89867. * @param imageData map of image data
  89868. * @returns glTF texture info, or null if the texture format is not supported
  89869. */
  89870. private _getTextureInfoFromBase64;
  89871. }
  89872. }
  89873. declare module BABYLON {
  89874. /**
  89875. * Class for holding and downloading glTF file data
  89876. */
  89877. export class GLTFData {
  89878. /**
  89879. * Object which contains the file name as the key and its data as the value
  89880. */
  89881. glTFFiles: {
  89882. [fileName: string]: string | Blob;
  89883. };
  89884. /**
  89885. * Initializes the glTF file object
  89886. */
  89887. constructor();
  89888. /**
  89889. * Downloads the glTF data as files based on their names and data
  89890. */
  89891. downloadFiles(): void;
  89892. }
  89893. }
  89894. declare module BABYLON {
  89895. /**
  89896. * Holds a collection of exporter options and parameters
  89897. */
  89898. export interface IExportOptions {
  89899. /**
  89900. * Function which indicates whether a babylon node should be exported or not
  89901. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  89902. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  89903. */
  89904. shouldExportNode?(node: Node): boolean;
  89905. /**
  89906. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  89907. * @param metadata source metadata to read from
  89908. * @returns the data to store to glTF node extras
  89909. */
  89910. metadataSelector?(metadata: any): any;
  89911. /**
  89912. * The sample rate to bake animation curves
  89913. */
  89914. animationSampleRate?: number;
  89915. /**
  89916. * Begin serialization without waiting for the scene to be ready
  89917. */
  89918. exportWithoutWaitingForScene?: boolean;
  89919. /**
  89920. * Indicates if coordinate system swapping root nodes should be included in export
  89921. */
  89922. includeCoordinateSystemConversionNodes?: boolean;
  89923. }
  89924. /**
  89925. * Class for generating glTF data from a Babylon scene.
  89926. */
  89927. export class GLTF2Export {
  89928. /**
  89929. * Exports the geometry of the scene to .gltf file format asynchronously
  89930. * @param scene Babylon scene with scene hierarchy information
  89931. * @param filePrefix File prefix to use when generating the glTF file
  89932. * @param options Exporter options
  89933. * @returns Returns an object with a .gltf file and associates texture names
  89934. * as keys and their data and paths as values
  89935. */
  89936. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  89937. private static _PreExportAsync;
  89938. private static _PostExportAsync;
  89939. /**
  89940. * Exports the geometry of the scene to .glb file format asychronously
  89941. * @param scene Babylon scene with scene hierarchy information
  89942. * @param filePrefix File prefix to use when generating glb file
  89943. * @param options Exporter options
  89944. * @returns Returns an object with a .glb filename as key and data as value
  89945. */
  89946. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  89947. }
  89948. }
  89949. declare module BABYLON.GLTF2.Exporter {
  89950. /**
  89951. * @hidden
  89952. */
  89953. export class _GLTFUtilities {
  89954. /**
  89955. * Creates a buffer view based on the supplied arguments
  89956. * @param bufferIndex index value of the specified buffer
  89957. * @param byteOffset byte offset value
  89958. * @param byteLength byte length of the bufferView
  89959. * @param byteStride byte distance between conequential elements
  89960. * @param name name of the buffer view
  89961. * @returns bufferView for glTF
  89962. */
  89963. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  89964. /**
  89965. * Creates an accessor based on the supplied arguments
  89966. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  89967. * @param name The name of the accessor
  89968. * @param type The type of the accessor
  89969. * @param componentType The datatype of components in the attribute
  89970. * @param count The number of attributes referenced by this accessor
  89971. * @param byteOffset The offset relative to the start of the bufferView in bytes
  89972. * @param min Minimum value of each component in this attribute
  89973. * @param max Maximum value of each component in this attribute
  89974. * @returns accessor for glTF
  89975. */
  89976. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  89977. /**
  89978. * Calculates the minimum and maximum values of an array of position floats
  89979. * @param positions Positions array of a mesh
  89980. * @param vertexStart Starting vertex offset to calculate min and max values
  89981. * @param vertexCount Number of vertices to check for min and max values
  89982. * @returns min number array and max number array
  89983. */
  89984. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  89985. min: number[];
  89986. max: number[];
  89987. };
  89988. /**
  89989. * Converts a new right-handed Vector3
  89990. * @param vector vector3 array
  89991. * @returns right-handed Vector3
  89992. */
  89993. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  89994. /**
  89995. * Converts a Vector3 to right-handed
  89996. * @param vector Vector3 to convert to right-handed
  89997. */
  89998. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  89999. /**
  90000. * Converts a three element number array to right-handed
  90001. * @param vector number array to convert to right-handed
  90002. */
  90003. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  90004. /**
  90005. * Converts a new right-handed Vector3
  90006. * @param vector vector3 array
  90007. * @returns right-handed Vector3
  90008. */
  90009. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  90010. /**
  90011. * Converts a Vector3 to right-handed
  90012. * @param vector Vector3 to convert to right-handed
  90013. */
  90014. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  90015. /**
  90016. * Converts a three element number array to right-handed
  90017. * @param vector number array to convert to right-handed
  90018. */
  90019. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  90020. /**
  90021. * Converts a Vector4 to right-handed
  90022. * @param vector Vector4 to convert to right-handed
  90023. */
  90024. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  90025. /**
  90026. * Converts a Vector4 to right-handed
  90027. * @param vector Vector4 to convert to right-handed
  90028. */
  90029. static _GetRightHandedArray4FromRef(vector: number[]): void;
  90030. /**
  90031. * Converts a Quaternion to right-handed
  90032. * @param quaternion Source quaternion to convert to right-handed
  90033. */
  90034. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  90035. /**
  90036. * Converts a Quaternion to right-handed
  90037. * @param quaternion Source quaternion to convert to right-handed
  90038. */
  90039. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  90040. static _NormalizeTangentFromRef(tangent: Vector4): void;
  90041. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  90042. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  90043. }
  90044. }
  90045. declare module BABYLON.GLTF2.Exporter {
  90046. /**
  90047. * Converts Babylon Scene into glTF 2.0.
  90048. * @hidden
  90049. */
  90050. export class _Exporter {
  90051. /**
  90052. * Stores the glTF to export
  90053. */
  90054. _glTF: IGLTF;
  90055. /**
  90056. * Stores all generated buffer views, which represents views into the main glTF buffer data
  90057. */
  90058. _bufferViews: IBufferView[];
  90059. /**
  90060. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  90061. */
  90062. _accessors: IAccessor[];
  90063. /**
  90064. * Stores all the generated nodes, which contains transform and/or mesh information per node
  90065. */
  90066. _nodes: INode[];
  90067. /**
  90068. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  90069. */
  90070. private _scenes;
  90071. /**
  90072. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  90073. */
  90074. private _meshes;
  90075. /**
  90076. * Stores all the generated material information, which represents the appearance of each primitive
  90077. */
  90078. _materials: IMaterial[];
  90079. _materialMap: {
  90080. [materialID: number]: number;
  90081. };
  90082. /**
  90083. * Stores all the generated texture information, which is referenced by glTF materials
  90084. */
  90085. _textures: ITexture[];
  90086. /**
  90087. * Stores all the generated image information, which is referenced by glTF textures
  90088. */
  90089. _images: IImage[];
  90090. /**
  90091. * Stores all the texture samplers
  90092. */
  90093. _samplers: ISampler[];
  90094. /**
  90095. * Stores all the generated glTF skins
  90096. */
  90097. _skins: ISkin[];
  90098. /**
  90099. * Stores all the generated animation samplers, which is referenced by glTF animations
  90100. */
  90101. /**
  90102. * Stores the animations for glTF models
  90103. */
  90104. private _animations;
  90105. /**
  90106. * Stores the total amount of bytes stored in the glTF buffer
  90107. */
  90108. private _totalByteLength;
  90109. /**
  90110. * Stores a reference to the Babylon scene containing the source geometry and material information
  90111. */
  90112. _babylonScene: Scene;
  90113. /**
  90114. * Stores a map of the image data, where the key is the file name and the value
  90115. * is the image data
  90116. */
  90117. _imageData: {
  90118. [fileName: string]: {
  90119. data: Uint8Array;
  90120. mimeType: ImageMimeType;
  90121. };
  90122. };
  90123. protected _orderedImageData: Array<{
  90124. data: Uint8Array;
  90125. mimeType: ImageMimeType;
  90126. }>;
  90127. /**
  90128. * Stores a map of the unique id of a node to its index in the node array
  90129. */
  90130. _nodeMap: {
  90131. [key: number]: number;
  90132. };
  90133. /**
  90134. * Specifies if the source Babylon scene was left handed, and needed conversion.
  90135. */
  90136. _convertToRightHandedSystem: boolean;
  90137. /**
  90138. * Specifies if a Babylon node should be converted to right-handed on export
  90139. */
  90140. _convertToRightHandedSystemMap: {
  90141. [nodeId: number]: boolean;
  90142. };
  90143. _includeCoordinateSystemConversionNodes: boolean;
  90144. /**
  90145. * Baked animation sample rate
  90146. */
  90147. private _animationSampleRate;
  90148. private _options;
  90149. private _localEngine;
  90150. _glTFMaterialExporter: _GLTFMaterialExporter;
  90151. private _extensions;
  90152. private static _ExtensionNames;
  90153. private static _ExtensionFactories;
  90154. private _applyExtension;
  90155. private _applyExtensions;
  90156. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  90157. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  90158. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  90159. [key: number]: number;
  90160. }): Promise<Nullable<INode>>;
  90161. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  90162. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  90163. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  90164. private _forEachExtensions;
  90165. private _extensionsOnExporting;
  90166. /**
  90167. * Load glTF serializer extensions
  90168. */
  90169. private _loadExtensions;
  90170. /**
  90171. * Creates a glTF Exporter instance, which can accept optional exporter options
  90172. * @param babylonScene Babylon scene object
  90173. * @param options Options to modify the behavior of the exporter
  90174. */
  90175. constructor(babylonScene: Scene, options?: IExportOptions);
  90176. dispose(): void;
  90177. /**
  90178. * Registers a glTF exporter extension
  90179. * @param name Name of the extension to export
  90180. * @param factory The factory function that creates the exporter extension
  90181. */
  90182. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  90183. /**
  90184. * Un-registers an exporter extension
  90185. * @param name The name fo the exporter extension
  90186. * @returns A boolean indicating whether the extension has been un-registered
  90187. */
  90188. static UnregisterExtension(name: string): boolean;
  90189. private reorderIndicesBasedOnPrimitiveMode;
  90190. /**
  90191. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  90192. * clock-wise during export to glTF
  90193. * @param submesh BabylonJS submesh
  90194. * @param primitiveMode Primitive mode of the mesh
  90195. * @param sideOrientation the winding order of the submesh
  90196. * @param vertexBufferKind The type of vertex attribute
  90197. * @param meshAttributeArray The vertex attribute data
  90198. * @param byteOffset The offset to the binary data
  90199. * @param binaryWriter The binary data for the glTF file
  90200. * @param convertToRightHandedSystem Converts the values to right-handed
  90201. */
  90202. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  90203. /**
  90204. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  90205. * clock-wise during export to glTF
  90206. * @param submesh BabylonJS submesh
  90207. * @param primitiveMode Primitive mode of the mesh
  90208. * @param sideOrientation the winding order of the submesh
  90209. * @param vertexBufferKind The type of vertex attribute
  90210. * @param meshAttributeArray The vertex attribute data
  90211. * @param byteOffset The offset to the binary data
  90212. * @param binaryWriter The binary data for the glTF file
  90213. * @param convertToRightHandedSystem Converts the values to right-handed
  90214. */
  90215. private reorderTriangleFillMode;
  90216. /**
  90217. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  90218. * clock-wise during export to glTF
  90219. * @param submesh BabylonJS submesh
  90220. * @param primitiveMode Primitive mode of the mesh
  90221. * @param sideOrientation the winding order of the submesh
  90222. * @param vertexBufferKind The type of vertex attribute
  90223. * @param meshAttributeArray The vertex attribute data
  90224. * @param byteOffset The offset to the binary data
  90225. * @param binaryWriter The binary data for the glTF file
  90226. * @param convertToRightHandedSystem Converts the values to right-handed
  90227. */
  90228. private reorderTriangleStripDrawMode;
  90229. /**
  90230. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  90231. * clock-wise during export to glTF
  90232. * @param submesh BabylonJS submesh
  90233. * @param primitiveMode Primitive mode of the mesh
  90234. * @param sideOrientation the winding order of the submesh
  90235. * @param vertexBufferKind The type of vertex attribute
  90236. * @param meshAttributeArray The vertex attribute data
  90237. * @param byteOffset The offset to the binary data
  90238. * @param binaryWriter The binary data for the glTF file
  90239. * @param convertToRightHandedSystem Converts the values to right-handed
  90240. */
  90241. private reorderTriangleFanMode;
  90242. /**
  90243. * Writes the vertex attribute data to binary
  90244. * @param vertices The vertices to write to the binary writer
  90245. * @param byteOffset The offset into the binary writer to overwrite binary data
  90246. * @param vertexAttributeKind The vertex attribute type
  90247. * @param meshAttributeArray The vertex attribute data
  90248. * @param binaryWriter The writer containing the binary data
  90249. * @param convertToRightHandedSystem Converts the values to right-handed
  90250. */
  90251. private writeVertexAttributeData;
  90252. /**
  90253. * Writes mesh attribute data to a data buffer
  90254. * Returns the bytelength of the data
  90255. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  90256. * @param meshAttributeArray Array containing the attribute data
  90257. * @param byteStride Specifies the space between data
  90258. * @param binaryWriter The buffer to write the binary data to
  90259. * @param convertToRightHandedSystem Converts the values to right-handed
  90260. */
  90261. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  90262. /**
  90263. * Writes mesh attribute data to a data buffer
  90264. * Returns the bytelength of the data
  90265. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  90266. * @param meshAttributeArray Array containing the attribute data
  90267. * @param byteStride Specifies the space between data
  90268. * @param binaryWriter The buffer to write the binary data to
  90269. * @param convertToRightHandedSystem Converts the values to right-handed
  90270. */
  90271. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  90272. /**
  90273. * Generates glTF json data
  90274. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  90275. * @param glTFPrefix Text to use when prefixing a glTF file
  90276. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  90277. * @returns json data as string
  90278. */
  90279. private generateJSON;
  90280. /**
  90281. * Generates data for .gltf and .bin files based on the glTF prefix string
  90282. * @param glTFPrefix Text to use when prefixing a glTF file
  90283. * @param dispose Dispose the exporter
  90284. * @returns GLTFData with glTF file data
  90285. */
  90286. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  90287. /**
  90288. * Creates a binary buffer for glTF
  90289. * @returns array buffer for binary data
  90290. */
  90291. private _generateBinaryAsync;
  90292. /**
  90293. * Pads the number to a multiple of 4
  90294. * @param num number to pad
  90295. * @returns padded number
  90296. */
  90297. private _getPadding;
  90298. /**
  90299. * @hidden
  90300. */
  90301. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  90302. /**
  90303. * Sets the TRS for each node
  90304. * @param node glTF Node for storing the transformation data
  90305. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  90306. * @param convertToRightHandedSystem Converts the values to right-handed
  90307. */
  90308. private setNodeTransformation;
  90309. private getVertexBufferFromMesh;
  90310. /**
  90311. * Creates a bufferview based on the vertices type for the Babylon mesh
  90312. * @param kind Indicates the type of vertices data
  90313. * @param componentType Indicates the numerical type used to store the data
  90314. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  90315. * @param binaryWriter The buffer to write the bufferview data to
  90316. * @param convertToRightHandedSystem Converts the values to right-handed
  90317. */
  90318. private createBufferViewKind;
  90319. /**
  90320. * Creates a bufferview based on the vertices type for the Babylon mesh
  90321. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  90322. * @param babylonMorphTarget the morph target to be exported
  90323. * @param binaryWriter The buffer to write the bufferview data to
  90324. * @param convertToRightHandedSystem Converts the values to right-handed
  90325. */
  90326. private setMorphTargetAttributes;
  90327. /**
  90328. * The primitive mode of the Babylon mesh
  90329. * @param babylonMesh The BabylonJS mesh
  90330. */
  90331. private getMeshPrimitiveMode;
  90332. /**
  90333. * Sets the primitive mode of the glTF mesh primitive
  90334. * @param meshPrimitive glTF mesh primitive
  90335. * @param primitiveMode The primitive mode
  90336. */
  90337. private setPrimitiveMode;
  90338. /**
  90339. * Sets the vertex attribute accessor based of the glTF mesh primitive
  90340. * @param meshPrimitive glTF mesh primitive
  90341. * @param attributeKind vertex attribute
  90342. * @returns boolean specifying if uv coordinates are present
  90343. */
  90344. private setAttributeKind;
  90345. /**
  90346. * Sets data for the primitive attributes of each submesh
  90347. * @param mesh glTF Mesh object to store the primitive attribute information
  90348. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  90349. * @param binaryWriter Buffer to write the attribute data to
  90350. * @param convertToRightHandedSystem Converts the values to right-handed
  90351. */
  90352. private setPrimitiveAttributesAsync;
  90353. /**
  90354. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  90355. * @param node The node to check
  90356. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  90357. */
  90358. private isBabylonCoordinateSystemConvertingNode;
  90359. /**
  90360. * Creates a glTF scene based on the array of meshes
  90361. * Returns the the total byte offset
  90362. * @param babylonScene Babylon scene to get the mesh data from
  90363. * @param binaryWriter Buffer to write binary data to
  90364. */
  90365. private createSceneAsync;
  90366. /**
  90367. * Creates a mapping of Node unique id to node index and handles animations
  90368. * @param babylonScene Babylon Scene
  90369. * @param nodes Babylon transform nodes
  90370. * @param binaryWriter Buffer to write binary data to
  90371. * @returns Node mapping of unique id to index
  90372. */
  90373. private createNodeMapAndAnimationsAsync;
  90374. /**
  90375. * Creates a glTF node from a Babylon mesh
  90376. * @param babylonMesh Source Babylon mesh
  90377. * @param binaryWriter Buffer for storing geometry data
  90378. * @param convertToRightHandedSystem Converts the values to right-handed
  90379. * @param nodeMap Node mapping of unique id to glTF node index
  90380. * @returns glTF node
  90381. */
  90382. private createNodeAsync;
  90383. /**
  90384. * Creates a glTF skin from a Babylon skeleton
  90385. * @param babylonScene Babylon Scene
  90386. * @param nodes Babylon transform nodes
  90387. * @param binaryWriter Buffer to write binary data to
  90388. * @returns Node mapping of unique id to index
  90389. */
  90390. private createSkinsAsync;
  90391. }
  90392. /**
  90393. * @hidden
  90394. *
  90395. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  90396. */
  90397. export class _BinaryWriter {
  90398. /**
  90399. * Array buffer which stores all binary data
  90400. */
  90401. private _arrayBuffer;
  90402. /**
  90403. * View of the array buffer
  90404. */
  90405. private _dataView;
  90406. /**
  90407. * byte offset of data in array buffer
  90408. */
  90409. private _byteOffset;
  90410. /**
  90411. * Initialize binary writer with an initial byte length
  90412. * @param byteLength Initial byte length of the array buffer
  90413. */
  90414. constructor(byteLength: number);
  90415. /**
  90416. * Resize the array buffer to the specified byte length
  90417. * @param byteLength
  90418. */
  90419. private resizeBuffer;
  90420. /**
  90421. * Get an array buffer with the length of the byte offset
  90422. * @returns ArrayBuffer resized to the byte offset
  90423. */
  90424. getArrayBuffer(): ArrayBuffer;
  90425. /**
  90426. * Get the byte offset of the array buffer
  90427. * @returns byte offset
  90428. */
  90429. getByteOffset(): number;
  90430. /**
  90431. * Stores an UInt8 in the array buffer
  90432. * @param entry
  90433. * @param byteOffset If defined, specifies where to set the value as an offset.
  90434. */
  90435. setUInt8(entry: number, byteOffset?: number): void;
  90436. /**
  90437. * Stores an UInt16 in the array buffer
  90438. * @param entry
  90439. * @param byteOffset If defined, specifies where to set the value as an offset.
  90440. */
  90441. setUInt16(entry: number, byteOffset?: number): void;
  90442. /**
  90443. * Gets an UInt32 in the array buffer
  90444. * @param entry
  90445. * @param byteOffset If defined, specifies where to set the value as an offset.
  90446. */
  90447. getUInt32(byteOffset: number): number;
  90448. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  90449. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  90450. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  90451. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  90452. /**
  90453. * Stores a Float32 in the array buffer
  90454. * @param entry
  90455. */
  90456. setFloat32(entry: number, byteOffset?: number): void;
  90457. /**
  90458. * Stores an UInt32 in the array buffer
  90459. * @param entry
  90460. * @param byteOffset If defined, specifies where to set the value as an offset.
  90461. */
  90462. setUInt32(entry: number, byteOffset?: number): void;
  90463. }
  90464. }
  90465. declare module BABYLON.GLTF2.Exporter {
  90466. /**
  90467. * @hidden
  90468. * Interface to store animation data.
  90469. */
  90470. export interface _IAnimationData {
  90471. /**
  90472. * Keyframe data.
  90473. */
  90474. inputs: number[];
  90475. /**
  90476. * Value data.
  90477. */
  90478. outputs: number[][];
  90479. /**
  90480. * Animation interpolation data.
  90481. */
  90482. samplerInterpolation: AnimationSamplerInterpolation;
  90483. /**
  90484. * Minimum keyframe value.
  90485. */
  90486. inputsMin: number;
  90487. /**
  90488. * Maximum keyframe value.
  90489. */
  90490. inputsMax: number;
  90491. }
  90492. /**
  90493. * @hidden
  90494. */
  90495. export interface _IAnimationInfo {
  90496. /**
  90497. * The target channel for the animation
  90498. */
  90499. animationChannelTargetPath: AnimationChannelTargetPath;
  90500. /**
  90501. * The glTF accessor type for the data.
  90502. */
  90503. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  90504. /**
  90505. * Specifies if quaternions should be used.
  90506. */
  90507. useQuaternion: boolean;
  90508. }
  90509. /**
  90510. * @hidden
  90511. * Utility class for generating glTF animation data from BabylonJS.
  90512. */
  90513. export class _GLTFAnimation {
  90514. /**
  90515. * @ignore
  90516. *
  90517. * Creates glTF channel animation from BabylonJS animation.
  90518. * @param babylonTransformNode - BabylonJS mesh.
  90519. * @param animation - animation.
  90520. * @param animationChannelTargetPath - The target animation channel.
  90521. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  90522. * @param useQuaternion - Specifies if quaternions are used.
  90523. * @returns nullable IAnimationData
  90524. */
  90525. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  90526. private static _DeduceAnimationInfo;
  90527. /**
  90528. * @ignore
  90529. * Create node animations from the transform node animations
  90530. * @param babylonNode
  90531. * @param runtimeGLTFAnimation
  90532. * @param idleGLTFAnimations
  90533. * @param nodeMap
  90534. * @param nodes
  90535. * @param binaryWriter
  90536. * @param bufferViews
  90537. * @param accessors
  90538. * @param convertToRightHandedSystem
  90539. * @param animationSampleRate
  90540. */
  90541. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  90542. [key: number]: number;
  90543. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  90544. /**
  90545. * @ignore
  90546. * Create individual morph animations from the mesh's morph target animation tracks
  90547. * @param babylonNode
  90548. * @param runtimeGLTFAnimation
  90549. * @param idleGLTFAnimations
  90550. * @param nodeMap
  90551. * @param nodes
  90552. * @param binaryWriter
  90553. * @param bufferViews
  90554. * @param accessors
  90555. * @param convertToRightHandedSystem
  90556. * @param animationSampleRate
  90557. */
  90558. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  90559. [key: number]: number;
  90560. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  90561. /**
  90562. * @ignore
  90563. * Create node and morph animations from the animation groups
  90564. * @param babylonScene
  90565. * @param glTFAnimations
  90566. * @param nodeMap
  90567. * @param nodes
  90568. * @param binaryWriter
  90569. * @param bufferViews
  90570. * @param accessors
  90571. * @param convertToRightHandedSystemMap
  90572. * @param animationSampleRate
  90573. */
  90574. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  90575. [key: number]: number;
  90576. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  90577. [nodeId: number]: boolean;
  90578. }, animationSampleRate: number): void;
  90579. private static AddAnimation;
  90580. /**
  90581. * Create a baked animation
  90582. * @param babylonTransformNode BabylonJS mesh
  90583. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  90584. * @param animationChannelTargetPath animation target channel
  90585. * @param minFrame minimum animation frame
  90586. * @param maxFrame maximum animation frame
  90587. * @param fps frames per second of the animation
  90588. * @param inputs input key frames of the animation
  90589. * @param outputs output key frame data of the animation
  90590. * @param convertToRightHandedSystem converts the values to right-handed
  90591. * @param useQuaternion specifies if quaternions should be used
  90592. */
  90593. private static _CreateBakedAnimation;
  90594. private static _ConvertFactorToVector3OrQuaternion;
  90595. private static _SetInterpolatedValue;
  90596. /**
  90597. * Creates linear animation from the animation key frames
  90598. * @param babylonTransformNode BabylonJS mesh
  90599. * @param animation BabylonJS animation
  90600. * @param animationChannelTargetPath The target animation channel
  90601. * @param frameDelta The difference between the last and first frame of the animation
  90602. * @param inputs Array to store the key frame times
  90603. * @param outputs Array to store the key frame data
  90604. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  90605. * @param useQuaternion Specifies if quaternions are used in the animation
  90606. */
  90607. private static _CreateLinearOrStepAnimation;
  90608. /**
  90609. * Creates cubic spline animation from the animation key frames
  90610. * @param babylonTransformNode BabylonJS mesh
  90611. * @param animation BabylonJS animation
  90612. * @param animationChannelTargetPath The target animation channel
  90613. * @param frameDelta The difference between the last and first frame of the animation
  90614. * @param inputs Array to store the key frame times
  90615. * @param outputs Array to store the key frame data
  90616. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  90617. * @param useQuaternion Specifies if quaternions are used in the animation
  90618. */
  90619. private static _CreateCubicSplineAnimation;
  90620. private static _GetBasePositionRotationOrScale;
  90621. /**
  90622. * Adds a key frame value
  90623. * @param keyFrame
  90624. * @param animation
  90625. * @param outputs
  90626. * @param animationChannelTargetPath
  90627. * @param basePositionRotationOrScale
  90628. * @param convertToRightHandedSystem
  90629. * @param useQuaternion
  90630. */
  90631. private static _AddKeyframeValue;
  90632. /**
  90633. * Determine the interpolation based on the key frames
  90634. * @param keyFrames
  90635. * @param animationChannelTargetPath
  90636. * @param useQuaternion
  90637. */
  90638. private static _DeduceInterpolation;
  90639. /**
  90640. * Adds an input tangent or output tangent to the output data
  90641. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  90642. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  90643. * @param outputs The animation data by keyframe
  90644. * @param animationChannelTargetPath The target animation channel
  90645. * @param interpolation The interpolation type
  90646. * @param keyFrame The key frame with the animation data
  90647. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  90648. * @param useQuaternion Specifies if quaternions are used
  90649. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  90650. */
  90651. private static AddSplineTangent;
  90652. /**
  90653. * Get the minimum and maximum key frames' frame values
  90654. * @param keyFrames animation key frames
  90655. * @returns the minimum and maximum key frame value
  90656. */
  90657. private static calculateMinMaxKeyFrames;
  90658. }
  90659. }
  90660. declare module BABYLON.GLTF2.Exporter {
  90661. /** @hidden */
  90662. export var textureTransformPixelShader: {
  90663. name: string;
  90664. shader: string;
  90665. };
  90666. }
  90667. declare module BABYLON.GLTF2.Exporter.Extensions {
  90668. /**
  90669. * @hidden
  90670. */
  90671. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  90672. private _recordedTextures;
  90673. /** Name of this extension */
  90674. readonly name: string;
  90675. /** Defines whether this extension is enabled */
  90676. enabled: boolean;
  90677. /** Defines whether this extension is required */
  90678. required: boolean;
  90679. /** Reference to the glTF exporter */
  90680. private _wasUsed;
  90681. constructor(exporter: _Exporter);
  90682. dispose(): void;
  90683. /** @hidden */
  90684. get wasUsed(): boolean;
  90685. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  90686. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  90687. /**
  90688. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  90689. * @param babylonTexture
  90690. * @param offset
  90691. * @param rotation
  90692. * @param scale
  90693. * @param scene
  90694. */
  90695. private _textureTransformTextureAsync;
  90696. }
  90697. }
  90698. declare module BABYLON.GLTF2.Exporter.Extensions {
  90699. /**
  90700. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  90701. */
  90702. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  90703. /** The name of this extension. */
  90704. readonly name: string;
  90705. /** Defines whether this extension is enabled. */
  90706. enabled: boolean;
  90707. /** Defines whether this extension is required */
  90708. required: boolean;
  90709. /** Reference to the glTF exporter */
  90710. private _exporter;
  90711. private _lights;
  90712. /** @hidden */
  90713. constructor(exporter: _Exporter);
  90714. /** @hidden */
  90715. dispose(): void;
  90716. /** @hidden */
  90717. get wasUsed(): boolean;
  90718. /** @hidden */
  90719. onExporting(): void;
  90720. /**
  90721. * Define this method to modify the default behavior when exporting a node
  90722. * @param context The context when exporting the node
  90723. * @param node glTF node
  90724. * @param babylonNode BabylonJS node
  90725. * @param nodeMap Node mapping of unique id to glTF node index
  90726. * @returns nullable INode promise
  90727. */
  90728. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  90729. [key: number]: number;
  90730. }): Promise<Nullable<INode>>;
  90731. }
  90732. }
  90733. declare module BABYLON.GLTF2.Exporter.Extensions {
  90734. /**
  90735. * @hidden
  90736. */
  90737. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  90738. /** Name of this extension */
  90739. readonly name: string;
  90740. /** Defines whether this extension is enabled */
  90741. enabled: boolean;
  90742. /** Defines whether this extension is required */
  90743. required: boolean;
  90744. /** Reference to the glTF exporter */
  90745. private _textureInfos;
  90746. private _exportedTextures;
  90747. private _wasUsed;
  90748. constructor(exporter: _Exporter);
  90749. dispose(): void;
  90750. /** @hidden */
  90751. get wasUsed(): boolean;
  90752. private _getTextureIndex;
  90753. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  90754. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  90755. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  90756. }
  90757. }
  90758. declare module BABYLON.GLTF2.Exporter.Extensions {
  90759. /**
  90760. * @hidden
  90761. */
  90762. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  90763. /** Name of this extension */
  90764. readonly name: string;
  90765. /** Defines whether this extension is enabled */
  90766. enabled: boolean;
  90767. /** Defines whether this extension is required */
  90768. required: boolean;
  90769. private _wasUsed;
  90770. constructor(exporter: _Exporter);
  90771. /** @hidden */
  90772. get wasUsed(): boolean;
  90773. dispose(): void;
  90774. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  90775. }
  90776. }
  90777. declare module BABYLON {
  90778. /**
  90779. * Class for generating STL data from a Babylon scene.
  90780. */
  90781. export class STLExport {
  90782. /**
  90783. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  90784. * @param meshes list defines the mesh to serialize
  90785. * @param download triggers the automatic download of the file.
  90786. * @param fileName changes the downloads fileName.
  90787. * @param binary changes the STL to a binary type.
  90788. * @param isLittleEndian toggle for binary type exporter.
  90789. * @param doNotBakeTransform toggle if meshes transforms should be baked or not.
  90790. * @returns the STL as UTF8 string
  90791. */
  90792. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean, doNotBakeTransform?: boolean): any;
  90793. }
  90794. }
  90795. declare module "babylonjs-gltf2interface" {
  90796. export = BABYLON.GLTF2;
  90797. }
  90798. /**
  90799. * Module for glTF 2.0 Interface
  90800. */
  90801. declare module BABYLON.GLTF2 {
  90802. /**
  90803. * The datatype of the components in the attribute
  90804. */
  90805. const enum AccessorComponentType {
  90806. /**
  90807. * Byte
  90808. */
  90809. BYTE = 5120,
  90810. /**
  90811. * Unsigned Byte
  90812. */
  90813. UNSIGNED_BYTE = 5121,
  90814. /**
  90815. * Short
  90816. */
  90817. SHORT = 5122,
  90818. /**
  90819. * Unsigned Short
  90820. */
  90821. UNSIGNED_SHORT = 5123,
  90822. /**
  90823. * Unsigned Int
  90824. */
  90825. UNSIGNED_INT = 5125,
  90826. /**
  90827. * Float
  90828. */
  90829. FLOAT = 5126,
  90830. }
  90831. /**
  90832. * Specifies if the attirbute is a scalar, vector, or matrix
  90833. */
  90834. const enum AccessorType {
  90835. /**
  90836. * Scalar
  90837. */
  90838. SCALAR = "SCALAR",
  90839. /**
  90840. * Vector2
  90841. */
  90842. VEC2 = "VEC2",
  90843. /**
  90844. * Vector3
  90845. */
  90846. VEC3 = "VEC3",
  90847. /**
  90848. * Vector4
  90849. */
  90850. VEC4 = "VEC4",
  90851. /**
  90852. * Matrix2x2
  90853. */
  90854. MAT2 = "MAT2",
  90855. /**
  90856. * Matrix3x3
  90857. */
  90858. MAT3 = "MAT3",
  90859. /**
  90860. * Matrix4x4
  90861. */
  90862. MAT4 = "MAT4",
  90863. }
  90864. /**
  90865. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  90866. */
  90867. const enum AnimationChannelTargetPath {
  90868. /**
  90869. * Translation
  90870. */
  90871. TRANSLATION = "translation",
  90872. /**
  90873. * Rotation
  90874. */
  90875. ROTATION = "rotation",
  90876. /**
  90877. * Scale
  90878. */
  90879. SCALE = "scale",
  90880. /**
  90881. * Weights
  90882. */
  90883. WEIGHTS = "weights",
  90884. }
  90885. /**
  90886. * Interpolation algorithm
  90887. */
  90888. const enum AnimationSamplerInterpolation {
  90889. /**
  90890. * The animated values are linearly interpolated between keyframes
  90891. */
  90892. LINEAR = "LINEAR",
  90893. /**
  90894. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  90895. */
  90896. STEP = "STEP",
  90897. /**
  90898. * The animation's interpolation is computed using a cubic spline with specified tangents
  90899. */
  90900. CUBICSPLINE = "CUBICSPLINE",
  90901. }
  90902. /**
  90903. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  90904. */
  90905. const enum CameraType {
  90906. /**
  90907. * A perspective camera containing properties to create a perspective projection matrix
  90908. */
  90909. PERSPECTIVE = "perspective",
  90910. /**
  90911. * An orthographic camera containing properties to create an orthographic projection matrix
  90912. */
  90913. ORTHOGRAPHIC = "orthographic",
  90914. }
  90915. /**
  90916. * The mime-type of the image
  90917. */
  90918. const enum ImageMimeType {
  90919. /**
  90920. * JPEG Mime-type
  90921. */
  90922. JPEG = "image/jpeg",
  90923. /**
  90924. * PNG Mime-type
  90925. */
  90926. PNG = "image/png",
  90927. }
  90928. /**
  90929. * The alpha rendering mode of the material
  90930. */
  90931. const enum MaterialAlphaMode {
  90932. /**
  90933. * The alpha value is ignored and the rendered output is fully opaque
  90934. */
  90935. OPAQUE = "OPAQUE",
  90936. /**
  90937. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  90938. */
  90939. MASK = "MASK",
  90940. /**
  90941. * 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)
  90942. */
  90943. BLEND = "BLEND",
  90944. }
  90945. /**
  90946. * The type of the primitives to render
  90947. */
  90948. const enum MeshPrimitiveMode {
  90949. /**
  90950. * Points
  90951. */
  90952. POINTS = 0,
  90953. /**
  90954. * Lines
  90955. */
  90956. LINES = 1,
  90957. /**
  90958. * Line Loop
  90959. */
  90960. LINE_LOOP = 2,
  90961. /**
  90962. * Line Strip
  90963. */
  90964. LINE_STRIP = 3,
  90965. /**
  90966. * Triangles
  90967. */
  90968. TRIANGLES = 4,
  90969. /**
  90970. * Triangle Strip
  90971. */
  90972. TRIANGLE_STRIP = 5,
  90973. /**
  90974. * Triangle Fan
  90975. */
  90976. TRIANGLE_FAN = 6,
  90977. }
  90978. /**
  90979. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  90980. */
  90981. const enum TextureMagFilter {
  90982. /**
  90983. * Nearest
  90984. */
  90985. NEAREST = 9728,
  90986. /**
  90987. * Linear
  90988. */
  90989. LINEAR = 9729,
  90990. }
  90991. /**
  90992. * Minification filter. All valid values correspond to WebGL enums
  90993. */
  90994. const enum TextureMinFilter {
  90995. /**
  90996. * Nearest
  90997. */
  90998. NEAREST = 9728,
  90999. /**
  91000. * Linear
  91001. */
  91002. LINEAR = 9729,
  91003. /**
  91004. * Nearest Mip-Map Nearest
  91005. */
  91006. NEAREST_MIPMAP_NEAREST = 9984,
  91007. /**
  91008. * Linear Mipmap Nearest
  91009. */
  91010. LINEAR_MIPMAP_NEAREST = 9985,
  91011. /**
  91012. * Nearest Mipmap Linear
  91013. */
  91014. NEAREST_MIPMAP_LINEAR = 9986,
  91015. /**
  91016. * Linear Mipmap Linear
  91017. */
  91018. LINEAR_MIPMAP_LINEAR = 9987,
  91019. }
  91020. /**
  91021. * S (U) wrapping mode. All valid values correspond to WebGL enums
  91022. */
  91023. const enum TextureWrapMode {
  91024. /**
  91025. * Clamp to Edge
  91026. */
  91027. CLAMP_TO_EDGE = 33071,
  91028. /**
  91029. * Mirrored Repeat
  91030. */
  91031. MIRRORED_REPEAT = 33648,
  91032. /**
  91033. * Repeat
  91034. */
  91035. REPEAT = 10497,
  91036. }
  91037. /**
  91038. * glTF Property
  91039. */
  91040. interface IProperty {
  91041. /**
  91042. * Dictionary object with extension-specific objects
  91043. */
  91044. extensions?: {
  91045. [key: string]: any;
  91046. };
  91047. /**
  91048. * Application-Specific data
  91049. */
  91050. extras?: any;
  91051. }
  91052. /**
  91053. * glTF Child of Root Property
  91054. */
  91055. interface IChildRootProperty extends IProperty {
  91056. /**
  91057. * The user-defined name of this object
  91058. */
  91059. name?: string;
  91060. }
  91061. /**
  91062. * Indices of those attributes that deviate from their initialization value
  91063. */
  91064. interface IAccessorSparseIndices extends IProperty {
  91065. /**
  91066. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  91067. */
  91068. bufferView: number;
  91069. /**
  91070. * The offset relative to the start of the bufferView in bytes. Must be aligned
  91071. */
  91072. byteOffset?: number;
  91073. /**
  91074. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  91075. */
  91076. componentType: AccessorComponentType;
  91077. }
  91078. /**
  91079. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  91080. */
  91081. interface IAccessorSparseValues extends IProperty {
  91082. /**
  91083. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  91084. */
  91085. bufferView: number;
  91086. /**
  91087. * The offset relative to the start of the bufferView in bytes. Must be aligned
  91088. */
  91089. byteOffset?: number;
  91090. }
  91091. /**
  91092. * Sparse storage of attributes that deviate from their initialization value
  91093. */
  91094. interface IAccessorSparse extends IProperty {
  91095. /**
  91096. * The number of attributes encoded in this sparse accessor
  91097. */
  91098. count: number;
  91099. /**
  91100. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  91101. */
  91102. indices: IAccessorSparseIndices;
  91103. /**
  91104. * 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
  91105. */
  91106. values: IAccessorSparseValues;
  91107. }
  91108. /**
  91109. * 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
  91110. */
  91111. interface IAccessor extends IChildRootProperty {
  91112. /**
  91113. * The index of the bufferview
  91114. */
  91115. bufferView?: number;
  91116. /**
  91117. * The offset relative to the start of the bufferView in bytes
  91118. */
  91119. byteOffset?: number;
  91120. /**
  91121. * The datatype of components in the attribute
  91122. */
  91123. componentType: AccessorComponentType;
  91124. /**
  91125. * Specifies whether integer data values should be normalized
  91126. */
  91127. normalized?: boolean;
  91128. /**
  91129. * The number of attributes referenced by this accessor
  91130. */
  91131. count: number;
  91132. /**
  91133. * Specifies if the attribute is a scalar, vector, or matrix
  91134. */
  91135. type: AccessorType;
  91136. /**
  91137. * Maximum value of each component in this attribute
  91138. */
  91139. max?: number[];
  91140. /**
  91141. * Minimum value of each component in this attribute
  91142. */
  91143. min?: number[];
  91144. /**
  91145. * Sparse storage of attributes that deviate from their initialization value
  91146. */
  91147. sparse?: IAccessorSparse;
  91148. }
  91149. /**
  91150. * Targets an animation's sampler at a node's property
  91151. */
  91152. interface IAnimationChannel extends IProperty {
  91153. /**
  91154. * The index of a sampler in this animation used to compute the value for the target
  91155. */
  91156. sampler: number;
  91157. /**
  91158. * The index of the node and TRS property to target
  91159. */
  91160. target: IAnimationChannelTarget;
  91161. }
  91162. /**
  91163. * The index of the node and TRS property that an animation channel targets
  91164. */
  91165. interface IAnimationChannelTarget extends IProperty {
  91166. /**
  91167. * The index of the node to target
  91168. */
  91169. node: number;
  91170. /**
  91171. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  91172. */
  91173. path: AnimationChannelTargetPath;
  91174. }
  91175. /**
  91176. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  91177. */
  91178. interface IAnimationSampler extends IProperty {
  91179. /**
  91180. * The index of an accessor containing keyframe input values, e.g., time
  91181. */
  91182. input: number;
  91183. /**
  91184. * Interpolation algorithm
  91185. */
  91186. interpolation?: AnimationSamplerInterpolation;
  91187. /**
  91188. * The index of an accessor, containing keyframe output values
  91189. */
  91190. output: number;
  91191. }
  91192. /**
  91193. * A keyframe animation
  91194. */
  91195. interface IAnimation extends IChildRootProperty {
  91196. /**
  91197. * An array of channels, each of which targets an animation's sampler at a node's property
  91198. */
  91199. channels: IAnimationChannel[];
  91200. /**
  91201. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  91202. */
  91203. samplers: IAnimationSampler[];
  91204. }
  91205. /**
  91206. * Metadata about the glTF asset
  91207. */
  91208. interface IAsset extends IChildRootProperty {
  91209. /**
  91210. * A copyright message suitable for display to credit the content creator
  91211. */
  91212. copyright?: string;
  91213. /**
  91214. * Tool that generated this glTF model. Useful for debugging
  91215. */
  91216. generator?: string;
  91217. /**
  91218. * The glTF version that this asset targets
  91219. */
  91220. version: string;
  91221. /**
  91222. * The minimum glTF version that this asset targets
  91223. */
  91224. minVersion?: string;
  91225. }
  91226. /**
  91227. * A buffer points to binary geometry, animation, or skins
  91228. */
  91229. interface IBuffer extends IChildRootProperty {
  91230. /**
  91231. * 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
  91232. */
  91233. uri?: string;
  91234. /**
  91235. * The length of the buffer in bytes
  91236. */
  91237. byteLength: number;
  91238. }
  91239. /**
  91240. * A view into a buffer generally representing a subset of the buffer
  91241. */
  91242. interface IBufferView extends IChildRootProperty {
  91243. /**
  91244. * The index of the buffer
  91245. */
  91246. buffer: number;
  91247. /**
  91248. * The offset into the buffer in bytes
  91249. */
  91250. byteOffset?: number;
  91251. /**
  91252. * The lenth of the bufferView in bytes
  91253. */
  91254. byteLength: number;
  91255. /**
  91256. * The stride, in bytes
  91257. */
  91258. byteStride?: number;
  91259. }
  91260. /**
  91261. * An orthographic camera containing properties to create an orthographic projection matrix
  91262. */
  91263. interface ICameraOrthographic extends IProperty {
  91264. /**
  91265. * The floating-point horizontal magnification of the view. Must not be zero
  91266. */
  91267. xmag: number;
  91268. /**
  91269. * The floating-point vertical magnification of the view. Must not be zero
  91270. */
  91271. ymag: number;
  91272. /**
  91273. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  91274. */
  91275. zfar: number;
  91276. /**
  91277. * The floating-point distance to the near clipping plane
  91278. */
  91279. znear: number;
  91280. }
  91281. /**
  91282. * A perspective camera containing properties to create a perspective projection matrix
  91283. */
  91284. interface ICameraPerspective extends IProperty {
  91285. /**
  91286. * The floating-point aspect ratio of the field of view
  91287. */
  91288. aspectRatio?: number;
  91289. /**
  91290. * The floating-point vertical field of view in radians
  91291. */
  91292. yfov: number;
  91293. /**
  91294. * The floating-point distance to the far clipping plane
  91295. */
  91296. zfar?: number;
  91297. /**
  91298. * The floating-point distance to the near clipping plane
  91299. */
  91300. znear: number;
  91301. }
  91302. /**
  91303. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  91304. */
  91305. interface ICamera extends IChildRootProperty {
  91306. /**
  91307. * An orthographic camera containing properties to create an orthographic projection matrix
  91308. */
  91309. orthographic?: ICameraOrthographic;
  91310. /**
  91311. * A perspective camera containing properties to create a perspective projection matrix
  91312. */
  91313. perspective?: ICameraPerspective;
  91314. /**
  91315. * Specifies if the camera uses a perspective or orthographic projection
  91316. */
  91317. type: CameraType;
  91318. }
  91319. /**
  91320. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  91321. */
  91322. interface IImage extends IChildRootProperty {
  91323. /**
  91324. * 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
  91325. */
  91326. uri?: string;
  91327. /**
  91328. * The image's MIME type
  91329. */
  91330. mimeType?: ImageMimeType;
  91331. /**
  91332. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  91333. */
  91334. bufferView?: number;
  91335. }
  91336. /**
  91337. * Material Normal Texture Info
  91338. */
  91339. interface IMaterialNormalTextureInfo extends ITextureInfo {
  91340. /**
  91341. * The scalar multiplier applied to each normal vector of the normal texture
  91342. */
  91343. scale?: number;
  91344. }
  91345. /**
  91346. * Material Occlusion Texture Info
  91347. */
  91348. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  91349. /**
  91350. * A scalar multiplier controlling the amount of occlusion applied
  91351. */
  91352. strength?: number;
  91353. }
  91354. /**
  91355. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  91356. */
  91357. interface IMaterialPbrMetallicRoughness {
  91358. /**
  91359. * The material's base color factor
  91360. */
  91361. baseColorFactor?: number[];
  91362. /**
  91363. * The base color texture
  91364. */
  91365. baseColorTexture?: ITextureInfo;
  91366. /**
  91367. * The metalness of the material
  91368. */
  91369. metallicFactor?: number;
  91370. /**
  91371. * The roughness of the material
  91372. */
  91373. roughnessFactor?: number;
  91374. /**
  91375. * The metallic-roughness texture
  91376. */
  91377. metallicRoughnessTexture?: ITextureInfo;
  91378. }
  91379. /**
  91380. * The material appearance of a primitive
  91381. */
  91382. interface IMaterial extends IChildRootProperty {
  91383. /**
  91384. * 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
  91385. */
  91386. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  91387. /**
  91388. * The normal map texture
  91389. */
  91390. normalTexture?: IMaterialNormalTextureInfo;
  91391. /**
  91392. * The occlusion map texture
  91393. */
  91394. occlusionTexture?: IMaterialOcclusionTextureInfo;
  91395. /**
  91396. * The emissive map texture
  91397. */
  91398. emissiveTexture?: ITextureInfo;
  91399. /**
  91400. * 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
  91401. */
  91402. emissiveFactor?: number[];
  91403. /**
  91404. * The alpha rendering mode of the material
  91405. */
  91406. alphaMode?: MaterialAlphaMode;
  91407. /**
  91408. * The alpha cutoff value of the material
  91409. */
  91410. alphaCutoff?: number;
  91411. /**
  91412. * Specifies whether the material is double sided
  91413. */
  91414. doubleSided?: boolean;
  91415. }
  91416. /**
  91417. * Geometry to be rendered with the given material
  91418. */
  91419. interface IMeshPrimitive extends IProperty {
  91420. /**
  91421. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  91422. */
  91423. attributes: {
  91424. [name: string]: number;
  91425. };
  91426. /**
  91427. * The index of the accessor that contains the indices
  91428. */
  91429. indices?: number;
  91430. /**
  91431. * The index of the material to apply to this primitive when rendering
  91432. */
  91433. material?: number;
  91434. /**
  91435. * The type of primitives to render. All valid values correspond to WebGL enums
  91436. */
  91437. mode?: MeshPrimitiveMode;
  91438. /**
  91439. * 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
  91440. */
  91441. targets?: {
  91442. [name: string]: number;
  91443. }[];
  91444. }
  91445. /**
  91446. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  91447. */
  91448. interface IMesh extends IChildRootProperty {
  91449. /**
  91450. * An array of primitives, each defining geometry to be rendered with a material
  91451. */
  91452. primitives: IMeshPrimitive[];
  91453. /**
  91454. * Array of weights to be applied to the Morph Targets
  91455. */
  91456. weights?: number[];
  91457. }
  91458. /**
  91459. * A node in the node hierarchy
  91460. */
  91461. interface INode extends IChildRootProperty {
  91462. /**
  91463. * The index of the camera referenced by this node
  91464. */
  91465. camera?: number;
  91466. /**
  91467. * The indices of this node's children
  91468. */
  91469. children?: number[];
  91470. /**
  91471. * The index of the skin referenced by this node
  91472. */
  91473. skin?: number;
  91474. /**
  91475. * A floating-point 4x4 transformation matrix stored in column-major order
  91476. */
  91477. matrix?: number[];
  91478. /**
  91479. * The index of the mesh in this node
  91480. */
  91481. mesh?: number;
  91482. /**
  91483. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  91484. */
  91485. rotation?: number[];
  91486. /**
  91487. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  91488. */
  91489. scale?: number[];
  91490. /**
  91491. * The node's translation along the x, y, and z axes
  91492. */
  91493. translation?: number[];
  91494. /**
  91495. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  91496. */
  91497. weights?: number[];
  91498. }
  91499. /**
  91500. * Texture sampler properties for filtering and wrapping modes
  91501. */
  91502. interface ISampler extends IChildRootProperty {
  91503. /**
  91504. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  91505. */
  91506. magFilter?: TextureMagFilter;
  91507. /**
  91508. * Minification filter. All valid values correspond to WebGL enums
  91509. */
  91510. minFilter?: TextureMinFilter;
  91511. /**
  91512. * S (U) wrapping mode. All valid values correspond to WebGL enums
  91513. */
  91514. wrapS?: TextureWrapMode;
  91515. /**
  91516. * T (V) wrapping mode. All valid values correspond to WebGL enums
  91517. */
  91518. wrapT?: TextureWrapMode;
  91519. }
  91520. /**
  91521. * The root nodes of a scene
  91522. */
  91523. interface IScene extends IChildRootProperty {
  91524. /**
  91525. * The indices of each root node
  91526. */
  91527. nodes: number[];
  91528. }
  91529. /**
  91530. * Joints and matrices defining a skin
  91531. */
  91532. interface ISkin extends IChildRootProperty {
  91533. /**
  91534. * 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
  91535. */
  91536. inverseBindMatrices?: number;
  91537. /**
  91538. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  91539. */
  91540. skeleton?: number;
  91541. /**
  91542. * 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)
  91543. */
  91544. joints: number[];
  91545. }
  91546. /**
  91547. * A texture and its sampler
  91548. */
  91549. interface ITexture extends IChildRootProperty {
  91550. /**
  91551. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  91552. */
  91553. sampler?: number;
  91554. /**
  91555. * The index of the image used by this texture
  91556. */
  91557. source: number;
  91558. }
  91559. /**
  91560. * Reference to a texture
  91561. */
  91562. interface ITextureInfo extends IProperty {
  91563. /**
  91564. * The index of the texture
  91565. */
  91566. index: number;
  91567. /**
  91568. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  91569. */
  91570. texCoord?: number;
  91571. }
  91572. /**
  91573. * The root object for a glTF asset
  91574. */
  91575. interface IGLTF extends IProperty {
  91576. /**
  91577. * An array of accessors. An accessor is a typed view into a bufferView
  91578. */
  91579. accessors?: IAccessor[];
  91580. /**
  91581. * An array of keyframe animations
  91582. */
  91583. animations?: IAnimation[];
  91584. /**
  91585. * Metadata about the glTF asset
  91586. */
  91587. asset: IAsset;
  91588. /**
  91589. * An array of buffers. A buffer points to binary geometry, animation, or skins
  91590. */
  91591. buffers?: IBuffer[];
  91592. /**
  91593. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  91594. */
  91595. bufferViews?: IBufferView[];
  91596. /**
  91597. * An array of cameras
  91598. */
  91599. cameras?: ICamera[];
  91600. /**
  91601. * Names of glTF extensions used somewhere in this asset
  91602. */
  91603. extensionsUsed?: string[];
  91604. /**
  91605. * Names of glTF extensions required to properly load this asset
  91606. */
  91607. extensionsRequired?: string[];
  91608. /**
  91609. * An array of images. An image defines data used to create a texture
  91610. */
  91611. images?: IImage[];
  91612. /**
  91613. * An array of materials. A material defines the appearance of a primitive
  91614. */
  91615. materials?: IMaterial[];
  91616. /**
  91617. * An array of meshes. A mesh is a set of primitives to be rendered
  91618. */
  91619. meshes?: IMesh[];
  91620. /**
  91621. * An array of nodes
  91622. */
  91623. nodes?: INode[];
  91624. /**
  91625. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  91626. */
  91627. samplers?: ISampler[];
  91628. /**
  91629. * The index of the default scene
  91630. */
  91631. scene?: number;
  91632. /**
  91633. * An array of scenes
  91634. */
  91635. scenes?: IScene[];
  91636. /**
  91637. * An array of skins. A skin is defined by joints and matrices
  91638. */
  91639. skins?: ISkin[];
  91640. /**
  91641. * An array of textures
  91642. */
  91643. textures?: ITexture[];
  91644. }
  91645. /**
  91646. * The glTF validation results
  91647. * @ignore
  91648. */
  91649. interface IGLTFValidationResults {
  91650. info: {
  91651. generator: string;
  91652. hasAnimations: boolean;
  91653. hasDefaultScene: boolean;
  91654. hasMaterials: boolean;
  91655. hasMorphTargets: boolean;
  91656. hasSkins: boolean;
  91657. hasTextures: boolean;
  91658. maxAttributesUsed: number;
  91659. primitivesCount: number
  91660. };
  91661. issues: {
  91662. messages: Array<string>;
  91663. numErrors: number;
  91664. numHints: number;
  91665. numInfos: number;
  91666. numWarnings: number;
  91667. truncated: boolean
  91668. };
  91669. mimeType: string;
  91670. uri: string;
  91671. validatedAt: string;
  91672. validatorVersion: string;
  91673. }
  91674. /**
  91675. * The glTF validation options
  91676. */
  91677. interface IGLTFValidationOptions {
  91678. /** Uri to use */
  91679. uri?: string;
  91680. /** Function used to load external resources */
  91681. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  91682. /** Boolean indicating that we need to validate accessor data */
  91683. validateAccessorData?: boolean;
  91684. /** max number of issues allowed */
  91685. maxIssues?: number;
  91686. /** Ignored issues */
  91687. ignoredIssues?: Array<string>;
  91688. /** Value to override severy settings */
  91689. severityOverrides?: Object;
  91690. }
  91691. /**
  91692. * The glTF validator object
  91693. * @ignore
  91694. */
  91695. interface IGLTFValidator {
  91696. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  91697. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  91698. }
  91699. /**
  91700. * Interfaces from the EXT_lights_image_based extension
  91701. */
  91702. /** @hidden */
  91703. interface IEXTLightsImageBased_LightReferenceImageBased {
  91704. light: number;
  91705. }
  91706. /** @hidden */
  91707. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  91708. intensity: number;
  91709. rotation: number[];
  91710. specularImageSize: number;
  91711. specularImages: number[][];
  91712. irradianceCoefficients: number[][];
  91713. }
  91714. /** @hidden */
  91715. interface IEXTLightsImageBased {
  91716. lights: IEXTLightsImageBased_LightImageBased[];
  91717. }
  91718. /**
  91719. * Interfaces from the EXT_mesh_gpu_instancing extension
  91720. * !!! Experimental Extension Subject to Changes !!!
  91721. */
  91722. /** @hidden */
  91723. interface IEXTMeshGpuInstancing {
  91724. mesh?: number;
  91725. attributes: { [name: string]: number };
  91726. }
  91727. /**
  91728. * Interfaces from the KHR_draco_mesh_compression extension
  91729. */
  91730. /** @hidden */
  91731. interface IKHRDracoMeshCompression {
  91732. bufferView: number;
  91733. attributes: { [name: string]: number };
  91734. }
  91735. /**
  91736. * Interfaces from the KHR_lights_punctual extension
  91737. */
  91738. /** @hidden */
  91739. const enum IKHRLightsPunctual_LightType {
  91740. DIRECTIONAL = "directional",
  91741. POINT = "point",
  91742. SPOT = "spot"
  91743. }
  91744. /** @hidden */
  91745. interface IKHRLightsPunctual_LightReference {
  91746. light: number;
  91747. }
  91748. /** @hidden */
  91749. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  91750. type: IKHRLightsPunctual_LightType;
  91751. color?: number[];
  91752. intensity?: number;
  91753. range?: number;
  91754. spot?: {
  91755. innerConeAngle?: number;
  91756. outerConeAngle?: number;
  91757. };
  91758. }
  91759. /** @hidden */
  91760. interface IKHRLightsPunctual {
  91761. lights: IKHRLightsPunctual_Light[];
  91762. }
  91763. /**
  91764. * Interfaces from the KHR_materials_clearcoat extension
  91765. * !!! Experimental Extension Subject to Changes !!!
  91766. */
  91767. /** @hidden */
  91768. interface IKHRMaterialsClearcoat {
  91769. clearcoatFactor: number;
  91770. clearcoatTexture: ITextureInfo;
  91771. clearcoatRoughnessFactor: number;
  91772. clearcoatRoughnessTexture: ITextureInfo;
  91773. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  91774. }
  91775. /**
  91776. * Interfaces from the KHR_materials_ior extension
  91777. * !!! Experimental Extension Subject to Changes !!!
  91778. */
  91779. /** @hidden */
  91780. interface IKHRMaterialsIor {
  91781. ior: number;
  91782. }
  91783. /**
  91784. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  91785. */
  91786. /** @hidden */
  91787. interface IKHRMaterialsPbrSpecularGlossiness {
  91788. diffuseFactor: number[];
  91789. diffuseTexture: ITextureInfo;
  91790. specularFactor: number[];
  91791. glossinessFactor: number;
  91792. specularGlossinessTexture: ITextureInfo;
  91793. }
  91794. /**
  91795. * Interfaces from the KHR_materials_sheen extension
  91796. * !!! Experimental Extension Subject to Changes !!!
  91797. */
  91798. /** @hidden */
  91799. interface IKHRMaterialsSheen {
  91800. sheenColorFactor?: number[];
  91801. sheenColorTexture?: ITextureInfo;
  91802. sheenRoughnessFactor?: number;
  91803. sheenRoughnessTexture?: ITextureInfo;
  91804. }
  91805. /**
  91806. * Interfaces from the KHR_materials_specular extension
  91807. * !!! Experimental Extension Subject to Changes !!!
  91808. */
  91809. /** @hidden */
  91810. interface IKHRMaterialsSpecular {
  91811. specularFactor: number;
  91812. specularColorFactor: number[];
  91813. specularTexture: ITextureInfo;
  91814. }
  91815. /**
  91816. * Interfaces from the KHR_materials_transmission extension
  91817. * !!! Experimental Extension Subject to Changes !!!
  91818. */
  91819. /** @hidden */
  91820. interface IKHRMaterialsTransmission {
  91821. transmissionFactor?: number;
  91822. transmissionTexture?: ITextureInfo;
  91823. }
  91824. /**
  91825. * Interfaces from the KHR_materials_translucency extension
  91826. * !!! Experimental Extension Subject to Changes !!!
  91827. */
  91828. /** @hidden */
  91829. interface IKHRMaterialsTranslucency {
  91830. translucencyFactor?: number;
  91831. translucencyTexture?: ITextureInfo;
  91832. }
  91833. /**
  91834. * Interfaces from the KHR_materials_variants extension
  91835. * !!! Experimental Extension Subject to Changes !!!
  91836. */
  91837. /** @hidden */
  91838. interface IKHRMaterialVariants_Mapping extends IProperty {
  91839. mappings: Array<{
  91840. variants: number[];
  91841. material: number;
  91842. }>;
  91843. }
  91844. /** @hidden */
  91845. interface IKHRMaterialVariants_Variant extends IProperty {
  91846. name: string;
  91847. }
  91848. /** @hidden */
  91849. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  91850. variants: Array<IKHRMaterialVariants_Variant>;
  91851. }
  91852. /**
  91853. * Interfaces from the KHR_texture_basisu extension
  91854. * !!! Experimental Extension Subject to Changes !!!
  91855. */
  91856. /** @hidden */
  91857. interface IKHRTextureBasisU {
  91858. source: number;
  91859. }
  91860. /**
  91861. * Interfaces from the EXT_texture_webp extension
  91862. */
  91863. /** @hidden */
  91864. interface IEXTTextureWebP {
  91865. source: number;
  91866. }
  91867. /**
  91868. * Interfaces from the KHR_texture_transform extension
  91869. */
  91870. /** @hidden */
  91871. interface IKHRTextureTransform {
  91872. offset?: number[];
  91873. rotation?: number;
  91874. scale?: number[];
  91875. texCoord?: number;
  91876. }
  91877. /**
  91878. * Interfaces from the KHR_xmp_json_ld extension
  91879. * !!! Experimental Extension Subject to Changes !!!
  91880. */
  91881. /** @hidden */
  91882. interface IKHRXmpJsonLd_Gltf {
  91883. packets: Array<{
  91884. [key: string]: unknown;
  91885. }>;
  91886. }
  91887. /** @hidden */
  91888. interface IKHRXmpJsonLd_Node {
  91889. packet: number;
  91890. }
  91891. /**
  91892. * Interfaces from the MSFT_audio_emitter extension
  91893. */
  91894. /** @hidden */
  91895. interface IMSFTAudioEmitter_ClipReference {
  91896. clip: number;
  91897. weight?: number;
  91898. }
  91899. /** @hidden */
  91900. interface IMSFTAudioEmitter_EmittersReference {
  91901. emitters: number[];
  91902. }
  91903. /** @hidden */
  91904. const enum IMSFTAudioEmitter_DistanceModel {
  91905. linear = "linear",
  91906. inverse = "inverse",
  91907. exponential = "exponential",
  91908. }
  91909. /** @hidden */
  91910. interface IMSFTAudioEmitter_Emitter {
  91911. name?: string;
  91912. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  91913. refDistance?: number;
  91914. maxDistance?: number;
  91915. rolloffFactor?: number;
  91916. innerAngle?: number;
  91917. outerAngle?: number;
  91918. loop?: boolean;
  91919. volume?: number;
  91920. clips: IMSFTAudioEmitter_ClipReference[];
  91921. }
  91922. /** @hidden */
  91923. const enum IMSFTAudioEmitter_AudioMimeType {
  91924. WAV = "audio/wav",
  91925. }
  91926. /** @hidden */
  91927. interface IMSFTAudioEmitter_Clip extends IProperty {
  91928. uri?: string;
  91929. bufferView?: number;
  91930. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  91931. }
  91932. /** @hidden */
  91933. const enum IMSFTAudioEmitter_AnimationEventAction {
  91934. play = "play",
  91935. pause = "pause",
  91936. stop = "stop",
  91937. }
  91938. /** @hidden */
  91939. interface IMSFTAudioEmitter_AnimationEvent {
  91940. action: IMSFTAudioEmitter_AnimationEventAction;
  91941. emitter: number;
  91942. time: number;
  91943. startOffset?: number;
  91944. }
  91945. /**
  91946. * Interfaces from the MSFT_lod extension
  91947. */
  91948. /** @hidden */
  91949. interface IMSFTLOD {
  91950. ids: number[];
  91951. }
  91952. /**
  91953. * Interfaces from the EXT_meshopt_compression extension
  91954. */
  91955. /** @hidden */
  91956. interface IEXTMeshoptCompression {
  91957. buffer: number;
  91958. byteOffset?: number;
  91959. byteLength: number;
  91960. byteStride: number;
  91961. count: number;
  91962. mode: "ATTRIBUTES" | "TRIANGLES" | "INDICES";
  91963. filter?: "NONE" | "OCTAHEDRAL" | "QUATERNION" | "EXPONENTIAL";
  91964. }
  91965. }
  91966. declare module BABYLON {
  91967. /** @hidden */
  91968. export var cellPixelShader: {
  91969. name: string;
  91970. shader: string;
  91971. };
  91972. }
  91973. declare module BABYLON {
  91974. /** @hidden */
  91975. export var cellVertexShader: {
  91976. name: string;
  91977. shader: string;
  91978. };
  91979. }
  91980. declare module BABYLON {
  91981. export class CellMaterial extends BABYLON.PushMaterial {
  91982. private _diffuseTexture;
  91983. diffuseTexture: BABYLON.BaseTexture;
  91984. diffuseColor: BABYLON.Color3;
  91985. _computeHighLevel: boolean;
  91986. computeHighLevel: boolean;
  91987. private _disableLighting;
  91988. disableLighting: boolean;
  91989. private _maxSimultaneousLights;
  91990. maxSimultaneousLights: number;
  91991. constructor(name: string, scene: BABYLON.Scene);
  91992. needAlphaBlending(): boolean;
  91993. needAlphaTesting(): boolean;
  91994. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91995. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91996. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91997. getAnimatables(): BABYLON.IAnimatable[];
  91998. getActiveTextures(): BABYLON.BaseTexture[];
  91999. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92000. dispose(forceDisposeEffect?: boolean): void;
  92001. getClassName(): string;
  92002. clone(name: string): CellMaterial;
  92003. serialize(): any;
  92004. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  92005. }
  92006. }
  92007. declare module BABYLON {
  92008. export class CustomShaderStructure {
  92009. FragmentStore: string;
  92010. VertexStore: string;
  92011. constructor();
  92012. }
  92013. export class ShaderSpecialParts {
  92014. constructor();
  92015. Fragment_Begin: string;
  92016. Fragment_Definitions: string;
  92017. Fragment_MainBegin: string;
  92018. Fragment_Custom_Diffuse: string;
  92019. Fragment_Before_Lights: string;
  92020. Fragment_Before_Fog: string;
  92021. Fragment_Custom_Alpha: string;
  92022. Fragment_Before_FragColor: string;
  92023. Vertex_Begin: string;
  92024. Vertex_Definitions: string;
  92025. Vertex_MainBegin: string;
  92026. Vertex_Before_PositionUpdated: string;
  92027. Vertex_Before_NormalUpdated: string;
  92028. Vertex_After_WorldPosComputed: string;
  92029. Vertex_MainEnd: string;
  92030. }
  92031. export class CustomMaterial extends BABYLON.StandardMaterial {
  92032. static ShaderIndexer: number;
  92033. CustomParts: ShaderSpecialParts;
  92034. _isCreatedShader: boolean;
  92035. _createdShaderName: string;
  92036. _customUniform: string[];
  92037. _newUniforms: string[];
  92038. _newUniformInstances: {
  92039. [name: string]: any;
  92040. };
  92041. _newSamplerInstances: {
  92042. [name: string]: BABYLON.Texture;
  92043. };
  92044. _customAttributes: string[];
  92045. FragmentShader: string;
  92046. VertexShader: string;
  92047. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  92048. ReviewUniform(name: string, arr: string[]): string[];
  92049. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  92050. constructor(name: string, scene: BABYLON.Scene);
  92051. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  92052. AddAttribute(name: string): CustomMaterial;
  92053. Fragment_Begin(shaderPart: string): CustomMaterial;
  92054. Fragment_Definitions(shaderPart: string): CustomMaterial;
  92055. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  92056. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  92057. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  92058. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  92059. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  92060. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  92061. Vertex_Begin(shaderPart: string): CustomMaterial;
  92062. Vertex_Definitions(shaderPart: string): CustomMaterial;
  92063. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  92064. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  92065. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  92066. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  92067. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  92068. }
  92069. }
  92070. declare module BABYLON {
  92071. export class ShaderAlebdoParts {
  92072. constructor();
  92073. Fragment_Begin: string;
  92074. Fragment_Definitions: string;
  92075. Fragment_MainBegin: string;
  92076. Fragment_Custom_Albedo: string;
  92077. Fragment_Before_Lights: string;
  92078. Fragment_Custom_MetallicRoughness: string;
  92079. Fragment_Custom_MicroSurface: string;
  92080. Fragment_Before_Fog: string;
  92081. Fragment_Custom_Alpha: string;
  92082. Fragment_Before_FragColor: string;
  92083. Vertex_Begin: string;
  92084. Vertex_Definitions: string;
  92085. Vertex_MainBegin: string;
  92086. Vertex_Before_PositionUpdated: string;
  92087. Vertex_Before_NormalUpdated: string;
  92088. Vertex_After_WorldPosComputed: string;
  92089. Vertex_MainEnd: string;
  92090. }
  92091. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  92092. static ShaderIndexer: number;
  92093. CustomParts: ShaderAlebdoParts;
  92094. _isCreatedShader: boolean;
  92095. _createdShaderName: string;
  92096. _customUniform: string[];
  92097. _newUniforms: string[];
  92098. _newUniformInstances: {
  92099. [name: string]: any;
  92100. };
  92101. _newSamplerInstances: {
  92102. [name: string]: BABYLON.Texture;
  92103. };
  92104. _customAttributes: string[];
  92105. FragmentShader: string;
  92106. VertexShader: string;
  92107. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  92108. ReviewUniform(name: string, arr: string[]): string[];
  92109. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[], options?: BABYLON.ICustomShaderNameResolveOptions): string;
  92110. constructor(name: string, scene: BABYLON.Scene);
  92111. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  92112. AddAttribute(name: string): PBRCustomMaterial;
  92113. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  92114. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  92115. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  92116. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  92117. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  92118. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  92119. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  92120. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  92121. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  92122. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  92123. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  92124. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  92125. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  92126. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  92127. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  92128. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  92129. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  92130. }
  92131. }
  92132. declare module BABYLON {
  92133. /** @hidden */
  92134. export var firePixelShader: {
  92135. name: string;
  92136. shader: string;
  92137. };
  92138. }
  92139. declare module BABYLON {
  92140. /** @hidden */
  92141. export var fireVertexShader: {
  92142. name: string;
  92143. shader: string;
  92144. };
  92145. }
  92146. declare module BABYLON {
  92147. export class FireMaterial extends BABYLON.PushMaterial {
  92148. private _diffuseTexture;
  92149. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  92150. private _distortionTexture;
  92151. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  92152. private _opacityTexture;
  92153. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  92154. diffuseColor: BABYLON.Color3;
  92155. speed: number;
  92156. private _scaledDiffuse;
  92157. private _lastTime;
  92158. constructor(name: string, scene: BABYLON.Scene);
  92159. needAlphaBlending(): boolean;
  92160. needAlphaTesting(): boolean;
  92161. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92162. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92163. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92164. getAnimatables(): BABYLON.IAnimatable[];
  92165. getActiveTextures(): BABYLON.BaseTexture[];
  92166. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92167. getClassName(): string;
  92168. dispose(forceDisposeEffect?: boolean): void;
  92169. clone(name: string): FireMaterial;
  92170. serialize(): any;
  92171. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  92172. }
  92173. }
  92174. declare module BABYLON {
  92175. /** @hidden */
  92176. export var furPixelShader: {
  92177. name: string;
  92178. shader: string;
  92179. };
  92180. }
  92181. declare module BABYLON {
  92182. /** @hidden */
  92183. export var furVertexShader: {
  92184. name: string;
  92185. shader: string;
  92186. };
  92187. }
  92188. declare module BABYLON {
  92189. export class FurMaterial extends BABYLON.PushMaterial {
  92190. private _diffuseTexture;
  92191. diffuseTexture: BABYLON.BaseTexture;
  92192. private _heightTexture;
  92193. heightTexture: BABYLON.BaseTexture;
  92194. diffuseColor: BABYLON.Color3;
  92195. furLength: number;
  92196. furAngle: number;
  92197. furColor: BABYLON.Color3;
  92198. furOffset: number;
  92199. furSpacing: number;
  92200. furGravity: BABYLON.Vector3;
  92201. furSpeed: number;
  92202. furDensity: number;
  92203. furOcclusion: number;
  92204. furTexture: BABYLON.DynamicTexture;
  92205. private _disableLighting;
  92206. disableLighting: boolean;
  92207. private _maxSimultaneousLights;
  92208. maxSimultaneousLights: number;
  92209. highLevelFur: boolean;
  92210. _meshes: BABYLON.AbstractMesh[];
  92211. private _furTime;
  92212. constructor(name: string, scene: BABYLON.Scene);
  92213. get furTime(): number;
  92214. set furTime(furTime: number);
  92215. needAlphaBlending(): boolean;
  92216. needAlphaTesting(): boolean;
  92217. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92218. updateFur(): void;
  92219. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92220. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92221. getAnimatables(): BABYLON.IAnimatable[];
  92222. getActiveTextures(): BABYLON.BaseTexture[];
  92223. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92224. dispose(forceDisposeEffect?: boolean): void;
  92225. clone(name: string): FurMaterial;
  92226. serialize(): any;
  92227. getClassName(): string;
  92228. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  92229. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  92230. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  92231. }
  92232. }
  92233. declare module BABYLON {
  92234. /** @hidden */
  92235. export var gradientPixelShader: {
  92236. name: string;
  92237. shader: string;
  92238. };
  92239. }
  92240. declare module BABYLON {
  92241. /** @hidden */
  92242. export var gradientVertexShader: {
  92243. name: string;
  92244. shader: string;
  92245. };
  92246. }
  92247. declare module BABYLON {
  92248. export class GradientMaterial extends BABYLON.PushMaterial {
  92249. private _maxSimultaneousLights;
  92250. maxSimultaneousLights: number;
  92251. topColor: BABYLON.Color3;
  92252. topColorAlpha: number;
  92253. bottomColor: BABYLON.Color3;
  92254. bottomColorAlpha: number;
  92255. offset: number;
  92256. scale: number;
  92257. smoothness: number;
  92258. private _disableLighting;
  92259. disableLighting: boolean;
  92260. constructor(name: string, scene: BABYLON.Scene);
  92261. needAlphaBlending(): boolean;
  92262. needAlphaTesting(): boolean;
  92263. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92264. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92265. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92266. getAnimatables(): BABYLON.IAnimatable[];
  92267. dispose(forceDisposeEffect?: boolean): void;
  92268. clone(name: string): GradientMaterial;
  92269. serialize(): any;
  92270. getClassName(): string;
  92271. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  92272. }
  92273. }
  92274. declare module BABYLON {
  92275. /** @hidden */
  92276. export var gridPixelShader: {
  92277. name: string;
  92278. shader: string;
  92279. };
  92280. }
  92281. declare module BABYLON {
  92282. /** @hidden */
  92283. export var gridVertexShader: {
  92284. name: string;
  92285. shader: string;
  92286. };
  92287. }
  92288. declare module BABYLON {
  92289. /**
  92290. * The grid materials allows you to wrap any shape with a grid.
  92291. * Colors are customizable.
  92292. */
  92293. export class GridMaterial extends BABYLON.PushMaterial {
  92294. /**
  92295. * Main color of the grid (e.g. between lines)
  92296. */
  92297. mainColor: BABYLON.Color3;
  92298. /**
  92299. * Color of the grid lines.
  92300. */
  92301. lineColor: BABYLON.Color3;
  92302. /**
  92303. * The scale of the grid compared to unit.
  92304. */
  92305. gridRatio: number;
  92306. /**
  92307. * Allows setting an offset for the grid lines.
  92308. */
  92309. gridOffset: BABYLON.Vector3;
  92310. /**
  92311. * The frequency of thicker lines.
  92312. */
  92313. majorUnitFrequency: number;
  92314. /**
  92315. * The visibility of minor units in the grid.
  92316. */
  92317. minorUnitVisibility: number;
  92318. /**
  92319. * The grid opacity outside of the lines.
  92320. */
  92321. opacity: number;
  92322. /**
  92323. * Determine RBG output is premultiplied by alpha value.
  92324. */
  92325. preMultiplyAlpha: boolean;
  92326. private _opacityTexture;
  92327. opacityTexture: BABYLON.BaseTexture;
  92328. private _gridControl;
  92329. /**
  92330. * constructor
  92331. * @param name The name given to the material in order to identify it afterwards.
  92332. * @param scene The scene the material is used in.
  92333. */
  92334. constructor(name: string, scene: BABYLON.Scene);
  92335. /**
  92336. * Returns wehter or not the grid requires alpha blending.
  92337. */
  92338. needAlphaBlending(): boolean;
  92339. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  92340. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92341. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92342. /**
  92343. * Dispose the material and its associated resources.
  92344. * @param forceDisposeEffect will also dispose the used effect when true
  92345. */
  92346. dispose(forceDisposeEffect?: boolean): void;
  92347. clone(name: string): GridMaterial;
  92348. serialize(): any;
  92349. getClassName(): string;
  92350. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  92351. }
  92352. }
  92353. declare module BABYLON {
  92354. /** @hidden */
  92355. export var lavaPixelShader: {
  92356. name: string;
  92357. shader: string;
  92358. };
  92359. }
  92360. declare module BABYLON {
  92361. /** @hidden */
  92362. export var lavaVertexShader: {
  92363. name: string;
  92364. shader: string;
  92365. };
  92366. }
  92367. declare module BABYLON {
  92368. export class LavaMaterial extends BABYLON.PushMaterial {
  92369. private _diffuseTexture;
  92370. diffuseTexture: BABYLON.BaseTexture;
  92371. noiseTexture: BABYLON.BaseTexture;
  92372. fogColor: BABYLON.Color3;
  92373. speed: number;
  92374. movingSpeed: number;
  92375. lowFrequencySpeed: number;
  92376. fogDensity: number;
  92377. private _lastTime;
  92378. diffuseColor: BABYLON.Color3;
  92379. private _disableLighting;
  92380. disableLighting: boolean;
  92381. private _unlit;
  92382. unlit: boolean;
  92383. private _maxSimultaneousLights;
  92384. maxSimultaneousLights: number;
  92385. private _scaledDiffuse;
  92386. constructor(name: string, scene: BABYLON.Scene);
  92387. needAlphaBlending(): boolean;
  92388. needAlphaTesting(): boolean;
  92389. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92390. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92391. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92392. getAnimatables(): BABYLON.IAnimatable[];
  92393. getActiveTextures(): BABYLON.BaseTexture[];
  92394. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92395. dispose(forceDisposeEffect?: boolean): void;
  92396. clone(name: string): LavaMaterial;
  92397. serialize(): any;
  92398. getClassName(): string;
  92399. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  92400. }
  92401. }
  92402. declare module BABYLON {
  92403. /** @hidden */
  92404. export var mixPixelShader: {
  92405. name: string;
  92406. shader: string;
  92407. };
  92408. }
  92409. declare module BABYLON {
  92410. /** @hidden */
  92411. export var mixVertexShader: {
  92412. name: string;
  92413. shader: string;
  92414. };
  92415. }
  92416. declare module BABYLON {
  92417. export class MixMaterial extends BABYLON.PushMaterial {
  92418. /**
  92419. * Mix textures
  92420. */
  92421. private _mixTexture1;
  92422. mixTexture1: BABYLON.BaseTexture;
  92423. private _mixTexture2;
  92424. mixTexture2: BABYLON.BaseTexture;
  92425. /**
  92426. * Diffuse textures
  92427. */
  92428. private _diffuseTexture1;
  92429. diffuseTexture1: BABYLON.Texture;
  92430. private _diffuseTexture2;
  92431. diffuseTexture2: BABYLON.Texture;
  92432. private _diffuseTexture3;
  92433. diffuseTexture3: BABYLON.Texture;
  92434. private _diffuseTexture4;
  92435. diffuseTexture4: BABYLON.Texture;
  92436. private _diffuseTexture5;
  92437. diffuseTexture5: BABYLON.Texture;
  92438. private _diffuseTexture6;
  92439. diffuseTexture6: BABYLON.Texture;
  92440. private _diffuseTexture7;
  92441. diffuseTexture7: BABYLON.Texture;
  92442. private _diffuseTexture8;
  92443. diffuseTexture8: BABYLON.Texture;
  92444. /**
  92445. * Uniforms
  92446. */
  92447. diffuseColor: BABYLON.Color3;
  92448. specularColor: BABYLON.Color3;
  92449. specularPower: number;
  92450. private _disableLighting;
  92451. disableLighting: boolean;
  92452. private _maxSimultaneousLights;
  92453. maxSimultaneousLights: number;
  92454. constructor(name: string, scene: BABYLON.Scene);
  92455. needAlphaBlending(): boolean;
  92456. needAlphaTesting(): boolean;
  92457. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92458. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92459. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92460. getAnimatables(): BABYLON.IAnimatable[];
  92461. getActiveTextures(): BABYLON.BaseTexture[];
  92462. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92463. dispose(forceDisposeEffect?: boolean): void;
  92464. clone(name: string): MixMaterial;
  92465. serialize(): any;
  92466. getClassName(): string;
  92467. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  92468. }
  92469. }
  92470. declare module BABYLON {
  92471. /** @hidden */
  92472. export var normalPixelShader: {
  92473. name: string;
  92474. shader: string;
  92475. };
  92476. }
  92477. declare module BABYLON {
  92478. /** @hidden */
  92479. export var normalVertexShader: {
  92480. name: string;
  92481. shader: string;
  92482. };
  92483. }
  92484. declare module BABYLON {
  92485. export class NormalMaterial extends BABYLON.PushMaterial {
  92486. private _diffuseTexture;
  92487. diffuseTexture: BABYLON.BaseTexture;
  92488. diffuseColor: BABYLON.Color3;
  92489. private _disableLighting;
  92490. disableLighting: boolean;
  92491. private _maxSimultaneousLights;
  92492. maxSimultaneousLights: number;
  92493. constructor(name: string, scene: BABYLON.Scene);
  92494. needAlphaBlending(): boolean;
  92495. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  92496. needAlphaTesting(): boolean;
  92497. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92498. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92499. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92500. getAnimatables(): BABYLON.IAnimatable[];
  92501. getActiveTextures(): BABYLON.BaseTexture[];
  92502. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92503. dispose(forceDisposeEffect?: boolean): void;
  92504. clone(name: string): NormalMaterial;
  92505. serialize(): any;
  92506. getClassName(): string;
  92507. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  92508. }
  92509. }
  92510. declare module BABYLON {
  92511. /** @hidden */
  92512. export var shadowOnlyPixelShader: {
  92513. name: string;
  92514. shader: string;
  92515. };
  92516. }
  92517. declare module BABYLON {
  92518. /** @hidden */
  92519. export var shadowOnlyVertexShader: {
  92520. name: string;
  92521. shader: string;
  92522. };
  92523. }
  92524. declare module BABYLON {
  92525. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  92526. private _activeLight;
  92527. private _needAlphaBlending;
  92528. constructor(name: string, scene: BABYLON.Scene);
  92529. shadowColor: BABYLON.Color3;
  92530. needAlphaBlending(): boolean;
  92531. needAlphaTesting(): boolean;
  92532. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92533. get activeLight(): BABYLON.IShadowLight;
  92534. set activeLight(light: BABYLON.IShadowLight);
  92535. private _getFirstShadowLightForMesh;
  92536. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92537. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92538. clone(name: string): ShadowOnlyMaterial;
  92539. serialize(): any;
  92540. getClassName(): string;
  92541. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  92542. }
  92543. }
  92544. declare module BABYLON {
  92545. /** @hidden */
  92546. export var simplePixelShader: {
  92547. name: string;
  92548. shader: string;
  92549. };
  92550. }
  92551. declare module BABYLON {
  92552. /** @hidden */
  92553. export var simpleVertexShader: {
  92554. name: string;
  92555. shader: string;
  92556. };
  92557. }
  92558. declare module BABYLON {
  92559. export class SimpleMaterial extends BABYLON.PushMaterial {
  92560. private _diffuseTexture;
  92561. diffuseTexture: BABYLON.BaseTexture;
  92562. diffuseColor: BABYLON.Color3;
  92563. private _disableLighting;
  92564. disableLighting: boolean;
  92565. private _maxSimultaneousLights;
  92566. maxSimultaneousLights: number;
  92567. constructor(name: string, scene: BABYLON.Scene);
  92568. needAlphaBlending(): boolean;
  92569. needAlphaTesting(): boolean;
  92570. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92571. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92572. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92573. getAnimatables(): BABYLON.IAnimatable[];
  92574. getActiveTextures(): BABYLON.BaseTexture[];
  92575. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92576. dispose(forceDisposeEffect?: boolean): void;
  92577. clone(name: string): SimpleMaterial;
  92578. serialize(): any;
  92579. getClassName(): string;
  92580. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  92581. }
  92582. }
  92583. declare module BABYLON {
  92584. /** @hidden */
  92585. export var skyPixelShader: {
  92586. name: string;
  92587. shader: string;
  92588. };
  92589. }
  92590. declare module BABYLON {
  92591. /** @hidden */
  92592. export var skyVertexShader: {
  92593. name: string;
  92594. shader: string;
  92595. };
  92596. }
  92597. declare module BABYLON {
  92598. /**
  92599. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  92600. * @see https://doc.babylonjs.com/extensions/sky
  92601. */
  92602. export class SkyMaterial extends BABYLON.PushMaterial {
  92603. /**
  92604. * Defines the overall luminance of sky in interval ]0, 1[.
  92605. */
  92606. luminance: number;
  92607. /**
  92608. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  92609. */
  92610. turbidity: number;
  92611. /**
  92612. * Defines the sky appearance (light intensity).
  92613. */
  92614. rayleigh: number;
  92615. /**
  92616. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  92617. */
  92618. mieCoefficient: number;
  92619. /**
  92620. * Defines the amount of haze particles following the Mie scattering theory.
  92621. */
  92622. mieDirectionalG: number;
  92623. /**
  92624. * Defines the distance of the sun according to the active scene camera.
  92625. */
  92626. distance: number;
  92627. /**
  92628. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  92629. * "inclined".
  92630. */
  92631. inclination: number;
  92632. /**
  92633. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  92634. * an object direction and a reference direction.
  92635. */
  92636. azimuth: number;
  92637. /**
  92638. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  92639. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  92640. */
  92641. sunPosition: BABYLON.Vector3;
  92642. /**
  92643. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  92644. * .sunPosition property.
  92645. */
  92646. useSunPosition: boolean;
  92647. /**
  92648. * Defines an offset vector used to get a horizon offset.
  92649. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  92650. */
  92651. cameraOffset: BABYLON.Vector3;
  92652. /**
  92653. * Defines the vector the skyMaterial should consider as up. (default is BABYLON.Vector3(0, 1, 0) as returned by BABYLON.Vector3.Up())
  92654. */
  92655. up: BABYLON.Vector3;
  92656. private _cameraPosition;
  92657. private _skyOrientation;
  92658. /**
  92659. * Instantiates a new sky material.
  92660. * This material allows to create dynamic and texture free
  92661. * effects for skyboxes by taking care of the atmosphere state.
  92662. * @see https://doc.babylonjs.com/extensions/sky
  92663. * @param name Define the name of the material in the scene
  92664. * @param scene Define the scene the material belong to
  92665. */
  92666. constructor(name: string, scene: BABYLON.Scene);
  92667. /**
  92668. * Specifies if the material will require alpha blending
  92669. * @returns a boolean specifying if alpha blending is needed
  92670. */
  92671. needAlphaBlending(): boolean;
  92672. /**
  92673. * Specifies if this material should be rendered in alpha test mode
  92674. * @returns false as the sky material doesn't need alpha testing.
  92675. */
  92676. needAlphaTesting(): boolean;
  92677. /**
  92678. * Get the texture used for alpha test purpose.
  92679. * @returns null as the sky material has no texture.
  92680. */
  92681. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92682. /**
  92683. * Get if the submesh is ready to be used and all its information available.
  92684. * Child classes can use it to update shaders
  92685. * @param mesh defines the mesh to check
  92686. * @param subMesh defines which submesh to check
  92687. * @param useInstances specifies that instances should be used
  92688. * @returns a boolean indicating that the submesh is ready or not
  92689. */
  92690. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92691. /**
  92692. * Binds the submesh to this material by preparing the effect and shader to draw
  92693. * @param world defines the world transformation matrix
  92694. * @param mesh defines the mesh containing the submesh
  92695. * @param subMesh defines the submesh to bind the material to
  92696. */
  92697. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92698. /**
  92699. * Get the list of animatables in the material.
  92700. * @returns the list of animatables object used in the material
  92701. */
  92702. getAnimatables(): BABYLON.IAnimatable[];
  92703. /**
  92704. * Disposes the material
  92705. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  92706. */
  92707. dispose(forceDisposeEffect?: boolean): void;
  92708. /**
  92709. * Makes a duplicate of the material, and gives it a new name
  92710. * @param name defines the new name for the duplicated material
  92711. * @returns the cloned material
  92712. */
  92713. clone(name: string): SkyMaterial;
  92714. /**
  92715. * Serializes this material in a JSON representation
  92716. * @returns the serialized material object
  92717. */
  92718. serialize(): any;
  92719. /**
  92720. * Gets the current class name of the material e.g. "SkyMaterial"
  92721. * Mainly use in serialization.
  92722. * @returns the class name
  92723. */
  92724. getClassName(): string;
  92725. /**
  92726. * Creates a sky material from parsed material data
  92727. * @param source defines the JSON representation of the material
  92728. * @param scene defines the hosting scene
  92729. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92730. * @returns a new sky material
  92731. */
  92732. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  92733. }
  92734. }
  92735. declare module BABYLON {
  92736. /** @hidden */
  92737. export var terrainPixelShader: {
  92738. name: string;
  92739. shader: string;
  92740. };
  92741. }
  92742. declare module BABYLON {
  92743. /** @hidden */
  92744. export var terrainVertexShader: {
  92745. name: string;
  92746. shader: string;
  92747. };
  92748. }
  92749. declare module BABYLON {
  92750. export class TerrainMaterial extends BABYLON.PushMaterial {
  92751. private _mixTexture;
  92752. mixTexture: BABYLON.BaseTexture;
  92753. private _diffuseTexture1;
  92754. diffuseTexture1: BABYLON.Texture;
  92755. private _diffuseTexture2;
  92756. diffuseTexture2: BABYLON.Texture;
  92757. private _diffuseTexture3;
  92758. diffuseTexture3: BABYLON.Texture;
  92759. private _bumpTexture1;
  92760. bumpTexture1: BABYLON.Texture;
  92761. private _bumpTexture2;
  92762. bumpTexture2: BABYLON.Texture;
  92763. private _bumpTexture3;
  92764. bumpTexture3: BABYLON.Texture;
  92765. diffuseColor: BABYLON.Color3;
  92766. specularColor: BABYLON.Color3;
  92767. specularPower: number;
  92768. private _disableLighting;
  92769. disableLighting: boolean;
  92770. private _maxSimultaneousLights;
  92771. maxSimultaneousLights: number;
  92772. constructor(name: string, scene: BABYLON.Scene);
  92773. needAlphaBlending(): boolean;
  92774. needAlphaTesting(): boolean;
  92775. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92776. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92777. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92778. getAnimatables(): BABYLON.IAnimatable[];
  92779. getActiveTextures(): BABYLON.BaseTexture[];
  92780. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92781. dispose(forceDisposeEffect?: boolean): void;
  92782. clone(name: string): TerrainMaterial;
  92783. serialize(): any;
  92784. getClassName(): string;
  92785. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  92786. }
  92787. }
  92788. declare module BABYLON {
  92789. /** @hidden */
  92790. export var triplanarPixelShader: {
  92791. name: string;
  92792. shader: string;
  92793. };
  92794. }
  92795. declare module BABYLON {
  92796. /** @hidden */
  92797. export var triplanarVertexShader: {
  92798. name: string;
  92799. shader: string;
  92800. };
  92801. }
  92802. declare module BABYLON {
  92803. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  92804. mixTexture: BABYLON.BaseTexture;
  92805. private _diffuseTextureX;
  92806. diffuseTextureX: BABYLON.BaseTexture;
  92807. private _diffuseTextureY;
  92808. diffuseTextureY: BABYLON.BaseTexture;
  92809. private _diffuseTextureZ;
  92810. diffuseTextureZ: BABYLON.BaseTexture;
  92811. private _normalTextureX;
  92812. normalTextureX: BABYLON.BaseTexture;
  92813. private _normalTextureY;
  92814. normalTextureY: BABYLON.BaseTexture;
  92815. private _normalTextureZ;
  92816. normalTextureZ: BABYLON.BaseTexture;
  92817. tileSize: number;
  92818. diffuseColor: BABYLON.Color3;
  92819. specularColor: BABYLON.Color3;
  92820. specularPower: number;
  92821. private _disableLighting;
  92822. disableLighting: boolean;
  92823. private _maxSimultaneousLights;
  92824. maxSimultaneousLights: number;
  92825. constructor(name: string, scene: BABYLON.Scene);
  92826. needAlphaBlending(): boolean;
  92827. needAlphaTesting(): boolean;
  92828. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92829. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92830. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92831. getAnimatables(): BABYLON.IAnimatable[];
  92832. getActiveTextures(): BABYLON.BaseTexture[];
  92833. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92834. dispose(forceDisposeEffect?: boolean): void;
  92835. clone(name: string): TriPlanarMaterial;
  92836. serialize(): any;
  92837. getClassName(): string;
  92838. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  92839. }
  92840. }
  92841. declare module BABYLON {
  92842. /** @hidden */
  92843. export var waterPixelShader: {
  92844. name: string;
  92845. shader: string;
  92846. };
  92847. }
  92848. declare module BABYLON {
  92849. /** @hidden */
  92850. export var waterVertexShader: {
  92851. name: string;
  92852. shader: string;
  92853. };
  92854. }
  92855. declare module BABYLON {
  92856. export class WaterMaterial extends BABYLON.PushMaterial {
  92857. renderTargetSize: BABYLON.Vector2;
  92858. private _bumpTexture;
  92859. bumpTexture: BABYLON.BaseTexture;
  92860. diffuseColor: BABYLON.Color3;
  92861. specularColor: BABYLON.Color3;
  92862. specularPower: number;
  92863. private _disableLighting;
  92864. disableLighting: boolean;
  92865. private _maxSimultaneousLights;
  92866. maxSimultaneousLights: number;
  92867. /**
  92868. * Defines the wind force.
  92869. */
  92870. windForce: number;
  92871. /**
  92872. * Defines the direction of the wind in the plane (X, Z).
  92873. */
  92874. windDirection: BABYLON.Vector2;
  92875. /**
  92876. * Defines the height of the waves.
  92877. */
  92878. waveHeight: number;
  92879. /**
  92880. * Defines the bump height related to the bump map.
  92881. */
  92882. bumpHeight: number;
  92883. /**
  92884. * Defines wether or not: to add a smaller moving bump to less steady waves.
  92885. */
  92886. private _bumpSuperimpose;
  92887. bumpSuperimpose: boolean;
  92888. /**
  92889. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  92890. */
  92891. private _fresnelSeparate;
  92892. fresnelSeparate: boolean;
  92893. /**
  92894. * Defines wether or not bump Wwves modify the reflection.
  92895. */
  92896. private _bumpAffectsReflection;
  92897. bumpAffectsReflection: boolean;
  92898. /**
  92899. * Defines the water color blended with the refraction (near).
  92900. */
  92901. waterColor: BABYLON.Color3;
  92902. /**
  92903. * Defines the blend factor related to the water color.
  92904. */
  92905. colorBlendFactor: number;
  92906. /**
  92907. * Defines the water color blended with the reflection (far).
  92908. */
  92909. waterColor2: BABYLON.Color3;
  92910. /**
  92911. * Defines the blend factor related to the water color (reflection, far).
  92912. */
  92913. colorBlendFactor2: number;
  92914. /**
  92915. * Defines the maximum length of a wave.
  92916. */
  92917. waveLength: number;
  92918. /**
  92919. * Defines the waves speed.
  92920. */
  92921. waveSpeed: number;
  92922. /**
  92923. * 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.
  92924. */
  92925. waveCount: number;
  92926. /**
  92927. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  92928. * will avoid calculating useless pixels in the pixel shader of the water material.
  92929. */
  92930. disableClipPlane: boolean;
  92931. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  92932. private _mesh;
  92933. private _refractionRTT;
  92934. private _reflectionRTT;
  92935. private _reflectionTransform;
  92936. private _lastTime;
  92937. private _lastDeltaTime;
  92938. private _useLogarithmicDepth;
  92939. private _waitingRenderList;
  92940. private _imageProcessingConfiguration;
  92941. private _imageProcessingObserver;
  92942. /**
  92943. * Gets a boolean indicating that current material needs to register RTT
  92944. */
  92945. get hasRenderTargetTextures(): boolean;
  92946. /**
  92947. * Constructor
  92948. */
  92949. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  92950. get useLogarithmicDepth(): boolean;
  92951. set useLogarithmicDepth(value: boolean);
  92952. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  92953. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  92954. addToRenderList(node: any): void;
  92955. enableRenderTargets(enable: boolean): void;
  92956. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  92957. get renderTargetsEnabled(): boolean;
  92958. needAlphaBlending(): boolean;
  92959. needAlphaTesting(): boolean;
  92960. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92961. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92962. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92963. private _createRenderTargets;
  92964. getAnimatables(): BABYLON.IAnimatable[];
  92965. getActiveTextures(): BABYLON.BaseTexture[];
  92966. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92967. dispose(forceDisposeEffect?: boolean): void;
  92968. clone(name: string): WaterMaterial;
  92969. serialize(): any;
  92970. getClassName(): string;
  92971. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  92972. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  92973. }
  92974. }
  92975. declare module BABYLON {
  92976. /** @hidden */
  92977. export var asciiartPixelShader: {
  92978. name: string;
  92979. shader: string;
  92980. };
  92981. }
  92982. declare module BABYLON {
  92983. /**
  92984. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  92985. *
  92986. * It basically takes care rendering the font front the given font size to a texture.
  92987. * This is used later on in the postprocess.
  92988. */
  92989. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  92990. private _font;
  92991. private _text;
  92992. private _charSize;
  92993. /**
  92994. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  92995. */
  92996. get charSize(): number;
  92997. /**
  92998. * Create a new instance of the Ascii Art FontTexture class
  92999. * @param name the name of the texture
  93000. * @param font the font to use, use the W3C CSS notation
  93001. * @param text the caracter set to use in the rendering.
  93002. * @param scene the scene that owns the texture
  93003. */
  93004. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  93005. /**
  93006. * Gets the max char width of a font.
  93007. * @param font the font to use, use the W3C CSS notation
  93008. * @return the max char width
  93009. */
  93010. private getFontWidth;
  93011. /**
  93012. * Gets the max char height of a font.
  93013. * @param font the font to use, use the W3C CSS notation
  93014. * @return the max char height
  93015. */
  93016. private getFontHeight;
  93017. /**
  93018. * Clones the current AsciiArtTexture.
  93019. * @return the clone of the texture.
  93020. */
  93021. clone(): AsciiArtFontTexture;
  93022. /**
  93023. * Parses a json object representing the texture and returns an instance of it.
  93024. * @param source the source JSON representation
  93025. * @param scene the scene to create the texture for
  93026. * @return the parsed texture
  93027. */
  93028. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  93029. }
  93030. /**
  93031. * Option available in the Ascii Art Post Process.
  93032. */
  93033. export interface IAsciiArtPostProcessOptions {
  93034. /**
  93035. * The font to use following the w3c font definition.
  93036. */
  93037. font?: string;
  93038. /**
  93039. * The character set to use in the postprocess.
  93040. */
  93041. characterSet?: string;
  93042. /**
  93043. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  93044. * This number is defined between 0 and 1;
  93045. */
  93046. mixToTile?: number;
  93047. /**
  93048. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  93049. * This number is defined between 0 and 1;
  93050. */
  93051. mixToNormal?: number;
  93052. }
  93053. /**
  93054. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  93055. *
  93056. * Simmply add it to your scene and let the nerd that lives in you have fun.
  93057. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  93058. */
  93059. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  93060. /**
  93061. * The font texture used to render the char in the post process.
  93062. */
  93063. private _asciiArtFontTexture;
  93064. /**
  93065. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  93066. * This number is defined between 0 and 1;
  93067. */
  93068. mixToTile: number;
  93069. /**
  93070. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  93071. * This number is defined between 0 and 1;
  93072. */
  93073. mixToNormal: number;
  93074. /**
  93075. * Instantiates a new Ascii Art Post Process.
  93076. * @param name the name to give to the postprocess
  93077. * @camera the camera to apply the post process to.
  93078. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  93079. */
  93080. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  93081. }
  93082. }
  93083. declare module BABYLON {
  93084. /** @hidden */
  93085. export var digitalrainPixelShader: {
  93086. name: string;
  93087. shader: string;
  93088. };
  93089. }
  93090. declare module BABYLON {
  93091. /**
  93092. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  93093. *
  93094. * It basically takes care rendering the font front the given font size to a texture.
  93095. * This is used later on in the postprocess.
  93096. */
  93097. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  93098. private _font;
  93099. private _text;
  93100. private _charSize;
  93101. /**
  93102. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  93103. */
  93104. get charSize(): number;
  93105. /**
  93106. * Create a new instance of the Digital Rain FontTexture class
  93107. * @param name the name of the texture
  93108. * @param font the font to use, use the W3C CSS notation
  93109. * @param text the caracter set to use in the rendering.
  93110. * @param scene the scene that owns the texture
  93111. */
  93112. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  93113. /**
  93114. * Gets the max char width of a font.
  93115. * @param font the font to use, use the W3C CSS notation
  93116. * @return the max char width
  93117. */
  93118. private getFontWidth;
  93119. /**
  93120. * Gets the max char height of a font.
  93121. * @param font the font to use, use the W3C CSS notation
  93122. * @return the max char height
  93123. */
  93124. private getFontHeight;
  93125. /**
  93126. * Clones the current DigitalRainFontTexture.
  93127. * @return the clone of the texture.
  93128. */
  93129. clone(): DigitalRainFontTexture;
  93130. /**
  93131. * Parses a json object representing the texture and returns an instance of it.
  93132. * @param source the source JSON representation
  93133. * @param scene the scene to create the texture for
  93134. * @return the parsed texture
  93135. */
  93136. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  93137. }
  93138. /**
  93139. * Option available in the Digital Rain Post Process.
  93140. */
  93141. export interface IDigitalRainPostProcessOptions {
  93142. /**
  93143. * The font to use following the w3c font definition.
  93144. */
  93145. font?: string;
  93146. /**
  93147. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  93148. * This number is defined between 0 and 1;
  93149. */
  93150. mixToTile?: number;
  93151. /**
  93152. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  93153. * This number is defined between 0 and 1;
  93154. */
  93155. mixToNormal?: number;
  93156. }
  93157. /**
  93158. * DigitalRainPostProcess helps rendering everithing in digital rain.
  93159. *
  93160. * Simmply add it to your scene and let the nerd that lives in you have fun.
  93161. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  93162. */
  93163. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  93164. /**
  93165. * The font texture used to render the char in the post process.
  93166. */
  93167. private _digitalRainFontTexture;
  93168. /**
  93169. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  93170. * This number is defined between 0 and 1;
  93171. */
  93172. mixToTile: number;
  93173. /**
  93174. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  93175. * This number is defined between 0 and 1;
  93176. */
  93177. mixToNormal: number;
  93178. /**
  93179. * Instantiates a new Digital Rain Post Process.
  93180. * @param name the name to give to the postprocess
  93181. * @camera the camera to apply the post process to.
  93182. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  93183. */
  93184. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  93185. }
  93186. }
  93187. declare module BABYLON {
  93188. /** @hidden */
  93189. export var brickProceduralTexturePixelShader: {
  93190. name: string;
  93191. shader: string;
  93192. };
  93193. }
  93194. declare module BABYLON {
  93195. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  93196. private _numberOfBricksHeight;
  93197. private _numberOfBricksWidth;
  93198. private _jointColor;
  93199. private _brickColor;
  93200. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93201. updateShaderUniforms(): void;
  93202. get numberOfBricksHeight(): number;
  93203. set numberOfBricksHeight(value: number);
  93204. get numberOfBricksWidth(): number;
  93205. set numberOfBricksWidth(value: number);
  93206. get jointColor(): BABYLON.Color3;
  93207. set jointColor(value: BABYLON.Color3);
  93208. get brickColor(): BABYLON.Color3;
  93209. set brickColor(value: BABYLON.Color3);
  93210. /**
  93211. * Serializes this brick procedural texture
  93212. * @returns a serialized brick procedural texture object
  93213. */
  93214. serialize(): any;
  93215. /**
  93216. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  93217. * @param parsedTexture defines parsed texture data
  93218. * @param scene defines the current scene
  93219. * @param rootUrl defines the root URL containing brick procedural texture information
  93220. * @returns a parsed Brick Procedural BABYLON.Texture
  93221. */
  93222. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  93223. }
  93224. }
  93225. declare module BABYLON {
  93226. /** @hidden */
  93227. export var cloudProceduralTexturePixelShader: {
  93228. name: string;
  93229. shader: string;
  93230. };
  93231. }
  93232. declare module BABYLON {
  93233. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  93234. private _skyColor;
  93235. private _cloudColor;
  93236. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93237. updateShaderUniforms(): void;
  93238. get skyColor(): BABYLON.Color4;
  93239. set skyColor(value: BABYLON.Color4);
  93240. get cloudColor(): BABYLON.Color4;
  93241. set cloudColor(value: BABYLON.Color4);
  93242. /**
  93243. * Serializes this cloud procedural texture
  93244. * @returns a serialized cloud procedural texture object
  93245. */
  93246. serialize(): any;
  93247. /**
  93248. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  93249. * @param parsedTexture defines parsed texture data
  93250. * @param scene defines the current scene
  93251. * @param rootUrl defines the root URL containing cloud procedural texture information
  93252. * @returns a parsed Cloud Procedural BABYLON.Texture
  93253. */
  93254. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  93255. }
  93256. }
  93257. declare module BABYLON {
  93258. /** @hidden */
  93259. export var fireProceduralTexturePixelShader: {
  93260. name: string;
  93261. shader: string;
  93262. };
  93263. }
  93264. declare module BABYLON {
  93265. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  93266. private _time;
  93267. private _speed;
  93268. private _autoGenerateTime;
  93269. private _fireColors;
  93270. private _alphaThreshold;
  93271. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93272. updateShaderUniforms(): void;
  93273. render(useCameraPostProcess?: boolean): void;
  93274. static get PurpleFireColors(): BABYLON.Color3[];
  93275. static get GreenFireColors(): BABYLON.Color3[];
  93276. static get RedFireColors(): BABYLON.Color3[];
  93277. static get BlueFireColors(): BABYLON.Color3[];
  93278. get autoGenerateTime(): boolean;
  93279. set autoGenerateTime(value: boolean);
  93280. get fireColors(): BABYLON.Color3[];
  93281. set fireColors(value: BABYLON.Color3[]);
  93282. get time(): number;
  93283. set time(value: number);
  93284. get speed(): BABYLON.Vector2;
  93285. set speed(value: BABYLON.Vector2);
  93286. get alphaThreshold(): number;
  93287. set alphaThreshold(value: number);
  93288. /**
  93289. * Serializes this fire procedural texture
  93290. * @returns a serialized fire procedural texture object
  93291. */
  93292. serialize(): any;
  93293. /**
  93294. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  93295. * @param parsedTexture defines parsed texture data
  93296. * @param scene defines the current scene
  93297. * @param rootUrl defines the root URL containing fire procedural texture information
  93298. * @returns a parsed Fire Procedural BABYLON.Texture
  93299. */
  93300. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  93301. }
  93302. }
  93303. declare module BABYLON {
  93304. /** @hidden */
  93305. export var grassProceduralTexturePixelShader: {
  93306. name: string;
  93307. shader: string;
  93308. };
  93309. }
  93310. declare module BABYLON {
  93311. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  93312. private _grassColors;
  93313. private _groundColor;
  93314. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93315. updateShaderUniforms(): void;
  93316. get grassColors(): BABYLON.Color3[];
  93317. set grassColors(value: BABYLON.Color3[]);
  93318. get groundColor(): BABYLON.Color3;
  93319. set groundColor(value: BABYLON.Color3);
  93320. /**
  93321. * Serializes this grass procedural texture
  93322. * @returns a serialized grass procedural texture object
  93323. */
  93324. serialize(): any;
  93325. /**
  93326. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  93327. * @param parsedTexture defines parsed texture data
  93328. * @param scene defines the current scene
  93329. * @param rootUrl defines the root URL containing grass procedural texture information
  93330. * @returns a parsed Grass Procedural BABYLON.Texture
  93331. */
  93332. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  93333. }
  93334. }
  93335. declare module BABYLON {
  93336. /** @hidden */
  93337. export var marbleProceduralTexturePixelShader: {
  93338. name: string;
  93339. shader: string;
  93340. };
  93341. }
  93342. declare module BABYLON {
  93343. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  93344. private _numberOfTilesHeight;
  93345. private _numberOfTilesWidth;
  93346. private _amplitude;
  93347. private _jointColor;
  93348. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93349. updateShaderUniforms(): void;
  93350. get numberOfTilesHeight(): number;
  93351. set numberOfTilesHeight(value: number);
  93352. get amplitude(): number;
  93353. set amplitude(value: number);
  93354. get numberOfTilesWidth(): number;
  93355. set numberOfTilesWidth(value: number);
  93356. get jointColor(): BABYLON.Color3;
  93357. set jointColor(value: BABYLON.Color3);
  93358. /**
  93359. * Serializes this marble procedural texture
  93360. * @returns a serialized marble procedural texture object
  93361. */
  93362. serialize(): any;
  93363. /**
  93364. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  93365. * @param parsedTexture defines parsed texture data
  93366. * @param scene defines the current scene
  93367. * @param rootUrl defines the root URL containing marble procedural texture information
  93368. * @returns a parsed Marble Procedural BABYLON.Texture
  93369. */
  93370. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  93371. }
  93372. }
  93373. declare module BABYLON {
  93374. /** @hidden */
  93375. export var normalMapProceduralTexturePixelShader: {
  93376. name: string;
  93377. shader: string;
  93378. };
  93379. }
  93380. declare module BABYLON {
  93381. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  93382. private _baseTexture;
  93383. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93384. updateShaderUniforms(): void;
  93385. render(useCameraPostProcess?: boolean): void;
  93386. resize(size: any, generateMipMaps: any): void;
  93387. isReady(): boolean;
  93388. get baseTexture(): BABYLON.Texture;
  93389. set baseTexture(texture: BABYLON.Texture);
  93390. /**
  93391. * Serializes this normal map procedural texture
  93392. * @returns a serialized normal map procedural texture object
  93393. */
  93394. serialize(): any;
  93395. /**
  93396. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  93397. * @param parsedTexture defines parsed texture data
  93398. * @param scene defines the current scene
  93399. * @param rootUrl defines the root URL containing normal map procedural texture information
  93400. * @returns a parsed Normal Map Procedural BABYLON.Texture
  93401. */
  93402. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  93403. }
  93404. }
  93405. declare module BABYLON {
  93406. /** @hidden */
  93407. export var perlinNoiseProceduralTexturePixelShader: {
  93408. name: string;
  93409. shader: string;
  93410. };
  93411. }
  93412. declare module BABYLON {
  93413. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  93414. time: number;
  93415. timeScale: number;
  93416. translationSpeed: number;
  93417. private _currentTranslation;
  93418. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93419. updateShaderUniforms(): void;
  93420. render(useCameraPostProcess?: boolean): void;
  93421. resize(size: any, generateMipMaps: any): void;
  93422. /**
  93423. * Serializes this perlin noise procedural texture
  93424. * @returns a serialized perlin noise procedural texture object
  93425. */
  93426. serialize(): any;
  93427. /**
  93428. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  93429. * @param parsedTexture defines parsed texture data
  93430. * @param scene defines the current scene
  93431. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  93432. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  93433. */
  93434. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  93435. }
  93436. }
  93437. declare module BABYLON {
  93438. /** @hidden */
  93439. export var roadProceduralTexturePixelShader: {
  93440. name: string;
  93441. shader: string;
  93442. };
  93443. }
  93444. declare module BABYLON {
  93445. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  93446. private _roadColor;
  93447. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93448. updateShaderUniforms(): void;
  93449. get roadColor(): BABYLON.Color3;
  93450. set roadColor(value: BABYLON.Color3);
  93451. /**
  93452. * Serializes this road procedural texture
  93453. * @returns a serialized road procedural texture object
  93454. */
  93455. serialize(): any;
  93456. /**
  93457. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  93458. * @param parsedTexture defines parsed texture data
  93459. * @param scene defines the current scene
  93460. * @param rootUrl defines the root URL containing road procedural texture information
  93461. * @returns a parsed Road Procedural BABYLON.Texture
  93462. */
  93463. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  93464. }
  93465. }
  93466. declare module BABYLON {
  93467. /** @hidden */
  93468. export var starfieldProceduralTexturePixelShader: {
  93469. name: string;
  93470. shader: string;
  93471. };
  93472. }
  93473. declare module BABYLON {
  93474. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  93475. private _time;
  93476. private _alpha;
  93477. private _beta;
  93478. private _zoom;
  93479. private _formuparam;
  93480. private _stepsize;
  93481. private _tile;
  93482. private _brightness;
  93483. private _darkmatter;
  93484. private _distfading;
  93485. private _saturation;
  93486. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93487. updateShaderUniforms(): void;
  93488. get time(): number;
  93489. set time(value: number);
  93490. get alpha(): number;
  93491. set alpha(value: number);
  93492. get beta(): number;
  93493. set beta(value: number);
  93494. get formuparam(): number;
  93495. set formuparam(value: number);
  93496. get stepsize(): number;
  93497. set stepsize(value: number);
  93498. get zoom(): number;
  93499. set zoom(value: number);
  93500. get tile(): number;
  93501. set tile(value: number);
  93502. get brightness(): number;
  93503. set brightness(value: number);
  93504. get darkmatter(): number;
  93505. set darkmatter(value: number);
  93506. get distfading(): number;
  93507. set distfading(value: number);
  93508. get saturation(): number;
  93509. set saturation(value: number);
  93510. /**
  93511. * Serializes this starfield procedural texture
  93512. * @returns a serialized starfield procedural texture object
  93513. */
  93514. serialize(): any;
  93515. /**
  93516. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  93517. * @param parsedTexture defines parsed texture data
  93518. * @param scene defines the current scene
  93519. * @param rootUrl defines the root URL containing startfield procedural texture information
  93520. * @returns a parsed Starfield Procedural BABYLON.Texture
  93521. */
  93522. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  93523. }
  93524. }
  93525. declare module BABYLON {
  93526. /** @hidden */
  93527. export var woodProceduralTexturePixelShader: {
  93528. name: string;
  93529. shader: string;
  93530. };
  93531. }
  93532. declare module BABYLON {
  93533. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  93534. private _ampScale;
  93535. private _woodColor;
  93536. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93537. updateShaderUniforms(): void;
  93538. get ampScale(): number;
  93539. set ampScale(value: number);
  93540. get woodColor(): BABYLON.Color3;
  93541. set woodColor(value: BABYLON.Color3);
  93542. /**
  93543. * Serializes this wood procedural texture
  93544. * @returns a serialized wood procedural texture object
  93545. */
  93546. serialize(): any;
  93547. /**
  93548. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  93549. * @param parsedTexture defines parsed texture data
  93550. * @param scene defines the current scene
  93551. * @param rootUrl defines the root URL containing wood procedural texture information
  93552. * @returns a parsed Wood Procedural BABYLON.Texture
  93553. */
  93554. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  93555. }
  93556. }