documentation.d.ts 3.8 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975839768397783978839798398083981839828398383984839858398683987839888398983990839918399283993839948399583996839978399883999840008400184002840038400484005840068400784008840098401084011840128401384014840158401684017840188401984020840218402284023840248402584026840278402884029840308403184032840338403484035840368403784038840398404084041840428404384044840458404684047840488404984050840518405284053840548405584056840578405884059840608406184062840638406484065840668406784068840698407084071840728407384074840758407684077840788407984080840818408284083840848408584086840878408884089840908409184092840938409484095840968409784098840998410084101841028410384104841058410684107841088410984110841118411284113841148411584116841178411884119841208412184122841238412484125841268412784128841298413084131841328413384134841358413684137841388413984140841418414284143841448414584146841478414884149841508415184152841538415484155841568415784158841598416084161841628416384164841658416684167841688416984170841718417284173841748417584176841778417884179841808418184182841838418484185841868418784188841898419084191841928419384194841958419684197841988419984200842018420284203842048420584206842078420884209842108421184212842138421484215842168421784218842198422084221842228422384224842258422684227842288422984230842318423284233842348423584236842378423884239842408424184242842438424484245842468424784248842498425084251842528425384254842558425684257842588425984260842618426284263842648426584266842678426884269842708427184272842738427484275842768427784278842798428084281842828428384284842858428684287842888428984290842918429284293842948429584296842978429884299843008430184302843038430484305843068430784308843098431084311843128431384314843158431684317843188431984320843218432284323843248432584326843278432884329843308433184332843338433484335843368433784338843398434084341843428434384344843458434684347843488434984350843518435284353843548435584356843578435884359843608436184362843638436484365843668436784368843698437084371843728437384374843758437684377843788437984380843818438284383843848438584386843878438884389843908439184392843938439484395843968439784398843998440084401844028440384404844058440684407844088440984410844118441284413844148441584416844178441884419844208442184422844238442484425844268442784428844298443084431844328443384434844358443684437844388443984440844418444284443844448444584446844478444884449844508445184452844538445484455844568445784458844598446084461844628446384464844658446684467844688446984470844718447284473844748447584476844778447884479844808448184482844838448484485844868448784488844898449084491844928449384494844958449684497844988449984500845018450284503845048450584506845078450884509845108451184512845138451484515845168451784518845198452084521845228452384524845258452684527845288452984530845318453284533845348453584536845378453884539845408454184542845438454484545845468454784548845498455084551845528455384554845558455684557845588455984560845618456284563845648456584566845678456884569845708457184572845738457484575845768457784578845798458084581845828458384584845858458684587845888458984590845918459284593845948459584596845978459884599846008460184602846038460484605846068460784608846098461084611846128461384614846158461684617846188461984620846218462284623846248462584626846278462884629846308463184632846338463484635846368463784638846398464084641846428464384644846458464684647846488464984650846518465284653846548465584656846578465884659846608466184662846638466484665846668466784668846698467084671846728467384674846758467684677846788467984680846818468284683846848468584686846878468884689846908469184692846938469484695846968469784698846998470084701847028470384704847058470684707847088470984710847118471284713847148471584716847178471884719847208472184722847238472484725847268472784728847298473084731847328473384734847358473684737847388473984740847418474284743847448474584746847478474884749847508475184752847538475484755847568475784758847598476084761847628476384764847658476684767847688476984770847718477284773847748477584776847778477884779847808478184782847838478484785847868478784788847898479084791847928479384794847958479684797847988479984800848018480284803848048480584806848078480884809848108481184812848138481484815848168481784818848198482084821848228482384824848258482684827848288482984830848318483284833848348483584836848378483884839848408484184842848438484484845848468484784848848498485084851848528485384854848558485684857848588485984860848618486284863848648486584866848678486884869848708487184872848738487484875848768487784878848798488084881848828488384884848858488684887848888488984890848918489284893848948489584896848978489884899849008490184902849038490484905849068490784908849098491084911849128491384914849158491684917849188491984920849218492284923849248492584926849278492884929849308493184932849338493484935849368493784938849398494084941849428494384944849458494684947849488494984950849518495284953849548495584956849578495884959849608496184962849638496484965849668496784968849698497084971849728497384974849758497684977849788497984980849818498284983849848498584986849878498884989849908499184992849938499484995849968499784998849998500085001850028500385004850058500685007850088500985010850118501285013850148501585016850178501885019850208502185022850238502485025850268502785028850298503085031850328503385034850358503685037850388503985040850418504285043850448504585046850478504885049850508505185052850538505485055850568505785058850598506085061850628506385064850658506685067850688506985070850718507285073850748507585076850778507885079850808508185082850838508485085850868508785088850898509085091850928509385094850958509685097850988509985100851018510285103851048510585106851078510885109851108511185112851138511485115851168511785118851198512085121851228512385124851258512685127851288512985130851318513285133851348513585136851378513885139851408514185142851438514485145851468514785148851498515085151851528515385154851558515685157851588515985160851618516285163851648516585166851678516885169851708517185172851738517485175851768517785178851798518085181851828518385184851858518685187851888518985190851918519285193851948519585196851978519885199852008520185202852038520485205852068520785208852098521085211852128521385214852158521685217852188521985220852218522285223852248522585226852278522885229852308523185232852338523485235852368523785238852398524085241852428524385244852458524685247852488524985250852518525285253852548525585256852578525885259852608526185262852638526485265852668526785268852698527085271852728527385274852758527685277852788527985280852818528285283852848528585286852878528885289852908529185292852938529485295852968529785298852998530085301853028530385304853058530685307853088530985310853118531285313853148531585316853178531885319853208532185322853238532485325853268532785328853298533085331853328533385334853358533685337853388533985340853418534285343853448534585346853478534885349853508535185352853538535485355853568535785358853598536085361853628536385364853658536685367853688536985370853718537285373853748537585376853778537885379853808538185382853838538485385853868538785388853898539085391853928539385394853958539685397853988539985400854018540285403854048540585406854078540885409854108541185412854138541485415854168541785418854198542085421854228542385424854258542685427854288542985430854318543285433854348543585436854378543885439854408544185442854438544485445854468544785448854498545085451854528545385454854558545685457854588545985460854618546285463854648546585466854678546885469854708547185472854738547485475854768547785478854798548085481854828548385484854858548685487854888548985490854918549285493854948549585496854978549885499855008550185502855038550485505855068550785508855098551085511855128551385514855158551685517855188551985520855218552285523855248552585526855278552885529855308553185532855338553485535855368553785538855398554085541855428554385544855458554685547855488554985550855518555285553855548555585556855578555885559855608556185562855638556485565855668556785568855698557085571855728557385574855758557685577855788557985580855818558285583855848558585586855878558885589855908559185592855938559485595855968559785598855998560085601856028560385604856058560685607856088560985610856118561285613856148561585616856178561885619856208562185622856238562485625856268562785628856298563085631856328563385634856358563685637856388563985640856418564285643856448564585646856478564885649856508565185652856538565485655856568565785658856598566085661856628566385664856658566685667856688566985670856718567285673856748567585676856778567885679856808568185682856838568485685856868568785688856898569085691856928569385694856958569685697856988569985700857018570285703857048570585706857078570885709857108571185712857138571485715857168571785718857198572085721857228572385724857258572685727857288572985730857318573285733857348573585736857378573885739857408574185742857438574485745857468574785748857498575085751857528575385754857558575685757857588575985760857618576285763857648576585766857678576885769857708577185772857738577485775857768577785778857798578085781857828578385784857858578685787857888578985790857918579285793857948579585796857978579885799858008580185802858038580485805858068580785808858098581085811858128581385814858158581685817858188581985820858218582285823858248582585826858278582885829858308583185832858338583485835858368583785838858398584085841858428584385844858458584685847858488584985850858518585285853858548585585856858578585885859858608586185862858638586485865858668586785868858698587085871858728587385874858758587685877858788587985880858818588285883858848588585886858878588885889858908589185892858938589485895858968589785898858998590085901859028590385904859058590685907859088590985910859118591285913859148591585916859178591885919859208592185922859238592485925859268592785928859298593085931859328593385934859358593685937859388593985940859418594285943859448594585946859478594885949859508595185952859538595485955859568595785958859598596085961859628596385964859658596685967859688596985970859718597285973859748597585976859778597885979859808598185982859838598485985859868598785988859898599085991859928599385994859958599685997859988599986000860018600286003860048600586006860078600886009860108601186012860138601486015860168601786018860198602086021860228602386024860258602686027860288602986030860318603286033860348603586036860378603886039860408604186042860438604486045860468604786048860498605086051860528605386054860558605686057860588605986060860618606286063860648606586066860678606886069860708607186072860738607486075860768607786078860798608086081860828608386084860858608686087860888608986090860918609286093860948609586096860978609886099861008610186102861038610486105861068610786108861098611086111861128611386114861158611686117861188611986120861218612286123861248612586126861278612886129861308613186132861338613486135861368613786138861398614086141861428614386144861458614686147861488614986150861518615286153861548615586156861578615886159861608616186162861638616486165861668616786168861698617086171861728617386174861758617686177861788617986180861818618286183861848618586186861878618886189861908619186192861938619486195861968619786198861998620086201862028620386204862058620686207862088620986210862118621286213862148621586216862178621886219862208622186222862238622486225862268622786228862298623086231862328623386234862358623686237862388623986240862418624286243862448624586246862478624886249862508625186252862538625486255862568625786258862598626086261862628626386264862658626686267862688626986270862718627286273862748627586276862778627886279862808628186282862838628486285862868628786288862898629086291862928629386294862958629686297862988629986300863018630286303863048630586306863078630886309863108631186312863138631486315863168631786318863198632086321863228632386324863258632686327863288632986330863318633286333863348633586336863378633886339863408634186342863438634486345863468634786348863498635086351863528635386354863558635686357863588635986360863618636286363863648636586366863678636886369863708637186372863738637486375863768637786378863798638086381863828638386384863858638686387863888638986390863918639286393863948639586396863978639886399864008640186402864038640486405864068640786408864098641086411864128641386414864158641686417864188641986420864218642286423864248642586426864278642886429864308643186432864338643486435864368643786438864398644086441864428644386444864458644686447864488644986450864518645286453864548645586456864578645886459864608646186462864638646486465864668646786468864698647086471864728647386474864758647686477864788647986480864818648286483864848648586486864878648886489864908649186492864938649486495864968649786498864998650086501865028650386504865058650686507865088650986510865118651286513865148651586516865178651886519865208652186522865238652486525865268652786528865298653086531865328653386534865358653686537865388653986540865418654286543865448654586546865478654886549865508655186552865538655486555865568655786558865598656086561865628656386564865658656686567865688656986570865718657286573865748657586576865778657886579865808658186582865838658486585865868658786588865898659086591865928659386594865958659686597865988659986600866018660286603866048660586606866078660886609866108661186612866138661486615866168661786618866198662086621866228662386624866258662686627866288662986630866318663286633866348663586636866378663886639866408664186642866438664486645866468664786648866498665086651866528665386654866558665686657866588665986660866618666286663866648666586666866678666886669866708667186672866738667486675866768667786678866798668086681866828668386684866858668686687866888668986690866918669286693866948669586696866978669886699867008670186702867038670486705867068670786708867098671086711867128671386714867158671686717867188671986720867218672286723867248672586726867278672886729867308673186732867338673486735867368673786738867398674086741867428674386744867458674686747867488674986750867518675286753867548675586756867578675886759867608676186762867638676486765867668676786768867698677086771867728677386774867758677686777867788677986780867818678286783867848678586786867878678886789867908679186792867938679486795867968679786798867998680086801868028680386804868058680686807868088680986810868118681286813868148681586816868178681886819868208682186822868238682486825868268682786828868298683086831868328683386834868358683686837868388683986840868418684286843868448684586846868478684886849868508685186852868538685486855868568685786858868598686086861868628686386864868658686686867868688686986870868718687286873868748687586876868778687886879868808688186882868838688486885868868688786888868898689086891868928689386894868958689686897868988689986900869018690286903869048690586906869078690886909869108691186912869138691486915869168691786918869198692086921869228692386924869258692686927869288692986930869318693286933869348693586936869378693886939869408694186942869438694486945869468694786948869498695086951869528695386954869558695686957869588695986960869618696286963869648696586966869678696886969869708697186972869738697486975869768697786978869798698086981869828698386984869858698686987869888698986990869918699286993869948699586996869978699886999870008700187002870038700487005870068700787008870098701087011870128701387014870158701687017870188701987020870218702287023870248702587026870278702887029870308703187032870338703487035870368703787038870398704087041870428704387044870458704687047870488704987050870518705287053870548705587056870578705887059870608706187062870638706487065870668706787068870698707087071870728707387074870758707687077870788707987080870818708287083870848708587086870878708887089870908709187092870938709487095870968709787098870998710087101871028710387104871058710687107871088710987110871118711287113871148711587116871178711887119871208712187122871238712487125871268712787128871298713087131871328713387134871358713687137871388713987140871418714287143871448714587146871478714887149871508715187152871538715487155871568715787158871598716087161871628716387164871658716687167871688716987170871718717287173871748717587176871778717887179871808718187182871838718487185871868718787188871898719087191871928719387194871958719687197871988719987200872018720287203872048720587206872078720887209872108721187212872138721487215872168721787218872198722087221872228722387224872258722687227872288722987230872318723287233872348723587236872378723887239872408724187242872438724487245872468724787248872498725087251872528725387254872558725687257872588725987260872618726287263872648726587266872678726887269872708727187272872738727487275872768727787278872798728087281872828728387284872858728687287872888728987290872918729287293872948729587296872978729887299873008730187302873038730487305873068730787308873098731087311873128731387314873158731687317873188731987320873218732287323873248732587326873278732887329873308733187332873338733487335873368733787338873398734087341873428734387344873458734687347873488734987350873518735287353873548735587356873578735887359873608736187362873638736487365873668736787368873698737087371873728737387374873758737687377873788737987380873818738287383873848738587386873878738887389873908739187392873938739487395873968739787398873998740087401874028740387404874058740687407874088740987410874118741287413874148741587416874178741887419874208742187422874238742487425874268742787428874298743087431874328743387434874358743687437874388743987440874418744287443874448744587446874478744887449874508745187452874538745487455874568745787458874598746087461874628746387464874658746687467874688746987470874718747287473874748747587476874778747887479874808748187482874838748487485874868748787488874898749087491874928749387494874958749687497874988749987500875018750287503875048750587506875078750887509875108751187512875138751487515875168751787518875198752087521875228752387524875258752687527875288752987530875318753287533875348753587536875378753887539875408754187542875438754487545875468754787548875498755087551875528755387554875558755687557875588755987560875618756287563875648756587566875678756887569875708757187572875738757487575875768757787578875798758087581875828758387584875858758687587875888758987590875918759287593875948759587596875978759887599876008760187602876038760487605876068760787608876098761087611876128761387614876158761687617876188761987620876218762287623876248762587626876278762887629876308763187632876338763487635876368763787638876398764087641876428764387644876458764687647876488764987650876518765287653876548765587656876578765887659876608766187662876638766487665876668766787668876698767087671876728767387674876758767687677876788767987680876818768287683876848768587686876878768887689876908769187692876938769487695876968769787698876998770087701877028770387704877058770687707877088770987710877118771287713877148771587716877178771887719877208772187722877238772487725877268772787728877298773087731877328773387734877358773687737877388773987740877418774287743877448774587746877478774887749877508775187752877538775487755877568775787758877598776087761877628776387764877658776687767877688776987770877718777287773877748777587776877778777887779877808778187782877838778487785877868778787788877898779087791877928779387794877958779687797877988779987800878018780287803878048780587806878078780887809878108781187812878138781487815878168781787818878198782087821878228782387824878258782687827878288782987830878318783287833878348783587836878378783887839878408784187842878438784487845878468784787848878498785087851878528785387854878558785687857878588785987860878618786287863878648786587866878678786887869878708787187872878738787487875878768787787878878798788087881878828788387884878858788687887878888788987890878918789287893878948789587896878978789887899879008790187902879038790487905879068790787908879098791087911879128791387914879158791687917879188791987920879218792287923879248792587926879278792887929879308793187932879338793487935879368793787938879398794087941879428794387944879458794687947879488794987950879518795287953879548795587956879578795887959879608796187962879638796487965879668796787968879698797087971879728797387974879758797687977879788797987980879818798287983879848798587986879878798887989879908799187992879938799487995879968799787998879998800088001880028800388004880058800688007880088800988010880118801288013880148801588016880178801888019880208802188022880238802488025880268802788028880298803088031880328803388034880358803688037880388803988040880418804288043880448804588046880478804888049880508805188052880538805488055880568805788058880598806088061880628806388064880658806688067880688806988070880718807288073880748807588076880778807888079880808808188082880838808488085880868808788088880898809088091880928809388094880958809688097880988809988100881018810288103881048810588106881078810888109881108811188112881138811488115881168811788118881198812088121881228812388124881258812688127881288812988130881318813288133881348813588136881378813888139881408814188142881438814488145881468814788148881498815088151881528815388154881558815688157881588815988160881618816288163881648816588166881678816888169881708817188172881738817488175881768817788178881798818088181881828818388184881858818688187881888818988190881918819288193881948819588196881978819888199882008820188202882038820488205882068820788208882098821088211882128821388214882158821688217882188821988220882218822288223882248822588226882278822888229882308823188232882338823488235882368823788238882398824088241882428824388244882458824688247882488824988250882518825288253882548825588256882578825888259882608826188262882638826488265882668826788268882698827088271882728827388274882758827688277882788827988280882818828288283882848828588286882878828888289882908829188292882938829488295882968829788298882998830088301883028830388304883058830688307883088830988310883118831288313883148831588316883178831888319883208832188322883238832488325883268832788328883298833088331883328833388334883358833688337883388833988340883418834288343883448834588346883478834888349883508835188352883538835488355883568835788358883598836088361883628836388364883658836688367883688836988370883718837288373883748837588376883778837888379883808838188382883838838488385883868838788388883898839088391883928839388394883958839688397883988839988400884018840288403884048840588406884078840888409884108841188412884138841488415884168841788418884198842088421884228842388424884258842688427884288842988430884318843288433884348843588436884378843888439884408844188442884438844488445884468844788448884498845088451884528845388454884558845688457884588845988460884618846288463884648846588466884678846888469884708847188472884738847488475884768847788478884798848088481884828848388484884858848688487884888848988490884918849288493884948849588496884978849888499885008850188502885038850488505885068850788508885098851088511885128851388514885158851688517885188851988520885218852288523885248852588526885278852888529885308853188532885338853488535885368853788538885398854088541885428854388544885458854688547885488854988550885518855288553885548855588556885578855888559885608856188562885638856488565885668856788568885698857088571885728857388574885758857688577885788857988580885818858288583885848858588586885878858888589885908859188592885938859488595885968859788598885998860088601886028860388604886058860688607886088860988610886118861288613886148861588616886178861888619886208862188622886238862488625886268862788628886298863088631886328863388634886358863688637886388863988640886418864288643886448864588646886478864888649886508865188652886538865488655886568865788658886598866088661886628866388664886658866688667886688866988670886718867288673886748867588676886778867888679886808868188682886838868488685886868868788688886898869088691886928869388694886958869688697886988869988700887018870288703887048870588706887078870888709887108871188712887138871488715887168871788718887198872088721887228872388724887258872688727887288872988730887318873288733887348873588736887378873888739887408874188742887438874488745887468874788748887498875088751887528875388754887558875688757887588875988760887618876288763887648876588766887678876888769887708877188772887738877488775887768877788778887798878088781887828878388784887858878688787887888878988790887918879288793887948879588796887978879888799888008880188802888038880488805888068880788808888098881088811888128881388814888158881688817888188881988820888218882288823888248882588826888278882888829888308883188832888338883488835888368883788838888398884088841888428884388844888458884688847888488884988850888518885288853888548885588856888578885888859888608886188862888638886488865888668886788868888698887088871888728887388874888758887688877888788887988880888818888288883888848888588886888878888888889888908889188892888938889488895888968889788898888998890088901889028890388904889058890688907889088890988910889118891288913889148891588916889178891888919889208892188922889238892488925889268892788928889298893088931889328893388934889358893688937889388893988940889418894288943889448894588946889478894888949889508895188952889538895488955889568895788958889598896088961889628896388964889658896688967889688896988970889718897288973889748897588976889778897888979889808898188982889838898488985889868898788988889898899088991889928899388994889958899688997889988899989000890018900289003890048900589006890078900889009890108901189012890138901489015890168901789018890198902089021890228902389024890258902689027890288902989030890318903289033890348903589036890378903889039890408904189042890438904489045890468904789048890498905089051890528905389054890558905689057890588905989060890618906289063890648906589066890678906889069890708907189072890738907489075890768907789078890798908089081890828908389084890858908689087890888908989090890918909289093890948909589096890978909889099891008910189102891038910489105891068910789108891098911089111891128911389114891158911689117891188911989120891218912289123891248912589126891278912889129891308913189132891338913489135891368913789138891398914089141891428914389144891458914689147891488914989150891518915289153891548915589156891578915889159891608916189162891638916489165891668916789168891698917089171891728917389174891758917689177891788917989180891818918289183891848918589186891878918889189891908919189192891938919489195891968919789198891998920089201892028920389204892058920689207892088920989210892118921289213892148921589216892178921889219892208922189222892238922489225892268922789228892298923089231892328923389234892358923689237892388923989240892418924289243892448924589246892478924889249892508925189252892538925489255892568925789258892598926089261892628926389264892658926689267892688926989270892718927289273892748927589276892778927889279892808928189282892838928489285892868928789288892898929089291892928929389294892958929689297892988929989300893018930289303893048930589306893078930889309893108931189312893138931489315893168931789318893198932089321893228932389324893258932689327893288932989330893318933289333893348933589336893378933889339893408934189342893438934489345893468934789348893498935089351893528935389354893558935689357893588935989360893618936289363893648936589366893678936889369893708937189372893738937489375893768937789378893798938089381893828938389384893858938689387893888938989390893918939289393893948939589396893978939889399894008940189402894038940489405894068940789408894098941089411894128941389414894158941689417894188941989420894218942289423894248942589426894278942889429894308943189432894338943489435894368943789438894398944089441894428944389444894458944689447894488944989450894518945289453894548945589456894578945889459894608946189462894638946489465894668946789468894698947089471894728947389474894758947689477894788947989480894818948289483894848948589486894878948889489894908949189492894938949489495894968949789498894998950089501895028950389504895058950689507895088950989510895118951289513895148951589516895178951889519895208952189522895238952489525895268952789528895298953089531895328953389534895358953689537895388953989540895418954289543895448954589546895478954889549895508955189552895538955489555895568955789558895598956089561895628956389564895658956689567895688956989570895718957289573895748957589576895778957889579895808958189582895838958489585895868958789588895898959089591895928959389594895958959689597895988959989600896018960289603896048960589606896078960889609896108961189612896138961489615896168961789618896198962089621896228962389624896258962689627896288962989630896318963289633896348963589636896378963889639896408964189642896438964489645896468964789648896498965089651896528965389654896558965689657896588965989660896618966289663896648966589666896678966889669896708967189672896738967489675896768967789678896798968089681896828968389684896858968689687896888968989690896918969289693896948969589696896978969889699897008970189702897038970489705897068970789708897098971089711897128971389714897158971689717897188971989720897218972289723897248972589726897278972889729897308973189732897338973489735897368973789738897398974089741897428974389744897458974689747897488974989750897518975289753897548975589756897578975889759897608976189762897638976489765897668976789768897698977089771897728977389774897758977689777897788977989780897818978289783897848978589786897878978889789897908979189792897938979489795897968979789798897998980089801898028980389804898058980689807898088980989810898118981289813898148981589816898178981889819898208982189822898238982489825898268982789828898298983089831898328983389834898358983689837898388983989840898418984289843898448984589846898478984889849898508985189852898538985489855898568985789858898598986089861898628986389864898658986689867898688986989870898718987289873898748987589876898778987889879898808988189882898838988489885898868988789888898898989089891898928989389894898958989689897898988989989900899018990289903899048990589906899078990889909899108991189912899138991489915899168991789918899198992089921899228992389924899258992689927899288992989930899318993289933899348993589936899378993889939899408994189942899438994489945899468994789948899498995089951899528995389954899558995689957899588995989960899618996289963899648996589966899678996889969899708997189972899738997489975899768997789978899798998089981899828998389984899858998689987899888998989990899918999289993899948999589996899978999889999900009000190002900039000490005900069000790008900099001090011900129001390014900159001690017900189001990020900219002290023900249002590026900279002890029900309003190032900339003490035900369003790038900399004090041900429004390044900459004690047900489004990050900519005290053900549005590056900579005890059900609006190062900639006490065900669006790068900699007090071900729007390074900759007690077900789007990080900819008290083900849008590086900879008890089900909009190092900939009490095900969009790098900999010090101901029010390104901059010690107901089010990110901119011290113901149011590116901179011890119901209012190122901239012490125901269012790128901299013090131901329013390134901359013690137901389013990140901419014290143901449014590146901479014890149901509015190152901539015490155901569015790158901599016090161901629016390164901659016690167901689016990170901719017290173901749017590176901779017890179901809018190182901839018490185901869018790188901899019090191901929019390194901959019690197901989019990200902019020290203902049020590206902079020890209902109021190212902139021490215902169021790218902199022090221902229022390224902259022690227902289022990230902319023290233902349023590236902379023890239902409024190242902439024490245902469024790248902499025090251902529025390254902559025690257902589025990260902619026290263902649026590266902679026890269902709027190272902739027490275902769027790278902799028090281902829028390284902859028690287902889028990290902919029290293902949029590296902979029890299903009030190302903039030490305903069030790308903099031090311903129031390314903159031690317903189031990320903219032290323903249032590326903279032890329903309033190332903339033490335903369033790338903399034090341903429034390344903459034690347903489034990350903519035290353903549035590356903579035890359903609036190362903639036490365903669036790368903699037090371903729037390374903759037690377903789037990380903819038290383903849038590386903879038890389903909039190392903939039490395903969039790398903999040090401904029040390404904059040690407904089040990410904119041290413904149041590416904179041890419904209042190422904239042490425904269042790428904299043090431904329043390434904359043690437904389043990440904419044290443904449044590446904479044890449904509045190452904539045490455904569045790458904599046090461904629046390464904659046690467904689046990470904719047290473904749047590476904779047890479904809048190482904839048490485904869048790488904899049090491904929049390494904959049690497904989049990500905019050290503905049050590506905079050890509905109051190512905139051490515905169051790518905199052090521905229052390524905259052690527905289052990530905319053290533905349053590536905379053890539905409054190542905439054490545905469054790548905499055090551905529055390554905559055690557905589055990560905619056290563905649056590566905679056890569905709057190572905739057490575905769057790578905799058090581905829058390584905859058690587905889058990590905919059290593905949059590596905979059890599906009060190602906039060490605906069060790608906099061090611906129061390614906159061690617906189061990620906219062290623906249062590626906279062890629906309063190632906339063490635906369063790638906399064090641906429064390644906459064690647906489064990650906519065290653906549065590656906579065890659906609066190662906639066490665906669066790668906699067090671906729067390674906759067690677906789067990680906819068290683906849068590686906879068890689906909069190692906939069490695906969069790698906999070090701907029070390704907059070690707907089070990710907119071290713907149071590716907179071890719907209072190722907239072490725907269072790728907299073090731907329073390734907359073690737907389073990740907419074290743907449074590746907479074890749907509075190752907539075490755907569075790758907599076090761907629076390764907659076690767907689076990770907719077290773907749077590776907779077890779907809078190782907839078490785907869078790788907899079090791907929079390794907959079690797907989079990800908019080290803908049080590806908079080890809908109081190812908139081490815908169081790818908199082090821908229082390824908259082690827908289082990830908319083290833908349083590836908379083890839908409084190842908439084490845908469084790848908499085090851908529085390854908559085690857908589085990860908619086290863908649086590866908679086890869908709087190872908739087490875908769087790878908799088090881908829088390884908859088690887908889088990890908919089290893908949089590896908979089890899909009090190902909039090490905909069090790908909099091090911909129091390914909159091690917909189091990920909219092290923909249092590926909279092890929909309093190932909339093490935909369093790938909399094090941909429094390944909459094690947909489094990950909519095290953909549095590956909579095890959909609096190962909639096490965909669096790968909699097090971909729097390974909759097690977909789097990980909819098290983909849098590986909879098890989909909099190992909939099490995909969099790998909999100091001910029100391004910059100691007910089100991010910119101291013910149101591016910179101891019910209102191022910239102491025910269102791028910299103091031910329103391034910359103691037910389103991040910419104291043910449104591046910479104891049910509105191052910539105491055910569105791058910599106091061910629106391064910659106691067910689106991070910719107291073910749107591076910779107891079910809108191082910839108491085910869108791088910899109091091910929109391094910959109691097910989109991100911019110291103911049110591106911079110891109911109111191112911139111491115911169111791118911199112091121911229112391124911259112691127911289112991130911319113291133911349113591136911379113891139911409114191142911439114491145911469114791148911499115091151911529115391154911559115691157911589115991160911619116291163911649116591166911679116891169911709117191172911739117491175911769117791178911799118091181911829118391184911859118691187911889118991190911919119291193911949119591196911979119891199912009120191202912039120491205912069120791208912099121091211912129121391214912159121691217912189121991220912219122291223912249122591226912279122891229912309123191232912339123491235912369123791238912399124091241912429124391244912459124691247912489124991250912519125291253912549125591256912579125891259912609126191262912639126491265912669126791268912699127091271912729127391274912759127691277912789127991280912819128291283912849128591286912879128891289912909129191292912939129491295912969129791298912999130091301913029130391304913059130691307913089130991310913119131291313913149131591316913179131891319913209132191322913239132491325913269132791328913299133091331913329133391334913359133691337913389133991340913419134291343913449134591346913479134891349913509135191352913539135491355913569135791358913599136091361913629136391364913659136691367913689136991370913719137291373913749137591376913779137891379913809138191382913839138491385913869138791388913899139091391913929139391394913959139691397913989139991400914019140291403914049140591406914079140891409914109141191412914139141491415914169141791418914199142091421914229142391424914259142691427914289142991430914319143291433914349143591436914379143891439914409144191442914439144491445914469144791448914499145091451914529145391454914559145691457914589145991460914619146291463914649146591466914679146891469914709147191472914739147491475914769147791478914799148091481914829148391484914859148691487914889148991490914919149291493914949149591496914979149891499915009150191502915039150491505915069150791508915099151091511915129151391514915159151691517915189151991520915219152291523915249152591526915279152891529915309153191532915339153491535915369153791538915399154091541915429154391544915459154691547915489154991550915519155291553915549155591556915579155891559915609156191562915639156491565915669156791568915699157091571915729157391574915759157691577915789157991580915819158291583915849158591586915879158891589915909159191592915939159491595915969159791598915999160091601916029160391604916059160691607916089160991610916119161291613916149161591616916179161891619916209162191622916239162491625916269162791628916299163091631916329163391634916359163691637916389163991640916419164291643916449164591646916479164891649916509165191652916539165491655916569165791658916599166091661916629166391664916659166691667916689166991670916719167291673916749167591676916779167891679916809168191682916839168491685916869168791688916899169091691916929169391694916959169691697916989169991700917019170291703917049170591706917079170891709917109171191712917139171491715917169171791718917199172091721917229172391724917259172691727917289172991730917319173291733917349173591736917379173891739917409174191742917439174491745917469174791748917499175091751917529175391754917559175691757917589175991760917619176291763917649176591766917679176891769917709177191772917739177491775917769177791778917799178091781917829178391784917859178691787917889178991790917919179291793917949179591796917979179891799918009180191802918039180491805918069180791808918099181091811918129181391814918159181691817918189181991820918219182291823918249182591826918279182891829918309183191832918339183491835918369183791838918399184091841918429184391844918459184691847918489184991850918519185291853918549185591856918579185891859918609186191862918639186491865918669186791868918699187091871918729187391874918759187691877918789187991880918819188291883918849188591886918879188891889918909189191892918939189491895918969189791898918999190091901919029190391904919059190691907919089190991910919119191291913919149191591916919179191891919919209192191922919239192491925919269192791928919299193091931919329193391934919359193691937919389193991940919419194291943919449194591946919479194891949919509195191952919539195491955919569195791958919599196091961919629196391964919659196691967919689196991970919719197291973919749197591976919779197891979919809198191982919839198491985919869198791988919899199091991919929199391994919959199691997919989199992000920019200292003920049200592006920079200892009920109201192012920139201492015920169201792018920199202092021920229202392024920259202692027920289202992030920319203292033920349203592036920379203892039920409204192042920439204492045920469204792048920499205092051920529205392054920559205692057920589205992060920619206292063920649206592066920679206892069920709207192072920739207492075920769207792078920799208092081920829208392084920859208692087920889208992090920919209292093920949209592096920979209892099921009210192102921039210492105921069210792108921099211092111921129211392114921159211692117921189211992120921219212292123921249212592126921279212892129921309213192132921339213492135921369213792138921399214092141921429214392144921459214692147921489214992150921519215292153921549215592156921579215892159921609216192162921639216492165921669216792168921699217092171921729217392174921759217692177921789217992180921819218292183921849218592186921879218892189921909219192192921939219492195921969219792198921999220092201922029220392204922059220692207922089220992210922119221292213922149221592216922179221892219922209222192222922239222492225922269222792228922299223092231922329223392234922359223692237922389223992240922419224292243922449224592246922479224892249922509225192252922539225492255922569225792258922599226092261922629226392264922659226692267922689226992270922719227292273922749227592276922779227892279922809228192282922839228492285922869228792288922899229092291922929229392294922959229692297922989229992300923019230292303923049230592306923079230892309923109231192312923139231492315923169231792318923199232092321923229232392324923259232692327923289232992330923319233292333923349233592336923379233892339923409234192342923439234492345923469234792348923499235092351923529235392354923559235692357923589235992360923619236292363923649236592366923679236892369923709237192372923739237492375923769237792378923799238092381923829238392384923859238692387923889238992390923919239292393923949239592396923979239892399924009240192402924039240492405924069240792408924099241092411924129241392414924159241692417924189241992420924219242292423924249242592426924279242892429924309243192432924339243492435924369243792438924399244092441924429244392444924459244692447924489244992450924519245292453924549245592456924579245892459924609246192462924639246492465924669246792468924699247092471924729247392474924759247692477924789247992480924819248292483924849248592486924879248892489924909249192492924939249492495924969249792498924999250092501925029250392504925059250692507925089250992510925119251292513925149251592516925179251892519925209252192522925239252492525925269252792528925299253092531925329253392534925359253692537925389253992540925419254292543925449254592546925479254892549925509255192552925539255492555925569255792558925599256092561925629256392564925659256692567925689256992570925719257292573925749257592576925779257892579925809258192582925839258492585925869258792588925899259092591925929259392594925959259692597925989259992600926019260292603926049260592606926079260892609926109261192612926139261492615926169261792618926199262092621926229262392624926259262692627926289262992630926319263292633926349263592636926379263892639926409264192642926439264492645926469264792648926499265092651926529265392654926559265692657926589265992660926619266292663926649266592666926679266892669926709267192672926739267492675926769267792678926799268092681926829268392684926859268692687926889268992690926919269292693926949269592696926979269892699927009270192702927039270492705927069270792708927099271092711927129271392714927159271692717927189271992720927219272292723927249272592726927279272892729927309273192732927339273492735927369273792738927399274092741927429274392744927459274692747927489274992750927519275292753927549275592756927579275892759927609276192762927639276492765927669276792768927699277092771927729277392774927759277692777927789277992780927819278292783927849278592786927879278892789927909279192792927939279492795927969279792798927999280092801928029280392804928059280692807928089280992810928119281292813928149281592816928179281892819928209282192822928239282492825928269282792828928299283092831928329283392834928359283692837928389283992840928419284292843928449284592846928479284892849928509285192852928539285492855928569285792858928599286092861928629286392864928659286692867928689286992870928719287292873928749287592876928779287892879
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. /**
  94. * User defined information that will be sent to observers
  95. */
  96. userInfo?: any;
  97. }
  98. /**
  99. * Represent an Observer registered to a given Observable object.
  100. */
  101. export class Observer<T> {
  102. /**
  103. * Defines the callback to call when the observer is notified
  104. */
  105. callback: (eventData: T, eventState: EventState) => void;
  106. /**
  107. * Defines the mask of the observer (used to filter notifications)
  108. */
  109. mask: number;
  110. /**
  111. * Defines the current scope used to restore the JS context
  112. */
  113. scope: any;
  114. /** @hidden */
  115. _willBeUnregistered: boolean;
  116. /**
  117. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  118. */
  119. unregisterOnNextCall: boolean;
  120. /**
  121. * Creates a new observer
  122. * @param callback defines the callback to call when the observer is notified
  123. * @param mask defines the mask of the observer (used to filter notifications)
  124. * @param scope defines the current scope used to restore the JS context
  125. */
  126. constructor(
  127. /**
  128. * Defines the callback to call when the observer is notified
  129. */
  130. callback: (eventData: T, eventState: EventState) => void,
  131. /**
  132. * Defines the mask of the observer (used to filter notifications)
  133. */
  134. mask: number,
  135. /**
  136. * Defines the current scope used to restore the JS context
  137. */
  138. scope?: any);
  139. }
  140. /**
  141. * Represent a list of observers registered to multiple Observables object.
  142. */
  143. export class MultiObserver<T> {
  144. private _observers;
  145. private _observables;
  146. /**
  147. * Release associated resources
  148. */
  149. dispose(): void;
  150. /**
  151. * Raise a callback when one of the observable will notify
  152. * @param observables defines a list of observables to watch
  153. * @param callback defines the callback to call on notification
  154. * @param mask defines the mask used to filter notifications
  155. * @param scope defines the current scope used to restore the JS context
  156. * @returns the new MultiObserver
  157. */
  158. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  159. }
  160. /**
  161. * The Observable class is a simple implementation of the Observable pattern.
  162. *
  163. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  164. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  165. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  166. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  167. */
  168. export class Observable<T> {
  169. private _observers;
  170. private _eventState;
  171. private _onObserverAdded;
  172. /**
  173. * Gets the list of observers
  174. */
  175. get observers(): Array<Observer<T>>;
  176. /**
  177. * Creates a new observable
  178. * @param onObserverAdded defines a callback to call when a new observer is added
  179. */
  180. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  181. /**
  182. * Create a new Observer with the specified callback
  183. * @param callback the callback that will be executed for that Observer
  184. * @param mask the mask used to filter observers
  185. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  186. * @param scope optional scope for the callback to be called from
  187. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  188. * @returns the new observer created for the callback
  189. */
  190. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  191. /**
  192. * Create a new Observer with the specified callback and unregisters after the next notification
  193. * @param callback the callback that will be executed for that Observer
  194. * @returns the new observer created for the callback
  195. */
  196. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  197. /**
  198. * Remove an Observer from the Observable object
  199. * @param observer the instance of the Observer to remove
  200. * @returns false if it doesn't belong to this Observable
  201. */
  202. remove(observer: Nullable<Observer<T>>): boolean;
  203. /**
  204. * Remove a callback from the Observable object
  205. * @param callback the callback to remove
  206. * @param scope optional scope. If used only the callbacks with this scope will be removed
  207. * @returns false if it doesn't belong to this Observable
  208. */
  209. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  210. private _deferUnregister;
  211. private _remove;
  212. /**
  213. * Moves the observable to the top of the observer list making it get called first when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverTopPriority(observer: Observer<T>): void;
  217. /**
  218. * Moves the observable to the bottom of the observer list making it get called last when notified
  219. * @param observer the observer to move
  220. */
  221. makeObserverBottomPriority(observer: Observer<T>): void;
  222. /**
  223. * Notify all Observers by calling their respective callback with the given data
  224. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  225. * @param eventData defines the data to send to all observers
  226. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  227. * @param target defines the original target of the state
  228. * @param currentTarget defines the current target of the state
  229. * @param userInfo defines any user info to send to observers
  230. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  231. */
  232. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  233. /**
  234. * Calling this will execute each callback, expecting it to be a promise or return a value.
  235. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  236. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  237. * and it is crucial that all callbacks will be executed.
  238. * The order of the callbacks is kept, callbacks are not executed parallel.
  239. *
  240. * @param eventData The data to be sent to each callback
  241. * @param mask is used to filter observers defaults to -1
  242. * @param target defines the callback target (see EventState)
  243. * @param currentTarget defines he current object in the bubbling phase
  244. * @param userInfo defines any user info to send to observers
  245. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  246. */
  247. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  248. /**
  249. * Notify a specific observer
  250. * @param observer defines the observer to notify
  251. * @param eventData defines the data to be sent to each callback
  252. * @param mask is used to filter observers defaults to -1
  253. */
  254. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  255. /**
  256. * Gets a boolean indicating if the observable has at least one observer
  257. * @returns true is the Observable has at least one Observer registered
  258. */
  259. hasObservers(): boolean;
  260. /**
  261. * Clear the list of observers
  262. */
  263. clear(): void;
  264. /**
  265. * Clone the current observable
  266. * @returns a new observable
  267. */
  268. clone(): Observable<T>;
  269. /**
  270. * Does this observable handles observer registered with a given mask
  271. * @param mask defines the mask to be tested
  272. * @return whether or not one observer registered with the given mask is handeled
  273. **/
  274. hasSpecificMask(mask?: number): boolean;
  275. }
  276. }
  277. declare module BABYLON {
  278. /**
  279. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  280. * Babylon.js
  281. */
  282. export class DomManagement {
  283. /**
  284. * Checks if the window object exists
  285. * @returns true if the window object exists
  286. */
  287. static IsWindowObjectExist(): boolean;
  288. /**
  289. * Checks if the navigator object exists
  290. * @returns true if the navigator object exists
  291. */
  292. static IsNavigatorAvailable(): boolean;
  293. /**
  294. * Check if the document object exists
  295. * @returns true if the document object exists
  296. */
  297. static IsDocumentAvailable(): boolean;
  298. /**
  299. * Extracts text content from a DOM element hierarchy
  300. * @param element defines the root element
  301. * @returns a string
  302. */
  303. static GetDOMTextContent(element: HTMLElement): string;
  304. }
  305. }
  306. declare module BABYLON {
  307. /**
  308. * Logger used througouht the application to allow configuration of
  309. * the log level required for the messages.
  310. */
  311. export class Logger {
  312. /**
  313. * No log
  314. */
  315. static readonly NoneLogLevel: number;
  316. /**
  317. * Only message logs
  318. */
  319. static readonly MessageLogLevel: number;
  320. /**
  321. * Only warning logs
  322. */
  323. static readonly WarningLogLevel: number;
  324. /**
  325. * Only error logs
  326. */
  327. static readonly ErrorLogLevel: number;
  328. /**
  329. * All logs
  330. */
  331. static readonly AllLogLevel: number;
  332. /**
  333. * Message to display when a message has been logged too many times
  334. */
  335. static MessageLimitReached: string;
  336. private static _LogCache;
  337. private static _LogLimitOutputs;
  338. /**
  339. * Gets a value indicating the number of loading errors
  340. * @ignorenaming
  341. */
  342. static errorsCount: number;
  343. /**
  344. * Callback called when a new log is added
  345. */
  346. static OnNewCacheEntry: (entry: string) => void;
  347. private static _CheckLimit;
  348. private static _GenerateLimitMessage;
  349. private static _AddLogEntry;
  350. private static _FormatMessage;
  351. private static _LogDisabled;
  352. private static _LogEnabled;
  353. private static _WarnDisabled;
  354. private static _WarnEnabled;
  355. private static _ErrorDisabled;
  356. private static _ErrorEnabled;
  357. /**
  358. * Log a message to the console
  359. */
  360. static Log: (message: string, limit?: number) => void;
  361. /**
  362. * Write a warning message to the console
  363. */
  364. static Warn: (message: string, limit?: number) => void;
  365. /**
  366. * Write an error message to the console
  367. */
  368. static Error: (message: string, limit?: number) => void;
  369. /**
  370. * Gets current log cache (list of logs)
  371. */
  372. static get LogCache(): string;
  373. /**
  374. * Clears the log cache
  375. */
  376. static ClearLogCache(): void;
  377. /**
  378. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  379. */
  380. static set LogLevels(level: number);
  381. }
  382. }
  383. declare module BABYLON {
  384. /** @hidden */
  385. export class _TypeStore {
  386. /** @hidden */
  387. static RegisteredTypes: {
  388. [key: string]: Object;
  389. };
  390. /** @hidden */
  391. static GetClass(fqdn: string): any;
  392. }
  393. }
  394. declare module BABYLON {
  395. /**
  396. * Helper to manipulate strings
  397. */
  398. export class StringTools {
  399. /**
  400. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  401. * @param str Source string
  402. * @param suffix Suffix to search for in the source string
  403. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  404. */
  405. static EndsWith(str: string, suffix: string): boolean;
  406. /**
  407. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  408. * @param str Source string
  409. * @param suffix Suffix to search for in the source string
  410. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  411. */
  412. static StartsWith(str: string, suffix: string): boolean;
  413. /**
  414. * Decodes a buffer into a string
  415. * @param buffer The buffer to decode
  416. * @returns The decoded string
  417. */
  418. static Decode(buffer: Uint8Array | Uint16Array): string;
  419. /**
  420. * Encode a buffer to a base64 string
  421. * @param buffer defines the buffer to encode
  422. * @returns the encoded string
  423. */
  424. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  425. /**
  426. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  427. * @param num the number to convert and pad
  428. * @param length the expected length of the string
  429. * @returns the padded string
  430. */
  431. static PadNumber(num: number, length: number): string;
  432. }
  433. }
  434. declare module BABYLON {
  435. /**
  436. * Class containing a set of static utilities functions for deep copy.
  437. */
  438. export class DeepCopier {
  439. /**
  440. * Tries to copy an object by duplicating every property
  441. * @param source defines the source object
  442. * @param destination defines the target object
  443. * @param doNotCopyList defines a list of properties to avoid
  444. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  445. */
  446. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  447. }
  448. }
  449. declare module BABYLON {
  450. /**
  451. * Class containing a set of static utilities functions for precision date
  452. */
  453. export class PrecisionDate {
  454. /**
  455. * Gets either window.performance.now() if supported or Date.now() else
  456. */
  457. static get Now(): number;
  458. }
  459. }
  460. declare module BABYLON {
  461. /** @hidden */
  462. export class _DevTools {
  463. static WarnImport(name: string): string;
  464. }
  465. }
  466. declare module BABYLON {
  467. /**
  468. * Interface used to define the mechanism to get data from the network
  469. */
  470. export interface IWebRequest {
  471. /**
  472. * Returns client's response url
  473. */
  474. responseURL: string;
  475. /**
  476. * Returns client's status
  477. */
  478. status: number;
  479. /**
  480. * Returns client's status as a text
  481. */
  482. statusText: string;
  483. }
  484. }
  485. declare module BABYLON {
  486. /**
  487. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  488. */
  489. export class WebRequest implements IWebRequest {
  490. private readonly _xhr;
  491. /**
  492. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  493. * i.e. when loading files, where the server/service expects an Authorization header
  494. */
  495. static CustomRequestHeaders: {
  496. [key: string]: string;
  497. };
  498. /**
  499. * Add callback functions in this array to update all the requests before they get sent to the network
  500. */
  501. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  502. private _injectCustomRequestHeaders;
  503. /**
  504. * Gets or sets a function to be called when loading progress changes
  505. */
  506. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  507. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  508. /**
  509. * Returns client's state
  510. */
  511. get readyState(): number;
  512. /**
  513. * Returns client's status
  514. */
  515. get status(): number;
  516. /**
  517. * Returns client's status as a text
  518. */
  519. get statusText(): string;
  520. /**
  521. * Returns client's response
  522. */
  523. get response(): any;
  524. /**
  525. * Returns client's response url
  526. */
  527. get responseURL(): string;
  528. /**
  529. * Returns client's response as text
  530. */
  531. get responseText(): string;
  532. /**
  533. * Gets or sets the expected response type
  534. */
  535. get responseType(): XMLHttpRequestResponseType;
  536. set responseType(value: XMLHttpRequestResponseType);
  537. /** @hidden */
  538. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  539. /** @hidden */
  540. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  541. /**
  542. * Cancels any network activity
  543. */
  544. abort(): void;
  545. /**
  546. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  547. * @param body defines an optional request body
  548. */
  549. send(body?: Document | BodyInit | null): void;
  550. /**
  551. * Sets the request method, request URL
  552. * @param method defines the method to use (GET, POST, etc..)
  553. * @param url defines the url to connect with
  554. */
  555. open(method: string, url: string): void;
  556. /**
  557. * Sets the value of a request header.
  558. * @param name The name of the header whose value is to be set
  559. * @param value The value to set as the body of the header
  560. */
  561. setRequestHeader(name: string, value: string): void;
  562. /**
  563. * Get the string containing the text of a particular header's value.
  564. * @param name The name of the header
  565. * @returns The string containing the text of the given header name
  566. */
  567. getResponseHeader(name: string): Nullable<string>;
  568. }
  569. }
  570. declare module BABYLON {
  571. /**
  572. * File request interface
  573. */
  574. export interface IFileRequest {
  575. /**
  576. * Raised when the request is complete (success or error).
  577. */
  578. onCompleteObservable: Observable<IFileRequest>;
  579. /**
  580. * Aborts the request for a file.
  581. */
  582. abort: () => void;
  583. }
  584. }
  585. declare module BABYLON {
  586. /**
  587. * Define options used to create a render target texture
  588. */
  589. export class RenderTargetCreationOptions {
  590. /**
  591. * Specifies if mipmaps must be created. If undefined, the value from generateMipMaps is taken instead
  592. */
  593. createMipMaps?: boolean;
  594. /**
  595. * Specifies if mipmaps must be generated
  596. */
  597. generateMipMaps?: boolean;
  598. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  599. generateDepthBuffer?: boolean;
  600. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  601. generateStencilBuffer?: boolean;
  602. /** Defines texture type (int by default) */
  603. type?: number;
  604. /** Defines sampling mode (trilinear by default) */
  605. samplingMode?: number;
  606. /** Defines format (RGBA by default) */
  607. format?: number;
  608. /** Defines sample count (1 by default) */
  609. samples?: number;
  610. }
  611. }
  612. declare module BABYLON {
  613. /** Defines the cross module used constants to avoid circular dependncies */
  614. export class Constants {
  615. /** Defines that alpha blending is disabled */
  616. static readonly ALPHA_DISABLE: number;
  617. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  618. static readonly ALPHA_ADD: number;
  619. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  620. static readonly ALPHA_COMBINE: number;
  621. /** Defines that alpha blending is DEST - SRC * DEST */
  622. static readonly ALPHA_SUBTRACT: number;
  623. /** Defines that alpha blending is SRC * DEST */
  624. static readonly ALPHA_MULTIPLY: number;
  625. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  626. static readonly ALPHA_MAXIMIZED: number;
  627. /** Defines that alpha blending is SRC + DEST */
  628. static readonly ALPHA_ONEONE: number;
  629. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  630. static readonly ALPHA_PREMULTIPLIED: number;
  631. /**
  632. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  633. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  634. */
  635. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  636. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  637. static readonly ALPHA_INTERPOLATE: number;
  638. /**
  639. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  640. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  641. */
  642. static readonly ALPHA_SCREENMODE: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA + DST ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEONE: number;
  648. /**
  649. * Defines that alpha blending is SRC * DST ALPHA + DST
  650. * Alpha will be set to 0
  651. */
  652. static readonly ALPHA_ALPHATOCOLOR: number;
  653. /**
  654. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  655. */
  656. static readonly ALPHA_REVERSEONEMINUS: number;
  657. /**
  658. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  659. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  660. */
  661. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  662. /**
  663. * Defines that alpha blending is SRC + DST
  664. * Alpha will be set to SRC ALPHA
  665. */
  666. static readonly ALPHA_ONEONE_ONEZERO: number;
  667. /**
  668. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  669. * Alpha will be set to DST ALPHA
  670. */
  671. static readonly ALPHA_EXCLUSION: number;
  672. /** Defines that alpha blending equation a SUM */
  673. static readonly ALPHA_EQUATION_ADD: number;
  674. /** Defines that alpha blending equation a SUBSTRACTION */
  675. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  676. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  677. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  678. /** Defines that alpha blending equation a MAX operation */
  679. static readonly ALPHA_EQUATION_MAX: number;
  680. /** Defines that alpha blending equation a MIN operation */
  681. static readonly ALPHA_EQUATION_MIN: number;
  682. /**
  683. * Defines that alpha blending equation a DARKEN operation:
  684. * It takes the min of the src and sums the alpha channels.
  685. */
  686. static readonly ALPHA_EQUATION_DARKEN: number;
  687. /** Defines that the ressource is not delayed*/
  688. static readonly DELAYLOADSTATE_NONE: number;
  689. /** Defines that the ressource was successfully delay loaded */
  690. static readonly DELAYLOADSTATE_LOADED: number;
  691. /** Defines that the ressource is currently delay loading */
  692. static readonly DELAYLOADSTATE_LOADING: number;
  693. /** Defines that the ressource is delayed and has not started loading */
  694. static readonly DELAYLOADSTATE_NOTLOADED: number;
  695. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  696. static readonly NEVER: number;
  697. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  698. static readonly ALWAYS: number;
  699. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  700. static readonly LESS: number;
  701. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  702. static readonly EQUAL: number;
  703. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  704. static readonly LEQUAL: number;
  705. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  706. static readonly GREATER: number;
  707. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  708. static readonly GEQUAL: number;
  709. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  710. static readonly NOTEQUAL: number;
  711. /** Passed to stencilOperation to specify that stencil value must be kept */
  712. static readonly KEEP: number;
  713. /** Passed to stencilOperation to specify that stencil value must be zero */
  714. static readonly ZERO: number;
  715. /** Passed to stencilOperation to specify that stencil value must be replaced */
  716. static readonly REPLACE: number;
  717. /** Passed to stencilOperation to specify that stencil value must be incremented */
  718. static readonly INCR: number;
  719. /** Passed to stencilOperation to specify that stencil value must be decremented */
  720. static readonly DECR: number;
  721. /** Passed to stencilOperation to specify that stencil value must be inverted */
  722. static readonly INVERT: number;
  723. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  724. static readonly INCR_WRAP: number;
  725. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  726. static readonly DECR_WRAP: number;
  727. /** Texture is not repeating outside of 0..1 UVs */
  728. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  729. /** Texture is repeating outside of 0..1 UVs */
  730. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  731. /** Texture is repeating and mirrored */
  732. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  733. /** ALPHA */
  734. static readonly TEXTUREFORMAT_ALPHA: number;
  735. /** LUMINANCE */
  736. static readonly TEXTUREFORMAT_LUMINANCE: number;
  737. /** LUMINANCE_ALPHA */
  738. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  739. /** RGB */
  740. static readonly TEXTUREFORMAT_RGB: number;
  741. /** RGBA */
  742. static readonly TEXTUREFORMAT_RGBA: number;
  743. /** RED */
  744. static readonly TEXTUREFORMAT_RED: number;
  745. /** RED (2nd reference) */
  746. static readonly TEXTUREFORMAT_R: number;
  747. /** RG */
  748. static readonly TEXTUREFORMAT_RG: number;
  749. /** RED_INTEGER */
  750. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  751. /** RED_INTEGER (2nd reference) */
  752. static readonly TEXTUREFORMAT_R_INTEGER: number;
  753. /** RG_INTEGER */
  754. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  755. /** RGB_INTEGER */
  756. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  757. /** RGBA_INTEGER */
  758. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  759. /** BGRA */
  760. static readonly TEXTUREFORMAT_BGRA: number;
  761. /** Depth 24 bits + Stencil 8 bits */
  762. static readonly TEXTUREFORMAT_DEPTH24_STENCIL8: number;
  763. /** Depth 32 bits float */
  764. static readonly TEXTUREFORMAT_DEPTH32_FLOAT: number;
  765. /** Compressed BC7 */
  766. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM: number;
  767. /** Compressed BC6 unsigned float */
  768. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: number;
  769. /** Compressed BC6 signed float */
  770. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: number;
  771. /** Compressed BC3 */
  772. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5: number;
  773. /** Compressed BC2 */
  774. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3: number;
  775. /** Compressed BC1 */
  776. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1: number;
  777. /** UNSIGNED_BYTE */
  778. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  779. /** UNSIGNED_BYTE (2nd reference) */
  780. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  781. /** FLOAT */
  782. static readonly TEXTURETYPE_FLOAT: number;
  783. /** HALF_FLOAT */
  784. static readonly TEXTURETYPE_HALF_FLOAT: number;
  785. /** BYTE */
  786. static readonly TEXTURETYPE_BYTE: number;
  787. /** SHORT */
  788. static readonly TEXTURETYPE_SHORT: number;
  789. /** UNSIGNED_SHORT */
  790. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  791. /** INT */
  792. static readonly TEXTURETYPE_INT: number;
  793. /** UNSIGNED_INT */
  794. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  795. /** UNSIGNED_SHORT_4_4_4_4 */
  796. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  797. /** UNSIGNED_SHORT_5_5_5_1 */
  798. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  799. /** UNSIGNED_SHORT_5_6_5 */
  800. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  801. /** UNSIGNED_INT_2_10_10_10_REV */
  802. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  803. /** UNSIGNED_INT_24_8 */
  804. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  805. /** UNSIGNED_INT_10F_11F_11F_REV */
  806. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  807. /** UNSIGNED_INT_5_9_9_9_REV */
  808. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  809. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  810. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  811. /** nearest is mag = nearest and min = nearest and no mip */
  812. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  813. /** mag = nearest and min = nearest and mip = none */
  814. static readonly TEXTURE_NEAREST_NEAREST: number;
  815. /** Bilinear is mag = linear and min = linear and no mip */
  816. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  817. /** mag = linear and min = linear and mip = none */
  818. static readonly TEXTURE_LINEAR_LINEAR: number;
  819. /** Trilinear is mag = linear and min = linear and mip = linear */
  820. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  821. /** Trilinear is mag = linear and min = linear and mip = linear */
  822. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  823. /** mag = nearest and min = nearest and mip = nearest */
  824. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  825. /** mag = nearest and min = linear and mip = nearest */
  826. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  827. /** mag = nearest and min = linear and mip = linear */
  828. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  829. /** mag = nearest and min = linear and mip = none */
  830. static readonly TEXTURE_NEAREST_LINEAR: number;
  831. /** nearest is mag = nearest and min = nearest and mip = linear */
  832. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  833. /** mag = linear and min = nearest and mip = nearest */
  834. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  835. /** mag = linear and min = nearest and mip = linear */
  836. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  837. /** Bilinear is mag = linear and min = linear and mip = nearest */
  838. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  839. /** mag = linear and min = nearest and mip = none */
  840. static readonly TEXTURE_LINEAR_NEAREST: number;
  841. /** Explicit coordinates mode */
  842. static readonly TEXTURE_EXPLICIT_MODE: number;
  843. /** Spherical coordinates mode */
  844. static readonly TEXTURE_SPHERICAL_MODE: number;
  845. /** Planar coordinates mode */
  846. static readonly TEXTURE_PLANAR_MODE: number;
  847. /** Cubic coordinates mode */
  848. static readonly TEXTURE_CUBIC_MODE: number;
  849. /** Projection coordinates mode */
  850. static readonly TEXTURE_PROJECTION_MODE: number;
  851. /** Skybox coordinates mode */
  852. static readonly TEXTURE_SKYBOX_MODE: number;
  853. /** Inverse Cubic coordinates mode */
  854. static readonly TEXTURE_INVCUBIC_MODE: number;
  855. /** Equirectangular coordinates mode */
  856. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  857. /** Equirectangular Fixed coordinates mode */
  858. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  859. /** Equirectangular Fixed Mirrored coordinates mode */
  860. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  861. /** Offline (baking) quality for texture filtering */
  862. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  863. /** High quality for texture filtering */
  864. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  865. /** Medium quality for texture filtering */
  866. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  867. /** Low quality for texture filtering */
  868. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  869. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  870. static readonly SCALEMODE_FLOOR: number;
  871. /** Defines that texture rescaling will look for the nearest power of 2 size */
  872. static readonly SCALEMODE_NEAREST: number;
  873. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  874. static readonly SCALEMODE_CEILING: number;
  875. /**
  876. * The dirty texture flag value
  877. */
  878. static readonly MATERIAL_TextureDirtyFlag: number;
  879. /**
  880. * The dirty light flag value
  881. */
  882. static readonly MATERIAL_LightDirtyFlag: number;
  883. /**
  884. * The dirty fresnel flag value
  885. */
  886. static readonly MATERIAL_FresnelDirtyFlag: number;
  887. /**
  888. * The dirty attribute flag value
  889. */
  890. static readonly MATERIAL_AttributesDirtyFlag: number;
  891. /**
  892. * The dirty misc flag value
  893. */
  894. static readonly MATERIAL_MiscDirtyFlag: number;
  895. /**
  896. * The dirty prepass flag value
  897. */
  898. static readonly MATERIAL_PrePassDirtyFlag: number;
  899. /**
  900. * The all dirty flag value
  901. */
  902. static readonly MATERIAL_AllDirtyFlag: number;
  903. /**
  904. * Returns the triangle fill mode
  905. */
  906. static readonly MATERIAL_TriangleFillMode: number;
  907. /**
  908. * Returns the wireframe mode
  909. */
  910. static readonly MATERIAL_WireFrameFillMode: number;
  911. /**
  912. * Returns the point fill mode
  913. */
  914. static readonly MATERIAL_PointFillMode: number;
  915. /**
  916. * Returns the point list draw mode
  917. */
  918. static readonly MATERIAL_PointListDrawMode: number;
  919. /**
  920. * Returns the line list draw mode
  921. */
  922. static readonly MATERIAL_LineListDrawMode: number;
  923. /**
  924. * Returns the line loop draw mode
  925. */
  926. static readonly MATERIAL_LineLoopDrawMode: number;
  927. /**
  928. * Returns the line strip draw mode
  929. */
  930. static readonly MATERIAL_LineStripDrawMode: number;
  931. /**
  932. * Returns the triangle strip draw mode
  933. */
  934. static readonly MATERIAL_TriangleStripDrawMode: number;
  935. /**
  936. * Returns the triangle fan draw mode
  937. */
  938. static readonly MATERIAL_TriangleFanDrawMode: number;
  939. /**
  940. * Stores the clock-wise side orientation
  941. */
  942. static readonly MATERIAL_ClockWiseSideOrientation: number;
  943. /**
  944. * Stores the counter clock-wise side orientation
  945. */
  946. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  947. /**
  948. * Nothing
  949. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_NothingTrigger: number;
  952. /**
  953. * On pick
  954. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnPickTrigger: number;
  957. /**
  958. * On left pick
  959. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnLeftPickTrigger: number;
  962. /**
  963. * On right pick
  964. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnRightPickTrigger: number;
  967. /**
  968. * On center pick
  969. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnCenterPickTrigger: number;
  972. /**
  973. * On pick down
  974. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnPickDownTrigger: number;
  977. /**
  978. * On double pick
  979. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  980. */
  981. static readonly ACTION_OnDoublePickTrigger: number;
  982. /**
  983. * On pick up
  984. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  985. */
  986. static readonly ACTION_OnPickUpTrigger: number;
  987. /**
  988. * On pick out.
  989. * This trigger will only be raised if you also declared a OnPickDown
  990. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  991. */
  992. static readonly ACTION_OnPickOutTrigger: number;
  993. /**
  994. * On long press
  995. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  996. */
  997. static readonly ACTION_OnLongPressTrigger: number;
  998. /**
  999. * On pointer over
  1000. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1001. */
  1002. static readonly ACTION_OnPointerOverTrigger: number;
  1003. /**
  1004. * On pointer out
  1005. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1006. */
  1007. static readonly ACTION_OnPointerOutTrigger: number;
  1008. /**
  1009. * On every frame
  1010. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1011. */
  1012. static readonly ACTION_OnEveryFrameTrigger: number;
  1013. /**
  1014. * On intersection enter
  1015. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1016. */
  1017. static readonly ACTION_OnIntersectionEnterTrigger: number;
  1018. /**
  1019. * On intersection exit
  1020. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1021. */
  1022. static readonly ACTION_OnIntersectionExitTrigger: number;
  1023. /**
  1024. * On key down
  1025. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1026. */
  1027. static readonly ACTION_OnKeyDownTrigger: number;
  1028. /**
  1029. * On key up
  1030. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1031. */
  1032. static readonly ACTION_OnKeyUpTrigger: number;
  1033. /**
  1034. * Billboard mode will only apply to Y axis
  1035. */
  1036. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1037. /**
  1038. * Billboard mode will apply to all axes
  1039. */
  1040. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1041. /**
  1042. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1043. */
  1044. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1045. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1046. * Test order :
  1047. * Is the bounding sphere outside the frustum ?
  1048. * If not, are the bounding box vertices outside the frustum ?
  1049. * It not, then the cullable object is in the frustum.
  1050. */
  1051. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1052. /** Culling strategy : Bounding Sphere Only.
  1053. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1054. * It's also less accurate than the standard because some not visible objects can still be selected.
  1055. * Test : is the bounding sphere outside the frustum ?
  1056. * If not, then the cullable object is in the frustum.
  1057. */
  1058. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1059. /** Culling strategy : Optimistic Inclusion.
  1060. * This in an inclusion test first, then the standard exclusion test.
  1061. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1062. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1063. * Anyway, it's as accurate as the standard strategy.
  1064. * Test :
  1065. * Is the cullable object bounding sphere center in the frustum ?
  1066. * If not, apply the default culling strategy.
  1067. */
  1068. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1069. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1070. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1071. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1072. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1073. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1074. * Test :
  1075. * Is the cullable object bounding sphere center in the frustum ?
  1076. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1077. */
  1078. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1079. /**
  1080. * No logging while loading
  1081. */
  1082. static readonly SCENELOADER_NO_LOGGING: number;
  1083. /**
  1084. * Minimal logging while loading
  1085. */
  1086. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1087. /**
  1088. * Summary logging while loading
  1089. */
  1090. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1091. /**
  1092. * Detailled logging while loading
  1093. */
  1094. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1095. /**
  1096. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1097. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1098. */
  1099. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1100. /**
  1101. * Constant used to retrieve the position texture index in the textures array in the prepass
  1102. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1103. */
  1104. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1105. /**
  1106. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1107. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1108. */
  1109. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1110. /**
  1111. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1112. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1113. */
  1114. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1115. /**
  1116. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1117. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1118. */
  1119. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1120. /**
  1121. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1122. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1123. */
  1124. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1125. /**
  1126. * Constant used to retrieve albedo index in the textures array in the prepass
  1127. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1128. */
  1129. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1130. /**
  1131. * Prefixes used by the engine for custom effects
  1132. */
  1133. static readonly CUSTOMEFFECT_PREFIX_SHADOWGENERATOR: string;
  1134. }
  1135. }
  1136. declare module BABYLON {
  1137. /** @hidden */
  1138. export interface HardwareTextureWrapper {
  1139. underlyingResource: any;
  1140. set(hardwareTexture: any): void;
  1141. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  1142. reset(): void;
  1143. release(): void;
  1144. }
  1145. }
  1146. declare module BABYLON {
  1147. /**
  1148. * This represents the required contract to create a new type of texture loader.
  1149. */
  1150. export interface IInternalTextureLoader {
  1151. /**
  1152. * Defines wether the loader supports cascade loading the different faces.
  1153. */
  1154. supportCascades: boolean;
  1155. /**
  1156. * This returns if the loader support the current file information.
  1157. * @param extension defines the file extension of the file being loaded
  1158. * @param mimeType defines the optional mime type of the file being loaded
  1159. * @returns true if the loader can load the specified file
  1160. */
  1161. canLoad(extension: string, mimeType?: string): boolean;
  1162. /**
  1163. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1164. * @param data contains the texture data
  1165. * @param texture defines the BabylonJS internal texture
  1166. * @param createPolynomials will be true if polynomials have been requested
  1167. * @param onLoad defines the callback to trigger once the texture is ready
  1168. * @param onError defines the callback to trigger in case of error
  1169. * @param options options to be passed to the loader
  1170. */
  1171. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1172. /**
  1173. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1174. * @param data contains the texture data
  1175. * @param texture defines the BabylonJS internal texture
  1176. * @param callback defines the method to call once ready to upload
  1177. * @param options options to be passed to the loader
  1178. */
  1179. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1180. }
  1181. }
  1182. declare module BABYLON {
  1183. /**
  1184. * @hidden
  1185. */
  1186. export interface IColor4Like {
  1187. r: float;
  1188. g: float;
  1189. b: float;
  1190. a: float;
  1191. }
  1192. /**
  1193. * @hidden
  1194. */
  1195. export interface IColor3Like {
  1196. r: float;
  1197. g: float;
  1198. b: float;
  1199. }
  1200. /**
  1201. * @hidden
  1202. */
  1203. export interface IVector4Like {
  1204. x: float;
  1205. y: float;
  1206. z: float;
  1207. w: float;
  1208. }
  1209. /**
  1210. * @hidden
  1211. */
  1212. export interface IVector3Like {
  1213. x: float;
  1214. y: float;
  1215. z: float;
  1216. }
  1217. /**
  1218. * @hidden
  1219. */
  1220. export interface IVector2Like {
  1221. x: float;
  1222. y: float;
  1223. }
  1224. /**
  1225. * @hidden
  1226. */
  1227. export interface IMatrixLike {
  1228. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1229. updateFlag: int;
  1230. }
  1231. /**
  1232. * @hidden
  1233. */
  1234. export interface IViewportLike {
  1235. x: float;
  1236. y: float;
  1237. width: float;
  1238. height: float;
  1239. }
  1240. /**
  1241. * @hidden
  1242. */
  1243. export interface IPlaneLike {
  1244. normal: IVector3Like;
  1245. d: float;
  1246. normalize(): void;
  1247. }
  1248. }
  1249. declare module BABYLON {
  1250. /**
  1251. * Class used to store and describe the pipeline context associated with an effect
  1252. */
  1253. export interface IPipelineContext {
  1254. /**
  1255. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1256. */
  1257. isAsync: boolean;
  1258. /**
  1259. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1260. */
  1261. isReady: boolean;
  1262. /** @hidden */
  1263. _name?: string;
  1264. /** @hidden */
  1265. _getVertexShaderCode(): string | null;
  1266. /** @hidden */
  1267. _getFragmentShaderCode(): string | null;
  1268. /** @hidden */
  1269. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1270. /** @hidden */
  1271. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  1272. [key: string]: number;
  1273. }, uniformsNames: string[], uniforms: {
  1274. [key: string]: Nullable<WebGLUniformLocation>;
  1275. }, samplerList: string[], samplers: {
  1276. [key: string]: number;
  1277. }, attributesNames: string[], attributes: number[]): void;
  1278. /** Releases the resources associated with the pipeline. */
  1279. dispose(): void;
  1280. /**
  1281. * Sets an integer value on a uniform variable.
  1282. * @param uniformName Name of the variable.
  1283. * @param value Value to be set.
  1284. */
  1285. setInt(uniformName: string, value: number): void;
  1286. /**
  1287. * Sets an int2 value on a uniform variable.
  1288. * @param uniformName Name of the variable.
  1289. * @param x First int in int2.
  1290. * @param y Second int in int2.
  1291. */
  1292. setInt2(uniformName: string, x: number, y: number): void;
  1293. /**
  1294. * Sets an int3 value on a uniform variable.
  1295. * @param uniformName Name of the variable.
  1296. * @param x First int in int3.
  1297. * @param y Second int in int3.
  1298. * @param z Third int in int3.
  1299. */
  1300. setInt3(uniformName: string, x: number, y: number, z: number): void;
  1301. /**
  1302. * Sets an int4 value on a uniform variable.
  1303. * @param uniformName Name of the variable.
  1304. * @param x First int in int4.
  1305. * @param y Second int in int4.
  1306. * @param z Third int in int4.
  1307. * @param w Fourth int in int4.
  1308. */
  1309. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  1310. /**
  1311. * Sets an int array on a uniform variable.
  1312. * @param uniformName Name of the variable.
  1313. * @param array array to be set.
  1314. */
  1315. setIntArray(uniformName: string, array: Int32Array): void;
  1316. /**
  1317. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  1318. * @param uniformName Name of the variable.
  1319. * @param array array to be set.
  1320. */
  1321. setIntArray2(uniformName: string, array: Int32Array): void;
  1322. /**
  1323. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  1324. * @param uniformName Name of the variable.
  1325. * @param array array to be set.
  1326. */
  1327. setIntArray3(uniformName: string, array: Int32Array): void;
  1328. /**
  1329. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  1330. * @param uniformName Name of the variable.
  1331. * @param array array to be set.
  1332. */
  1333. setIntArray4(uniformName: string, array: Int32Array): void;
  1334. /**
  1335. * Sets an array on a uniform variable.
  1336. * @param uniformName Name of the variable.
  1337. * @param array array to be set.
  1338. */
  1339. setArray(uniformName: string, array: number[] | Float32Array): void;
  1340. /**
  1341. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  1342. * @param uniformName Name of the variable.
  1343. * @param array array to be set.
  1344. */
  1345. setArray2(uniformName: string, array: number[] | Float32Array): void;
  1346. /**
  1347. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  1348. * @param uniformName Name of the variable.
  1349. * @param array array to be set.
  1350. */
  1351. setArray3(uniformName: string, array: number[] | Float32Array): void;
  1352. /**
  1353. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  1354. * @param uniformName Name of the variable.
  1355. * @param array array to be set.
  1356. */
  1357. setArray4(uniformName: string, array: number[] | Float32Array): void;
  1358. /**
  1359. * Sets matrices on a uniform variable.
  1360. * @param uniformName Name of the variable.
  1361. * @param matrices matrices to be set.
  1362. */
  1363. setMatrices(uniformName: string, matrices: Float32Array): void;
  1364. /**
  1365. * Sets matrix on a uniform variable.
  1366. * @param uniformName Name of the variable.
  1367. * @param matrix matrix to be set.
  1368. */
  1369. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  1370. /**
  1371. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  1372. * @param uniformName Name of the variable.
  1373. * @param matrix matrix to be set.
  1374. */
  1375. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  1376. /**
  1377. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  1378. * @param uniformName Name of the variable.
  1379. * @param matrix matrix to be set.
  1380. */
  1381. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  1382. /**
  1383. * Sets a float on a uniform variable.
  1384. * @param uniformName Name of the variable.
  1385. * @param value value to be set.
  1386. */
  1387. setFloat(uniformName: string, value: number): void;
  1388. /**
  1389. * Sets a Vector2 on a uniform variable.
  1390. * @param uniformName Name of the variable.
  1391. * @param vector2 vector2 to be set.
  1392. */
  1393. setVector2(uniformName: string, vector2: IVector2Like): void;
  1394. /**
  1395. * Sets a float2 on a uniform variable.
  1396. * @param uniformName Name of the variable.
  1397. * @param x First float in float2.
  1398. * @param y Second float in float2.
  1399. */
  1400. setFloat2(uniformName: string, x: number, y: number): void;
  1401. /**
  1402. * Sets a Vector3 on a uniform variable.
  1403. * @param uniformName Name of the variable.
  1404. * @param vector3 Value to be set.
  1405. */
  1406. setVector3(uniformName: string, vector3: IVector3Like): void;
  1407. /**
  1408. * Sets a float3 on a uniform variable.
  1409. * @param uniformName Name of the variable.
  1410. * @param x First float in float3.
  1411. * @param y Second float in float3.
  1412. * @param z Third float in float3.
  1413. */
  1414. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  1415. /**
  1416. * Sets a Vector4 on a uniform variable.
  1417. * @param uniformName Name of the variable.
  1418. * @param vector4 Value to be set.
  1419. */
  1420. setVector4(uniformName: string, vector4: IVector4Like): void;
  1421. /**
  1422. * Sets a float4 on a uniform variable.
  1423. * @param uniformName Name of the variable.
  1424. * @param x First float in float4.
  1425. * @param y Second float in float4.
  1426. * @param z Third float in float4.
  1427. * @param w Fourth float in float4.
  1428. */
  1429. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  1430. /**
  1431. * Sets a Color3 on a uniform variable.
  1432. * @param uniformName Name of the variable.
  1433. * @param color3 Value to be set.
  1434. */
  1435. setColor3(uniformName: string, color3: IColor3Like): void;
  1436. /**
  1437. * Sets a Color4 on a uniform variable.
  1438. * @param uniformName Name of the variable.
  1439. * @param color3 Value to be set.
  1440. * @param alpha Alpha value to be set.
  1441. */
  1442. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  1443. /**
  1444. * Sets a Color4 on a uniform variable
  1445. * @param uniformName defines the name of the variable
  1446. * @param color4 defines the value to be set
  1447. */
  1448. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  1449. }
  1450. }
  1451. declare module BABYLON {
  1452. /**
  1453. * Class used to store gfx data (like WebGLBuffer)
  1454. */
  1455. export class DataBuffer {
  1456. /**
  1457. * Gets or sets the number of objects referencing this buffer
  1458. */
  1459. references: number;
  1460. /** Gets or sets the size of the underlying buffer */
  1461. capacity: number;
  1462. /**
  1463. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1464. */
  1465. is32Bits: boolean;
  1466. /**
  1467. * Gets the underlying buffer
  1468. */
  1469. get underlyingResource(): any;
  1470. }
  1471. }
  1472. declare module BABYLON {
  1473. /** @hidden */
  1474. export interface IShaderProcessor {
  1475. attributeProcessor?: (attribute: string, preProcessors: {
  1476. [key: string]: string;
  1477. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1478. varyingProcessor?: (varying: string, isFragment: boolean, preProcessors: {
  1479. [key: string]: string;
  1480. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1481. uniformProcessor?: (uniform: string, isFragment: boolean, preProcessors: {
  1482. [key: string]: string;
  1483. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1484. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1485. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1486. lineProcessor?: (line: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1487. preProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1488. postProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine) => string;
  1489. initializeShaders?: (processingContext: Nullable<ShaderProcessingContext>) => void;
  1490. finalizeShaders?: (vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>) => {
  1491. vertexCode: string;
  1492. fragmentCode: string;
  1493. };
  1494. }
  1495. }
  1496. declare module BABYLON {
  1497. /** @hidden */
  1498. export interface ShaderProcessingContext {
  1499. }
  1500. /** @hidden */
  1501. export interface ProcessingOptions {
  1502. defines: string[];
  1503. indexParameters: any;
  1504. isFragment: boolean;
  1505. shouldUseHighPrecisionShader: boolean;
  1506. supportsUniformBuffers: boolean;
  1507. shadersRepository: string;
  1508. includesShadersStore: {
  1509. [key: string]: string;
  1510. };
  1511. processor: Nullable<IShaderProcessor>;
  1512. version: string;
  1513. platformName: string;
  1514. lookForClosingBracketForUniformBuffer?: boolean;
  1515. processingContext: Nullable<ShaderProcessingContext>;
  1516. }
  1517. }
  1518. declare module BABYLON {
  1519. /** @hidden */
  1520. export class ShaderCodeNode {
  1521. line: string;
  1522. children: ShaderCodeNode[];
  1523. additionalDefineKey?: string;
  1524. additionalDefineValue?: string;
  1525. isValid(preprocessors: {
  1526. [key: string]: string;
  1527. }): boolean;
  1528. process(preprocessors: {
  1529. [key: string]: string;
  1530. }, options: ProcessingOptions): string;
  1531. }
  1532. }
  1533. declare module BABYLON {
  1534. /** @hidden */
  1535. export class ShaderCodeCursor {
  1536. private _lines;
  1537. lineIndex: number;
  1538. get currentLine(): string;
  1539. get canRead(): boolean;
  1540. set lines(value: string[]);
  1541. }
  1542. }
  1543. declare module BABYLON {
  1544. /** @hidden */
  1545. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1546. process(preprocessors: {
  1547. [key: string]: string;
  1548. }, options: ProcessingOptions): string;
  1549. }
  1550. }
  1551. declare module BABYLON {
  1552. /** @hidden */
  1553. export class ShaderDefineExpression {
  1554. isTrue(preprocessors: {
  1555. [key: string]: string;
  1556. }): boolean;
  1557. private static _OperatorPriority;
  1558. private static _Stack;
  1559. static postfixToInfix(postfix: string[]): string;
  1560. static infixToPostfix(infix: string): string[];
  1561. }
  1562. }
  1563. declare module BABYLON {
  1564. /** @hidden */
  1565. export class ShaderCodeTestNode extends ShaderCodeNode {
  1566. testExpression: ShaderDefineExpression;
  1567. isValid(preprocessors: {
  1568. [key: string]: string;
  1569. }): boolean;
  1570. }
  1571. }
  1572. declare module BABYLON {
  1573. /** @hidden */
  1574. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1575. define: string;
  1576. not: boolean;
  1577. constructor(define: string, not?: boolean);
  1578. isTrue(preprocessors: {
  1579. [key: string]: string;
  1580. }): boolean;
  1581. }
  1582. }
  1583. declare module BABYLON {
  1584. /** @hidden */
  1585. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1586. leftOperand: ShaderDefineExpression;
  1587. rightOperand: ShaderDefineExpression;
  1588. isTrue(preprocessors: {
  1589. [key: string]: string;
  1590. }): boolean;
  1591. }
  1592. }
  1593. declare module BABYLON {
  1594. /** @hidden */
  1595. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1596. leftOperand: ShaderDefineExpression;
  1597. rightOperand: ShaderDefineExpression;
  1598. isTrue(preprocessors: {
  1599. [key: string]: string;
  1600. }): boolean;
  1601. }
  1602. }
  1603. declare module BABYLON {
  1604. /** @hidden */
  1605. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1606. define: string;
  1607. operand: string;
  1608. testValue: string;
  1609. constructor(define: string, operand: string, testValue: string);
  1610. isTrue(preprocessors: {
  1611. [key: string]: string;
  1612. }): boolean;
  1613. }
  1614. }
  1615. declare module BABYLON {
  1616. /**
  1617. * Class used to enable access to offline support
  1618. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1619. */
  1620. export interface IOfflineProvider {
  1621. /**
  1622. * Gets a boolean indicating if scene must be saved in the database
  1623. */
  1624. enableSceneOffline: boolean;
  1625. /**
  1626. * Gets a boolean indicating if textures must be saved in the database
  1627. */
  1628. enableTexturesOffline: boolean;
  1629. /**
  1630. * Open the offline support and make it available
  1631. * @param successCallback defines the callback to call on success
  1632. * @param errorCallback defines the callback to call on error
  1633. */
  1634. open(successCallback: () => void, errorCallback: () => void): void;
  1635. /**
  1636. * Loads an image from the offline support
  1637. * @param url defines the url to load from
  1638. * @param image defines the target DOM image
  1639. */
  1640. loadImage(url: string, image: HTMLImageElement): void;
  1641. /**
  1642. * Loads a file from offline support
  1643. * @param url defines the URL to load from
  1644. * @param sceneLoaded defines a callback to call on success
  1645. * @param progressCallBack defines a callback to call when progress changed
  1646. * @param errorCallback defines a callback to call on error
  1647. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1648. */
  1649. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1650. }
  1651. }
  1652. declare module BABYLON {
  1653. /**
  1654. * Class used to help managing file picking and drag'n'drop
  1655. * File Storage
  1656. */
  1657. export class FilesInputStore {
  1658. /**
  1659. * List of files ready to be loaded
  1660. */
  1661. static FilesToLoad: {
  1662. [key: string]: File;
  1663. };
  1664. }
  1665. }
  1666. declare module BABYLON {
  1667. /**
  1668. * Class used to define a retry strategy when error happens while loading assets
  1669. */
  1670. export class RetryStrategy {
  1671. /**
  1672. * Function used to defines an exponential back off strategy
  1673. * @param maxRetries defines the maximum number of retries (3 by default)
  1674. * @param baseInterval defines the interval between retries
  1675. * @returns the strategy function to use
  1676. */
  1677. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1678. }
  1679. }
  1680. declare module BABYLON {
  1681. /**
  1682. * @ignore
  1683. * Application error to support additional information when loading a file
  1684. */
  1685. export abstract class BaseError extends Error {
  1686. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1687. }
  1688. }
  1689. declare module BABYLON {
  1690. /** @ignore */
  1691. export class LoadFileError extends BaseError {
  1692. request?: WebRequest;
  1693. file?: File;
  1694. /**
  1695. * Creates a new LoadFileError
  1696. * @param message defines the message of the error
  1697. * @param request defines the optional web request
  1698. * @param file defines the optional file
  1699. */
  1700. constructor(message: string, object?: WebRequest | File);
  1701. }
  1702. /** @ignore */
  1703. export class RequestFileError extends BaseError {
  1704. request: WebRequest;
  1705. /**
  1706. * Creates a new LoadFileError
  1707. * @param message defines the message of the error
  1708. * @param request defines the optional web request
  1709. */
  1710. constructor(message: string, request: WebRequest);
  1711. }
  1712. /** @ignore */
  1713. export class ReadFileError extends BaseError {
  1714. file: File;
  1715. /**
  1716. * Creates a new ReadFileError
  1717. * @param message defines the message of the error
  1718. * @param file defines the optional file
  1719. */
  1720. constructor(message: string, file: File);
  1721. }
  1722. /**
  1723. * @hidden
  1724. */
  1725. export class FileTools {
  1726. /**
  1727. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1728. */
  1729. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1730. /**
  1731. * Gets or sets the base URL to use to load assets
  1732. */
  1733. static BaseUrl: string;
  1734. /**
  1735. * Default behaviour for cors in the application.
  1736. * It can be a string if the expected behavior is identical in the entire app.
  1737. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1738. */
  1739. static CorsBehavior: string | ((url: string | string[]) => string);
  1740. /**
  1741. * Gets or sets a function used to pre-process url before using them to load assets
  1742. */
  1743. static PreprocessUrl: (url: string) => string;
  1744. /**
  1745. * Removes unwanted characters from an url
  1746. * @param url defines the url to clean
  1747. * @returns the cleaned url
  1748. */
  1749. private static _CleanUrl;
  1750. /**
  1751. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1752. * @param url define the url we are trying
  1753. * @param element define the dom element where to configure the cors policy
  1754. */
  1755. static SetCorsBehavior(url: string | string[], element: {
  1756. crossOrigin: string | null;
  1757. }): void;
  1758. /**
  1759. * Loads an image as an HTMLImageElement.
  1760. * @param input url string, ArrayBuffer, or Blob to load
  1761. * @param onLoad callback called when the image successfully loads
  1762. * @param onError callback called when the image fails to load
  1763. * @param offlineProvider offline provider for caching
  1764. * @param mimeType optional mime type
  1765. * @returns the HTMLImageElement of the loaded image
  1766. */
  1767. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1768. /**
  1769. * Reads a file from a File object
  1770. * @param file defines the file to load
  1771. * @param onSuccess defines the callback to call when data is loaded
  1772. * @param onProgress defines the callback to call during loading process
  1773. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1774. * @param onError defines the callback to call when an error occurs
  1775. * @returns a file request object
  1776. */
  1777. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1778. /**
  1779. * Loads a file from a url
  1780. * @param url url to load
  1781. * @param onSuccess callback called when the file successfully loads
  1782. * @param onProgress callback called while file is loading (if the server supports this mode)
  1783. * @param offlineProvider defines the offline provider for caching
  1784. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1785. * @param onError callback called when the file fails to load
  1786. * @returns a file request object
  1787. */
  1788. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1789. /**
  1790. * Loads a file
  1791. * @param url url to load
  1792. * @param onSuccess callback called when the file successfully loads
  1793. * @param onProgress callback called while file is loading (if the server supports this mode)
  1794. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1795. * @param onError callback called when the file fails to load
  1796. * @param onOpened callback called when the web request is opened
  1797. * @returns a file request object
  1798. */
  1799. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1800. /**
  1801. * Checks if the loaded document was accessed via `file:`-Protocol.
  1802. * @returns boolean
  1803. */
  1804. static IsFileURL(): boolean;
  1805. }
  1806. }
  1807. declare module BABYLON {
  1808. /** @hidden */
  1809. export class ShaderProcessor {
  1810. static Initialize(options: ProcessingOptions): void;
  1811. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1812. static Finalize(vertexCode: string, fragmentCode: string, options: ProcessingOptions): {
  1813. vertexCode: string;
  1814. fragmentCode: string;
  1815. };
  1816. private static _ProcessPrecision;
  1817. private static _ExtractOperation;
  1818. private static _BuildSubExpression;
  1819. private static _BuildExpression;
  1820. private static _MoveCursorWithinIf;
  1821. private static _MoveCursor;
  1822. private static _EvaluatePreProcessors;
  1823. private static _PreparePreProcessors;
  1824. private static _ProcessShaderConversion;
  1825. private static _ProcessIncludes;
  1826. /**
  1827. * Loads a file from a url
  1828. * @param url url to load
  1829. * @param onSuccess callback called when the file successfully loads
  1830. * @param onProgress callback called while file is loading (if the server supports this mode)
  1831. * @param offlineProvider defines the offline provider for caching
  1832. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1833. * @param onError callback called when the file fails to load
  1834. * @returns a file request object
  1835. * @hidden
  1836. */
  1837. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1838. }
  1839. }
  1840. declare module BABYLON {
  1841. /**
  1842. * Interface used to define common properties for effect fallbacks
  1843. */
  1844. export interface IEffectFallbacks {
  1845. /**
  1846. * Removes the defines that should be removed when falling back.
  1847. * @param currentDefines defines the current define statements for the shader.
  1848. * @param effect defines the current effect we try to compile
  1849. * @returns The resulting defines with defines of the current rank removed.
  1850. */
  1851. reduce(currentDefines: string, effect: Effect): string;
  1852. /**
  1853. * Removes the fallback from the bound mesh.
  1854. */
  1855. unBindMesh(): void;
  1856. /**
  1857. * Checks to see if more fallbacks are still availible.
  1858. */
  1859. hasMoreFallbacks: boolean;
  1860. }
  1861. }
  1862. declare module BABYLON {
  1863. /**
  1864. * Interface for the size containing width and height
  1865. */
  1866. export interface ISize {
  1867. /**
  1868. * Width
  1869. */
  1870. width: number;
  1871. /**
  1872. * Heighht
  1873. */
  1874. height: number;
  1875. }
  1876. /**
  1877. * Size containing widht and height
  1878. */
  1879. export class Size implements ISize {
  1880. /**
  1881. * Width
  1882. */
  1883. width: number;
  1884. /**
  1885. * Height
  1886. */
  1887. height: number;
  1888. /**
  1889. * Creates a Size object from the given width and height (floats).
  1890. * @param width width of the new size
  1891. * @param height height of the new size
  1892. */
  1893. constructor(width: number, height: number);
  1894. /**
  1895. * Returns a string with the Size width and height
  1896. * @returns a string with the Size width and height
  1897. */
  1898. toString(): string;
  1899. /**
  1900. * "Size"
  1901. * @returns the string "Size"
  1902. */
  1903. getClassName(): string;
  1904. /**
  1905. * Returns the Size hash code.
  1906. * @returns a hash code for a unique width and height
  1907. */
  1908. getHashCode(): number;
  1909. /**
  1910. * Updates the current size from the given one.
  1911. * @param src the given size
  1912. */
  1913. copyFrom(src: Size): void;
  1914. /**
  1915. * Updates in place the current Size from the given floats.
  1916. * @param width width of the new size
  1917. * @param height height of the new size
  1918. * @returns the updated Size.
  1919. */
  1920. copyFromFloats(width: number, height: number): Size;
  1921. /**
  1922. * Updates in place the current Size from the given floats.
  1923. * @param width width to set
  1924. * @param height height to set
  1925. * @returns the updated Size.
  1926. */
  1927. set(width: number, height: number): Size;
  1928. /**
  1929. * Multiplies the width and height by numbers
  1930. * @param w factor to multiple the width by
  1931. * @param h factor to multiple the height by
  1932. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  1933. */
  1934. multiplyByFloats(w: number, h: number): Size;
  1935. /**
  1936. * Clones the size
  1937. * @returns a new Size copied from the given one.
  1938. */
  1939. clone(): Size;
  1940. /**
  1941. * True if the current Size and the given one width and height are strictly equal.
  1942. * @param other the other size to compare against
  1943. * @returns True if the current Size and the given one width and height are strictly equal.
  1944. */
  1945. equals(other: Size): boolean;
  1946. /**
  1947. * The surface of the Size : width * height (float).
  1948. */
  1949. get surface(): number;
  1950. /**
  1951. * Create a new size of zero
  1952. * @returns a new Size set to (0.0, 0.0)
  1953. */
  1954. static Zero(): Size;
  1955. /**
  1956. * Sums the width and height of two sizes
  1957. * @param otherSize size to add to this size
  1958. * @returns a new Size set as the addition result of the current Size and the given one.
  1959. */
  1960. add(otherSize: Size): Size;
  1961. /**
  1962. * Subtracts the width and height of two
  1963. * @param otherSize size to subtract to this size
  1964. * @returns a new Size set as the subtraction result of the given one from the current Size.
  1965. */
  1966. subtract(otherSize: Size): Size;
  1967. /**
  1968. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  1969. * @param start starting size to lerp between
  1970. * @param end end size to lerp between
  1971. * @param amount amount to lerp between the start and end values
  1972. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  1973. */
  1974. static Lerp(start: Size, end: Size, amount: number): Size;
  1975. }
  1976. }
  1977. declare module BABYLON {
  1978. /**
  1979. * Base class of all the textures in babylon.
  1980. * It groups all the common properties required to work with Thin Engine.
  1981. */
  1982. export class ThinTexture {
  1983. protected _wrapU: number;
  1984. /**
  1985. * | Value | Type | Description |
  1986. * | ----- | ------------------ | ----------- |
  1987. * | 0 | CLAMP_ADDRESSMODE | |
  1988. * | 1 | WRAP_ADDRESSMODE | |
  1989. * | 2 | MIRROR_ADDRESSMODE | |
  1990. */
  1991. get wrapU(): number;
  1992. set wrapU(value: number);
  1993. protected _wrapV: number;
  1994. /**
  1995. * | Value | Type | Description |
  1996. * | ----- | ------------------ | ----------- |
  1997. * | 0 | CLAMP_ADDRESSMODE | |
  1998. * | 1 | WRAP_ADDRESSMODE | |
  1999. * | 2 | MIRROR_ADDRESSMODE | |
  2000. */
  2001. get wrapV(): number;
  2002. set wrapV(value: number);
  2003. /**
  2004. * | Value | Type | Description |
  2005. * | ----- | ------------------ | ----------- |
  2006. * | 0 | CLAMP_ADDRESSMODE | |
  2007. * | 1 | WRAP_ADDRESSMODE | |
  2008. * | 2 | MIRROR_ADDRESSMODE | |
  2009. */
  2010. wrapR: number;
  2011. /**
  2012. * With compliant hardware and browser (supporting anisotropic filtering)
  2013. * this defines the level of anisotropic filtering in the texture.
  2014. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  2015. */
  2016. anisotropicFilteringLevel: number;
  2017. /**
  2018. * Define the current state of the loading sequence when in delayed load mode.
  2019. */
  2020. delayLoadState: number;
  2021. /**
  2022. * How a texture is mapped.
  2023. * Unused in thin texture mode.
  2024. */
  2025. get coordinatesMode(): number;
  2026. /**
  2027. * Define if the texture is a cube texture or if false a 2d texture.
  2028. */
  2029. get isCube(): boolean;
  2030. set isCube(value: boolean);
  2031. /**
  2032. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  2033. */
  2034. get is3D(): boolean;
  2035. set is3D(value: boolean);
  2036. /**
  2037. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  2038. */
  2039. get is2DArray(): boolean;
  2040. set is2DArray(value: boolean);
  2041. /**
  2042. * Get the class name of the texture.
  2043. * @returns "ThinTexture"
  2044. */
  2045. getClassName(): string;
  2046. /** @hidden */
  2047. _texture: Nullable<InternalTexture>;
  2048. protected _engine: Nullable<ThinEngine>;
  2049. private _cachedSize;
  2050. private _cachedBaseSize;
  2051. /**
  2052. * Instantiates a new ThinTexture.
  2053. * Base class of all the textures in babylon.
  2054. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  2055. * @param internalTexture Define the internalTexture to wrap
  2056. */
  2057. constructor(internalTexture: Nullable<InternalTexture>);
  2058. /**
  2059. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  2060. * @returns true if fully ready
  2061. */
  2062. isReady(): boolean;
  2063. /**
  2064. * Triggers the load sequence in delayed load mode.
  2065. */
  2066. delayLoad(): void;
  2067. /**
  2068. * Get the underlying lower level texture from Babylon.
  2069. * @returns the insternal texture
  2070. */
  2071. getInternalTexture(): Nullable<InternalTexture>;
  2072. /**
  2073. * Get the size of the texture.
  2074. * @returns the texture size.
  2075. */
  2076. getSize(): ISize;
  2077. /**
  2078. * Get the base size of the texture.
  2079. * It can be different from the size if the texture has been resized for POT for instance
  2080. * @returns the base size
  2081. */
  2082. getBaseSize(): ISize;
  2083. /**
  2084. * Update the sampling mode of the texture.
  2085. * Default is Trilinear mode.
  2086. *
  2087. * | Value | Type | Description |
  2088. * | ----- | ------------------ | ----------- |
  2089. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  2090. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  2091. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  2092. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  2093. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  2094. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  2095. * | 7 | NEAREST_LINEAR | |
  2096. * | 8 | NEAREST_NEAREST | |
  2097. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  2098. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  2099. * | 11 | LINEAR_LINEAR | |
  2100. * | 12 | LINEAR_NEAREST | |
  2101. *
  2102. * > _mag_: magnification filter (close to the viewer)
  2103. * > _min_: minification filter (far from the viewer)
  2104. * > _mip_: filter used between mip map levels
  2105. *@param samplingMode Define the new sampling mode of the texture
  2106. */
  2107. updateSamplingMode(samplingMode: number): void;
  2108. /**
  2109. * Release and destroy the underlying lower level texture aka internalTexture.
  2110. */
  2111. releaseInternalTexture(): void;
  2112. /**
  2113. * Dispose the texture and release its associated resources.
  2114. */
  2115. dispose(): void;
  2116. }
  2117. }
  2118. declare module BABYLON {
  2119. /**
  2120. * Defines an array and its length.
  2121. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  2122. */
  2123. export interface ISmartArrayLike<T> {
  2124. /**
  2125. * The data of the array.
  2126. */
  2127. data: Array<T>;
  2128. /**
  2129. * The active length of the array.
  2130. */
  2131. length: number;
  2132. }
  2133. /**
  2134. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2135. */
  2136. export class SmartArray<T> implements ISmartArrayLike<T> {
  2137. /**
  2138. * The full set of data from the array.
  2139. */
  2140. data: Array<T>;
  2141. /**
  2142. * The active length of the array.
  2143. */
  2144. length: number;
  2145. protected _id: number;
  2146. /**
  2147. * Instantiates a Smart Array.
  2148. * @param capacity defines the default capacity of the array.
  2149. */
  2150. constructor(capacity: number);
  2151. /**
  2152. * Pushes a value at the end of the active data.
  2153. * @param value defines the object to push in the array.
  2154. */
  2155. push(value: T): void;
  2156. /**
  2157. * Iterates over the active data and apply the lambda to them.
  2158. * @param func defines the action to apply on each value.
  2159. */
  2160. forEach(func: (content: T) => void): void;
  2161. /**
  2162. * Sorts the full sets of data.
  2163. * @param compareFn defines the comparison function to apply.
  2164. */
  2165. sort(compareFn: (a: T, b: T) => number): void;
  2166. /**
  2167. * Resets the active data to an empty array.
  2168. */
  2169. reset(): void;
  2170. /**
  2171. * Releases all the data from the array as well as the array.
  2172. */
  2173. dispose(): void;
  2174. /**
  2175. * Concats the active data with a given array.
  2176. * @param array defines the data to concatenate with.
  2177. */
  2178. concat(array: any): void;
  2179. /**
  2180. * Returns the position of a value in the active data.
  2181. * @param value defines the value to find the index for
  2182. * @returns the index if found in the active data otherwise -1
  2183. */
  2184. indexOf(value: T): number;
  2185. /**
  2186. * Returns whether an element is part of the active data.
  2187. * @param value defines the value to look for
  2188. * @returns true if found in the active data otherwise false
  2189. */
  2190. contains(value: T): boolean;
  2191. private static _GlobalId;
  2192. }
  2193. /**
  2194. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2195. * The data in this array can only be present once
  2196. */
  2197. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  2198. private _duplicateId;
  2199. /**
  2200. * Pushes a value at the end of the active data.
  2201. * THIS DOES NOT PREVENT DUPPLICATE DATA
  2202. * @param value defines the object to push in the array.
  2203. */
  2204. push(value: T): void;
  2205. /**
  2206. * Pushes a value at the end of the active data.
  2207. * If the data is already present, it won t be added again
  2208. * @param value defines the object to push in the array.
  2209. * @returns true if added false if it was already present
  2210. */
  2211. pushNoDuplicate(value: T): boolean;
  2212. /**
  2213. * Resets the active data to an empty array.
  2214. */
  2215. reset(): void;
  2216. /**
  2217. * Concats the active data with a given array.
  2218. * This ensures no dupplicate will be present in the result.
  2219. * @param array defines the data to concatenate with.
  2220. */
  2221. concatWithNoDuplicate(array: any): void;
  2222. }
  2223. }
  2224. declare module BABYLON {
  2225. /**
  2226. * Class used to evalaute queries containing `and` and `or` operators
  2227. */
  2228. export class AndOrNotEvaluator {
  2229. /**
  2230. * Evaluate a query
  2231. * @param query defines the query to evaluate
  2232. * @param evaluateCallback defines the callback used to filter result
  2233. * @returns true if the query matches
  2234. */
  2235. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  2236. private static _HandleParenthesisContent;
  2237. private static _SimplifyNegation;
  2238. }
  2239. }
  2240. declare module BABYLON {
  2241. /**
  2242. * Class used to store custom tags
  2243. */
  2244. export class Tags {
  2245. /**
  2246. * Adds support for tags on the given object
  2247. * @param obj defines the object to use
  2248. */
  2249. static EnableFor(obj: any): void;
  2250. /**
  2251. * Removes tags support
  2252. * @param obj defines the object to use
  2253. */
  2254. static DisableFor(obj: any): void;
  2255. /**
  2256. * Gets a boolean indicating if the given object has tags
  2257. * @param obj defines the object to use
  2258. * @returns a boolean
  2259. */
  2260. static HasTags(obj: any): boolean;
  2261. /**
  2262. * Gets the tags available on a given object
  2263. * @param obj defines the object to use
  2264. * @param asString defines if the tags must be returned as a string instead of an array of strings
  2265. * @returns the tags
  2266. */
  2267. static GetTags(obj: any, asString?: boolean): any;
  2268. /**
  2269. * Adds tags to an object
  2270. * @param obj defines the object to use
  2271. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  2272. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  2273. */
  2274. static AddTagsTo(obj: any, tagsString: string): void;
  2275. /**
  2276. * @hidden
  2277. */
  2278. static _AddTagTo(obj: any, tag: string): void;
  2279. /**
  2280. * Removes specific tags from a specific object
  2281. * @param obj defines the object to use
  2282. * @param tagsString defines the tags to remove
  2283. */
  2284. static RemoveTagsFrom(obj: any, tagsString: string): void;
  2285. /**
  2286. * @hidden
  2287. */
  2288. static _RemoveTagFrom(obj: any, tag: string): void;
  2289. /**
  2290. * Defines if tags hosted on an object match a given query
  2291. * @param obj defines the object to use
  2292. * @param tagsQuery defines the tag query
  2293. * @returns a boolean
  2294. */
  2295. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  2296. }
  2297. }
  2298. declare module BABYLON {
  2299. /**
  2300. * Scalar computation library
  2301. */
  2302. export class Scalar {
  2303. /**
  2304. * Two pi constants convenient for computation.
  2305. */
  2306. static TwoPi: number;
  2307. /**
  2308. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2309. * @param a number
  2310. * @param b number
  2311. * @param epsilon (default = 1.401298E-45)
  2312. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2313. */
  2314. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  2315. /**
  2316. * Returns a string : the upper case translation of the number i to hexadecimal.
  2317. * @param i number
  2318. * @returns the upper case translation of the number i to hexadecimal.
  2319. */
  2320. static ToHex(i: number): string;
  2321. /**
  2322. * Returns -1 if value is negative and +1 is value is positive.
  2323. * @param value the value
  2324. * @returns the value itself if it's equal to zero.
  2325. */
  2326. static Sign(value: number): number;
  2327. /**
  2328. * Returns the value itself if it's between min and max.
  2329. * Returns min if the value is lower than min.
  2330. * Returns max if the value is greater than max.
  2331. * @param value the value to clmap
  2332. * @param min the min value to clamp to (default: 0)
  2333. * @param max the max value to clamp to (default: 1)
  2334. * @returns the clamped value
  2335. */
  2336. static Clamp(value: number, min?: number, max?: number): number;
  2337. /**
  2338. * the log2 of value.
  2339. * @param value the value to compute log2 of
  2340. * @returns the log2 of value.
  2341. */
  2342. static Log2(value: number): number;
  2343. /**
  2344. * the floor part of a log2 value.
  2345. * @param value the value to compute log2 of
  2346. * @returns the log2 of value.
  2347. */
  2348. static ILog2(value: number): number;
  2349. /**
  2350. * Loops the value, so that it is never larger than length and never smaller than 0.
  2351. *
  2352. * This is similar to the modulo operator but it works with floating point numbers.
  2353. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  2354. * With t = 5 and length = 2.5, the result would be 0.0.
  2355. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  2356. * @param value the value
  2357. * @param length the length
  2358. * @returns the looped value
  2359. */
  2360. static Repeat(value: number, length: number): number;
  2361. /**
  2362. * Normalize the value between 0.0 and 1.0 using min and max values
  2363. * @param value value to normalize
  2364. * @param min max to normalize between
  2365. * @param max min to normalize between
  2366. * @returns the normalized value
  2367. */
  2368. static Normalize(value: number, min: number, max: number): number;
  2369. /**
  2370. * Denormalize the value from 0.0 and 1.0 using min and max values
  2371. * @param normalized value to denormalize
  2372. * @param min max to denormalize between
  2373. * @param max min to denormalize between
  2374. * @returns the denormalized value
  2375. */
  2376. static Denormalize(normalized: number, min: number, max: number): number;
  2377. /**
  2378. * Calculates the shortest difference between two given angles given in degrees.
  2379. * @param current current angle in degrees
  2380. * @param target target angle in degrees
  2381. * @returns the delta
  2382. */
  2383. static DeltaAngle(current: number, target: number): number;
  2384. /**
  2385. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  2386. * @param tx value
  2387. * @param length length
  2388. * @returns The returned value will move back and forth between 0 and length
  2389. */
  2390. static PingPong(tx: number, length: number): number;
  2391. /**
  2392. * Interpolates between min and max with smoothing at the limits.
  2393. *
  2394. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  2395. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  2396. * @param from from
  2397. * @param to to
  2398. * @param tx value
  2399. * @returns the smooth stepped value
  2400. */
  2401. static SmoothStep(from: number, to: number, tx: number): number;
  2402. /**
  2403. * Moves a value current towards target.
  2404. *
  2405. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  2406. * Negative values of maxDelta pushes the value away from target.
  2407. * @param current current value
  2408. * @param target target value
  2409. * @param maxDelta max distance to move
  2410. * @returns resulting value
  2411. */
  2412. static MoveTowards(current: number, target: number, maxDelta: number): number;
  2413. /**
  2414. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2415. *
  2416. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  2417. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  2418. * @param current current value
  2419. * @param target target value
  2420. * @param maxDelta max distance to move
  2421. * @returns resulting angle
  2422. */
  2423. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  2424. /**
  2425. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  2426. * @param start start value
  2427. * @param end target value
  2428. * @param amount amount to lerp between
  2429. * @returns the lerped value
  2430. */
  2431. static Lerp(start: number, end: number, amount: number): number;
  2432. /**
  2433. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2434. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  2435. * @param start start value
  2436. * @param end target value
  2437. * @param amount amount to lerp between
  2438. * @returns the lerped value
  2439. */
  2440. static LerpAngle(start: number, end: number, amount: number): number;
  2441. /**
  2442. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  2443. * @param a start value
  2444. * @param b target value
  2445. * @param value value between a and b
  2446. * @returns the inverseLerp value
  2447. */
  2448. static InverseLerp(a: number, b: number, value: number): number;
  2449. /**
  2450. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  2451. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  2452. * @param value1 spline value
  2453. * @param tangent1 spline value
  2454. * @param value2 spline value
  2455. * @param tangent2 spline value
  2456. * @param amount input value
  2457. * @returns hermite result
  2458. */
  2459. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  2460. /**
  2461. * Returns a random float number between and min and max values
  2462. * @param min min value of random
  2463. * @param max max value of random
  2464. * @returns random value
  2465. */
  2466. static RandomRange(min: number, max: number): number;
  2467. /**
  2468. * This function returns percentage of a number in a given range.
  2469. *
  2470. * RangeToPercent(40,20,60) will return 0.5 (50%)
  2471. * RangeToPercent(34,0,100) will return 0.34 (34%)
  2472. * @param number to convert to percentage
  2473. * @param min min range
  2474. * @param max max range
  2475. * @returns the percentage
  2476. */
  2477. static RangeToPercent(number: number, min: number, max: number): number;
  2478. /**
  2479. * This function returns number that corresponds to the percentage in a given range.
  2480. *
  2481. * PercentToRange(0.34,0,100) will return 34.
  2482. * @param percent to convert to number
  2483. * @param min min range
  2484. * @param max max range
  2485. * @returns the number
  2486. */
  2487. static PercentToRange(percent: number, min: number, max: number): number;
  2488. /**
  2489. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  2490. * @param angle The angle to normalize in radian.
  2491. * @return The converted angle.
  2492. */
  2493. static NormalizeRadians(angle: number): number;
  2494. }
  2495. }
  2496. declare module BABYLON {
  2497. /**
  2498. * Constant used to convert a value to gamma space
  2499. * @ignorenaming
  2500. */
  2501. export const ToGammaSpace: number;
  2502. /**
  2503. * Constant used to convert a value to linear space
  2504. * @ignorenaming
  2505. */
  2506. export const ToLinearSpace = 2.2;
  2507. /**
  2508. * Constant used to define the minimal number value in Babylon.js
  2509. * @ignorenaming
  2510. */
  2511. let Epsilon: number;
  2512. }
  2513. declare module BABYLON {
  2514. /**
  2515. * Class used to represent a viewport on screen
  2516. */
  2517. export class Viewport {
  2518. /** viewport left coordinate */
  2519. x: number;
  2520. /** viewport top coordinate */
  2521. y: number;
  2522. /**viewport width */
  2523. width: number;
  2524. /** viewport height */
  2525. height: number;
  2526. /**
  2527. * Creates a Viewport object located at (x, y) and sized (width, height)
  2528. * @param x defines viewport left coordinate
  2529. * @param y defines viewport top coordinate
  2530. * @param width defines the viewport width
  2531. * @param height defines the viewport height
  2532. */
  2533. constructor(
  2534. /** viewport left coordinate */
  2535. x: number,
  2536. /** viewport top coordinate */
  2537. y: number,
  2538. /**viewport width */
  2539. width: number,
  2540. /** viewport height */
  2541. height: number);
  2542. /**
  2543. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  2544. * @param renderWidth defines the rendering width
  2545. * @param renderHeight defines the rendering height
  2546. * @returns a new Viewport
  2547. */
  2548. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  2549. /**
  2550. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  2551. * @param renderWidth defines the rendering width
  2552. * @param renderHeight defines the rendering height
  2553. * @param ref defines the target viewport
  2554. * @returns the current viewport
  2555. */
  2556. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  2557. /**
  2558. * Returns a new Viewport copied from the current one
  2559. * @returns a new Viewport
  2560. */
  2561. clone(): Viewport;
  2562. }
  2563. }
  2564. declare module BABYLON {
  2565. /**
  2566. * Class containing a set of static utilities functions for arrays.
  2567. */
  2568. export class ArrayTools {
  2569. /**
  2570. * Returns an array of the given size filled with element built from the given constructor and the paramters
  2571. * @param size the number of element to construct and put in the array
  2572. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  2573. * @returns a new array filled with new objects
  2574. */
  2575. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  2576. }
  2577. }
  2578. declare module BABYLON {
  2579. /**
  2580. * Represents a plane by the equation ax + by + cz + d = 0
  2581. */
  2582. export class Plane {
  2583. private static _TmpMatrix;
  2584. /**
  2585. * Normal of the plane (a,b,c)
  2586. */
  2587. normal: Vector3;
  2588. /**
  2589. * d component of the plane
  2590. */
  2591. d: number;
  2592. /**
  2593. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2594. * @param a a component of the plane
  2595. * @param b b component of the plane
  2596. * @param c c component of the plane
  2597. * @param d d component of the plane
  2598. */
  2599. constructor(a: number, b: number, c: number, d: number);
  2600. /**
  2601. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2602. */
  2603. asArray(): number[];
  2604. /**
  2605. * @returns a new plane copied from the current Plane.
  2606. */
  2607. clone(): Plane;
  2608. /**
  2609. * @returns the string "Plane".
  2610. */
  2611. getClassName(): string;
  2612. /**
  2613. * @returns the Plane hash code.
  2614. */
  2615. getHashCode(): number;
  2616. /**
  2617. * Normalize the current Plane in place.
  2618. * @returns the updated Plane.
  2619. */
  2620. normalize(): Plane;
  2621. /**
  2622. * Applies a transformation the plane and returns the result
  2623. * @param transformation the transformation matrix to be applied to the plane
  2624. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2625. */
  2626. transform(transformation: DeepImmutable<Matrix>): Plane;
  2627. /**
  2628. * Compute the dot product between the point and the plane normal
  2629. * @param point point to calculate the dot product with
  2630. * @returns the dot product (float) of the point coordinates and the plane normal.
  2631. */
  2632. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2633. /**
  2634. * Updates the current Plane from the plane defined by the three given points.
  2635. * @param point1 one of the points used to contruct the plane
  2636. * @param point2 one of the points used to contruct the plane
  2637. * @param point3 one of the points used to contruct the plane
  2638. * @returns the updated Plane.
  2639. */
  2640. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2641. /**
  2642. * Checks if the plane is facing a given direction (meaning if the plane's normal is pointing in the opposite direction of the given vector).
  2643. * Note that for this function to work as expected you should make sure that:
  2644. * - direction and the plane normal are normalized
  2645. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  2646. * @param direction the direction to check if the plane is facing
  2647. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2648. * @returns True if the plane is facing the given direction
  2649. */
  2650. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2651. /**
  2652. * Calculates the distance to a point
  2653. * @param point point to calculate distance to
  2654. * @returns the signed distance (float) from the given point to the Plane.
  2655. */
  2656. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2657. /**
  2658. * Creates a plane from an array
  2659. * @param array the array to create a plane from
  2660. * @returns a new Plane from the given array.
  2661. */
  2662. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2663. /**
  2664. * Creates a plane from three points
  2665. * @param point1 point used to create the plane
  2666. * @param point2 point used to create the plane
  2667. * @param point3 point used to create the plane
  2668. * @returns a new Plane defined by the three given points.
  2669. */
  2670. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2671. /**
  2672. * Creates a plane from an origin point and a normal
  2673. * @param origin origin of the plane to be constructed
  2674. * @param normal normal of the plane to be constructed
  2675. * @returns a new Plane the normal vector to this plane at the given origin point.
  2676. * Note : the vector "normal" is updated because normalized.
  2677. */
  2678. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2679. /**
  2680. * Calculates the distance from a plane and a point
  2681. * @param origin origin of the plane to be constructed
  2682. * @param normal normal of the plane to be constructed
  2683. * @param point point to calculate distance to
  2684. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2685. */
  2686. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2687. }
  2688. }
  2689. declare module BABYLON {
  2690. /** @hidden */
  2691. export class PerformanceConfigurator {
  2692. /** @hidden */
  2693. static MatrixUse64Bits: boolean;
  2694. /** @hidden */
  2695. static MatrixTrackPrecisionChange: boolean;
  2696. /** @hidden */
  2697. static MatrixCurrentType: any;
  2698. /** @hidden */
  2699. static MatrixTrackedMatrices: Array<any> | null;
  2700. /** @hidden */
  2701. static SetMatrixPrecision(use64bits: boolean): void;
  2702. }
  2703. }
  2704. declare module BABYLON {
  2705. /**
  2706. * Class representing a vector containing 2 coordinates
  2707. */
  2708. export class Vector2 {
  2709. /** defines the first coordinate */
  2710. x: number;
  2711. /** defines the second coordinate */
  2712. y: number;
  2713. /**
  2714. * Creates a new Vector2 from the given x and y coordinates
  2715. * @param x defines the first coordinate
  2716. * @param y defines the second coordinate
  2717. */
  2718. constructor(
  2719. /** defines the first coordinate */
  2720. x?: number,
  2721. /** defines the second coordinate */
  2722. y?: number);
  2723. /**
  2724. * Gets a string with the Vector2 coordinates
  2725. * @returns a string with the Vector2 coordinates
  2726. */
  2727. toString(): string;
  2728. /**
  2729. * Gets class name
  2730. * @returns the string "Vector2"
  2731. */
  2732. getClassName(): string;
  2733. /**
  2734. * Gets current vector hash code
  2735. * @returns the Vector2 hash code as a number
  2736. */
  2737. getHashCode(): number;
  2738. /**
  2739. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2740. * @param array defines the source array
  2741. * @param index defines the offset in source array
  2742. * @returns the current Vector2
  2743. */
  2744. toArray(array: FloatArray, index?: number): Vector2;
  2745. /**
  2746. * Update the current vector from an array
  2747. * @param array defines the destination array
  2748. * @param index defines the offset in the destination array
  2749. * @returns the current Vector3
  2750. */
  2751. fromArray(array: FloatArray, index?: number): Vector2;
  2752. /**
  2753. * Copy the current vector to an array
  2754. * @returns a new array with 2 elements: the Vector2 coordinates.
  2755. */
  2756. asArray(): number[];
  2757. /**
  2758. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2759. * @param source defines the source Vector2
  2760. * @returns the current updated Vector2
  2761. */
  2762. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2763. /**
  2764. * Sets the Vector2 coordinates with the given floats
  2765. * @param x defines the first coordinate
  2766. * @param y defines the second coordinate
  2767. * @returns the current updated Vector2
  2768. */
  2769. copyFromFloats(x: number, y: number): Vector2;
  2770. /**
  2771. * Sets the Vector2 coordinates with the given floats
  2772. * @param x defines the first coordinate
  2773. * @param y defines the second coordinate
  2774. * @returns the current updated Vector2
  2775. */
  2776. set(x: number, y: number): Vector2;
  2777. /**
  2778. * Add another vector with the current one
  2779. * @param otherVector defines the other vector
  2780. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2781. */
  2782. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2783. /**
  2784. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2785. * @param otherVector defines the other vector
  2786. * @param result defines the target vector
  2787. * @returns the unmodified current Vector2
  2788. */
  2789. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2790. /**
  2791. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2792. * @param otherVector defines the other vector
  2793. * @returns the current updated Vector2
  2794. */
  2795. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2796. /**
  2797. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2798. * @param otherVector defines the other vector
  2799. * @returns a new Vector2
  2800. */
  2801. addVector3(otherVector: Vector3): Vector2;
  2802. /**
  2803. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2804. * @param otherVector defines the other vector
  2805. * @returns a new Vector2
  2806. */
  2807. subtract(otherVector: Vector2): Vector2;
  2808. /**
  2809. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2810. * @param otherVector defines the other vector
  2811. * @param result defines the target vector
  2812. * @returns the unmodified current Vector2
  2813. */
  2814. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2815. /**
  2816. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2817. * @param otherVector defines the other vector
  2818. * @returns the current updated Vector2
  2819. */
  2820. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2821. /**
  2822. * Multiplies in place the current Vector2 coordinates by the given ones
  2823. * @param otherVector defines the other vector
  2824. * @returns the current updated Vector2
  2825. */
  2826. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2827. /**
  2828. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2829. * @param otherVector defines the other vector
  2830. * @returns a new Vector2
  2831. */
  2832. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2833. /**
  2834. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2835. * @param otherVector defines the other vector
  2836. * @param result defines the target vector
  2837. * @returns the unmodified current Vector2
  2838. */
  2839. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2840. /**
  2841. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2842. * @param x defines the first coordinate
  2843. * @param y defines the second coordinate
  2844. * @returns a new Vector2
  2845. */
  2846. multiplyByFloats(x: number, y: number): Vector2;
  2847. /**
  2848. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2849. * @param otherVector defines the other vector
  2850. * @returns a new Vector2
  2851. */
  2852. divide(otherVector: Vector2): Vector2;
  2853. /**
  2854. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2855. * @param otherVector defines the other vector
  2856. * @param result defines the target vector
  2857. * @returns the unmodified current Vector2
  2858. */
  2859. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2860. /**
  2861. * Divides the current Vector2 coordinates by the given ones
  2862. * @param otherVector defines the other vector
  2863. * @returns the current updated Vector2
  2864. */
  2865. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2866. /**
  2867. * Gets a new Vector2 with current Vector2 negated coordinates
  2868. * @returns a new Vector2
  2869. */
  2870. negate(): Vector2;
  2871. /**
  2872. * Negate this vector in place
  2873. * @returns this
  2874. */
  2875. negateInPlace(): Vector2;
  2876. /**
  2877. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2878. * @param result defines the Vector3 object where to store the result
  2879. * @returns the current Vector2
  2880. */
  2881. negateToRef(result: Vector2): Vector2;
  2882. /**
  2883. * Multiply the Vector2 coordinates by scale
  2884. * @param scale defines the scaling factor
  2885. * @returns the current updated Vector2
  2886. */
  2887. scaleInPlace(scale: number): Vector2;
  2888. /**
  2889. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2890. * @param scale defines the scaling factor
  2891. * @returns a new Vector2
  2892. */
  2893. scale(scale: number): Vector2;
  2894. /**
  2895. * Scale the current Vector2 values by a factor to a given Vector2
  2896. * @param scale defines the scale factor
  2897. * @param result defines the Vector2 object where to store the result
  2898. * @returns the unmodified current Vector2
  2899. */
  2900. scaleToRef(scale: number, result: Vector2): Vector2;
  2901. /**
  2902. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2903. * @param scale defines the scale factor
  2904. * @param result defines the Vector2 object where to store the result
  2905. * @returns the unmodified current Vector2
  2906. */
  2907. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2908. /**
  2909. * Gets a boolean if two vectors are equals
  2910. * @param otherVector defines the other vector
  2911. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2912. */
  2913. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2914. /**
  2915. * Gets a boolean if two vectors are equals (using an epsilon value)
  2916. * @param otherVector defines the other vector
  2917. * @param epsilon defines the minimal distance to consider equality
  2918. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2919. */
  2920. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2921. /**
  2922. * Gets a new Vector2 from current Vector2 floored values
  2923. * @returns a new Vector2
  2924. */
  2925. floor(): Vector2;
  2926. /**
  2927. * Gets a new Vector2 from current Vector2 floored values
  2928. * @returns a new Vector2
  2929. */
  2930. fract(): Vector2;
  2931. /**
  2932. * Gets the length of the vector
  2933. * @returns the vector length (float)
  2934. */
  2935. length(): number;
  2936. /**
  2937. * Gets the vector squared length
  2938. * @returns the vector squared length (float)
  2939. */
  2940. lengthSquared(): number;
  2941. /**
  2942. * Normalize the vector
  2943. * @returns the current updated Vector2
  2944. */
  2945. normalize(): Vector2;
  2946. /**
  2947. * Gets a new Vector2 copied from the Vector2
  2948. * @returns a new Vector2
  2949. */
  2950. clone(): Vector2;
  2951. /**
  2952. * Gets a new Vector2(0, 0)
  2953. * @returns a new Vector2
  2954. */
  2955. static Zero(): Vector2;
  2956. /**
  2957. * Gets a new Vector2(1, 1)
  2958. * @returns a new Vector2
  2959. */
  2960. static One(): Vector2;
  2961. /**
  2962. * Gets a new Vector2 set from the given index element of the given array
  2963. * @param array defines the data source
  2964. * @param offset defines the offset in the data source
  2965. * @returns a new Vector2
  2966. */
  2967. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2968. /**
  2969. * Sets "result" from the given index element of the given array
  2970. * @param array defines the data source
  2971. * @param offset defines the offset in the data source
  2972. * @param result defines the target vector
  2973. */
  2974. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2975. /**
  2976. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2977. * @param value1 defines 1st point of control
  2978. * @param value2 defines 2nd point of control
  2979. * @param value3 defines 3rd point of control
  2980. * @param value4 defines 4th point of control
  2981. * @param amount defines the interpolation factor
  2982. * @returns a new Vector2
  2983. */
  2984. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2985. /**
  2986. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2987. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2988. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2989. * @param value defines the value to clamp
  2990. * @param min defines the lower limit
  2991. * @param max defines the upper limit
  2992. * @returns a new Vector2
  2993. */
  2994. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2995. /**
  2996. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2997. * @param value1 defines the 1st control point
  2998. * @param tangent1 defines the outgoing tangent
  2999. * @param value2 defines the 2nd control point
  3000. * @param tangent2 defines the incoming tangent
  3001. * @param amount defines the interpolation factor
  3002. * @returns a new Vector2
  3003. */
  3004. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  3005. /**
  3006. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  3007. * @param start defines the start vector
  3008. * @param end defines the end vector
  3009. * @param amount defines the interpolation factor
  3010. * @returns a new Vector2
  3011. */
  3012. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  3013. /**
  3014. * Gets the dot product of the vector "left" and the vector "right"
  3015. * @param left defines first vector
  3016. * @param right defines second vector
  3017. * @returns the dot product (float)
  3018. */
  3019. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  3020. /**
  3021. * Returns a new Vector2 equal to the normalized given vector
  3022. * @param vector defines the vector to normalize
  3023. * @returns a new Vector2
  3024. */
  3025. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  3026. /**
  3027. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  3028. * @param left defines 1st vector
  3029. * @param right defines 2nd vector
  3030. * @returns a new Vector2
  3031. */
  3032. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3033. /**
  3034. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  3035. * @param left defines 1st vector
  3036. * @param right defines 2nd vector
  3037. * @returns a new Vector2
  3038. */
  3039. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3040. /**
  3041. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  3042. * @param vector defines the vector to transform
  3043. * @param transformation defines the matrix to apply
  3044. * @returns a new Vector2
  3045. */
  3046. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  3047. /**
  3048. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  3049. * @param vector defines the vector to transform
  3050. * @param transformation defines the matrix to apply
  3051. * @param result defines the target vector
  3052. */
  3053. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  3054. /**
  3055. * Determines if a given vector is included in a triangle
  3056. * @param p defines the vector to test
  3057. * @param p0 defines 1st triangle point
  3058. * @param p1 defines 2nd triangle point
  3059. * @param p2 defines 3rd triangle point
  3060. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  3061. */
  3062. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  3063. /**
  3064. * Gets the distance between the vectors "value1" and "value2"
  3065. * @param value1 defines first vector
  3066. * @param value2 defines second vector
  3067. * @returns the distance between vectors
  3068. */
  3069. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3070. /**
  3071. * Returns the squared distance between the vectors "value1" and "value2"
  3072. * @param value1 defines first vector
  3073. * @param value2 defines second vector
  3074. * @returns the squared distance between vectors
  3075. */
  3076. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3077. /**
  3078. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  3079. * @param value1 defines first vector
  3080. * @param value2 defines second vector
  3081. * @returns a new Vector2
  3082. */
  3083. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  3084. /**
  3085. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3086. * @param value1 defines first vector
  3087. * @param value2 defines second vector
  3088. * @param ref defines third vector
  3089. * @returns ref
  3090. */
  3091. static CenterToRef(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, ref: DeepImmutable<Vector2>): Vector2;
  3092. /**
  3093. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  3094. * @param p defines the middle point
  3095. * @param segA defines one point of the segment
  3096. * @param segB defines the other point of the segment
  3097. * @returns the shortest distance
  3098. */
  3099. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  3100. }
  3101. /**
  3102. * Class used to store (x,y,z) vector representation
  3103. * A Vector3 is the main object used in 3D geometry
  3104. * It can represent etiher the coordinates of a point the space, either a direction
  3105. * Reminder: js uses a left handed forward facing system
  3106. */
  3107. export class Vector3 {
  3108. private static _UpReadOnly;
  3109. private static _ZeroReadOnly;
  3110. /** @hidden */
  3111. _x: number;
  3112. /** @hidden */
  3113. _y: number;
  3114. /** @hidden */
  3115. _z: number;
  3116. /** @hidden */
  3117. _isDirty: boolean;
  3118. /** Gets or sets the x coordinate */
  3119. get x(): number;
  3120. set x(value: number);
  3121. /** Gets or sets the y coordinate */
  3122. get y(): number;
  3123. set y(value: number);
  3124. /** Gets or sets the z coordinate */
  3125. get z(): number;
  3126. set z(value: number);
  3127. /**
  3128. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  3129. * @param x defines the first coordinates (on X axis)
  3130. * @param y defines the second coordinates (on Y axis)
  3131. * @param z defines the third coordinates (on Z axis)
  3132. */
  3133. constructor(x?: number, y?: number, z?: number);
  3134. /**
  3135. * Creates a string representation of the Vector3
  3136. * @returns a string with the Vector3 coordinates.
  3137. */
  3138. toString(): string;
  3139. /**
  3140. * Gets the class name
  3141. * @returns the string "Vector3"
  3142. */
  3143. getClassName(): string;
  3144. /**
  3145. * Creates the Vector3 hash code
  3146. * @returns a number which tends to be unique between Vector3 instances
  3147. */
  3148. getHashCode(): number;
  3149. /**
  3150. * Creates an array containing three elements : the coordinates of the Vector3
  3151. * @returns a new array of numbers
  3152. */
  3153. asArray(): number[];
  3154. /**
  3155. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  3156. * @param array defines the destination array
  3157. * @param index defines the offset in the destination array
  3158. * @returns the current Vector3
  3159. */
  3160. toArray(array: FloatArray, index?: number): Vector3;
  3161. /**
  3162. * Update the current vector from an array
  3163. * @param array defines the destination array
  3164. * @param index defines the offset in the destination array
  3165. * @returns the current Vector3
  3166. */
  3167. fromArray(array: FloatArray, index?: number): Vector3;
  3168. /**
  3169. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  3170. * @returns a new Quaternion object, computed from the Vector3 coordinates
  3171. */
  3172. toQuaternion(): Quaternion;
  3173. /**
  3174. * Adds the given vector to the current Vector3
  3175. * @param otherVector defines the second operand
  3176. * @returns the current updated Vector3
  3177. */
  3178. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3179. /**
  3180. * Adds the given coordinates to the current Vector3
  3181. * @param x defines the x coordinate of the operand
  3182. * @param y defines the y coordinate of the operand
  3183. * @param z defines the z coordinate of the operand
  3184. * @returns the current updated Vector3
  3185. */
  3186. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3187. /**
  3188. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  3189. * @param otherVector defines the second operand
  3190. * @returns the resulting Vector3
  3191. */
  3192. add(otherVector: DeepImmutable<Vector3>): Vector3;
  3193. /**
  3194. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  3195. * @param otherVector defines the second operand
  3196. * @param result defines the Vector3 object where to store the result
  3197. * @returns the current Vector3
  3198. */
  3199. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3200. /**
  3201. * Subtract the given vector from the current Vector3
  3202. * @param otherVector defines the second operand
  3203. * @returns the current updated Vector3
  3204. */
  3205. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3206. /**
  3207. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  3208. * @param otherVector defines the second operand
  3209. * @returns the resulting Vector3
  3210. */
  3211. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  3212. /**
  3213. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  3214. * @param otherVector defines the second operand
  3215. * @param result defines the Vector3 object where to store the result
  3216. * @returns the current Vector3
  3217. */
  3218. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3219. /**
  3220. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  3221. * @param x defines the x coordinate of the operand
  3222. * @param y defines the y coordinate of the operand
  3223. * @param z defines the z coordinate of the operand
  3224. * @returns the resulting Vector3
  3225. */
  3226. subtractFromFloats(x: number, y: number, z: number): Vector3;
  3227. /**
  3228. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  3229. * @param x defines the x coordinate of the operand
  3230. * @param y defines the y coordinate of the operand
  3231. * @param z defines the z coordinate of the operand
  3232. * @param result defines the Vector3 object where to store the result
  3233. * @returns the current Vector3
  3234. */
  3235. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  3236. /**
  3237. * Gets a new Vector3 set with the current Vector3 negated coordinates
  3238. * @returns a new Vector3
  3239. */
  3240. negate(): Vector3;
  3241. /**
  3242. * Negate this vector in place
  3243. * @returns this
  3244. */
  3245. negateInPlace(): Vector3;
  3246. /**
  3247. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  3248. * @param result defines the Vector3 object where to store the result
  3249. * @returns the current Vector3
  3250. */
  3251. negateToRef(result: Vector3): Vector3;
  3252. /**
  3253. * Multiplies the Vector3 coordinates by the float "scale"
  3254. * @param scale defines the multiplier factor
  3255. * @returns the current updated Vector3
  3256. */
  3257. scaleInPlace(scale: number): Vector3;
  3258. /**
  3259. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  3260. * @param scale defines the multiplier factor
  3261. * @returns a new Vector3
  3262. */
  3263. scale(scale: number): Vector3;
  3264. /**
  3265. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  3266. * @param scale defines the multiplier factor
  3267. * @param result defines the Vector3 object where to store the result
  3268. * @returns the current Vector3
  3269. */
  3270. scaleToRef(scale: number, result: Vector3): Vector3;
  3271. /**
  3272. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  3273. * @param scale defines the scale factor
  3274. * @param result defines the Vector3 object where to store the result
  3275. * @returns the unmodified current Vector3
  3276. */
  3277. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  3278. /**
  3279. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3280. * @param origin defines the origin of the projection ray
  3281. * @param plane defines the plane to project to
  3282. * @returns the projected vector3
  3283. */
  3284. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  3285. /**
  3286. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3287. * @param origin defines the origin of the projection ray
  3288. * @param plane defines the plane to project to
  3289. * @param result defines the Vector3 where to store the result
  3290. */
  3291. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  3292. /**
  3293. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  3294. * @param otherVector defines the second operand
  3295. * @returns true if both vectors are equals
  3296. */
  3297. equals(otherVector: DeepImmutable<Vector3>): boolean;
  3298. /**
  3299. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  3300. * @param otherVector defines the second operand
  3301. * @param epsilon defines the minimal distance to define values as equals
  3302. * @returns true if both vectors are distant less than epsilon
  3303. */
  3304. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  3305. /**
  3306. * Returns true if the current Vector3 coordinates equals the given floats
  3307. * @param x defines the x coordinate of the operand
  3308. * @param y defines the y coordinate of the operand
  3309. * @param z defines the z coordinate of the operand
  3310. * @returns true if both vectors are equals
  3311. */
  3312. equalsToFloats(x: number, y: number, z: number): boolean;
  3313. /**
  3314. * Multiplies the current Vector3 coordinates by the given ones
  3315. * @param otherVector defines the second operand
  3316. * @returns the current updated Vector3
  3317. */
  3318. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3319. /**
  3320. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  3321. * @param otherVector defines the second operand
  3322. * @returns the new Vector3
  3323. */
  3324. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  3325. /**
  3326. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  3327. * @param otherVector defines the second operand
  3328. * @param result defines the Vector3 object where to store the result
  3329. * @returns the current Vector3
  3330. */
  3331. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3332. /**
  3333. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  3334. * @param x defines the x coordinate of the operand
  3335. * @param y defines the y coordinate of the operand
  3336. * @param z defines the z coordinate of the operand
  3337. * @returns the new Vector3
  3338. */
  3339. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3340. /**
  3341. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  3342. * @param otherVector defines the second operand
  3343. * @returns the new Vector3
  3344. */
  3345. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  3346. /**
  3347. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  3348. * @param otherVector defines the second operand
  3349. * @param result defines the Vector3 object where to store the result
  3350. * @returns the current Vector3
  3351. */
  3352. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3353. /**
  3354. * Divides the current Vector3 coordinates by the given ones.
  3355. * @param otherVector defines the second operand
  3356. * @returns the current updated Vector3
  3357. */
  3358. divideInPlace(otherVector: Vector3): Vector3;
  3359. /**
  3360. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  3361. * @param other defines the second operand
  3362. * @returns the current updated Vector3
  3363. */
  3364. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3365. /**
  3366. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  3367. * @param other defines the second operand
  3368. * @returns the current updated Vector3
  3369. */
  3370. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3371. /**
  3372. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  3373. * @param x defines the x coordinate of the operand
  3374. * @param y defines the y coordinate of the operand
  3375. * @param z defines the z coordinate of the operand
  3376. * @returns the current updated Vector3
  3377. */
  3378. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3379. /**
  3380. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  3381. * @param x defines the x coordinate of the operand
  3382. * @param y defines the y coordinate of the operand
  3383. * @param z defines the z coordinate of the operand
  3384. * @returns the current updated Vector3
  3385. */
  3386. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3387. /**
  3388. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  3389. * Check if is non uniform within a certain amount of decimal places to account for this
  3390. * @param epsilon the amount the values can differ
  3391. * @returns if the the vector is non uniform to a certain number of decimal places
  3392. */
  3393. isNonUniformWithinEpsilon(epsilon: number): boolean;
  3394. /**
  3395. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  3396. */
  3397. get isNonUniform(): boolean;
  3398. /**
  3399. * Gets a new Vector3 from current Vector3 floored values
  3400. * @returns a new Vector3
  3401. */
  3402. floor(): Vector3;
  3403. /**
  3404. * Gets a new Vector3 from current Vector3 floored values
  3405. * @returns a new Vector3
  3406. */
  3407. fract(): Vector3;
  3408. /**
  3409. * Gets the length of the Vector3
  3410. * @returns the length of the Vector3
  3411. */
  3412. length(): number;
  3413. /**
  3414. * Gets the squared length of the Vector3
  3415. * @returns squared length of the Vector3
  3416. */
  3417. lengthSquared(): number;
  3418. /**
  3419. * Normalize the current Vector3.
  3420. * Please note that this is an in place operation.
  3421. * @returns the current updated Vector3
  3422. */
  3423. normalize(): Vector3;
  3424. /**
  3425. * Reorders the x y z properties of the vector in place
  3426. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  3427. * @returns the current updated vector
  3428. */
  3429. reorderInPlace(order: string): this;
  3430. /**
  3431. * Rotates the vector around 0,0,0 by a quaternion
  3432. * @param quaternion the rotation quaternion
  3433. * @param result vector to store the result
  3434. * @returns the resulting vector
  3435. */
  3436. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  3437. /**
  3438. * Rotates a vector around a given point
  3439. * @param quaternion the rotation quaternion
  3440. * @param point the point to rotate around
  3441. * @param result vector to store the result
  3442. * @returns the resulting vector
  3443. */
  3444. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  3445. /**
  3446. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  3447. * The cross product is then orthogonal to both current and "other"
  3448. * @param other defines the right operand
  3449. * @returns the cross product
  3450. */
  3451. cross(other: Vector3): Vector3;
  3452. /**
  3453. * Normalize the current Vector3 with the given input length.
  3454. * Please note that this is an in place operation.
  3455. * @param len the length of the vector
  3456. * @returns the current updated Vector3
  3457. */
  3458. normalizeFromLength(len: number): Vector3;
  3459. /**
  3460. * Normalize the current Vector3 to a new vector
  3461. * @returns the new Vector3
  3462. */
  3463. normalizeToNew(): Vector3;
  3464. /**
  3465. * Normalize the current Vector3 to the reference
  3466. * @param reference define the Vector3 to update
  3467. * @returns the updated Vector3
  3468. */
  3469. normalizeToRef(reference: Vector3): Vector3;
  3470. /**
  3471. * Creates a new Vector3 copied from the current Vector3
  3472. * @returns the new Vector3
  3473. */
  3474. clone(): Vector3;
  3475. /**
  3476. * Copies the given vector coordinates to the current Vector3 ones
  3477. * @param source defines the source Vector3
  3478. * @returns the current updated Vector3
  3479. */
  3480. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  3481. /**
  3482. * Copies the given floats to the current Vector3 coordinates
  3483. * @param x defines the x coordinate of the operand
  3484. * @param y defines the y coordinate of the operand
  3485. * @param z defines the z coordinate of the operand
  3486. * @returns the current updated Vector3
  3487. */
  3488. copyFromFloats(x: number, y: number, z: number): Vector3;
  3489. /**
  3490. * Copies the given floats to the current Vector3 coordinates
  3491. * @param x defines the x coordinate of the operand
  3492. * @param y defines the y coordinate of the operand
  3493. * @param z defines the z coordinate of the operand
  3494. * @returns the current updated Vector3
  3495. */
  3496. set(x: number, y: number, z: number): Vector3;
  3497. /**
  3498. * Copies the given float to the current Vector3 coordinates
  3499. * @param v defines the x, y and z coordinates of the operand
  3500. * @returns the current updated Vector3
  3501. */
  3502. setAll(v: number): Vector3;
  3503. /**
  3504. * Get the clip factor between two vectors
  3505. * @param vector0 defines the first operand
  3506. * @param vector1 defines the second operand
  3507. * @param axis defines the axis to use
  3508. * @param size defines the size along the axis
  3509. * @returns the clip factor
  3510. */
  3511. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  3512. /**
  3513. * Get angle between two vectors
  3514. * @param vector0 angle between vector0 and vector1
  3515. * @param vector1 angle between vector0 and vector1
  3516. * @param normal direction of the normal
  3517. * @return the angle between vector0 and vector1
  3518. */
  3519. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  3520. /**
  3521. * Returns a new Vector3 set from the index "offset" of the given array
  3522. * @param array defines the source array
  3523. * @param offset defines the offset in the source array
  3524. * @returns the new Vector3
  3525. */
  3526. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  3527. /**
  3528. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  3529. * @param array defines the source array
  3530. * @param offset defines the offset in the source array
  3531. * @returns the new Vector3
  3532. * @deprecated Please use FromArray instead.
  3533. */
  3534. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  3535. /**
  3536. * Sets the given vector "result" with the element values from the index "offset" of the given array
  3537. * @param array defines the source array
  3538. * @param offset defines the offset in the source array
  3539. * @param result defines the Vector3 where to store the result
  3540. */
  3541. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  3542. /**
  3543. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  3544. * @param array defines the source array
  3545. * @param offset defines the offset in the source array
  3546. * @param result defines the Vector3 where to store the result
  3547. * @deprecated Please use FromArrayToRef instead.
  3548. */
  3549. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  3550. /**
  3551. * Sets the given vector "result" with the given floats.
  3552. * @param x defines the x coordinate of the source
  3553. * @param y defines the y coordinate of the source
  3554. * @param z defines the z coordinate of the source
  3555. * @param result defines the Vector3 where to store the result
  3556. */
  3557. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3558. /**
  3559. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  3560. * @returns a new empty Vector3
  3561. */
  3562. static Zero(): Vector3;
  3563. /**
  3564. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  3565. * @returns a new unit Vector3
  3566. */
  3567. static One(): Vector3;
  3568. /**
  3569. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  3570. * @returns a new up Vector3
  3571. */
  3572. static Up(): Vector3;
  3573. /**
  3574. * Gets a up Vector3 that must not be updated
  3575. */
  3576. static get UpReadOnly(): DeepImmutable<Vector3>;
  3577. /**
  3578. * Gets a zero Vector3 that must not be updated
  3579. */
  3580. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  3581. /**
  3582. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  3583. * @returns a new down Vector3
  3584. */
  3585. static Down(): Vector3;
  3586. /**
  3587. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  3588. * @param rightHandedSystem is the scene right-handed (negative z)
  3589. * @returns a new forward Vector3
  3590. */
  3591. static Forward(rightHandedSystem?: boolean): Vector3;
  3592. /**
  3593. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3594. * @param rightHandedSystem is the scene right-handed (negative-z)
  3595. * @returns a new forward Vector3
  3596. */
  3597. static Backward(rightHandedSystem?: boolean): Vector3;
  3598. /**
  3599. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3600. * @returns a new right Vector3
  3601. */
  3602. static Right(): Vector3;
  3603. /**
  3604. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3605. * @returns a new left Vector3
  3606. */
  3607. static Left(): Vector3;
  3608. /**
  3609. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3610. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3611. * @param vector defines the Vector3 to transform
  3612. * @param transformation defines the transformation matrix
  3613. * @returns the transformed Vector3
  3614. */
  3615. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3616. /**
  3617. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3618. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3619. * @param vector defines the Vector3 to transform
  3620. * @param transformation defines the transformation matrix
  3621. * @param result defines the Vector3 where to store the result
  3622. */
  3623. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3624. /**
  3625. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3626. * This method computes tranformed coordinates only, not transformed direction vectors
  3627. * @param x define the x coordinate of the source vector
  3628. * @param y define the y coordinate of the source vector
  3629. * @param z define the z coordinate of the source vector
  3630. * @param transformation defines the transformation matrix
  3631. * @param result defines the Vector3 where to store the result
  3632. */
  3633. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3634. /**
  3635. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3636. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3637. * @param vector defines the Vector3 to transform
  3638. * @param transformation defines the transformation matrix
  3639. * @returns the new Vector3
  3640. */
  3641. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3642. /**
  3643. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3644. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3645. * @param vector defines the Vector3 to transform
  3646. * @param transformation defines the transformation matrix
  3647. * @param result defines the Vector3 where to store the result
  3648. */
  3649. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3650. /**
  3651. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3652. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3653. * @param x define the x coordinate of the source vector
  3654. * @param y define the y coordinate of the source vector
  3655. * @param z define the z coordinate of the source vector
  3656. * @param transformation defines the transformation matrix
  3657. * @param result defines the Vector3 where to store the result
  3658. */
  3659. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3660. /**
  3661. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3662. * @param value1 defines the first control point
  3663. * @param value2 defines the second control point
  3664. * @param value3 defines the third control point
  3665. * @param value4 defines the fourth control point
  3666. * @param amount defines the amount on the spline to use
  3667. * @returns the new Vector3
  3668. */
  3669. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3670. /**
  3671. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3672. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3673. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3674. * @param value defines the current value
  3675. * @param min defines the lower range value
  3676. * @param max defines the upper range value
  3677. * @returns the new Vector3
  3678. */
  3679. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3680. /**
  3681. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3682. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3683. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3684. * @param value defines the current value
  3685. * @param min defines the lower range value
  3686. * @param max defines the upper range value
  3687. * @param result defines the Vector3 where to store the result
  3688. */
  3689. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3690. /**
  3691. * Checks if a given vector is inside a specific range
  3692. * @param v defines the vector to test
  3693. * @param min defines the minimum range
  3694. * @param max defines the maximum range
  3695. */
  3696. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3697. /**
  3698. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3699. * @param value1 defines the first control point
  3700. * @param tangent1 defines the first tangent vector
  3701. * @param value2 defines the second control point
  3702. * @param tangent2 defines the second tangent vector
  3703. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3704. * @returns the new Vector3
  3705. */
  3706. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3707. /**
  3708. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3709. * @param start defines the start value
  3710. * @param end defines the end value
  3711. * @param amount max defines amount between both (between 0 and 1)
  3712. * @returns the new Vector3
  3713. */
  3714. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3715. /**
  3716. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3717. * @param start defines the start value
  3718. * @param end defines the end value
  3719. * @param amount max defines amount between both (between 0 and 1)
  3720. * @param result defines the Vector3 where to store the result
  3721. */
  3722. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3723. /**
  3724. * Returns the dot product (float) between the vectors "left" and "right"
  3725. * @param left defines the left operand
  3726. * @param right defines the right operand
  3727. * @returns the dot product
  3728. */
  3729. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3730. /**
  3731. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3732. * The cross product is then orthogonal to both "left" and "right"
  3733. * @param left defines the left operand
  3734. * @param right defines the right operand
  3735. * @returns the cross product
  3736. */
  3737. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3738. /**
  3739. * Sets the given vector "result" with the cross product of "left" and "right"
  3740. * The cross product is then orthogonal to both "left" and "right"
  3741. * @param left defines the left operand
  3742. * @param right defines the right operand
  3743. * @param result defines the Vector3 where to store the result
  3744. */
  3745. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3746. /**
  3747. * Returns a new Vector3 as the normalization of the given vector
  3748. * @param vector defines the Vector3 to normalize
  3749. * @returns the new Vector3
  3750. */
  3751. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3752. /**
  3753. * Sets the given vector "result" with the normalization of the given first vector
  3754. * @param vector defines the Vector3 to normalize
  3755. * @param result defines the Vector3 where to store the result
  3756. */
  3757. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3758. /**
  3759. * Project a Vector3 onto screen space
  3760. * @param vector defines the Vector3 to project
  3761. * @param world defines the world matrix to use
  3762. * @param transform defines the transform (view x projection) matrix to use
  3763. * @param viewport defines the screen viewport to use
  3764. * @returns the new Vector3
  3765. */
  3766. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3767. /**
  3768. * Project a Vector3 onto screen space to reference
  3769. * @param vector defines the Vector3 to project
  3770. * @param world defines the world matrix to use
  3771. * @param transform defines the transform (view x projection) matrix to use
  3772. * @param viewport defines the screen viewport to use
  3773. * @param result the vector in which the screen space will be stored
  3774. * @returns the new Vector3
  3775. */
  3776. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3777. /** @hidden */
  3778. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3779. /**
  3780. * Unproject from screen space to object space
  3781. * @param source defines the screen space Vector3 to use
  3782. * @param viewportWidth defines the current width of the viewport
  3783. * @param viewportHeight defines the current height of the viewport
  3784. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3785. * @param transform defines the transform (view x projection) matrix to use
  3786. * @returns the new Vector3
  3787. */
  3788. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3789. /**
  3790. * Unproject from screen space to object space
  3791. * @param source defines the screen space Vector3 to use
  3792. * @param viewportWidth defines the current width of the viewport
  3793. * @param viewportHeight defines the current height of the viewport
  3794. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3795. * @param view defines the view matrix to use
  3796. * @param projection defines the projection matrix to use
  3797. * @returns the new Vector3
  3798. */
  3799. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3800. /**
  3801. * Unproject from screen space to object space
  3802. * @param source defines the screen space Vector3 to use
  3803. * @param viewportWidth defines the current width of the viewport
  3804. * @param viewportHeight defines the current height of the viewport
  3805. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3806. * @param view defines the view matrix to use
  3807. * @param projection defines the projection matrix to use
  3808. * @param result defines the Vector3 where to store the result
  3809. */
  3810. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3811. /**
  3812. * Unproject from screen space to object space
  3813. * @param sourceX defines the screen space x coordinate to use
  3814. * @param sourceY defines the screen space y coordinate to use
  3815. * @param sourceZ defines the screen space z coordinate to use
  3816. * @param viewportWidth defines the current width of the viewport
  3817. * @param viewportHeight defines the current height of the viewport
  3818. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3819. * @param view defines the view matrix to use
  3820. * @param projection defines the projection matrix to use
  3821. * @param result defines the Vector3 where to store the result
  3822. */
  3823. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3824. /**
  3825. * Gets the minimal coordinate values between two Vector3
  3826. * @param left defines the first operand
  3827. * @param right defines the second operand
  3828. * @returns the new Vector3
  3829. */
  3830. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3831. /**
  3832. * Gets the maximal coordinate values between two Vector3
  3833. * @param left defines the first operand
  3834. * @param right defines the second operand
  3835. * @returns the new Vector3
  3836. */
  3837. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3838. /**
  3839. * Returns the distance between the vectors "value1" and "value2"
  3840. * @param value1 defines the first operand
  3841. * @param value2 defines the second operand
  3842. * @returns the distance
  3843. */
  3844. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3845. /**
  3846. * Returns the squared distance between the vectors "value1" and "value2"
  3847. * @param value1 defines the first operand
  3848. * @param value2 defines the second operand
  3849. * @returns the squared distance
  3850. */
  3851. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3852. /**
  3853. * Returns a new Vector3 located at the center between "value1" and "value2"
  3854. * @param value1 defines the first operand
  3855. * @param value2 defines the second operand
  3856. * @returns the new Vector3
  3857. */
  3858. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3859. /**
  3860. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3861. * @param value1 defines first vector
  3862. * @param value2 defines second vector
  3863. * @param ref defines third vector
  3864. * @returns ref
  3865. */
  3866. static CenterToRef(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, ref: DeepImmutable<Vector3>): Vector3;
  3867. /**
  3868. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3869. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3870. * to something in order to rotate it from its local system to the given target system
  3871. * Note: axis1, axis2 and axis3 are normalized during this operation
  3872. * @param axis1 defines the first axis
  3873. * @param axis2 defines the second axis
  3874. * @param axis3 defines the third axis
  3875. * @returns a new Vector3
  3876. */
  3877. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3878. /**
  3879. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3880. * @param axis1 defines the first axis
  3881. * @param axis2 defines the second axis
  3882. * @param axis3 defines the third axis
  3883. * @param ref defines the Vector3 where to store the result
  3884. */
  3885. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3886. }
  3887. /**
  3888. * Vector4 class created for EulerAngle class conversion to Quaternion
  3889. */
  3890. export class Vector4 {
  3891. /** x value of the vector */
  3892. x: number;
  3893. /** y value of the vector */
  3894. y: number;
  3895. /** z value of the vector */
  3896. z: number;
  3897. /** w value of the vector */
  3898. w: number;
  3899. /**
  3900. * Creates a Vector4 object from the given floats.
  3901. * @param x x value of the vector
  3902. * @param y y value of the vector
  3903. * @param z z value of the vector
  3904. * @param w w value of the vector
  3905. */
  3906. constructor(
  3907. /** x value of the vector */
  3908. x: number,
  3909. /** y value of the vector */
  3910. y: number,
  3911. /** z value of the vector */
  3912. z: number,
  3913. /** w value of the vector */
  3914. w: number);
  3915. /**
  3916. * Returns the string with the Vector4 coordinates.
  3917. * @returns a string containing all the vector values
  3918. */
  3919. toString(): string;
  3920. /**
  3921. * Returns the string "Vector4".
  3922. * @returns "Vector4"
  3923. */
  3924. getClassName(): string;
  3925. /**
  3926. * Returns the Vector4 hash code.
  3927. * @returns a unique hash code
  3928. */
  3929. getHashCode(): number;
  3930. /**
  3931. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3932. * @returns the resulting array
  3933. */
  3934. asArray(): number[];
  3935. /**
  3936. * Populates the given array from the given index with the Vector4 coordinates.
  3937. * @param array array to populate
  3938. * @param index index of the array to start at (default: 0)
  3939. * @returns the Vector4.
  3940. */
  3941. toArray(array: FloatArray, index?: number): Vector4;
  3942. /**
  3943. * Update the current vector from an array
  3944. * @param array defines the destination array
  3945. * @param index defines the offset in the destination array
  3946. * @returns the current Vector3
  3947. */
  3948. fromArray(array: FloatArray, index?: number): Vector4;
  3949. /**
  3950. * Adds the given vector to the current Vector4.
  3951. * @param otherVector the vector to add
  3952. * @returns the updated Vector4.
  3953. */
  3954. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3955. /**
  3956. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3957. * @param otherVector the vector to add
  3958. * @returns the resulting vector
  3959. */
  3960. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3961. /**
  3962. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3963. * @param otherVector the vector to add
  3964. * @param result the vector to store the result
  3965. * @returns the current Vector4.
  3966. */
  3967. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3968. /**
  3969. * Subtract in place the given vector from the current Vector4.
  3970. * @param otherVector the vector to subtract
  3971. * @returns the updated Vector4.
  3972. */
  3973. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3974. /**
  3975. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3976. * @param otherVector the vector to add
  3977. * @returns the new vector with the result
  3978. */
  3979. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3980. /**
  3981. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3982. * @param otherVector the vector to subtract
  3983. * @param result the vector to store the result
  3984. * @returns the current Vector4.
  3985. */
  3986. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3987. /**
  3988. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3989. */
  3990. /**
  3991. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3992. * @param x value to subtract
  3993. * @param y value to subtract
  3994. * @param z value to subtract
  3995. * @param w value to subtract
  3996. * @returns new vector containing the result
  3997. */
  3998. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3999. /**
  4000. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4001. * @param x value to subtract
  4002. * @param y value to subtract
  4003. * @param z value to subtract
  4004. * @param w value to subtract
  4005. * @param result the vector to store the result in
  4006. * @returns the current Vector4.
  4007. */
  4008. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  4009. /**
  4010. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  4011. * @returns a new vector with the negated values
  4012. */
  4013. negate(): Vector4;
  4014. /**
  4015. * Negate this vector in place
  4016. * @returns this
  4017. */
  4018. negateInPlace(): Vector4;
  4019. /**
  4020. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  4021. * @param result defines the Vector3 object where to store the result
  4022. * @returns the current Vector4
  4023. */
  4024. negateToRef(result: Vector4): Vector4;
  4025. /**
  4026. * Multiplies the current Vector4 coordinates by scale (float).
  4027. * @param scale the number to scale with
  4028. * @returns the updated Vector4.
  4029. */
  4030. scaleInPlace(scale: number): Vector4;
  4031. /**
  4032. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  4033. * @param scale the number to scale with
  4034. * @returns a new vector with the result
  4035. */
  4036. scale(scale: number): Vector4;
  4037. /**
  4038. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  4039. * @param scale the number to scale with
  4040. * @param result a vector to store the result in
  4041. * @returns the current Vector4.
  4042. */
  4043. scaleToRef(scale: number, result: Vector4): Vector4;
  4044. /**
  4045. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  4046. * @param scale defines the scale factor
  4047. * @param result defines the Vector4 object where to store the result
  4048. * @returns the unmodified current Vector4
  4049. */
  4050. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  4051. /**
  4052. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  4053. * @param otherVector the vector to compare against
  4054. * @returns true if they are equal
  4055. */
  4056. equals(otherVector: DeepImmutable<Vector4>): boolean;
  4057. /**
  4058. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  4059. * @param otherVector vector to compare against
  4060. * @param epsilon (Default: very small number)
  4061. * @returns true if they are equal
  4062. */
  4063. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  4064. /**
  4065. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  4066. * @param x x value to compare against
  4067. * @param y y value to compare against
  4068. * @param z z value to compare against
  4069. * @param w w value to compare against
  4070. * @returns true if equal
  4071. */
  4072. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  4073. /**
  4074. * Multiplies in place the current Vector4 by the given one.
  4075. * @param otherVector vector to multiple with
  4076. * @returns the updated Vector4.
  4077. */
  4078. multiplyInPlace(otherVector: Vector4): Vector4;
  4079. /**
  4080. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  4081. * @param otherVector vector to multiple with
  4082. * @returns resulting new vector
  4083. */
  4084. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  4085. /**
  4086. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  4087. * @param otherVector vector to multiple with
  4088. * @param result vector to store the result
  4089. * @returns the current Vector4.
  4090. */
  4091. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4092. /**
  4093. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  4094. * @param x x value multiply with
  4095. * @param y y value multiply with
  4096. * @param z z value multiply with
  4097. * @param w w value multiply with
  4098. * @returns resulting new vector
  4099. */
  4100. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  4101. /**
  4102. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  4103. * @param otherVector vector to devide with
  4104. * @returns resulting new vector
  4105. */
  4106. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  4107. /**
  4108. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  4109. * @param otherVector vector to devide with
  4110. * @param result vector to store the result
  4111. * @returns the current Vector4.
  4112. */
  4113. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4114. /**
  4115. * Divides the current Vector3 coordinates by the given ones.
  4116. * @param otherVector vector to devide with
  4117. * @returns the updated Vector3.
  4118. */
  4119. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  4120. /**
  4121. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  4122. * @param other defines the second operand
  4123. * @returns the current updated Vector4
  4124. */
  4125. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4126. /**
  4127. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  4128. * @param other defines the second operand
  4129. * @returns the current updated Vector4
  4130. */
  4131. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4132. /**
  4133. * Gets a new Vector4 from current Vector4 floored values
  4134. * @returns a new Vector4
  4135. */
  4136. floor(): Vector4;
  4137. /**
  4138. * Gets a new Vector4 from current Vector3 floored values
  4139. * @returns a new Vector4
  4140. */
  4141. fract(): Vector4;
  4142. /**
  4143. * Returns the Vector4 length (float).
  4144. * @returns the length
  4145. */
  4146. length(): number;
  4147. /**
  4148. * Returns the Vector4 squared length (float).
  4149. * @returns the length squared
  4150. */
  4151. lengthSquared(): number;
  4152. /**
  4153. * Normalizes in place the Vector4.
  4154. * @returns the updated Vector4.
  4155. */
  4156. normalize(): Vector4;
  4157. /**
  4158. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  4159. * @returns this converted to a new vector3
  4160. */
  4161. toVector3(): Vector3;
  4162. /**
  4163. * Returns a new Vector4 copied from the current one.
  4164. * @returns the new cloned vector
  4165. */
  4166. clone(): Vector4;
  4167. /**
  4168. * Updates the current Vector4 with the given one coordinates.
  4169. * @param source the source vector to copy from
  4170. * @returns the updated Vector4.
  4171. */
  4172. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  4173. /**
  4174. * Updates the current Vector4 coordinates with the given floats.
  4175. * @param x float to copy from
  4176. * @param y float to copy from
  4177. * @param z float to copy from
  4178. * @param w float to copy from
  4179. * @returns the updated Vector4.
  4180. */
  4181. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4182. /**
  4183. * Updates the current Vector4 coordinates with the given floats.
  4184. * @param x float to set from
  4185. * @param y float to set from
  4186. * @param z float to set from
  4187. * @param w float to set from
  4188. * @returns the updated Vector4.
  4189. */
  4190. set(x: number, y: number, z: number, w: number): Vector4;
  4191. /**
  4192. * Copies the given float to the current Vector3 coordinates
  4193. * @param v defines the x, y, z and w coordinates of the operand
  4194. * @returns the current updated Vector3
  4195. */
  4196. setAll(v: number): Vector4;
  4197. /**
  4198. * Returns a new Vector4 set from the starting index of the given array.
  4199. * @param array the array to pull values from
  4200. * @param offset the offset into the array to start at
  4201. * @returns the new vector
  4202. */
  4203. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  4204. /**
  4205. * Updates the given vector "result" from the starting index of the given array.
  4206. * @param array the array to pull values from
  4207. * @param offset the offset into the array to start at
  4208. * @param result the vector to store the result in
  4209. */
  4210. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  4211. /**
  4212. * Updates the given vector "result" from the starting index of the given Float32Array.
  4213. * @param array the array to pull values from
  4214. * @param offset the offset into the array to start at
  4215. * @param result the vector to store the result in
  4216. */
  4217. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  4218. /**
  4219. * Updates the given vector "result" coordinates from the given floats.
  4220. * @param x float to set from
  4221. * @param y float to set from
  4222. * @param z float to set from
  4223. * @param w float to set from
  4224. * @param result the vector to the floats in
  4225. */
  4226. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  4227. /**
  4228. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  4229. * @returns the new vector
  4230. */
  4231. static Zero(): Vector4;
  4232. /**
  4233. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  4234. * @returns the new vector
  4235. */
  4236. static One(): Vector4;
  4237. /**
  4238. * Returns a new normalized Vector4 from the given one.
  4239. * @param vector the vector to normalize
  4240. * @returns the vector
  4241. */
  4242. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  4243. /**
  4244. * Updates the given vector "result" from the normalization of the given one.
  4245. * @param vector the vector to normalize
  4246. * @param result the vector to store the result in
  4247. */
  4248. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  4249. /**
  4250. * Returns a vector with the minimum values from the left and right vectors
  4251. * @param left left vector to minimize
  4252. * @param right right vector to minimize
  4253. * @returns a new vector with the minimum of the left and right vector values
  4254. */
  4255. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4256. /**
  4257. * Returns a vector with the maximum values from the left and right vectors
  4258. * @param left left vector to maximize
  4259. * @param right right vector to maximize
  4260. * @returns a new vector with the maximum of the left and right vector values
  4261. */
  4262. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4263. /**
  4264. * Returns the distance (float) between the vectors "value1" and "value2".
  4265. * @param value1 value to calulate the distance between
  4266. * @param value2 value to calulate the distance between
  4267. * @return the distance between the two vectors
  4268. */
  4269. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4270. /**
  4271. * Returns the squared distance (float) between the vectors "value1" and "value2".
  4272. * @param value1 value to calulate the distance between
  4273. * @param value2 value to calulate the distance between
  4274. * @return the distance between the two vectors squared
  4275. */
  4276. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4277. /**
  4278. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  4279. * @param value1 value to calulate the center between
  4280. * @param value2 value to calulate the center between
  4281. * @return the center between the two vectors
  4282. */
  4283. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  4284. /**
  4285. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  4286. * @param value1 defines first vector
  4287. * @param value2 defines second vector
  4288. * @param ref defines third vector
  4289. * @returns ref
  4290. */
  4291. static CenterToRef(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>, ref: DeepImmutable<Vector4>): Vector4;
  4292. /**
  4293. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  4294. * This methods computes transformed normalized direction vectors only.
  4295. * @param vector the vector to transform
  4296. * @param transformation the transformation matrix to apply
  4297. * @returns the new vector
  4298. */
  4299. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  4300. /**
  4301. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  4302. * This methods computes transformed normalized direction vectors only.
  4303. * @param vector the vector to transform
  4304. * @param transformation the transformation matrix to apply
  4305. * @param result the vector to store the result in
  4306. */
  4307. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4308. /**
  4309. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  4310. * This methods computes transformed normalized direction vectors only.
  4311. * @param x value to transform
  4312. * @param y value to transform
  4313. * @param z value to transform
  4314. * @param w value to transform
  4315. * @param transformation the transformation matrix to apply
  4316. * @param result the vector to store the results in
  4317. */
  4318. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4319. /**
  4320. * Creates a new Vector4 from a Vector3
  4321. * @param source defines the source data
  4322. * @param w defines the 4th component (default is 0)
  4323. * @returns a new Vector4
  4324. */
  4325. static FromVector3(source: Vector3, w?: number): Vector4;
  4326. }
  4327. /**
  4328. * Class used to store quaternion data
  4329. * @see https://en.wikipedia.org/wiki/Quaternion
  4330. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  4331. */
  4332. export class Quaternion {
  4333. /** @hidden */
  4334. _x: number;
  4335. /** @hidden */
  4336. _y: number;
  4337. /** @hidden */
  4338. _z: number;
  4339. /** @hidden */
  4340. _w: number;
  4341. /** @hidden */
  4342. _isDirty: boolean;
  4343. /** Gets or sets the x coordinate */
  4344. get x(): number;
  4345. set x(value: number);
  4346. /** Gets or sets the y coordinate */
  4347. get y(): number;
  4348. set y(value: number);
  4349. /** Gets or sets the z coordinate */
  4350. get z(): number;
  4351. set z(value: number);
  4352. /** Gets or sets the w coordinate */
  4353. get w(): number;
  4354. set w(value: number);
  4355. /**
  4356. * Creates a new Quaternion from the given floats
  4357. * @param x defines the first component (0 by default)
  4358. * @param y defines the second component (0 by default)
  4359. * @param z defines the third component (0 by default)
  4360. * @param w defines the fourth component (1.0 by default)
  4361. */
  4362. constructor(x?: number, y?: number, z?: number, w?: number);
  4363. /**
  4364. * Gets a string representation for the current quaternion
  4365. * @returns a string with the Quaternion coordinates
  4366. */
  4367. toString(): string;
  4368. /**
  4369. * Gets the class name of the quaternion
  4370. * @returns the string "Quaternion"
  4371. */
  4372. getClassName(): string;
  4373. /**
  4374. * Gets a hash code for this quaternion
  4375. * @returns the quaternion hash code
  4376. */
  4377. getHashCode(): number;
  4378. /**
  4379. * Copy the quaternion to an array
  4380. * @returns a new array populated with 4 elements from the quaternion coordinates
  4381. */
  4382. asArray(): number[];
  4383. /**
  4384. * Check if two quaternions are equals
  4385. * @param otherQuaternion defines the second operand
  4386. * @return true if the current quaternion and the given one coordinates are strictly equals
  4387. */
  4388. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  4389. /**
  4390. * Gets a boolean if two quaternions are equals (using an epsilon value)
  4391. * @param otherQuaternion defines the other quaternion
  4392. * @param epsilon defines the minimal distance to consider equality
  4393. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  4394. */
  4395. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  4396. /**
  4397. * Clone the current quaternion
  4398. * @returns a new quaternion copied from the current one
  4399. */
  4400. clone(): Quaternion;
  4401. /**
  4402. * Copy a quaternion to the current one
  4403. * @param other defines the other quaternion
  4404. * @returns the updated current quaternion
  4405. */
  4406. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  4407. /**
  4408. * Updates the current quaternion with the given float coordinates
  4409. * @param x defines the x coordinate
  4410. * @param y defines the y coordinate
  4411. * @param z defines the z coordinate
  4412. * @param w defines the w coordinate
  4413. * @returns the updated current quaternion
  4414. */
  4415. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  4416. /**
  4417. * Updates the current quaternion from the given float coordinates
  4418. * @param x defines the x coordinate
  4419. * @param y defines the y coordinate
  4420. * @param z defines the z coordinate
  4421. * @param w defines the w coordinate
  4422. * @returns the updated current quaternion
  4423. */
  4424. set(x: number, y: number, z: number, w: number): Quaternion;
  4425. /**
  4426. * Adds two quaternions
  4427. * @param other defines the second operand
  4428. * @returns a new quaternion as the addition result of the given one and the current quaternion
  4429. */
  4430. add(other: DeepImmutable<Quaternion>): Quaternion;
  4431. /**
  4432. * Add a quaternion to the current one
  4433. * @param other defines the quaternion to add
  4434. * @returns the current quaternion
  4435. */
  4436. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  4437. /**
  4438. * Subtract two quaternions
  4439. * @param other defines the second operand
  4440. * @returns a new quaternion as the subtraction result of the given one from the current one
  4441. */
  4442. subtract(other: Quaternion): Quaternion;
  4443. /**
  4444. * Multiplies the current quaternion by a scale factor
  4445. * @param value defines the scale factor
  4446. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  4447. */
  4448. scale(value: number): Quaternion;
  4449. /**
  4450. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  4451. * @param scale defines the scale factor
  4452. * @param result defines the Quaternion object where to store the result
  4453. * @returns the unmodified current quaternion
  4454. */
  4455. scaleToRef(scale: number, result: Quaternion): Quaternion;
  4456. /**
  4457. * Multiplies in place the current quaternion by a scale factor
  4458. * @param value defines the scale factor
  4459. * @returns the current modified quaternion
  4460. */
  4461. scaleInPlace(value: number): Quaternion;
  4462. /**
  4463. * Scale the current quaternion values by a factor and add the result to a given quaternion
  4464. * @param scale defines the scale factor
  4465. * @param result defines the Quaternion object where to store the result
  4466. * @returns the unmodified current quaternion
  4467. */
  4468. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  4469. /**
  4470. * Multiplies two quaternions
  4471. * @param q1 defines the second operand
  4472. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  4473. */
  4474. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  4475. /**
  4476. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  4477. * @param q1 defines the second operand
  4478. * @param result defines the target quaternion
  4479. * @returns the current quaternion
  4480. */
  4481. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  4482. /**
  4483. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  4484. * @param q1 defines the second operand
  4485. * @returns the currentupdated quaternion
  4486. */
  4487. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  4488. /**
  4489. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  4490. * @param ref defines the target quaternion
  4491. * @returns the current quaternion
  4492. */
  4493. conjugateToRef(ref: Quaternion): Quaternion;
  4494. /**
  4495. * Conjugates in place (1-q) the current quaternion
  4496. * @returns the current updated quaternion
  4497. */
  4498. conjugateInPlace(): Quaternion;
  4499. /**
  4500. * Conjugates in place (1-q) the current quaternion
  4501. * @returns a new quaternion
  4502. */
  4503. conjugate(): Quaternion;
  4504. /**
  4505. * Gets length of current quaternion
  4506. * @returns the quaternion length (float)
  4507. */
  4508. length(): number;
  4509. /**
  4510. * Normalize in place the current quaternion
  4511. * @returns the current updated quaternion
  4512. */
  4513. normalize(): Quaternion;
  4514. /**
  4515. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  4516. * @param order is a reserved parameter and is ignored for now
  4517. * @returns a new Vector3 containing the Euler angles
  4518. */
  4519. toEulerAngles(order?: string): Vector3;
  4520. /**
  4521. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  4522. * @param result defines the vector which will be filled with the Euler angles
  4523. * @returns the current unchanged quaternion
  4524. */
  4525. toEulerAnglesToRef(result: Vector3): Quaternion;
  4526. /**
  4527. * Updates the given rotation matrix with the current quaternion values
  4528. * @param result defines the target matrix
  4529. * @returns the current unchanged quaternion
  4530. */
  4531. toRotationMatrix(result: Matrix): Quaternion;
  4532. /**
  4533. * Updates the current quaternion from the given rotation matrix values
  4534. * @param matrix defines the source matrix
  4535. * @returns the current updated quaternion
  4536. */
  4537. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4538. /**
  4539. * Creates a new quaternion from a rotation matrix
  4540. * @param matrix defines the source matrix
  4541. * @returns a new quaternion created from the given rotation matrix values
  4542. */
  4543. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4544. /**
  4545. * Updates the given quaternion with the given rotation matrix values
  4546. * @param matrix defines the source matrix
  4547. * @param result defines the target quaternion
  4548. */
  4549. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  4550. /**
  4551. * Returns the dot product (float) between the quaternions "left" and "right"
  4552. * @param left defines the left operand
  4553. * @param right defines the right operand
  4554. * @returns the dot product
  4555. */
  4556. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  4557. /**
  4558. * Checks if the two quaternions are close to each other
  4559. * @param quat0 defines the first quaternion to check
  4560. * @param quat1 defines the second quaternion to check
  4561. * @returns true if the two quaternions are close to each other
  4562. */
  4563. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  4564. /**
  4565. * Creates an empty quaternion
  4566. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  4567. */
  4568. static Zero(): Quaternion;
  4569. /**
  4570. * Inverse a given quaternion
  4571. * @param q defines the source quaternion
  4572. * @returns a new quaternion as the inverted current quaternion
  4573. */
  4574. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  4575. /**
  4576. * Inverse a given quaternion
  4577. * @param q defines the source quaternion
  4578. * @param result the quaternion the result will be stored in
  4579. * @returns the result quaternion
  4580. */
  4581. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  4582. /**
  4583. * Creates an identity quaternion
  4584. * @returns the identity quaternion
  4585. */
  4586. static Identity(): Quaternion;
  4587. /**
  4588. * Gets a boolean indicating if the given quaternion is identity
  4589. * @param quaternion defines the quaternion to check
  4590. * @returns true if the quaternion is identity
  4591. */
  4592. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  4593. /**
  4594. * Creates a quaternion from a rotation around an axis
  4595. * @param axis defines the axis to use
  4596. * @param angle defines the angle to use
  4597. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  4598. */
  4599. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  4600. /**
  4601. * Creates a rotation around an axis and stores it into the given quaternion
  4602. * @param axis defines the axis to use
  4603. * @param angle defines the angle to use
  4604. * @param result defines the target quaternion
  4605. * @returns the target quaternion
  4606. */
  4607. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4608. /**
  4609. * Creates a new quaternion from data stored into an array
  4610. * @param array defines the data source
  4611. * @param offset defines the offset in the source array where the data starts
  4612. * @returns a new quaternion
  4613. */
  4614. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4615. /**
  4616. * Updates the given quaternion "result" from the starting index of the given array.
  4617. * @param array the array to pull values from
  4618. * @param offset the offset into the array to start at
  4619. * @param result the quaternion to store the result in
  4620. */
  4621. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4622. /**
  4623. * Create a quaternion from Euler rotation angles
  4624. * @param x Pitch
  4625. * @param y Yaw
  4626. * @param z Roll
  4627. * @returns the new Quaternion
  4628. */
  4629. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4630. /**
  4631. * Updates a quaternion from Euler rotation angles
  4632. * @param x Pitch
  4633. * @param y Yaw
  4634. * @param z Roll
  4635. * @param result the quaternion to store the result
  4636. * @returns the updated quaternion
  4637. */
  4638. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4639. /**
  4640. * Create a quaternion from Euler rotation vector
  4641. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4642. * @returns the new Quaternion
  4643. */
  4644. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4645. /**
  4646. * Updates a quaternion from Euler rotation vector
  4647. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4648. * @param result the quaternion to store the result
  4649. * @returns the updated quaternion
  4650. */
  4651. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4652. /**
  4653. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4654. * @param yaw defines the rotation around Y axis
  4655. * @param pitch defines the rotation around X axis
  4656. * @param roll defines the rotation around Z axis
  4657. * @returns the new quaternion
  4658. */
  4659. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4660. /**
  4661. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4662. * @param yaw defines the rotation around Y axis
  4663. * @param pitch defines the rotation around X axis
  4664. * @param roll defines the rotation around Z axis
  4665. * @param result defines the target quaternion
  4666. */
  4667. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4668. /**
  4669. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4670. * @param alpha defines the rotation around first axis
  4671. * @param beta defines the rotation around second axis
  4672. * @param gamma defines the rotation around third axis
  4673. * @returns the new quaternion
  4674. */
  4675. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4676. /**
  4677. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4678. * @param alpha defines the rotation around first axis
  4679. * @param beta defines the rotation around second axis
  4680. * @param gamma defines the rotation around third axis
  4681. * @param result defines the target quaternion
  4682. */
  4683. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4684. /**
  4685. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4686. * @param axis1 defines the first axis
  4687. * @param axis2 defines the second axis
  4688. * @param axis3 defines the third axis
  4689. * @returns the new quaternion
  4690. */
  4691. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4692. /**
  4693. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4694. * @param axis1 defines the first axis
  4695. * @param axis2 defines the second axis
  4696. * @param axis3 defines the third axis
  4697. * @param ref defines the target quaternion
  4698. */
  4699. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4700. /**
  4701. * Interpolates between two quaternions
  4702. * @param left defines first quaternion
  4703. * @param right defines second quaternion
  4704. * @param amount defines the gradient to use
  4705. * @returns the new interpolated quaternion
  4706. */
  4707. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4708. /**
  4709. * Interpolates between two quaternions and stores it into a target quaternion
  4710. * @param left defines first quaternion
  4711. * @param right defines second quaternion
  4712. * @param amount defines the gradient to use
  4713. * @param result defines the target quaternion
  4714. */
  4715. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4716. /**
  4717. * Interpolate between two quaternions using Hermite interpolation
  4718. * @param value1 defines first quaternion
  4719. * @param tangent1 defines the incoming tangent
  4720. * @param value2 defines second quaternion
  4721. * @param tangent2 defines the outgoing tangent
  4722. * @param amount defines the target quaternion
  4723. * @returns the new interpolated quaternion
  4724. */
  4725. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4726. }
  4727. /**
  4728. * Class used to store matrix data (4x4)
  4729. */
  4730. export class Matrix {
  4731. /**
  4732. * Gets the precision of matrix computations
  4733. */
  4734. static get Use64Bits(): boolean;
  4735. private static _updateFlagSeed;
  4736. private static _identityReadOnly;
  4737. private _isIdentity;
  4738. private _isIdentityDirty;
  4739. private _isIdentity3x2;
  4740. private _isIdentity3x2Dirty;
  4741. /**
  4742. * Gets the update flag of the matrix which is an unique number for the matrix.
  4743. * It will be incremented every time the matrix data change.
  4744. * You can use it to speed the comparison between two versions of the same matrix.
  4745. */
  4746. updateFlag: number;
  4747. private readonly _m;
  4748. /**
  4749. * Gets the internal data of the matrix
  4750. */
  4751. get m(): DeepImmutable<Float32Array | Array<number>>;
  4752. /** @hidden */
  4753. _markAsUpdated(): void;
  4754. /** @hidden */
  4755. private _updateIdentityStatus;
  4756. /**
  4757. * Creates an empty matrix (filled with zeros)
  4758. */
  4759. constructor();
  4760. /**
  4761. * Check if the current matrix is identity
  4762. * @returns true is the matrix is the identity matrix
  4763. */
  4764. isIdentity(): boolean;
  4765. /**
  4766. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4767. * @returns true is the matrix is the identity matrix
  4768. */
  4769. isIdentityAs3x2(): boolean;
  4770. /**
  4771. * Gets the determinant of the matrix
  4772. * @returns the matrix determinant
  4773. */
  4774. determinant(): number;
  4775. /**
  4776. * Returns the matrix as a Float32Array or Array<number>
  4777. * @returns the matrix underlying array
  4778. */
  4779. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4780. /**
  4781. * Returns the matrix as a Float32Array or Array<number>
  4782. * @returns the matrix underlying array.
  4783. */
  4784. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4785. /**
  4786. * Inverts the current matrix in place
  4787. * @returns the current inverted matrix
  4788. */
  4789. invert(): Matrix;
  4790. /**
  4791. * Sets all the matrix elements to zero
  4792. * @returns the current matrix
  4793. */
  4794. reset(): Matrix;
  4795. /**
  4796. * Adds the current matrix with a second one
  4797. * @param other defines the matrix to add
  4798. * @returns a new matrix as the addition of the current matrix and the given one
  4799. */
  4800. add(other: DeepImmutable<Matrix>): Matrix;
  4801. /**
  4802. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4803. * @param other defines the matrix to add
  4804. * @param result defines the target matrix
  4805. * @returns the current matrix
  4806. */
  4807. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4808. /**
  4809. * Adds in place the given matrix to the current matrix
  4810. * @param other defines the second operand
  4811. * @returns the current updated matrix
  4812. */
  4813. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4814. /**
  4815. * Sets the given matrix to the current inverted Matrix
  4816. * @param other defines the target matrix
  4817. * @returns the unmodified current matrix
  4818. */
  4819. invertToRef(other: Matrix): Matrix;
  4820. /**
  4821. * add a value at the specified position in the current Matrix
  4822. * @param index the index of the value within the matrix. between 0 and 15.
  4823. * @param value the value to be added
  4824. * @returns the current updated matrix
  4825. */
  4826. addAtIndex(index: number, value: number): Matrix;
  4827. /**
  4828. * mutiply the specified position in the current Matrix by a value
  4829. * @param index the index of the value within the matrix. between 0 and 15.
  4830. * @param value the value to be added
  4831. * @returns the current updated matrix
  4832. */
  4833. multiplyAtIndex(index: number, value: number): Matrix;
  4834. /**
  4835. * Inserts the translation vector (using 3 floats) in the current matrix
  4836. * @param x defines the 1st component of the translation
  4837. * @param y defines the 2nd component of the translation
  4838. * @param z defines the 3rd component of the translation
  4839. * @returns the current updated matrix
  4840. */
  4841. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4842. /**
  4843. * Adds the translation vector (using 3 floats) in the current matrix
  4844. * @param x defines the 1st component of the translation
  4845. * @param y defines the 2nd component of the translation
  4846. * @param z defines the 3rd component of the translation
  4847. * @returns the current updated matrix
  4848. */
  4849. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4850. /**
  4851. * Inserts the translation vector in the current matrix
  4852. * @param vector3 defines the translation to insert
  4853. * @returns the current updated matrix
  4854. */
  4855. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4856. /**
  4857. * Gets the translation value of the current matrix
  4858. * @returns a new Vector3 as the extracted translation from the matrix
  4859. */
  4860. getTranslation(): Vector3;
  4861. /**
  4862. * Fill a Vector3 with the extracted translation from the matrix
  4863. * @param result defines the Vector3 where to store the translation
  4864. * @returns the current matrix
  4865. */
  4866. getTranslationToRef(result: Vector3): Matrix;
  4867. /**
  4868. * Remove rotation and scaling part from the matrix
  4869. * @returns the updated matrix
  4870. */
  4871. removeRotationAndScaling(): Matrix;
  4872. /**
  4873. * Multiply two matrices
  4874. * @param other defines the second operand
  4875. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4876. */
  4877. multiply(other: DeepImmutable<Matrix>): Matrix;
  4878. /**
  4879. * Copy the current matrix from the given one
  4880. * @param other defines the source matrix
  4881. * @returns the current updated matrix
  4882. */
  4883. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4884. /**
  4885. * Populates the given array from the starting index with the current matrix values
  4886. * @param array defines the target array
  4887. * @param offset defines the offset in the target array where to start storing values
  4888. * @returns the current matrix
  4889. */
  4890. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4891. /**
  4892. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4893. * @param other defines the second operand
  4894. * @param result defines the matrix where to store the multiplication
  4895. * @returns the current matrix
  4896. */
  4897. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4898. /**
  4899. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4900. * @param other defines the second operand
  4901. * @param result defines the array where to store the multiplication
  4902. * @param offset defines the offset in the target array where to start storing values
  4903. * @returns the current matrix
  4904. */
  4905. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4906. /**
  4907. * Check equality between this matrix and a second one
  4908. * @param value defines the second matrix to compare
  4909. * @returns true is the current matrix and the given one values are strictly equal
  4910. */
  4911. equals(value: DeepImmutable<Matrix>): boolean;
  4912. /**
  4913. * Clone the current matrix
  4914. * @returns a new matrix from the current matrix
  4915. */
  4916. clone(): Matrix;
  4917. /**
  4918. * Returns the name of the current matrix class
  4919. * @returns the string "Matrix"
  4920. */
  4921. getClassName(): string;
  4922. /**
  4923. * Gets the hash code of the current matrix
  4924. * @returns the hash code
  4925. */
  4926. getHashCode(): number;
  4927. /**
  4928. * Decomposes the current Matrix into a translation, rotation and scaling components
  4929. * @param scale defines the scale vector3 given as a reference to update
  4930. * @param rotation defines the rotation quaternion given as a reference to update
  4931. * @param translation defines the translation vector3 given as a reference to update
  4932. * @returns true if operation was successful
  4933. */
  4934. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4935. /**
  4936. * Gets specific row of the matrix
  4937. * @param index defines the number of the row to get
  4938. * @returns the index-th row of the current matrix as a new Vector4
  4939. */
  4940. getRow(index: number): Nullable<Vector4>;
  4941. /**
  4942. * Sets the index-th row of the current matrix to the vector4 values
  4943. * @param index defines the number of the row to set
  4944. * @param row defines the target vector4
  4945. * @returns the updated current matrix
  4946. */
  4947. setRow(index: number, row: Vector4): Matrix;
  4948. /**
  4949. * Compute the transpose of the matrix
  4950. * @returns the new transposed matrix
  4951. */
  4952. transpose(): Matrix;
  4953. /**
  4954. * Compute the transpose of the matrix and store it in a given matrix
  4955. * @param result defines the target matrix
  4956. * @returns the current matrix
  4957. */
  4958. transposeToRef(result: Matrix): Matrix;
  4959. /**
  4960. * Sets the index-th row of the current matrix with the given 4 x float values
  4961. * @param index defines the row index
  4962. * @param x defines the x component to set
  4963. * @param y defines the y component to set
  4964. * @param z defines the z component to set
  4965. * @param w defines the w component to set
  4966. * @returns the updated current matrix
  4967. */
  4968. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4969. /**
  4970. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4971. * @param scale defines the scale factor
  4972. * @returns a new matrix
  4973. */
  4974. scale(scale: number): Matrix;
  4975. /**
  4976. * Scale the current matrix values by a factor to a given result matrix
  4977. * @param scale defines the scale factor
  4978. * @param result defines the matrix to store the result
  4979. * @returns the current matrix
  4980. */
  4981. scaleToRef(scale: number, result: Matrix): Matrix;
  4982. /**
  4983. * Scale the current matrix values by a factor and add the result to a given matrix
  4984. * @param scale defines the scale factor
  4985. * @param result defines the Matrix to store the result
  4986. * @returns the current matrix
  4987. */
  4988. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4989. /**
  4990. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4991. * @param ref matrix to store the result
  4992. */
  4993. toNormalMatrix(ref: Matrix): void;
  4994. /**
  4995. * Gets only rotation part of the current matrix
  4996. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4997. */
  4998. getRotationMatrix(): Matrix;
  4999. /**
  5000. * Extracts the rotation matrix from the current one and sets it as the given "result"
  5001. * @param result defines the target matrix to store data to
  5002. * @returns the current matrix
  5003. */
  5004. getRotationMatrixToRef(result: Matrix): Matrix;
  5005. /**
  5006. * Toggles model matrix from being right handed to left handed in place and vice versa
  5007. */
  5008. toggleModelMatrixHandInPlace(): void;
  5009. /**
  5010. * Toggles projection matrix from being right handed to left handed in place and vice versa
  5011. */
  5012. toggleProjectionMatrixHandInPlace(): void;
  5013. /**
  5014. * Creates a matrix from an array
  5015. * @param array defines the source array
  5016. * @param offset defines an offset in the source array
  5017. * @returns a new Matrix set from the starting index of the given array
  5018. */
  5019. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  5020. /**
  5021. * Copy the content of an array into a given matrix
  5022. * @param array defines the source array
  5023. * @param offset defines an offset in the source array
  5024. * @param result defines the target matrix
  5025. */
  5026. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  5027. /**
  5028. * Stores an array into a matrix after having multiplied each component by a given factor
  5029. * @param array defines the source array
  5030. * @param offset defines the offset in the source array
  5031. * @param scale defines the scaling factor
  5032. * @param result defines the target matrix
  5033. */
  5034. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  5035. /**
  5036. * Gets an identity matrix that must not be updated
  5037. */
  5038. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  5039. /**
  5040. * Stores a list of values (16) inside a given matrix
  5041. * @param initialM11 defines 1st value of 1st row
  5042. * @param initialM12 defines 2nd value of 1st row
  5043. * @param initialM13 defines 3rd value of 1st row
  5044. * @param initialM14 defines 4th value of 1st row
  5045. * @param initialM21 defines 1st value of 2nd row
  5046. * @param initialM22 defines 2nd value of 2nd row
  5047. * @param initialM23 defines 3rd value of 2nd row
  5048. * @param initialM24 defines 4th value of 2nd row
  5049. * @param initialM31 defines 1st value of 3rd row
  5050. * @param initialM32 defines 2nd value of 3rd row
  5051. * @param initialM33 defines 3rd value of 3rd row
  5052. * @param initialM34 defines 4th value of 3rd row
  5053. * @param initialM41 defines 1st value of 4th row
  5054. * @param initialM42 defines 2nd value of 4th row
  5055. * @param initialM43 defines 3rd value of 4th row
  5056. * @param initialM44 defines 4th value of 4th row
  5057. * @param result defines the target matrix
  5058. */
  5059. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  5060. /**
  5061. * Creates new matrix from a list of values (16)
  5062. * @param initialM11 defines 1st value of 1st row
  5063. * @param initialM12 defines 2nd value of 1st row
  5064. * @param initialM13 defines 3rd value of 1st row
  5065. * @param initialM14 defines 4th value of 1st row
  5066. * @param initialM21 defines 1st value of 2nd row
  5067. * @param initialM22 defines 2nd value of 2nd row
  5068. * @param initialM23 defines 3rd value of 2nd row
  5069. * @param initialM24 defines 4th value of 2nd row
  5070. * @param initialM31 defines 1st value of 3rd row
  5071. * @param initialM32 defines 2nd value of 3rd row
  5072. * @param initialM33 defines 3rd value of 3rd row
  5073. * @param initialM34 defines 4th value of 3rd row
  5074. * @param initialM41 defines 1st value of 4th row
  5075. * @param initialM42 defines 2nd value of 4th row
  5076. * @param initialM43 defines 3rd value of 4th row
  5077. * @param initialM44 defines 4th value of 4th row
  5078. * @returns the new matrix
  5079. */
  5080. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  5081. /**
  5082. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5083. * @param scale defines the scale vector3
  5084. * @param rotation defines the rotation quaternion
  5085. * @param translation defines the translation vector3
  5086. * @returns a new matrix
  5087. */
  5088. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  5089. /**
  5090. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5091. * @param scale defines the scale vector3
  5092. * @param rotation defines the rotation quaternion
  5093. * @param translation defines the translation vector3
  5094. * @param result defines the target matrix
  5095. */
  5096. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  5097. /**
  5098. * Creates a new identity matrix
  5099. * @returns a new identity matrix
  5100. */
  5101. static Identity(): Matrix;
  5102. /**
  5103. * Creates a new identity matrix and stores the result in a given matrix
  5104. * @param result defines the target matrix
  5105. */
  5106. static IdentityToRef(result: Matrix): void;
  5107. /**
  5108. * Creates a new zero matrix
  5109. * @returns a new zero matrix
  5110. */
  5111. static Zero(): Matrix;
  5112. /**
  5113. * Creates a new rotation matrix for "angle" radians around the X axis
  5114. * @param angle defines the angle (in radians) to use
  5115. * @return the new matrix
  5116. */
  5117. static RotationX(angle: number): Matrix;
  5118. /**
  5119. * Creates a new matrix as the invert of a given matrix
  5120. * @param source defines the source matrix
  5121. * @returns the new matrix
  5122. */
  5123. static Invert(source: DeepImmutable<Matrix>): Matrix;
  5124. /**
  5125. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  5126. * @param angle defines the angle (in radians) to use
  5127. * @param result defines the target matrix
  5128. */
  5129. static RotationXToRef(angle: number, result: Matrix): void;
  5130. /**
  5131. * Creates a new rotation matrix for "angle" radians around the Y axis
  5132. * @param angle defines the angle (in radians) to use
  5133. * @return the new matrix
  5134. */
  5135. static RotationY(angle: number): Matrix;
  5136. /**
  5137. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  5138. * @param angle defines the angle (in radians) to use
  5139. * @param result defines the target matrix
  5140. */
  5141. static RotationYToRef(angle: number, result: Matrix): void;
  5142. /**
  5143. * Creates a new rotation matrix for "angle" radians around the Z axis
  5144. * @param angle defines the angle (in radians) to use
  5145. * @return the new matrix
  5146. */
  5147. static RotationZ(angle: number): Matrix;
  5148. /**
  5149. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  5150. * @param angle defines the angle (in radians) to use
  5151. * @param result defines the target matrix
  5152. */
  5153. static RotationZToRef(angle: number, result: Matrix): void;
  5154. /**
  5155. * Creates a new rotation matrix for "angle" radians around the given axis
  5156. * @param axis defines the axis to use
  5157. * @param angle defines the angle (in radians) to use
  5158. * @return the new matrix
  5159. */
  5160. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  5161. /**
  5162. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  5163. * @param axis defines the axis to use
  5164. * @param angle defines the angle (in radians) to use
  5165. * @param result defines the target matrix
  5166. */
  5167. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  5168. /**
  5169. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  5170. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  5171. * @param from defines the vector to align
  5172. * @param to defines the vector to align to
  5173. * @param result defines the target matrix
  5174. */
  5175. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  5176. /**
  5177. * Creates a rotation matrix
  5178. * @param yaw defines the yaw angle in radians (Y axis)
  5179. * @param pitch defines the pitch angle in radians (X axis)
  5180. * @param roll defines the roll angle in radians (Z axis)
  5181. * @returns the new rotation matrix
  5182. */
  5183. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  5184. /**
  5185. * Creates a rotation matrix and stores it in a given matrix
  5186. * @param yaw defines the yaw angle in radians (Y axis)
  5187. * @param pitch defines the pitch angle in radians (X axis)
  5188. * @param roll defines the roll angle in radians (Z axis)
  5189. * @param result defines the target matrix
  5190. */
  5191. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  5192. /**
  5193. * Creates a scaling matrix
  5194. * @param x defines the scale factor on X axis
  5195. * @param y defines the scale factor on Y axis
  5196. * @param z defines the scale factor on Z axis
  5197. * @returns the new matrix
  5198. */
  5199. static Scaling(x: number, y: number, z: number): Matrix;
  5200. /**
  5201. * Creates a scaling matrix and stores it in a given matrix
  5202. * @param x defines the scale factor on X axis
  5203. * @param y defines the scale factor on Y axis
  5204. * @param z defines the scale factor on Z axis
  5205. * @param result defines the target matrix
  5206. */
  5207. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  5208. /**
  5209. * Creates a translation matrix
  5210. * @param x defines the translation on X axis
  5211. * @param y defines the translation on Y axis
  5212. * @param z defines the translationon Z axis
  5213. * @returns the new matrix
  5214. */
  5215. static Translation(x: number, y: number, z: number): Matrix;
  5216. /**
  5217. * Creates a translation matrix and stores it in a given matrix
  5218. * @param x defines the translation on X axis
  5219. * @param y defines the translation on Y axis
  5220. * @param z defines the translationon Z axis
  5221. * @param result defines the target matrix
  5222. */
  5223. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  5224. /**
  5225. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5226. * @param startValue defines the start value
  5227. * @param endValue defines the end value
  5228. * @param gradient defines the gradient factor
  5229. * @returns the new matrix
  5230. */
  5231. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5232. /**
  5233. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5234. * @param startValue defines the start value
  5235. * @param endValue defines the end value
  5236. * @param gradient defines the gradient factor
  5237. * @param result defines the Matrix object where to store data
  5238. */
  5239. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5240. /**
  5241. * Builds a new matrix whose values are computed by:
  5242. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5243. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5244. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5245. * @param startValue defines the first matrix
  5246. * @param endValue defines the second matrix
  5247. * @param gradient defines the gradient between the two matrices
  5248. * @returns the new matrix
  5249. */
  5250. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5251. /**
  5252. * Update a matrix to values which are computed by:
  5253. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5254. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5255. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5256. * @param startValue defines the first matrix
  5257. * @param endValue defines the second matrix
  5258. * @param gradient defines the gradient between the two matrices
  5259. * @param result defines the target matrix
  5260. */
  5261. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5262. /**
  5263. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  5264. * This function works in left handed mode
  5265. * @param eye defines the final position of the entity
  5266. * @param target defines where the entity should look at
  5267. * @param up defines the up vector for the entity
  5268. * @returns the new matrix
  5269. */
  5270. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5271. /**
  5272. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  5273. * This function works in left handed mode
  5274. * @param eye defines the final position of the entity
  5275. * @param target defines where the entity should look at
  5276. * @param up defines the up vector for the entity
  5277. * @param result defines the target matrix
  5278. */
  5279. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5280. /**
  5281. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  5282. * This function works in right handed mode
  5283. * @param eye defines the final position of the entity
  5284. * @param target defines where the entity should look at
  5285. * @param up defines the up vector for the entity
  5286. * @returns the new matrix
  5287. */
  5288. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5289. /**
  5290. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  5291. * This function works in right handed mode
  5292. * @param eye defines the final position of the entity
  5293. * @param target defines where the entity should look at
  5294. * @param up defines the up vector for the entity
  5295. * @param result defines the target matrix
  5296. */
  5297. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5298. /**
  5299. * Create a left-handed orthographic projection matrix
  5300. * @param width defines the viewport width
  5301. * @param height defines the viewport height
  5302. * @param znear defines the near clip plane
  5303. * @param zfar defines the far clip plane
  5304. * @returns a new matrix as a left-handed orthographic projection matrix
  5305. */
  5306. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5307. /**
  5308. * Store a left-handed orthographic projection to a given matrix
  5309. * @param width defines the viewport width
  5310. * @param height defines the viewport height
  5311. * @param znear defines the near clip plane
  5312. * @param zfar defines the far clip plane
  5313. * @param result defines the target matrix
  5314. */
  5315. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5316. /**
  5317. * Create a left-handed orthographic projection matrix
  5318. * @param left defines the viewport left coordinate
  5319. * @param right defines the viewport right coordinate
  5320. * @param bottom defines the viewport bottom coordinate
  5321. * @param top defines the viewport top coordinate
  5322. * @param znear defines the near clip plane
  5323. * @param zfar defines the far clip plane
  5324. * @returns a new matrix as a left-handed orthographic projection matrix
  5325. */
  5326. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5327. /**
  5328. * Stores a left-handed orthographic projection into a given matrix
  5329. * @param left defines the viewport left coordinate
  5330. * @param right defines the viewport right coordinate
  5331. * @param bottom defines the viewport bottom coordinate
  5332. * @param top defines the viewport top coordinate
  5333. * @param znear defines the near clip plane
  5334. * @param zfar defines the far clip plane
  5335. * @param result defines the target matrix
  5336. */
  5337. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5338. /**
  5339. * Creates a right-handed orthographic projection matrix
  5340. * @param left defines the viewport left coordinate
  5341. * @param right defines the viewport right coordinate
  5342. * @param bottom defines the viewport bottom coordinate
  5343. * @param top defines the viewport top coordinate
  5344. * @param znear defines the near clip plane
  5345. * @param zfar defines the far clip plane
  5346. * @returns a new matrix as a right-handed orthographic projection matrix
  5347. */
  5348. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5349. /**
  5350. * Stores a right-handed orthographic projection into a given matrix
  5351. * @param left defines the viewport left coordinate
  5352. * @param right defines the viewport right coordinate
  5353. * @param bottom defines the viewport bottom coordinate
  5354. * @param top defines the viewport top coordinate
  5355. * @param znear defines the near clip plane
  5356. * @param zfar defines the far clip plane
  5357. * @param result defines the target matrix
  5358. */
  5359. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5360. /**
  5361. * Creates a left-handed perspective projection matrix
  5362. * @param width defines the viewport width
  5363. * @param height defines the viewport height
  5364. * @param znear defines the near clip plane
  5365. * @param zfar defines the far clip plane
  5366. * @returns a new matrix as a left-handed perspective projection matrix
  5367. */
  5368. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5369. /**
  5370. * Creates a left-handed perspective projection matrix
  5371. * @param fov defines the horizontal field of view
  5372. * @param aspect defines the aspect ratio
  5373. * @param znear defines the near clip plane
  5374. * @param zfar defines the far clip plane
  5375. * @returns a new matrix as a left-handed perspective projection matrix
  5376. */
  5377. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5378. /**
  5379. * Stores a left-handed perspective projection into a given matrix
  5380. * @param fov defines the horizontal field of view
  5381. * @param aspect defines the aspect ratio
  5382. * @param znear defines the near clip plane
  5383. * @param zfar defines the far clip plane
  5384. * @param result defines the target matrix
  5385. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5386. */
  5387. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5388. /**
  5389. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5390. * @param fov defines the horizontal field of view
  5391. * @param aspect defines the aspect ratio
  5392. * @param znear defines the near clip plane
  5393. * @param zfar not used as infinity is used as far clip
  5394. * @param result defines the target matrix
  5395. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5396. */
  5397. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5398. /**
  5399. * Creates a right-handed perspective projection matrix
  5400. * @param fov defines the horizontal field of view
  5401. * @param aspect defines the aspect ratio
  5402. * @param znear defines the near clip plane
  5403. * @param zfar defines the far clip plane
  5404. * @returns a new matrix as a right-handed perspective projection matrix
  5405. */
  5406. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5407. /**
  5408. * Stores a right-handed perspective projection into a given matrix
  5409. * @param fov defines the horizontal field of view
  5410. * @param aspect defines the aspect ratio
  5411. * @param znear defines the near clip plane
  5412. * @param zfar defines the far clip plane
  5413. * @param result defines the target matrix
  5414. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5415. */
  5416. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5417. /**
  5418. * Stores a right-handed perspective projection into a given matrix
  5419. * @param fov defines the horizontal field of view
  5420. * @param aspect defines the aspect ratio
  5421. * @param znear defines the near clip plane
  5422. * @param zfar not used as infinity is used as far clip
  5423. * @param result defines the target matrix
  5424. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5425. */
  5426. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5427. /**
  5428. * Stores a perspective projection for WebVR info a given matrix
  5429. * @param fov defines the field of view
  5430. * @param znear defines the near clip plane
  5431. * @param zfar defines the far clip plane
  5432. * @param result defines the target matrix
  5433. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5434. */
  5435. static PerspectiveFovWebVRToRef(fov: {
  5436. upDegrees: number;
  5437. downDegrees: number;
  5438. leftDegrees: number;
  5439. rightDegrees: number;
  5440. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5441. /**
  5442. * Computes a complete transformation matrix
  5443. * @param viewport defines the viewport to use
  5444. * @param world defines the world matrix
  5445. * @param view defines the view matrix
  5446. * @param projection defines the projection matrix
  5447. * @param zmin defines the near clip plane
  5448. * @param zmax defines the far clip plane
  5449. * @returns the transformation matrix
  5450. */
  5451. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5452. /**
  5453. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5454. * @param matrix defines the matrix to use
  5455. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5456. */
  5457. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5458. /**
  5459. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5460. * @param matrix defines the matrix to use
  5461. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5462. */
  5463. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5464. /**
  5465. * Compute the transpose of a given matrix
  5466. * @param matrix defines the matrix to transpose
  5467. * @returns the new matrix
  5468. */
  5469. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5470. /**
  5471. * Compute the transpose of a matrix and store it in a target matrix
  5472. * @param matrix defines the matrix to transpose
  5473. * @param result defines the target matrix
  5474. */
  5475. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5476. /**
  5477. * Computes a reflection matrix from a plane
  5478. * @param plane defines the reflection plane
  5479. * @returns a new matrix
  5480. */
  5481. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5482. /**
  5483. * Computes a reflection matrix from a plane
  5484. * @param plane defines the reflection plane
  5485. * @param result defines the target matrix
  5486. */
  5487. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5488. /**
  5489. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5490. * @param xaxis defines the value of the 1st axis
  5491. * @param yaxis defines the value of the 2nd axis
  5492. * @param zaxis defines the value of the 3rd axis
  5493. * @param result defines the target matrix
  5494. */
  5495. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5496. /**
  5497. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5498. * @param quat defines the quaternion to use
  5499. * @param result defines the target matrix
  5500. */
  5501. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5502. }
  5503. /**
  5504. * @hidden
  5505. */
  5506. export class TmpVectors {
  5507. static Vector2: Vector2[];
  5508. static Vector3: Vector3[];
  5509. static Vector4: Vector4[];
  5510. static Quaternion: Quaternion[];
  5511. static Matrix: Matrix[];
  5512. }
  5513. }
  5514. declare module BABYLON {
  5515. /**
  5516. * Defines potential orientation for back face culling
  5517. */
  5518. export enum Orientation {
  5519. /**
  5520. * Clockwise
  5521. */
  5522. CW = 0,
  5523. /** Counter clockwise */
  5524. CCW = 1
  5525. }
  5526. /** Class used to represent a Bezier curve */
  5527. export class BezierCurve {
  5528. /**
  5529. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5530. * @param t defines the time
  5531. * @param x1 defines the left coordinate on X axis
  5532. * @param y1 defines the left coordinate on Y axis
  5533. * @param x2 defines the right coordinate on X axis
  5534. * @param y2 defines the right coordinate on Y axis
  5535. * @returns the interpolated value
  5536. */
  5537. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5538. }
  5539. /**
  5540. * Defines angle representation
  5541. */
  5542. export class Angle {
  5543. private _radians;
  5544. /**
  5545. * Creates an Angle object of "radians" radians (float).
  5546. * @param radians the angle in radians
  5547. */
  5548. constructor(radians: number);
  5549. /**
  5550. * Get value in degrees
  5551. * @returns the Angle value in degrees (float)
  5552. */
  5553. degrees(): number;
  5554. /**
  5555. * Get value in radians
  5556. * @returns the Angle value in radians (float)
  5557. */
  5558. radians(): number;
  5559. /**
  5560. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5561. * @param a defines first point as the origin
  5562. * @param b defines point
  5563. * @returns a new Angle
  5564. */
  5565. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5566. /**
  5567. * Gets a new Angle object from the given float in radians
  5568. * @param radians defines the angle value in radians
  5569. * @returns a new Angle
  5570. */
  5571. static FromRadians(radians: number): Angle;
  5572. /**
  5573. * Gets a new Angle object from the given float in degrees
  5574. * @param degrees defines the angle value in degrees
  5575. * @returns a new Angle
  5576. */
  5577. static FromDegrees(degrees: number): Angle;
  5578. }
  5579. /**
  5580. * This represents an arc in a 2d space.
  5581. */
  5582. export class Arc2 {
  5583. /** Defines the start point of the arc */
  5584. startPoint: Vector2;
  5585. /** Defines the mid point of the arc */
  5586. midPoint: Vector2;
  5587. /** Defines the end point of the arc */
  5588. endPoint: Vector2;
  5589. /**
  5590. * Defines the center point of the arc.
  5591. */
  5592. centerPoint: Vector2;
  5593. /**
  5594. * Defines the radius of the arc.
  5595. */
  5596. radius: number;
  5597. /**
  5598. * Defines the angle of the arc (from mid point to end point).
  5599. */
  5600. angle: Angle;
  5601. /**
  5602. * Defines the start angle of the arc (from start point to middle point).
  5603. */
  5604. startAngle: Angle;
  5605. /**
  5606. * Defines the orientation of the arc (clock wise/counter clock wise).
  5607. */
  5608. orientation: Orientation;
  5609. /**
  5610. * Creates an Arc object from the three given points : start, middle and end.
  5611. * @param startPoint Defines the start point of the arc
  5612. * @param midPoint Defines the midlle point of the arc
  5613. * @param endPoint Defines the end point of the arc
  5614. */
  5615. constructor(
  5616. /** Defines the start point of the arc */
  5617. startPoint: Vector2,
  5618. /** Defines the mid point of the arc */
  5619. midPoint: Vector2,
  5620. /** Defines the end point of the arc */
  5621. endPoint: Vector2);
  5622. }
  5623. /**
  5624. * Represents a 2D path made up of multiple 2D points
  5625. */
  5626. export class Path2 {
  5627. private _points;
  5628. private _length;
  5629. /**
  5630. * If the path start and end point are the same
  5631. */
  5632. closed: boolean;
  5633. /**
  5634. * Creates a Path2 object from the starting 2D coordinates x and y.
  5635. * @param x the starting points x value
  5636. * @param y the starting points y value
  5637. */
  5638. constructor(x: number, y: number);
  5639. /**
  5640. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5641. * @param x the added points x value
  5642. * @param y the added points y value
  5643. * @returns the updated Path2.
  5644. */
  5645. addLineTo(x: number, y: number): Path2;
  5646. /**
  5647. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5648. * @param midX middle point x value
  5649. * @param midY middle point y value
  5650. * @param endX end point x value
  5651. * @param endY end point y value
  5652. * @param numberOfSegments (default: 36)
  5653. * @returns the updated Path2.
  5654. */
  5655. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5656. /**
  5657. * Closes the Path2.
  5658. * @returns the Path2.
  5659. */
  5660. close(): Path2;
  5661. /**
  5662. * Gets the sum of the distance between each sequential point in the path
  5663. * @returns the Path2 total length (float).
  5664. */
  5665. length(): number;
  5666. /**
  5667. * Gets the points which construct the path
  5668. * @returns the Path2 internal array of points.
  5669. */
  5670. getPoints(): Vector2[];
  5671. /**
  5672. * Retreives the point at the distance aways from the starting point
  5673. * @param normalizedLengthPosition the length along the path to retreive the point from
  5674. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5675. */
  5676. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5677. /**
  5678. * Creates a new path starting from an x and y position
  5679. * @param x starting x value
  5680. * @param y starting y value
  5681. * @returns a new Path2 starting at the coordinates (x, y).
  5682. */
  5683. static StartingAt(x: number, y: number): Path2;
  5684. }
  5685. /**
  5686. * Represents a 3D path made up of multiple 3D points
  5687. */
  5688. export class Path3D {
  5689. /**
  5690. * an array of Vector3, the curve axis of the Path3D
  5691. */
  5692. path: Vector3[];
  5693. private _curve;
  5694. private _distances;
  5695. private _tangents;
  5696. private _normals;
  5697. private _binormals;
  5698. private _raw;
  5699. private _alignTangentsWithPath;
  5700. private readonly _pointAtData;
  5701. /**
  5702. * new Path3D(path, normal, raw)
  5703. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5704. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5705. * @param path an array of Vector3, the curve axis of the Path3D
  5706. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5707. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5708. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5709. */
  5710. constructor(
  5711. /**
  5712. * an array of Vector3, the curve axis of the Path3D
  5713. */
  5714. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5715. /**
  5716. * Returns the Path3D array of successive Vector3 designing its curve.
  5717. * @returns the Path3D array of successive Vector3 designing its curve.
  5718. */
  5719. getCurve(): Vector3[];
  5720. /**
  5721. * Returns the Path3D array of successive Vector3 designing its curve.
  5722. * @returns the Path3D array of successive Vector3 designing its curve.
  5723. */
  5724. getPoints(): Vector3[];
  5725. /**
  5726. * @returns the computed length (float) of the path.
  5727. */
  5728. length(): number;
  5729. /**
  5730. * Returns an array populated with tangent vectors on each Path3D curve point.
  5731. * @returns an array populated with tangent vectors on each Path3D curve point.
  5732. */
  5733. getTangents(): Vector3[];
  5734. /**
  5735. * Returns an array populated with normal vectors on each Path3D curve point.
  5736. * @returns an array populated with normal vectors on each Path3D curve point.
  5737. */
  5738. getNormals(): Vector3[];
  5739. /**
  5740. * Returns an array populated with binormal vectors on each Path3D curve point.
  5741. * @returns an array populated with binormal vectors on each Path3D curve point.
  5742. */
  5743. getBinormals(): Vector3[];
  5744. /**
  5745. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5746. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5747. */
  5748. getDistances(): number[];
  5749. /**
  5750. * Returns an interpolated point along this path
  5751. * @param position the position of the point along this path, from 0.0 to 1.0
  5752. * @returns a new Vector3 as the point
  5753. */
  5754. getPointAt(position: number): Vector3;
  5755. /**
  5756. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5757. * @param position the position of the point along this path, from 0.0 to 1.0
  5758. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5759. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5760. */
  5761. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5762. /**
  5763. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5764. * @param position the position of the point along this path, from 0.0 to 1.0
  5765. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5766. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5767. */
  5768. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5769. /**
  5770. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5771. * @param position the position of the point along this path, from 0.0 to 1.0
  5772. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5773. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5774. */
  5775. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5776. /**
  5777. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5778. * @param position the position of the point along this path, from 0.0 to 1.0
  5779. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5780. */
  5781. getDistanceAt(position: number): number;
  5782. /**
  5783. * Returns the array index of the previous point of an interpolated point along this path
  5784. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5785. * @returns the array index
  5786. */
  5787. getPreviousPointIndexAt(position: number): number;
  5788. /**
  5789. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5790. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5791. * @returns the sub position
  5792. */
  5793. getSubPositionAt(position: number): number;
  5794. /**
  5795. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5796. * @param target the vector of which to get the closest position to
  5797. * @returns the position of the closest virtual point on this path to the target vector
  5798. */
  5799. getClosestPositionTo(target: Vector3): number;
  5800. /**
  5801. * Returns a sub path (slice) of this path
  5802. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5803. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5804. * @returns a sub path (slice) of this path
  5805. */
  5806. slice(start?: number, end?: number): Path3D;
  5807. /**
  5808. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5809. * @param path path which all values are copied into the curves points
  5810. * @param firstNormal which should be projected onto the curve
  5811. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5812. * @returns the same object updated.
  5813. */
  5814. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5815. private _compute;
  5816. private _getFirstNonNullVector;
  5817. private _getLastNonNullVector;
  5818. private _normalVector;
  5819. /**
  5820. * Updates the point at data for an interpolated point along this curve
  5821. * @param position the position of the point along this curve, from 0.0 to 1.0
  5822. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5823. * @returns the (updated) point at data
  5824. */
  5825. private _updatePointAtData;
  5826. /**
  5827. * Updates the point at data from the specified parameters
  5828. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5829. * @param point the interpolated point
  5830. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5831. */
  5832. private _setPointAtData;
  5833. /**
  5834. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5835. */
  5836. private _updateInterpolationMatrix;
  5837. }
  5838. /**
  5839. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5840. * A Curve3 is designed from a series of successive Vector3.
  5841. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5842. */
  5843. export class Curve3 {
  5844. private _points;
  5845. private _length;
  5846. /**
  5847. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5848. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5849. * @param v1 (Vector3) the control point
  5850. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5851. * @param nbPoints (integer) the wanted number of points in the curve
  5852. * @returns the created Curve3
  5853. */
  5854. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5855. /**
  5856. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5857. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5858. * @param v1 (Vector3) the first control point
  5859. * @param v2 (Vector3) the second control point
  5860. * @param v3 (Vector3) the end point of the Cubic Bezier
  5861. * @param nbPoints (integer) the wanted number of points in the curve
  5862. * @returns the created Curve3
  5863. */
  5864. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5865. /**
  5866. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5867. * @param p1 (Vector3) the origin point of the Hermite Spline
  5868. * @param t1 (Vector3) the tangent vector at the origin point
  5869. * @param p2 (Vector3) the end point of the Hermite Spline
  5870. * @param t2 (Vector3) the tangent vector at the end point
  5871. * @param nbPoints (integer) the wanted number of points in the curve
  5872. * @returns the created Curve3
  5873. */
  5874. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5875. /**
  5876. * Returns a Curve3 object along a CatmullRom Spline curve :
  5877. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5878. * @param nbPoints (integer) the wanted number of points between each curve control points
  5879. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5880. * @returns the created Curve3
  5881. */
  5882. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5883. /**
  5884. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5885. * A Curve3 is designed from a series of successive Vector3.
  5886. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5887. * @param points points which make up the curve
  5888. */
  5889. constructor(points: Vector3[]);
  5890. /**
  5891. * @returns the Curve3 stored array of successive Vector3
  5892. */
  5893. getPoints(): Vector3[];
  5894. /**
  5895. * @returns the computed length (float) of the curve.
  5896. */
  5897. length(): number;
  5898. /**
  5899. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5900. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5901. * curveA and curveB keep unchanged.
  5902. * @param curve the curve to continue from this curve
  5903. * @returns the newly constructed curve
  5904. */
  5905. continue(curve: DeepImmutable<Curve3>): Curve3;
  5906. private _computeLength;
  5907. }
  5908. }
  5909. declare module BABYLON {
  5910. /**
  5911. * This represents the main contract an easing function should follow.
  5912. * Easing functions are used throughout the animation system.
  5913. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5914. */
  5915. export interface IEasingFunction {
  5916. /**
  5917. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5918. * of the easing function.
  5919. * The link below provides some of the most common examples of easing functions.
  5920. * @see https://easings.net/
  5921. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5922. * @returns the corresponding value on the curve defined by the easing function
  5923. */
  5924. ease(gradient: number): number;
  5925. }
  5926. /**
  5927. * Base class used for every default easing function.
  5928. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5929. */
  5930. export class EasingFunction implements IEasingFunction {
  5931. /**
  5932. * Interpolation follows the mathematical formula associated with the easing function.
  5933. */
  5934. static readonly EASINGMODE_EASEIN: number;
  5935. /**
  5936. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5937. */
  5938. static readonly EASINGMODE_EASEOUT: number;
  5939. /**
  5940. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5941. */
  5942. static readonly EASINGMODE_EASEINOUT: number;
  5943. private _easingMode;
  5944. /**
  5945. * Sets the easing mode of the current function.
  5946. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5947. */
  5948. setEasingMode(easingMode: number): void;
  5949. /**
  5950. * Gets the current easing mode.
  5951. * @returns the easing mode
  5952. */
  5953. getEasingMode(): number;
  5954. /**
  5955. * @hidden
  5956. */
  5957. easeInCore(gradient: number): number;
  5958. /**
  5959. * Given an input gradient between 0 and 1, this returns the corresponding value
  5960. * of the easing function.
  5961. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5962. * @returns the corresponding value on the curve defined by the easing function
  5963. */
  5964. ease(gradient: number): number;
  5965. }
  5966. /**
  5967. * Easing function with a circle shape (see link below).
  5968. * @see https://easings.net/#easeInCirc
  5969. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5970. */
  5971. export class CircleEase extends EasingFunction implements IEasingFunction {
  5972. /** @hidden */
  5973. easeInCore(gradient: number): number;
  5974. }
  5975. /**
  5976. * Easing function with a ease back shape (see link below).
  5977. * @see https://easings.net/#easeInBack
  5978. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5979. */
  5980. export class BackEase extends EasingFunction implements IEasingFunction {
  5981. /** Defines the amplitude of the function */
  5982. amplitude: number;
  5983. /**
  5984. * Instantiates a back ease easing
  5985. * @see https://easings.net/#easeInBack
  5986. * @param amplitude Defines the amplitude of the function
  5987. */
  5988. constructor(
  5989. /** Defines the amplitude of the function */
  5990. amplitude?: number);
  5991. /** @hidden */
  5992. easeInCore(gradient: number): number;
  5993. }
  5994. /**
  5995. * Easing function with a bouncing shape (see link below).
  5996. * @see https://easings.net/#easeInBounce
  5997. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5998. */
  5999. export class BounceEase extends EasingFunction implements IEasingFunction {
  6000. /** Defines the number of bounces */
  6001. bounces: number;
  6002. /** Defines the amplitude of the bounce */
  6003. bounciness: number;
  6004. /**
  6005. * Instantiates a bounce easing
  6006. * @see https://easings.net/#easeInBounce
  6007. * @param bounces Defines the number of bounces
  6008. * @param bounciness Defines the amplitude of the bounce
  6009. */
  6010. constructor(
  6011. /** Defines the number of bounces */
  6012. bounces?: number,
  6013. /** Defines the amplitude of the bounce */
  6014. bounciness?: number);
  6015. /** @hidden */
  6016. easeInCore(gradient: number): number;
  6017. }
  6018. /**
  6019. * Easing function with a power of 3 shape (see link below).
  6020. * @see https://easings.net/#easeInCubic
  6021. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6022. */
  6023. export class CubicEase extends EasingFunction implements IEasingFunction {
  6024. /** @hidden */
  6025. easeInCore(gradient: number): number;
  6026. }
  6027. /**
  6028. * Easing function with an elastic shape (see link below).
  6029. * @see https://easings.net/#easeInElastic
  6030. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6031. */
  6032. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6033. /** Defines the number of oscillations*/
  6034. oscillations: number;
  6035. /** Defines the amplitude of the oscillations*/
  6036. springiness: number;
  6037. /**
  6038. * Instantiates an elastic easing function
  6039. * @see https://easings.net/#easeInElastic
  6040. * @param oscillations Defines the number of oscillations
  6041. * @param springiness Defines the amplitude of the oscillations
  6042. */
  6043. constructor(
  6044. /** Defines the number of oscillations*/
  6045. oscillations?: number,
  6046. /** Defines the amplitude of the oscillations*/
  6047. springiness?: number);
  6048. /** @hidden */
  6049. easeInCore(gradient: number): number;
  6050. }
  6051. /**
  6052. * Easing function with an exponential shape (see link below).
  6053. * @see https://easings.net/#easeInExpo
  6054. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6055. */
  6056. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6057. /** Defines the exponent of the function */
  6058. exponent: number;
  6059. /**
  6060. * Instantiates an exponential easing function
  6061. * @see https://easings.net/#easeInExpo
  6062. * @param exponent Defines the exponent of the function
  6063. */
  6064. constructor(
  6065. /** Defines the exponent of the function */
  6066. exponent?: number);
  6067. /** @hidden */
  6068. easeInCore(gradient: number): number;
  6069. }
  6070. /**
  6071. * Easing function with a power shape (see link below).
  6072. * @see https://easings.net/#easeInQuad
  6073. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6074. */
  6075. export class PowerEase extends EasingFunction implements IEasingFunction {
  6076. /** Defines the power of the function */
  6077. power: number;
  6078. /**
  6079. * Instantiates an power base easing function
  6080. * @see https://easings.net/#easeInQuad
  6081. * @param power Defines the power of the function
  6082. */
  6083. constructor(
  6084. /** Defines the power of the function */
  6085. power?: number);
  6086. /** @hidden */
  6087. easeInCore(gradient: number): number;
  6088. }
  6089. /**
  6090. * Easing function with a power of 2 shape (see link below).
  6091. * @see https://easings.net/#easeInQuad
  6092. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6093. */
  6094. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6095. /** @hidden */
  6096. easeInCore(gradient: number): number;
  6097. }
  6098. /**
  6099. * Easing function with a power of 4 shape (see link below).
  6100. * @see https://easings.net/#easeInQuart
  6101. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6102. */
  6103. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6104. /** @hidden */
  6105. easeInCore(gradient: number): number;
  6106. }
  6107. /**
  6108. * Easing function with a power of 5 shape (see link below).
  6109. * @see https://easings.net/#easeInQuint
  6110. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6111. */
  6112. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6113. /** @hidden */
  6114. easeInCore(gradient: number): number;
  6115. }
  6116. /**
  6117. * Easing function with a sin shape (see link below).
  6118. * @see https://easings.net/#easeInSine
  6119. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6120. */
  6121. export class SineEase extends EasingFunction implements IEasingFunction {
  6122. /** @hidden */
  6123. easeInCore(gradient: number): number;
  6124. }
  6125. /**
  6126. * Easing function with a bezier shape (see link below).
  6127. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6128. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6129. */
  6130. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6131. /** Defines the x component of the start tangent in the bezier curve */
  6132. x1: number;
  6133. /** Defines the y component of the start tangent in the bezier curve */
  6134. y1: number;
  6135. /** Defines the x component of the end tangent in the bezier curve */
  6136. x2: number;
  6137. /** Defines the y component of the end tangent in the bezier curve */
  6138. y2: number;
  6139. /**
  6140. * Instantiates a bezier function
  6141. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6142. * @param x1 Defines the x component of the start tangent in the bezier curve
  6143. * @param y1 Defines the y component of the start tangent in the bezier curve
  6144. * @param x2 Defines the x component of the end tangent in the bezier curve
  6145. * @param y2 Defines the y component of the end tangent in the bezier curve
  6146. */
  6147. constructor(
  6148. /** Defines the x component of the start tangent in the bezier curve */
  6149. x1?: number,
  6150. /** Defines the y component of the start tangent in the bezier curve */
  6151. y1?: number,
  6152. /** Defines the x component of the end tangent in the bezier curve */
  6153. x2?: number,
  6154. /** Defines the y component of the end tangent in the bezier curve */
  6155. y2?: number);
  6156. /** @hidden */
  6157. easeInCore(gradient: number): number;
  6158. }
  6159. }
  6160. declare module BABYLON {
  6161. /**
  6162. * Class used to hold a RBG color
  6163. */
  6164. export class Color3 {
  6165. /**
  6166. * Defines the red component (between 0 and 1, default is 0)
  6167. */
  6168. r: number;
  6169. /**
  6170. * Defines the green component (between 0 and 1, default is 0)
  6171. */
  6172. g: number;
  6173. /**
  6174. * Defines the blue component (between 0 and 1, default is 0)
  6175. */
  6176. b: number;
  6177. /**
  6178. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  6179. * @param r defines the red component (between 0 and 1, default is 0)
  6180. * @param g defines the green component (between 0 and 1, default is 0)
  6181. * @param b defines the blue component (between 0 and 1, default is 0)
  6182. */
  6183. constructor(
  6184. /**
  6185. * Defines the red component (between 0 and 1, default is 0)
  6186. */
  6187. r?: number,
  6188. /**
  6189. * Defines the green component (between 0 and 1, default is 0)
  6190. */
  6191. g?: number,
  6192. /**
  6193. * Defines the blue component (between 0 and 1, default is 0)
  6194. */
  6195. b?: number);
  6196. /**
  6197. * Creates a string with the Color3 current values
  6198. * @returns the string representation of the Color3 object
  6199. */
  6200. toString(): string;
  6201. /**
  6202. * Returns the string "Color3"
  6203. * @returns "Color3"
  6204. */
  6205. getClassName(): string;
  6206. /**
  6207. * Compute the Color3 hash code
  6208. * @returns an unique number that can be used to hash Color3 objects
  6209. */
  6210. getHashCode(): number;
  6211. /**
  6212. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  6213. * @param array defines the array where to store the r,g,b components
  6214. * @param index defines an optional index in the target array to define where to start storing values
  6215. * @returns the current Color3 object
  6216. */
  6217. toArray(array: FloatArray, index?: number): Color3;
  6218. /**
  6219. * Update the current color with values stored in an array from the starting index of the given array
  6220. * @param array defines the source array
  6221. * @param offset defines an offset in the source array
  6222. * @returns the current Color3 object
  6223. */
  6224. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6225. /**
  6226. * Returns a new Color4 object from the current Color3 and the given alpha
  6227. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  6228. * @returns a new Color4 object
  6229. */
  6230. toColor4(alpha?: number): Color4;
  6231. /**
  6232. * Returns a new array populated with 3 numeric elements : red, green and blue values
  6233. * @returns the new array
  6234. */
  6235. asArray(): number[];
  6236. /**
  6237. * Returns the luminance value
  6238. * @returns a float value
  6239. */
  6240. toLuminance(): number;
  6241. /**
  6242. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  6243. * @param otherColor defines the second operand
  6244. * @returns the new Color3 object
  6245. */
  6246. multiply(otherColor: DeepImmutable<Color3>): Color3;
  6247. /**
  6248. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  6249. * @param otherColor defines the second operand
  6250. * @param result defines the Color3 object where to store the result
  6251. * @returns the current Color3
  6252. */
  6253. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6254. /**
  6255. * Determines equality between Color3 objects
  6256. * @param otherColor defines the second operand
  6257. * @returns true if the rgb values are equal to the given ones
  6258. */
  6259. equals(otherColor: DeepImmutable<Color3>): boolean;
  6260. /**
  6261. * Determines equality between the current Color3 object and a set of r,b,g values
  6262. * @param r defines the red component to check
  6263. * @param g defines the green component to check
  6264. * @param b defines the blue component to check
  6265. * @returns true if the rgb values are equal to the given ones
  6266. */
  6267. equalsFloats(r: number, g: number, b: number): boolean;
  6268. /**
  6269. * Multiplies in place each rgb value by scale
  6270. * @param scale defines the scaling factor
  6271. * @returns the updated Color3
  6272. */
  6273. scale(scale: number): Color3;
  6274. /**
  6275. * Multiplies the rgb values by scale and stores the result into "result"
  6276. * @param scale defines the scaling factor
  6277. * @param result defines the Color3 object where to store the result
  6278. * @returns the unmodified current Color3
  6279. */
  6280. scaleToRef(scale: number, result: Color3): Color3;
  6281. /**
  6282. * Scale the current Color3 values by a factor and add the result to a given Color3
  6283. * @param scale defines the scale factor
  6284. * @param result defines color to store the result into
  6285. * @returns the unmodified current Color3
  6286. */
  6287. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6288. /**
  6289. * Clamps the rgb values by the min and max values and stores the result into "result"
  6290. * @param min defines minimum clamping value (default is 0)
  6291. * @param max defines maximum clamping value (default is 1)
  6292. * @param result defines color to store the result into
  6293. * @returns the original Color3
  6294. */
  6295. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6296. /**
  6297. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6298. * @param otherColor defines the second operand
  6299. * @returns the new Color3
  6300. */
  6301. add(otherColor: DeepImmutable<Color3>): Color3;
  6302. /**
  6303. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6304. * @param otherColor defines the second operand
  6305. * @param result defines Color3 object to store the result into
  6306. * @returns the unmodified current Color3
  6307. */
  6308. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6309. /**
  6310. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6311. * @param otherColor defines the second operand
  6312. * @returns the new Color3
  6313. */
  6314. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6315. /**
  6316. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  6317. * @param otherColor defines the second operand
  6318. * @param result defines Color3 object to store the result into
  6319. * @returns the unmodified current Color3
  6320. */
  6321. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6322. /**
  6323. * Copy the current object
  6324. * @returns a new Color3 copied the current one
  6325. */
  6326. clone(): Color3;
  6327. /**
  6328. * Copies the rgb values from the source in the current Color3
  6329. * @param source defines the source Color3 object
  6330. * @returns the updated Color3 object
  6331. */
  6332. copyFrom(source: DeepImmutable<Color3>): Color3;
  6333. /**
  6334. * Updates the Color3 rgb values from the given floats
  6335. * @param r defines the red component to read from
  6336. * @param g defines the green component to read from
  6337. * @param b defines the blue component to read from
  6338. * @returns the current Color3 object
  6339. */
  6340. copyFromFloats(r: number, g: number, b: number): Color3;
  6341. /**
  6342. * Updates the Color3 rgb values from the given floats
  6343. * @param r defines the red component to read from
  6344. * @param g defines the green component to read from
  6345. * @param b defines the blue component to read from
  6346. * @returns the current Color3 object
  6347. */
  6348. set(r: number, g: number, b: number): Color3;
  6349. /**
  6350. * Compute the Color3 hexadecimal code as a string
  6351. * @returns a string containing the hexadecimal representation of the Color3 object
  6352. */
  6353. toHexString(): string;
  6354. /**
  6355. * Computes a new Color3 converted from the current one to linear space
  6356. * @returns a new Color3 object
  6357. */
  6358. toLinearSpace(): Color3;
  6359. /**
  6360. * Converts current color in rgb space to HSV values
  6361. * @returns a new color3 representing the HSV values
  6362. */
  6363. toHSV(): Color3;
  6364. /**
  6365. * Converts current color in rgb space to HSV values
  6366. * @param result defines the Color3 where to store the HSV values
  6367. */
  6368. toHSVToRef(result: Color3): void;
  6369. /**
  6370. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6371. * @param convertedColor defines the Color3 object where to store the linear space version
  6372. * @returns the unmodified Color3
  6373. */
  6374. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6375. /**
  6376. * Computes a new Color3 converted from the current one to gamma space
  6377. * @returns a new Color3 object
  6378. */
  6379. toGammaSpace(): Color3;
  6380. /**
  6381. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6382. * @param convertedColor defines the Color3 object where to store the gamma space version
  6383. * @returns the unmodified Color3
  6384. */
  6385. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6386. private static _BlackReadOnly;
  6387. /**
  6388. * Convert Hue, saturation and value to a Color3 (RGB)
  6389. * @param hue defines the hue
  6390. * @param saturation defines the saturation
  6391. * @param value defines the value
  6392. * @param result defines the Color3 where to store the RGB values
  6393. */
  6394. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6395. /**
  6396. * Creates a new Color3 from the string containing valid hexadecimal values
  6397. * @param hex defines a string containing valid hexadecimal values
  6398. * @returns a new Color3 object
  6399. */
  6400. static FromHexString(hex: string): Color3;
  6401. /**
  6402. * Creates a new Color3 from the starting index of the given array
  6403. * @param array defines the source array
  6404. * @param offset defines an offset in the source array
  6405. * @returns a new Color3 object
  6406. */
  6407. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6408. /**
  6409. * Creates a new Color3 from the starting index element of the given array
  6410. * @param array defines the source array to read from
  6411. * @param offset defines the offset in the source array
  6412. * @param result defines the target Color3 object
  6413. */
  6414. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6415. /**
  6416. * Creates a new Color3 from integer values (< 256)
  6417. * @param r defines the red component to read from (value between 0 and 255)
  6418. * @param g defines the green component to read from (value between 0 and 255)
  6419. * @param b defines the blue component to read from (value between 0 and 255)
  6420. * @returns a new Color3 object
  6421. */
  6422. static FromInts(r: number, g: number, b: number): Color3;
  6423. /**
  6424. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6425. * @param start defines the start Color3 value
  6426. * @param end defines the end Color3 value
  6427. * @param amount defines the gradient value between start and end
  6428. * @returns a new Color3 object
  6429. */
  6430. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6431. /**
  6432. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6433. * @param left defines the start value
  6434. * @param right defines the end value
  6435. * @param amount defines the gradient factor
  6436. * @param result defines the Color3 object where to store the result
  6437. */
  6438. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6439. /**
  6440. * Returns a Color3 value containing a red color
  6441. * @returns a new Color3 object
  6442. */
  6443. static Red(): Color3;
  6444. /**
  6445. * Returns a Color3 value containing a green color
  6446. * @returns a new Color3 object
  6447. */
  6448. static Green(): Color3;
  6449. /**
  6450. * Returns a Color3 value containing a blue color
  6451. * @returns a new Color3 object
  6452. */
  6453. static Blue(): Color3;
  6454. /**
  6455. * Returns a Color3 value containing a black color
  6456. * @returns a new Color3 object
  6457. */
  6458. static Black(): Color3;
  6459. /**
  6460. * Gets a Color3 value containing a black color that must not be updated
  6461. */
  6462. static get BlackReadOnly(): DeepImmutable<Color3>;
  6463. /**
  6464. * Returns a Color3 value containing a white color
  6465. * @returns a new Color3 object
  6466. */
  6467. static White(): Color3;
  6468. /**
  6469. * Returns a Color3 value containing a purple color
  6470. * @returns a new Color3 object
  6471. */
  6472. static Purple(): Color3;
  6473. /**
  6474. * Returns a Color3 value containing a magenta color
  6475. * @returns a new Color3 object
  6476. */
  6477. static Magenta(): Color3;
  6478. /**
  6479. * Returns a Color3 value containing a yellow color
  6480. * @returns a new Color3 object
  6481. */
  6482. static Yellow(): Color3;
  6483. /**
  6484. * Returns a Color3 value containing a gray color
  6485. * @returns a new Color3 object
  6486. */
  6487. static Gray(): Color3;
  6488. /**
  6489. * Returns a Color3 value containing a teal color
  6490. * @returns a new Color3 object
  6491. */
  6492. static Teal(): Color3;
  6493. /**
  6494. * Returns a Color3 value containing a random color
  6495. * @returns a new Color3 object
  6496. */
  6497. static Random(): Color3;
  6498. }
  6499. /**
  6500. * Class used to hold a RBGA color
  6501. */
  6502. export class Color4 {
  6503. /**
  6504. * Defines the red component (between 0 and 1, default is 0)
  6505. */
  6506. r: number;
  6507. /**
  6508. * Defines the green component (between 0 and 1, default is 0)
  6509. */
  6510. g: number;
  6511. /**
  6512. * Defines the blue component (between 0 and 1, default is 0)
  6513. */
  6514. b: number;
  6515. /**
  6516. * Defines the alpha component (between 0 and 1, default is 1)
  6517. */
  6518. a: number;
  6519. /**
  6520. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6521. * @param r defines the red component (between 0 and 1, default is 0)
  6522. * @param g defines the green component (between 0 and 1, default is 0)
  6523. * @param b defines the blue component (between 0 and 1, default is 0)
  6524. * @param a defines the alpha component (between 0 and 1, default is 1)
  6525. */
  6526. constructor(
  6527. /**
  6528. * Defines the red component (between 0 and 1, default is 0)
  6529. */
  6530. r?: number,
  6531. /**
  6532. * Defines the green component (between 0 and 1, default is 0)
  6533. */
  6534. g?: number,
  6535. /**
  6536. * Defines the blue component (between 0 and 1, default is 0)
  6537. */
  6538. b?: number,
  6539. /**
  6540. * Defines the alpha component (between 0 and 1, default is 1)
  6541. */
  6542. a?: number);
  6543. /**
  6544. * Adds in place the given Color4 values to the current Color4 object
  6545. * @param right defines the second operand
  6546. * @returns the current updated Color4 object
  6547. */
  6548. addInPlace(right: DeepImmutable<Color4>): Color4;
  6549. /**
  6550. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6551. * @returns the new array
  6552. */
  6553. asArray(): number[];
  6554. /**
  6555. * Stores from the starting index in the given array the Color4 successive values
  6556. * @param array defines the array where to store the r,g,b components
  6557. * @param index defines an optional index in the target array to define where to start storing values
  6558. * @returns the current Color4 object
  6559. */
  6560. toArray(array: number[], index?: number): Color4;
  6561. /**
  6562. * Update the current color with values stored in an array from the starting index of the given array
  6563. * @param array defines the source array
  6564. * @param offset defines an offset in the source array
  6565. * @returns the current Color4 object
  6566. */
  6567. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6568. /**
  6569. * Determines equality between Color4 objects
  6570. * @param otherColor defines the second operand
  6571. * @returns true if the rgba values are equal to the given ones
  6572. */
  6573. equals(otherColor: DeepImmutable<Color4>): boolean;
  6574. /**
  6575. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6576. * @param right defines the second operand
  6577. * @returns a new Color4 object
  6578. */
  6579. add(right: DeepImmutable<Color4>): Color4;
  6580. /**
  6581. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6582. * @param right defines the second operand
  6583. * @returns a new Color4 object
  6584. */
  6585. subtract(right: DeepImmutable<Color4>): Color4;
  6586. /**
  6587. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6588. * @param right defines the second operand
  6589. * @param result defines the Color4 object where to store the result
  6590. * @returns the current Color4 object
  6591. */
  6592. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6593. /**
  6594. * Creates a new Color4 with the current Color4 values multiplied by scale
  6595. * @param scale defines the scaling factor to apply
  6596. * @returns a new Color4 object
  6597. */
  6598. scale(scale: number): Color4;
  6599. /**
  6600. * Multiplies the current Color4 values by scale and stores the result in "result"
  6601. * @param scale defines the scaling factor to apply
  6602. * @param result defines the Color4 object where to store the result
  6603. * @returns the current unmodified Color4
  6604. */
  6605. scaleToRef(scale: number, result: Color4): Color4;
  6606. /**
  6607. * Scale the current Color4 values by a factor and add the result to a given Color4
  6608. * @param scale defines the scale factor
  6609. * @param result defines the Color4 object where to store the result
  6610. * @returns the unmodified current Color4
  6611. */
  6612. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6613. /**
  6614. * Clamps the rgb values by the min and max values and stores the result into "result"
  6615. * @param min defines minimum clamping value (default is 0)
  6616. * @param max defines maximum clamping value (default is 1)
  6617. * @param result defines color to store the result into.
  6618. * @returns the cuurent Color4
  6619. */
  6620. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6621. /**
  6622. * Multipy an Color4 value by another and return a new Color4 object
  6623. * @param color defines the Color4 value to multiply by
  6624. * @returns a new Color4 object
  6625. */
  6626. multiply(color: Color4): Color4;
  6627. /**
  6628. * Multipy a Color4 value by another and push the result in a reference value
  6629. * @param color defines the Color4 value to multiply by
  6630. * @param result defines the Color4 to fill the result in
  6631. * @returns the result Color4
  6632. */
  6633. multiplyToRef(color: Color4, result: Color4): Color4;
  6634. /**
  6635. * Creates a string with the Color4 current values
  6636. * @returns the string representation of the Color4 object
  6637. */
  6638. toString(): string;
  6639. /**
  6640. * Returns the string "Color4"
  6641. * @returns "Color4"
  6642. */
  6643. getClassName(): string;
  6644. /**
  6645. * Compute the Color4 hash code
  6646. * @returns an unique number that can be used to hash Color4 objects
  6647. */
  6648. getHashCode(): number;
  6649. /**
  6650. * Creates a new Color4 copied from the current one
  6651. * @returns a new Color4 object
  6652. */
  6653. clone(): Color4;
  6654. /**
  6655. * Copies the given Color4 values into the current one
  6656. * @param source defines the source Color4 object
  6657. * @returns the current updated Color4 object
  6658. */
  6659. copyFrom(source: Color4): Color4;
  6660. /**
  6661. * Copies the given float values into the current one
  6662. * @param r defines the red component to read from
  6663. * @param g defines the green component to read from
  6664. * @param b defines the blue component to read from
  6665. * @param a defines the alpha component to read from
  6666. * @returns the current updated Color4 object
  6667. */
  6668. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6669. /**
  6670. * Copies the given float values into the current one
  6671. * @param r defines the red component to read from
  6672. * @param g defines the green component to read from
  6673. * @param b defines the blue component to read from
  6674. * @param a defines the alpha component to read from
  6675. * @returns the current updated Color4 object
  6676. */
  6677. set(r: number, g: number, b: number, a: number): Color4;
  6678. /**
  6679. * Compute the Color4 hexadecimal code as a string
  6680. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6681. * @returns a string containing the hexadecimal representation of the Color4 object
  6682. */
  6683. toHexString(returnAsColor3?: boolean): string;
  6684. /**
  6685. * Computes a new Color4 converted from the current one to linear space
  6686. * @returns a new Color4 object
  6687. */
  6688. toLinearSpace(): Color4;
  6689. /**
  6690. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6691. * @param convertedColor defines the Color4 object where to store the linear space version
  6692. * @returns the unmodified Color4
  6693. */
  6694. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6695. /**
  6696. * Computes a new Color4 converted from the current one to gamma space
  6697. * @returns a new Color4 object
  6698. */
  6699. toGammaSpace(): Color4;
  6700. /**
  6701. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6702. * @param convertedColor defines the Color4 object where to store the gamma space version
  6703. * @returns the unmodified Color4
  6704. */
  6705. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6706. /**
  6707. * Creates a new Color4 from the string containing valid hexadecimal values
  6708. * @param hex defines a string containing valid hexadecimal values
  6709. * @returns a new Color4 object
  6710. */
  6711. static FromHexString(hex: string): Color4;
  6712. /**
  6713. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6714. * @param left defines the start value
  6715. * @param right defines the end value
  6716. * @param amount defines the gradient factor
  6717. * @returns a new Color4 object
  6718. */
  6719. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6720. /**
  6721. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6722. * @param left defines the start value
  6723. * @param right defines the end value
  6724. * @param amount defines the gradient factor
  6725. * @param result defines the Color4 object where to store data
  6726. */
  6727. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6728. /**
  6729. * Creates a new Color4 from a Color3 and an alpha value
  6730. * @param color3 defines the source Color3 to read from
  6731. * @param alpha defines the alpha component (1.0 by default)
  6732. * @returns a new Color4 object
  6733. */
  6734. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6735. /**
  6736. * Creates a new Color4 from the starting index element of the given array
  6737. * @param array defines the source array to read from
  6738. * @param offset defines the offset in the source array
  6739. * @returns a new Color4 object
  6740. */
  6741. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6742. /**
  6743. * Creates a new Color4 from the starting index element of the given array
  6744. * @param array defines the source array to read from
  6745. * @param offset defines the offset in the source array
  6746. * @param result defines the target Color4 object
  6747. */
  6748. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6749. /**
  6750. * Creates a new Color3 from integer values (< 256)
  6751. * @param r defines the red component to read from (value between 0 and 255)
  6752. * @param g defines the green component to read from (value between 0 and 255)
  6753. * @param b defines the blue component to read from (value between 0 and 255)
  6754. * @param a defines the alpha component to read from (value between 0 and 255)
  6755. * @returns a new Color3 object
  6756. */
  6757. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6758. /**
  6759. * Check the content of a given array and convert it to an array containing RGBA data
  6760. * If the original array was already containing count * 4 values then it is returned directly
  6761. * @param colors defines the array to check
  6762. * @param count defines the number of RGBA data to expect
  6763. * @returns an array containing count * 4 values (RGBA)
  6764. */
  6765. static CheckColors4(colors: number[], count: number): number[];
  6766. }
  6767. /**
  6768. * @hidden
  6769. */
  6770. export class TmpColors {
  6771. static Color3: Color3[];
  6772. static Color4: Color4[];
  6773. }
  6774. }
  6775. declare module BABYLON {
  6776. /**
  6777. * Defines an interface which represents an animation key frame
  6778. */
  6779. export interface IAnimationKey {
  6780. /**
  6781. * Frame of the key frame
  6782. */
  6783. frame: number;
  6784. /**
  6785. * Value at the specifies key frame
  6786. */
  6787. value: any;
  6788. /**
  6789. * The input tangent for the cubic hermite spline
  6790. */
  6791. inTangent?: any;
  6792. /**
  6793. * The output tangent for the cubic hermite spline
  6794. */
  6795. outTangent?: any;
  6796. /**
  6797. * The animation interpolation type
  6798. */
  6799. interpolation?: AnimationKeyInterpolation;
  6800. }
  6801. /**
  6802. * Enum for the animation key frame interpolation type
  6803. */
  6804. export enum AnimationKeyInterpolation {
  6805. /**
  6806. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6807. */
  6808. STEP = 1
  6809. }
  6810. }
  6811. declare module BABYLON {
  6812. /**
  6813. * Represents the range of an animation
  6814. */
  6815. export class AnimationRange {
  6816. /**The name of the animation range**/
  6817. name: string;
  6818. /**The starting frame of the animation */
  6819. from: number;
  6820. /**The ending frame of the animation*/
  6821. to: number;
  6822. /**
  6823. * Initializes the range of an animation
  6824. * @param name The name of the animation range
  6825. * @param from The starting frame of the animation
  6826. * @param to The ending frame of the animation
  6827. */
  6828. constructor(
  6829. /**The name of the animation range**/
  6830. name: string,
  6831. /**The starting frame of the animation */
  6832. from: number,
  6833. /**The ending frame of the animation*/
  6834. to: number);
  6835. /**
  6836. * Makes a copy of the animation range
  6837. * @returns A copy of the animation range
  6838. */
  6839. clone(): AnimationRange;
  6840. }
  6841. }
  6842. declare module BABYLON {
  6843. /**
  6844. * Composed of a frame, and an action function
  6845. */
  6846. export class AnimationEvent {
  6847. /** The frame for which the event is triggered **/
  6848. frame: number;
  6849. /** The event to perform when triggered **/
  6850. action: (currentFrame: number) => void;
  6851. /** Specifies if the event should be triggered only once**/
  6852. onlyOnce?: boolean | undefined;
  6853. /**
  6854. * Specifies if the animation event is done
  6855. */
  6856. isDone: boolean;
  6857. /**
  6858. * Initializes the animation event
  6859. * @param frame The frame for which the event is triggered
  6860. * @param action The event to perform when triggered
  6861. * @param onlyOnce Specifies if the event should be triggered only once
  6862. */
  6863. constructor(
  6864. /** The frame for which the event is triggered **/
  6865. frame: number,
  6866. /** The event to perform when triggered **/
  6867. action: (currentFrame: number) => void,
  6868. /** Specifies if the event should be triggered only once**/
  6869. onlyOnce?: boolean | undefined);
  6870. /** @hidden */
  6871. _clone(): AnimationEvent;
  6872. }
  6873. }
  6874. declare module BABYLON {
  6875. /**
  6876. * Interface used to define a behavior
  6877. */
  6878. export interface Behavior<T> {
  6879. /** gets or sets behavior's name */
  6880. name: string;
  6881. /**
  6882. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6883. */
  6884. init(): void;
  6885. /**
  6886. * Called when the behavior is attached to a target
  6887. * @param target defines the target where the behavior is attached to
  6888. */
  6889. attach(target: T): void;
  6890. /**
  6891. * Called when the behavior is detached from its target
  6892. */
  6893. detach(): void;
  6894. }
  6895. /**
  6896. * Interface implemented by classes supporting behaviors
  6897. */
  6898. export interface IBehaviorAware<T> {
  6899. /**
  6900. * Attach a behavior
  6901. * @param behavior defines the behavior to attach
  6902. * @returns the current host
  6903. */
  6904. addBehavior(behavior: Behavior<T>): T;
  6905. /**
  6906. * Remove a behavior from the current object
  6907. * @param behavior defines the behavior to detach
  6908. * @returns the current host
  6909. */
  6910. removeBehavior(behavior: Behavior<T>): T;
  6911. /**
  6912. * Gets a behavior using its name to search
  6913. * @param name defines the name to search
  6914. * @returns the behavior or null if not found
  6915. */
  6916. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6917. }
  6918. }
  6919. declare module BABYLON {
  6920. /**
  6921. * Class used to store data that will be store in GPU memory
  6922. */
  6923. export class Buffer {
  6924. private _engine;
  6925. private _buffer;
  6926. /** @hidden */
  6927. _data: Nullable<DataArray>;
  6928. private _updatable;
  6929. private _instanced;
  6930. private _divisor;
  6931. private _isAlreadyOwned;
  6932. /**
  6933. * Gets the byte stride.
  6934. */
  6935. readonly byteStride: number;
  6936. /**
  6937. * Constructor
  6938. * @param engine the engine
  6939. * @param data the data to use for this buffer
  6940. * @param updatable whether the data is updatable
  6941. * @param stride the stride (optional)
  6942. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6943. * @param instanced whether the buffer is instanced (optional)
  6944. * @param useBytes set to true if the stride in in bytes (optional)
  6945. * @param divisor sets an optional divisor for instances (1 by default)
  6946. */
  6947. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6948. /**
  6949. * Create a new VertexBuffer based on the current buffer
  6950. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6951. * @param offset defines offset in the buffer (0 by default)
  6952. * @param size defines the size in floats of attributes (position is 3 for instance)
  6953. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6954. * @param instanced defines if the vertex buffer contains indexed data
  6955. * @param useBytes defines if the offset and stride are in bytes *
  6956. * @param divisor sets an optional divisor for instances (1 by default)
  6957. * @returns the new vertex buffer
  6958. */
  6959. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6960. /**
  6961. * Gets a boolean indicating if the Buffer is updatable?
  6962. * @returns true if the buffer is updatable
  6963. */
  6964. isUpdatable(): boolean;
  6965. /**
  6966. * Gets current buffer's data
  6967. * @returns a DataArray or null
  6968. */
  6969. getData(): Nullable<DataArray>;
  6970. /**
  6971. * Gets underlying native buffer
  6972. * @returns underlying native buffer
  6973. */
  6974. getBuffer(): Nullable<DataBuffer>;
  6975. /**
  6976. * Gets the stride in float32 units (i.e. byte stride / 4).
  6977. * May not be an integer if the byte stride is not divisible by 4.
  6978. * @returns the stride in float32 units
  6979. * @deprecated Please use byteStride instead.
  6980. */
  6981. getStrideSize(): number;
  6982. /**
  6983. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6984. * @param data defines the data to store
  6985. */
  6986. create(data?: Nullable<DataArray>): void;
  6987. /** @hidden */
  6988. _rebuild(): void;
  6989. /**
  6990. * Update current buffer data
  6991. * @param data defines the data to store
  6992. */
  6993. update(data: DataArray): void;
  6994. /**
  6995. * Updates the data directly.
  6996. * @param data the new data
  6997. * @param offset the new offset
  6998. * @param vertexCount the vertex count (optional)
  6999. * @param useBytes set to true if the offset is in bytes
  7000. */
  7001. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  7002. /** @hidden */
  7003. _increaseReferences(): void;
  7004. /**
  7005. * Release all resources
  7006. */
  7007. dispose(): void;
  7008. }
  7009. /**
  7010. * Specialized buffer used to store vertex data
  7011. */
  7012. export class VertexBuffer {
  7013. /** @hidden */
  7014. _buffer: Buffer;
  7015. private _kind;
  7016. private _size;
  7017. private _ownsBuffer;
  7018. private _instanced;
  7019. private _instanceDivisor;
  7020. /**
  7021. * The byte type.
  7022. */
  7023. static readonly BYTE: number;
  7024. /**
  7025. * The unsigned byte type.
  7026. */
  7027. static readonly UNSIGNED_BYTE: number;
  7028. /**
  7029. * The short type.
  7030. */
  7031. static readonly SHORT: number;
  7032. /**
  7033. * The unsigned short type.
  7034. */
  7035. static readonly UNSIGNED_SHORT: number;
  7036. /**
  7037. * The integer type.
  7038. */
  7039. static readonly INT: number;
  7040. /**
  7041. * The unsigned integer type.
  7042. */
  7043. static readonly UNSIGNED_INT: number;
  7044. /**
  7045. * The float type.
  7046. */
  7047. static readonly FLOAT: number;
  7048. /**
  7049. * Gets or sets the instance divisor when in instanced mode
  7050. */
  7051. get instanceDivisor(): number;
  7052. set instanceDivisor(value: number);
  7053. /**
  7054. * Gets the byte stride.
  7055. */
  7056. readonly byteStride: number;
  7057. /**
  7058. * Gets the byte offset.
  7059. */
  7060. readonly byteOffset: number;
  7061. /**
  7062. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  7063. */
  7064. readonly normalized: boolean;
  7065. /**
  7066. * Gets the data type of each component in the array.
  7067. */
  7068. readonly type: number;
  7069. /**
  7070. * Constructor
  7071. * @param engine the engine
  7072. * @param data the data to use for this vertex buffer
  7073. * @param kind the vertex buffer kind
  7074. * @param updatable whether the data is updatable
  7075. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  7076. * @param stride the stride (optional)
  7077. * @param instanced whether the buffer is instanced (optional)
  7078. * @param offset the offset of the data (optional)
  7079. * @param size the number of components (optional)
  7080. * @param type the type of the component (optional)
  7081. * @param normalized whether the data contains normalized data (optional)
  7082. * @param useBytes set to true if stride and offset are in bytes (optional)
  7083. * @param divisor defines the instance divisor to use (1 by default)
  7084. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  7085. */
  7086. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number, takeBufferOwnership?: boolean);
  7087. /** @hidden */
  7088. _rebuild(): void;
  7089. /**
  7090. * Returns the kind of the VertexBuffer (string)
  7091. * @returns a string
  7092. */
  7093. getKind(): string;
  7094. /**
  7095. * Gets a boolean indicating if the VertexBuffer is updatable?
  7096. * @returns true if the buffer is updatable
  7097. */
  7098. isUpdatable(): boolean;
  7099. /**
  7100. * Gets current buffer's data
  7101. * @returns a DataArray or null
  7102. */
  7103. getData(): Nullable<DataArray>;
  7104. /**
  7105. * Gets underlying native buffer
  7106. * @returns underlying native buffer
  7107. */
  7108. getBuffer(): Nullable<DataBuffer>;
  7109. /**
  7110. * Gets the stride in float32 units (i.e. byte stride / 4).
  7111. * May not be an integer if the byte stride is not divisible by 4.
  7112. * @returns the stride in float32 units
  7113. * @deprecated Please use byteStride instead.
  7114. */
  7115. getStrideSize(): number;
  7116. /**
  7117. * Returns the offset as a multiple of the type byte length.
  7118. * @returns the offset in bytes
  7119. * @deprecated Please use byteOffset instead.
  7120. */
  7121. getOffset(): number;
  7122. /**
  7123. * Returns the number of components per vertex attribute (integer)
  7124. * @returns the size in float
  7125. */
  7126. getSize(): number;
  7127. /**
  7128. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  7129. * @returns true if this buffer is instanced
  7130. */
  7131. getIsInstanced(): boolean;
  7132. /**
  7133. * Returns the instancing divisor, zero for non-instanced (integer).
  7134. * @returns a number
  7135. */
  7136. getInstanceDivisor(): number;
  7137. /**
  7138. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7139. * @param data defines the data to store
  7140. */
  7141. create(data?: DataArray): void;
  7142. /**
  7143. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  7144. * This function will create a new buffer if the current one is not updatable
  7145. * @param data defines the data to store
  7146. */
  7147. update(data: DataArray): void;
  7148. /**
  7149. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  7150. * Returns the directly updated WebGLBuffer.
  7151. * @param data the new data
  7152. * @param offset the new offset
  7153. * @param useBytes set to true if the offset is in bytes
  7154. */
  7155. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  7156. /**
  7157. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  7158. */
  7159. dispose(): void;
  7160. /**
  7161. * Enumerates each value of this vertex buffer as numbers.
  7162. * @param count the number of values to enumerate
  7163. * @param callback the callback function called for each value
  7164. */
  7165. forEach(count: number, callback: (value: number, index: number) => void): void;
  7166. /**
  7167. * Positions
  7168. */
  7169. static readonly PositionKind: string;
  7170. /**
  7171. * Normals
  7172. */
  7173. static readonly NormalKind: string;
  7174. /**
  7175. * Tangents
  7176. */
  7177. static readonly TangentKind: string;
  7178. /**
  7179. * Texture coordinates
  7180. */
  7181. static readonly UVKind: string;
  7182. /**
  7183. * Texture coordinates 2
  7184. */
  7185. static readonly UV2Kind: string;
  7186. /**
  7187. * Texture coordinates 3
  7188. */
  7189. static readonly UV3Kind: string;
  7190. /**
  7191. * Texture coordinates 4
  7192. */
  7193. static readonly UV4Kind: string;
  7194. /**
  7195. * Texture coordinates 5
  7196. */
  7197. static readonly UV5Kind: string;
  7198. /**
  7199. * Texture coordinates 6
  7200. */
  7201. static readonly UV6Kind: string;
  7202. /**
  7203. * Colors
  7204. */
  7205. static readonly ColorKind: string;
  7206. /**
  7207. * Matrix indices (for bones)
  7208. */
  7209. static readonly MatricesIndicesKind: string;
  7210. /**
  7211. * Matrix weights (for bones)
  7212. */
  7213. static readonly MatricesWeightsKind: string;
  7214. /**
  7215. * Additional matrix indices (for bones)
  7216. */
  7217. static readonly MatricesIndicesExtraKind: string;
  7218. /**
  7219. * Additional matrix weights (for bones)
  7220. */
  7221. static readonly MatricesWeightsExtraKind: string;
  7222. /**
  7223. * Deduces the stride given a kind.
  7224. * @param kind The kind string to deduce
  7225. * @returns The deduced stride
  7226. */
  7227. static DeduceStride(kind: string): number;
  7228. /**
  7229. * Gets the byte length of the given type.
  7230. * @param type the type
  7231. * @returns the number of bytes
  7232. */
  7233. static GetTypeByteLength(type: number): number;
  7234. /**
  7235. * Enumerates each value of the given parameters as numbers.
  7236. * @param data the data to enumerate
  7237. * @param byteOffset the byte offset of the data
  7238. * @param byteStride the byte stride of the data
  7239. * @param componentCount the number of components per element
  7240. * @param componentType the type of the component
  7241. * @param count the number of values to enumerate
  7242. * @param normalized whether the data is normalized
  7243. * @param callback the callback function called for each value
  7244. */
  7245. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  7246. private static _GetFloatValue;
  7247. }
  7248. }
  7249. declare module BABYLON {
  7250. /**
  7251. * @hidden
  7252. */
  7253. export class IntersectionInfo {
  7254. bu: Nullable<number>;
  7255. bv: Nullable<number>;
  7256. distance: number;
  7257. faceId: number;
  7258. subMeshId: number;
  7259. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7260. }
  7261. }
  7262. declare module BABYLON {
  7263. /**
  7264. * Class used to store bounding sphere information
  7265. */
  7266. export class BoundingSphere {
  7267. /**
  7268. * Gets the center of the bounding sphere in local space
  7269. */
  7270. readonly center: Vector3;
  7271. /**
  7272. * Radius of the bounding sphere in local space
  7273. */
  7274. radius: number;
  7275. /**
  7276. * Gets the center of the bounding sphere in world space
  7277. */
  7278. readonly centerWorld: Vector3;
  7279. /**
  7280. * Radius of the bounding sphere in world space
  7281. */
  7282. radiusWorld: number;
  7283. /**
  7284. * Gets the minimum vector in local space
  7285. */
  7286. readonly minimum: Vector3;
  7287. /**
  7288. * Gets the maximum vector in local space
  7289. */
  7290. readonly maximum: Vector3;
  7291. private _worldMatrix;
  7292. private static readonly TmpVector3;
  7293. /**
  7294. * Creates a new bounding sphere
  7295. * @param min defines the minimum vector (in local space)
  7296. * @param max defines the maximum vector (in local space)
  7297. * @param worldMatrix defines the new world matrix
  7298. */
  7299. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7300. /**
  7301. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7302. * @param min defines the new minimum vector (in local space)
  7303. * @param max defines the new maximum vector (in local space)
  7304. * @param worldMatrix defines the new world matrix
  7305. */
  7306. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7307. /**
  7308. * Scale the current bounding sphere by applying a scale factor
  7309. * @param factor defines the scale factor to apply
  7310. * @returns the current bounding box
  7311. */
  7312. scale(factor: number): BoundingSphere;
  7313. /**
  7314. * Gets the world matrix of the bounding box
  7315. * @returns a matrix
  7316. */
  7317. getWorldMatrix(): DeepImmutable<Matrix>;
  7318. /** @hidden */
  7319. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7320. /**
  7321. * Tests if the bounding sphere is intersecting the frustum planes
  7322. * @param frustumPlanes defines the frustum planes to test
  7323. * @returns true if there is an intersection
  7324. */
  7325. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7326. /**
  7327. * Tests if the bounding sphere center is in between the frustum planes.
  7328. * Used for optimistic fast inclusion.
  7329. * @param frustumPlanes defines the frustum planes to test
  7330. * @returns true if the sphere center is in between the frustum planes
  7331. */
  7332. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7333. /**
  7334. * Tests if a point is inside the bounding sphere
  7335. * @param point defines the point to test
  7336. * @returns true if the point is inside the bounding sphere
  7337. */
  7338. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7339. /**
  7340. * Checks if two sphere intersct
  7341. * @param sphere0 sphere 0
  7342. * @param sphere1 sphere 1
  7343. * @returns true if the speres intersect
  7344. */
  7345. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7346. }
  7347. }
  7348. declare module BABYLON {
  7349. /**
  7350. * Class used to store bounding box information
  7351. */
  7352. export class BoundingBox implements ICullable {
  7353. /**
  7354. * Gets the 8 vectors representing the bounding box in local space
  7355. */
  7356. readonly vectors: Vector3[];
  7357. /**
  7358. * Gets the center of the bounding box in local space
  7359. */
  7360. readonly center: Vector3;
  7361. /**
  7362. * Gets the center of the bounding box in world space
  7363. */
  7364. readonly centerWorld: Vector3;
  7365. /**
  7366. * Gets the extend size in local space
  7367. */
  7368. readonly extendSize: Vector3;
  7369. /**
  7370. * Gets the extend size in world space
  7371. */
  7372. readonly extendSizeWorld: Vector3;
  7373. /**
  7374. * Gets the OBB (object bounding box) directions
  7375. */
  7376. readonly directions: Vector3[];
  7377. /**
  7378. * Gets the 8 vectors representing the bounding box in world space
  7379. */
  7380. readonly vectorsWorld: Vector3[];
  7381. /**
  7382. * Gets the minimum vector in world space
  7383. */
  7384. readonly minimumWorld: Vector3;
  7385. /**
  7386. * Gets the maximum vector in world space
  7387. */
  7388. readonly maximumWorld: Vector3;
  7389. /**
  7390. * Gets the minimum vector in local space
  7391. */
  7392. readonly minimum: Vector3;
  7393. /**
  7394. * Gets the maximum vector in local space
  7395. */
  7396. readonly maximum: Vector3;
  7397. private _worldMatrix;
  7398. private static readonly TmpVector3;
  7399. /**
  7400. * @hidden
  7401. */
  7402. _tag: number;
  7403. /**
  7404. * Creates a new bounding box
  7405. * @param min defines the minimum vector (in local space)
  7406. * @param max defines the maximum vector (in local space)
  7407. * @param worldMatrix defines the new world matrix
  7408. */
  7409. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7410. /**
  7411. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7412. * @param min defines the new minimum vector (in local space)
  7413. * @param max defines the new maximum vector (in local space)
  7414. * @param worldMatrix defines the new world matrix
  7415. */
  7416. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7417. /**
  7418. * Scale the current bounding box by applying a scale factor
  7419. * @param factor defines the scale factor to apply
  7420. * @returns the current bounding box
  7421. */
  7422. scale(factor: number): BoundingBox;
  7423. /**
  7424. * Gets the world matrix of the bounding box
  7425. * @returns a matrix
  7426. */
  7427. getWorldMatrix(): DeepImmutable<Matrix>;
  7428. /** @hidden */
  7429. _update(world: DeepImmutable<Matrix>): void;
  7430. /**
  7431. * Tests if the bounding box is intersecting the frustum planes
  7432. * @param frustumPlanes defines the frustum planes to test
  7433. * @returns true if there is an intersection
  7434. */
  7435. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7436. /**
  7437. * Tests if the bounding box is entirely inside the frustum planes
  7438. * @param frustumPlanes defines the frustum planes to test
  7439. * @returns true if there is an inclusion
  7440. */
  7441. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7442. /**
  7443. * Tests if a point is inside the bounding box
  7444. * @param point defines the point to test
  7445. * @returns true if the point is inside the bounding box
  7446. */
  7447. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7448. /**
  7449. * Tests if the bounding box intersects with a bounding sphere
  7450. * @param sphere defines the sphere to test
  7451. * @returns true if there is an intersection
  7452. */
  7453. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7454. /**
  7455. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7456. * @param min defines the min vector to use
  7457. * @param max defines the max vector to use
  7458. * @returns true if there is an intersection
  7459. */
  7460. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7461. /**
  7462. * Tests if two bounding boxes are intersections
  7463. * @param box0 defines the first box to test
  7464. * @param box1 defines the second box to test
  7465. * @returns true if there is an intersection
  7466. */
  7467. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7468. /**
  7469. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7470. * @param minPoint defines the minimum vector of the bounding box
  7471. * @param maxPoint defines the maximum vector of the bounding box
  7472. * @param sphereCenter defines the sphere center
  7473. * @param sphereRadius defines the sphere radius
  7474. * @returns true if there is an intersection
  7475. */
  7476. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7477. /**
  7478. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7479. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7480. * @param frustumPlanes defines the frustum planes to test
  7481. * @return true if there is an inclusion
  7482. */
  7483. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7484. /**
  7485. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7486. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7487. * @param frustumPlanes defines the frustum planes to test
  7488. * @return true if there is an intersection
  7489. */
  7490. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7491. }
  7492. }
  7493. declare module BABYLON {
  7494. /** @hidden */
  7495. export class Collider {
  7496. /** Define if a collision was found */
  7497. collisionFound: boolean;
  7498. /**
  7499. * Define last intersection point in local space
  7500. */
  7501. intersectionPoint: Vector3;
  7502. /**
  7503. * Define last collided mesh
  7504. */
  7505. collidedMesh: Nullable<AbstractMesh>;
  7506. private _collisionPoint;
  7507. private _planeIntersectionPoint;
  7508. private _tempVector;
  7509. private _tempVector2;
  7510. private _tempVector3;
  7511. private _tempVector4;
  7512. private _edge;
  7513. private _baseToVertex;
  7514. private _destinationPoint;
  7515. private _slidePlaneNormal;
  7516. private _displacementVector;
  7517. /** @hidden */
  7518. _radius: Vector3;
  7519. /** @hidden */
  7520. _retry: number;
  7521. private _velocity;
  7522. private _basePoint;
  7523. private _epsilon;
  7524. /** @hidden */
  7525. _velocityWorldLength: number;
  7526. /** @hidden */
  7527. _basePointWorld: Vector3;
  7528. private _velocityWorld;
  7529. private _normalizedVelocity;
  7530. /** @hidden */
  7531. _initialVelocity: Vector3;
  7532. /** @hidden */
  7533. _initialPosition: Vector3;
  7534. private _nearestDistance;
  7535. private _collisionMask;
  7536. get collisionMask(): number;
  7537. set collisionMask(mask: number);
  7538. /**
  7539. * Gets the plane normal used to compute the sliding response (in local space)
  7540. */
  7541. get slidePlaneNormal(): Vector3;
  7542. /** @hidden */
  7543. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7544. /** @hidden */
  7545. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7546. /** @hidden */
  7547. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7548. /** @hidden */
  7549. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7550. /** @hidden */
  7551. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7552. /** @hidden */
  7553. _getResponse(pos: Vector3, vel: Vector3): void;
  7554. }
  7555. }
  7556. declare module BABYLON {
  7557. /**
  7558. * Interface for cullable objects
  7559. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7560. */
  7561. export interface ICullable {
  7562. /**
  7563. * Checks if the object or part of the object is in the frustum
  7564. * @param frustumPlanes Camera near/planes
  7565. * @returns true if the object is in frustum otherwise false
  7566. */
  7567. isInFrustum(frustumPlanes: Plane[]): boolean;
  7568. /**
  7569. * Checks if a cullable object (mesh...) is in the camera frustum
  7570. * Unlike isInFrustum this cheks the full bounding box
  7571. * @param frustumPlanes Camera near/planes
  7572. * @returns true if the object is in frustum otherwise false
  7573. */
  7574. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7575. }
  7576. /**
  7577. * Info for a bounding data of a mesh
  7578. */
  7579. export class BoundingInfo implements ICullable {
  7580. /**
  7581. * Bounding box for the mesh
  7582. */
  7583. readonly boundingBox: BoundingBox;
  7584. /**
  7585. * Bounding sphere for the mesh
  7586. */
  7587. readonly boundingSphere: BoundingSphere;
  7588. private _isLocked;
  7589. private static readonly TmpVector3;
  7590. /**
  7591. * Constructs bounding info
  7592. * @param minimum min vector of the bounding box/sphere
  7593. * @param maximum max vector of the bounding box/sphere
  7594. * @param worldMatrix defines the new world matrix
  7595. */
  7596. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7597. /**
  7598. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7599. * @param min defines the new minimum vector (in local space)
  7600. * @param max defines the new maximum vector (in local space)
  7601. * @param worldMatrix defines the new world matrix
  7602. */
  7603. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7604. /**
  7605. * min vector of the bounding box/sphere
  7606. */
  7607. get minimum(): Vector3;
  7608. /**
  7609. * max vector of the bounding box/sphere
  7610. */
  7611. get maximum(): Vector3;
  7612. /**
  7613. * If the info is locked and won't be updated to avoid perf overhead
  7614. */
  7615. get isLocked(): boolean;
  7616. set isLocked(value: boolean);
  7617. /**
  7618. * Updates the bounding sphere and box
  7619. * @param world world matrix to be used to update
  7620. */
  7621. update(world: DeepImmutable<Matrix>): void;
  7622. /**
  7623. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7624. * @param center New center of the bounding info
  7625. * @param extend New extend of the bounding info
  7626. * @returns the current bounding info
  7627. */
  7628. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7629. /**
  7630. * Scale the current bounding info by applying a scale factor
  7631. * @param factor defines the scale factor to apply
  7632. * @returns the current bounding info
  7633. */
  7634. scale(factor: number): BoundingInfo;
  7635. /**
  7636. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7637. * @param frustumPlanes defines the frustum to test
  7638. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7639. * @returns true if the bounding info is in the frustum planes
  7640. */
  7641. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7642. /**
  7643. * Gets the world distance between the min and max points of the bounding box
  7644. */
  7645. get diagonalLength(): number;
  7646. /**
  7647. * Checks if a cullable object (mesh...) is in the camera frustum
  7648. * Unlike isInFrustum this cheks the full bounding box
  7649. * @param frustumPlanes Camera near/planes
  7650. * @returns true if the object is in frustum otherwise false
  7651. */
  7652. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7653. /** @hidden */
  7654. _checkCollision(collider: Collider): boolean;
  7655. /**
  7656. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7657. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7658. * @param point the point to check intersection with
  7659. * @returns if the point intersects
  7660. */
  7661. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7662. /**
  7663. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7664. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7665. * @param boundingInfo the bounding info to check intersection with
  7666. * @param precise if the intersection should be done using OBB
  7667. * @returns if the bounding info intersects
  7668. */
  7669. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7670. }
  7671. }
  7672. declare module BABYLON {
  7673. /**
  7674. * Extracts minimum and maximum values from a list of indexed positions
  7675. * @param positions defines the positions to use
  7676. * @param indices defines the indices to the positions
  7677. * @param indexStart defines the start index
  7678. * @param indexCount defines the end index
  7679. * @param bias defines bias value to add to the result
  7680. * @return minimum and maximum values
  7681. */
  7682. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7683. minimum: Vector3;
  7684. maximum: Vector3;
  7685. };
  7686. /**
  7687. * Extracts minimum and maximum values from a list of positions
  7688. * @param positions defines the positions to use
  7689. * @param start defines the start index in the positions array
  7690. * @param count defines the number of positions to handle
  7691. * @param bias defines bias value to add to the result
  7692. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7693. * @return minimum and maximum values
  7694. */
  7695. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7696. minimum: Vector3;
  7697. maximum: Vector3;
  7698. };
  7699. }
  7700. declare module BABYLON {
  7701. /**
  7702. * Class used to manipulate GUIDs
  7703. */
  7704. export class GUID {
  7705. /**
  7706. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7707. * Be aware Math.random() could cause collisions, but:
  7708. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  7709. * @returns a pseudo random id
  7710. */
  7711. static RandomId(): string;
  7712. }
  7713. }
  7714. declare module BABYLON {
  7715. /**
  7716. * Base class of all the textures in babylon.
  7717. * It groups all the common properties the materials, post process, lights... might need
  7718. * in order to make a correct use of the texture.
  7719. */
  7720. export class BaseTexture extends ThinTexture implements IAnimatable {
  7721. /**
  7722. * Default anisotropic filtering level for the application.
  7723. * It is set to 4 as a good tradeoff between perf and quality.
  7724. */
  7725. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7726. /**
  7727. * Gets or sets the unique id of the texture
  7728. */
  7729. uniqueId: number;
  7730. /**
  7731. * Define the name of the texture.
  7732. */
  7733. name: string;
  7734. /**
  7735. * Gets or sets an object used to store user defined information.
  7736. */
  7737. metadata: any;
  7738. /**
  7739. * For internal use only. Please do not use.
  7740. */
  7741. reservedDataStore: any;
  7742. private _hasAlpha;
  7743. /**
  7744. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7745. */
  7746. set hasAlpha(value: boolean);
  7747. get hasAlpha(): boolean;
  7748. /**
  7749. * Defines if the alpha value should be determined via the rgb values.
  7750. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7751. */
  7752. getAlphaFromRGB: boolean;
  7753. /**
  7754. * Intensity or strength of the texture.
  7755. * It is commonly used by materials to fine tune the intensity of the texture
  7756. */
  7757. level: number;
  7758. /**
  7759. * Define the UV chanel to use starting from 0 and defaulting to 0.
  7760. * This is part of the texture as textures usually maps to one uv set.
  7761. */
  7762. coordinatesIndex: number;
  7763. protected _coordinatesMode: number;
  7764. /**
  7765. * How a texture is mapped.
  7766. *
  7767. * | Value | Type | Description |
  7768. * | ----- | ----------------------------------- | ----------- |
  7769. * | 0 | EXPLICIT_MODE | |
  7770. * | 1 | SPHERICAL_MODE | |
  7771. * | 2 | PLANAR_MODE | |
  7772. * | 3 | CUBIC_MODE | |
  7773. * | 4 | PROJECTION_MODE | |
  7774. * | 5 | SKYBOX_MODE | |
  7775. * | 6 | INVCUBIC_MODE | |
  7776. * | 7 | EQUIRECTANGULAR_MODE | |
  7777. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7778. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7779. */
  7780. set coordinatesMode(value: number);
  7781. get coordinatesMode(): number;
  7782. /**
  7783. * | Value | Type | Description |
  7784. * | ----- | ------------------ | ----------- |
  7785. * | 0 | CLAMP_ADDRESSMODE | |
  7786. * | 1 | WRAP_ADDRESSMODE | |
  7787. * | 2 | MIRROR_ADDRESSMODE | |
  7788. */
  7789. get wrapU(): number;
  7790. set wrapU(value: number);
  7791. /**
  7792. * | Value | Type | Description |
  7793. * | ----- | ------------------ | ----------- |
  7794. * | 0 | CLAMP_ADDRESSMODE | |
  7795. * | 1 | WRAP_ADDRESSMODE | |
  7796. * | 2 | MIRROR_ADDRESSMODE | |
  7797. */
  7798. get wrapV(): number;
  7799. set wrapV(value: number);
  7800. /**
  7801. * | Value | Type | Description |
  7802. * | ----- | ------------------ | ----------- |
  7803. * | 0 | CLAMP_ADDRESSMODE | |
  7804. * | 1 | WRAP_ADDRESSMODE | |
  7805. * | 2 | MIRROR_ADDRESSMODE | |
  7806. */
  7807. wrapR: number;
  7808. /**
  7809. * With compliant hardware and browser (supporting anisotropic filtering)
  7810. * this defines the level of anisotropic filtering in the texture.
  7811. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7812. */
  7813. anisotropicFilteringLevel: number;
  7814. private _isCube;
  7815. /**
  7816. * Define if the texture is a cube texture or if false a 2d texture.
  7817. */
  7818. get isCube(): boolean;
  7819. set isCube(value: boolean);
  7820. /**
  7821. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7822. */
  7823. get is3D(): boolean;
  7824. set is3D(value: boolean);
  7825. /**
  7826. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7827. */
  7828. get is2DArray(): boolean;
  7829. set is2DArray(value: boolean);
  7830. private _gammaSpace;
  7831. /**
  7832. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7833. * HDR texture are usually stored in linear space.
  7834. * This only impacts the PBR and Background materials
  7835. */
  7836. get gammaSpace(): boolean;
  7837. set gammaSpace(gamma: boolean);
  7838. /**
  7839. * Gets or sets whether or not the texture contains RGBD data.
  7840. */
  7841. get isRGBD(): boolean;
  7842. set isRGBD(value: boolean);
  7843. /**
  7844. * Is Z inverted in the texture (useful in a cube texture).
  7845. */
  7846. invertZ: boolean;
  7847. /**
  7848. * Are mip maps generated for this texture or not.
  7849. */
  7850. get noMipmap(): boolean;
  7851. /**
  7852. * @hidden
  7853. */
  7854. lodLevelInAlpha: boolean;
  7855. /**
  7856. * With prefiltered texture, defined the offset used during the prefiltering steps.
  7857. */
  7858. get lodGenerationOffset(): number;
  7859. set lodGenerationOffset(value: number);
  7860. /**
  7861. * With prefiltered texture, defined the scale used during the prefiltering steps.
  7862. */
  7863. get lodGenerationScale(): number;
  7864. set lodGenerationScale(value: number);
  7865. /**
  7866. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  7867. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  7868. * average roughness values.
  7869. */
  7870. get linearSpecularLOD(): boolean;
  7871. set linearSpecularLOD(value: boolean);
  7872. /**
  7873. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  7874. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  7875. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  7876. */
  7877. get irradianceTexture(): Nullable<BaseTexture>;
  7878. set irradianceTexture(value: Nullable<BaseTexture>);
  7879. /**
  7880. * Define if the texture is a render target.
  7881. */
  7882. isRenderTarget: boolean;
  7883. /**
  7884. * Define the unique id of the texture in the scene.
  7885. */
  7886. get uid(): string;
  7887. /** @hidden */
  7888. _prefiltered: boolean;
  7889. /**
  7890. * Return a string representation of the texture.
  7891. * @returns the texture as a string
  7892. */
  7893. toString(): string;
  7894. /**
  7895. * Get the class name of the texture.
  7896. * @returns "BaseTexture"
  7897. */
  7898. getClassName(): string;
  7899. /**
  7900. * Define the list of animation attached to the texture.
  7901. */
  7902. animations: Animation[];
  7903. /**
  7904. * An event triggered when the texture is disposed.
  7905. */
  7906. onDisposeObservable: Observable<BaseTexture>;
  7907. private _onDisposeObserver;
  7908. /**
  7909. * Callback triggered when the texture has been disposed.
  7910. * Kept for back compatibility, you can use the onDisposeObservable instead.
  7911. */
  7912. set onDispose(callback: () => void);
  7913. protected _scene: Nullable<Scene>;
  7914. /** @hidden */
  7915. _texture: Nullable<InternalTexture>;
  7916. private _uid;
  7917. /**
  7918. * Define if the texture is preventinga material to render or not.
  7919. * If not and the texture is not ready, the engine will use a default black texture instead.
  7920. */
  7921. get isBlocking(): boolean;
  7922. /**
  7923. * Instantiates a new BaseTexture.
  7924. * Base class of all the textures in babylon.
  7925. * It groups all the common properties the materials, post process, lights... might need
  7926. * in order to make a correct use of the texture.
  7927. * @param sceneOrEngine Define the scene or engine the texture blongs to
  7928. */
  7929. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  7930. /**
  7931. * Get the scene the texture belongs to.
  7932. * @returns the scene or null if undefined
  7933. */
  7934. getScene(): Nullable<Scene>;
  7935. /** @hidden */
  7936. protected _getEngine(): Nullable<ThinEngine>;
  7937. /**
  7938. * Checks if the texture has the same transform matrix than another texture
  7939. * @param texture texture to check against
  7940. * @returns true if the transforms are the same, else false
  7941. */
  7942. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  7943. /**
  7944. * Get the texture transform matrix used to offset tile the texture for istance.
  7945. * @returns the transformation matrix
  7946. */
  7947. getTextureMatrix(): Matrix;
  7948. /**
  7949. * Get the texture reflection matrix used to rotate/transform the reflection.
  7950. * @returns the reflection matrix
  7951. */
  7952. getReflectionTextureMatrix(): Matrix;
  7953. /**
  7954. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  7955. * @returns true if ready or not blocking
  7956. */
  7957. isReadyOrNotBlocking(): boolean;
  7958. /**
  7959. * Scales the texture if is `canRescale()`
  7960. * @param ratio the resize factor we want to use to rescale
  7961. */
  7962. scale(ratio: number): void;
  7963. /**
  7964. * Get if the texture can rescale.
  7965. */
  7966. get canRescale(): boolean;
  7967. /** @hidden */
  7968. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  7969. /** @hidden */
  7970. _rebuild(): void;
  7971. /**
  7972. * Clones the texture.
  7973. * @returns the cloned texture
  7974. */
  7975. clone(): Nullable<BaseTexture>;
  7976. /**
  7977. * Get the texture underlying type (INT, FLOAT...)
  7978. */
  7979. get textureType(): number;
  7980. /**
  7981. * Get the texture underlying format (RGB, RGBA...)
  7982. */
  7983. get textureFormat(): number;
  7984. /**
  7985. * Indicates that textures need to be re-calculated for all materials
  7986. */
  7987. protected _markAllSubMeshesAsTexturesDirty(): void;
  7988. /**
  7989. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  7990. * This will returns an RGBA array buffer containing either in values (0-255) or
  7991. * float values (0-1) depending of the underlying buffer type.
  7992. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  7993. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  7994. * @param buffer defines a user defined buffer to fill with data (can be null)
  7995. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  7996. * @returns The Array buffer promise containing the pixels data.
  7997. */
  7998. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<Promise<ArrayBufferView>>;
  7999. /** @hidden */
  8000. get _lodTextureHigh(): Nullable<BaseTexture>;
  8001. /** @hidden */
  8002. get _lodTextureMid(): Nullable<BaseTexture>;
  8003. /** @hidden */
  8004. get _lodTextureLow(): Nullable<BaseTexture>;
  8005. /**
  8006. * Dispose the texture and release its associated resources.
  8007. */
  8008. dispose(): void;
  8009. /**
  8010. * Serialize the texture into a JSON representation that can be parsed later on.
  8011. * @returns the JSON representation of the texture
  8012. */
  8013. serialize(): any;
  8014. /**
  8015. * Helper function to be called back once a list of texture contains only ready textures.
  8016. * @param textures Define the list of textures to wait for
  8017. * @param callback Define the callback triggered once the entire list will be ready
  8018. */
  8019. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  8020. private static _isScene;
  8021. }
  8022. }
  8023. declare module BABYLON {
  8024. /** @hidden */
  8025. export class WebGLDataBuffer extends DataBuffer {
  8026. private _buffer;
  8027. constructor(resource: WebGLBuffer);
  8028. get underlyingResource(): any;
  8029. }
  8030. }
  8031. declare module BABYLON {
  8032. /** @hidden */
  8033. export class WebGLPipelineContext implements IPipelineContext {
  8034. private _valueCache;
  8035. private _uniforms;
  8036. engine: ThinEngine;
  8037. program: Nullable<WebGLProgram>;
  8038. context?: WebGLRenderingContext;
  8039. vertexShader?: WebGLShader;
  8040. fragmentShader?: WebGLShader;
  8041. isParallelCompiled: boolean;
  8042. onCompiled?: () => void;
  8043. transformFeedback?: WebGLTransformFeedback | null;
  8044. vertexCompilationError: Nullable<string>;
  8045. fragmentCompilationError: Nullable<string>;
  8046. programLinkError: Nullable<string>;
  8047. programValidationError: Nullable<string>;
  8048. get isAsync(): boolean;
  8049. get isReady(): boolean;
  8050. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  8051. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  8052. [key: string]: number;
  8053. }, uniformsNames: string[], uniforms: {
  8054. [key: string]: Nullable<WebGLUniformLocation>;
  8055. }, samplerList: string[], samplers: {
  8056. [key: string]: number;
  8057. }, attributesNames: string[], attributes: number[]): void;
  8058. /**
  8059. * Release all associated resources.
  8060. **/
  8061. dispose(): void;
  8062. /** @hidden */
  8063. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  8064. /** @hidden */
  8065. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  8066. /** @hidden */
  8067. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  8068. /** @hidden */
  8069. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  8070. /**
  8071. * Sets an interger value on a uniform variable.
  8072. * @param uniformName Name of the variable.
  8073. * @param value Value to be set.
  8074. */
  8075. setInt(uniformName: string, value: number): void;
  8076. /**
  8077. * Sets a int2 on a uniform variable.
  8078. * @param uniformName Name of the variable.
  8079. * @param x First int in int2.
  8080. * @param y Second int in int2.
  8081. */
  8082. setInt2(uniformName: string, x: number, y: number): void;
  8083. /**
  8084. * Sets a int3 on a uniform variable.
  8085. * @param uniformName Name of the variable.
  8086. * @param x First int in int3.
  8087. * @param y Second int in int3.
  8088. * @param y Third int in int3.
  8089. */
  8090. setInt3(uniformName: string, x: number, y: number, z: number): void;
  8091. /**
  8092. * Sets a int4 on a uniform variable.
  8093. * @param uniformName Name of the variable.
  8094. * @param x First int in int4.
  8095. * @param y Second int in int4.
  8096. * @param y Third int in int4.
  8097. * @param w Fourth int in int4.
  8098. */
  8099. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8100. /**
  8101. * Sets an int array on a uniform variable.
  8102. * @param uniformName Name of the variable.
  8103. * @param array array to be set.
  8104. */
  8105. setIntArray(uniformName: string, array: Int32Array): void;
  8106. /**
  8107. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  8108. * @param uniformName Name of the variable.
  8109. * @param array array to be set.
  8110. */
  8111. setIntArray2(uniformName: string, array: Int32Array): void;
  8112. /**
  8113. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  8114. * @param uniformName Name of the variable.
  8115. * @param array array to be set.
  8116. */
  8117. setIntArray3(uniformName: string, array: Int32Array): void;
  8118. /**
  8119. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  8120. * @param uniformName Name of the variable.
  8121. * @param array array to be set.
  8122. */
  8123. setIntArray4(uniformName: string, array: Int32Array): void;
  8124. /**
  8125. * Sets an array on a uniform variable.
  8126. * @param uniformName Name of the variable.
  8127. * @param array array to be set.
  8128. */
  8129. setArray(uniformName: string, array: number[]): void;
  8130. /**
  8131. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  8132. * @param uniformName Name of the variable.
  8133. * @param array array to be set.
  8134. */
  8135. setArray2(uniformName: string, array: number[]): void;
  8136. /**
  8137. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  8138. * @param uniformName Name of the variable.
  8139. * @param array array to be set.
  8140. * @returns this effect.
  8141. */
  8142. setArray3(uniformName: string, array: number[]): void;
  8143. /**
  8144. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  8145. * @param uniformName Name of the variable.
  8146. * @param array array to be set.
  8147. */
  8148. setArray4(uniformName: string, array: number[]): void;
  8149. /**
  8150. * Sets matrices on a uniform variable.
  8151. * @param uniformName Name of the variable.
  8152. * @param matrices matrices to be set.
  8153. */
  8154. setMatrices(uniformName: string, matrices: Float32Array): void;
  8155. /**
  8156. * Sets matrix on a uniform variable.
  8157. * @param uniformName Name of the variable.
  8158. * @param matrix matrix to be set.
  8159. */
  8160. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  8161. /**
  8162. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  8163. * @param uniformName Name of the variable.
  8164. * @param matrix matrix to be set.
  8165. */
  8166. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  8167. /**
  8168. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  8169. * @param uniformName Name of the variable.
  8170. * @param matrix matrix to be set.
  8171. */
  8172. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  8173. /**
  8174. * Sets a float on a uniform variable.
  8175. * @param uniformName Name of the variable.
  8176. * @param value value to be set.
  8177. * @returns this effect.
  8178. */
  8179. setFloat(uniformName: string, value: number): void;
  8180. /**
  8181. * Sets a Vector2 on a uniform variable.
  8182. * @param uniformName Name of the variable.
  8183. * @param vector2 vector2 to be set.
  8184. */
  8185. setVector2(uniformName: string, vector2: IVector2Like): void;
  8186. /**
  8187. * Sets a float2 on a uniform variable.
  8188. * @param uniformName Name of the variable.
  8189. * @param x First float in float2.
  8190. * @param y Second float in float2.
  8191. */
  8192. setFloat2(uniformName: string, x: number, y: number): void;
  8193. /**
  8194. * Sets a Vector3 on a uniform variable.
  8195. * @param uniformName Name of the variable.
  8196. * @param vector3 Value to be set.
  8197. */
  8198. setVector3(uniformName: string, vector3: IVector3Like): void;
  8199. /**
  8200. * Sets a float3 on a uniform variable.
  8201. * @param uniformName Name of the variable.
  8202. * @param x First float in float3.
  8203. * @param y Second float in float3.
  8204. * @param z Third float in float3.
  8205. */
  8206. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  8207. /**
  8208. * Sets a Vector4 on a uniform variable.
  8209. * @param uniformName Name of the variable.
  8210. * @param vector4 Value to be set.
  8211. */
  8212. setVector4(uniformName: string, vector4: IVector4Like): void;
  8213. /**
  8214. * Sets a float4 on a uniform variable.
  8215. * @param uniformName Name of the variable.
  8216. * @param x First float in float4.
  8217. * @param y Second float in float4.
  8218. * @param z Third float in float4.
  8219. * @param w Fourth float in float4.
  8220. * @returns this effect.
  8221. */
  8222. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8223. /**
  8224. * Sets a Color3 on a uniform variable.
  8225. * @param uniformName Name of the variable.
  8226. * @param color3 Value to be set.
  8227. */
  8228. setColor3(uniformName: string, color3: IColor3Like): void;
  8229. /**
  8230. * Sets a Color4 on a uniform variable.
  8231. * @param uniformName Name of the variable.
  8232. * @param color3 Value to be set.
  8233. * @param alpha Alpha value to be set.
  8234. */
  8235. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  8236. /**
  8237. * Sets a Color4 on a uniform variable
  8238. * @param uniformName defines the name of the variable
  8239. * @param color4 defines the value to be set
  8240. */
  8241. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  8242. _getVertexShaderCode(): string | null;
  8243. _getFragmentShaderCode(): string | null;
  8244. }
  8245. }
  8246. declare module BABYLON {
  8247. interface ThinEngine {
  8248. /**
  8249. * Create an uniform buffer
  8250. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8251. * @param elements defines the content of the uniform buffer
  8252. * @returns the webGL uniform buffer
  8253. */
  8254. createUniformBuffer(elements: FloatArray): DataBuffer;
  8255. /**
  8256. * Create a dynamic uniform buffer
  8257. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8258. * @param elements defines the content of the uniform buffer
  8259. * @returns the webGL uniform buffer
  8260. */
  8261. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  8262. /**
  8263. * Update an existing uniform buffer
  8264. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8265. * @param uniformBuffer defines the target uniform buffer
  8266. * @param elements defines the content to update
  8267. * @param offset defines the offset in the uniform buffer where update should start
  8268. * @param count defines the size of the data to update
  8269. */
  8270. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8271. /**
  8272. * Bind an uniform buffer to the current webGL context
  8273. * @param buffer defines the buffer to bind
  8274. */
  8275. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  8276. /**
  8277. * Bind a buffer to the current webGL context at a given location
  8278. * @param buffer defines the buffer to bind
  8279. * @param location defines the index where to bind the buffer
  8280. * @param name Name of the uniform variable to bind
  8281. */
  8282. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  8283. /**
  8284. * Bind a specific block at a given index in a specific shader program
  8285. * @param pipelineContext defines the pipeline context to use
  8286. * @param blockName defines the block name
  8287. * @param index defines the index where to bind the block
  8288. */
  8289. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  8290. }
  8291. }
  8292. declare module BABYLON {
  8293. /**
  8294. * Uniform buffer objects.
  8295. *
  8296. * Handles blocks of uniform on the GPU.
  8297. *
  8298. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  8299. *
  8300. * For more information, please refer to :
  8301. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8302. */
  8303. export class UniformBuffer {
  8304. /** @hidden */
  8305. static _updatedUbosInFrame: {
  8306. [name: string]: number;
  8307. };
  8308. private _engine;
  8309. private _buffer;
  8310. private _buffers;
  8311. private _bufferIndex;
  8312. private _createBufferOnWrite;
  8313. private _data;
  8314. private _bufferData;
  8315. private _dynamic?;
  8316. private _uniformLocations;
  8317. private _uniformSizes;
  8318. private _uniformArraySizes;
  8319. private _uniformLocationPointer;
  8320. private _needSync;
  8321. private _noUBO;
  8322. private _currentEffect;
  8323. private _currentEffectName;
  8324. private _name;
  8325. private _currentFrameId;
  8326. /** @hidden */
  8327. _alreadyBound: boolean;
  8328. private static _MAX_UNIFORM_SIZE;
  8329. private static _tempBuffer;
  8330. private static _tempBufferInt32View;
  8331. /**
  8332. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  8333. * This is dynamic to allow compat with webgl 1 and 2.
  8334. * You will need to pass the name of the uniform as well as the value.
  8335. */
  8336. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  8337. /**
  8338. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  8339. * This is dynamic to allow compat with webgl 1 and 2.
  8340. * You will need to pass the name of the uniform as well as the value.
  8341. */
  8342. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  8343. /**
  8344. * Lambda to Update a single float in a uniform buffer.
  8345. * This is dynamic to allow compat with webgl 1 and 2.
  8346. * You will need to pass the name of the uniform as well as the value.
  8347. */
  8348. updateFloat: (name: string, x: number) => void;
  8349. /**
  8350. * Lambda to Update a vec2 of float in a uniform buffer.
  8351. * This is dynamic to allow compat with webgl 1 and 2.
  8352. * You will need to pass the name of the uniform as well as the value.
  8353. */
  8354. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  8355. /**
  8356. * Lambda to Update a vec3 of float in a uniform buffer.
  8357. * This is dynamic to allow compat with webgl 1 and 2.
  8358. * You will need to pass the name of the uniform as well as the value.
  8359. */
  8360. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8361. /**
  8362. * Lambda to Update a vec4 of float in a uniform buffer.
  8363. * This is dynamic to allow compat with webgl 1 and 2.
  8364. * You will need to pass the name of the uniform as well as the value.
  8365. */
  8366. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8367. /**
  8368. * Lambda to Update an array of float in a uniform buffer.
  8369. * This is dynamic to allow compat with webgl 1 and 2.
  8370. * You will need to pass the name of the uniform as well as the value.
  8371. */
  8372. updateFloatArray: (name: string, array: Float32Array) => void;
  8373. /**
  8374. * Lambda to Update an array of number in a uniform buffer.
  8375. * This is dynamic to allow compat with webgl 1 and 2.
  8376. * You will need to pass the name of the uniform as well as the value.
  8377. */
  8378. updateArray: (name: string, array: number[]) => void;
  8379. /**
  8380. * Lambda to Update an array of number in a uniform buffer.
  8381. * This is dynamic to allow compat with webgl 1 and 2.
  8382. * You will need to pass the name of the uniform as well as the value.
  8383. */
  8384. updateIntArray: (name: string, array: Int32Array) => void;
  8385. /**
  8386. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  8387. * This is dynamic to allow compat with webgl 1 and 2.
  8388. * You will need to pass the name of the uniform as well as the value.
  8389. */
  8390. updateMatrix: (name: string, mat: IMatrixLike) => void;
  8391. /**
  8392. * Lambda to Update an array of 4x4 Matrix in a uniform buffer.
  8393. * This is dynamic to allow compat with webgl 1 and 2.
  8394. * You will need to pass the name of the uniform as well as the value.
  8395. */
  8396. updateMatrices: (name: string, mat: Float32Array) => void;
  8397. /**
  8398. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  8399. * This is dynamic to allow compat with webgl 1 and 2.
  8400. * You will need to pass the name of the uniform as well as the value.
  8401. */
  8402. updateVector3: (name: string, vector: Vector3) => void;
  8403. /**
  8404. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  8405. * This is dynamic to allow compat with webgl 1 and 2.
  8406. * You will need to pass the name of the uniform as well as the value.
  8407. */
  8408. updateVector4: (name: string, vector: Vector4) => void;
  8409. /**
  8410. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  8411. * This is dynamic to allow compat with webgl 1 and 2.
  8412. * You will need to pass the name of the uniform as well as the value.
  8413. */
  8414. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  8415. /**
  8416. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  8417. * This is dynamic to allow compat with webgl 1 and 2.
  8418. * You will need to pass the name of the uniform as well as the value.
  8419. */
  8420. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  8421. /**
  8422. * Lambda to Update a int a uniform buffer.
  8423. * This is dynamic to allow compat with webgl 1 and 2.
  8424. * You will need to pass the name of the uniform as well as the value.
  8425. */
  8426. updateInt: (name: string, x: number, suffix?: string) => void;
  8427. /**
  8428. * Lambda to Update a vec2 of int in a uniform buffer.
  8429. * This is dynamic to allow compat with webgl 1 and 2.
  8430. * You will need to pass the name of the uniform as well as the value.
  8431. */
  8432. updateInt2: (name: string, x: number, y: number, suffix?: string) => void;
  8433. /**
  8434. * Lambda to Update a vec3 of int in a uniform buffer.
  8435. * This is dynamic to allow compat with webgl 1 and 2.
  8436. * You will need to pass the name of the uniform as well as the value.
  8437. */
  8438. updateInt3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8439. /**
  8440. * Lambda to Update a vec4 of int in a uniform buffer.
  8441. * This is dynamic to allow compat with webgl 1 and 2.
  8442. * You will need to pass the name of the uniform as well as the value.
  8443. */
  8444. updateInt4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8445. /**
  8446. * Instantiates a new Uniform buffer objects.
  8447. *
  8448. * Handles blocks of uniform on the GPU.
  8449. *
  8450. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  8451. *
  8452. * For more information, please refer to :
  8453. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8454. * @param engine Define the engine the buffer is associated with
  8455. * @param data Define the data contained in the buffer
  8456. * @param dynamic Define if the buffer is updatable
  8457. * @param name to assign to the buffer (debugging purpose)
  8458. */
  8459. constructor(engine: Engine, data?: number[], dynamic?: boolean, name?: string);
  8460. /**
  8461. * Indicates if the buffer is using the WebGL2 UBO implementation,
  8462. * or just falling back on setUniformXXX calls.
  8463. */
  8464. get useUbo(): boolean;
  8465. /**
  8466. * Indicates if the WebGL underlying uniform buffer is in sync
  8467. * with the javascript cache data.
  8468. */
  8469. get isSync(): boolean;
  8470. /**
  8471. * Indicates if the WebGL underlying uniform buffer is dynamic.
  8472. * Also, a dynamic UniformBuffer will disable cache verification and always
  8473. * update the underlying WebGL uniform buffer to the GPU.
  8474. * @returns if Dynamic, otherwise false
  8475. */
  8476. isDynamic(): boolean;
  8477. /**
  8478. * The data cache on JS side.
  8479. * @returns the underlying data as a float array
  8480. */
  8481. getData(): Float32Array;
  8482. /**
  8483. * The underlying WebGL Uniform buffer.
  8484. * @returns the webgl buffer
  8485. */
  8486. getBuffer(): Nullable<DataBuffer>;
  8487. /**
  8488. * std140 layout specifies how to align data within an UBO structure.
  8489. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  8490. * for specs.
  8491. */
  8492. private _fillAlignment;
  8493. /**
  8494. * Adds an uniform in the buffer.
  8495. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  8496. * for the layout to be correct !
  8497. * @param name Name of the uniform, as used in the uniform block in the shader.
  8498. * @param size Data size, or data directly.
  8499. * @param arraySize The number of elements in the array, 0 if not an array.
  8500. */
  8501. addUniform(name: string, size: number | number[], arraySize?: number): void;
  8502. /**
  8503. * Adds a Matrix 4x4 to the uniform buffer.
  8504. * @param name Name of the uniform, as used in the uniform block in the shader.
  8505. * @param mat A 4x4 matrix.
  8506. */
  8507. addMatrix(name: string, mat: Matrix): void;
  8508. /**
  8509. * Adds a vec2 to the uniform buffer.
  8510. * @param name Name of the uniform, as used in the uniform block in the shader.
  8511. * @param x Define the x component value of the vec2
  8512. * @param y Define the y component value of the vec2
  8513. */
  8514. addFloat2(name: string, x: number, y: number): void;
  8515. /**
  8516. * Adds a vec3 to the uniform buffer.
  8517. * @param name Name of the uniform, as used in the uniform block in the shader.
  8518. * @param x Define the x component value of the vec3
  8519. * @param y Define the y component value of the vec3
  8520. * @param z Define the z component value of the vec3
  8521. */
  8522. addFloat3(name: string, x: number, y: number, z: number): void;
  8523. /**
  8524. * Adds a vec3 to the uniform buffer.
  8525. * @param name Name of the uniform, as used in the uniform block in the shader.
  8526. * @param color Define the vec3 from a Color
  8527. */
  8528. addColor3(name: string, color: Color3): void;
  8529. /**
  8530. * Adds a vec4 to the uniform buffer.
  8531. * @param name Name of the uniform, as used in the uniform block in the shader.
  8532. * @param color Define the rgb components from a Color
  8533. * @param alpha Define the a component of the vec4
  8534. */
  8535. addColor4(name: string, color: Color3, alpha: number): void;
  8536. /**
  8537. * Adds a vec3 to the uniform buffer.
  8538. * @param name Name of the uniform, as used in the uniform block in the shader.
  8539. * @param vector Define the vec3 components from a Vector
  8540. */
  8541. addVector3(name: string, vector: Vector3): void;
  8542. /**
  8543. * Adds a Matrix 3x3 to the uniform buffer.
  8544. * @param name Name of the uniform, as used in the uniform block in the shader.
  8545. */
  8546. addMatrix3x3(name: string): void;
  8547. /**
  8548. * Adds a Matrix 2x2 to the uniform buffer.
  8549. * @param name Name of the uniform, as used in the uniform block in the shader.
  8550. */
  8551. addMatrix2x2(name: string): void;
  8552. /**
  8553. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8554. */
  8555. create(): void;
  8556. /** @hidden */
  8557. _rebuild(): void;
  8558. /** @hidden */
  8559. get _numBuffers(): number;
  8560. /** @hidden */
  8561. get _indexBuffer(): number;
  8562. /** Gets the name of this buffer */
  8563. get name(): string;
  8564. /**
  8565. * Updates the WebGL Uniform Buffer on the GPU.
  8566. * If the `dynamic` flag is set to true, no cache comparison is done.
  8567. * Otherwise, the buffer will be updated only if the cache differs.
  8568. */
  8569. update(): void;
  8570. private _createNewBuffer;
  8571. private _checkNewFrame;
  8572. /**
  8573. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8574. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8575. * @param data Define the flattened data
  8576. * @param size Define the size of the data.
  8577. */
  8578. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8579. /**
  8580. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8581. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8582. * @param data Define the flattened data
  8583. * @param size Define the size of the data.
  8584. */
  8585. updateUniformArray(uniformName: string, data: FloatArray, size: number): void;
  8586. private _valueCache;
  8587. private _cacheMatrix;
  8588. private _updateMatrix3x3ForUniform;
  8589. private _updateMatrix3x3ForEffect;
  8590. private _updateMatrix2x2ForEffect;
  8591. private _updateMatrix2x2ForUniform;
  8592. private _updateFloatForEffect;
  8593. private _updateFloatForUniform;
  8594. private _updateFloat2ForEffect;
  8595. private _updateFloat2ForUniform;
  8596. private _updateFloat3ForEffect;
  8597. private _updateFloat3ForUniform;
  8598. private _updateFloat4ForEffect;
  8599. private _updateFloat4ForUniform;
  8600. private _updateFloatArrayForEffect;
  8601. private _updateFloatArrayForUniform;
  8602. private _updateArrayForEffect;
  8603. private _updateArrayForUniform;
  8604. private _updateIntArrayForEffect;
  8605. private _updateIntArrayForUniform;
  8606. private _updateMatrixForEffect;
  8607. private _updateMatrixForUniform;
  8608. private _updateMatricesForEffect;
  8609. private _updateMatricesForUniform;
  8610. private _updateVector3ForEffect;
  8611. private _updateVector3ForUniform;
  8612. private _updateVector4ForEffect;
  8613. private _updateVector4ForUniform;
  8614. private _updateColor3ForEffect;
  8615. private _updateColor3ForUniform;
  8616. private _updateColor4ForEffect;
  8617. private _updateColor4ForUniform;
  8618. private _updateIntForEffect;
  8619. private _updateIntForUniform;
  8620. private _updateInt2ForEffect;
  8621. private _updateInt2ForUniform;
  8622. private _updateInt3ForEffect;
  8623. private _updateInt3ForUniform;
  8624. private _updateInt4ForEffect;
  8625. private _updateInt4ForUniform;
  8626. /**
  8627. * Sets a sampler uniform on the effect.
  8628. * @param name Define the name of the sampler.
  8629. * @param texture Define the texture to set in the sampler
  8630. */
  8631. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8632. /**
  8633. * Directly updates the value of the uniform in the cache AND on the GPU.
  8634. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8635. * @param data Define the flattened data
  8636. */
  8637. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8638. /**
  8639. * Binds this uniform buffer to an effect.
  8640. * @param effect Define the effect to bind the buffer to
  8641. * @param name Name of the uniform block in the shader.
  8642. */
  8643. bindToEffect(effect: Effect, name: string): void;
  8644. /**
  8645. * Disposes the uniform buffer.
  8646. */
  8647. dispose(): void;
  8648. }
  8649. }
  8650. declare module BABYLON {
  8651. /**
  8652. * Manages the defines for the Material
  8653. */
  8654. export class MaterialDefines {
  8655. /** @hidden */
  8656. protected _keys: string[];
  8657. private _isDirty;
  8658. /** @hidden */
  8659. _renderId: number;
  8660. /** @hidden */
  8661. _areLightsDirty: boolean;
  8662. /** @hidden */
  8663. _areLightsDisposed: boolean;
  8664. /** @hidden */
  8665. _areAttributesDirty: boolean;
  8666. /** @hidden */
  8667. _areTexturesDirty: boolean;
  8668. /** @hidden */
  8669. _areFresnelDirty: boolean;
  8670. /** @hidden */
  8671. _areMiscDirty: boolean;
  8672. /** @hidden */
  8673. _arePrePassDirty: boolean;
  8674. /** @hidden */
  8675. _areImageProcessingDirty: boolean;
  8676. /** @hidden */
  8677. _normals: boolean;
  8678. /** @hidden */
  8679. _uvs: boolean;
  8680. /** @hidden */
  8681. _needNormals: boolean;
  8682. /** @hidden */
  8683. _needUVs: boolean;
  8684. [id: string]: any;
  8685. /**
  8686. * Specifies if the material needs to be re-calculated
  8687. */
  8688. get isDirty(): boolean;
  8689. /**
  8690. * Marks the material to indicate that it has been re-calculated
  8691. */
  8692. markAsProcessed(): void;
  8693. /**
  8694. * Marks the material to indicate that it needs to be re-calculated
  8695. */
  8696. markAsUnprocessed(): void;
  8697. /**
  8698. * Marks the material to indicate all of its defines need to be re-calculated
  8699. */
  8700. markAllAsDirty(): void;
  8701. /**
  8702. * Marks the material to indicate that image processing needs to be re-calculated
  8703. */
  8704. markAsImageProcessingDirty(): void;
  8705. /**
  8706. * Marks the material to indicate the lights need to be re-calculated
  8707. * @param disposed Defines whether the light is dirty due to dispose or not
  8708. */
  8709. markAsLightDirty(disposed?: boolean): void;
  8710. /**
  8711. * Marks the attribute state as changed
  8712. */
  8713. markAsAttributesDirty(): void;
  8714. /**
  8715. * Marks the texture state as changed
  8716. */
  8717. markAsTexturesDirty(): void;
  8718. /**
  8719. * Marks the fresnel state as changed
  8720. */
  8721. markAsFresnelDirty(): void;
  8722. /**
  8723. * Marks the misc state as changed
  8724. */
  8725. markAsMiscDirty(): void;
  8726. /**
  8727. * Marks the prepass state as changed
  8728. */
  8729. markAsPrePassDirty(): void;
  8730. /**
  8731. * Rebuilds the material defines
  8732. */
  8733. rebuild(): void;
  8734. /**
  8735. * Specifies if two material defines are equal
  8736. * @param other - A material define instance to compare to
  8737. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8738. */
  8739. isEqual(other: MaterialDefines): boolean;
  8740. /**
  8741. * Clones this instance's defines to another instance
  8742. * @param other - material defines to clone values to
  8743. */
  8744. cloneTo(other: MaterialDefines): void;
  8745. /**
  8746. * Resets the material define values
  8747. */
  8748. reset(): void;
  8749. /**
  8750. * Converts the material define values to a string
  8751. * @returns - String of material define information
  8752. */
  8753. toString(): string;
  8754. }
  8755. }
  8756. declare module BABYLON {
  8757. /**
  8758. * Enum that determines the text-wrapping mode to use.
  8759. */
  8760. export enum InspectableType {
  8761. /**
  8762. * Checkbox for booleans
  8763. */
  8764. Checkbox = 0,
  8765. /**
  8766. * Sliders for numbers
  8767. */
  8768. Slider = 1,
  8769. /**
  8770. * Vector3
  8771. */
  8772. Vector3 = 2,
  8773. /**
  8774. * Quaternions
  8775. */
  8776. Quaternion = 3,
  8777. /**
  8778. * Color3
  8779. */
  8780. Color3 = 4,
  8781. /**
  8782. * String
  8783. */
  8784. String = 5
  8785. }
  8786. /**
  8787. * Interface used to define custom inspectable properties.
  8788. * This interface is used by the inspector to display custom property grids
  8789. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8790. */
  8791. export interface IInspectable {
  8792. /**
  8793. * Gets the label to display
  8794. */
  8795. label: string;
  8796. /**
  8797. * Gets the name of the property to edit
  8798. */
  8799. propertyName: string;
  8800. /**
  8801. * Gets the type of the editor to use
  8802. */
  8803. type: InspectableType;
  8804. /**
  8805. * Gets the minimum value of the property when using in "slider" mode
  8806. */
  8807. min?: number;
  8808. /**
  8809. * Gets the maximum value of the property when using in "slider" mode
  8810. */
  8811. max?: number;
  8812. /**
  8813. * Gets the setp to use when using in "slider" mode
  8814. */
  8815. step?: number;
  8816. }
  8817. }
  8818. declare module BABYLON {
  8819. /**
  8820. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8821. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8822. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  8823. */
  8824. export abstract class Light extends Node {
  8825. /**
  8826. * Falloff Default: light is falling off following the material specification:
  8827. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  8828. */
  8829. static readonly FALLOFF_DEFAULT: number;
  8830. /**
  8831. * Falloff Physical: light is falling off following the inverse squared distance law.
  8832. */
  8833. static readonly FALLOFF_PHYSICAL: number;
  8834. /**
  8835. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  8836. * to enhance interoperability with other engines.
  8837. */
  8838. static readonly FALLOFF_GLTF: number;
  8839. /**
  8840. * Falloff Standard: light is falling off like in the standard material
  8841. * to enhance interoperability with other materials.
  8842. */
  8843. static readonly FALLOFF_STANDARD: number;
  8844. /**
  8845. * If every light affecting the material is in this lightmapMode,
  8846. * material.lightmapTexture adds or multiplies
  8847. * (depends on material.useLightmapAsShadowmap)
  8848. * after every other light calculations.
  8849. */
  8850. static readonly LIGHTMAP_DEFAULT: number;
  8851. /**
  8852. * material.lightmapTexture as only diffuse lighting from this light
  8853. * adds only specular lighting from this light
  8854. * adds dynamic shadows
  8855. */
  8856. static readonly LIGHTMAP_SPECULAR: number;
  8857. /**
  8858. * material.lightmapTexture as only lighting
  8859. * no light calculation from this light
  8860. * only adds dynamic shadows from this light
  8861. */
  8862. static readonly LIGHTMAP_SHADOWSONLY: number;
  8863. /**
  8864. * Each light type uses the default quantity according to its type:
  8865. * point/spot lights use luminous intensity
  8866. * directional lights use illuminance
  8867. */
  8868. static readonly INTENSITYMODE_AUTOMATIC: number;
  8869. /**
  8870. * lumen (lm)
  8871. */
  8872. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  8873. /**
  8874. * candela (lm/sr)
  8875. */
  8876. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  8877. /**
  8878. * lux (lm/m^2)
  8879. */
  8880. static readonly INTENSITYMODE_ILLUMINANCE: number;
  8881. /**
  8882. * nit (cd/m^2)
  8883. */
  8884. static readonly INTENSITYMODE_LUMINANCE: number;
  8885. /**
  8886. * Light type const id of the point light.
  8887. */
  8888. static readonly LIGHTTYPEID_POINTLIGHT: number;
  8889. /**
  8890. * Light type const id of the directional light.
  8891. */
  8892. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  8893. /**
  8894. * Light type const id of the spot light.
  8895. */
  8896. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  8897. /**
  8898. * Light type const id of the hemispheric light.
  8899. */
  8900. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  8901. /**
  8902. * Diffuse gives the basic color to an object.
  8903. */
  8904. diffuse: Color3;
  8905. /**
  8906. * Specular produces a highlight color on an object.
  8907. * Note: This is note affecting PBR materials.
  8908. */
  8909. specular: Color3;
  8910. /**
  8911. * Defines the falloff type for this light. This lets overrriding how punctual light are
  8912. * falling off base on range or angle.
  8913. * This can be set to any values in Light.FALLOFF_x.
  8914. *
  8915. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  8916. * other types of materials.
  8917. */
  8918. falloffType: number;
  8919. /**
  8920. * Strength of the light.
  8921. * Note: By default it is define in the framework own unit.
  8922. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  8923. */
  8924. intensity: number;
  8925. private _range;
  8926. protected _inverseSquaredRange: number;
  8927. /**
  8928. * Defines how far from the source the light is impacting in scene units.
  8929. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8930. */
  8931. get range(): number;
  8932. /**
  8933. * Defines how far from the source the light is impacting in scene units.
  8934. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8935. */
  8936. set range(value: number);
  8937. /**
  8938. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  8939. * of light.
  8940. */
  8941. private _photometricScale;
  8942. private _intensityMode;
  8943. /**
  8944. * Gets the photometric scale used to interpret the intensity.
  8945. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8946. */
  8947. get intensityMode(): number;
  8948. /**
  8949. * Sets the photometric scale used to interpret the intensity.
  8950. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8951. */
  8952. set intensityMode(value: number);
  8953. private _radius;
  8954. /**
  8955. * Gets the light radius used by PBR Materials to simulate soft area lights.
  8956. */
  8957. get radius(): number;
  8958. /**
  8959. * sets the light radius used by PBR Materials to simulate soft area lights.
  8960. */
  8961. set radius(value: number);
  8962. private _renderPriority;
  8963. /**
  8964. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  8965. * exceeding the number allowed of the materials.
  8966. */
  8967. renderPriority: number;
  8968. private _shadowEnabled;
  8969. /**
  8970. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8971. * the current shadow generator.
  8972. */
  8973. get shadowEnabled(): boolean;
  8974. /**
  8975. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8976. * the current shadow generator.
  8977. */
  8978. set shadowEnabled(value: boolean);
  8979. private _includedOnlyMeshes;
  8980. /**
  8981. * Gets the only meshes impacted by this light.
  8982. */
  8983. get includedOnlyMeshes(): AbstractMesh[];
  8984. /**
  8985. * Sets the only meshes impacted by this light.
  8986. */
  8987. set includedOnlyMeshes(value: AbstractMesh[]);
  8988. private _excludedMeshes;
  8989. /**
  8990. * Gets the meshes not impacted by this light.
  8991. */
  8992. get excludedMeshes(): AbstractMesh[];
  8993. /**
  8994. * Sets the meshes not impacted by this light.
  8995. */
  8996. set excludedMeshes(value: AbstractMesh[]);
  8997. private _excludeWithLayerMask;
  8998. /**
  8999. * Gets the layer id use to find what meshes are not impacted by the light.
  9000. * Inactive if 0
  9001. */
  9002. get excludeWithLayerMask(): number;
  9003. /**
  9004. * Sets the layer id use to find what meshes are not impacted by the light.
  9005. * Inactive if 0
  9006. */
  9007. set excludeWithLayerMask(value: number);
  9008. private _includeOnlyWithLayerMask;
  9009. /**
  9010. * Gets the layer id use to find what meshes are impacted by the light.
  9011. * Inactive if 0
  9012. */
  9013. get includeOnlyWithLayerMask(): number;
  9014. /**
  9015. * Sets the layer id use to find what meshes are impacted by the light.
  9016. * Inactive if 0
  9017. */
  9018. set includeOnlyWithLayerMask(value: number);
  9019. private _lightmapMode;
  9020. /**
  9021. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9022. */
  9023. get lightmapMode(): number;
  9024. /**
  9025. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9026. */
  9027. set lightmapMode(value: number);
  9028. /**
  9029. * Shadow generator associted to the light.
  9030. * @hidden Internal use only.
  9031. */
  9032. _shadowGenerator: Nullable<IShadowGenerator>;
  9033. /**
  9034. * @hidden Internal use only.
  9035. */
  9036. _excludedMeshesIds: string[];
  9037. /**
  9038. * @hidden Internal use only.
  9039. */
  9040. _includedOnlyMeshesIds: string[];
  9041. /**
  9042. * The current light unifom buffer.
  9043. * @hidden Internal use only.
  9044. */
  9045. _uniformBuffer: UniformBuffer;
  9046. /** @hidden */
  9047. _renderId: number;
  9048. /**
  9049. * Creates a Light object in the scene.
  9050. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9051. * @param name The firendly name of the light
  9052. * @param scene The scene the light belongs too
  9053. */
  9054. constructor(name: string, scene: Scene);
  9055. protected abstract _buildUniformLayout(): void;
  9056. /**
  9057. * Sets the passed Effect "effect" with the Light information.
  9058. * @param effect The effect to update
  9059. * @param lightIndex The index of the light in the effect to update
  9060. * @returns The light
  9061. */
  9062. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9063. /**
  9064. * Sets the passed Effect "effect" with the Light textures.
  9065. * @param effect The effect to update
  9066. * @param lightIndex The index of the light in the effect to update
  9067. * @returns The light
  9068. */
  9069. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  9070. /**
  9071. * Binds the lights information from the scene to the effect for the given mesh.
  9072. * @param lightIndex Light index
  9073. * @param scene The scene where the light belongs to
  9074. * @param effect The effect we are binding the data to
  9075. * @param useSpecular Defines if specular is supported
  9076. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9077. */
  9078. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9079. /**
  9080. * Sets the passed Effect "effect" with the Light information.
  9081. * @param effect The effect to update
  9082. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9083. * @returns The light
  9084. */
  9085. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9086. /**
  9087. * Returns the string "Light".
  9088. * @returns the class name
  9089. */
  9090. getClassName(): string;
  9091. /** @hidden */
  9092. readonly _isLight: boolean;
  9093. /**
  9094. * Converts the light information to a readable string for debug purpose.
  9095. * @param fullDetails Supports for multiple levels of logging within scene loading
  9096. * @returns the human readable light info
  9097. */
  9098. toString(fullDetails?: boolean): string;
  9099. /** @hidden */
  9100. protected _syncParentEnabledState(): void;
  9101. /**
  9102. * Set the enabled state of this node.
  9103. * @param value - the new enabled state
  9104. */
  9105. setEnabled(value: boolean): void;
  9106. /**
  9107. * Returns the Light associated shadow generator if any.
  9108. * @return the associated shadow generator.
  9109. */
  9110. getShadowGenerator(): Nullable<IShadowGenerator>;
  9111. /**
  9112. * Returns a Vector3, the absolute light position in the World.
  9113. * @returns the world space position of the light
  9114. */
  9115. getAbsolutePosition(): Vector3;
  9116. /**
  9117. * Specifies if the light will affect the passed mesh.
  9118. * @param mesh The mesh to test against the light
  9119. * @return true the mesh is affected otherwise, false.
  9120. */
  9121. canAffectMesh(mesh: AbstractMesh): boolean;
  9122. /**
  9123. * Sort function to order lights for rendering.
  9124. * @param a First Light object to compare to second.
  9125. * @param b Second Light object to compare first.
  9126. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9127. */
  9128. static CompareLightsPriority(a: Light, b: Light): number;
  9129. /**
  9130. * Releases resources associated with this node.
  9131. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9132. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9133. */
  9134. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9135. /**
  9136. * Returns the light type ID (integer).
  9137. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9138. */
  9139. getTypeID(): number;
  9140. /**
  9141. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9142. * @returns the scaled intensity in intensity mode unit
  9143. */
  9144. getScaledIntensity(): number;
  9145. /**
  9146. * Returns a new Light object, named "name", from the current one.
  9147. * @param name The name of the cloned light
  9148. * @param newParent The parent of this light, if it has one
  9149. * @returns the new created light
  9150. */
  9151. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  9152. /**
  9153. * Serializes the current light into a Serialization object.
  9154. * @returns the serialized object.
  9155. */
  9156. serialize(): any;
  9157. /**
  9158. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9159. * This new light is named "name" and added to the passed scene.
  9160. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9161. * @param name The friendly name of the light
  9162. * @param scene The scene the new light will belong to
  9163. * @returns the constructor function
  9164. */
  9165. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9166. /**
  9167. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9168. * @param parsedLight The JSON representation of the light
  9169. * @param scene The scene to create the parsed light in
  9170. * @returns the created light after parsing
  9171. */
  9172. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9173. private _hookArrayForExcluded;
  9174. private _hookArrayForIncludedOnly;
  9175. private _resyncMeshes;
  9176. /**
  9177. * Forces the meshes to update their light related information in their rendering used effects
  9178. * @hidden Internal Use Only
  9179. */
  9180. _markMeshesAsLightDirty(): void;
  9181. /**
  9182. * Recomputes the cached photometric scale if needed.
  9183. */
  9184. private _computePhotometricScale;
  9185. /**
  9186. * Returns the Photometric Scale according to the light type and intensity mode.
  9187. */
  9188. private _getPhotometricScale;
  9189. /**
  9190. * Reorder the light in the scene according to their defined priority.
  9191. * @hidden Internal Use Only
  9192. */
  9193. _reorderLightsInScene(): void;
  9194. /**
  9195. * Prepares the list of defines specific to the light type.
  9196. * @param defines the list of defines
  9197. * @param lightIndex defines the index of the light for the effect
  9198. */
  9199. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9200. }
  9201. }
  9202. declare module BABYLON {
  9203. /** Defines supported spaces */
  9204. export enum Space {
  9205. /** Local (object) space */
  9206. LOCAL = 0,
  9207. /** World space */
  9208. WORLD = 1,
  9209. /** Bone space */
  9210. BONE = 2
  9211. }
  9212. /** Defines the 3 main axes */
  9213. export class Axis {
  9214. /** X axis */
  9215. static X: Vector3;
  9216. /** Y axis */
  9217. static Y: Vector3;
  9218. /** Z axis */
  9219. static Z: Vector3;
  9220. }
  9221. /**
  9222. * Defines cartesian components.
  9223. */
  9224. export enum Coordinate {
  9225. /** X axis */
  9226. X = 0,
  9227. /** Y axis */
  9228. Y = 1,
  9229. /** Z axis */
  9230. Z = 2
  9231. }
  9232. }
  9233. declare module BABYLON {
  9234. /**
  9235. * Interface describing all the common properties and methods a shadow light needs to implement.
  9236. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9237. * as well as binding the different shadow properties to the effects.
  9238. */
  9239. export interface IShadowLight extends Light {
  9240. /**
  9241. * The light id in the scene (used in scene.findLighById for instance)
  9242. */
  9243. id: string;
  9244. /**
  9245. * The position the shdow will be casted from.
  9246. */
  9247. position: Vector3;
  9248. /**
  9249. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9250. */
  9251. direction: Vector3;
  9252. /**
  9253. * The transformed position. Position of the light in world space taking parenting in account.
  9254. */
  9255. transformedPosition: Vector3;
  9256. /**
  9257. * The transformed direction. Direction of the light in world space taking parenting in account.
  9258. */
  9259. transformedDirection: Vector3;
  9260. /**
  9261. * The friendly name of the light in the scene.
  9262. */
  9263. name: string;
  9264. /**
  9265. * Defines the shadow projection clipping minimum z value.
  9266. */
  9267. shadowMinZ: number;
  9268. /**
  9269. * Defines the shadow projection clipping maximum z value.
  9270. */
  9271. shadowMaxZ: number;
  9272. /**
  9273. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9274. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9275. */
  9276. computeTransformedInformation(): boolean;
  9277. /**
  9278. * Gets the scene the light belongs to.
  9279. * @returns The scene
  9280. */
  9281. getScene(): Scene;
  9282. /**
  9283. * Callback defining a custom Projection Matrix Builder.
  9284. * This can be used to override the default projection matrix computation.
  9285. */
  9286. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9287. /**
  9288. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9289. * @param matrix The materix to updated with the projection information
  9290. * @param viewMatrix The transform matrix of the light
  9291. * @param renderList The list of mesh to render in the map
  9292. * @returns The current light
  9293. */
  9294. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9295. /**
  9296. * Gets the current depth scale used in ESM.
  9297. * @returns The scale
  9298. */
  9299. getDepthScale(): number;
  9300. /**
  9301. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9302. * @returns true if a cube texture needs to be use
  9303. */
  9304. needCube(): boolean;
  9305. /**
  9306. * Detects if the projection matrix requires to be recomputed this frame.
  9307. * @returns true if it requires to be recomputed otherwise, false.
  9308. */
  9309. needProjectionMatrixCompute(): boolean;
  9310. /**
  9311. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9312. */
  9313. forceProjectionMatrixCompute(): void;
  9314. /**
  9315. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9316. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9317. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9318. */
  9319. getShadowDirection(faceIndex?: number): Vector3;
  9320. /**
  9321. * Gets the minZ used for shadow according to both the scene and the light.
  9322. * @param activeCamera The camera we are returning the min for
  9323. * @returns the depth min z
  9324. */
  9325. getDepthMinZ(activeCamera: Camera): number;
  9326. /**
  9327. * Gets the maxZ used for shadow according to both the scene and the light.
  9328. * @param activeCamera The camera we are returning the max for
  9329. * @returns the depth max z
  9330. */
  9331. getDepthMaxZ(activeCamera: Camera): number;
  9332. }
  9333. /**
  9334. * Base implementation IShadowLight
  9335. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9336. */
  9337. export abstract class ShadowLight extends Light implements IShadowLight {
  9338. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9339. protected _position: Vector3;
  9340. protected _setPosition(value: Vector3): void;
  9341. /**
  9342. * Sets the position the shadow will be casted from. Also use as the light position for both
  9343. * point and spot lights.
  9344. */
  9345. get position(): Vector3;
  9346. /**
  9347. * Sets the position the shadow will be casted from. Also use as the light position for both
  9348. * point and spot lights.
  9349. */
  9350. set position(value: Vector3);
  9351. protected _direction: Vector3;
  9352. protected _setDirection(value: Vector3): void;
  9353. /**
  9354. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9355. * Also use as the light direction on spot and directional lights.
  9356. */
  9357. get direction(): Vector3;
  9358. /**
  9359. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9360. * Also use as the light direction on spot and directional lights.
  9361. */
  9362. set direction(value: Vector3);
  9363. protected _shadowMinZ: number;
  9364. /**
  9365. * Gets the shadow projection clipping minimum z value.
  9366. */
  9367. get shadowMinZ(): number;
  9368. /**
  9369. * Sets the shadow projection clipping minimum z value.
  9370. */
  9371. set shadowMinZ(value: number);
  9372. protected _shadowMaxZ: number;
  9373. /**
  9374. * Sets the shadow projection clipping maximum z value.
  9375. */
  9376. get shadowMaxZ(): number;
  9377. /**
  9378. * Gets the shadow projection clipping maximum z value.
  9379. */
  9380. set shadowMaxZ(value: number);
  9381. /**
  9382. * Callback defining a custom Projection Matrix Builder.
  9383. * This can be used to override the default projection matrix computation.
  9384. */
  9385. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9386. /**
  9387. * The transformed position. Position of the light in world space taking parenting in account.
  9388. */
  9389. transformedPosition: Vector3;
  9390. /**
  9391. * The transformed direction. Direction of the light in world space taking parenting in account.
  9392. */
  9393. transformedDirection: Vector3;
  9394. private _needProjectionMatrixCompute;
  9395. /**
  9396. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9397. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9398. */
  9399. computeTransformedInformation(): boolean;
  9400. /**
  9401. * Return the depth scale used for the shadow map.
  9402. * @returns the depth scale.
  9403. */
  9404. getDepthScale(): number;
  9405. /**
  9406. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9407. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9408. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9409. */
  9410. getShadowDirection(faceIndex?: number): Vector3;
  9411. /**
  9412. * Returns the ShadowLight absolute position in the World.
  9413. * @returns the position vector in world space
  9414. */
  9415. getAbsolutePosition(): Vector3;
  9416. /**
  9417. * Sets the ShadowLight direction toward the passed target.
  9418. * @param target The point to target in local space
  9419. * @returns the updated ShadowLight direction
  9420. */
  9421. setDirectionToTarget(target: Vector3): Vector3;
  9422. /**
  9423. * Returns the light rotation in euler definition.
  9424. * @returns the x y z rotation in local space.
  9425. */
  9426. getRotation(): Vector3;
  9427. /**
  9428. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9429. * @returns true if a cube texture needs to be use
  9430. */
  9431. needCube(): boolean;
  9432. /**
  9433. * Detects if the projection matrix requires to be recomputed this frame.
  9434. * @returns true if it requires to be recomputed otherwise, false.
  9435. */
  9436. needProjectionMatrixCompute(): boolean;
  9437. /**
  9438. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9439. */
  9440. forceProjectionMatrixCompute(): void;
  9441. /** @hidden */
  9442. _initCache(): void;
  9443. /** @hidden */
  9444. _isSynchronized(): boolean;
  9445. /**
  9446. * Computes the world matrix of the node
  9447. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9448. * @returns the world matrix
  9449. */
  9450. computeWorldMatrix(force?: boolean): Matrix;
  9451. /**
  9452. * Gets the minZ used for shadow according to both the scene and the light.
  9453. * @param activeCamera The camera we are returning the min for
  9454. * @returns the depth min z
  9455. */
  9456. getDepthMinZ(activeCamera: Camera): number;
  9457. /**
  9458. * Gets the maxZ used for shadow according to both the scene and the light.
  9459. * @param activeCamera The camera we are returning the max for
  9460. * @returns the depth max z
  9461. */
  9462. getDepthMaxZ(activeCamera: Camera): number;
  9463. /**
  9464. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9465. * @param matrix The materix to updated with the projection information
  9466. * @param viewMatrix The transform matrix of the light
  9467. * @param renderList The list of mesh to render in the map
  9468. * @returns The current light
  9469. */
  9470. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9471. }
  9472. }
  9473. declare module BABYLON {
  9474. /**
  9475. * Configuration needed for prepass-capable materials
  9476. */
  9477. export class PrePassConfiguration {
  9478. /**
  9479. * Previous world matrices of meshes carrying this material
  9480. * Used for computing velocity
  9481. */
  9482. previousWorldMatrices: {
  9483. [index: number]: Matrix;
  9484. };
  9485. /**
  9486. * Previous view project matrix
  9487. * Used for computing velocity
  9488. */
  9489. previousViewProjection: Matrix;
  9490. /**
  9491. * Previous bones of meshes carrying this material
  9492. * Used for computing velocity
  9493. */
  9494. previousBones: {
  9495. [index: number]: Float32Array;
  9496. };
  9497. /**
  9498. * Add the required uniforms to the current list.
  9499. * @param uniforms defines the current uniform list.
  9500. */
  9501. static AddUniforms(uniforms: string[]): void;
  9502. /**
  9503. * Add the required samplers to the current list.
  9504. * @param samplers defines the current sampler list.
  9505. */
  9506. static AddSamplers(samplers: string[]): void;
  9507. /**
  9508. * Binds the material data.
  9509. * @param effect defines the effect to update
  9510. * @param scene defines the scene the material belongs to.
  9511. * @param mesh The mesh
  9512. * @param world World matrix of this mesh
  9513. * @param isFrozen Is the material frozen
  9514. */
  9515. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  9516. }
  9517. }
  9518. declare module BABYLON {
  9519. /**
  9520. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9521. * This is the base of the follow, arc rotate cameras and Free camera
  9522. * @see https://doc.babylonjs.com/features/cameras
  9523. */
  9524. export class TargetCamera extends Camera {
  9525. private static _RigCamTransformMatrix;
  9526. private static _TargetTransformMatrix;
  9527. private static _TargetFocalPoint;
  9528. private _tmpUpVector;
  9529. private _tmpTargetVector;
  9530. /**
  9531. * Define the current direction the camera is moving to
  9532. */
  9533. cameraDirection: Vector3;
  9534. /**
  9535. * Define the current rotation the camera is rotating to
  9536. */
  9537. cameraRotation: Vector2;
  9538. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  9539. ignoreParentScaling: boolean;
  9540. /**
  9541. * When set, the up vector of the camera will be updated by the rotation of the camera
  9542. */
  9543. updateUpVectorFromRotation: boolean;
  9544. private _tmpQuaternion;
  9545. /**
  9546. * Define the current rotation of the camera
  9547. */
  9548. rotation: Vector3;
  9549. /**
  9550. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9551. */
  9552. rotationQuaternion: Quaternion;
  9553. /**
  9554. * Define the current speed of the camera
  9555. */
  9556. speed: number;
  9557. /**
  9558. * Add constraint to the camera to prevent it to move freely in all directions and
  9559. * around all axis.
  9560. */
  9561. noRotationConstraint: boolean;
  9562. /**
  9563. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  9564. * panning
  9565. */
  9566. invertRotation: boolean;
  9567. /**
  9568. * Speed multiplier for inverse camera panning
  9569. */
  9570. inverseRotationSpeed: number;
  9571. /**
  9572. * Define the current target of the camera as an object or a position.
  9573. */
  9574. lockedTarget: any;
  9575. /** @hidden */
  9576. _currentTarget: Vector3;
  9577. /** @hidden */
  9578. _initialFocalDistance: number;
  9579. /** @hidden */
  9580. _viewMatrix: Matrix;
  9581. /** @hidden */
  9582. _camMatrix: Matrix;
  9583. /** @hidden */
  9584. _cameraTransformMatrix: Matrix;
  9585. /** @hidden */
  9586. _cameraRotationMatrix: Matrix;
  9587. /** @hidden */
  9588. _referencePoint: Vector3;
  9589. /** @hidden */
  9590. _transformedReferencePoint: Vector3;
  9591. /** @hidden */
  9592. _reset: () => void;
  9593. private _defaultUp;
  9594. /**
  9595. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9596. * This is the base of the follow, arc rotate cameras and Free camera
  9597. * @see https://doc.babylonjs.com/features/cameras
  9598. * @param name Defines the name of the camera in the scene
  9599. * @param position Defines the start position of the camera in the scene
  9600. * @param scene Defines the scene the camera belongs to
  9601. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9602. */
  9603. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9604. /**
  9605. * Gets the position in front of the camera at a given distance.
  9606. * @param distance The distance from the camera we want the position to be
  9607. * @returns the position
  9608. */
  9609. getFrontPosition(distance: number): Vector3;
  9610. /** @hidden */
  9611. _getLockedTargetPosition(): Nullable<Vector3>;
  9612. private _storedPosition;
  9613. private _storedRotation;
  9614. private _storedRotationQuaternion;
  9615. /**
  9616. * Store current camera state of the camera (fov, position, rotation, etc..)
  9617. * @returns the camera
  9618. */
  9619. storeState(): Camera;
  9620. /**
  9621. * Restored camera state. You must call storeState() first
  9622. * @returns whether it was successful or not
  9623. * @hidden
  9624. */
  9625. _restoreStateValues(): boolean;
  9626. /** @hidden */
  9627. _initCache(): void;
  9628. /** @hidden */
  9629. _updateCache(ignoreParentClass?: boolean): void;
  9630. /** @hidden */
  9631. _isSynchronizedViewMatrix(): boolean;
  9632. /** @hidden */
  9633. _computeLocalCameraSpeed(): number;
  9634. /**
  9635. * Defines the target the camera should look at.
  9636. * @param target Defines the new target as a Vector or a mesh
  9637. */
  9638. setTarget(target: Vector3): void;
  9639. /**
  9640. * Defines the target point of the camera.
  9641. * The camera looks towards it form the radius distance.
  9642. */
  9643. get target(): Vector3;
  9644. set target(value: Vector3);
  9645. /**
  9646. * Return the current target position of the camera. This value is expressed in local space.
  9647. * @returns the target position
  9648. */
  9649. getTarget(): Vector3;
  9650. /** @hidden */
  9651. _decideIfNeedsToMove(): boolean;
  9652. /** @hidden */
  9653. _updatePosition(): void;
  9654. /** @hidden */
  9655. _checkInputs(): void;
  9656. protected _updateCameraRotationMatrix(): void;
  9657. /**
  9658. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  9659. * @returns the current camera
  9660. */
  9661. private _rotateUpVectorWithCameraRotationMatrix;
  9662. private _cachedRotationZ;
  9663. private _cachedQuaternionRotationZ;
  9664. /** @hidden */
  9665. _getViewMatrix(): Matrix;
  9666. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9667. /**
  9668. * @hidden
  9669. */
  9670. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9671. /**
  9672. * @hidden
  9673. */
  9674. _updateRigCameras(): void;
  9675. private _getRigCamPositionAndTarget;
  9676. /**
  9677. * Gets the current object class name.
  9678. * @return the class name
  9679. */
  9680. getClassName(): string;
  9681. }
  9682. }
  9683. declare module BABYLON {
  9684. /**
  9685. * @ignore
  9686. * This is a list of all the different input types that are available in the application.
  9687. * Fo instance: ArcRotateCameraGamepadInput...
  9688. */
  9689. export var CameraInputTypes: {};
  9690. /**
  9691. * This is the contract to implement in order to create a new input class.
  9692. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9693. */
  9694. export interface ICameraInput<TCamera extends Camera> {
  9695. /**
  9696. * Defines the camera the input is attached to.
  9697. */
  9698. camera: Nullable<TCamera>;
  9699. /**
  9700. * Gets the class name of the current intput.
  9701. * @returns the class name
  9702. */
  9703. getClassName(): string;
  9704. /**
  9705. * Get the friendly name associated with the input class.
  9706. * @returns the input friendly name
  9707. */
  9708. getSimpleName(): string;
  9709. /**
  9710. * Attach the input controls to a specific dom element to get the input from.
  9711. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9712. */
  9713. attachControl(noPreventDefault?: boolean): void;
  9714. /**
  9715. * Detach the current controls from the specified dom element.
  9716. */
  9717. detachControl(): void;
  9718. /**
  9719. * Update the current camera state depending on the inputs that have been used this frame.
  9720. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9721. */
  9722. checkInputs?: () => void;
  9723. }
  9724. /**
  9725. * Represents a map of input types to input instance or input index to input instance.
  9726. */
  9727. export interface CameraInputsMap<TCamera extends Camera> {
  9728. /**
  9729. * Accessor to the input by input type.
  9730. */
  9731. [name: string]: ICameraInput<TCamera>;
  9732. /**
  9733. * Accessor to the input by input index.
  9734. */
  9735. [idx: number]: ICameraInput<TCamera>;
  9736. }
  9737. /**
  9738. * This represents the input manager used within a camera.
  9739. * It helps dealing with all the different kind of input attached to a camera.
  9740. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9741. */
  9742. export class CameraInputsManager<TCamera extends Camera> {
  9743. /**
  9744. * Defines the list of inputs attahed to the camera.
  9745. */
  9746. attached: CameraInputsMap<TCamera>;
  9747. /**
  9748. * Defines the dom element the camera is collecting inputs from.
  9749. * This is null if the controls have not been attached.
  9750. */
  9751. attachedToElement: boolean;
  9752. /**
  9753. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9754. */
  9755. noPreventDefault: boolean;
  9756. /**
  9757. * Defined the camera the input manager belongs to.
  9758. */
  9759. camera: TCamera;
  9760. /**
  9761. * Update the current camera state depending on the inputs that have been used this frame.
  9762. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9763. */
  9764. checkInputs: () => void;
  9765. /**
  9766. * Instantiate a new Camera Input Manager.
  9767. * @param camera Defines the camera the input manager blongs to
  9768. */
  9769. constructor(camera: TCamera);
  9770. /**
  9771. * Add an input method to a camera
  9772. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9773. * @param input camera input method
  9774. */
  9775. add(input: ICameraInput<TCamera>): void;
  9776. /**
  9777. * Remove a specific input method from a camera
  9778. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9779. * @param inputToRemove camera input method
  9780. */
  9781. remove(inputToRemove: ICameraInput<TCamera>): void;
  9782. /**
  9783. * Remove a specific input type from a camera
  9784. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9785. * @param inputType the type of the input to remove
  9786. */
  9787. removeByType(inputType: string): void;
  9788. private _addCheckInputs;
  9789. /**
  9790. * Attach the input controls to the currently attached dom element to listen the events from.
  9791. * @param input Defines the input to attach
  9792. */
  9793. attachInput(input: ICameraInput<TCamera>): void;
  9794. /**
  9795. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9796. * @param element Defines the dom element to collect the events from
  9797. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9798. */
  9799. attachElement(noPreventDefault?: boolean): void;
  9800. /**
  9801. * Detach the current manager inputs controls from a specific dom element.
  9802. * @param element Defines the dom element to collect the events from
  9803. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9804. */
  9805. detachElement(disconnect?: boolean): void;
  9806. /**
  9807. * Rebuild the dynamic inputCheck function from the current list of
  9808. * defined inputs in the manager.
  9809. */
  9810. rebuildInputCheck(): void;
  9811. /**
  9812. * Remove all attached input methods from a camera
  9813. */
  9814. clear(): void;
  9815. /**
  9816. * Serialize the current input manager attached to a camera.
  9817. * This ensures than once parsed,
  9818. * the input associated to the camera will be identical to the current ones
  9819. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9820. */
  9821. serialize(serializedCamera: any): void;
  9822. /**
  9823. * Parses an input manager serialized JSON to restore the previous list of inputs
  9824. * and states associated to a camera.
  9825. * @param parsedCamera Defines the JSON to parse
  9826. */
  9827. parse(parsedCamera: any): void;
  9828. }
  9829. }
  9830. declare module BABYLON {
  9831. /**
  9832. * Gather the list of keyboard event types as constants.
  9833. */
  9834. export class KeyboardEventTypes {
  9835. /**
  9836. * The keydown event is fired when a key becomes active (pressed).
  9837. */
  9838. static readonly KEYDOWN: number;
  9839. /**
  9840. * The keyup event is fired when a key has been released.
  9841. */
  9842. static readonly KEYUP: number;
  9843. }
  9844. /**
  9845. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9846. */
  9847. export class KeyboardInfo {
  9848. /**
  9849. * Defines the type of event (KeyboardEventTypes)
  9850. */
  9851. type: number;
  9852. /**
  9853. * Defines the related dom event
  9854. */
  9855. event: KeyboardEvent;
  9856. /**
  9857. * Instantiates a new keyboard info.
  9858. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9859. * @param type Defines the type of event (KeyboardEventTypes)
  9860. * @param event Defines the related dom event
  9861. */
  9862. constructor(
  9863. /**
  9864. * Defines the type of event (KeyboardEventTypes)
  9865. */
  9866. type: number,
  9867. /**
  9868. * Defines the related dom event
  9869. */
  9870. event: KeyboardEvent);
  9871. }
  9872. /**
  9873. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9874. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9875. */
  9876. export class KeyboardInfoPre extends KeyboardInfo {
  9877. /**
  9878. * Defines the type of event (KeyboardEventTypes)
  9879. */
  9880. type: number;
  9881. /**
  9882. * Defines the related dom event
  9883. */
  9884. event: KeyboardEvent;
  9885. /**
  9886. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9887. */
  9888. skipOnPointerObservable: boolean;
  9889. /**
  9890. * Instantiates a new keyboard pre info.
  9891. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9892. * @param type Defines the type of event (KeyboardEventTypes)
  9893. * @param event Defines the related dom event
  9894. */
  9895. constructor(
  9896. /**
  9897. * Defines the type of event (KeyboardEventTypes)
  9898. */
  9899. type: number,
  9900. /**
  9901. * Defines the related dom event
  9902. */
  9903. event: KeyboardEvent);
  9904. }
  9905. }
  9906. declare module BABYLON {
  9907. /**
  9908. * Manage the keyboard inputs to control the movement of a free camera.
  9909. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9910. */
  9911. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9912. /**
  9913. * Defines the camera the input is attached to.
  9914. */
  9915. camera: FreeCamera;
  9916. /**
  9917. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9918. */
  9919. keysUp: number[];
  9920. /**
  9921. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  9922. */
  9923. keysUpward: number[];
  9924. /**
  9925. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9926. */
  9927. keysDown: number[];
  9928. /**
  9929. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  9930. */
  9931. keysDownward: number[];
  9932. /**
  9933. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9934. */
  9935. keysLeft: number[];
  9936. /**
  9937. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9938. */
  9939. keysRight: number[];
  9940. private _keys;
  9941. private _onCanvasBlurObserver;
  9942. private _onKeyboardObserver;
  9943. private _engine;
  9944. private _scene;
  9945. /**
  9946. * Attach the input controls to a specific dom element to get the input from.
  9947. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9948. */
  9949. attachControl(noPreventDefault?: boolean): void;
  9950. /**
  9951. * Detach the current controls from the specified dom element.
  9952. */
  9953. detachControl(): void;
  9954. /**
  9955. * Update the current camera state depending on the inputs that have been used this frame.
  9956. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9957. */
  9958. checkInputs(): void;
  9959. /**
  9960. * Gets the class name of the current intput.
  9961. * @returns the class name
  9962. */
  9963. getClassName(): string;
  9964. /** @hidden */
  9965. _onLostFocus(): void;
  9966. /**
  9967. * Get the friendly name associated with the input class.
  9968. * @returns the input friendly name
  9969. */
  9970. getSimpleName(): string;
  9971. }
  9972. }
  9973. declare module BABYLON {
  9974. /**
  9975. * Interface used to define Action
  9976. */
  9977. export interface IAction {
  9978. /**
  9979. * Trigger for the action
  9980. */
  9981. trigger: number;
  9982. /** Options of the trigger */
  9983. triggerOptions: any;
  9984. /**
  9985. * Gets the trigger parameters
  9986. * @returns the trigger parameters
  9987. */
  9988. getTriggerParameter(): any;
  9989. /**
  9990. * Internal only - executes current action event
  9991. * @hidden
  9992. */
  9993. _executeCurrent(evt?: ActionEvent): void;
  9994. /**
  9995. * Serialize placeholder for child classes
  9996. * @param parent of child
  9997. * @returns the serialized object
  9998. */
  9999. serialize(parent: any): any;
  10000. /**
  10001. * Internal only
  10002. * @hidden
  10003. */
  10004. _prepare(): void;
  10005. /**
  10006. * Internal only - manager for action
  10007. * @hidden
  10008. */
  10009. _actionManager: Nullable<AbstractActionManager>;
  10010. /**
  10011. * Adds action to chain of actions, may be a DoNothingAction
  10012. * @param action defines the next action to execute
  10013. * @returns The action passed in
  10014. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10015. */
  10016. then(action: IAction): IAction;
  10017. }
  10018. /**
  10019. * The action to be carried out following a trigger
  10020. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10021. */
  10022. export class Action implements IAction {
  10023. /** the trigger, with or without parameters, for the action */
  10024. triggerOptions: any;
  10025. /**
  10026. * Trigger for the action
  10027. */
  10028. trigger: number;
  10029. /**
  10030. * Internal only - manager for action
  10031. * @hidden
  10032. */
  10033. _actionManager: ActionManager;
  10034. private _nextActiveAction;
  10035. private _child;
  10036. private _condition?;
  10037. private _triggerParameter;
  10038. /**
  10039. * An event triggered prior to action being executed.
  10040. */
  10041. onBeforeExecuteObservable: Observable<Action>;
  10042. /**
  10043. * Creates a new Action
  10044. * @param triggerOptions the trigger, with or without parameters, for the action
  10045. * @param condition an optional determinant of action
  10046. */
  10047. constructor(
  10048. /** the trigger, with or without parameters, for the action */
  10049. triggerOptions: any, condition?: Condition);
  10050. /**
  10051. * Internal only
  10052. * @hidden
  10053. */
  10054. _prepare(): void;
  10055. /**
  10056. * Gets the trigger parameter
  10057. * @returns the trigger parameter
  10058. */
  10059. getTriggerParameter(): any;
  10060. /**
  10061. * Sets the trigger parameter
  10062. * @param value defines the new trigger parameter
  10063. */
  10064. setTriggerParameter(value: any): void;
  10065. /**
  10066. * Internal only - executes current action event
  10067. * @hidden
  10068. */
  10069. _executeCurrent(evt?: ActionEvent): void;
  10070. /**
  10071. * Execute placeholder for child classes
  10072. * @param evt optional action event
  10073. */
  10074. execute(evt?: ActionEvent): void;
  10075. /**
  10076. * Skips to next active action
  10077. */
  10078. skipToNextActiveAction(): void;
  10079. /**
  10080. * Adds action to chain of actions, may be a DoNothingAction
  10081. * @param action defines the next action to execute
  10082. * @returns The action passed in
  10083. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10084. */
  10085. then(action: Action): Action;
  10086. /**
  10087. * Internal only
  10088. * @hidden
  10089. */
  10090. _getProperty(propertyPath: string): string;
  10091. /**
  10092. * Internal only
  10093. * @hidden
  10094. */
  10095. _getEffectiveTarget(target: any, propertyPath: string): any;
  10096. /**
  10097. * Serialize placeholder for child classes
  10098. * @param parent of child
  10099. * @returns the serialized object
  10100. */
  10101. serialize(parent: any): any;
  10102. /**
  10103. * Internal only called by serialize
  10104. * @hidden
  10105. */
  10106. protected _serialize(serializedAction: any, parent?: any): any;
  10107. /**
  10108. * Internal only
  10109. * @hidden
  10110. */
  10111. static _SerializeValueAsString: (value: any) => string;
  10112. /**
  10113. * Internal only
  10114. * @hidden
  10115. */
  10116. static _GetTargetProperty: (target: Scene | Node) => {
  10117. name: string;
  10118. targetType: string;
  10119. value: string;
  10120. };
  10121. }
  10122. }
  10123. declare module BABYLON {
  10124. /**
  10125. * A Condition applied to an Action
  10126. */
  10127. export class Condition {
  10128. /**
  10129. * Internal only - manager for action
  10130. * @hidden
  10131. */
  10132. _actionManager: ActionManager;
  10133. /**
  10134. * Internal only
  10135. * @hidden
  10136. */
  10137. _evaluationId: number;
  10138. /**
  10139. * Internal only
  10140. * @hidden
  10141. */
  10142. _currentResult: boolean;
  10143. /**
  10144. * Creates a new Condition
  10145. * @param actionManager the manager of the action the condition is applied to
  10146. */
  10147. constructor(actionManager: ActionManager);
  10148. /**
  10149. * Check if the current condition is valid
  10150. * @returns a boolean
  10151. */
  10152. isValid(): boolean;
  10153. /**
  10154. * Internal only
  10155. * @hidden
  10156. */
  10157. _getProperty(propertyPath: string): string;
  10158. /**
  10159. * Internal only
  10160. * @hidden
  10161. */
  10162. _getEffectiveTarget(target: any, propertyPath: string): any;
  10163. /**
  10164. * Serialize placeholder for child classes
  10165. * @returns the serialized object
  10166. */
  10167. serialize(): any;
  10168. /**
  10169. * Internal only
  10170. * @hidden
  10171. */
  10172. protected _serialize(serializedCondition: any): any;
  10173. }
  10174. /**
  10175. * Defines specific conditional operators as extensions of Condition
  10176. */
  10177. export class ValueCondition extends Condition {
  10178. /** path to specify the property of the target the conditional operator uses */
  10179. propertyPath: string;
  10180. /** the value compared by the conditional operator against the current value of the property */
  10181. value: any;
  10182. /** the conditional operator, default ValueCondition.IsEqual */
  10183. operator: number;
  10184. /**
  10185. * Internal only
  10186. * @hidden
  10187. */
  10188. private static _IsEqual;
  10189. /**
  10190. * Internal only
  10191. * @hidden
  10192. */
  10193. private static _IsDifferent;
  10194. /**
  10195. * Internal only
  10196. * @hidden
  10197. */
  10198. private static _IsGreater;
  10199. /**
  10200. * Internal only
  10201. * @hidden
  10202. */
  10203. private static _IsLesser;
  10204. /**
  10205. * returns the number for IsEqual
  10206. */
  10207. static get IsEqual(): number;
  10208. /**
  10209. * Returns the number for IsDifferent
  10210. */
  10211. static get IsDifferent(): number;
  10212. /**
  10213. * Returns the number for IsGreater
  10214. */
  10215. static get IsGreater(): number;
  10216. /**
  10217. * Returns the number for IsLesser
  10218. */
  10219. static get IsLesser(): number;
  10220. /**
  10221. * Internal only The action manager for the condition
  10222. * @hidden
  10223. */
  10224. _actionManager: ActionManager;
  10225. /**
  10226. * Internal only
  10227. * @hidden
  10228. */
  10229. private _target;
  10230. /**
  10231. * Internal only
  10232. * @hidden
  10233. */
  10234. private _effectiveTarget;
  10235. /**
  10236. * Internal only
  10237. * @hidden
  10238. */
  10239. private _property;
  10240. /**
  10241. * Creates a new ValueCondition
  10242. * @param actionManager manager for the action the condition applies to
  10243. * @param target for the action
  10244. * @param propertyPath path to specify the property of the target the conditional operator uses
  10245. * @param value the value compared by the conditional operator against the current value of the property
  10246. * @param operator the conditional operator, default ValueCondition.IsEqual
  10247. */
  10248. constructor(actionManager: ActionManager, target: any,
  10249. /** path to specify the property of the target the conditional operator uses */
  10250. propertyPath: string,
  10251. /** the value compared by the conditional operator against the current value of the property */
  10252. value: any,
  10253. /** the conditional operator, default ValueCondition.IsEqual */
  10254. operator?: number);
  10255. /**
  10256. * Compares the given value with the property value for the specified conditional operator
  10257. * @returns the result of the comparison
  10258. */
  10259. isValid(): boolean;
  10260. /**
  10261. * Serialize the ValueCondition into a JSON compatible object
  10262. * @returns serialization object
  10263. */
  10264. serialize(): any;
  10265. /**
  10266. * Gets the name of the conditional operator for the ValueCondition
  10267. * @param operator the conditional operator
  10268. * @returns the name
  10269. */
  10270. static GetOperatorName(operator: number): string;
  10271. }
  10272. /**
  10273. * Defines a predicate condition as an extension of Condition
  10274. */
  10275. export class PredicateCondition extends Condition {
  10276. /** defines the predicate function used to validate the condition */
  10277. predicate: () => boolean;
  10278. /**
  10279. * Internal only - manager for action
  10280. * @hidden
  10281. */
  10282. _actionManager: ActionManager;
  10283. /**
  10284. * Creates a new PredicateCondition
  10285. * @param actionManager manager for the action the condition applies to
  10286. * @param predicate defines the predicate function used to validate the condition
  10287. */
  10288. constructor(actionManager: ActionManager,
  10289. /** defines the predicate function used to validate the condition */
  10290. predicate: () => boolean);
  10291. /**
  10292. * @returns the validity of the predicate condition
  10293. */
  10294. isValid(): boolean;
  10295. }
  10296. /**
  10297. * Defines a state condition as an extension of Condition
  10298. */
  10299. export class StateCondition extends Condition {
  10300. /** Value to compare with target state */
  10301. value: string;
  10302. /**
  10303. * Internal only - manager for action
  10304. * @hidden
  10305. */
  10306. _actionManager: ActionManager;
  10307. /**
  10308. * Internal only
  10309. * @hidden
  10310. */
  10311. private _target;
  10312. /**
  10313. * Creates a new StateCondition
  10314. * @param actionManager manager for the action the condition applies to
  10315. * @param target of the condition
  10316. * @param value to compare with target state
  10317. */
  10318. constructor(actionManager: ActionManager, target: any,
  10319. /** Value to compare with target state */
  10320. value: string);
  10321. /**
  10322. * Gets a boolean indicating if the current condition is met
  10323. * @returns the validity of the state
  10324. */
  10325. isValid(): boolean;
  10326. /**
  10327. * Serialize the StateCondition into a JSON compatible object
  10328. * @returns serialization object
  10329. */
  10330. serialize(): any;
  10331. }
  10332. }
  10333. declare module BABYLON {
  10334. /**
  10335. * This defines an action responsible to toggle a boolean once triggered.
  10336. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10337. */
  10338. export class SwitchBooleanAction extends Action {
  10339. /**
  10340. * The path to the boolean property in the target object
  10341. */
  10342. propertyPath: string;
  10343. private _target;
  10344. private _effectiveTarget;
  10345. private _property;
  10346. /**
  10347. * Instantiate the action
  10348. * @param triggerOptions defines the trigger options
  10349. * @param target defines the object containing the boolean
  10350. * @param propertyPath defines the path to the boolean property in the target object
  10351. * @param condition defines the trigger related conditions
  10352. */
  10353. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10354. /** @hidden */
  10355. _prepare(): void;
  10356. /**
  10357. * Execute the action toggle the boolean value.
  10358. */
  10359. execute(): void;
  10360. /**
  10361. * Serializes the actions and its related information.
  10362. * @param parent defines the object to serialize in
  10363. * @returns the serialized object
  10364. */
  10365. serialize(parent: any): any;
  10366. }
  10367. /**
  10368. * This defines an action responsible to set a the state field of the target
  10369. * to a desired value once triggered.
  10370. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10371. */
  10372. export class SetStateAction extends Action {
  10373. /**
  10374. * The value to store in the state field.
  10375. */
  10376. value: string;
  10377. private _target;
  10378. /**
  10379. * Instantiate the action
  10380. * @param triggerOptions defines the trigger options
  10381. * @param target defines the object containing the state property
  10382. * @param value defines the value to store in the state field
  10383. * @param condition defines the trigger related conditions
  10384. */
  10385. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10386. /**
  10387. * Execute the action and store the value on the target state property.
  10388. */
  10389. execute(): void;
  10390. /**
  10391. * Serializes the actions and its related information.
  10392. * @param parent defines the object to serialize in
  10393. * @returns the serialized object
  10394. */
  10395. serialize(parent: any): any;
  10396. }
  10397. /**
  10398. * This defines an action responsible to set a property of the target
  10399. * to a desired value once triggered.
  10400. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10401. */
  10402. export class SetValueAction extends Action {
  10403. /**
  10404. * The path of the property to set in the target.
  10405. */
  10406. propertyPath: string;
  10407. /**
  10408. * The value to set in the property
  10409. */
  10410. value: any;
  10411. private _target;
  10412. private _effectiveTarget;
  10413. private _property;
  10414. /**
  10415. * Instantiate the action
  10416. * @param triggerOptions defines the trigger options
  10417. * @param target defines the object containing the property
  10418. * @param propertyPath defines the path of the property to set in the target
  10419. * @param value defines the value to set in the property
  10420. * @param condition defines the trigger related conditions
  10421. */
  10422. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10423. /** @hidden */
  10424. _prepare(): void;
  10425. /**
  10426. * Execute the action and set the targetted property to the desired value.
  10427. */
  10428. execute(): void;
  10429. /**
  10430. * Serializes the actions and its related information.
  10431. * @param parent defines the object to serialize in
  10432. * @returns the serialized object
  10433. */
  10434. serialize(parent: any): any;
  10435. }
  10436. /**
  10437. * This defines an action responsible to increment the target value
  10438. * to a desired value once triggered.
  10439. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10440. */
  10441. export class IncrementValueAction extends Action {
  10442. /**
  10443. * The path of the property to increment in the target.
  10444. */
  10445. propertyPath: string;
  10446. /**
  10447. * The value we should increment the property by.
  10448. */
  10449. value: any;
  10450. private _target;
  10451. private _effectiveTarget;
  10452. private _property;
  10453. /**
  10454. * Instantiate the action
  10455. * @param triggerOptions defines the trigger options
  10456. * @param target defines the object containing the property
  10457. * @param propertyPath defines the path of the property to increment in the target
  10458. * @param value defines the value value we should increment the property by
  10459. * @param condition defines the trigger related conditions
  10460. */
  10461. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10462. /** @hidden */
  10463. _prepare(): void;
  10464. /**
  10465. * Execute the action and increment the target of the value amount.
  10466. */
  10467. execute(): void;
  10468. /**
  10469. * Serializes the actions and its related information.
  10470. * @param parent defines the object to serialize in
  10471. * @returns the serialized object
  10472. */
  10473. serialize(parent: any): any;
  10474. }
  10475. /**
  10476. * This defines an action responsible to start an animation once triggered.
  10477. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10478. */
  10479. export class PlayAnimationAction extends Action {
  10480. /**
  10481. * Where the animation should start (animation frame)
  10482. */
  10483. from: number;
  10484. /**
  10485. * Where the animation should stop (animation frame)
  10486. */
  10487. to: number;
  10488. /**
  10489. * Define if the animation should loop or stop after the first play.
  10490. */
  10491. loop?: boolean;
  10492. private _target;
  10493. /**
  10494. * Instantiate the action
  10495. * @param triggerOptions defines the trigger options
  10496. * @param target defines the target animation or animation name
  10497. * @param from defines from where the animation should start (animation frame)
  10498. * @param end defines where the animation should stop (animation frame)
  10499. * @param loop defines if the animation should loop or stop after the first play
  10500. * @param condition defines the trigger related conditions
  10501. */
  10502. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10503. /** @hidden */
  10504. _prepare(): void;
  10505. /**
  10506. * Execute the action and play the animation.
  10507. */
  10508. execute(): void;
  10509. /**
  10510. * Serializes the actions and its related information.
  10511. * @param parent defines the object to serialize in
  10512. * @returns the serialized object
  10513. */
  10514. serialize(parent: any): any;
  10515. }
  10516. /**
  10517. * This defines an action responsible to stop an animation once triggered.
  10518. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10519. */
  10520. export class StopAnimationAction extends Action {
  10521. private _target;
  10522. /**
  10523. * Instantiate the action
  10524. * @param triggerOptions defines the trigger options
  10525. * @param target defines the target animation or animation name
  10526. * @param condition defines the trigger related conditions
  10527. */
  10528. constructor(triggerOptions: any, target: any, condition?: Condition);
  10529. /** @hidden */
  10530. _prepare(): void;
  10531. /**
  10532. * Execute the action and stop the animation.
  10533. */
  10534. execute(): void;
  10535. /**
  10536. * Serializes the actions and its related information.
  10537. * @param parent defines the object to serialize in
  10538. * @returns the serialized object
  10539. */
  10540. serialize(parent: any): any;
  10541. }
  10542. /**
  10543. * This defines an action responsible that does nothing once triggered.
  10544. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10545. */
  10546. export class DoNothingAction extends Action {
  10547. /**
  10548. * Instantiate the action
  10549. * @param triggerOptions defines the trigger options
  10550. * @param condition defines the trigger related conditions
  10551. */
  10552. constructor(triggerOptions?: any, condition?: Condition);
  10553. /**
  10554. * Execute the action and do nothing.
  10555. */
  10556. execute(): void;
  10557. /**
  10558. * Serializes the actions and its related information.
  10559. * @param parent defines the object to serialize in
  10560. * @returns the serialized object
  10561. */
  10562. serialize(parent: any): any;
  10563. }
  10564. /**
  10565. * This defines an action responsible to trigger several actions once triggered.
  10566. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10567. */
  10568. export class CombineAction extends Action {
  10569. /**
  10570. * The list of aggregated animations to run.
  10571. */
  10572. children: Action[];
  10573. /**
  10574. * Instantiate the action
  10575. * @param triggerOptions defines the trigger options
  10576. * @param children defines the list of aggregated animations to run
  10577. * @param condition defines the trigger related conditions
  10578. */
  10579. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10580. /** @hidden */
  10581. _prepare(): void;
  10582. /**
  10583. * Execute the action and executes all the aggregated actions.
  10584. */
  10585. execute(evt: ActionEvent): void;
  10586. /**
  10587. * Serializes the actions and its related information.
  10588. * @param parent defines the object to serialize in
  10589. * @returns the serialized object
  10590. */
  10591. serialize(parent: any): any;
  10592. }
  10593. /**
  10594. * This defines an action responsible to run code (external event) once triggered.
  10595. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10596. */
  10597. export class ExecuteCodeAction extends Action {
  10598. /**
  10599. * The callback function to run.
  10600. */
  10601. func: (evt: ActionEvent) => void;
  10602. /**
  10603. * Instantiate the action
  10604. * @param triggerOptions defines the trigger options
  10605. * @param func defines the callback function to run
  10606. * @param condition defines the trigger related conditions
  10607. */
  10608. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10609. /**
  10610. * Execute the action and run the attached code.
  10611. */
  10612. execute(evt: ActionEvent): void;
  10613. }
  10614. /**
  10615. * This defines an action responsible to set the parent property of the target once triggered.
  10616. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10617. */
  10618. export class SetParentAction extends Action {
  10619. private _parent;
  10620. private _target;
  10621. /**
  10622. * Instantiate the action
  10623. * @param triggerOptions defines the trigger options
  10624. * @param target defines the target containing the parent property
  10625. * @param parent defines from where the animation should start (animation frame)
  10626. * @param condition defines the trigger related conditions
  10627. */
  10628. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10629. /** @hidden */
  10630. _prepare(): void;
  10631. /**
  10632. * Execute the action and set the parent property.
  10633. */
  10634. execute(): void;
  10635. /**
  10636. * Serializes the actions and its related information.
  10637. * @param parent defines the object to serialize in
  10638. * @returns the serialized object
  10639. */
  10640. serialize(parent: any): any;
  10641. }
  10642. }
  10643. declare module BABYLON {
  10644. /**
  10645. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10646. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10647. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10648. */
  10649. export class ActionManager extends AbstractActionManager {
  10650. /**
  10651. * Nothing
  10652. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10653. */
  10654. static readonly NothingTrigger: number;
  10655. /**
  10656. * On pick
  10657. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10658. */
  10659. static readonly OnPickTrigger: number;
  10660. /**
  10661. * On left pick
  10662. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10663. */
  10664. static readonly OnLeftPickTrigger: number;
  10665. /**
  10666. * On right pick
  10667. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10668. */
  10669. static readonly OnRightPickTrigger: number;
  10670. /**
  10671. * On center pick
  10672. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10673. */
  10674. static readonly OnCenterPickTrigger: number;
  10675. /**
  10676. * On pick down
  10677. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10678. */
  10679. static readonly OnPickDownTrigger: number;
  10680. /**
  10681. * On double pick
  10682. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10683. */
  10684. static readonly OnDoublePickTrigger: number;
  10685. /**
  10686. * On pick up
  10687. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10688. */
  10689. static readonly OnPickUpTrigger: number;
  10690. /**
  10691. * On pick out.
  10692. * This trigger will only be raised if you also declared a OnPickDown
  10693. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10694. */
  10695. static readonly OnPickOutTrigger: number;
  10696. /**
  10697. * On long press
  10698. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10699. */
  10700. static readonly OnLongPressTrigger: number;
  10701. /**
  10702. * On pointer over
  10703. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10704. */
  10705. static readonly OnPointerOverTrigger: number;
  10706. /**
  10707. * On pointer out
  10708. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10709. */
  10710. static readonly OnPointerOutTrigger: number;
  10711. /**
  10712. * On every frame
  10713. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10714. */
  10715. static readonly OnEveryFrameTrigger: number;
  10716. /**
  10717. * On intersection enter
  10718. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10719. */
  10720. static readonly OnIntersectionEnterTrigger: number;
  10721. /**
  10722. * On intersection exit
  10723. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10724. */
  10725. static readonly OnIntersectionExitTrigger: number;
  10726. /**
  10727. * On key down
  10728. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10729. */
  10730. static readonly OnKeyDownTrigger: number;
  10731. /**
  10732. * On key up
  10733. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10734. */
  10735. static readonly OnKeyUpTrigger: number;
  10736. private _scene;
  10737. /**
  10738. * Creates a new action manager
  10739. * @param scene defines the hosting scene
  10740. */
  10741. constructor(scene: Scene);
  10742. /**
  10743. * Releases all associated resources
  10744. */
  10745. dispose(): void;
  10746. /**
  10747. * Gets hosting scene
  10748. * @returns the hosting scene
  10749. */
  10750. getScene(): Scene;
  10751. /**
  10752. * Does this action manager handles actions of any of the given triggers
  10753. * @param triggers defines the triggers to be tested
  10754. * @return a boolean indicating whether one (or more) of the triggers is handled
  10755. */
  10756. hasSpecificTriggers(triggers: number[]): boolean;
  10757. /**
  10758. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10759. * speed.
  10760. * @param triggerA defines the trigger to be tested
  10761. * @param triggerB defines the trigger to be tested
  10762. * @return a boolean indicating whether one (or more) of the triggers is handled
  10763. */
  10764. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10765. /**
  10766. * Does this action manager handles actions of a given trigger
  10767. * @param trigger defines the trigger to be tested
  10768. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10769. * @return whether the trigger is handled
  10770. */
  10771. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10772. /**
  10773. * Does this action manager has pointer triggers
  10774. */
  10775. get hasPointerTriggers(): boolean;
  10776. /**
  10777. * Does this action manager has pick triggers
  10778. */
  10779. get hasPickTriggers(): boolean;
  10780. /**
  10781. * Registers an action to this action manager
  10782. * @param action defines the action to be registered
  10783. * @return the action amended (prepared) after registration
  10784. */
  10785. registerAction(action: IAction): Nullable<IAction>;
  10786. /**
  10787. * Unregisters an action to this action manager
  10788. * @param action defines the action to be unregistered
  10789. * @return a boolean indicating whether the action has been unregistered
  10790. */
  10791. unregisterAction(action: IAction): Boolean;
  10792. /**
  10793. * Process a specific trigger
  10794. * @param trigger defines the trigger to process
  10795. * @param evt defines the event details to be processed
  10796. */
  10797. processTrigger(trigger: number, evt?: IActionEvent): void;
  10798. /** @hidden */
  10799. _getEffectiveTarget(target: any, propertyPath: string): any;
  10800. /** @hidden */
  10801. _getProperty(propertyPath: string): string;
  10802. /**
  10803. * Serialize this manager to a JSON object
  10804. * @param name defines the property name to store this manager
  10805. * @returns a JSON representation of this manager
  10806. */
  10807. serialize(name: string): any;
  10808. /**
  10809. * Creates a new ActionManager from a JSON data
  10810. * @param parsedActions defines the JSON data to read from
  10811. * @param object defines the hosting mesh
  10812. * @param scene defines the hosting scene
  10813. */
  10814. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10815. /**
  10816. * Get a trigger name by index
  10817. * @param trigger defines the trigger index
  10818. * @returns a trigger name
  10819. */
  10820. static GetTriggerName(trigger: number): string;
  10821. }
  10822. }
  10823. declare module BABYLON {
  10824. /**
  10825. * Class representing a ray with position and direction
  10826. */
  10827. export class Ray {
  10828. /** origin point */
  10829. origin: Vector3;
  10830. /** direction */
  10831. direction: Vector3;
  10832. /** length of the ray */
  10833. length: number;
  10834. private static readonly _TmpVector3;
  10835. private _tmpRay;
  10836. /**
  10837. * Creates a new ray
  10838. * @param origin origin point
  10839. * @param direction direction
  10840. * @param length length of the ray
  10841. */
  10842. constructor(
  10843. /** origin point */
  10844. origin: Vector3,
  10845. /** direction */
  10846. direction: Vector3,
  10847. /** length of the ray */
  10848. length?: number);
  10849. /**
  10850. * Checks if the ray intersects a box
  10851. * This does not account for the ray lenght by design to improve perfs.
  10852. * @param minimum bound of the box
  10853. * @param maximum bound of the box
  10854. * @param intersectionTreshold extra extend to be added to the box in all direction
  10855. * @returns if the box was hit
  10856. */
  10857. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10858. /**
  10859. * Checks if the ray intersects a box
  10860. * This does not account for the ray lenght by design to improve perfs.
  10861. * @param box the bounding box to check
  10862. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10863. * @returns if the box was hit
  10864. */
  10865. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10866. /**
  10867. * If the ray hits a sphere
  10868. * @param sphere the bounding sphere to check
  10869. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10870. * @returns true if it hits the sphere
  10871. */
  10872. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10873. /**
  10874. * If the ray hits a triange
  10875. * @param vertex0 triangle vertex
  10876. * @param vertex1 triangle vertex
  10877. * @param vertex2 triangle vertex
  10878. * @returns intersection information if hit
  10879. */
  10880. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10881. /**
  10882. * Checks if ray intersects a plane
  10883. * @param plane the plane to check
  10884. * @returns the distance away it was hit
  10885. */
  10886. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10887. /**
  10888. * Calculate the intercept of a ray on a given axis
  10889. * @param axis to check 'x' | 'y' | 'z'
  10890. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10891. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10892. */
  10893. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10894. /**
  10895. * Checks if ray intersects a mesh
  10896. * @param mesh the mesh to check
  10897. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10898. * @returns picking info of the intersecton
  10899. */
  10900. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10901. /**
  10902. * Checks if ray intersects a mesh
  10903. * @param meshes the meshes to check
  10904. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10905. * @param results array to store result in
  10906. * @returns Array of picking infos
  10907. */
  10908. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10909. private _comparePickingInfo;
  10910. private static smallnum;
  10911. private static rayl;
  10912. /**
  10913. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10914. * @param sega the first point of the segment to test the intersection against
  10915. * @param segb the second point of the segment to test the intersection against
  10916. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10917. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10918. */
  10919. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10920. /**
  10921. * Update the ray from viewport position
  10922. * @param x position
  10923. * @param y y position
  10924. * @param viewportWidth viewport width
  10925. * @param viewportHeight viewport height
  10926. * @param world world matrix
  10927. * @param view view matrix
  10928. * @param projection projection matrix
  10929. * @returns this ray updated
  10930. */
  10931. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10932. /**
  10933. * Creates a ray with origin and direction of 0,0,0
  10934. * @returns the new ray
  10935. */
  10936. static Zero(): Ray;
  10937. /**
  10938. * Creates a new ray from screen space and viewport
  10939. * @param x position
  10940. * @param y y position
  10941. * @param viewportWidth viewport width
  10942. * @param viewportHeight viewport height
  10943. * @param world world matrix
  10944. * @param view view matrix
  10945. * @param projection projection matrix
  10946. * @returns new ray
  10947. */
  10948. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10949. /**
  10950. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  10951. * transformed to the given world matrix.
  10952. * @param origin The origin point
  10953. * @param end The end point
  10954. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10955. * @returns the new ray
  10956. */
  10957. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10958. /**
  10959. * Transforms a ray by a matrix
  10960. * @param ray ray to transform
  10961. * @param matrix matrix to apply
  10962. * @returns the resulting new ray
  10963. */
  10964. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10965. /**
  10966. * Transforms a ray by a matrix
  10967. * @param ray ray to transform
  10968. * @param matrix matrix to apply
  10969. * @param result ray to store result in
  10970. */
  10971. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10972. /**
  10973. * Unproject a ray from screen space to object space
  10974. * @param sourceX defines the screen space x coordinate to use
  10975. * @param sourceY defines the screen space y coordinate to use
  10976. * @param viewportWidth defines the current width of the viewport
  10977. * @param viewportHeight defines the current height of the viewport
  10978. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10979. * @param view defines the view matrix to use
  10980. * @param projection defines the projection matrix to use
  10981. */
  10982. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10983. }
  10984. /**
  10985. * Type used to define predicate used to select faces when a mesh intersection is detected
  10986. */
  10987. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10988. interface Scene {
  10989. /** @hidden */
  10990. _tempPickingRay: Nullable<Ray>;
  10991. /** @hidden */
  10992. _cachedRayForTransform: Ray;
  10993. /** @hidden */
  10994. _pickWithRayInverseMatrix: Matrix;
  10995. /** @hidden */
  10996. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10997. /** @hidden */
  10998. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10999. /** @hidden */
  11000. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  11001. }
  11002. }
  11003. declare module BABYLON {
  11004. /**
  11005. * Groups all the scene component constants in one place to ease maintenance.
  11006. * @hidden
  11007. */
  11008. export class SceneComponentConstants {
  11009. static readonly NAME_EFFECTLAYER: string;
  11010. static readonly NAME_LAYER: string;
  11011. static readonly NAME_LENSFLARESYSTEM: string;
  11012. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11013. static readonly NAME_PARTICLESYSTEM: string;
  11014. static readonly NAME_GAMEPAD: string;
  11015. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11016. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11017. static readonly NAME_PREPASSRENDERER: string;
  11018. static readonly NAME_DEPTHRENDERER: string;
  11019. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11020. static readonly NAME_SPRITE: string;
  11021. static readonly NAME_SUBSURFACE: string;
  11022. static readonly NAME_OUTLINERENDERER: string;
  11023. static readonly NAME_PROCEDURALTEXTURE: string;
  11024. static readonly NAME_SHADOWGENERATOR: string;
  11025. static readonly NAME_OCTREE: string;
  11026. static readonly NAME_PHYSICSENGINE: string;
  11027. static readonly NAME_AUDIO: string;
  11028. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11029. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11030. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11031. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11032. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11033. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11034. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11035. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  11036. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11037. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  11038. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11039. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  11040. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11041. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11042. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11043. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11044. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11045. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11046. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11047. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11048. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11049. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11050. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11051. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  11052. static readonly STEP_AFTERRENDER_AUDIO: number;
  11053. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11054. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11055. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11056. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11057. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11058. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  11059. static readonly STEP_POINTERMOVE_SPRITE: number;
  11060. static readonly STEP_POINTERDOWN_SPRITE: number;
  11061. static readonly STEP_POINTERUP_SPRITE: number;
  11062. }
  11063. /**
  11064. * This represents a scene component.
  11065. *
  11066. * This is used to decouple the dependency the scene is having on the different workloads like
  11067. * layers, post processes...
  11068. */
  11069. export interface ISceneComponent {
  11070. /**
  11071. * The name of the component. Each component must have a unique name.
  11072. */
  11073. name: string;
  11074. /**
  11075. * The scene the component belongs to.
  11076. */
  11077. scene: Scene;
  11078. /**
  11079. * Register the component to one instance of a scene.
  11080. */
  11081. register(): void;
  11082. /**
  11083. * Rebuilds the elements related to this component in case of
  11084. * context lost for instance.
  11085. */
  11086. rebuild(): void;
  11087. /**
  11088. * Disposes the component and the associated ressources.
  11089. */
  11090. dispose(): void;
  11091. }
  11092. /**
  11093. * This represents a SERIALIZABLE scene component.
  11094. *
  11095. * This extends Scene Component to add Serialization methods on top.
  11096. */
  11097. export interface ISceneSerializableComponent extends ISceneComponent {
  11098. /**
  11099. * Adds all the elements from the container to the scene
  11100. * @param container the container holding the elements
  11101. */
  11102. addFromContainer(container: AbstractScene): void;
  11103. /**
  11104. * Removes all the elements in the container from the scene
  11105. * @param container contains the elements to remove
  11106. * @param dispose if the removed element should be disposed (default: false)
  11107. */
  11108. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11109. /**
  11110. * Serializes the component data to the specified json object
  11111. * @param serializationObject The object to serialize to
  11112. */
  11113. serialize(serializationObject: any): void;
  11114. }
  11115. /**
  11116. * Strong typing of a Mesh related stage step action
  11117. */
  11118. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11119. /**
  11120. * Strong typing of a Evaluate Sub Mesh related stage step action
  11121. */
  11122. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11123. /**
  11124. * Strong typing of a pre active Mesh related stage step action
  11125. */
  11126. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  11127. /**
  11128. * Strong typing of a Camera related stage step action
  11129. */
  11130. export type CameraStageAction = (camera: Camera) => void;
  11131. /**
  11132. * Strong typing of a Camera Frame buffer related stage step action
  11133. */
  11134. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11135. /**
  11136. * Strong typing of a Render Target related stage step action
  11137. */
  11138. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11139. /**
  11140. * Strong typing of a RenderingGroup related stage step action
  11141. */
  11142. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11143. /**
  11144. * Strong typing of a Mesh Render related stage step action
  11145. */
  11146. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  11147. /**
  11148. * Strong typing of a simple stage step action
  11149. */
  11150. export type SimpleStageAction = () => void;
  11151. /**
  11152. * Strong typing of a render target action.
  11153. */
  11154. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11155. /**
  11156. * Strong typing of a pointer move action.
  11157. */
  11158. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11159. /**
  11160. * Strong typing of a pointer up/down action.
  11161. */
  11162. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11163. /**
  11164. * Representation of a stage in the scene (Basically a list of ordered steps)
  11165. * @hidden
  11166. */
  11167. export class Stage<T extends Function> extends Array<{
  11168. index: number;
  11169. component: ISceneComponent;
  11170. action: T;
  11171. }> {
  11172. /**
  11173. * Hide ctor from the rest of the world.
  11174. * @param items The items to add.
  11175. */
  11176. private constructor();
  11177. /**
  11178. * Creates a new Stage.
  11179. * @returns A new instance of a Stage
  11180. */
  11181. static Create<T extends Function>(): Stage<T>;
  11182. /**
  11183. * Registers a step in an ordered way in the targeted stage.
  11184. * @param index Defines the position to register the step in
  11185. * @param component Defines the component attached to the step
  11186. * @param action Defines the action to launch during the step
  11187. */
  11188. registerStep(index: number, component: ISceneComponent, action: T): void;
  11189. /**
  11190. * Clears all the steps from the stage.
  11191. */
  11192. clear(): void;
  11193. }
  11194. }
  11195. declare module BABYLON {
  11196. interface Scene {
  11197. /** @hidden */
  11198. _pointerOverSprite: Nullable<Sprite>;
  11199. /** @hidden */
  11200. _pickedDownSprite: Nullable<Sprite>;
  11201. /** @hidden */
  11202. _tempSpritePickingRay: Nullable<Ray>;
  11203. /**
  11204. * All of the sprite managers added to this scene
  11205. * @see https://doc.babylonjs.com/babylon101/sprites
  11206. */
  11207. spriteManagers: Array<ISpriteManager>;
  11208. /**
  11209. * An event triggered when sprites rendering is about to start
  11210. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11211. */
  11212. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11213. /**
  11214. * An event triggered when sprites rendering is done
  11215. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11216. */
  11217. onAfterSpritesRenderingObservable: Observable<Scene>;
  11218. /** @hidden */
  11219. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11220. /** Launch a ray to try to pick a sprite in the scene
  11221. * @param x position on screen
  11222. * @param y position on screen
  11223. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11224. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11225. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11226. * @returns a PickingInfo
  11227. */
  11228. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11229. /** Use the given ray to pick a sprite in the scene
  11230. * @param ray The ray (in world space) to use to pick meshes
  11231. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11232. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11233. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11234. * @returns a PickingInfo
  11235. */
  11236. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11237. /** @hidden */
  11238. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11239. /** Launch a ray to try to pick sprites in the scene
  11240. * @param x position on screen
  11241. * @param y position on screen
  11242. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11243. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11244. * @returns a PickingInfo array
  11245. */
  11246. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11247. /** Use the given ray to pick sprites in the scene
  11248. * @param ray The ray (in world space) to use to pick meshes
  11249. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11250. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11251. * @returns a PickingInfo array
  11252. */
  11253. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11254. /**
  11255. * Force the sprite under the pointer
  11256. * @param sprite defines the sprite to use
  11257. */
  11258. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11259. /**
  11260. * Gets the sprite under the pointer
  11261. * @returns a Sprite or null if no sprite is under the pointer
  11262. */
  11263. getPointerOverSprite(): Nullable<Sprite>;
  11264. }
  11265. /**
  11266. * Defines the sprite scene component responsible to manage sprites
  11267. * in a given scene.
  11268. */
  11269. export class SpriteSceneComponent implements ISceneComponent {
  11270. /**
  11271. * The component name helpfull to identify the component in the list of scene components.
  11272. */
  11273. readonly name: string;
  11274. /**
  11275. * The scene the component belongs to.
  11276. */
  11277. scene: Scene;
  11278. /** @hidden */
  11279. private _spritePredicate;
  11280. /**
  11281. * Creates a new instance of the component for the given scene
  11282. * @param scene Defines the scene to register the component in
  11283. */
  11284. constructor(scene: Scene);
  11285. /**
  11286. * Registers the component in a given scene
  11287. */
  11288. register(): void;
  11289. /**
  11290. * Rebuilds the elements related to this component in case of
  11291. * context lost for instance.
  11292. */
  11293. rebuild(): void;
  11294. /**
  11295. * Disposes the component and the associated ressources.
  11296. */
  11297. dispose(): void;
  11298. private _pickSpriteButKeepRay;
  11299. private _pointerMove;
  11300. private _pointerDown;
  11301. private _pointerUp;
  11302. }
  11303. }
  11304. declare module BABYLON {
  11305. /**
  11306. * Class used to provide helper for timing
  11307. */
  11308. export class TimingTools {
  11309. /**
  11310. * Polyfill for setImmediate
  11311. * @param action defines the action to execute after the current execution block
  11312. */
  11313. static SetImmediate(action: () => void): void;
  11314. }
  11315. }
  11316. declare module BABYLON {
  11317. /**
  11318. * Class used to enable instatition of objects by class name
  11319. */
  11320. export class InstantiationTools {
  11321. /**
  11322. * Use this object to register external classes like custom textures or material
  11323. * to allow the laoders to instantiate them
  11324. */
  11325. static RegisteredExternalClasses: {
  11326. [key: string]: Object;
  11327. };
  11328. /**
  11329. * Tries to instantiate a new object from a given class name
  11330. * @param className defines the class name to instantiate
  11331. * @returns the new object or null if the system was not able to do the instantiation
  11332. */
  11333. static Instantiate(className: string): any;
  11334. }
  11335. }
  11336. declare module BABYLON {
  11337. /**
  11338. * Class used to host copy specific utilities
  11339. */
  11340. export class CopyTools {
  11341. /**
  11342. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  11343. * @param texture defines the texture to read pixels from
  11344. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  11345. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  11346. * @returns The base64 encoded string or null
  11347. */
  11348. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Promise<Nullable<string>>;
  11349. }
  11350. }
  11351. declare module BABYLON {
  11352. /**
  11353. * Define options used to create a depth texture
  11354. */
  11355. export class DepthTextureCreationOptions {
  11356. /** Specifies whether or not a stencil should be allocated in the texture */
  11357. generateStencil?: boolean;
  11358. /** Specifies whether or not bilinear filtering is enable on the texture */
  11359. bilinearFiltering?: boolean;
  11360. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  11361. comparisonFunction?: number;
  11362. /** Specifies if the created texture is a cube texture */
  11363. isCube?: boolean;
  11364. /** Specifies the sample count of the depth/stencil texture texture */
  11365. samples?: number;
  11366. }
  11367. }
  11368. declare module BABYLON {
  11369. interface ThinEngine {
  11370. /**
  11371. * Creates a depth stencil cube texture.
  11372. * This is only available in WebGL 2.
  11373. * @param size The size of face edge in the cube texture.
  11374. * @param options The options defining the cube texture.
  11375. * @returns The cube texture
  11376. */
  11377. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  11378. /**
  11379. * Creates a cube texture
  11380. * @param rootUrl defines the url where the files to load is located
  11381. * @param scene defines the current scene
  11382. * @param files defines the list of files to load (1 per face)
  11383. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11384. * @param onLoad defines an optional callback raised when the texture is loaded
  11385. * @param onError defines an optional callback raised if there is an issue to load the texture
  11386. * @param format defines the format of the data
  11387. * @param forcedExtension defines the extension to use to pick the right loader
  11388. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11389. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11390. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11391. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11392. * @param loaderOptions options to be passed to the loader
  11393. * @returns the cube texture as an InternalTexture
  11394. */
  11395. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, loaderOptions: any): InternalTexture;
  11396. /**
  11397. * Creates a cube texture
  11398. * @param rootUrl defines the url where the files to load is located
  11399. * @param scene defines the current scene
  11400. * @param files defines the list of files to load (1 per face)
  11401. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11402. * @param onLoad defines an optional callback raised when the texture is loaded
  11403. * @param onError defines an optional callback raised if there is an issue to load the texture
  11404. * @param format defines the format of the data
  11405. * @param forcedExtension defines the extension to use to pick the right loader
  11406. * @returns the cube texture as an InternalTexture
  11407. */
  11408. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  11409. /**
  11410. * Creates a cube texture
  11411. * @param rootUrl defines the url where the files to load is located
  11412. * @param scene defines the current scene
  11413. * @param files defines the list of files to load (1 per face)
  11414. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11415. * @param onLoad defines an optional callback raised when the texture is loaded
  11416. * @param onError defines an optional callback raised if there is an issue to load the texture
  11417. * @param format defines the format of the data
  11418. * @param forcedExtension defines the extension to use to pick the right loader
  11419. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11420. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11421. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11422. * @returns the cube texture as an InternalTexture
  11423. */
  11424. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  11425. /** @hidden */
  11426. createCubeTextureBase(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, beforeLoadCubeDataCallback: Nullable<(texture: InternalTexture, data: ArrayBufferView | ArrayBufferView[]) => void>, imageHandler: Nullable<(texture: InternalTexture, imgs: HTMLImageElement[] | ImageBitmap[]) => void>): InternalTexture;
  11427. /** @hidden */
  11428. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  11429. /** @hidden */
  11430. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  11431. /** @hidden */
  11432. _cascadeLoadImgs(scene: Nullable<Scene>, texture: InternalTexture, onfinish: Nullable<(texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void>, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  11433. /** @hidden */
  11434. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[] | ImageBitmap[], scene: Nullable<Scene>, texture: InternalTexture, onfinish: Nullable<(texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void>, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  11435. /**
  11436. * @hidden
  11437. */
  11438. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  11439. }
  11440. }
  11441. declare module BABYLON {
  11442. /**
  11443. * Class for creating a cube texture
  11444. */
  11445. export class CubeTexture extends BaseTexture {
  11446. private _delayedOnLoad;
  11447. /**
  11448. * Observable triggered once the texture has been loaded.
  11449. */
  11450. onLoadObservable: Observable<CubeTexture>;
  11451. /**
  11452. * The url of the texture
  11453. */
  11454. url: string;
  11455. /**
  11456. * Gets or sets the center of the bounding box associated with the cube texture.
  11457. * It must define where the camera used to render the texture was set
  11458. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11459. */
  11460. boundingBoxPosition: Vector3;
  11461. private _boundingBoxSize;
  11462. /**
  11463. * Gets or sets the size of the bounding box associated with the cube texture
  11464. * When defined, the cubemap will switch to local mode
  11465. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  11466. * @example https://www.babylonjs-playground.com/#RNASML
  11467. */
  11468. set boundingBoxSize(value: Vector3);
  11469. /**
  11470. * Returns the bounding box size
  11471. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11472. */
  11473. get boundingBoxSize(): Vector3;
  11474. protected _rotationY: number;
  11475. /**
  11476. * Sets texture matrix rotation angle around Y axis in radians.
  11477. */
  11478. set rotationY(value: number);
  11479. /**
  11480. * Gets texture matrix rotation angle around Y axis radians.
  11481. */
  11482. get rotationY(): number;
  11483. /**
  11484. * Are mip maps generated for this texture or not.
  11485. */
  11486. get noMipmap(): boolean;
  11487. private _noMipmap;
  11488. private _files;
  11489. protected _forcedExtension: Nullable<string>;
  11490. private _extensions;
  11491. private _textureMatrix;
  11492. private _format;
  11493. private _createPolynomials;
  11494. private _loaderOptions;
  11495. /**
  11496. * Creates a cube texture from an array of image urls
  11497. * @param files defines an array of image urls
  11498. * @param scene defines the hosting scene
  11499. * @param noMipmap specifies if mip maps are not used
  11500. * @returns a cube texture
  11501. */
  11502. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  11503. /**
  11504. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  11505. * @param url defines the url of the prefiltered texture
  11506. * @param scene defines the scene the texture is attached to
  11507. * @param forcedExtension defines the extension of the file if different from the url
  11508. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11509. * @return the prefiltered texture
  11510. */
  11511. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  11512. /**
  11513. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  11514. * as prefiltered data.
  11515. * @param rootUrl defines the url of the texture or the root name of the six images
  11516. * @param null defines the scene or engine the texture is attached to
  11517. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  11518. * @param noMipmap defines if mipmaps should be created or not
  11519. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  11520. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  11521. * @param onError defines a callback triggered in case of error during load
  11522. * @param format defines the internal format to use for the texture once loaded
  11523. * @param prefiltered defines whether or not the texture is created from prefiltered data
  11524. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  11525. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11526. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11527. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11528. * @param loaderOptions options to be passed to the loader
  11529. * @return the cube texture
  11530. */
  11531. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, loaderOptions?: any);
  11532. /**
  11533. * Get the current class name of the texture useful for serialization or dynamic coding.
  11534. * @returns "CubeTexture"
  11535. */
  11536. getClassName(): string;
  11537. /**
  11538. * Update the url (and optional buffer) of this texture if url was null during construction.
  11539. * @param url the url of the texture
  11540. * @param forcedExtension defines the extension to use
  11541. * @param onLoad callback called when the texture is loaded (defaults to null)
  11542. * @param prefiltered Defines whether the updated texture is prefiltered or not
  11543. */
  11544. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  11545. /**
  11546. * Delays loading of the cube texture
  11547. * @param forcedExtension defines the extension to use
  11548. */
  11549. delayLoad(forcedExtension?: string): void;
  11550. /**
  11551. * Returns the reflection texture matrix
  11552. * @returns the reflection texture matrix
  11553. */
  11554. getReflectionTextureMatrix(): Matrix;
  11555. /**
  11556. * Sets the reflection texture matrix
  11557. * @param value Reflection texture matrix
  11558. */
  11559. setReflectionTextureMatrix(value: Matrix): void;
  11560. /**
  11561. * Parses text to create a cube texture
  11562. * @param parsedTexture define the serialized text to read from
  11563. * @param scene defines the hosting scene
  11564. * @param rootUrl defines the root url of the cube texture
  11565. * @returns a cube texture
  11566. */
  11567. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  11568. /**
  11569. * Makes a clone, or deep copy, of the cube texture
  11570. * @returns a new cube texture
  11571. */
  11572. clone(): CubeTexture;
  11573. }
  11574. }
  11575. declare module BABYLON {
  11576. /**
  11577. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11578. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11579. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  11580. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11581. */
  11582. export class ColorCurves {
  11583. private _dirty;
  11584. private _tempColor;
  11585. private _globalCurve;
  11586. private _highlightsCurve;
  11587. private _midtonesCurve;
  11588. private _shadowsCurve;
  11589. private _positiveCurve;
  11590. private _negativeCurve;
  11591. private _globalHue;
  11592. private _globalDensity;
  11593. private _globalSaturation;
  11594. private _globalExposure;
  11595. /**
  11596. * Gets the global Hue value.
  11597. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11598. */
  11599. get globalHue(): number;
  11600. /**
  11601. * Sets the global Hue value.
  11602. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11603. */
  11604. set globalHue(value: number);
  11605. /**
  11606. * Gets the global Density value.
  11607. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11608. * Values less than zero provide a filter of opposite hue.
  11609. */
  11610. get globalDensity(): number;
  11611. /**
  11612. * Sets the global Density value.
  11613. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11614. * Values less than zero provide a filter of opposite hue.
  11615. */
  11616. set globalDensity(value: number);
  11617. /**
  11618. * Gets the global Saturation value.
  11619. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11620. */
  11621. get globalSaturation(): number;
  11622. /**
  11623. * Sets the global Saturation value.
  11624. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11625. */
  11626. set globalSaturation(value: number);
  11627. /**
  11628. * Gets the global Exposure value.
  11629. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11630. */
  11631. get globalExposure(): number;
  11632. /**
  11633. * Sets the global Exposure value.
  11634. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11635. */
  11636. set globalExposure(value: number);
  11637. private _highlightsHue;
  11638. private _highlightsDensity;
  11639. private _highlightsSaturation;
  11640. private _highlightsExposure;
  11641. /**
  11642. * Gets the highlights Hue value.
  11643. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11644. */
  11645. get highlightsHue(): number;
  11646. /**
  11647. * Sets the highlights Hue value.
  11648. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11649. */
  11650. set highlightsHue(value: number);
  11651. /**
  11652. * Gets the highlights Density value.
  11653. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11654. * Values less than zero provide a filter of opposite hue.
  11655. */
  11656. get highlightsDensity(): number;
  11657. /**
  11658. * Sets the highlights Density value.
  11659. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11660. * Values less than zero provide a filter of opposite hue.
  11661. */
  11662. set highlightsDensity(value: number);
  11663. /**
  11664. * Gets the highlights Saturation value.
  11665. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11666. */
  11667. get highlightsSaturation(): number;
  11668. /**
  11669. * Sets the highlights Saturation value.
  11670. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11671. */
  11672. set highlightsSaturation(value: number);
  11673. /**
  11674. * Gets the highlights Exposure value.
  11675. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11676. */
  11677. get highlightsExposure(): number;
  11678. /**
  11679. * Sets the highlights Exposure value.
  11680. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11681. */
  11682. set highlightsExposure(value: number);
  11683. private _midtonesHue;
  11684. private _midtonesDensity;
  11685. private _midtonesSaturation;
  11686. private _midtonesExposure;
  11687. /**
  11688. * Gets the midtones Hue value.
  11689. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11690. */
  11691. get midtonesHue(): number;
  11692. /**
  11693. * Sets the midtones Hue value.
  11694. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11695. */
  11696. set midtonesHue(value: number);
  11697. /**
  11698. * Gets the midtones Density value.
  11699. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11700. * Values less than zero provide a filter of opposite hue.
  11701. */
  11702. get midtonesDensity(): number;
  11703. /**
  11704. * Sets the midtones Density value.
  11705. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11706. * Values less than zero provide a filter of opposite hue.
  11707. */
  11708. set midtonesDensity(value: number);
  11709. /**
  11710. * Gets the midtones Saturation value.
  11711. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11712. */
  11713. get midtonesSaturation(): number;
  11714. /**
  11715. * Sets the midtones Saturation value.
  11716. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11717. */
  11718. set midtonesSaturation(value: number);
  11719. /**
  11720. * Gets the midtones Exposure value.
  11721. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11722. */
  11723. get midtonesExposure(): number;
  11724. /**
  11725. * Sets the midtones Exposure value.
  11726. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11727. */
  11728. set midtonesExposure(value: number);
  11729. private _shadowsHue;
  11730. private _shadowsDensity;
  11731. private _shadowsSaturation;
  11732. private _shadowsExposure;
  11733. /**
  11734. * Gets the shadows Hue value.
  11735. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11736. */
  11737. get shadowsHue(): number;
  11738. /**
  11739. * Sets the shadows Hue value.
  11740. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11741. */
  11742. set shadowsHue(value: number);
  11743. /**
  11744. * Gets the shadows Density value.
  11745. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11746. * Values less than zero provide a filter of opposite hue.
  11747. */
  11748. get shadowsDensity(): number;
  11749. /**
  11750. * Sets the shadows Density value.
  11751. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11752. * Values less than zero provide a filter of opposite hue.
  11753. */
  11754. set shadowsDensity(value: number);
  11755. /**
  11756. * Gets the shadows Saturation value.
  11757. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11758. */
  11759. get shadowsSaturation(): number;
  11760. /**
  11761. * Sets the shadows Saturation value.
  11762. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11763. */
  11764. set shadowsSaturation(value: number);
  11765. /**
  11766. * Gets the shadows Exposure value.
  11767. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11768. */
  11769. get shadowsExposure(): number;
  11770. /**
  11771. * Sets the shadows Exposure value.
  11772. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11773. */
  11774. set shadowsExposure(value: number);
  11775. /**
  11776. * Returns the class name
  11777. * @returns The class name
  11778. */
  11779. getClassName(): string;
  11780. /**
  11781. * Binds the color curves to the shader.
  11782. * @param colorCurves The color curve to bind
  11783. * @param effect The effect to bind to
  11784. * @param positiveUniform The positive uniform shader parameter
  11785. * @param neutralUniform The neutral uniform shader parameter
  11786. * @param negativeUniform The negative uniform shader parameter
  11787. */
  11788. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11789. /**
  11790. * Prepare the list of uniforms associated with the ColorCurves effects.
  11791. * @param uniformsList The list of uniforms used in the effect
  11792. */
  11793. static PrepareUniforms(uniformsList: string[]): void;
  11794. /**
  11795. * Returns color grading data based on a hue, density, saturation and exposure value.
  11796. * @param filterHue The hue of the color filter.
  11797. * @param filterDensity The density of the color filter.
  11798. * @param saturation The saturation.
  11799. * @param exposure The exposure.
  11800. * @param result The result data container.
  11801. */
  11802. private getColorGradingDataToRef;
  11803. /**
  11804. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11805. * @param value The input slider value in range [-100,100].
  11806. * @returns Adjusted value.
  11807. */
  11808. private static applyColorGradingSliderNonlinear;
  11809. /**
  11810. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11811. * @param hue The hue (H) input.
  11812. * @param saturation The saturation (S) input.
  11813. * @param brightness The brightness (B) input.
  11814. * @result An RGBA color represented as Vector4.
  11815. */
  11816. private static fromHSBToRef;
  11817. /**
  11818. * Returns a value clamped between min and max
  11819. * @param value The value to clamp
  11820. * @param min The minimum of value
  11821. * @param max The maximum of value
  11822. * @returns The clamped value.
  11823. */
  11824. private static clamp;
  11825. /**
  11826. * Clones the current color curve instance.
  11827. * @return The cloned curves
  11828. */
  11829. clone(): ColorCurves;
  11830. /**
  11831. * Serializes the current color curve instance to a json representation.
  11832. * @return a JSON representation
  11833. */
  11834. serialize(): any;
  11835. /**
  11836. * Parses the color curve from a json representation.
  11837. * @param source the JSON source to parse
  11838. * @return The parsed curves
  11839. */
  11840. static Parse(source: any): ColorCurves;
  11841. }
  11842. }
  11843. declare module BABYLON {
  11844. /**
  11845. * Interface to follow in your material defines to integrate easily the
  11846. * Image proccessing functions.
  11847. * @hidden
  11848. */
  11849. export interface IImageProcessingConfigurationDefines {
  11850. IMAGEPROCESSING: boolean;
  11851. VIGNETTE: boolean;
  11852. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11853. VIGNETTEBLENDMODEOPAQUE: boolean;
  11854. TONEMAPPING: boolean;
  11855. TONEMAPPING_ACES: boolean;
  11856. CONTRAST: boolean;
  11857. EXPOSURE: boolean;
  11858. COLORCURVES: boolean;
  11859. COLORGRADING: boolean;
  11860. COLORGRADING3D: boolean;
  11861. SAMPLER3DGREENDEPTH: boolean;
  11862. SAMPLER3DBGRMAP: boolean;
  11863. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11864. }
  11865. /**
  11866. * @hidden
  11867. */
  11868. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  11869. IMAGEPROCESSING: boolean;
  11870. VIGNETTE: boolean;
  11871. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11872. VIGNETTEBLENDMODEOPAQUE: boolean;
  11873. TONEMAPPING: boolean;
  11874. TONEMAPPING_ACES: boolean;
  11875. CONTRAST: boolean;
  11876. COLORCURVES: boolean;
  11877. COLORGRADING: boolean;
  11878. COLORGRADING3D: boolean;
  11879. SAMPLER3DGREENDEPTH: boolean;
  11880. SAMPLER3DBGRMAP: boolean;
  11881. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11882. EXPOSURE: boolean;
  11883. constructor();
  11884. }
  11885. /**
  11886. * This groups together the common properties used for image processing either in direct forward pass
  11887. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11888. * or not.
  11889. */
  11890. export class ImageProcessingConfiguration {
  11891. /**
  11892. * Default tone mapping applied in BabylonJS.
  11893. */
  11894. static readonly TONEMAPPING_STANDARD: number;
  11895. /**
  11896. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  11897. * to other engines rendering to increase portability.
  11898. */
  11899. static readonly TONEMAPPING_ACES: number;
  11900. /**
  11901. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11902. */
  11903. colorCurves: Nullable<ColorCurves>;
  11904. private _colorCurvesEnabled;
  11905. /**
  11906. * Gets wether the color curves effect is enabled.
  11907. */
  11908. get colorCurvesEnabled(): boolean;
  11909. /**
  11910. * Sets wether the color curves effect is enabled.
  11911. */
  11912. set colorCurvesEnabled(value: boolean);
  11913. private _colorGradingTexture;
  11914. /**
  11915. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11916. */
  11917. get colorGradingTexture(): Nullable<BaseTexture>;
  11918. /**
  11919. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11920. */
  11921. set colorGradingTexture(value: Nullable<BaseTexture>);
  11922. private _colorGradingEnabled;
  11923. /**
  11924. * Gets wether the color grading effect is enabled.
  11925. */
  11926. get colorGradingEnabled(): boolean;
  11927. /**
  11928. * Sets wether the color grading effect is enabled.
  11929. */
  11930. set colorGradingEnabled(value: boolean);
  11931. private _colorGradingWithGreenDepth;
  11932. /**
  11933. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  11934. */
  11935. get colorGradingWithGreenDepth(): boolean;
  11936. /**
  11937. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  11938. */
  11939. set colorGradingWithGreenDepth(value: boolean);
  11940. private _colorGradingBGR;
  11941. /**
  11942. * Gets wether the color grading texture contains BGR values.
  11943. */
  11944. get colorGradingBGR(): boolean;
  11945. /**
  11946. * Sets wether the color grading texture contains BGR values.
  11947. */
  11948. set colorGradingBGR(value: boolean);
  11949. /** @hidden */
  11950. _exposure: number;
  11951. /**
  11952. * Gets the Exposure used in the effect.
  11953. */
  11954. get exposure(): number;
  11955. /**
  11956. * Sets the Exposure used in the effect.
  11957. */
  11958. set exposure(value: number);
  11959. private _toneMappingEnabled;
  11960. /**
  11961. * Gets wether the tone mapping effect is enabled.
  11962. */
  11963. get toneMappingEnabled(): boolean;
  11964. /**
  11965. * Sets wether the tone mapping effect is enabled.
  11966. */
  11967. set toneMappingEnabled(value: boolean);
  11968. private _toneMappingType;
  11969. /**
  11970. * Gets the type of tone mapping effect.
  11971. */
  11972. get toneMappingType(): number;
  11973. /**
  11974. * Sets the type of tone mapping effect used in BabylonJS.
  11975. */
  11976. set toneMappingType(value: number);
  11977. protected _contrast: number;
  11978. /**
  11979. * Gets the contrast used in the effect.
  11980. */
  11981. get contrast(): number;
  11982. /**
  11983. * Sets the contrast used in the effect.
  11984. */
  11985. set contrast(value: number);
  11986. /**
  11987. * Vignette stretch size.
  11988. */
  11989. vignetteStretch: number;
  11990. /**
  11991. * Vignette centre X Offset.
  11992. */
  11993. vignetteCentreX: number;
  11994. /**
  11995. * Vignette centre Y Offset.
  11996. */
  11997. vignetteCentreY: number;
  11998. /**
  11999. * Vignette weight or intensity of the vignette effect.
  12000. */
  12001. vignetteWeight: number;
  12002. /**
  12003. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  12004. * if vignetteEnabled is set to true.
  12005. */
  12006. vignetteColor: Color4;
  12007. /**
  12008. * Camera field of view used by the Vignette effect.
  12009. */
  12010. vignetteCameraFov: number;
  12011. private _vignetteBlendMode;
  12012. /**
  12013. * Gets the vignette blend mode allowing different kind of effect.
  12014. */
  12015. get vignetteBlendMode(): number;
  12016. /**
  12017. * Sets the vignette blend mode allowing different kind of effect.
  12018. */
  12019. set vignetteBlendMode(value: number);
  12020. private _vignetteEnabled;
  12021. /**
  12022. * Gets wether the vignette effect is enabled.
  12023. */
  12024. get vignetteEnabled(): boolean;
  12025. /**
  12026. * Sets wether the vignette effect is enabled.
  12027. */
  12028. set vignetteEnabled(value: boolean);
  12029. private _applyByPostProcess;
  12030. /**
  12031. * Gets wether the image processing is applied through a post process or not.
  12032. */
  12033. get applyByPostProcess(): boolean;
  12034. /**
  12035. * Sets wether the image processing is applied through a post process or not.
  12036. */
  12037. set applyByPostProcess(value: boolean);
  12038. private _isEnabled;
  12039. /**
  12040. * Gets wether the image processing is enabled or not.
  12041. */
  12042. get isEnabled(): boolean;
  12043. /**
  12044. * Sets wether the image processing is enabled or not.
  12045. */
  12046. set isEnabled(value: boolean);
  12047. /**
  12048. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  12049. */
  12050. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  12051. /**
  12052. * Method called each time the image processing information changes requires to recompile the effect.
  12053. */
  12054. protected _updateParameters(): void;
  12055. /**
  12056. * Gets the current class name.
  12057. * @return "ImageProcessingConfiguration"
  12058. */
  12059. getClassName(): string;
  12060. /**
  12061. * Prepare the list of uniforms associated with the Image Processing effects.
  12062. * @param uniforms The list of uniforms used in the effect
  12063. * @param defines the list of defines currently in use
  12064. */
  12065. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  12066. /**
  12067. * Prepare the list of samplers associated with the Image Processing effects.
  12068. * @param samplersList The list of uniforms used in the effect
  12069. * @param defines the list of defines currently in use
  12070. */
  12071. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  12072. /**
  12073. * Prepare the list of defines associated to the shader.
  12074. * @param defines the list of defines to complete
  12075. * @param forPostProcess Define if we are currently in post process mode or not
  12076. */
  12077. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  12078. /**
  12079. * Returns true if all the image processing information are ready.
  12080. * @returns True if ready, otherwise, false
  12081. */
  12082. isReady(): boolean;
  12083. /**
  12084. * Binds the image processing to the shader.
  12085. * @param effect The effect to bind to
  12086. * @param overrideAspectRatio Override the aspect ratio of the effect
  12087. */
  12088. bind(effect: Effect, overrideAspectRatio?: number): void;
  12089. /**
  12090. * Clones the current image processing instance.
  12091. * @return The cloned image processing
  12092. */
  12093. clone(): ImageProcessingConfiguration;
  12094. /**
  12095. * Serializes the current image processing instance to a json representation.
  12096. * @return a JSON representation
  12097. */
  12098. serialize(): any;
  12099. /**
  12100. * Parses the image processing from a json representation.
  12101. * @param source the JSON source to parse
  12102. * @return The parsed image processing
  12103. */
  12104. static Parse(source: any): ImageProcessingConfiguration;
  12105. private static _VIGNETTEMODE_MULTIPLY;
  12106. private static _VIGNETTEMODE_OPAQUE;
  12107. /**
  12108. * Used to apply the vignette as a mix with the pixel color.
  12109. */
  12110. static get VIGNETTEMODE_MULTIPLY(): number;
  12111. /**
  12112. * Used to apply the vignette as a replacement of the pixel color.
  12113. */
  12114. static get VIGNETTEMODE_OPAQUE(): number;
  12115. }
  12116. }
  12117. declare module BABYLON {
  12118. /** @hidden */
  12119. export var postprocessVertexShader: {
  12120. name: string;
  12121. shader: string;
  12122. };
  12123. }
  12124. declare module BABYLON {
  12125. /**
  12126. * Type used to define a render target texture size (either with a number or with a rect width and height)
  12127. */
  12128. export type RenderTargetTextureSize = number | {
  12129. width: number;
  12130. height: number;
  12131. layers?: number;
  12132. };
  12133. interface ThinEngine {
  12134. /**
  12135. * Creates a new render target texture
  12136. * @param size defines the size of the texture
  12137. * @param options defines the options used to create the texture
  12138. * @returns a new render target texture stored in an InternalTexture
  12139. */
  12140. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12141. /**
  12142. * Creates a depth stencil texture.
  12143. * This is only available in WebGL 2 or with the depth texture extension available.
  12144. * @param size The size of face edge in the texture.
  12145. * @param options The options defining the texture.
  12146. * @returns The texture
  12147. */
  12148. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12149. /** @hidden */
  12150. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12151. }
  12152. }
  12153. declare module BABYLON {
  12154. /**
  12155. * Defines the kind of connection point for node based material
  12156. */
  12157. export enum NodeMaterialBlockConnectionPointTypes {
  12158. /** Float */
  12159. Float = 1,
  12160. /** Int */
  12161. Int = 2,
  12162. /** Vector2 */
  12163. Vector2 = 4,
  12164. /** Vector3 */
  12165. Vector3 = 8,
  12166. /** Vector4 */
  12167. Vector4 = 16,
  12168. /** Color3 */
  12169. Color3 = 32,
  12170. /** Color4 */
  12171. Color4 = 64,
  12172. /** Matrix */
  12173. Matrix = 128,
  12174. /** Custom object */
  12175. Object = 256,
  12176. /** Detect type based on connection */
  12177. AutoDetect = 1024,
  12178. /** Output type that will be defined by input type */
  12179. BasedOnInput = 2048
  12180. }
  12181. }
  12182. declare module BABYLON {
  12183. /**
  12184. * Enum used to define the target of a block
  12185. */
  12186. export enum NodeMaterialBlockTargets {
  12187. /** Vertex shader */
  12188. Vertex = 1,
  12189. /** Fragment shader */
  12190. Fragment = 2,
  12191. /** Neutral */
  12192. Neutral = 4,
  12193. /** Vertex and Fragment */
  12194. VertexAndFragment = 3
  12195. }
  12196. }
  12197. declare module BABYLON {
  12198. /**
  12199. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  12200. */
  12201. export enum NodeMaterialBlockConnectionPointMode {
  12202. /** Value is an uniform */
  12203. Uniform = 0,
  12204. /** Value is a mesh attribute */
  12205. Attribute = 1,
  12206. /** Value is a varying between vertex and fragment shaders */
  12207. Varying = 2,
  12208. /** Mode is undefined */
  12209. Undefined = 3
  12210. }
  12211. }
  12212. declare module BABYLON {
  12213. /**
  12214. * Enum used to define system values e.g. values automatically provided by the system
  12215. */
  12216. export enum NodeMaterialSystemValues {
  12217. /** World */
  12218. World = 1,
  12219. /** View */
  12220. View = 2,
  12221. /** Projection */
  12222. Projection = 3,
  12223. /** ViewProjection */
  12224. ViewProjection = 4,
  12225. /** WorldView */
  12226. WorldView = 5,
  12227. /** WorldViewProjection */
  12228. WorldViewProjection = 6,
  12229. /** CameraPosition */
  12230. CameraPosition = 7,
  12231. /** Fog Color */
  12232. FogColor = 8,
  12233. /** Delta time */
  12234. DeltaTime = 9
  12235. }
  12236. }
  12237. declare module BABYLON {
  12238. /**
  12239. * Represents a camera frustum
  12240. */
  12241. export class Frustum {
  12242. /**
  12243. * Gets the planes representing the frustum
  12244. * @param transform matrix to be applied to the returned planes
  12245. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  12246. */
  12247. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  12248. /**
  12249. * Gets the near frustum plane transformed by the transform matrix
  12250. * @param transform transformation matrix to be applied to the resulting frustum plane
  12251. * @param frustumPlane the resuling frustum plane
  12252. */
  12253. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12254. /**
  12255. * Gets the far frustum plane transformed by the transform matrix
  12256. * @param transform transformation matrix to be applied to the resulting frustum plane
  12257. * @param frustumPlane the resuling frustum plane
  12258. */
  12259. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12260. /**
  12261. * Gets the left frustum plane transformed by the transform matrix
  12262. * @param transform transformation matrix to be applied to the resulting frustum plane
  12263. * @param frustumPlane the resuling frustum plane
  12264. */
  12265. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12266. /**
  12267. * Gets the right frustum plane transformed by the transform matrix
  12268. * @param transform transformation matrix to be applied to the resulting frustum plane
  12269. * @param frustumPlane the resuling frustum plane
  12270. */
  12271. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12272. /**
  12273. * Gets the top frustum plane transformed by the transform matrix
  12274. * @param transform transformation matrix to be applied to the resulting frustum plane
  12275. * @param frustumPlane the resuling frustum plane
  12276. */
  12277. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12278. /**
  12279. * Gets the bottom frustum plane transformed by the transform matrix
  12280. * @param transform transformation matrix to be applied to the resulting frustum plane
  12281. * @param frustumPlane the resuling frustum plane
  12282. */
  12283. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12284. /**
  12285. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  12286. * @param transform transformation matrix to be applied to the resulting frustum planes
  12287. * @param frustumPlanes the resuling frustum planes
  12288. */
  12289. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  12290. }
  12291. }
  12292. declare module BABYLON {
  12293. /**
  12294. * Contains position and normal vectors for a vertex
  12295. */
  12296. export class PositionNormalVertex {
  12297. /** the position of the vertex (defaut: 0,0,0) */
  12298. position: Vector3;
  12299. /** the normal of the vertex (defaut: 0,1,0) */
  12300. normal: Vector3;
  12301. /**
  12302. * Creates a PositionNormalVertex
  12303. * @param position the position of the vertex (defaut: 0,0,0)
  12304. * @param normal the normal of the vertex (defaut: 0,1,0)
  12305. */
  12306. constructor(
  12307. /** the position of the vertex (defaut: 0,0,0) */
  12308. position?: Vector3,
  12309. /** the normal of the vertex (defaut: 0,1,0) */
  12310. normal?: Vector3);
  12311. /**
  12312. * Clones the PositionNormalVertex
  12313. * @returns the cloned PositionNormalVertex
  12314. */
  12315. clone(): PositionNormalVertex;
  12316. }
  12317. /**
  12318. * Contains position, normal and uv vectors for a vertex
  12319. */
  12320. export class PositionNormalTextureVertex {
  12321. /** the position of the vertex (defaut: 0,0,0) */
  12322. position: Vector3;
  12323. /** the normal of the vertex (defaut: 0,1,0) */
  12324. normal: Vector3;
  12325. /** the uv of the vertex (default: 0,0) */
  12326. uv: Vector2;
  12327. /**
  12328. * Creates a PositionNormalTextureVertex
  12329. * @param position the position of the vertex (defaut: 0,0,0)
  12330. * @param normal the normal of the vertex (defaut: 0,1,0)
  12331. * @param uv the uv of the vertex (default: 0,0)
  12332. */
  12333. constructor(
  12334. /** the position of the vertex (defaut: 0,0,0) */
  12335. position?: Vector3,
  12336. /** the normal of the vertex (defaut: 0,1,0) */
  12337. normal?: Vector3,
  12338. /** the uv of the vertex (default: 0,0) */
  12339. uv?: Vector2);
  12340. /**
  12341. * Clones the PositionNormalTextureVertex
  12342. * @returns the cloned PositionNormalTextureVertex
  12343. */
  12344. clone(): PositionNormalTextureVertex;
  12345. }
  12346. }
  12347. declare module BABYLON {
  12348. /**
  12349. * Enum defining the type of animations supported by InputBlock
  12350. */
  12351. export enum AnimatedInputBlockTypes {
  12352. /** No animation */
  12353. None = 0,
  12354. /** Time based animation. Will only work for floats */
  12355. Time = 1
  12356. }
  12357. }
  12358. declare module BABYLON {
  12359. /**
  12360. * Block used to expose an input value
  12361. */
  12362. export class InputBlock extends NodeMaterialBlock {
  12363. private _mode;
  12364. private _associatedVariableName;
  12365. private _storedValue;
  12366. private _valueCallback;
  12367. private _type;
  12368. private _animationType;
  12369. /** Gets or set a value used to limit the range of float values */
  12370. min: number;
  12371. /** Gets or set a value used to limit the range of float values */
  12372. max: number;
  12373. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  12374. isBoolean: boolean;
  12375. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  12376. matrixMode: number;
  12377. /** @hidden */
  12378. _systemValue: Nullable<NodeMaterialSystemValues>;
  12379. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  12380. isConstant: boolean;
  12381. /** Gets or sets the group to use to display this block in the Inspector */
  12382. groupInInspector: string;
  12383. /** Gets an observable raised when the value is changed */
  12384. onValueChangedObservable: Observable<InputBlock>;
  12385. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  12386. convertToGammaSpace: boolean;
  12387. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  12388. convertToLinearSpace: boolean;
  12389. /**
  12390. * Gets or sets the connection point type (default is float)
  12391. */
  12392. get type(): NodeMaterialBlockConnectionPointTypes;
  12393. /**
  12394. * Creates a new InputBlock
  12395. * @param name defines the block name
  12396. * @param target defines the target of that block (Vertex by default)
  12397. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  12398. */
  12399. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  12400. /**
  12401. * Validates if a name is a reserve word.
  12402. * @param newName the new name to be given to the node.
  12403. * @returns false if the name is a reserve word, else true.
  12404. */
  12405. validateBlockName(newName: string): boolean;
  12406. /**
  12407. * Gets the output component
  12408. */
  12409. get output(): NodeMaterialConnectionPoint;
  12410. /**
  12411. * Set the source of this connection point to a vertex attribute
  12412. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  12413. * @returns the current connection point
  12414. */
  12415. setAsAttribute(attributeName?: string): InputBlock;
  12416. /**
  12417. * Set the source of this connection point to a system value
  12418. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  12419. * @returns the current connection point
  12420. */
  12421. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  12422. /**
  12423. * Gets or sets the value of that point.
  12424. * Please note that this value will be ignored if valueCallback is defined
  12425. */
  12426. get value(): any;
  12427. set value(value: any);
  12428. /**
  12429. * Gets or sets a callback used to get the value of that point.
  12430. * Please note that setting this value will force the connection point to ignore the value property
  12431. */
  12432. get valueCallback(): () => any;
  12433. set valueCallback(value: () => any);
  12434. /**
  12435. * Gets or sets the associated variable name in the shader
  12436. */
  12437. get associatedVariableName(): string;
  12438. set associatedVariableName(value: string);
  12439. /** Gets or sets the type of animation applied to the input */
  12440. get animationType(): AnimatedInputBlockTypes;
  12441. set animationType(value: AnimatedInputBlockTypes);
  12442. /**
  12443. * Gets a boolean indicating that this connection point not defined yet
  12444. */
  12445. get isUndefined(): boolean;
  12446. /**
  12447. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  12448. * In this case the connection point name must be the name of the uniform to use.
  12449. * Can only be set on inputs
  12450. */
  12451. get isUniform(): boolean;
  12452. set isUniform(value: boolean);
  12453. /**
  12454. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  12455. * In this case the connection point name must be the name of the attribute to use
  12456. * Can only be set on inputs
  12457. */
  12458. get isAttribute(): boolean;
  12459. set isAttribute(value: boolean);
  12460. /**
  12461. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  12462. * Can only be set on exit points
  12463. */
  12464. get isVarying(): boolean;
  12465. set isVarying(value: boolean);
  12466. /**
  12467. * Gets a boolean indicating that the current connection point is a system value
  12468. */
  12469. get isSystemValue(): boolean;
  12470. /**
  12471. * Gets or sets the current well known value or null if not defined as a system value
  12472. */
  12473. get systemValue(): Nullable<NodeMaterialSystemValues>;
  12474. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  12475. /**
  12476. * Gets the current class name
  12477. * @returns the class name
  12478. */
  12479. getClassName(): string;
  12480. /**
  12481. * Animate the input if animationType !== None
  12482. * @param scene defines the rendering scene
  12483. */
  12484. animate(scene: Scene): void;
  12485. private _emitDefine;
  12486. initialize(state: NodeMaterialBuildState): void;
  12487. /**
  12488. * Set the input block to its default value (based on its type)
  12489. */
  12490. setDefaultValue(): void;
  12491. private _emitConstant;
  12492. /** @hidden */
  12493. get _noContextSwitch(): boolean;
  12494. private _emit;
  12495. /** @hidden */
  12496. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  12497. /** @hidden */
  12498. _transmit(effect: Effect, scene: Scene): void;
  12499. protected _buildBlock(state: NodeMaterialBuildState): void;
  12500. protected _dumpPropertiesCode(): string;
  12501. dispose(): void;
  12502. serialize(): any;
  12503. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12504. }
  12505. }
  12506. declare module BABYLON {
  12507. /**
  12508. * Enum used to define the compatibility state between two connection points
  12509. */
  12510. export enum NodeMaterialConnectionPointCompatibilityStates {
  12511. /** Points are compatibles */
  12512. Compatible = 0,
  12513. /** Points are incompatible because of their types */
  12514. TypeIncompatible = 1,
  12515. /** Points are incompatible because of their targets (vertex vs fragment) */
  12516. TargetIncompatible = 2
  12517. }
  12518. /**
  12519. * Defines the direction of a connection point
  12520. */
  12521. export enum NodeMaterialConnectionPointDirection {
  12522. /** Input */
  12523. Input = 0,
  12524. /** Output */
  12525. Output = 1
  12526. }
  12527. /**
  12528. * Defines a connection point for a block
  12529. */
  12530. export class NodeMaterialConnectionPoint {
  12531. /**
  12532. * Checks if two types are equivalent
  12533. * @param type1 type 1 to check
  12534. * @param type2 type 2 to check
  12535. * @returns true if both types are equivalent, else false
  12536. */
  12537. static AreEquivalentTypes(type1: number, type2: number): boolean;
  12538. /** @hidden */
  12539. _ownerBlock: NodeMaterialBlock;
  12540. /** @hidden */
  12541. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  12542. private _endpoints;
  12543. private _associatedVariableName;
  12544. private _direction;
  12545. /** @hidden */
  12546. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12547. /** @hidden */
  12548. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12549. /** @hidden */
  12550. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  12551. private _type;
  12552. /** @hidden */
  12553. _enforceAssociatedVariableName: boolean;
  12554. /** Gets the direction of the point */
  12555. get direction(): NodeMaterialConnectionPointDirection;
  12556. /** Indicates that this connection point needs dual validation before being connected to another point */
  12557. needDualDirectionValidation: boolean;
  12558. /**
  12559. * Gets or sets the additional types supported by this connection point
  12560. */
  12561. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12562. /**
  12563. * Gets or sets the additional types excluded by this connection point
  12564. */
  12565. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12566. /**
  12567. * Observable triggered when this point is connected
  12568. */
  12569. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  12570. /**
  12571. * Gets or sets the associated variable name in the shader
  12572. */
  12573. get associatedVariableName(): string;
  12574. set associatedVariableName(value: string);
  12575. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  12576. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12577. /**
  12578. * Gets or sets the connection point type (default is float)
  12579. */
  12580. get type(): NodeMaterialBlockConnectionPointTypes;
  12581. set type(value: NodeMaterialBlockConnectionPointTypes);
  12582. /**
  12583. * Gets or sets the connection point name
  12584. */
  12585. name: string;
  12586. /**
  12587. * Gets or sets the connection point name
  12588. */
  12589. displayName: string;
  12590. /**
  12591. * Gets or sets a boolean indicating that this connection point can be omitted
  12592. */
  12593. isOptional: boolean;
  12594. /**
  12595. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12596. */
  12597. isExposedOnFrame: boolean;
  12598. /**
  12599. * Gets or sets number indicating the position that the port is exposed to on a frame
  12600. */
  12601. exposedPortPosition: number;
  12602. /**
  12603. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12604. */
  12605. define: string;
  12606. /** @hidden */
  12607. _prioritizeVertex: boolean;
  12608. private _target;
  12609. /** Gets or sets the target of that connection point */
  12610. get target(): NodeMaterialBlockTargets;
  12611. set target(value: NodeMaterialBlockTargets);
  12612. /**
  12613. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12614. */
  12615. get isConnected(): boolean;
  12616. /**
  12617. * Gets a boolean indicating that the current point is connected to an input block
  12618. */
  12619. get isConnectedToInputBlock(): boolean;
  12620. /**
  12621. * Gets a the connected input block (if any)
  12622. */
  12623. get connectInputBlock(): Nullable<InputBlock>;
  12624. /** Get the other side of the connection (if any) */
  12625. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12626. /** Get the block that owns this connection point */
  12627. get ownerBlock(): NodeMaterialBlock;
  12628. /** Get the block connected on the other side of this connection (if any) */
  12629. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12630. /** Get the block connected on the endpoints of this connection (if any) */
  12631. get connectedBlocks(): Array<NodeMaterialBlock>;
  12632. /** Gets the list of connected endpoints */
  12633. get endpoints(): NodeMaterialConnectionPoint[];
  12634. /** Gets a boolean indicating if that output point is connected to at least one input */
  12635. get hasEndpoints(): boolean;
  12636. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12637. get isConnectedInVertexShader(): boolean;
  12638. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12639. get isConnectedInFragmentShader(): boolean;
  12640. /**
  12641. * Creates a block suitable to be used as an input for this input point.
  12642. * If null is returned, a block based on the point type will be created.
  12643. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  12644. */
  12645. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12646. /**
  12647. * Creates a new connection point
  12648. * @param name defines the connection point name
  12649. * @param ownerBlock defines the block hosting this connection point
  12650. * @param direction defines the direction of the connection point
  12651. */
  12652. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12653. /**
  12654. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12655. * @returns the class name
  12656. */
  12657. getClassName(): string;
  12658. /**
  12659. * Gets a boolean indicating if the current point can be connected to another point
  12660. * @param connectionPoint defines the other connection point
  12661. * @returns a boolean
  12662. */
  12663. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  12664. /**
  12665. * Gets a number indicating if the current point can be connected to another point
  12666. * @param connectionPoint defines the other connection point
  12667. * @returns a number defining the compatibility state
  12668. */
  12669. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12670. /**
  12671. * Connect this point to another connection point
  12672. * @param connectionPoint defines the other connection point
  12673. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  12674. * @returns the current connection point
  12675. */
  12676. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  12677. /**
  12678. * Disconnect this point from one of his endpoint
  12679. * @param endpoint defines the other connection point
  12680. * @returns the current connection point
  12681. */
  12682. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  12683. /**
  12684. * Serializes this point in a JSON representation
  12685. * @param isInput defines if the connection point is an input (default is true)
  12686. * @returns the serialized point object
  12687. */
  12688. serialize(isInput?: boolean): any;
  12689. /**
  12690. * Release resources
  12691. */
  12692. dispose(): void;
  12693. }
  12694. }
  12695. declare module BABYLON {
  12696. /**
  12697. * Enum used to define the material modes
  12698. */
  12699. export enum NodeMaterialModes {
  12700. /** Regular material */
  12701. Material = 0,
  12702. /** For post process */
  12703. PostProcess = 1,
  12704. /** For particle system */
  12705. Particle = 2,
  12706. /** For procedural texture */
  12707. ProceduralTexture = 3
  12708. }
  12709. }
  12710. declare module BABYLON {
  12711. /** @hidden */
  12712. export var helperFunctions: {
  12713. name: string;
  12714. shader: string;
  12715. };
  12716. }
  12717. declare module BABYLON {
  12718. /**
  12719. * Block used to read a texture from a sampler
  12720. */
  12721. export class TextureBlock extends NodeMaterialBlock {
  12722. private _defineName;
  12723. private _linearDefineName;
  12724. private _gammaDefineName;
  12725. private _tempTextureRead;
  12726. private _samplerName;
  12727. private _transformedUVName;
  12728. private _textureTransformName;
  12729. private _textureInfoName;
  12730. private _mainUVName;
  12731. private _mainUVDefineName;
  12732. private _fragmentOnly;
  12733. /**
  12734. * Gets or sets the texture associated with the node
  12735. */
  12736. texture: Nullable<Texture>;
  12737. /**
  12738. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12739. */
  12740. convertToGammaSpace: boolean;
  12741. /**
  12742. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12743. */
  12744. convertToLinearSpace: boolean;
  12745. /**
  12746. * Create a new TextureBlock
  12747. * @param name defines the block name
  12748. */
  12749. constructor(name: string, fragmentOnly?: boolean);
  12750. /**
  12751. * Gets the current class name
  12752. * @returns the class name
  12753. */
  12754. getClassName(): string;
  12755. /**
  12756. * Gets the uv input component
  12757. */
  12758. get uv(): NodeMaterialConnectionPoint;
  12759. /**
  12760. * Gets the rgba output component
  12761. */
  12762. get rgba(): NodeMaterialConnectionPoint;
  12763. /**
  12764. * Gets the rgb output component
  12765. */
  12766. get rgb(): NodeMaterialConnectionPoint;
  12767. /**
  12768. * Gets the r output component
  12769. */
  12770. get r(): NodeMaterialConnectionPoint;
  12771. /**
  12772. * Gets the g output component
  12773. */
  12774. get g(): NodeMaterialConnectionPoint;
  12775. /**
  12776. * Gets the b output component
  12777. */
  12778. get b(): NodeMaterialConnectionPoint;
  12779. /**
  12780. * Gets the a output component
  12781. */
  12782. get a(): NodeMaterialConnectionPoint;
  12783. get target(): NodeMaterialBlockTargets;
  12784. autoConfigure(material: NodeMaterial): void;
  12785. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  12786. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12787. isReady(): boolean;
  12788. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12789. private get _isMixed();
  12790. private _injectVertexCode;
  12791. private _writeTextureRead;
  12792. private _writeOutput;
  12793. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12794. protected _dumpPropertiesCode(): string;
  12795. serialize(): any;
  12796. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12797. }
  12798. }
  12799. declare module BABYLON {
  12800. /** @hidden */
  12801. export var reflectionFunction: {
  12802. name: string;
  12803. shader: string;
  12804. };
  12805. }
  12806. declare module BABYLON {
  12807. /**
  12808. * Base block used to read a reflection texture from a sampler
  12809. */
  12810. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  12811. /** @hidden */
  12812. _define3DName: string;
  12813. /** @hidden */
  12814. _defineCubicName: string;
  12815. /** @hidden */
  12816. _defineExplicitName: string;
  12817. /** @hidden */
  12818. _defineProjectionName: string;
  12819. /** @hidden */
  12820. _defineLocalCubicName: string;
  12821. /** @hidden */
  12822. _defineSphericalName: string;
  12823. /** @hidden */
  12824. _definePlanarName: string;
  12825. /** @hidden */
  12826. _defineEquirectangularName: string;
  12827. /** @hidden */
  12828. _defineMirroredEquirectangularFixedName: string;
  12829. /** @hidden */
  12830. _defineEquirectangularFixedName: string;
  12831. /** @hidden */
  12832. _defineSkyboxName: string;
  12833. /** @hidden */
  12834. _defineOppositeZ: string;
  12835. /** @hidden */
  12836. _cubeSamplerName: string;
  12837. /** @hidden */
  12838. _2DSamplerName: string;
  12839. protected _positionUVWName: string;
  12840. protected _directionWName: string;
  12841. protected _reflectionVectorName: string;
  12842. /** @hidden */
  12843. _reflectionCoordsName: string;
  12844. /** @hidden */
  12845. _reflectionMatrixName: string;
  12846. protected _reflectionColorName: string;
  12847. /**
  12848. * Gets or sets the texture associated with the node
  12849. */
  12850. texture: Nullable<BaseTexture>;
  12851. /**
  12852. * Create a new ReflectionTextureBaseBlock
  12853. * @param name defines the block name
  12854. */
  12855. constructor(name: string);
  12856. /**
  12857. * Gets the current class name
  12858. * @returns the class name
  12859. */
  12860. getClassName(): string;
  12861. /**
  12862. * Gets the world position input component
  12863. */
  12864. abstract get position(): NodeMaterialConnectionPoint;
  12865. /**
  12866. * Gets the world position input component
  12867. */
  12868. abstract get worldPosition(): NodeMaterialConnectionPoint;
  12869. /**
  12870. * Gets the world normal input component
  12871. */
  12872. abstract get worldNormal(): NodeMaterialConnectionPoint;
  12873. /**
  12874. * Gets the world input component
  12875. */
  12876. abstract get world(): NodeMaterialConnectionPoint;
  12877. /**
  12878. * Gets the camera (or eye) position component
  12879. */
  12880. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  12881. /**
  12882. * Gets the view input component
  12883. */
  12884. abstract get view(): NodeMaterialConnectionPoint;
  12885. protected _getTexture(): Nullable<BaseTexture>;
  12886. autoConfigure(material: NodeMaterial): void;
  12887. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12888. isReady(): boolean;
  12889. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12890. /**
  12891. * Gets the code to inject in the vertex shader
  12892. * @param state current state of the node material building
  12893. * @returns the shader code
  12894. */
  12895. handleVertexSide(state: NodeMaterialBuildState): string;
  12896. /**
  12897. * Handles the inits for the fragment code path
  12898. * @param state node material build state
  12899. */
  12900. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  12901. /**
  12902. * Generates the reflection coords code for the fragment code path
  12903. * @param worldNormalVarName name of the world normal variable
  12904. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  12905. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  12906. * @returns the shader code
  12907. */
  12908. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  12909. /**
  12910. * Generates the reflection color code for the fragment code path
  12911. * @param lodVarName name of the lod variable
  12912. * @param swizzleLookupTexture swizzle to use for the final color variable
  12913. * @returns the shader code
  12914. */
  12915. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  12916. /**
  12917. * Generates the code corresponding to the connected output points
  12918. * @param state node material build state
  12919. * @param varName name of the variable to output
  12920. * @returns the shader code
  12921. */
  12922. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  12923. protected _buildBlock(state: NodeMaterialBuildState): this;
  12924. protected _dumpPropertiesCode(): string;
  12925. serialize(): any;
  12926. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12927. }
  12928. }
  12929. declare module BABYLON {
  12930. /**
  12931. * Defines a connection point to be used for points with a custom object type
  12932. */
  12933. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  12934. private _blockType;
  12935. private _blockName;
  12936. private _nameForCheking?;
  12937. /**
  12938. * Creates a new connection point
  12939. * @param name defines the connection point name
  12940. * @param ownerBlock defines the block hosting this connection point
  12941. * @param direction defines the direction of the connection point
  12942. */
  12943. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  12944. /**
  12945. * Gets a number indicating if the current point can be connected to another point
  12946. * @param connectionPoint defines the other connection point
  12947. * @returns a number defining the compatibility state
  12948. */
  12949. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12950. /**
  12951. * Creates a block suitable to be used as an input for this input point.
  12952. * If null is returned, a block based on the point type will be created.
  12953. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  12954. */
  12955. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12956. }
  12957. }
  12958. declare module BABYLON {
  12959. /**
  12960. * Enum defining the type of properties that can be edited in the property pages in the NME
  12961. */
  12962. export enum PropertyTypeForEdition {
  12963. /** property is a boolean */
  12964. Boolean = 0,
  12965. /** property is a float */
  12966. Float = 1,
  12967. /** property is a Vector2 */
  12968. Vector2 = 2,
  12969. /** property is a list of values */
  12970. List = 3
  12971. }
  12972. /**
  12973. * Interface that defines an option in a variable of type list
  12974. */
  12975. export interface IEditablePropertyListOption {
  12976. /** label of the option */
  12977. "label": string;
  12978. /** value of the option */
  12979. "value": number;
  12980. }
  12981. /**
  12982. * Interface that defines the options available for an editable property
  12983. */
  12984. export interface IEditablePropertyOption {
  12985. /** min value */
  12986. "min"?: number;
  12987. /** max value */
  12988. "max"?: number;
  12989. /** notifiers: indicates which actions to take when the property is changed */
  12990. "notifiers"?: {
  12991. /** the material should be rebuilt */
  12992. "rebuild"?: boolean;
  12993. /** the preview should be updated */
  12994. "update"?: boolean;
  12995. };
  12996. /** list of the options for a variable of type list */
  12997. "options"?: IEditablePropertyListOption[];
  12998. }
  12999. /**
  13000. * Interface that describes an editable property
  13001. */
  13002. export interface IPropertyDescriptionForEdition {
  13003. /** name of the property */
  13004. "propertyName": string;
  13005. /** display name of the property */
  13006. "displayName": string;
  13007. /** type of the property */
  13008. "type": PropertyTypeForEdition;
  13009. /** group of the property - all properties with the same group value will be displayed in a specific section */
  13010. "groupName": string;
  13011. /** options for the property */
  13012. "options": IEditablePropertyOption;
  13013. }
  13014. /**
  13015. * Decorator that flags a property in a node material block as being editable
  13016. */
  13017. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  13018. }
  13019. declare module BABYLON {
  13020. /**
  13021. * Block used to implement the refraction part of the sub surface module of the PBR material
  13022. */
  13023. export class RefractionBlock extends NodeMaterialBlock {
  13024. /** @hidden */
  13025. _define3DName: string;
  13026. /** @hidden */
  13027. _refractionMatrixName: string;
  13028. /** @hidden */
  13029. _defineLODRefractionAlpha: string;
  13030. /** @hidden */
  13031. _defineLinearSpecularRefraction: string;
  13032. /** @hidden */
  13033. _defineOppositeZ: string;
  13034. /** @hidden */
  13035. _cubeSamplerName: string;
  13036. /** @hidden */
  13037. _2DSamplerName: string;
  13038. /** @hidden */
  13039. _vRefractionMicrosurfaceInfosName: string;
  13040. /** @hidden */
  13041. _vRefractionInfosName: string;
  13042. /** @hidden */
  13043. _vRefractionFilteringInfoName: string;
  13044. private _scene;
  13045. /**
  13046. * The properties below are set by the main PBR block prior to calling methods of this class.
  13047. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  13048. * It's less burden on the user side in the editor part.
  13049. */
  13050. /** @hidden */
  13051. viewConnectionPoint: NodeMaterialConnectionPoint;
  13052. /** @hidden */
  13053. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  13054. /**
  13055. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  13056. * Materials half opaque for instance using refraction could benefit from this control.
  13057. */
  13058. linkRefractionWithTransparency: boolean;
  13059. /**
  13060. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  13061. */
  13062. invertRefractionY: boolean;
  13063. /**
  13064. * Gets or sets the texture associated with the node
  13065. */
  13066. texture: Nullable<BaseTexture>;
  13067. /**
  13068. * Create a new RefractionBlock
  13069. * @param name defines the block name
  13070. */
  13071. constructor(name: string);
  13072. /**
  13073. * Gets the current class name
  13074. * @returns the class name
  13075. */
  13076. getClassName(): string;
  13077. /**
  13078. * Gets the intensity input component
  13079. */
  13080. get intensity(): NodeMaterialConnectionPoint;
  13081. /**
  13082. * Gets the tint at distance input component
  13083. */
  13084. get tintAtDistance(): NodeMaterialConnectionPoint;
  13085. /**
  13086. * Gets the view input component
  13087. */
  13088. get view(): NodeMaterialConnectionPoint;
  13089. /**
  13090. * Gets the refraction object output component
  13091. */
  13092. get refraction(): NodeMaterialConnectionPoint;
  13093. /**
  13094. * Returns true if the block has a texture
  13095. */
  13096. get hasTexture(): boolean;
  13097. protected _getTexture(): Nullable<BaseTexture>;
  13098. autoConfigure(material: NodeMaterial): void;
  13099. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13100. isReady(): boolean;
  13101. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13102. /**
  13103. * Gets the main code of the block (fragment side)
  13104. * @param state current state of the node material building
  13105. * @returns the shader code
  13106. */
  13107. getCode(state: NodeMaterialBuildState): string;
  13108. protected _buildBlock(state: NodeMaterialBuildState): this;
  13109. protected _dumpPropertiesCode(): string;
  13110. serialize(): any;
  13111. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13112. }
  13113. }
  13114. declare module BABYLON {
  13115. /**
  13116. * Base block used as input for post process
  13117. */
  13118. export class CurrentScreenBlock extends NodeMaterialBlock {
  13119. private _samplerName;
  13120. private _linearDefineName;
  13121. private _gammaDefineName;
  13122. private _mainUVName;
  13123. private _tempTextureRead;
  13124. /**
  13125. * Gets or sets the texture associated with the node
  13126. */
  13127. texture: Nullable<BaseTexture>;
  13128. /**
  13129. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13130. */
  13131. convertToGammaSpace: boolean;
  13132. /**
  13133. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13134. */
  13135. convertToLinearSpace: boolean;
  13136. /**
  13137. * Create a new CurrentScreenBlock
  13138. * @param name defines the block name
  13139. */
  13140. constructor(name: string);
  13141. /**
  13142. * Gets the current class name
  13143. * @returns the class name
  13144. */
  13145. getClassName(): string;
  13146. /**
  13147. * Gets the uv input component
  13148. */
  13149. get uv(): NodeMaterialConnectionPoint;
  13150. /**
  13151. * Gets the rgba output component
  13152. */
  13153. get rgba(): NodeMaterialConnectionPoint;
  13154. /**
  13155. * Gets the rgb output component
  13156. */
  13157. get rgb(): NodeMaterialConnectionPoint;
  13158. /**
  13159. * Gets the r output component
  13160. */
  13161. get r(): NodeMaterialConnectionPoint;
  13162. /**
  13163. * Gets the g output component
  13164. */
  13165. get g(): NodeMaterialConnectionPoint;
  13166. /**
  13167. * Gets the b output component
  13168. */
  13169. get b(): NodeMaterialConnectionPoint;
  13170. /**
  13171. * Gets the a output component
  13172. */
  13173. get a(): NodeMaterialConnectionPoint;
  13174. /**
  13175. * Initialize the block and prepare the context for build
  13176. * @param state defines the state that will be used for the build
  13177. */
  13178. initialize(state: NodeMaterialBuildState): void;
  13179. get target(): NodeMaterialBlockTargets;
  13180. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13181. isReady(): boolean;
  13182. private _injectVertexCode;
  13183. private _writeTextureRead;
  13184. private _writeOutput;
  13185. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13186. serialize(): any;
  13187. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13188. }
  13189. }
  13190. declare module BABYLON {
  13191. /**
  13192. * Base block used for the particle texture
  13193. */
  13194. export class ParticleTextureBlock extends NodeMaterialBlock {
  13195. private _samplerName;
  13196. private _linearDefineName;
  13197. private _gammaDefineName;
  13198. private _tempTextureRead;
  13199. /**
  13200. * Gets or sets the texture associated with the node
  13201. */
  13202. texture: Nullable<BaseTexture>;
  13203. /**
  13204. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13205. */
  13206. convertToGammaSpace: boolean;
  13207. /**
  13208. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13209. */
  13210. convertToLinearSpace: boolean;
  13211. /**
  13212. * Create a new ParticleTextureBlock
  13213. * @param name defines the block name
  13214. */
  13215. constructor(name: string);
  13216. /**
  13217. * Gets the current class name
  13218. * @returns the class name
  13219. */
  13220. getClassName(): string;
  13221. /**
  13222. * Gets the uv input component
  13223. */
  13224. get uv(): NodeMaterialConnectionPoint;
  13225. /**
  13226. * Gets the rgba output component
  13227. */
  13228. get rgba(): NodeMaterialConnectionPoint;
  13229. /**
  13230. * Gets the rgb output component
  13231. */
  13232. get rgb(): NodeMaterialConnectionPoint;
  13233. /**
  13234. * Gets the r output component
  13235. */
  13236. get r(): NodeMaterialConnectionPoint;
  13237. /**
  13238. * Gets the g output component
  13239. */
  13240. get g(): NodeMaterialConnectionPoint;
  13241. /**
  13242. * Gets the b output component
  13243. */
  13244. get b(): NodeMaterialConnectionPoint;
  13245. /**
  13246. * Gets the a output component
  13247. */
  13248. get a(): NodeMaterialConnectionPoint;
  13249. /**
  13250. * Initialize the block and prepare the context for build
  13251. * @param state defines the state that will be used for the build
  13252. */
  13253. initialize(state: NodeMaterialBuildState): void;
  13254. autoConfigure(material: NodeMaterial): void;
  13255. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13256. isReady(): boolean;
  13257. private _writeOutput;
  13258. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13259. serialize(): any;
  13260. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13261. }
  13262. }
  13263. declare module BABYLON {
  13264. /**
  13265. * Class used to store shared data between 2 NodeMaterialBuildState
  13266. */
  13267. export class NodeMaterialBuildStateSharedData {
  13268. /**
  13269. * Gets the list of emitted varyings
  13270. */
  13271. temps: string[];
  13272. /**
  13273. * Gets the list of emitted varyings
  13274. */
  13275. varyings: string[];
  13276. /**
  13277. * Gets the varying declaration string
  13278. */
  13279. varyingDeclaration: string;
  13280. /**
  13281. * Input blocks
  13282. */
  13283. inputBlocks: InputBlock[];
  13284. /**
  13285. * Input blocks
  13286. */
  13287. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  13288. /**
  13289. * Bindable blocks (Blocks that need to set data to the effect)
  13290. */
  13291. bindableBlocks: NodeMaterialBlock[];
  13292. /**
  13293. * List of blocks that can provide a compilation fallback
  13294. */
  13295. blocksWithFallbacks: NodeMaterialBlock[];
  13296. /**
  13297. * List of blocks that can provide a define update
  13298. */
  13299. blocksWithDefines: NodeMaterialBlock[];
  13300. /**
  13301. * List of blocks that can provide a repeatable content
  13302. */
  13303. repeatableContentBlocks: NodeMaterialBlock[];
  13304. /**
  13305. * List of blocks that can provide a dynamic list of uniforms
  13306. */
  13307. dynamicUniformBlocks: NodeMaterialBlock[];
  13308. /**
  13309. * List of blocks that can block the isReady function for the material
  13310. */
  13311. blockingBlocks: NodeMaterialBlock[];
  13312. /**
  13313. * Gets the list of animated inputs
  13314. */
  13315. animatedInputs: InputBlock[];
  13316. /**
  13317. * Build Id used to avoid multiple recompilations
  13318. */
  13319. buildId: number;
  13320. /** List of emitted variables */
  13321. variableNames: {
  13322. [key: string]: number;
  13323. };
  13324. /** List of emitted defines */
  13325. defineNames: {
  13326. [key: string]: number;
  13327. };
  13328. /** Should emit comments? */
  13329. emitComments: boolean;
  13330. /** Emit build activity */
  13331. verbose: boolean;
  13332. /** Gets or sets the hosting scene */
  13333. scene: Scene;
  13334. /**
  13335. * Gets the compilation hints emitted at compilation time
  13336. */
  13337. hints: {
  13338. needWorldViewMatrix: boolean;
  13339. needWorldViewProjectionMatrix: boolean;
  13340. needAlphaBlending: boolean;
  13341. needAlphaTesting: boolean;
  13342. };
  13343. /**
  13344. * List of compilation checks
  13345. */
  13346. checks: {
  13347. emitVertex: boolean;
  13348. emitFragment: boolean;
  13349. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  13350. };
  13351. /**
  13352. * Is vertex program allowed to be empty?
  13353. */
  13354. allowEmptyVertexProgram: boolean;
  13355. /** Creates a new shared data */
  13356. constructor();
  13357. /**
  13358. * Emits console errors and exceptions if there is a failing check
  13359. */
  13360. emitErrors(): void;
  13361. }
  13362. }
  13363. declare module BABYLON {
  13364. /**
  13365. * Class used to store node based material build state
  13366. */
  13367. export class NodeMaterialBuildState {
  13368. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  13369. supportUniformBuffers: boolean;
  13370. /**
  13371. * Gets the list of emitted attributes
  13372. */
  13373. attributes: string[];
  13374. /**
  13375. * Gets the list of emitted uniforms
  13376. */
  13377. uniforms: string[];
  13378. /**
  13379. * Gets the list of emitted constants
  13380. */
  13381. constants: string[];
  13382. /**
  13383. * Gets the list of emitted samplers
  13384. */
  13385. samplers: string[];
  13386. /**
  13387. * Gets the list of emitted functions
  13388. */
  13389. functions: {
  13390. [key: string]: string;
  13391. };
  13392. /**
  13393. * Gets the list of emitted extensions
  13394. */
  13395. extensions: {
  13396. [key: string]: string;
  13397. };
  13398. /**
  13399. * Gets the target of the compilation state
  13400. */
  13401. target: NodeMaterialBlockTargets;
  13402. /**
  13403. * Gets the list of emitted counters
  13404. */
  13405. counters: {
  13406. [key: string]: number;
  13407. };
  13408. /**
  13409. * Shared data between multiple NodeMaterialBuildState instances
  13410. */
  13411. sharedData: NodeMaterialBuildStateSharedData;
  13412. /** @hidden */
  13413. _vertexState: NodeMaterialBuildState;
  13414. /** @hidden */
  13415. _attributeDeclaration: string;
  13416. /** @hidden */
  13417. _uniformDeclaration: string;
  13418. /** @hidden */
  13419. _constantDeclaration: string;
  13420. /** @hidden */
  13421. _samplerDeclaration: string;
  13422. /** @hidden */
  13423. _varyingTransfer: string;
  13424. /** @hidden */
  13425. _injectAtEnd: string;
  13426. private _repeatableContentAnchorIndex;
  13427. /** @hidden */
  13428. _builtCompilationString: string;
  13429. /**
  13430. * Gets the emitted compilation strings
  13431. */
  13432. compilationString: string;
  13433. /**
  13434. * Finalize the compilation strings
  13435. * @param state defines the current compilation state
  13436. */
  13437. finalize(state: NodeMaterialBuildState): void;
  13438. /** @hidden */
  13439. get _repeatableContentAnchor(): string;
  13440. /** @hidden */
  13441. _getFreeVariableName(prefix: string): string;
  13442. /** @hidden */
  13443. _getFreeDefineName(prefix: string): string;
  13444. /** @hidden */
  13445. _excludeVariableName(name: string): void;
  13446. /** @hidden */
  13447. _emit2DSampler(name: string): void;
  13448. /** @hidden */
  13449. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  13450. /** @hidden */
  13451. _emitExtension(name: string, extension: string, define?: string): void;
  13452. /** @hidden */
  13453. _emitFunction(name: string, code: string, comments: string): void;
  13454. /** @hidden */
  13455. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  13456. replaceStrings?: {
  13457. search: RegExp;
  13458. replace: string;
  13459. }[];
  13460. repeatKey?: string;
  13461. }): string;
  13462. /** @hidden */
  13463. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  13464. repeatKey?: string;
  13465. removeAttributes?: boolean;
  13466. removeUniforms?: boolean;
  13467. removeVaryings?: boolean;
  13468. removeIfDef?: boolean;
  13469. replaceStrings?: {
  13470. search: RegExp;
  13471. replace: string;
  13472. }[];
  13473. }, storeKey?: string): void;
  13474. /** @hidden */
  13475. _registerTempVariable(name: string): boolean;
  13476. /** @hidden */
  13477. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  13478. /** @hidden */
  13479. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  13480. /** @hidden */
  13481. _emitFloat(value: number): string;
  13482. }
  13483. }
  13484. declare module BABYLON {
  13485. /**
  13486. * Helper class used to generate session unique ID
  13487. */
  13488. export class UniqueIdGenerator {
  13489. private static _UniqueIdCounter;
  13490. /**
  13491. * Gets an unique (relatively to the current scene) Id
  13492. */
  13493. static get UniqueId(): number;
  13494. }
  13495. }
  13496. declare module BABYLON {
  13497. /**
  13498. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13499. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13500. */
  13501. export class EffectFallbacks implements IEffectFallbacks {
  13502. private _defines;
  13503. private _currentRank;
  13504. private _maxRank;
  13505. private _mesh;
  13506. /**
  13507. * Removes the fallback from the bound mesh.
  13508. */
  13509. unBindMesh(): void;
  13510. /**
  13511. * Adds a fallback on the specified property.
  13512. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13513. * @param define The name of the define in the shader
  13514. */
  13515. addFallback(rank: number, define: string): void;
  13516. /**
  13517. * Sets the mesh to use CPU skinning when needing to fallback.
  13518. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13519. * @param mesh The mesh to use the fallbacks.
  13520. */
  13521. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13522. /**
  13523. * Checks to see if more fallbacks are still availible.
  13524. */
  13525. get hasMoreFallbacks(): boolean;
  13526. /**
  13527. * Removes the defines that should be removed when falling back.
  13528. * @param currentDefines defines the current define statements for the shader.
  13529. * @param effect defines the current effect we try to compile
  13530. * @returns The resulting defines with defines of the current rank removed.
  13531. */
  13532. reduce(currentDefines: string, effect: Effect): string;
  13533. }
  13534. }
  13535. declare module BABYLON {
  13536. /**
  13537. * Defines a block that can be used inside a node based material
  13538. */
  13539. export class NodeMaterialBlock {
  13540. private _buildId;
  13541. private _buildTarget;
  13542. private _target;
  13543. private _isFinalMerger;
  13544. private _isInput;
  13545. private _name;
  13546. protected _isUnique: boolean;
  13547. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  13548. inputsAreExclusive: boolean;
  13549. /** @hidden */
  13550. _codeVariableName: string;
  13551. /** @hidden */
  13552. _inputs: NodeMaterialConnectionPoint[];
  13553. /** @hidden */
  13554. _outputs: NodeMaterialConnectionPoint[];
  13555. /** @hidden */
  13556. _preparationId: number;
  13557. /**
  13558. * Gets the name of the block
  13559. */
  13560. get name(): string;
  13561. /**
  13562. * Sets the name of the block. Will check if the name is valid.
  13563. */
  13564. set name(newName: string);
  13565. /**
  13566. * Gets or sets the unique id of the node
  13567. */
  13568. uniqueId: number;
  13569. /**
  13570. * Gets or sets the comments associated with this block
  13571. */
  13572. comments: string;
  13573. /**
  13574. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  13575. */
  13576. get isUnique(): boolean;
  13577. /**
  13578. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  13579. */
  13580. get isFinalMerger(): boolean;
  13581. /**
  13582. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  13583. */
  13584. get isInput(): boolean;
  13585. /**
  13586. * Gets or sets the build Id
  13587. */
  13588. get buildId(): number;
  13589. set buildId(value: number);
  13590. /**
  13591. * Gets or sets the target of the block
  13592. */
  13593. get target(): NodeMaterialBlockTargets;
  13594. set target(value: NodeMaterialBlockTargets);
  13595. /**
  13596. * Gets the list of input points
  13597. */
  13598. get inputs(): NodeMaterialConnectionPoint[];
  13599. /** Gets the list of output points */
  13600. get outputs(): NodeMaterialConnectionPoint[];
  13601. /**
  13602. * Find an input by its name
  13603. * @param name defines the name of the input to look for
  13604. * @returns the input or null if not found
  13605. */
  13606. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13607. /**
  13608. * Find an output by its name
  13609. * @param name defines the name of the outputto look for
  13610. * @returns the output or null if not found
  13611. */
  13612. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13613. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13614. visibleInInspector: boolean;
  13615. /** Gets or sets a boolean indicating that this input can be edited from a collapsed frame*/
  13616. visibleOnFrame: boolean;
  13617. /**
  13618. * Creates a new NodeMaterialBlock
  13619. * @param name defines the block name
  13620. * @param target defines the target of that block (Vertex by default)
  13621. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13622. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13623. */
  13624. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13625. /**
  13626. * Initialize the block and prepare the context for build
  13627. * @param state defines the state that will be used for the build
  13628. */
  13629. initialize(state: NodeMaterialBuildState): void;
  13630. /**
  13631. * Bind data to effect. Will only be called for blocks with isBindable === true
  13632. * @param effect defines the effect to bind data to
  13633. * @param nodeMaterial defines the hosting NodeMaterial
  13634. * @param mesh defines the mesh that will be rendered
  13635. * @param subMesh defines the submesh that will be rendered
  13636. */
  13637. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13638. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13639. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13640. protected _writeFloat(value: number): string;
  13641. /**
  13642. * Gets the current class name e.g. "NodeMaterialBlock"
  13643. * @returns the class name
  13644. */
  13645. getClassName(): string;
  13646. /**
  13647. * Register a new input. Must be called inside a block constructor
  13648. * @param name defines the connection point name
  13649. * @param type defines the connection point type
  13650. * @param isOptional defines a boolean indicating that this input can be omitted
  13651. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13652. * @param point an already created connection point. If not provided, create a new one
  13653. * @returns the current block
  13654. */
  13655. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13656. /**
  13657. * Register a new output. Must be called inside a block constructor
  13658. * @param name defines the connection point name
  13659. * @param type defines the connection point type
  13660. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13661. * @param point an already created connection point. If not provided, create a new one
  13662. * @returns the current block
  13663. */
  13664. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13665. /**
  13666. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  13667. * @param forOutput defines an optional connection point to check compatibility with
  13668. * @returns the first available input or null
  13669. */
  13670. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  13671. /**
  13672. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  13673. * @param forBlock defines an optional block to check compatibility with
  13674. * @returns the first available input or null
  13675. */
  13676. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  13677. /**
  13678. * Gets the sibling of the given output
  13679. * @param current defines the current output
  13680. * @returns the next output in the list or null
  13681. */
  13682. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  13683. /**
  13684. * Connect current block with another block
  13685. * @param other defines the block to connect with
  13686. * @param options define the various options to help pick the right connections
  13687. * @returns the current block
  13688. */
  13689. connectTo(other: NodeMaterialBlock, options?: {
  13690. input?: string;
  13691. output?: string;
  13692. outputSwizzle?: string;
  13693. }): this | undefined;
  13694. protected _buildBlock(state: NodeMaterialBuildState): void;
  13695. /**
  13696. * Add uniforms, samplers and uniform buffers at compilation time
  13697. * @param state defines the state to update
  13698. * @param nodeMaterial defines the node material requesting the update
  13699. * @param defines defines the material defines to update
  13700. * @param uniformBuffers defines the list of uniform buffer names
  13701. */
  13702. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  13703. /**
  13704. * Add potential fallbacks if shader compilation fails
  13705. * @param mesh defines the mesh to be rendered
  13706. * @param fallbacks defines the current prioritized list of fallbacks
  13707. */
  13708. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  13709. /**
  13710. * Initialize defines for shader compilation
  13711. * @param mesh defines the mesh to be rendered
  13712. * @param nodeMaterial defines the node material requesting the update
  13713. * @param defines defines the material defines to update
  13714. * @param useInstances specifies that instances should be used
  13715. */
  13716. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13717. /**
  13718. * Update defines for shader compilation
  13719. * @param mesh defines the mesh to be rendered
  13720. * @param nodeMaterial defines the node material requesting the update
  13721. * @param defines defines the material defines to update
  13722. * @param useInstances specifies that instances should be used
  13723. * @param subMesh defines which submesh to render
  13724. */
  13725. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13726. /**
  13727. * Lets the block try to connect some inputs automatically
  13728. * @param material defines the hosting NodeMaterial
  13729. */
  13730. autoConfigure(material: NodeMaterial): void;
  13731. /**
  13732. * Function called when a block is declared as repeatable content generator
  13733. * @param vertexShaderState defines the current compilation state for the vertex shader
  13734. * @param fragmentShaderState defines the current compilation state for the fragment shader
  13735. * @param mesh defines the mesh to be rendered
  13736. * @param defines defines the material defines to update
  13737. */
  13738. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  13739. /**
  13740. * Checks if the block is ready
  13741. * @param mesh defines the mesh to be rendered
  13742. * @param nodeMaterial defines the node material requesting the update
  13743. * @param defines defines the material defines to update
  13744. * @param useInstances specifies that instances should be used
  13745. * @returns true if the block is ready
  13746. */
  13747. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  13748. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  13749. private _processBuild;
  13750. /**
  13751. * Validates the new name for the block node.
  13752. * @param newName the new name to be given to the node.
  13753. * @returns false if the name is a reserve word, else true.
  13754. */
  13755. validateBlockName(newName: string): boolean;
  13756. /**
  13757. * Compile the current node and generate the shader code
  13758. * @param state defines the current compilation state (uniforms, samplers, current string)
  13759. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  13760. * @returns true if already built
  13761. */
  13762. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  13763. protected _inputRename(name: string): string;
  13764. protected _outputRename(name: string): string;
  13765. protected _dumpPropertiesCode(): string;
  13766. /** @hidden */
  13767. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  13768. /** @hidden */
  13769. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  13770. /**
  13771. * Clone the current block to a new identical block
  13772. * @param scene defines the hosting scene
  13773. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  13774. * @returns a copy of the current block
  13775. */
  13776. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  13777. /**
  13778. * Serializes this block in a JSON representation
  13779. * @returns the serialized block object
  13780. */
  13781. serialize(): any;
  13782. /** @hidden */
  13783. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13784. private _deserializePortDisplayNamesAndExposedOnFrame;
  13785. /**
  13786. * Release resources
  13787. */
  13788. dispose(): void;
  13789. }
  13790. }
  13791. declare module BABYLON {
  13792. /**
  13793. * Base class of materials working in push mode in babylon JS
  13794. * @hidden
  13795. */
  13796. export class PushMaterial extends Material {
  13797. protected _activeEffect: Effect;
  13798. protected _normalMatrix: Matrix;
  13799. constructor(name: string, scene: Scene);
  13800. getEffect(): Effect;
  13801. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13802. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  13803. /**
  13804. * Binds the given world matrix to the active effect
  13805. *
  13806. * @param world the matrix to bind
  13807. */
  13808. bindOnlyWorldMatrix(world: Matrix): void;
  13809. /**
  13810. * Binds the given normal matrix to the active effect
  13811. *
  13812. * @param normalMatrix the matrix to bind
  13813. */
  13814. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13815. bind(world: Matrix, mesh?: Mesh): void;
  13816. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13817. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13818. }
  13819. }
  13820. declare module BABYLON {
  13821. /**
  13822. * Root class for all node material optimizers
  13823. */
  13824. export class NodeMaterialOptimizer {
  13825. /**
  13826. * Function used to optimize a NodeMaterial graph
  13827. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  13828. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  13829. */
  13830. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  13831. }
  13832. }
  13833. declare module BABYLON {
  13834. /**
  13835. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  13836. */
  13837. export class TransformBlock extends NodeMaterialBlock {
  13838. /**
  13839. * Defines the value to use to complement W value to transform it to a Vector4
  13840. */
  13841. complementW: number;
  13842. /**
  13843. * Defines the value to use to complement z value to transform it to a Vector4
  13844. */
  13845. complementZ: number;
  13846. /**
  13847. * Creates a new TransformBlock
  13848. * @param name defines the block name
  13849. */
  13850. constructor(name: string);
  13851. /**
  13852. * Gets the current class name
  13853. * @returns the class name
  13854. */
  13855. getClassName(): string;
  13856. /**
  13857. * Gets the vector input
  13858. */
  13859. get vector(): NodeMaterialConnectionPoint;
  13860. /**
  13861. * Gets the output component
  13862. */
  13863. get output(): NodeMaterialConnectionPoint;
  13864. /**
  13865. * Gets the xyz output component
  13866. */
  13867. get xyz(): NodeMaterialConnectionPoint;
  13868. /**
  13869. * Gets the matrix transform input
  13870. */
  13871. get transform(): NodeMaterialConnectionPoint;
  13872. protected _buildBlock(state: NodeMaterialBuildState): this;
  13873. /**
  13874. * Update defines for shader compilation
  13875. * @param mesh defines the mesh to be rendered
  13876. * @param nodeMaterial defines the node material requesting the update
  13877. * @param defines defines the material defines to update
  13878. * @param useInstances specifies that instances should be used
  13879. * @param subMesh defines which submesh to render
  13880. */
  13881. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13882. serialize(): any;
  13883. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13884. protected _dumpPropertiesCode(): string;
  13885. }
  13886. }
  13887. declare module BABYLON {
  13888. /**
  13889. * Block used to output the vertex position
  13890. */
  13891. export class VertexOutputBlock extends NodeMaterialBlock {
  13892. /**
  13893. * Creates a new VertexOutputBlock
  13894. * @param name defines the block name
  13895. */
  13896. constructor(name: string);
  13897. /**
  13898. * Gets the current class name
  13899. * @returns the class name
  13900. */
  13901. getClassName(): string;
  13902. /**
  13903. * Gets the vector input component
  13904. */
  13905. get vector(): NodeMaterialConnectionPoint;
  13906. protected _buildBlock(state: NodeMaterialBuildState): this;
  13907. }
  13908. }
  13909. declare module BABYLON {
  13910. /**
  13911. * Block used to output the final color
  13912. */
  13913. export class FragmentOutputBlock extends NodeMaterialBlock {
  13914. /**
  13915. * Create a new FragmentOutputBlock
  13916. * @param name defines the block name
  13917. */
  13918. constructor(name: string);
  13919. /**
  13920. * Gets the current class name
  13921. * @returns the class name
  13922. */
  13923. getClassName(): string;
  13924. /**
  13925. * Gets the rgba input component
  13926. */
  13927. get rgba(): NodeMaterialConnectionPoint;
  13928. /**
  13929. * Gets the rgb input component
  13930. */
  13931. get rgb(): NodeMaterialConnectionPoint;
  13932. /**
  13933. * Gets the a input component
  13934. */
  13935. get a(): NodeMaterialConnectionPoint;
  13936. protected _buildBlock(state: NodeMaterialBuildState): this;
  13937. }
  13938. }
  13939. declare module BABYLON {
  13940. /**
  13941. * Block used for the particle ramp gradient section
  13942. */
  13943. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  13944. /**
  13945. * Create a new ParticleRampGradientBlock
  13946. * @param name defines the block name
  13947. */
  13948. constructor(name: string);
  13949. /**
  13950. * Gets the current class name
  13951. * @returns the class name
  13952. */
  13953. getClassName(): string;
  13954. /**
  13955. * Gets the color input component
  13956. */
  13957. get color(): NodeMaterialConnectionPoint;
  13958. /**
  13959. * Gets the rampColor output component
  13960. */
  13961. get rampColor(): NodeMaterialConnectionPoint;
  13962. /**
  13963. * Initialize the block and prepare the context for build
  13964. * @param state defines the state that will be used for the build
  13965. */
  13966. initialize(state: NodeMaterialBuildState): void;
  13967. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13968. }
  13969. }
  13970. declare module BABYLON {
  13971. /**
  13972. * Block used for the particle blend multiply section
  13973. */
  13974. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  13975. /**
  13976. * Create a new ParticleBlendMultiplyBlock
  13977. * @param name defines the block name
  13978. */
  13979. constructor(name: string);
  13980. /**
  13981. * Gets the current class name
  13982. * @returns the class name
  13983. */
  13984. getClassName(): string;
  13985. /**
  13986. * Gets the color input component
  13987. */
  13988. get color(): NodeMaterialConnectionPoint;
  13989. /**
  13990. * Gets the alphaTexture input component
  13991. */
  13992. get alphaTexture(): NodeMaterialConnectionPoint;
  13993. /**
  13994. * Gets the alphaColor input component
  13995. */
  13996. get alphaColor(): NodeMaterialConnectionPoint;
  13997. /**
  13998. * Gets the blendColor output component
  13999. */
  14000. get blendColor(): NodeMaterialConnectionPoint;
  14001. /**
  14002. * Initialize the block and prepare the context for build
  14003. * @param state defines the state that will be used for the build
  14004. */
  14005. initialize(state: NodeMaterialBuildState): void;
  14006. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14007. }
  14008. }
  14009. declare module BABYLON {
  14010. /**
  14011. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  14012. */
  14013. export class VectorMergerBlock extends NodeMaterialBlock {
  14014. /**
  14015. * Create a new VectorMergerBlock
  14016. * @param name defines the block name
  14017. */
  14018. constructor(name: string);
  14019. /**
  14020. * Gets the current class name
  14021. * @returns the class name
  14022. */
  14023. getClassName(): string;
  14024. /**
  14025. * Gets the xyz component (input)
  14026. */
  14027. get xyzIn(): NodeMaterialConnectionPoint;
  14028. /**
  14029. * Gets the xy component (input)
  14030. */
  14031. get xyIn(): NodeMaterialConnectionPoint;
  14032. /**
  14033. * Gets the x component (input)
  14034. */
  14035. get x(): NodeMaterialConnectionPoint;
  14036. /**
  14037. * Gets the y component (input)
  14038. */
  14039. get y(): NodeMaterialConnectionPoint;
  14040. /**
  14041. * Gets the z component (input)
  14042. */
  14043. get z(): NodeMaterialConnectionPoint;
  14044. /**
  14045. * Gets the w component (input)
  14046. */
  14047. get w(): NodeMaterialConnectionPoint;
  14048. /**
  14049. * Gets the xyzw component (output)
  14050. */
  14051. get xyzw(): NodeMaterialConnectionPoint;
  14052. /**
  14053. * Gets the xyz component (output)
  14054. */
  14055. get xyzOut(): NodeMaterialConnectionPoint;
  14056. /**
  14057. * Gets the xy component (output)
  14058. */
  14059. get xyOut(): NodeMaterialConnectionPoint;
  14060. /**
  14061. * Gets the xy component (output)
  14062. * @deprecated Please use xyOut instead.
  14063. */
  14064. get xy(): NodeMaterialConnectionPoint;
  14065. /**
  14066. * Gets the xyz component (output)
  14067. * @deprecated Please use xyzOut instead.
  14068. */
  14069. get xyz(): NodeMaterialConnectionPoint;
  14070. protected _buildBlock(state: NodeMaterialBuildState): this;
  14071. }
  14072. }
  14073. declare module BABYLON {
  14074. /**
  14075. * Block used to remap a float from a range to a new one
  14076. */
  14077. export class RemapBlock extends NodeMaterialBlock {
  14078. /**
  14079. * Gets or sets the source range
  14080. */
  14081. sourceRange: Vector2;
  14082. /**
  14083. * Gets or sets the target range
  14084. */
  14085. targetRange: Vector2;
  14086. /**
  14087. * Creates a new RemapBlock
  14088. * @param name defines the block name
  14089. */
  14090. constructor(name: string);
  14091. /**
  14092. * Gets the current class name
  14093. * @returns the class name
  14094. */
  14095. getClassName(): string;
  14096. /**
  14097. * Gets the input component
  14098. */
  14099. get input(): NodeMaterialConnectionPoint;
  14100. /**
  14101. * Gets the source min input component
  14102. */
  14103. get sourceMin(): NodeMaterialConnectionPoint;
  14104. /**
  14105. * Gets the source max input component
  14106. */
  14107. get sourceMax(): NodeMaterialConnectionPoint;
  14108. /**
  14109. * Gets the target min input component
  14110. */
  14111. get targetMin(): NodeMaterialConnectionPoint;
  14112. /**
  14113. * Gets the target max input component
  14114. */
  14115. get targetMax(): NodeMaterialConnectionPoint;
  14116. /**
  14117. * Gets the output component
  14118. */
  14119. get output(): NodeMaterialConnectionPoint;
  14120. protected _buildBlock(state: NodeMaterialBuildState): this;
  14121. protected _dumpPropertiesCode(): string;
  14122. serialize(): any;
  14123. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14124. }
  14125. }
  14126. declare module BABYLON {
  14127. /**
  14128. * Block used to multiply 2 values
  14129. */
  14130. export class MultiplyBlock extends NodeMaterialBlock {
  14131. /**
  14132. * Creates a new MultiplyBlock
  14133. * @param name defines the block name
  14134. */
  14135. constructor(name: string);
  14136. /**
  14137. * Gets the current class name
  14138. * @returns the class name
  14139. */
  14140. getClassName(): string;
  14141. /**
  14142. * Gets the left operand input component
  14143. */
  14144. get left(): NodeMaterialConnectionPoint;
  14145. /**
  14146. * Gets the right operand input component
  14147. */
  14148. get right(): NodeMaterialConnectionPoint;
  14149. /**
  14150. * Gets the output component
  14151. */
  14152. get output(): NodeMaterialConnectionPoint;
  14153. protected _buildBlock(state: NodeMaterialBuildState): this;
  14154. }
  14155. }
  14156. declare module BABYLON {
  14157. /** Interface used by value gradients (color, factor, ...) */
  14158. export interface IValueGradient {
  14159. /**
  14160. * Gets or sets the gradient value (between 0 and 1)
  14161. */
  14162. gradient: number;
  14163. }
  14164. /** Class used to store color4 gradient */
  14165. export class ColorGradient implements IValueGradient {
  14166. /**
  14167. * Gets or sets the gradient value (between 0 and 1)
  14168. */
  14169. gradient: number;
  14170. /**
  14171. * Gets or sets first associated color
  14172. */
  14173. color1: Color4;
  14174. /**
  14175. * Gets or sets second associated color
  14176. */
  14177. color2?: Color4 | undefined;
  14178. /**
  14179. * Creates a new color4 gradient
  14180. * @param gradient gets or sets the gradient value (between 0 and 1)
  14181. * @param color1 gets or sets first associated color
  14182. * @param color2 gets or sets first second color
  14183. */
  14184. constructor(
  14185. /**
  14186. * Gets or sets the gradient value (between 0 and 1)
  14187. */
  14188. gradient: number,
  14189. /**
  14190. * Gets or sets first associated color
  14191. */
  14192. color1: Color4,
  14193. /**
  14194. * Gets or sets second associated color
  14195. */
  14196. color2?: Color4 | undefined);
  14197. /**
  14198. * Will get a color picked randomly between color1 and color2.
  14199. * If color2 is undefined then color1 will be used
  14200. * @param result defines the target Color4 to store the result in
  14201. */
  14202. getColorToRef(result: Color4): void;
  14203. }
  14204. /** Class used to store color 3 gradient */
  14205. export class Color3Gradient implements IValueGradient {
  14206. /**
  14207. * Gets or sets the gradient value (between 0 and 1)
  14208. */
  14209. gradient: number;
  14210. /**
  14211. * Gets or sets the associated color
  14212. */
  14213. color: Color3;
  14214. /**
  14215. * Creates a new color3 gradient
  14216. * @param gradient gets or sets the gradient value (between 0 and 1)
  14217. * @param color gets or sets associated color
  14218. */
  14219. constructor(
  14220. /**
  14221. * Gets or sets the gradient value (between 0 and 1)
  14222. */
  14223. gradient: number,
  14224. /**
  14225. * Gets or sets the associated color
  14226. */
  14227. color: Color3);
  14228. }
  14229. /** Class used to store factor gradient */
  14230. export class FactorGradient implements IValueGradient {
  14231. /**
  14232. * Gets or sets the gradient value (between 0 and 1)
  14233. */
  14234. gradient: number;
  14235. /**
  14236. * Gets or sets first associated factor
  14237. */
  14238. factor1: number;
  14239. /**
  14240. * Gets or sets second associated factor
  14241. */
  14242. factor2?: number | undefined;
  14243. /**
  14244. * Creates a new factor gradient
  14245. * @param gradient gets or sets the gradient value (between 0 and 1)
  14246. * @param factor1 gets or sets first associated factor
  14247. * @param factor2 gets or sets second associated factor
  14248. */
  14249. constructor(
  14250. /**
  14251. * Gets or sets the gradient value (between 0 and 1)
  14252. */
  14253. gradient: number,
  14254. /**
  14255. * Gets or sets first associated factor
  14256. */
  14257. factor1: number,
  14258. /**
  14259. * Gets or sets second associated factor
  14260. */
  14261. factor2?: number | undefined);
  14262. /**
  14263. * Will get a number picked randomly between factor1 and factor2.
  14264. * If factor2 is undefined then factor1 will be used
  14265. * @returns the picked number
  14266. */
  14267. getFactor(): number;
  14268. }
  14269. /**
  14270. * Helper used to simplify some generic gradient tasks
  14271. */
  14272. export class GradientHelper {
  14273. /**
  14274. * Gets the current gradient from an array of IValueGradient
  14275. * @param ratio defines the current ratio to get
  14276. * @param gradients defines the array of IValueGradient
  14277. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  14278. */
  14279. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  14280. }
  14281. }
  14282. declare module BABYLON {
  14283. interface ThinEngine {
  14284. /**
  14285. * Creates a raw texture
  14286. * @param data defines the data to store in the texture
  14287. * @param width defines the width of the texture
  14288. * @param height defines the height of the texture
  14289. * @param format defines the format of the data
  14290. * @param generateMipMaps defines if the engine should generate the mip levels
  14291. * @param invertY defines if data must be stored with Y axis inverted
  14292. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  14293. * @param compression defines the compression used (null by default)
  14294. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14295. * @returns the raw texture inside an InternalTexture
  14296. */
  14297. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  14298. /**
  14299. * Update a raw texture
  14300. * @param texture defines the texture to update
  14301. * @param data defines the data to store in the texture
  14302. * @param format defines the format of the data
  14303. * @param invertY defines if data must be stored with Y axis inverted
  14304. */
  14305. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14306. /**
  14307. * Update a raw texture
  14308. * @param texture defines the texture to update
  14309. * @param data defines the data to store in the texture
  14310. * @param format defines the format of the data
  14311. * @param invertY defines if data must be stored with Y axis inverted
  14312. * @param compression defines the compression used (null by default)
  14313. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14314. */
  14315. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  14316. /**
  14317. * Creates a new raw cube texture
  14318. * @param data defines the array of data to use to create each face
  14319. * @param size defines the size of the textures
  14320. * @param format defines the format of the data
  14321. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14322. * @param generateMipMaps defines if the engine should generate the mip levels
  14323. * @param invertY defines if data must be stored with Y axis inverted
  14324. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14325. * @param compression defines the compression used (null by default)
  14326. * @returns the cube texture as an InternalTexture
  14327. */
  14328. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  14329. /**
  14330. * Update a raw cube texture
  14331. * @param texture defines the texture to udpdate
  14332. * @param data defines the data to store
  14333. * @param format defines the data format
  14334. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14335. * @param invertY defines if data must be stored with Y axis inverted
  14336. */
  14337. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  14338. /**
  14339. * Update a raw cube texture
  14340. * @param texture defines the texture to udpdate
  14341. * @param data defines the data to store
  14342. * @param format defines the data format
  14343. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14344. * @param invertY defines if data must be stored with Y axis inverted
  14345. * @param compression defines the compression used (null by default)
  14346. */
  14347. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  14348. /**
  14349. * Update a raw cube texture
  14350. * @param texture defines the texture to udpdate
  14351. * @param data defines the data to store
  14352. * @param format defines the data format
  14353. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14354. * @param invertY defines if data must be stored with Y axis inverted
  14355. * @param compression defines the compression used (null by default)
  14356. * @param level defines which level of the texture to update
  14357. */
  14358. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  14359. /**
  14360. * Creates a new raw cube texture from a specified url
  14361. * @param url defines the url where the data is located
  14362. * @param scene defines the current scene
  14363. * @param size defines the size of the textures
  14364. * @param format defines the format of the data
  14365. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14366. * @param noMipmap defines if the engine should avoid generating the mip levels
  14367. * @param callback defines a callback used to extract texture data from loaded data
  14368. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14369. * @param onLoad defines a callback called when texture is loaded
  14370. * @param onError defines a callback called if there is an error
  14371. * @returns the cube texture as an InternalTexture
  14372. */
  14373. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  14374. /**
  14375. * Creates a new raw cube texture from a specified url
  14376. * @param url defines the url where the data is located
  14377. * @param scene defines the current scene
  14378. * @param size defines the size of the textures
  14379. * @param format defines the format of the data
  14380. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14381. * @param noMipmap defines if the engine should avoid generating the mip levels
  14382. * @param callback defines a callback used to extract texture data from loaded data
  14383. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14384. * @param onLoad defines a callback called when texture is loaded
  14385. * @param onError defines a callback called if there is an error
  14386. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14387. * @param invertY defines if data must be stored with Y axis inverted
  14388. * @returns the cube texture as an InternalTexture
  14389. */
  14390. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  14391. /**
  14392. * Creates a new raw 3D texture
  14393. * @param data defines the data used to create the texture
  14394. * @param width defines the width of the texture
  14395. * @param height defines the height of the texture
  14396. * @param depth defines the depth of the texture
  14397. * @param format defines the format of the texture
  14398. * @param generateMipMaps defines if the engine must generate mip levels
  14399. * @param invertY defines if data must be stored with Y axis inverted
  14400. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14401. * @param compression defines the compressed used (can be null)
  14402. * @param textureType defines the compressed used (can be null)
  14403. * @returns a new raw 3D texture (stored in an InternalTexture)
  14404. */
  14405. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14406. /**
  14407. * Update a raw 3D texture
  14408. * @param texture defines the texture to update
  14409. * @param data defines the data to store
  14410. * @param format defines the data format
  14411. * @param invertY defines if data must be stored with Y axis inverted
  14412. */
  14413. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14414. /**
  14415. * Update a raw 3D texture
  14416. * @param texture defines the texture to update
  14417. * @param data defines the data to store
  14418. * @param format defines the data format
  14419. * @param invertY defines if data must be stored with Y axis inverted
  14420. * @param compression defines the used compression (can be null)
  14421. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14422. */
  14423. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14424. /**
  14425. * Creates a new raw 2D array texture
  14426. * @param data defines the data used to create the texture
  14427. * @param width defines the width of the texture
  14428. * @param height defines the height of the texture
  14429. * @param depth defines the number of layers of the texture
  14430. * @param format defines the format of the texture
  14431. * @param generateMipMaps defines if the engine must generate mip levels
  14432. * @param invertY defines if data must be stored with Y axis inverted
  14433. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14434. * @param compression defines the compressed used (can be null)
  14435. * @param textureType defines the compressed used (can be null)
  14436. * @returns a new raw 2D array texture (stored in an InternalTexture)
  14437. */
  14438. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14439. /**
  14440. * Update a raw 2D array texture
  14441. * @param texture defines the texture to update
  14442. * @param data defines the data to store
  14443. * @param format defines the data format
  14444. * @param invertY defines if data must be stored with Y axis inverted
  14445. */
  14446. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14447. /**
  14448. * Update a raw 2D array texture
  14449. * @param texture defines the texture to update
  14450. * @param data defines the data to store
  14451. * @param format defines the data format
  14452. * @param invertY defines if data must be stored with Y axis inverted
  14453. * @param compression defines the used compression (can be null)
  14454. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14455. */
  14456. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14457. }
  14458. }
  14459. declare module BABYLON {
  14460. /**
  14461. * Raw texture can help creating a texture directly from an array of data.
  14462. * This can be super useful if you either get the data from an uncompressed source or
  14463. * if you wish to create your texture pixel by pixel.
  14464. */
  14465. export class RawTexture extends Texture {
  14466. /**
  14467. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14468. */
  14469. format: number;
  14470. /**
  14471. * Instantiates a new RawTexture.
  14472. * Raw texture can help creating a texture directly from an array of data.
  14473. * This can be super useful if you either get the data from an uncompressed source or
  14474. * if you wish to create your texture pixel by pixel.
  14475. * @param data define the array of data to use to create the texture
  14476. * @param width define the width of the texture
  14477. * @param height define the height of the texture
  14478. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14479. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14480. * @param generateMipMaps define whether mip maps should be generated or not
  14481. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14482. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14483. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14484. */
  14485. constructor(data: ArrayBufferView, width: number, height: number,
  14486. /**
  14487. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14488. */
  14489. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  14490. /**
  14491. * Updates the texture underlying data.
  14492. * @param data Define the new data of the texture
  14493. */
  14494. update(data: ArrayBufferView): void;
  14495. /**
  14496. * Creates a luminance texture from some data.
  14497. * @param data Define the texture data
  14498. * @param width Define the width of the texture
  14499. * @param height Define the height of the texture
  14500. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14501. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14502. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14503. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14504. * @returns the luminance texture
  14505. */
  14506. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14507. /**
  14508. * Creates a luminance alpha texture from some data.
  14509. * @param data Define the texture data
  14510. * @param width Define the width of the texture
  14511. * @param height Define the height of the texture
  14512. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14513. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14514. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14515. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14516. * @returns the luminance alpha texture
  14517. */
  14518. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14519. /**
  14520. * Creates an alpha texture from some data.
  14521. * @param data Define the texture data
  14522. * @param width Define the width of the texture
  14523. * @param height Define the height of the texture
  14524. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14525. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14526. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14527. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14528. * @returns the alpha texture
  14529. */
  14530. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14531. /**
  14532. * Creates a RGB texture from some data.
  14533. * @param data Define the texture data
  14534. * @param width Define the width of the texture
  14535. * @param height Define the height of the texture
  14536. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14537. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14538. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14539. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14540. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14541. * @returns the RGB alpha texture
  14542. */
  14543. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14544. /**
  14545. * Creates a RGBA texture from some data.
  14546. * @param data Define the texture data
  14547. * @param width Define the width of the texture
  14548. * @param height Define the height of the texture
  14549. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14550. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14551. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14552. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14553. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14554. * @returns the RGBA texture
  14555. */
  14556. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14557. /**
  14558. * Creates a R texture from some data.
  14559. * @param data Define the texture data
  14560. * @param width Define the width of the texture
  14561. * @param height Define the height of the texture
  14562. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14563. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14564. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14565. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14566. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14567. * @returns the R texture
  14568. */
  14569. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14570. }
  14571. }
  14572. declare module BABYLON {
  14573. interface ThinEngine {
  14574. /**
  14575. * Update a dynamic index buffer
  14576. * @param indexBuffer defines the target index buffer
  14577. * @param indices defines the data to update
  14578. * @param offset defines the offset in the target index buffer where update should start
  14579. */
  14580. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  14581. /**
  14582. * Updates a dynamic vertex buffer.
  14583. * @param vertexBuffer the vertex buffer to update
  14584. * @param data the data used to update the vertex buffer
  14585. * @param byteOffset the byte offset of the data
  14586. * @param byteLength the byte length of the data
  14587. */
  14588. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  14589. }
  14590. }
  14591. declare module BABYLON {
  14592. interface AbstractScene {
  14593. /**
  14594. * The list of procedural textures added to the scene
  14595. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14596. */
  14597. proceduralTextures: Array<ProceduralTexture>;
  14598. }
  14599. /**
  14600. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14601. * in a given scene.
  14602. */
  14603. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14604. /**
  14605. * The component name helpfull to identify the component in the list of scene components.
  14606. */
  14607. readonly name: string;
  14608. /**
  14609. * The scene the component belongs to.
  14610. */
  14611. scene: Scene;
  14612. /**
  14613. * Creates a new instance of the component for the given scene
  14614. * @param scene Defines the scene to register the component in
  14615. */
  14616. constructor(scene: Scene);
  14617. /**
  14618. * Registers the component in a given scene
  14619. */
  14620. register(): void;
  14621. /**
  14622. * Rebuilds the elements related to this component in case of
  14623. * context lost for instance.
  14624. */
  14625. rebuild(): void;
  14626. /**
  14627. * Disposes the component and the associated ressources.
  14628. */
  14629. dispose(): void;
  14630. private _beforeClear;
  14631. }
  14632. }
  14633. declare module BABYLON {
  14634. interface ThinEngine {
  14635. /**
  14636. * Creates a new render target cube texture
  14637. * @param size defines the size of the texture
  14638. * @param options defines the options used to create the texture
  14639. * @returns a new render target cube texture stored in an InternalTexture
  14640. */
  14641. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14642. }
  14643. }
  14644. declare module BABYLON {
  14645. /** @hidden */
  14646. export var proceduralVertexShader: {
  14647. name: string;
  14648. shader: string;
  14649. };
  14650. }
  14651. declare module BABYLON {
  14652. /**
  14653. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  14654. * This is the base class of any Procedural texture and contains most of the shareable code.
  14655. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14656. */
  14657. export class ProceduralTexture extends Texture {
  14658. /**
  14659. * Define if the texture is enabled or not (disabled texture will not render)
  14660. */
  14661. isEnabled: boolean;
  14662. /**
  14663. * Define if the texture must be cleared before rendering (default is true)
  14664. */
  14665. autoClear: boolean;
  14666. /**
  14667. * Callback called when the texture is generated
  14668. */
  14669. onGenerated: () => void;
  14670. /**
  14671. * Event raised when the texture is generated
  14672. */
  14673. onGeneratedObservable: Observable<ProceduralTexture>;
  14674. /**
  14675. * Event raised before the texture is generated
  14676. */
  14677. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  14678. /**
  14679. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  14680. */
  14681. nodeMaterialSource: Nullable<NodeMaterial>;
  14682. /** @hidden */
  14683. _generateMipMaps: boolean;
  14684. /** @hidden **/
  14685. _effect: Effect;
  14686. /** @hidden */
  14687. _textures: {
  14688. [key: string]: Texture;
  14689. };
  14690. /** @hidden */
  14691. protected _fallbackTexture: Nullable<Texture>;
  14692. private _size;
  14693. private _textureType;
  14694. private _currentRefreshId;
  14695. private _frameId;
  14696. private _refreshRate;
  14697. private _vertexBuffers;
  14698. private _indexBuffer;
  14699. private _uniforms;
  14700. private _samplers;
  14701. private _fragment;
  14702. private _floats;
  14703. private _ints;
  14704. private _floatsArrays;
  14705. private _colors3;
  14706. private _colors4;
  14707. private _vectors2;
  14708. private _vectors3;
  14709. private _matrices;
  14710. private _fallbackTextureUsed;
  14711. private _fullEngine;
  14712. private _cachedDefines;
  14713. private _contentUpdateId;
  14714. private _contentData;
  14715. /**
  14716. * Instantiates a new procedural texture.
  14717. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  14718. * This is the base class of any Procedural texture and contains most of the shareable code.
  14719. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14720. * @param name Define the name of the texture
  14721. * @param size Define the size of the texture to create
  14722. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14723. * @param scene Define the scene the texture belongs to
  14724. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14725. * @param generateMipMaps Define if the texture should creates mip maps or not
  14726. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14727. * @param textureType The FBO internal texture type
  14728. */
  14729. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  14730. /**
  14731. * The effect that is created when initializing the post process.
  14732. * @returns The created effect corresponding the the postprocess.
  14733. */
  14734. getEffect(): Effect;
  14735. /**
  14736. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14737. * @returns an ArrayBufferView promise (Uint8Array or Float32Array)
  14738. */
  14739. getContent(): Nullable<Promise<ArrayBufferView>>;
  14740. private _createIndexBuffer;
  14741. /** @hidden */
  14742. _rebuild(): void;
  14743. /**
  14744. * Resets the texture in order to recreate its associated resources.
  14745. * This can be called in case of context loss
  14746. */
  14747. reset(): void;
  14748. protected _getDefines(): string;
  14749. /**
  14750. * Is the texture ready to be used ? (rendered at least once)
  14751. * @returns true if ready, otherwise, false.
  14752. */
  14753. isReady(): boolean;
  14754. /**
  14755. * Resets the refresh counter of the texture and start bak from scratch.
  14756. * Could be useful to regenerate the texture if it is setup to render only once.
  14757. */
  14758. resetRefreshCounter(): void;
  14759. /**
  14760. * Set the fragment shader to use in order to render the texture.
  14761. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14762. */
  14763. setFragment(fragment: any): void;
  14764. /**
  14765. * Define the refresh rate of the texture or the rendering frequency.
  14766. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14767. */
  14768. get refreshRate(): number;
  14769. set refreshRate(value: number);
  14770. /** @hidden */
  14771. _shouldRender(): boolean;
  14772. /**
  14773. * Get the size the texture is rendering at.
  14774. * @returns the size (on cube texture it is always squared)
  14775. */
  14776. getRenderSize(): RenderTargetTextureSize;
  14777. /**
  14778. * Resize the texture to new value.
  14779. * @param size Define the new size the texture should have
  14780. * @param generateMipMaps Define whether the new texture should create mip maps
  14781. */
  14782. resize(size: number, generateMipMaps: boolean): void;
  14783. private _checkUniform;
  14784. /**
  14785. * Set a texture in the shader program used to render.
  14786. * @param name Define the name of the uniform samplers as defined in the shader
  14787. * @param texture Define the texture to bind to this sampler
  14788. * @return the texture itself allowing "fluent" like uniform updates
  14789. */
  14790. setTexture(name: string, texture: Texture): ProceduralTexture;
  14791. /**
  14792. * Set a float in the shader.
  14793. * @param name Define the name of the uniform as defined in the shader
  14794. * @param value Define the value to give to the uniform
  14795. * @return the texture itself allowing "fluent" like uniform updates
  14796. */
  14797. setFloat(name: string, value: number): ProceduralTexture;
  14798. /**
  14799. * Set a int in the shader.
  14800. * @param name Define the name of the uniform as defined in the shader
  14801. * @param value Define the value to give to the uniform
  14802. * @return the texture itself allowing "fluent" like uniform updates
  14803. */
  14804. setInt(name: string, value: number): ProceduralTexture;
  14805. /**
  14806. * Set an array of floats in the shader.
  14807. * @param name Define the name of the uniform as defined in the shader
  14808. * @param value Define the value to give to the uniform
  14809. * @return the texture itself allowing "fluent" like uniform updates
  14810. */
  14811. setFloats(name: string, value: number[]): ProceduralTexture;
  14812. /**
  14813. * Set a vec3 in the shader from a Color3.
  14814. * @param name Define the name of the uniform as defined in the shader
  14815. * @param value Define the value to give to the uniform
  14816. * @return the texture itself allowing "fluent" like uniform updates
  14817. */
  14818. setColor3(name: string, value: Color3): ProceduralTexture;
  14819. /**
  14820. * Set a vec4 in the shader from a Color4.
  14821. * @param name Define the name of the uniform as defined in the shader
  14822. * @param value Define the value to give to the uniform
  14823. * @return the texture itself allowing "fluent" like uniform updates
  14824. */
  14825. setColor4(name: string, value: Color4): ProceduralTexture;
  14826. /**
  14827. * Set a vec2 in the shader from a Vector2.
  14828. * @param name Define the name of the uniform as defined in the shader
  14829. * @param value Define the value to give to the uniform
  14830. * @return the texture itself allowing "fluent" like uniform updates
  14831. */
  14832. setVector2(name: string, value: Vector2): ProceduralTexture;
  14833. /**
  14834. * Set a vec3 in the shader from a Vector3.
  14835. * @param name Define the name of the uniform as defined in the shader
  14836. * @param value Define the value to give to the uniform
  14837. * @return the texture itself allowing "fluent" like uniform updates
  14838. */
  14839. setVector3(name: string, value: Vector3): ProceduralTexture;
  14840. /**
  14841. * Set a mat4 in the shader from a MAtrix.
  14842. * @param name Define the name of the uniform as defined in the shader
  14843. * @param value Define the value to give to the uniform
  14844. * @return the texture itself allowing "fluent" like uniform updates
  14845. */
  14846. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14847. /**
  14848. * Render the texture to its associated render target.
  14849. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14850. */
  14851. render(useCameraPostProcess?: boolean): void;
  14852. /**
  14853. * Clone the texture.
  14854. * @returns the cloned texture
  14855. */
  14856. clone(): ProceduralTexture;
  14857. /**
  14858. * Dispose the texture and release its asoociated resources.
  14859. */
  14860. dispose(): void;
  14861. }
  14862. }
  14863. declare module BABYLON {
  14864. /**
  14865. * This represents the base class for particle system in Babylon.
  14866. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  14867. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14868. * @example https://doc.babylonjs.com/babylon101/particles
  14869. */
  14870. export class BaseParticleSystem {
  14871. /**
  14872. * Source color is added to the destination color without alpha affecting the result
  14873. */
  14874. static BLENDMODE_ONEONE: number;
  14875. /**
  14876. * Blend current color and particle color using particle’s alpha
  14877. */
  14878. static BLENDMODE_STANDARD: number;
  14879. /**
  14880. * Add current color and particle color multiplied by particle’s alpha
  14881. */
  14882. static BLENDMODE_ADD: number;
  14883. /**
  14884. * Multiply current color with particle color
  14885. */
  14886. static BLENDMODE_MULTIPLY: number;
  14887. /**
  14888. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14889. */
  14890. static BLENDMODE_MULTIPLYADD: number;
  14891. /**
  14892. * List of animations used by the particle system.
  14893. */
  14894. animations: Animation[];
  14895. /**
  14896. * Gets or sets the unique id of the particle system
  14897. */
  14898. uniqueId: number;
  14899. /**
  14900. * The id of the Particle system.
  14901. */
  14902. id: string;
  14903. /**
  14904. * The friendly name of the Particle system.
  14905. */
  14906. name: string;
  14907. /**
  14908. * Snippet ID if the particle system was created from the snippet server
  14909. */
  14910. snippetId: string;
  14911. /**
  14912. * The rendering group used by the Particle system to chose when to render.
  14913. */
  14914. renderingGroupId: number;
  14915. /**
  14916. * The emitter represents the Mesh or position we are attaching the particle system to.
  14917. */
  14918. emitter: Nullable<AbstractMesh | Vector3>;
  14919. /**
  14920. * The maximum number of particles to emit per frame
  14921. */
  14922. emitRate: number;
  14923. /**
  14924. * If you want to launch only a few particles at once, that can be done, as well.
  14925. */
  14926. manualEmitCount: number;
  14927. /**
  14928. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14929. */
  14930. updateSpeed: number;
  14931. /**
  14932. * The amount of time the particle system is running (depends of the overall update speed).
  14933. */
  14934. targetStopDuration: number;
  14935. /**
  14936. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14937. */
  14938. disposeOnStop: boolean;
  14939. /**
  14940. * Minimum power of emitting particles.
  14941. */
  14942. minEmitPower: number;
  14943. /**
  14944. * Maximum power of emitting particles.
  14945. */
  14946. maxEmitPower: number;
  14947. /**
  14948. * Minimum life time of emitting particles.
  14949. */
  14950. minLifeTime: number;
  14951. /**
  14952. * Maximum life time of emitting particles.
  14953. */
  14954. maxLifeTime: number;
  14955. /**
  14956. * Minimum Size of emitting particles.
  14957. */
  14958. minSize: number;
  14959. /**
  14960. * Maximum Size of emitting particles.
  14961. */
  14962. maxSize: number;
  14963. /**
  14964. * Minimum scale of emitting particles on X axis.
  14965. */
  14966. minScaleX: number;
  14967. /**
  14968. * Maximum scale of emitting particles on X axis.
  14969. */
  14970. maxScaleX: number;
  14971. /**
  14972. * Minimum scale of emitting particles on Y axis.
  14973. */
  14974. minScaleY: number;
  14975. /**
  14976. * Maximum scale of emitting particles on Y axis.
  14977. */
  14978. maxScaleY: number;
  14979. /**
  14980. * Gets or sets the minimal initial rotation in radians.
  14981. */
  14982. minInitialRotation: number;
  14983. /**
  14984. * Gets or sets the maximal initial rotation in radians.
  14985. */
  14986. maxInitialRotation: number;
  14987. /**
  14988. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14989. */
  14990. minAngularSpeed: number;
  14991. /**
  14992. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14993. */
  14994. maxAngularSpeed: number;
  14995. /**
  14996. * The texture used to render each particle. (this can be a spritesheet)
  14997. */
  14998. particleTexture: Nullable<BaseTexture>;
  14999. /**
  15000. * The layer mask we are rendering the particles through.
  15001. */
  15002. layerMask: number;
  15003. /**
  15004. * This can help using your own shader to render the particle system.
  15005. * The according effect will be created
  15006. */
  15007. customShader: any;
  15008. /**
  15009. * By default particle system starts as soon as they are created. This prevents the
  15010. * automatic start to happen and let you decide when to start emitting particles.
  15011. */
  15012. preventAutoStart: boolean;
  15013. private _noiseTexture;
  15014. /**
  15015. * Gets or sets a texture used to add random noise to particle positions
  15016. */
  15017. get noiseTexture(): Nullable<ProceduralTexture>;
  15018. set noiseTexture(value: Nullable<ProceduralTexture>);
  15019. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15020. noiseStrength: Vector3;
  15021. /**
  15022. * Callback triggered when the particle animation is ending.
  15023. */
  15024. onAnimationEnd: Nullable<() => void>;
  15025. /**
  15026. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  15027. */
  15028. blendMode: number;
  15029. /**
  15030. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  15031. * to override the particles.
  15032. */
  15033. forceDepthWrite: boolean;
  15034. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  15035. preWarmCycles: number;
  15036. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  15037. preWarmStepOffset: number;
  15038. /**
  15039. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  15040. */
  15041. spriteCellChangeSpeed: number;
  15042. /**
  15043. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15044. */
  15045. startSpriteCellID: number;
  15046. /**
  15047. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15048. */
  15049. endSpriteCellID: number;
  15050. /**
  15051. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15052. */
  15053. spriteCellWidth: number;
  15054. /**
  15055. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15056. */
  15057. spriteCellHeight: number;
  15058. /**
  15059. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15060. */
  15061. spriteRandomStartCell: boolean;
  15062. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15063. translationPivot: Vector2;
  15064. /** @hidden */
  15065. protected _isAnimationSheetEnabled: boolean;
  15066. /**
  15067. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15068. */
  15069. beginAnimationOnStart: boolean;
  15070. /**
  15071. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15072. */
  15073. beginAnimationFrom: number;
  15074. /**
  15075. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15076. */
  15077. beginAnimationTo: number;
  15078. /**
  15079. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15080. */
  15081. beginAnimationLoop: boolean;
  15082. /**
  15083. * Gets or sets a world offset applied to all particles
  15084. */
  15085. worldOffset: Vector3;
  15086. /**
  15087. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  15088. */
  15089. get isAnimationSheetEnabled(): boolean;
  15090. set isAnimationSheetEnabled(value: boolean);
  15091. /**
  15092. * Get hosting scene
  15093. * @returns the scene
  15094. */
  15095. getScene(): Nullable<Scene>;
  15096. /**
  15097. * You can use gravity if you want to give an orientation to your particles.
  15098. */
  15099. gravity: Vector3;
  15100. protected _colorGradients: Nullable<Array<ColorGradient>>;
  15101. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  15102. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  15103. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  15104. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  15105. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  15106. protected _dragGradients: Nullable<Array<FactorGradient>>;
  15107. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  15108. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  15109. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  15110. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  15111. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  15112. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  15113. /**
  15114. * Defines the delay in milliseconds before starting the system (0 by default)
  15115. */
  15116. startDelay: number;
  15117. /**
  15118. * Gets the current list of drag gradients.
  15119. * You must use addDragGradient and removeDragGradient to udpate this list
  15120. * @returns the list of drag gradients
  15121. */
  15122. getDragGradients(): Nullable<Array<FactorGradient>>;
  15123. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15124. limitVelocityDamping: number;
  15125. /**
  15126. * Gets the current list of limit velocity gradients.
  15127. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  15128. * @returns the list of limit velocity gradients
  15129. */
  15130. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  15131. /**
  15132. * Gets the current list of color gradients.
  15133. * You must use addColorGradient and removeColorGradient to udpate this list
  15134. * @returns the list of color gradients
  15135. */
  15136. getColorGradients(): Nullable<Array<ColorGradient>>;
  15137. /**
  15138. * Gets the current list of size gradients.
  15139. * You must use addSizeGradient and removeSizeGradient to udpate this list
  15140. * @returns the list of size gradients
  15141. */
  15142. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15143. /**
  15144. * Gets the current list of color remap gradients.
  15145. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  15146. * @returns the list of color remap gradients
  15147. */
  15148. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15149. /**
  15150. * Gets the current list of alpha remap gradients.
  15151. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15152. * @returns the list of alpha remap gradients
  15153. */
  15154. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15155. /**
  15156. * Gets the current list of life time gradients.
  15157. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  15158. * @returns the list of life time gradients
  15159. */
  15160. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15161. /**
  15162. * Gets the current list of angular speed gradients.
  15163. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  15164. * @returns the list of angular speed gradients
  15165. */
  15166. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15167. /**
  15168. * Gets the current list of velocity gradients.
  15169. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  15170. * @returns the list of velocity gradients
  15171. */
  15172. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15173. /**
  15174. * Gets the current list of start size gradients.
  15175. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15176. * @returns the list of start size gradients
  15177. */
  15178. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15179. /**
  15180. * Gets the current list of emit rate gradients.
  15181. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15182. * @returns the list of emit rate gradients
  15183. */
  15184. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15185. /**
  15186. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15187. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15188. */
  15189. get direction1(): Vector3;
  15190. set direction1(value: Vector3);
  15191. /**
  15192. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15193. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15194. */
  15195. get direction2(): Vector3;
  15196. set direction2(value: Vector3);
  15197. /**
  15198. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  15199. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15200. */
  15201. get minEmitBox(): Vector3;
  15202. set minEmitBox(value: Vector3);
  15203. /**
  15204. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  15205. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15206. */
  15207. get maxEmitBox(): Vector3;
  15208. set maxEmitBox(value: Vector3);
  15209. /**
  15210. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15211. */
  15212. color1: Color4;
  15213. /**
  15214. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15215. */
  15216. color2: Color4;
  15217. /**
  15218. * Color the particle will have at the end of its lifetime
  15219. */
  15220. colorDead: Color4;
  15221. /**
  15222. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15223. */
  15224. textureMask: Color4;
  15225. /**
  15226. * The particle emitter type defines the emitter used by the particle system.
  15227. * It can be for example box, sphere, or cone...
  15228. */
  15229. particleEmitterType: IParticleEmitterType;
  15230. /** @hidden */
  15231. _isSubEmitter: boolean;
  15232. /**
  15233. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15234. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15235. */
  15236. billboardMode: number;
  15237. protected _isBillboardBased: boolean;
  15238. /**
  15239. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15240. */
  15241. get isBillboardBased(): boolean;
  15242. set isBillboardBased(value: boolean);
  15243. /**
  15244. * The scene the particle system belongs to.
  15245. */
  15246. protected _scene: Nullable<Scene>;
  15247. /**
  15248. * The engine the particle system belongs to.
  15249. */
  15250. protected _engine: ThinEngine;
  15251. /**
  15252. * Local cache of defines for image processing.
  15253. */
  15254. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15255. /**
  15256. * Default configuration related to image processing available in the standard Material.
  15257. */
  15258. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  15259. /**
  15260. * Gets the image processing configuration used either in this material.
  15261. */
  15262. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  15263. /**
  15264. * Sets the Default image processing configuration used either in the this material.
  15265. *
  15266. * If sets to null, the scene one is in use.
  15267. */
  15268. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  15269. /**
  15270. * Attaches a new image processing configuration to the Standard Material.
  15271. * @param configuration
  15272. */
  15273. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15274. /** @hidden */
  15275. protected _reset(): void;
  15276. /** @hidden */
  15277. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15278. /**
  15279. * Instantiates a particle system.
  15280. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  15281. * @param name The name of the particle system
  15282. */
  15283. constructor(name: string);
  15284. /**
  15285. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15286. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15287. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15288. * @returns the emitter
  15289. */
  15290. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15291. /**
  15292. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15293. * @param radius The radius of the hemisphere to emit from
  15294. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15295. * @returns the emitter
  15296. */
  15297. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15298. /**
  15299. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15300. * @param radius The radius of the sphere to emit from
  15301. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15302. * @returns the emitter
  15303. */
  15304. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15305. /**
  15306. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15307. * @param radius The radius of the sphere to emit from
  15308. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15309. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15310. * @returns the emitter
  15311. */
  15312. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15313. /**
  15314. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15315. * @param radius The radius of the emission cylinder
  15316. * @param height The height of the emission cylinder
  15317. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15318. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15319. * @returns the emitter
  15320. */
  15321. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15322. /**
  15323. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15324. * @param radius The radius of the cylinder to emit from
  15325. * @param height The height of the emission cylinder
  15326. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15327. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15328. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15329. * @returns the emitter
  15330. */
  15331. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15332. /**
  15333. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15334. * @param radius The radius of the cone to emit from
  15335. * @param angle The base angle of the cone
  15336. * @returns the emitter
  15337. */
  15338. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15339. /**
  15340. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15341. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15342. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15343. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15344. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15345. * @returns the emitter
  15346. */
  15347. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15348. }
  15349. }
  15350. declare module BABYLON {
  15351. /**
  15352. * Type of sub emitter
  15353. */
  15354. export enum SubEmitterType {
  15355. /**
  15356. * Attached to the particle over it's lifetime
  15357. */
  15358. ATTACHED = 0,
  15359. /**
  15360. * Created when the particle dies
  15361. */
  15362. END = 1
  15363. }
  15364. /**
  15365. * Sub emitter class used to emit particles from an existing particle
  15366. */
  15367. export class SubEmitter {
  15368. /**
  15369. * the particle system to be used by the sub emitter
  15370. */
  15371. particleSystem: ParticleSystem;
  15372. /**
  15373. * Type of the submitter (Default: END)
  15374. */
  15375. type: SubEmitterType;
  15376. /**
  15377. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  15378. * Note: This only is supported when using an emitter of type Mesh
  15379. */
  15380. inheritDirection: boolean;
  15381. /**
  15382. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15383. */
  15384. inheritedVelocityAmount: number;
  15385. /**
  15386. * Creates a sub emitter
  15387. * @param particleSystem the particle system to be used by the sub emitter
  15388. */
  15389. constructor(
  15390. /**
  15391. * the particle system to be used by the sub emitter
  15392. */
  15393. particleSystem: ParticleSystem);
  15394. /**
  15395. * Clones the sub emitter
  15396. * @returns the cloned sub emitter
  15397. */
  15398. clone(): SubEmitter;
  15399. /**
  15400. * Serialize current object to a JSON object
  15401. * @returns the serialized object
  15402. */
  15403. serialize(): any;
  15404. /** @hidden */
  15405. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  15406. /**
  15407. * Creates a new SubEmitter from a serialized JSON version
  15408. * @param serializationObject defines the JSON object to read from
  15409. * @param sceneOrEngine defines the hosting scene or the hosting engine
  15410. * @param rootUrl defines the rootUrl for data loading
  15411. * @returns a new SubEmitter
  15412. */
  15413. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  15414. /** Release associated resources */
  15415. dispose(): void;
  15416. }
  15417. }
  15418. declare module BABYLON {
  15419. /** @hidden */
  15420. export var clipPlaneFragmentDeclaration: {
  15421. name: string;
  15422. shader: string;
  15423. };
  15424. }
  15425. declare module BABYLON {
  15426. /** @hidden */
  15427. export var imageProcessingDeclaration: {
  15428. name: string;
  15429. shader: string;
  15430. };
  15431. }
  15432. declare module BABYLON {
  15433. /** @hidden */
  15434. export var imageProcessingFunctions: {
  15435. name: string;
  15436. shader: string;
  15437. };
  15438. }
  15439. declare module BABYLON {
  15440. /** @hidden */
  15441. export var clipPlaneFragment: {
  15442. name: string;
  15443. shader: string;
  15444. };
  15445. }
  15446. declare module BABYLON {
  15447. /** @hidden */
  15448. export var particlesPixelShader: {
  15449. name: string;
  15450. shader: string;
  15451. };
  15452. }
  15453. declare module BABYLON {
  15454. /** @hidden */
  15455. export var clipPlaneVertexDeclaration: {
  15456. name: string;
  15457. shader: string;
  15458. };
  15459. }
  15460. declare module BABYLON {
  15461. /** @hidden */
  15462. export var clipPlaneVertex: {
  15463. name: string;
  15464. shader: string;
  15465. };
  15466. }
  15467. declare module BABYLON {
  15468. /** @hidden */
  15469. export var particlesVertexShader: {
  15470. name: string;
  15471. shader: string;
  15472. };
  15473. }
  15474. declare module BABYLON {
  15475. /**
  15476. * Interface used to define entities containing multiple clip planes
  15477. */
  15478. export interface IClipPlanesHolder {
  15479. /**
  15480. * Gets or sets the active clipplane 1
  15481. */
  15482. clipPlane: Nullable<Plane>;
  15483. /**
  15484. * Gets or sets the active clipplane 2
  15485. */
  15486. clipPlane2: Nullable<Plane>;
  15487. /**
  15488. * Gets or sets the active clipplane 3
  15489. */
  15490. clipPlane3: Nullable<Plane>;
  15491. /**
  15492. * Gets or sets the active clipplane 4
  15493. */
  15494. clipPlane4: Nullable<Plane>;
  15495. /**
  15496. * Gets or sets the active clipplane 5
  15497. */
  15498. clipPlane5: Nullable<Plane>;
  15499. /**
  15500. * Gets or sets the active clipplane 6
  15501. */
  15502. clipPlane6: Nullable<Plane>;
  15503. }
  15504. }
  15505. declare module BABYLON {
  15506. /**
  15507. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  15508. *
  15509. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  15510. *
  15511. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  15512. */
  15513. export class ThinMaterialHelper {
  15514. /**
  15515. * Binds the clip plane information from the holder to the effect.
  15516. * @param effect The effect we are binding the data to
  15517. * @param holder The entity containing the clip plane information
  15518. */
  15519. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  15520. }
  15521. }
  15522. declare module BABYLON {
  15523. interface ThinEngine {
  15524. /**
  15525. * Sets alpha constants used by some alpha blending modes
  15526. * @param r defines the red component
  15527. * @param g defines the green component
  15528. * @param b defines the blue component
  15529. * @param a defines the alpha component
  15530. */
  15531. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  15532. /**
  15533. * Sets the current alpha mode
  15534. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  15535. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  15536. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15537. */
  15538. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  15539. /**
  15540. * Gets the current alpha mode
  15541. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15542. * @returns the current alpha mode
  15543. */
  15544. getAlphaMode(): number;
  15545. /**
  15546. * Sets the current alpha equation
  15547. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  15548. */
  15549. setAlphaEquation(equation: number): void;
  15550. /**
  15551. * Gets the current alpha equation.
  15552. * @returns the current alpha equation
  15553. */
  15554. getAlphaEquation(): number;
  15555. }
  15556. }
  15557. declare module BABYLON {
  15558. /**
  15559. * This represents a particle system in Babylon.
  15560. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  15561. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15562. * @example https://doc.babylonjs.com/babylon101/particles
  15563. */
  15564. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15565. /**
  15566. * Billboard mode will only apply to Y axis
  15567. */
  15568. static readonly BILLBOARDMODE_Y: number;
  15569. /**
  15570. * Billboard mode will apply to all axes
  15571. */
  15572. static readonly BILLBOARDMODE_ALL: number;
  15573. /**
  15574. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15575. */
  15576. static readonly BILLBOARDMODE_STRETCHED: number;
  15577. /**
  15578. * This function can be defined to provide custom update for active particles.
  15579. * This function will be called instead of regular update (age, position, color, etc.).
  15580. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15581. */
  15582. updateFunction: (particles: Particle[]) => void;
  15583. private _emitterWorldMatrix;
  15584. /**
  15585. * This function can be defined to specify initial direction for every new particle.
  15586. * It by default use the emitterType defined function
  15587. */
  15588. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15589. /**
  15590. * This function can be defined to specify initial position for every new particle.
  15591. * It by default use the emitterType defined function
  15592. */
  15593. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15594. /**
  15595. * @hidden
  15596. */
  15597. _inheritedVelocityOffset: Vector3;
  15598. /**
  15599. * An event triggered when the system is disposed
  15600. */
  15601. onDisposeObservable: Observable<IParticleSystem>;
  15602. /**
  15603. * An event triggered when the system is stopped
  15604. */
  15605. onStoppedObservable: Observable<IParticleSystem>;
  15606. private _onDisposeObserver;
  15607. /**
  15608. * Sets a callback that will be triggered when the system is disposed
  15609. */
  15610. set onDispose(callback: () => void);
  15611. private _particles;
  15612. private _epsilon;
  15613. private _capacity;
  15614. private _stockParticles;
  15615. private _newPartsExcess;
  15616. private _vertexData;
  15617. private _vertexBuffer;
  15618. private _vertexBuffers;
  15619. private _spriteBuffer;
  15620. private _indexBuffer;
  15621. private _effect;
  15622. private _customEffect;
  15623. private _cachedDefines;
  15624. private _scaledColorStep;
  15625. private _colorDiff;
  15626. private _scaledDirection;
  15627. private _scaledGravity;
  15628. private _currentRenderId;
  15629. private _alive;
  15630. private _useInstancing;
  15631. private _vertexArrayObject;
  15632. private _started;
  15633. private _stopped;
  15634. private _actualFrame;
  15635. private _scaledUpdateSpeed;
  15636. private _vertexBufferSize;
  15637. /** @hidden */
  15638. _currentEmitRateGradient: Nullable<FactorGradient>;
  15639. /** @hidden */
  15640. _currentEmitRate1: number;
  15641. /** @hidden */
  15642. _currentEmitRate2: number;
  15643. /** @hidden */
  15644. _currentStartSizeGradient: Nullable<FactorGradient>;
  15645. /** @hidden */
  15646. _currentStartSize1: number;
  15647. /** @hidden */
  15648. _currentStartSize2: number;
  15649. private readonly _rawTextureWidth;
  15650. private _rampGradientsTexture;
  15651. private _useRampGradients;
  15652. /** Gets or sets a matrix to use to compute projection */
  15653. defaultProjectionMatrix: Matrix;
  15654. /** Gets or sets a matrix to use to compute view */
  15655. defaultViewMatrix: Matrix;
  15656. /** Gets or sets a boolean indicating that ramp gradients must be used
  15657. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15658. */
  15659. get useRampGradients(): boolean;
  15660. set useRampGradients(value: boolean);
  15661. /**
  15662. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  15663. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  15664. */
  15665. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15666. private _subEmitters;
  15667. /**
  15668. * @hidden
  15669. * If the particle systems emitter should be disposed when the particle system is disposed
  15670. */
  15671. _disposeEmitterOnDispose: boolean;
  15672. /**
  15673. * The current active Sub-systems, this property is used by the root particle system only.
  15674. */
  15675. activeSubSystems: Array<ParticleSystem>;
  15676. /**
  15677. * Specifies if the particles are updated in emitter local space or world space
  15678. */
  15679. isLocal: boolean;
  15680. private _rootParticleSystem;
  15681. /**
  15682. * Gets the current list of active particles
  15683. */
  15684. get particles(): Particle[];
  15685. /**
  15686. * Gets the number of particles active at the same time.
  15687. * @returns The number of active particles.
  15688. */
  15689. getActiveCount(): number;
  15690. /**
  15691. * Returns the string "ParticleSystem"
  15692. * @returns a string containing the class name
  15693. */
  15694. getClassName(): string;
  15695. /**
  15696. * Gets a boolean indicating that the system is stopping
  15697. * @returns true if the system is currently stopping
  15698. */
  15699. isStopping(): boolean;
  15700. /**
  15701. * Gets the custom effect used to render the particles
  15702. * @param blendMode Blend mode for which the effect should be retrieved
  15703. * @returns The effect
  15704. */
  15705. getCustomEffect(blendMode?: number): Nullable<Effect>;
  15706. /**
  15707. * Sets the custom effect used to render the particles
  15708. * @param effect The effect to set
  15709. * @param blendMode Blend mode for which the effect should be set
  15710. */
  15711. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  15712. /** @hidden */
  15713. private _onBeforeDrawParticlesObservable;
  15714. /**
  15715. * Observable that will be called just before the particles are drawn
  15716. */
  15717. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  15718. /**
  15719. * Gets the name of the particle vertex shader
  15720. */
  15721. get vertexShaderName(): string;
  15722. /**
  15723. * Instantiates a particle system.
  15724. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  15725. * @param name The name of the particle system
  15726. * @param capacity The max number of particles alive at the same time
  15727. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  15728. * @param customEffect a custom effect used to change the way particles are rendered by default
  15729. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15730. * @param epsilon Offset used to render the particles
  15731. */
  15732. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15733. private _addFactorGradient;
  15734. private _removeFactorGradient;
  15735. /**
  15736. * Adds a new life time gradient
  15737. * @param gradient defines the gradient to use (between 0 and 1)
  15738. * @param factor defines the life time factor to affect to the specified gradient
  15739. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15740. * @returns the current particle system
  15741. */
  15742. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15743. /**
  15744. * Remove a specific life time gradient
  15745. * @param gradient defines the gradient to remove
  15746. * @returns the current particle system
  15747. */
  15748. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15749. /**
  15750. * Adds a new size gradient
  15751. * @param gradient defines the gradient to use (between 0 and 1)
  15752. * @param factor defines the size factor to affect to the specified gradient
  15753. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15754. * @returns the current particle system
  15755. */
  15756. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15757. /**
  15758. * Remove a specific size gradient
  15759. * @param gradient defines the gradient to remove
  15760. * @returns the current particle system
  15761. */
  15762. removeSizeGradient(gradient: number): IParticleSystem;
  15763. /**
  15764. * Adds a new color remap gradient
  15765. * @param gradient defines the gradient to use (between 0 and 1)
  15766. * @param min defines the color remap minimal range
  15767. * @param max defines the color remap maximal range
  15768. * @returns the current particle system
  15769. */
  15770. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15771. /**
  15772. * Remove a specific color remap gradient
  15773. * @param gradient defines the gradient to remove
  15774. * @returns the current particle system
  15775. */
  15776. removeColorRemapGradient(gradient: number): IParticleSystem;
  15777. /**
  15778. * Adds a new alpha remap gradient
  15779. * @param gradient defines the gradient to use (between 0 and 1)
  15780. * @param min defines the alpha remap minimal range
  15781. * @param max defines the alpha remap maximal range
  15782. * @returns the current particle system
  15783. */
  15784. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15785. /**
  15786. * Remove a specific alpha remap gradient
  15787. * @param gradient defines the gradient to remove
  15788. * @returns the current particle system
  15789. */
  15790. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15791. /**
  15792. * Adds a new angular speed gradient
  15793. * @param gradient defines the gradient to use (between 0 and 1)
  15794. * @param factor defines the angular speed to affect to the specified gradient
  15795. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15796. * @returns the current particle system
  15797. */
  15798. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15799. /**
  15800. * Remove a specific angular speed gradient
  15801. * @param gradient defines the gradient to remove
  15802. * @returns the current particle system
  15803. */
  15804. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15805. /**
  15806. * Adds a new velocity gradient
  15807. * @param gradient defines the gradient to use (between 0 and 1)
  15808. * @param factor defines the velocity to affect to the specified gradient
  15809. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15810. * @returns the current particle system
  15811. */
  15812. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15813. /**
  15814. * Remove a specific velocity gradient
  15815. * @param gradient defines the gradient to remove
  15816. * @returns the current particle system
  15817. */
  15818. removeVelocityGradient(gradient: number): IParticleSystem;
  15819. /**
  15820. * Adds a new limit velocity gradient
  15821. * @param gradient defines the gradient to use (between 0 and 1)
  15822. * @param factor defines the limit velocity value to affect to the specified gradient
  15823. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15824. * @returns the current particle system
  15825. */
  15826. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15827. /**
  15828. * Remove a specific limit velocity gradient
  15829. * @param gradient defines the gradient to remove
  15830. * @returns the current particle system
  15831. */
  15832. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15833. /**
  15834. * Adds a new drag gradient
  15835. * @param gradient defines the gradient to use (between 0 and 1)
  15836. * @param factor defines the drag value to affect to the specified gradient
  15837. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15838. * @returns the current particle system
  15839. */
  15840. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15841. /**
  15842. * Remove a specific drag gradient
  15843. * @param gradient defines the gradient to remove
  15844. * @returns the current particle system
  15845. */
  15846. removeDragGradient(gradient: number): IParticleSystem;
  15847. /**
  15848. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15849. * @param gradient defines the gradient to use (between 0 and 1)
  15850. * @param factor defines the emit rate value to affect to the specified gradient
  15851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15852. * @returns the current particle system
  15853. */
  15854. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15855. /**
  15856. * Remove a specific emit rate gradient
  15857. * @param gradient defines the gradient to remove
  15858. * @returns the current particle system
  15859. */
  15860. removeEmitRateGradient(gradient: number): IParticleSystem;
  15861. /**
  15862. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15863. * @param gradient defines the gradient to use (between 0 and 1)
  15864. * @param factor defines the start size value to affect to the specified gradient
  15865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15866. * @returns the current particle system
  15867. */
  15868. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15869. /**
  15870. * Remove a specific start size gradient
  15871. * @param gradient defines the gradient to remove
  15872. * @returns the current particle system
  15873. */
  15874. removeStartSizeGradient(gradient: number): IParticleSystem;
  15875. private _createRampGradientTexture;
  15876. /**
  15877. * Gets the current list of ramp gradients.
  15878. * You must use addRampGradient and removeRampGradient to udpate this list
  15879. * @returns the list of ramp gradients
  15880. */
  15881. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15882. /** Force the system to rebuild all gradients that need to be resync */
  15883. forceRefreshGradients(): void;
  15884. private _syncRampGradientTexture;
  15885. /**
  15886. * Adds a new ramp gradient used to remap particle colors
  15887. * @param gradient defines the gradient to use (between 0 and 1)
  15888. * @param color defines the color to affect to the specified gradient
  15889. * @returns the current particle system
  15890. */
  15891. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15892. /**
  15893. * Remove a specific ramp gradient
  15894. * @param gradient defines the gradient to remove
  15895. * @returns the current particle system
  15896. */
  15897. removeRampGradient(gradient: number): ParticleSystem;
  15898. /**
  15899. * Adds a new color gradient
  15900. * @param gradient defines the gradient to use (between 0 and 1)
  15901. * @param color1 defines the color to affect to the specified gradient
  15902. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15903. * @returns this particle system
  15904. */
  15905. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15906. /**
  15907. * Remove a specific color gradient
  15908. * @param gradient defines the gradient to remove
  15909. * @returns this particle system
  15910. */
  15911. removeColorGradient(gradient: number): IParticleSystem;
  15912. private _fetchR;
  15913. protected _reset(): void;
  15914. private _resetEffect;
  15915. private _createVertexBuffers;
  15916. private _createIndexBuffer;
  15917. /**
  15918. * Gets the maximum number of particles active at the same time.
  15919. * @returns The max number of active particles.
  15920. */
  15921. getCapacity(): number;
  15922. /**
  15923. * Gets whether there are still active particles in the system.
  15924. * @returns True if it is alive, otherwise false.
  15925. */
  15926. isAlive(): boolean;
  15927. /**
  15928. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15929. * @returns True if it has been started, otherwise false.
  15930. */
  15931. isStarted(): boolean;
  15932. private _prepareSubEmitterInternalArray;
  15933. /**
  15934. * Starts the particle system and begins to emit
  15935. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15936. */
  15937. start(delay?: number): void;
  15938. /**
  15939. * Stops the particle system.
  15940. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  15941. */
  15942. stop(stopSubEmitters?: boolean): void;
  15943. /**
  15944. * Remove all active particles
  15945. */
  15946. reset(): void;
  15947. /**
  15948. * @hidden (for internal use only)
  15949. */
  15950. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15951. /**
  15952. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15953. * Its lifetime will start back at 0.
  15954. */
  15955. recycleParticle: (particle: Particle) => void;
  15956. private _stopSubEmitters;
  15957. private _createParticle;
  15958. private _removeFromRoot;
  15959. private _emitFromParticle;
  15960. private _update;
  15961. /** @hidden */
  15962. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15963. /** @hidden */
  15964. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15965. /**
  15966. * Fill the defines array according to the current settings of the particle system
  15967. * @param defines Array to be updated
  15968. * @param blendMode blend mode to take into account when updating the array
  15969. */
  15970. fillDefines(defines: Array<string>, blendMode: number): void;
  15971. /**
  15972. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  15973. * @param uniforms Uniforms array to fill
  15974. * @param attributes Attributes array to fill
  15975. * @param samplers Samplers array to fill
  15976. */
  15977. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  15978. /** @hidden */
  15979. private _getEffect;
  15980. /**
  15981. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15982. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15983. */
  15984. animate(preWarmOnly?: boolean): void;
  15985. private _appendParticleVertices;
  15986. /**
  15987. * Rebuilds the particle system.
  15988. */
  15989. rebuild(): void;
  15990. /**
  15991. * Is this system ready to be used/rendered
  15992. * @return true if the system is ready
  15993. */
  15994. isReady(): boolean;
  15995. private _render;
  15996. /**
  15997. * Renders the particle system in its current state.
  15998. * @returns the current number of particles
  15999. */
  16000. render(): number;
  16001. /**
  16002. * Disposes the particle system and free the associated resources
  16003. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16004. */
  16005. dispose(disposeTexture?: boolean): void;
  16006. /**
  16007. * Clones the particle system.
  16008. * @param name The name of the cloned object
  16009. * @param newEmitter The new emitter to use
  16010. * @returns the cloned particle system
  16011. */
  16012. clone(name: string, newEmitter: any): ParticleSystem;
  16013. /**
  16014. * Serializes the particle system to a JSON object
  16015. * @param serializeTexture defines if the texture must be serialized as well
  16016. * @returns the JSON object
  16017. */
  16018. serialize(serializeTexture?: boolean): any;
  16019. /** @hidden */
  16020. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  16021. /** @hidden */
  16022. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  16023. /**
  16024. * Parses a JSON object to create a particle system.
  16025. * @param parsedParticleSystem The JSON object to parse
  16026. * @param sceneOrEngine The scene or the engine to create the particle system in
  16027. * @param rootUrl The root url to use to load external dependencies like texture
  16028. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  16029. * @returns the Parsed particle system
  16030. */
  16031. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  16032. }
  16033. }
  16034. declare module BABYLON {
  16035. /**
  16036. * A particle represents one of the element emitted by a particle system.
  16037. * This is mainly define by its coordinates, direction, velocity and age.
  16038. */
  16039. export class Particle {
  16040. /**
  16041. * The particle system the particle belongs to.
  16042. */
  16043. particleSystem: ParticleSystem;
  16044. private static _Count;
  16045. /**
  16046. * Unique ID of the particle
  16047. */
  16048. id: number;
  16049. /**
  16050. * The world position of the particle in the scene.
  16051. */
  16052. position: Vector3;
  16053. /**
  16054. * The world direction of the particle in the scene.
  16055. */
  16056. direction: Vector3;
  16057. /**
  16058. * The color of the particle.
  16059. */
  16060. color: Color4;
  16061. /**
  16062. * The color change of the particle per step.
  16063. */
  16064. colorStep: Color4;
  16065. /**
  16066. * Defines how long will the life of the particle be.
  16067. */
  16068. lifeTime: number;
  16069. /**
  16070. * The current age of the particle.
  16071. */
  16072. age: number;
  16073. /**
  16074. * The current size of the particle.
  16075. */
  16076. size: number;
  16077. /**
  16078. * The current scale of the particle.
  16079. */
  16080. scale: Vector2;
  16081. /**
  16082. * The current angle of the particle.
  16083. */
  16084. angle: number;
  16085. /**
  16086. * Defines how fast is the angle changing.
  16087. */
  16088. angularSpeed: number;
  16089. /**
  16090. * Defines the cell index used by the particle to be rendered from a sprite.
  16091. */
  16092. cellIndex: number;
  16093. /**
  16094. * The information required to support color remapping
  16095. */
  16096. remapData: Vector4;
  16097. /** @hidden */
  16098. _randomCellOffset?: number;
  16099. /** @hidden */
  16100. _initialDirection: Nullable<Vector3>;
  16101. /** @hidden */
  16102. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  16103. /** @hidden */
  16104. _initialStartSpriteCellID: number;
  16105. /** @hidden */
  16106. _initialEndSpriteCellID: number;
  16107. /** @hidden */
  16108. _currentColorGradient: Nullable<ColorGradient>;
  16109. /** @hidden */
  16110. _currentColor1: Color4;
  16111. /** @hidden */
  16112. _currentColor2: Color4;
  16113. /** @hidden */
  16114. _currentSizeGradient: Nullable<FactorGradient>;
  16115. /** @hidden */
  16116. _currentSize1: number;
  16117. /** @hidden */
  16118. _currentSize2: number;
  16119. /** @hidden */
  16120. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  16121. /** @hidden */
  16122. _currentAngularSpeed1: number;
  16123. /** @hidden */
  16124. _currentAngularSpeed2: number;
  16125. /** @hidden */
  16126. _currentVelocityGradient: Nullable<FactorGradient>;
  16127. /** @hidden */
  16128. _currentVelocity1: number;
  16129. /** @hidden */
  16130. _currentVelocity2: number;
  16131. /** @hidden */
  16132. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  16133. /** @hidden */
  16134. _currentLimitVelocity1: number;
  16135. /** @hidden */
  16136. _currentLimitVelocity2: number;
  16137. /** @hidden */
  16138. _currentDragGradient: Nullable<FactorGradient>;
  16139. /** @hidden */
  16140. _currentDrag1: number;
  16141. /** @hidden */
  16142. _currentDrag2: number;
  16143. /** @hidden */
  16144. _randomNoiseCoordinates1: Vector3;
  16145. /** @hidden */
  16146. _randomNoiseCoordinates2: Vector3;
  16147. /** @hidden */
  16148. _localPosition?: Vector3;
  16149. /**
  16150. * Creates a new instance Particle
  16151. * @param particleSystem the particle system the particle belongs to
  16152. */
  16153. constructor(
  16154. /**
  16155. * The particle system the particle belongs to.
  16156. */
  16157. particleSystem: ParticleSystem);
  16158. private updateCellInfoFromSystem;
  16159. /**
  16160. * Defines how the sprite cell index is updated for the particle
  16161. */
  16162. updateCellIndex(): void;
  16163. /** @hidden */
  16164. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  16165. /** @hidden */
  16166. _inheritParticleInfoToSubEmitters(): void;
  16167. /** @hidden */
  16168. _reset(): void;
  16169. /**
  16170. * Copy the properties of particle to another one.
  16171. * @param other the particle to copy the information to.
  16172. */
  16173. copyTo(other: Particle): void;
  16174. }
  16175. }
  16176. declare module BABYLON {
  16177. /**
  16178. * Particle emitter represents a volume emitting particles.
  16179. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  16180. */
  16181. export interface IParticleEmitterType {
  16182. /**
  16183. * Called by the particle System when the direction is computed for the created particle.
  16184. * @param worldMatrix is the world matrix of the particle system
  16185. * @param directionToUpdate is the direction vector to update with the result
  16186. * @param particle is the particle we are computed the direction for
  16187. * @param isLocal defines if the direction should be set in local space
  16188. */
  16189. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16190. /**
  16191. * Called by the particle System when the position is computed for the created particle.
  16192. * @param worldMatrix is the world matrix of the particle system
  16193. * @param positionToUpdate is the position vector to update with the result
  16194. * @param particle is the particle we are computed the position for
  16195. * @param isLocal defines if the position should be set in local space
  16196. */
  16197. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16198. /**
  16199. * Clones the current emitter and returns a copy of it
  16200. * @returns the new emitter
  16201. */
  16202. clone(): IParticleEmitterType;
  16203. /**
  16204. * Called by the GPUParticleSystem to setup the update shader
  16205. * @param effect defines the update shader
  16206. */
  16207. applyToShader(effect: Effect): void;
  16208. /**
  16209. * Returns a string to use to update the GPU particles update shader
  16210. * @returns the effect defines string
  16211. */
  16212. getEffectDefines(): string;
  16213. /**
  16214. * Returns a string representing the class name
  16215. * @returns a string containing the class name
  16216. */
  16217. getClassName(): string;
  16218. /**
  16219. * Serializes the particle system to a JSON object.
  16220. * @returns the JSON object
  16221. */
  16222. serialize(): any;
  16223. /**
  16224. * Parse properties from a JSON object
  16225. * @param serializationObject defines the JSON object
  16226. * @param scene defines the hosting scene
  16227. */
  16228. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16229. }
  16230. }
  16231. declare module BABYLON {
  16232. /**
  16233. * Particle emitter emitting particles from the inside of a box.
  16234. * It emits the particles randomly between 2 given directions.
  16235. */
  16236. export class BoxParticleEmitter implements IParticleEmitterType {
  16237. /**
  16238. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16239. */
  16240. direction1: Vector3;
  16241. /**
  16242. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16243. */
  16244. direction2: Vector3;
  16245. /**
  16246. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  16247. */
  16248. minEmitBox: Vector3;
  16249. /**
  16250. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  16251. */
  16252. maxEmitBox: Vector3;
  16253. /**
  16254. * Creates a new instance BoxParticleEmitter
  16255. */
  16256. constructor();
  16257. /**
  16258. * Called by the particle System when the direction is computed for the created particle.
  16259. * @param worldMatrix is the world matrix of the particle system
  16260. * @param directionToUpdate is the direction vector to update with the result
  16261. * @param particle is the particle we are computed the direction for
  16262. * @param isLocal defines if the direction should be set in local space
  16263. */
  16264. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16265. /**
  16266. * Called by the particle System when the position is computed for the created particle.
  16267. * @param worldMatrix is the world matrix of the particle system
  16268. * @param positionToUpdate is the position vector to update with the result
  16269. * @param particle is the particle we are computed the position for
  16270. * @param isLocal defines if the position should be set in local space
  16271. */
  16272. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16273. /**
  16274. * Clones the current emitter and returns a copy of it
  16275. * @returns the new emitter
  16276. */
  16277. clone(): BoxParticleEmitter;
  16278. /**
  16279. * Called by the GPUParticleSystem to setup the update shader
  16280. * @param effect defines the update shader
  16281. */
  16282. applyToShader(effect: Effect): void;
  16283. /**
  16284. * Returns a string to use to update the GPU particles update shader
  16285. * @returns a string containng the defines string
  16286. */
  16287. getEffectDefines(): string;
  16288. /**
  16289. * Returns the string "BoxParticleEmitter"
  16290. * @returns a string containing the class name
  16291. */
  16292. getClassName(): string;
  16293. /**
  16294. * Serializes the particle system to a JSON object.
  16295. * @returns the JSON object
  16296. */
  16297. serialize(): any;
  16298. /**
  16299. * Parse properties from a JSON object
  16300. * @param serializationObject defines the JSON object
  16301. */
  16302. parse(serializationObject: any): void;
  16303. }
  16304. }
  16305. declare module BABYLON {
  16306. /**
  16307. * Particle emitter emitting particles from the inside of a cone.
  16308. * It emits the particles alongside the cone volume from the base to the particle.
  16309. * The emission direction might be randomized.
  16310. */
  16311. export class ConeParticleEmitter implements IParticleEmitterType {
  16312. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16313. directionRandomizer: number;
  16314. private _radius;
  16315. private _angle;
  16316. private _height;
  16317. /**
  16318. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16319. */
  16320. radiusRange: number;
  16321. /**
  16322. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16323. */
  16324. heightRange: number;
  16325. /**
  16326. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16327. */
  16328. emitFromSpawnPointOnly: boolean;
  16329. /**
  16330. * Gets or sets the radius of the emission cone
  16331. */
  16332. get radius(): number;
  16333. set radius(value: number);
  16334. /**
  16335. * Gets or sets the angle of the emission cone
  16336. */
  16337. get angle(): number;
  16338. set angle(value: number);
  16339. private _buildHeight;
  16340. /**
  16341. * Creates a new instance ConeParticleEmitter
  16342. * @param radius the radius of the emission cone (1 by default)
  16343. * @param angle the cone base angle (PI by default)
  16344. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16345. */
  16346. constructor(radius?: number, angle?: number,
  16347. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16348. directionRandomizer?: number);
  16349. /**
  16350. * Called by the particle System when the direction is computed for the created particle.
  16351. * @param worldMatrix is the world matrix of the particle system
  16352. * @param directionToUpdate is the direction vector to update with the result
  16353. * @param particle is the particle we are computed the direction for
  16354. * @param isLocal defines if the direction should be set in local space
  16355. */
  16356. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16357. /**
  16358. * Called by the particle System when the position is computed for the created particle.
  16359. * @param worldMatrix is the world matrix of the particle system
  16360. * @param positionToUpdate is the position vector to update with the result
  16361. * @param particle is the particle we are computed the position for
  16362. * @param isLocal defines if the position should be set in local space
  16363. */
  16364. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16365. /**
  16366. * Clones the current emitter and returns a copy of it
  16367. * @returns the new emitter
  16368. */
  16369. clone(): ConeParticleEmitter;
  16370. /**
  16371. * Called by the GPUParticleSystem to setup the update shader
  16372. * @param effect defines the update shader
  16373. */
  16374. applyToShader(effect: Effect): void;
  16375. /**
  16376. * Returns a string to use to update the GPU particles update shader
  16377. * @returns a string containng the defines string
  16378. */
  16379. getEffectDefines(): string;
  16380. /**
  16381. * Returns the string "ConeParticleEmitter"
  16382. * @returns a string containing the class name
  16383. */
  16384. getClassName(): string;
  16385. /**
  16386. * Serializes the particle system to a JSON object.
  16387. * @returns the JSON object
  16388. */
  16389. serialize(): any;
  16390. /**
  16391. * Parse properties from a JSON object
  16392. * @param serializationObject defines the JSON object
  16393. */
  16394. parse(serializationObject: any): void;
  16395. }
  16396. }
  16397. declare module BABYLON {
  16398. /**
  16399. * Particle emitter emitting particles from the inside of a cylinder.
  16400. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16401. */
  16402. export class CylinderParticleEmitter implements IParticleEmitterType {
  16403. /**
  16404. * The radius of the emission cylinder.
  16405. */
  16406. radius: number;
  16407. /**
  16408. * The height of the emission cylinder.
  16409. */
  16410. height: number;
  16411. /**
  16412. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16413. */
  16414. radiusRange: number;
  16415. /**
  16416. * How much to randomize the particle direction [0-1].
  16417. */
  16418. directionRandomizer: number;
  16419. /**
  16420. * Creates a new instance CylinderParticleEmitter
  16421. * @param radius the radius of the emission cylinder (1 by default)
  16422. * @param height the height of the emission cylinder (1 by default)
  16423. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16424. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16425. */
  16426. constructor(
  16427. /**
  16428. * The radius of the emission cylinder.
  16429. */
  16430. radius?: number,
  16431. /**
  16432. * The height of the emission cylinder.
  16433. */
  16434. height?: number,
  16435. /**
  16436. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16437. */
  16438. radiusRange?: number,
  16439. /**
  16440. * How much to randomize the particle direction [0-1].
  16441. */
  16442. directionRandomizer?: number);
  16443. /**
  16444. * Called by the particle System when the direction is computed for the created particle.
  16445. * @param worldMatrix is the world matrix of the particle system
  16446. * @param directionToUpdate is the direction vector to update with the result
  16447. * @param particle is the particle we are computed the direction for
  16448. * @param isLocal defines if the direction should be set in local space
  16449. */
  16450. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16451. /**
  16452. * Called by the particle System when the position is computed for the created particle.
  16453. * @param worldMatrix is the world matrix of the particle system
  16454. * @param positionToUpdate is the position vector to update with the result
  16455. * @param particle is the particle we are computed the position for
  16456. * @param isLocal defines if the position should be set in local space
  16457. */
  16458. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16459. /**
  16460. * Clones the current emitter and returns a copy of it
  16461. * @returns the new emitter
  16462. */
  16463. clone(): CylinderParticleEmitter;
  16464. /**
  16465. * Called by the GPUParticleSystem to setup the update shader
  16466. * @param effect defines the update shader
  16467. */
  16468. applyToShader(effect: Effect): void;
  16469. /**
  16470. * Returns a string to use to update the GPU particles update shader
  16471. * @returns a string containng the defines string
  16472. */
  16473. getEffectDefines(): string;
  16474. /**
  16475. * Returns the string "CylinderParticleEmitter"
  16476. * @returns a string containing the class name
  16477. */
  16478. getClassName(): string;
  16479. /**
  16480. * Serializes the particle system to a JSON object.
  16481. * @returns the JSON object
  16482. */
  16483. serialize(): any;
  16484. /**
  16485. * Parse properties from a JSON object
  16486. * @param serializationObject defines the JSON object
  16487. */
  16488. parse(serializationObject: any): void;
  16489. }
  16490. /**
  16491. * Particle emitter emitting particles from the inside of a cylinder.
  16492. * It emits the particles randomly between two vectors.
  16493. */
  16494. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16495. /**
  16496. * The min limit of the emission direction.
  16497. */
  16498. direction1: Vector3;
  16499. /**
  16500. * The max limit of the emission direction.
  16501. */
  16502. direction2: Vector3;
  16503. /**
  16504. * Creates a new instance CylinderDirectedParticleEmitter
  16505. * @param radius the radius of the emission cylinder (1 by default)
  16506. * @param height the height of the emission cylinder (1 by default)
  16507. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16508. * @param direction1 the min limit of the emission direction (up vector by default)
  16509. * @param direction2 the max limit of the emission direction (up vector by default)
  16510. */
  16511. constructor(radius?: number, height?: number, radiusRange?: number,
  16512. /**
  16513. * The min limit of the emission direction.
  16514. */
  16515. direction1?: Vector3,
  16516. /**
  16517. * The max limit of the emission direction.
  16518. */
  16519. direction2?: Vector3);
  16520. /**
  16521. * Called by the particle System when the direction is computed for the created particle.
  16522. * @param worldMatrix is the world matrix of the particle system
  16523. * @param directionToUpdate is the direction vector to update with the result
  16524. * @param particle is the particle we are computed the direction for
  16525. */
  16526. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16527. /**
  16528. * Clones the current emitter and returns a copy of it
  16529. * @returns the new emitter
  16530. */
  16531. clone(): CylinderDirectedParticleEmitter;
  16532. /**
  16533. * Called by the GPUParticleSystem to setup the update shader
  16534. * @param effect defines the update shader
  16535. */
  16536. applyToShader(effect: Effect): void;
  16537. /**
  16538. * Returns a string to use to update the GPU particles update shader
  16539. * @returns a string containng the defines string
  16540. */
  16541. getEffectDefines(): string;
  16542. /**
  16543. * Returns the string "CylinderDirectedParticleEmitter"
  16544. * @returns a string containing the class name
  16545. */
  16546. getClassName(): string;
  16547. /**
  16548. * Serializes the particle system to a JSON object.
  16549. * @returns the JSON object
  16550. */
  16551. serialize(): any;
  16552. /**
  16553. * Parse properties from a JSON object
  16554. * @param serializationObject defines the JSON object
  16555. */
  16556. parse(serializationObject: any): void;
  16557. }
  16558. }
  16559. declare module BABYLON {
  16560. /**
  16561. * Particle emitter emitting particles from the inside of a hemisphere.
  16562. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16563. */
  16564. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16565. /**
  16566. * The radius of the emission hemisphere.
  16567. */
  16568. radius: number;
  16569. /**
  16570. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16571. */
  16572. radiusRange: number;
  16573. /**
  16574. * How much to randomize the particle direction [0-1].
  16575. */
  16576. directionRandomizer: number;
  16577. /**
  16578. * Creates a new instance HemisphericParticleEmitter
  16579. * @param radius the radius of the emission hemisphere (1 by default)
  16580. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16581. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16582. */
  16583. constructor(
  16584. /**
  16585. * The radius of the emission hemisphere.
  16586. */
  16587. radius?: number,
  16588. /**
  16589. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16590. */
  16591. radiusRange?: number,
  16592. /**
  16593. * How much to randomize the particle direction [0-1].
  16594. */
  16595. directionRandomizer?: number);
  16596. /**
  16597. * Called by the particle System when the direction is computed for the created particle.
  16598. * @param worldMatrix is the world matrix of the particle system
  16599. * @param directionToUpdate is the direction vector to update with the result
  16600. * @param particle is the particle we are computed the direction for
  16601. * @param isLocal defines if the direction should be set in local space
  16602. */
  16603. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16604. /**
  16605. * Called by the particle System when the position is computed for the created particle.
  16606. * @param worldMatrix is the world matrix of the particle system
  16607. * @param positionToUpdate is the position vector to update with the result
  16608. * @param particle is the particle we are computed the position for
  16609. * @param isLocal defines if the position should be set in local space
  16610. */
  16611. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16612. /**
  16613. * Clones the current emitter and returns a copy of it
  16614. * @returns the new emitter
  16615. */
  16616. clone(): HemisphericParticleEmitter;
  16617. /**
  16618. * Called by the GPUParticleSystem to setup the update shader
  16619. * @param effect defines the update shader
  16620. */
  16621. applyToShader(effect: Effect): void;
  16622. /**
  16623. * Returns a string to use to update the GPU particles update shader
  16624. * @returns a string containng the defines string
  16625. */
  16626. getEffectDefines(): string;
  16627. /**
  16628. * Returns the string "HemisphericParticleEmitter"
  16629. * @returns a string containing the class name
  16630. */
  16631. getClassName(): string;
  16632. /**
  16633. * Serializes the particle system to a JSON object.
  16634. * @returns the JSON object
  16635. */
  16636. serialize(): any;
  16637. /**
  16638. * Parse properties from a JSON object
  16639. * @param serializationObject defines the JSON object
  16640. */
  16641. parse(serializationObject: any): void;
  16642. }
  16643. }
  16644. declare module BABYLON {
  16645. /**
  16646. * Particle emitter emitting particles from a point.
  16647. * It emits the particles randomly between 2 given directions.
  16648. */
  16649. export class PointParticleEmitter implements IParticleEmitterType {
  16650. /**
  16651. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16652. */
  16653. direction1: Vector3;
  16654. /**
  16655. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16656. */
  16657. direction2: Vector3;
  16658. /**
  16659. * Creates a new instance PointParticleEmitter
  16660. */
  16661. constructor();
  16662. /**
  16663. * Called by the particle System when the direction is computed for the created particle.
  16664. * @param worldMatrix is the world matrix of the particle system
  16665. * @param directionToUpdate is the direction vector to update with the result
  16666. * @param particle is the particle we are computed the direction for
  16667. * @param isLocal defines if the direction should be set in local space
  16668. */
  16669. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16670. /**
  16671. * Called by the particle System when the position is computed for the created particle.
  16672. * @param worldMatrix is the world matrix of the particle system
  16673. * @param positionToUpdate is the position vector to update with the result
  16674. * @param particle is the particle we are computed the position for
  16675. * @param isLocal defines if the position should be set in local space
  16676. */
  16677. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16678. /**
  16679. * Clones the current emitter and returns a copy of it
  16680. * @returns the new emitter
  16681. */
  16682. clone(): PointParticleEmitter;
  16683. /**
  16684. * Called by the GPUParticleSystem to setup the update shader
  16685. * @param effect defines the update shader
  16686. */
  16687. applyToShader(effect: Effect): void;
  16688. /**
  16689. * Returns a string to use to update the GPU particles update shader
  16690. * @returns a string containng the defines string
  16691. */
  16692. getEffectDefines(): string;
  16693. /**
  16694. * Returns the string "PointParticleEmitter"
  16695. * @returns a string containing the class name
  16696. */
  16697. getClassName(): string;
  16698. /**
  16699. * Serializes the particle system to a JSON object.
  16700. * @returns the JSON object
  16701. */
  16702. serialize(): any;
  16703. /**
  16704. * Parse properties from a JSON object
  16705. * @param serializationObject defines the JSON object
  16706. */
  16707. parse(serializationObject: any): void;
  16708. }
  16709. }
  16710. declare module BABYLON {
  16711. /**
  16712. * Particle emitter emitting particles from the inside of a sphere.
  16713. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16714. */
  16715. export class SphereParticleEmitter implements IParticleEmitterType {
  16716. /**
  16717. * The radius of the emission sphere.
  16718. */
  16719. radius: number;
  16720. /**
  16721. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16722. */
  16723. radiusRange: number;
  16724. /**
  16725. * How much to randomize the particle direction [0-1].
  16726. */
  16727. directionRandomizer: number;
  16728. /**
  16729. * Creates a new instance SphereParticleEmitter
  16730. * @param radius the radius of the emission sphere (1 by default)
  16731. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16732. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16733. */
  16734. constructor(
  16735. /**
  16736. * The radius of the emission sphere.
  16737. */
  16738. radius?: number,
  16739. /**
  16740. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16741. */
  16742. radiusRange?: number,
  16743. /**
  16744. * How much to randomize the particle direction [0-1].
  16745. */
  16746. directionRandomizer?: number);
  16747. /**
  16748. * Called by the particle System when the direction is computed for the created particle.
  16749. * @param worldMatrix is the world matrix of the particle system
  16750. * @param directionToUpdate is the direction vector to update with the result
  16751. * @param particle is the particle we are computed the direction for
  16752. * @param isLocal defines if the direction should be set in local space
  16753. */
  16754. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16755. /**
  16756. * Called by the particle System when the position is computed for the created particle.
  16757. * @param worldMatrix is the world matrix of the particle system
  16758. * @param positionToUpdate is the position vector to update with the result
  16759. * @param particle is the particle we are computed the position for
  16760. * @param isLocal defines if the position should be set in local space
  16761. */
  16762. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16763. /**
  16764. * Clones the current emitter and returns a copy of it
  16765. * @returns the new emitter
  16766. */
  16767. clone(): SphereParticleEmitter;
  16768. /**
  16769. * Called by the GPUParticleSystem to setup the update shader
  16770. * @param effect defines the update shader
  16771. */
  16772. applyToShader(effect: Effect): void;
  16773. /**
  16774. * Returns a string to use to update the GPU particles update shader
  16775. * @returns a string containng the defines string
  16776. */
  16777. getEffectDefines(): string;
  16778. /**
  16779. * Returns the string "SphereParticleEmitter"
  16780. * @returns a string containing the class name
  16781. */
  16782. getClassName(): string;
  16783. /**
  16784. * Serializes the particle system to a JSON object.
  16785. * @returns the JSON object
  16786. */
  16787. serialize(): any;
  16788. /**
  16789. * Parse properties from a JSON object
  16790. * @param serializationObject defines the JSON object
  16791. */
  16792. parse(serializationObject: any): void;
  16793. }
  16794. /**
  16795. * Particle emitter emitting particles from the inside of a sphere.
  16796. * It emits the particles randomly between two vectors.
  16797. */
  16798. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16799. /**
  16800. * The min limit of the emission direction.
  16801. */
  16802. direction1: Vector3;
  16803. /**
  16804. * The max limit of the emission direction.
  16805. */
  16806. direction2: Vector3;
  16807. /**
  16808. * Creates a new instance SphereDirectedParticleEmitter
  16809. * @param radius the radius of the emission sphere (1 by default)
  16810. * @param direction1 the min limit of the emission direction (up vector by default)
  16811. * @param direction2 the max limit of the emission direction (up vector by default)
  16812. */
  16813. constructor(radius?: number,
  16814. /**
  16815. * The min limit of the emission direction.
  16816. */
  16817. direction1?: Vector3,
  16818. /**
  16819. * The max limit of the emission direction.
  16820. */
  16821. direction2?: Vector3);
  16822. /**
  16823. * Called by the particle System when the direction is computed for the created particle.
  16824. * @param worldMatrix is the world matrix of the particle system
  16825. * @param directionToUpdate is the direction vector to update with the result
  16826. * @param particle is the particle we are computed the direction for
  16827. */
  16828. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16829. /**
  16830. * Clones the current emitter and returns a copy of it
  16831. * @returns the new emitter
  16832. */
  16833. clone(): SphereDirectedParticleEmitter;
  16834. /**
  16835. * Called by the GPUParticleSystem to setup the update shader
  16836. * @param effect defines the update shader
  16837. */
  16838. applyToShader(effect: Effect): void;
  16839. /**
  16840. * Returns a string to use to update the GPU particles update shader
  16841. * @returns a string containng the defines string
  16842. */
  16843. getEffectDefines(): string;
  16844. /**
  16845. * Returns the string "SphereDirectedParticleEmitter"
  16846. * @returns a string containing the class name
  16847. */
  16848. getClassName(): string;
  16849. /**
  16850. * Serializes the particle system to a JSON object.
  16851. * @returns the JSON object
  16852. */
  16853. serialize(): any;
  16854. /**
  16855. * Parse properties from a JSON object
  16856. * @param serializationObject defines the JSON object
  16857. */
  16858. parse(serializationObject: any): void;
  16859. }
  16860. }
  16861. declare module BABYLON {
  16862. /**
  16863. * Particle emitter emitting particles from a custom list of positions.
  16864. */
  16865. export class CustomParticleEmitter implements IParticleEmitterType {
  16866. /**
  16867. * Gets or sets the position generator that will create the inital position of each particle.
  16868. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16869. */
  16870. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  16871. /**
  16872. * Gets or sets the destination generator that will create the final destination of each particle.
  16873. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16874. */
  16875. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  16876. /**
  16877. * Creates a new instance CustomParticleEmitter
  16878. */
  16879. constructor();
  16880. /**
  16881. * Called by the particle System when the direction is computed for the created particle.
  16882. * @param worldMatrix is the world matrix of the particle system
  16883. * @param directionToUpdate is the direction vector to update with the result
  16884. * @param particle is the particle we are computed the direction for
  16885. * @param isLocal defines if the direction should be set in local space
  16886. */
  16887. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16888. /**
  16889. * Called by the particle System when the position is computed for the created particle.
  16890. * @param worldMatrix is the world matrix of the particle system
  16891. * @param positionToUpdate is the position vector to update with the result
  16892. * @param particle is the particle we are computed the position for
  16893. * @param isLocal defines if the position should be set in local space
  16894. */
  16895. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16896. /**
  16897. * Clones the current emitter and returns a copy of it
  16898. * @returns the new emitter
  16899. */
  16900. clone(): CustomParticleEmitter;
  16901. /**
  16902. * Called by the GPUParticleSystem to setup the update shader
  16903. * @param effect defines the update shader
  16904. */
  16905. applyToShader(effect: Effect): void;
  16906. /**
  16907. * Returns a string to use to update the GPU particles update shader
  16908. * @returns a string containng the defines string
  16909. */
  16910. getEffectDefines(): string;
  16911. /**
  16912. * Returns the string "PointParticleEmitter"
  16913. * @returns a string containing the class name
  16914. */
  16915. getClassName(): string;
  16916. /**
  16917. * Serializes the particle system to a JSON object.
  16918. * @returns the JSON object
  16919. */
  16920. serialize(): any;
  16921. /**
  16922. * Parse properties from a JSON object
  16923. * @param serializationObject defines the JSON object
  16924. */
  16925. parse(serializationObject: any): void;
  16926. }
  16927. }
  16928. declare module BABYLON {
  16929. /**
  16930. * Particle emitter emitting particles from the inside of a box.
  16931. * It emits the particles randomly between 2 given directions.
  16932. */
  16933. export class MeshParticleEmitter implements IParticleEmitterType {
  16934. private _indices;
  16935. private _positions;
  16936. private _normals;
  16937. private _storedNormal;
  16938. private _mesh;
  16939. /**
  16940. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16941. */
  16942. direction1: Vector3;
  16943. /**
  16944. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16945. */
  16946. direction2: Vector3;
  16947. /**
  16948. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  16949. */
  16950. useMeshNormalsForDirection: boolean;
  16951. /** Defines the mesh to use as source */
  16952. get mesh(): Nullable<AbstractMesh>;
  16953. set mesh(value: Nullable<AbstractMesh>);
  16954. /**
  16955. * Creates a new instance MeshParticleEmitter
  16956. * @param mesh defines the mesh to use as source
  16957. */
  16958. constructor(mesh?: Nullable<AbstractMesh>);
  16959. /**
  16960. * Called by the particle System when the direction is computed for the created particle.
  16961. * @param worldMatrix is the world matrix of the particle system
  16962. * @param directionToUpdate is the direction vector to update with the result
  16963. * @param particle is the particle we are computed the direction for
  16964. * @param isLocal defines if the direction should be set in local space
  16965. */
  16966. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16967. /**
  16968. * Called by the particle System when the position is computed for the created particle.
  16969. * @param worldMatrix is the world matrix of the particle system
  16970. * @param positionToUpdate is the position vector to update with the result
  16971. * @param particle is the particle we are computed the position for
  16972. * @param isLocal defines if the position should be set in local space
  16973. */
  16974. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16975. /**
  16976. * Clones the current emitter and returns a copy of it
  16977. * @returns the new emitter
  16978. */
  16979. clone(): MeshParticleEmitter;
  16980. /**
  16981. * Called by the GPUParticleSystem to setup the update shader
  16982. * @param effect defines the update shader
  16983. */
  16984. applyToShader(effect: Effect): void;
  16985. /**
  16986. * Returns a string to use to update the GPU particles update shader
  16987. * @returns a string containng the defines string
  16988. */
  16989. getEffectDefines(): string;
  16990. /**
  16991. * Returns the string "BoxParticleEmitter"
  16992. * @returns a string containing the class name
  16993. */
  16994. getClassName(): string;
  16995. /**
  16996. * Serializes the particle system to a JSON object.
  16997. * @returns the JSON object
  16998. */
  16999. serialize(): any;
  17000. /**
  17001. * Parse properties from a JSON object
  17002. * @param serializationObject defines the JSON object
  17003. * @param scene defines the hosting scene
  17004. */
  17005. parse(serializationObject: any, scene: Nullable<Scene>): void;
  17006. }
  17007. }
  17008. declare module BABYLON {
  17009. /**
  17010. * Interface representing a particle system in Babylon.js.
  17011. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17012. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17013. */
  17014. export interface IParticleSystem {
  17015. /**
  17016. * List of animations used by the particle system.
  17017. */
  17018. animations: Animation[];
  17019. /**
  17020. * The id of the Particle system.
  17021. */
  17022. id: string;
  17023. /**
  17024. * The name of the Particle system.
  17025. */
  17026. name: string;
  17027. /**
  17028. * The emitter represents the Mesh or position we are attaching the particle system to.
  17029. */
  17030. emitter: Nullable<AbstractMesh | Vector3>;
  17031. /**
  17032. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17033. */
  17034. isBillboardBased: boolean;
  17035. /**
  17036. * The rendering group used by the Particle system to chose when to render.
  17037. */
  17038. renderingGroupId: number;
  17039. /**
  17040. * The layer mask we are rendering the particles through.
  17041. */
  17042. layerMask: number;
  17043. /**
  17044. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17045. */
  17046. updateSpeed: number;
  17047. /**
  17048. * The amount of time the particle system is running (depends of the overall update speed).
  17049. */
  17050. targetStopDuration: number;
  17051. /**
  17052. * The texture used to render each particle. (this can be a spritesheet)
  17053. */
  17054. particleTexture: Nullable<BaseTexture>;
  17055. /**
  17056. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17057. */
  17058. blendMode: number;
  17059. /**
  17060. * Minimum life time of emitting particles.
  17061. */
  17062. minLifeTime: number;
  17063. /**
  17064. * Maximum life time of emitting particles.
  17065. */
  17066. maxLifeTime: number;
  17067. /**
  17068. * Minimum Size of emitting particles.
  17069. */
  17070. minSize: number;
  17071. /**
  17072. * Maximum Size of emitting particles.
  17073. */
  17074. maxSize: number;
  17075. /**
  17076. * Minimum scale of emitting particles on X axis.
  17077. */
  17078. minScaleX: number;
  17079. /**
  17080. * Maximum scale of emitting particles on X axis.
  17081. */
  17082. maxScaleX: number;
  17083. /**
  17084. * Minimum scale of emitting particles on Y axis.
  17085. */
  17086. minScaleY: number;
  17087. /**
  17088. * Maximum scale of emitting particles on Y axis.
  17089. */
  17090. maxScaleY: number;
  17091. /**
  17092. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17093. */
  17094. color1: Color4;
  17095. /**
  17096. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17097. */
  17098. color2: Color4;
  17099. /**
  17100. * Color the particle will have at the end of its lifetime.
  17101. */
  17102. colorDead: Color4;
  17103. /**
  17104. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17105. */
  17106. emitRate: number;
  17107. /**
  17108. * You can use gravity if you want to give an orientation to your particles.
  17109. */
  17110. gravity: Vector3;
  17111. /**
  17112. * Minimum power of emitting particles.
  17113. */
  17114. minEmitPower: number;
  17115. /**
  17116. * Maximum power of emitting particles.
  17117. */
  17118. maxEmitPower: number;
  17119. /**
  17120. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17121. */
  17122. minAngularSpeed: number;
  17123. /**
  17124. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17125. */
  17126. maxAngularSpeed: number;
  17127. /**
  17128. * Gets or sets the minimal initial rotation in radians.
  17129. */
  17130. minInitialRotation: number;
  17131. /**
  17132. * Gets or sets the maximal initial rotation in radians.
  17133. */
  17134. maxInitialRotation: number;
  17135. /**
  17136. * The particle emitter type defines the emitter used by the particle system.
  17137. * It can be for example box, sphere, or cone...
  17138. */
  17139. particleEmitterType: Nullable<IParticleEmitterType>;
  17140. /**
  17141. * Defines the delay in milliseconds before starting the system (0 by default)
  17142. */
  17143. startDelay: number;
  17144. /**
  17145. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  17146. */
  17147. preWarmCycles: number;
  17148. /**
  17149. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17150. */
  17151. preWarmStepOffset: number;
  17152. /**
  17153. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  17154. */
  17155. spriteCellChangeSpeed: number;
  17156. /**
  17157. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17158. */
  17159. startSpriteCellID: number;
  17160. /**
  17161. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17162. */
  17163. endSpriteCellID: number;
  17164. /**
  17165. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17166. */
  17167. spriteCellWidth: number;
  17168. /**
  17169. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17170. */
  17171. spriteCellHeight: number;
  17172. /**
  17173. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17174. */
  17175. spriteRandomStartCell: boolean;
  17176. /**
  17177. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  17178. */
  17179. isAnimationSheetEnabled: boolean;
  17180. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17181. translationPivot: Vector2;
  17182. /**
  17183. * Gets or sets a texture used to add random noise to particle positions
  17184. */
  17185. noiseTexture: Nullable<BaseTexture>;
  17186. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17187. noiseStrength: Vector3;
  17188. /**
  17189. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17190. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17191. */
  17192. billboardMode: number;
  17193. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17194. limitVelocityDamping: number;
  17195. /**
  17196. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17197. */
  17198. beginAnimationOnStart: boolean;
  17199. /**
  17200. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17201. */
  17202. beginAnimationFrom: number;
  17203. /**
  17204. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17205. */
  17206. beginAnimationTo: number;
  17207. /**
  17208. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17209. */
  17210. beginAnimationLoop: boolean;
  17211. /**
  17212. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17213. */
  17214. disposeOnStop: boolean;
  17215. /**
  17216. * Specifies if the particles are updated in emitter local space or world space
  17217. */
  17218. isLocal: boolean;
  17219. /** Snippet ID if the particle system was created from the snippet server */
  17220. snippetId: string;
  17221. /** Gets or sets a matrix to use to compute projection */
  17222. defaultProjectionMatrix: Matrix;
  17223. /**
  17224. * Gets the maximum number of particles active at the same time.
  17225. * @returns The max number of active particles.
  17226. */
  17227. getCapacity(): number;
  17228. /**
  17229. * Gets the number of particles active at the same time.
  17230. * @returns The number of active particles.
  17231. */
  17232. getActiveCount(): number;
  17233. /**
  17234. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17235. * @returns True if it has been started, otherwise false.
  17236. */
  17237. isStarted(): boolean;
  17238. /**
  17239. * Animates the particle system for this frame.
  17240. */
  17241. animate(): void;
  17242. /**
  17243. * Renders the particle system in its current state.
  17244. * @returns the current number of particles
  17245. */
  17246. render(): number;
  17247. /**
  17248. * Dispose the particle system and frees its associated resources.
  17249. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17250. */
  17251. dispose(disposeTexture?: boolean): void;
  17252. /**
  17253. * An event triggered when the system is disposed
  17254. */
  17255. onDisposeObservable: Observable<IParticleSystem>;
  17256. /**
  17257. * An event triggered when the system is stopped
  17258. */
  17259. onStoppedObservable: Observable<IParticleSystem>;
  17260. /**
  17261. * Clones the particle system.
  17262. * @param name The name of the cloned object
  17263. * @param newEmitter The new emitter to use
  17264. * @returns the cloned particle system
  17265. */
  17266. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17267. /**
  17268. * Serializes the particle system to a JSON object
  17269. * @param serializeTexture defines if the texture must be serialized as well
  17270. * @returns the JSON object
  17271. */
  17272. serialize(serializeTexture: boolean): any;
  17273. /**
  17274. * Rebuild the particle system
  17275. */
  17276. rebuild(): void;
  17277. /** Force the system to rebuild all gradients that need to be resync */
  17278. forceRefreshGradients(): void;
  17279. /**
  17280. * Starts the particle system and begins to emit
  17281. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  17282. */
  17283. start(delay?: number): void;
  17284. /**
  17285. * Stops the particle system.
  17286. */
  17287. stop(): void;
  17288. /**
  17289. * Remove all active particles
  17290. */
  17291. reset(): void;
  17292. /**
  17293. * Gets a boolean indicating that the system is stopping
  17294. * @returns true if the system is currently stopping
  17295. */
  17296. isStopping(): boolean;
  17297. /**
  17298. * Is this system ready to be used/rendered
  17299. * @return true if the system is ready
  17300. */
  17301. isReady(): boolean;
  17302. /**
  17303. * Returns the string "ParticleSystem"
  17304. * @returns a string containing the class name
  17305. */
  17306. getClassName(): string;
  17307. /**
  17308. * Gets the custom effect used to render the particles
  17309. * @param blendMode Blend mode for which the effect should be retrieved
  17310. * @returns The effect
  17311. */
  17312. getCustomEffect(blendMode: number): Nullable<Effect>;
  17313. /**
  17314. * Sets the custom effect used to render the particles
  17315. * @param effect The effect to set
  17316. * @param blendMode Blend mode for which the effect should be set
  17317. */
  17318. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  17319. /**
  17320. * Fill the defines array according to the current settings of the particle system
  17321. * @param defines Array to be updated
  17322. * @param blendMode blend mode to take into account when updating the array
  17323. */
  17324. fillDefines(defines: Array<string>, blendMode: number): void;
  17325. /**
  17326. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  17327. * @param uniforms Uniforms array to fill
  17328. * @param attributes Attributes array to fill
  17329. * @param samplers Samplers array to fill
  17330. */
  17331. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  17332. /**
  17333. * Observable that will be called just before the particles are drawn
  17334. */
  17335. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  17336. /**
  17337. * Gets the name of the particle vertex shader
  17338. */
  17339. vertexShaderName: string;
  17340. /**
  17341. * Adds a new color gradient
  17342. * @param gradient defines the gradient to use (between 0 and 1)
  17343. * @param color1 defines the color to affect to the specified gradient
  17344. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17345. * @returns the current particle system
  17346. */
  17347. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17348. /**
  17349. * Remove a specific color gradient
  17350. * @param gradient defines the gradient to remove
  17351. * @returns the current particle system
  17352. */
  17353. removeColorGradient(gradient: number): IParticleSystem;
  17354. /**
  17355. * Adds a new size gradient
  17356. * @param gradient defines the gradient to use (between 0 and 1)
  17357. * @param factor defines the size factor to affect to the specified gradient
  17358. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17359. * @returns the current particle system
  17360. */
  17361. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17362. /**
  17363. * Remove a specific size gradient
  17364. * @param gradient defines the gradient to remove
  17365. * @returns the current particle system
  17366. */
  17367. removeSizeGradient(gradient: number): IParticleSystem;
  17368. /**
  17369. * Gets the current list of color gradients.
  17370. * You must use addColorGradient and removeColorGradient to udpate this list
  17371. * @returns the list of color gradients
  17372. */
  17373. getColorGradients(): Nullable<Array<ColorGradient>>;
  17374. /**
  17375. * Gets the current list of size gradients.
  17376. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17377. * @returns the list of size gradients
  17378. */
  17379. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17380. /**
  17381. * Gets the current list of angular speed gradients.
  17382. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17383. * @returns the list of angular speed gradients
  17384. */
  17385. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17386. /**
  17387. * Adds a new angular speed gradient
  17388. * @param gradient defines the gradient to use (between 0 and 1)
  17389. * @param factor defines the angular speed to affect to the specified gradient
  17390. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17391. * @returns the current particle system
  17392. */
  17393. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17394. /**
  17395. * Remove a specific angular speed gradient
  17396. * @param gradient defines the gradient to remove
  17397. * @returns the current particle system
  17398. */
  17399. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17400. /**
  17401. * Gets the current list of velocity gradients.
  17402. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17403. * @returns the list of velocity gradients
  17404. */
  17405. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17406. /**
  17407. * Adds a new velocity gradient
  17408. * @param gradient defines the gradient to use (between 0 and 1)
  17409. * @param factor defines the velocity to affect to the specified gradient
  17410. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17411. * @returns the current particle system
  17412. */
  17413. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17414. /**
  17415. * Remove a specific velocity gradient
  17416. * @param gradient defines the gradient to remove
  17417. * @returns the current particle system
  17418. */
  17419. removeVelocityGradient(gradient: number): IParticleSystem;
  17420. /**
  17421. * Gets the current list of limit velocity gradients.
  17422. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17423. * @returns the list of limit velocity gradients
  17424. */
  17425. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17426. /**
  17427. * Adds a new limit velocity gradient
  17428. * @param gradient defines the gradient to use (between 0 and 1)
  17429. * @param factor defines the limit velocity to affect to the specified gradient
  17430. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17431. * @returns the current particle system
  17432. */
  17433. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17434. /**
  17435. * Remove a specific limit velocity gradient
  17436. * @param gradient defines the gradient to remove
  17437. * @returns the current particle system
  17438. */
  17439. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17440. /**
  17441. * Adds a new drag gradient
  17442. * @param gradient defines the gradient to use (between 0 and 1)
  17443. * @param factor defines the drag to affect to the specified gradient
  17444. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17445. * @returns the current particle system
  17446. */
  17447. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17448. /**
  17449. * Remove a specific drag gradient
  17450. * @param gradient defines the gradient to remove
  17451. * @returns the current particle system
  17452. */
  17453. removeDragGradient(gradient: number): IParticleSystem;
  17454. /**
  17455. * Gets the current list of drag gradients.
  17456. * You must use addDragGradient and removeDragGradient to udpate this list
  17457. * @returns the list of drag gradients
  17458. */
  17459. getDragGradients(): Nullable<Array<FactorGradient>>;
  17460. /**
  17461. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17462. * @param gradient defines the gradient to use (between 0 and 1)
  17463. * @param factor defines the emit rate to affect to the specified gradient
  17464. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17465. * @returns the current particle system
  17466. */
  17467. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17468. /**
  17469. * Remove a specific emit rate gradient
  17470. * @param gradient defines the gradient to remove
  17471. * @returns the current particle system
  17472. */
  17473. removeEmitRateGradient(gradient: number): IParticleSystem;
  17474. /**
  17475. * Gets the current list of emit rate gradients.
  17476. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17477. * @returns the list of emit rate gradients
  17478. */
  17479. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17480. /**
  17481. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17482. * @param gradient defines the gradient to use (between 0 and 1)
  17483. * @param factor defines the start size to affect to the specified gradient
  17484. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17485. * @returns the current particle system
  17486. */
  17487. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17488. /**
  17489. * Remove a specific start size gradient
  17490. * @param gradient defines the gradient to remove
  17491. * @returns the current particle system
  17492. */
  17493. removeStartSizeGradient(gradient: number): IParticleSystem;
  17494. /**
  17495. * Gets the current list of start size gradients.
  17496. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17497. * @returns the list of start size gradients
  17498. */
  17499. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17500. /**
  17501. * Adds a new life time gradient
  17502. * @param gradient defines the gradient to use (between 0 and 1)
  17503. * @param factor defines the life time factor to affect to the specified gradient
  17504. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17505. * @returns the current particle system
  17506. */
  17507. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17508. /**
  17509. * Remove a specific life time gradient
  17510. * @param gradient defines the gradient to remove
  17511. * @returns the current particle system
  17512. */
  17513. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17514. /**
  17515. * Gets the current list of life time gradients.
  17516. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17517. * @returns the list of life time gradients
  17518. */
  17519. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17520. /**
  17521. * Gets the current list of color gradients.
  17522. * You must use addColorGradient and removeColorGradient to udpate this list
  17523. * @returns the list of color gradients
  17524. */
  17525. getColorGradients(): Nullable<Array<ColorGradient>>;
  17526. /**
  17527. * Adds a new ramp gradient used to remap particle colors
  17528. * @param gradient defines the gradient to use (between 0 and 1)
  17529. * @param color defines the color to affect to the specified gradient
  17530. * @returns the current particle system
  17531. */
  17532. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17533. /**
  17534. * Gets the current list of ramp gradients.
  17535. * You must use addRampGradient and removeRampGradient to udpate this list
  17536. * @returns the list of ramp gradients
  17537. */
  17538. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17539. /** Gets or sets a boolean indicating that ramp gradients must be used
  17540. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17541. */
  17542. useRampGradients: boolean;
  17543. /**
  17544. * Adds a new color remap gradient
  17545. * @param gradient defines the gradient to use (between 0 and 1)
  17546. * @param min defines the color remap minimal range
  17547. * @param max defines the color remap maximal range
  17548. * @returns the current particle system
  17549. */
  17550. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17551. /**
  17552. * Gets the current list of color remap gradients.
  17553. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17554. * @returns the list of color remap gradients
  17555. */
  17556. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17557. /**
  17558. * Adds a new alpha remap gradient
  17559. * @param gradient defines the gradient to use (between 0 and 1)
  17560. * @param min defines the alpha remap minimal range
  17561. * @param max defines the alpha remap maximal range
  17562. * @returns the current particle system
  17563. */
  17564. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17565. /**
  17566. * Gets the current list of alpha remap gradients.
  17567. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17568. * @returns the list of alpha remap gradients
  17569. */
  17570. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17571. /**
  17572. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17573. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17574. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17575. * @returns the emitter
  17576. */
  17577. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17578. /**
  17579. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17580. * @param radius The radius of the hemisphere to emit from
  17581. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17582. * @returns the emitter
  17583. */
  17584. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17585. /**
  17586. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17587. * @param radius The radius of the sphere to emit from
  17588. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17589. * @returns the emitter
  17590. */
  17591. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17592. /**
  17593. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17594. * @param radius The radius of the sphere to emit from
  17595. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17596. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17597. * @returns the emitter
  17598. */
  17599. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17600. /**
  17601. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17602. * @param radius The radius of the emission cylinder
  17603. * @param height The height of the emission cylinder
  17604. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17605. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17606. * @returns the emitter
  17607. */
  17608. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17609. /**
  17610. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17611. * @param radius The radius of the cylinder to emit from
  17612. * @param height The height of the emission cylinder
  17613. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17614. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17615. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17616. * @returns the emitter
  17617. */
  17618. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17619. /**
  17620. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17621. * @param radius The radius of the cone to emit from
  17622. * @param angle The base angle of the cone
  17623. * @returns the emitter
  17624. */
  17625. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17626. /**
  17627. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17628. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17629. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17630. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17631. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17632. * @returns the emitter
  17633. */
  17634. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17635. /**
  17636. * Get hosting scene
  17637. * @returns the scene
  17638. */
  17639. getScene(): Nullable<Scene>;
  17640. }
  17641. }
  17642. declare module BABYLON {
  17643. /**
  17644. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  17645. */
  17646. export class ColorSplitterBlock extends NodeMaterialBlock {
  17647. /**
  17648. * Create a new ColorSplitterBlock
  17649. * @param name defines the block name
  17650. */
  17651. constructor(name: string);
  17652. /**
  17653. * Gets the current class name
  17654. * @returns the class name
  17655. */
  17656. getClassName(): string;
  17657. /**
  17658. * Gets the rgba component (input)
  17659. */
  17660. get rgba(): NodeMaterialConnectionPoint;
  17661. /**
  17662. * Gets the rgb component (input)
  17663. */
  17664. get rgbIn(): NodeMaterialConnectionPoint;
  17665. /**
  17666. * Gets the rgb component (output)
  17667. */
  17668. get rgbOut(): NodeMaterialConnectionPoint;
  17669. /**
  17670. * Gets the r component (output)
  17671. */
  17672. get r(): NodeMaterialConnectionPoint;
  17673. /**
  17674. * Gets the g component (output)
  17675. */
  17676. get g(): NodeMaterialConnectionPoint;
  17677. /**
  17678. * Gets the b component (output)
  17679. */
  17680. get b(): NodeMaterialConnectionPoint;
  17681. /**
  17682. * Gets the a component (output)
  17683. */
  17684. get a(): NodeMaterialConnectionPoint;
  17685. protected _inputRename(name: string): string;
  17686. protected _outputRename(name: string): string;
  17687. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  17688. }
  17689. }
  17690. declare module BABYLON {
  17691. /**
  17692. * Operations supported by the Trigonometry block
  17693. */
  17694. export enum TrigonometryBlockOperations {
  17695. /** Cos */
  17696. Cos = 0,
  17697. /** Sin */
  17698. Sin = 1,
  17699. /** Abs */
  17700. Abs = 2,
  17701. /** Exp */
  17702. Exp = 3,
  17703. /** Exp2 */
  17704. Exp2 = 4,
  17705. /** Round */
  17706. Round = 5,
  17707. /** Floor */
  17708. Floor = 6,
  17709. /** Ceiling */
  17710. Ceiling = 7,
  17711. /** Square root */
  17712. Sqrt = 8,
  17713. /** Log */
  17714. Log = 9,
  17715. /** Tangent */
  17716. Tan = 10,
  17717. /** Arc tangent */
  17718. ArcTan = 11,
  17719. /** Arc cosinus */
  17720. ArcCos = 12,
  17721. /** Arc sinus */
  17722. ArcSin = 13,
  17723. /** Fraction */
  17724. Fract = 14,
  17725. /** Sign */
  17726. Sign = 15,
  17727. /** To radians (from degrees) */
  17728. Radians = 16,
  17729. /** To degrees (from radians) */
  17730. Degrees = 17
  17731. }
  17732. /**
  17733. * Block used to apply trigonometry operation to floats
  17734. */
  17735. export class TrigonometryBlock extends NodeMaterialBlock {
  17736. /**
  17737. * Gets or sets the operation applied by the block
  17738. */
  17739. operation: TrigonometryBlockOperations;
  17740. /**
  17741. * Creates a new TrigonometryBlock
  17742. * @param name defines the block name
  17743. */
  17744. constructor(name: string);
  17745. /**
  17746. * Gets the current class name
  17747. * @returns the class name
  17748. */
  17749. getClassName(): string;
  17750. /**
  17751. * Gets the input component
  17752. */
  17753. get input(): NodeMaterialConnectionPoint;
  17754. /**
  17755. * Gets the output component
  17756. */
  17757. get output(): NodeMaterialConnectionPoint;
  17758. protected _buildBlock(state: NodeMaterialBuildState): this;
  17759. serialize(): any;
  17760. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  17761. protected _dumpPropertiesCode(): string;
  17762. }
  17763. }
  17764. declare module BABYLON {
  17765. /**
  17766. * Interface used to configure the node material editor
  17767. */
  17768. export interface INodeMaterialEditorOptions {
  17769. /** Define the URl to load node editor script */
  17770. editorURL?: string;
  17771. }
  17772. /** @hidden */
  17773. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17774. NORMAL: boolean;
  17775. TANGENT: boolean;
  17776. UV1: boolean;
  17777. /** BONES */
  17778. NUM_BONE_INFLUENCERS: number;
  17779. BonesPerMesh: number;
  17780. BONETEXTURE: boolean;
  17781. /** MORPH TARGETS */
  17782. MORPHTARGETS: boolean;
  17783. MORPHTARGETS_NORMAL: boolean;
  17784. MORPHTARGETS_TANGENT: boolean;
  17785. MORPHTARGETS_UV: boolean;
  17786. NUM_MORPH_INFLUENCERS: number;
  17787. /** IMAGE PROCESSING */
  17788. IMAGEPROCESSING: boolean;
  17789. VIGNETTE: boolean;
  17790. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17791. VIGNETTEBLENDMODEOPAQUE: boolean;
  17792. TONEMAPPING: boolean;
  17793. TONEMAPPING_ACES: boolean;
  17794. CONTRAST: boolean;
  17795. EXPOSURE: boolean;
  17796. COLORCURVES: boolean;
  17797. COLORGRADING: boolean;
  17798. COLORGRADING3D: boolean;
  17799. SAMPLER3DGREENDEPTH: boolean;
  17800. SAMPLER3DBGRMAP: boolean;
  17801. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17802. /** MISC. */
  17803. BUMPDIRECTUV: number;
  17804. constructor();
  17805. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  17806. }
  17807. /**
  17808. * Class used to configure NodeMaterial
  17809. */
  17810. export interface INodeMaterialOptions {
  17811. /**
  17812. * Defines if blocks should emit comments
  17813. */
  17814. emitComments: boolean;
  17815. }
  17816. /**
  17817. * Class used to create a node based material built by assembling shader blocks
  17818. */
  17819. export class NodeMaterial extends PushMaterial {
  17820. private static _BuildIdGenerator;
  17821. private _options;
  17822. private _vertexCompilationState;
  17823. private _fragmentCompilationState;
  17824. private _sharedData;
  17825. private _buildId;
  17826. private _buildWasSuccessful;
  17827. private _cachedWorldViewMatrix;
  17828. private _cachedWorldViewProjectionMatrix;
  17829. private _optimizers;
  17830. private _animationFrame;
  17831. /** Define the Url to load node editor script */
  17832. static EditorURL: string;
  17833. /** Define the Url to load snippets */
  17834. static SnippetUrl: string;
  17835. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  17836. static IgnoreTexturesAtLoadTime: boolean;
  17837. private BJSNODEMATERIALEDITOR;
  17838. /** Get the inspector from bundle or global */
  17839. private _getGlobalNodeMaterialEditor;
  17840. /**
  17841. * Snippet ID if the material was created from the snippet server
  17842. */
  17843. snippetId: string;
  17844. /**
  17845. * Gets or sets data used by visual editor
  17846. * @see https://nme.babylonjs.com
  17847. */
  17848. editorData: any;
  17849. /**
  17850. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  17851. */
  17852. ignoreAlpha: boolean;
  17853. /**
  17854. * Defines the maximum number of lights that can be used in the material
  17855. */
  17856. maxSimultaneousLights: number;
  17857. /**
  17858. * Observable raised when the material is built
  17859. */
  17860. onBuildObservable: Observable<NodeMaterial>;
  17861. /**
  17862. * Gets or sets the root nodes of the material vertex shader
  17863. */
  17864. _vertexOutputNodes: NodeMaterialBlock[];
  17865. /**
  17866. * Gets or sets the root nodes of the material fragment (pixel) shader
  17867. */
  17868. _fragmentOutputNodes: NodeMaterialBlock[];
  17869. /** Gets or sets options to control the node material overall behavior */
  17870. get options(): INodeMaterialOptions;
  17871. set options(options: INodeMaterialOptions);
  17872. /**
  17873. * Default configuration related to image processing available in the standard Material.
  17874. */
  17875. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17876. /**
  17877. * Gets the image processing configuration used either in this material.
  17878. */
  17879. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17880. /**
  17881. * Sets the Default image processing configuration used either in the this material.
  17882. *
  17883. * If sets to null, the scene one is in use.
  17884. */
  17885. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17886. /**
  17887. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  17888. */
  17889. attachedBlocks: NodeMaterialBlock[];
  17890. /**
  17891. * Specifies the mode of the node material
  17892. * @hidden
  17893. */
  17894. _mode: NodeMaterialModes;
  17895. /**
  17896. * Gets the mode property
  17897. */
  17898. get mode(): NodeMaterialModes;
  17899. /**
  17900. * A free comment about the material
  17901. */
  17902. comment: string;
  17903. /**
  17904. * Create a new node based material
  17905. * @param name defines the material name
  17906. * @param scene defines the hosting scene
  17907. * @param options defines creation option
  17908. */
  17909. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  17910. /**
  17911. * Gets the current class name of the material e.g. "NodeMaterial"
  17912. * @returns the class name
  17913. */
  17914. getClassName(): string;
  17915. /**
  17916. * Keep track of the image processing observer to allow dispose and replace.
  17917. */
  17918. private _imageProcessingObserver;
  17919. /**
  17920. * Attaches a new image processing configuration to the Standard Material.
  17921. * @param configuration
  17922. */
  17923. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17924. /**
  17925. * Get a block by its name
  17926. * @param name defines the name of the block to retrieve
  17927. * @returns the required block or null if not found
  17928. */
  17929. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  17930. /**
  17931. * Get a block by its name
  17932. * @param predicate defines the predicate used to find the good candidate
  17933. * @returns the required block or null if not found
  17934. */
  17935. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  17936. /**
  17937. * Get an input block by its name
  17938. * @param predicate defines the predicate used to find the good candidate
  17939. * @returns the required input block or null if not found
  17940. */
  17941. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  17942. /**
  17943. * Gets the list of input blocks attached to this material
  17944. * @returns an array of InputBlocks
  17945. */
  17946. getInputBlocks(): InputBlock[];
  17947. /**
  17948. * Adds a new optimizer to the list of optimizers
  17949. * @param optimizer defines the optimizers to add
  17950. * @returns the current material
  17951. */
  17952. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17953. /**
  17954. * Remove an optimizer from the list of optimizers
  17955. * @param optimizer defines the optimizers to remove
  17956. * @returns the current material
  17957. */
  17958. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17959. /**
  17960. * Add a new block to the list of output nodes
  17961. * @param node defines the node to add
  17962. * @returns the current material
  17963. */
  17964. addOutputNode(node: NodeMaterialBlock): this;
  17965. /**
  17966. * Remove a block from the list of root nodes
  17967. * @param node defines the node to remove
  17968. * @returns the current material
  17969. */
  17970. removeOutputNode(node: NodeMaterialBlock): this;
  17971. private _addVertexOutputNode;
  17972. private _removeVertexOutputNode;
  17973. private _addFragmentOutputNode;
  17974. private _removeFragmentOutputNode;
  17975. /**
  17976. * Specifies if the material will require alpha blending
  17977. * @returns a boolean specifying if alpha blending is needed
  17978. */
  17979. needAlphaBlending(): boolean;
  17980. /**
  17981. * Specifies if this material should be rendered in alpha test mode
  17982. * @returns a boolean specifying if an alpha test is needed.
  17983. */
  17984. needAlphaTesting(): boolean;
  17985. private _initializeBlock;
  17986. private _resetDualBlocks;
  17987. /**
  17988. * Remove a block from the current node material
  17989. * @param block defines the block to remove
  17990. */
  17991. removeBlock(block: NodeMaterialBlock): void;
  17992. /**
  17993. * Build the material and generates the inner effect
  17994. * @param verbose defines if the build should log activity
  17995. */
  17996. build(verbose?: boolean): void;
  17997. /**
  17998. * Runs an otpimization phase to try to improve the shader code
  17999. */
  18000. optimize(): void;
  18001. private _prepareDefinesForAttributes;
  18002. /**
  18003. * Create a post process from the material
  18004. * @param camera The camera to apply the render pass to.
  18005. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18006. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18007. * @param engine The engine which the post process will be applied. (default: current engine)
  18008. * @param reusable If the post process can be reused on the same frame. (default: false)
  18009. * @param textureType Type of textures used when performing the post process. (default: 0)
  18010. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  18011. * @returns the post process created
  18012. */
  18013. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  18014. /**
  18015. * Create the post process effect from the material
  18016. * @param postProcess The post process to create the effect for
  18017. */
  18018. createEffectForPostProcess(postProcess: PostProcess): void;
  18019. private _createEffectForPostProcess;
  18020. /**
  18021. * Create a new procedural texture based on this node material
  18022. * @param size defines the size of the texture
  18023. * @param scene defines the hosting scene
  18024. * @returns the new procedural texture attached to this node material
  18025. */
  18026. createProceduralTexture(size: number | {
  18027. width: number;
  18028. height: number;
  18029. layers?: number;
  18030. }, scene: Scene): Nullable<ProceduralTexture>;
  18031. private _createEffectForParticles;
  18032. private _checkInternals;
  18033. /**
  18034. * Create the effect to be used as the custom effect for a particle system
  18035. * @param particleSystem Particle system to create the effect for
  18036. * @param onCompiled defines a function to call when the effect creation is successful
  18037. * @param onError defines a function to call when the effect creation has failed
  18038. */
  18039. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18040. private _processDefines;
  18041. /**
  18042. * Get if the submesh is ready to be used and all its information available.
  18043. * Child classes can use it to update shaders
  18044. * @param mesh defines the mesh to check
  18045. * @param subMesh defines which submesh to check
  18046. * @param useInstances specifies that instances should be used
  18047. * @returns a boolean indicating that the submesh is ready or not
  18048. */
  18049. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  18050. /**
  18051. * Get a string representing the shaders built by the current node graph
  18052. */
  18053. get compiledShaders(): string;
  18054. /**
  18055. * Binds the world matrix to the material
  18056. * @param world defines the world transformation matrix
  18057. */
  18058. bindOnlyWorldMatrix(world: Matrix): void;
  18059. /**
  18060. * Binds the submesh to this material by preparing the effect and shader to draw
  18061. * @param world defines the world transformation matrix
  18062. * @param mesh defines the mesh containing the submesh
  18063. * @param subMesh defines the submesh to bind the material to
  18064. */
  18065. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18066. /**
  18067. * Gets the active textures from the material
  18068. * @returns an array of textures
  18069. */
  18070. getActiveTextures(): BaseTexture[];
  18071. /**
  18072. * Gets the list of texture blocks
  18073. * @returns an array of texture blocks
  18074. */
  18075. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  18076. /**
  18077. * Specifies if the material uses a texture
  18078. * @param texture defines the texture to check against the material
  18079. * @returns a boolean specifying if the material uses the texture
  18080. */
  18081. hasTexture(texture: BaseTexture): boolean;
  18082. /**
  18083. * Disposes the material
  18084. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18085. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18086. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18087. */
  18088. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18089. /** Creates the node editor window. */
  18090. private _createNodeEditor;
  18091. /**
  18092. * Launch the node material editor
  18093. * @param config Define the configuration of the editor
  18094. * @return a promise fulfilled when the node editor is visible
  18095. */
  18096. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  18097. /**
  18098. * Clear the current material
  18099. */
  18100. clear(): void;
  18101. /**
  18102. * Clear the current material and set it to a default state
  18103. */
  18104. setToDefault(): void;
  18105. /**
  18106. * Clear the current material and set it to a default state for post process
  18107. */
  18108. setToDefaultPostProcess(): void;
  18109. /**
  18110. * Clear the current material and set it to a default state for procedural texture
  18111. */
  18112. setToDefaultProceduralTexture(): void;
  18113. /**
  18114. * Clear the current material and set it to a default state for particle
  18115. */
  18116. setToDefaultParticle(): void;
  18117. /**
  18118. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  18119. * @param url defines the url to load from
  18120. * @returns a promise that will fullfil when the material is fully loaded
  18121. */
  18122. loadAsync(url: string): Promise<void>;
  18123. private _gatherBlocks;
  18124. /**
  18125. * Generate a string containing the code declaration required to create an equivalent of this material
  18126. * @returns a string
  18127. */
  18128. generateCode(): string;
  18129. /**
  18130. * Serializes this material in a JSON representation
  18131. * @returns the serialized material object
  18132. */
  18133. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  18134. private _restoreConnections;
  18135. /**
  18136. * Clear the current graph and load a new one from a serialization object
  18137. * @param source defines the JSON representation of the material
  18138. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18139. * @param merge defines whether or not the source must be merged or replace the current content
  18140. */
  18141. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  18142. /**
  18143. * Makes a duplicate of the current material.
  18144. * @param name - name to use for the new material.
  18145. */
  18146. clone(name: string): NodeMaterial;
  18147. /**
  18148. * Creates a node material from parsed material data
  18149. * @param source defines the JSON representation of the material
  18150. * @param scene defines the hosting scene
  18151. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18152. * @returns a new node material
  18153. */
  18154. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  18155. /**
  18156. * Creates a node material from a snippet saved in a remote file
  18157. * @param name defines the name of the material to create
  18158. * @param url defines the url to load from
  18159. * @param scene defines the hosting scene
  18160. * @returns a promise that will resolve to the new node material
  18161. */
  18162. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  18163. /**
  18164. * Creates a node material from a snippet saved by the node material editor
  18165. * @param snippetId defines the snippet to load
  18166. * @param scene defines the hosting scene
  18167. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18168. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  18169. * @returns a promise that will resolve to the new node material
  18170. */
  18171. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  18172. /**
  18173. * Creates a new node material set to default basic configuration
  18174. * @param name defines the name of the material
  18175. * @param scene defines the hosting scene
  18176. * @returns a new NodeMaterial
  18177. */
  18178. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  18179. }
  18180. }
  18181. declare module BABYLON {
  18182. interface ThinEngine {
  18183. /**
  18184. * Unbind a list of render target textures from the webGL context
  18185. * This is used only when drawBuffer extension or webGL2 are active
  18186. * @param textures defines the render target textures to unbind
  18187. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  18188. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  18189. */
  18190. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  18191. /**
  18192. * Create a multi render target texture
  18193. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  18194. * @param size defines the size of the texture
  18195. * @param options defines the creation options
  18196. * @returns the cube texture as an InternalTexture
  18197. */
  18198. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  18199. /**
  18200. * Update the sample count for a given multiple render target texture
  18201. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  18202. * @param textures defines the textures to update
  18203. * @param samples defines the sample count to set
  18204. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  18205. */
  18206. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  18207. /**
  18208. * Select a subsets of attachments to draw to.
  18209. * @param attachments gl attachments
  18210. */
  18211. bindAttachments(attachments: number[]): void;
  18212. /**
  18213. * Creates a layout object to draw/clear on specific textures in a MRT
  18214. * @param textureStatus textureStatus[i] indicates if the i-th is active
  18215. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  18216. */
  18217. buildTextureLayout(textureStatus: boolean[]): number[];
  18218. /**
  18219. * Restores the webgl state to only draw on the main color attachment
  18220. */
  18221. restoreSingleAttachment(): void;
  18222. /**
  18223. * Clears a list of attachments
  18224. * @param attachments list of the attachments
  18225. * @param colorMain clear color for the main attachment (the first one)
  18226. * @param colorOthers clear color for the other attachments
  18227. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  18228. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  18229. */
  18230. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  18231. }
  18232. }
  18233. declare module BABYLON {
  18234. /**
  18235. * Creation options of the multi render target texture.
  18236. */
  18237. export interface IMultiRenderTargetOptions {
  18238. /**
  18239. * Define if the texture needs to create mip maps after render.
  18240. */
  18241. generateMipMaps?: boolean;
  18242. /**
  18243. * Define the types of all the draw buffers we want to create
  18244. */
  18245. types?: number[];
  18246. /**
  18247. * Define the sampling modes of all the draw buffers we want to create
  18248. */
  18249. samplingModes?: number[];
  18250. /**
  18251. * Define if a depth buffer is required
  18252. */
  18253. generateDepthBuffer?: boolean;
  18254. /**
  18255. * Define if a stencil buffer is required
  18256. */
  18257. generateStencilBuffer?: boolean;
  18258. /**
  18259. * Define if a depth texture is required instead of a depth buffer
  18260. */
  18261. generateDepthTexture?: boolean;
  18262. /**
  18263. * Define the number of desired draw buffers
  18264. */
  18265. textureCount?: number;
  18266. /**
  18267. * Define if aspect ratio should be adapted to the texture or stay the scene one
  18268. */
  18269. doNotChangeAspectRatio?: boolean;
  18270. /**
  18271. * Define the default type of the buffers we are creating
  18272. */
  18273. defaultType?: number;
  18274. }
  18275. /**
  18276. * A multi render target, like a render target provides the ability to render to a texture.
  18277. * Unlike the render target, it can render to several draw buffers in one draw.
  18278. * This is specially interesting in deferred rendering or for any effects requiring more than
  18279. * just one color from a single pass.
  18280. */
  18281. export class MultiRenderTarget extends RenderTargetTexture {
  18282. private _internalTextures;
  18283. private _textures;
  18284. private _multiRenderTargetOptions;
  18285. private _count;
  18286. /**
  18287. * Get if draw buffers are currently supported by the used hardware and browser.
  18288. */
  18289. get isSupported(): boolean;
  18290. /**
  18291. * Get the list of textures generated by the multi render target.
  18292. */
  18293. get textures(): Texture[];
  18294. /**
  18295. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  18296. */
  18297. get count(): number;
  18298. /**
  18299. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  18300. */
  18301. get depthTexture(): Texture;
  18302. /**
  18303. * Set the wrapping mode on U of all the textures we are rendering to.
  18304. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18305. */
  18306. set wrapU(wrap: number);
  18307. /**
  18308. * Set the wrapping mode on V of all the textures we are rendering to.
  18309. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18310. */
  18311. set wrapV(wrap: number);
  18312. /**
  18313. * Instantiate a new multi render target texture.
  18314. * A multi render target, like a render target provides the ability to render to a texture.
  18315. * Unlike the render target, it can render to several draw buffers in one draw.
  18316. * This is specially interesting in deferred rendering or for any effects requiring more than
  18317. * just one color from a single pass.
  18318. * @param name Define the name of the texture
  18319. * @param size Define the size of the buffers to render to
  18320. * @param count Define the number of target we are rendering into
  18321. * @param scene Define the scene the texture belongs to
  18322. * @param options Define the options used to create the multi render target
  18323. */
  18324. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  18325. private _initTypes;
  18326. /** @hidden */
  18327. _rebuild(forceFullRebuild?: boolean): void;
  18328. private _createInternalTextures;
  18329. private _createTextures;
  18330. /**
  18331. * Replaces a texture within the MRT.
  18332. * @param texture The new texture to insert in the MRT
  18333. * @param index The index of the texture to replace
  18334. */
  18335. replaceTexture(texture: Texture, index: number): void;
  18336. /**
  18337. * Define the number of samples used if MSAA is enabled.
  18338. */
  18339. get samples(): number;
  18340. set samples(value: number);
  18341. /**
  18342. * Resize all the textures in the multi render target.
  18343. * Be careful as it will recreate all the data in the new texture.
  18344. * @param size Define the new size
  18345. */
  18346. resize(size: any): void;
  18347. /**
  18348. * Changes the number of render targets in this MRT
  18349. * Be careful as it will recreate all the data in the new texture.
  18350. * @param count new texture count
  18351. * @param options Specifies texture types and sampling modes for new textures
  18352. */
  18353. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18354. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18355. /**
  18356. * Dispose the render targets and their associated resources
  18357. */
  18358. dispose(): void;
  18359. /**
  18360. * Release all the underlying texture used as draw buffers.
  18361. */
  18362. releaseInternalTextures(): void;
  18363. }
  18364. }
  18365. declare module BABYLON {
  18366. /** @hidden */
  18367. export var imageProcessingPixelShader: {
  18368. name: string;
  18369. shader: string;
  18370. };
  18371. }
  18372. declare module BABYLON {
  18373. /**
  18374. * ImageProcessingPostProcess
  18375. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  18376. */
  18377. export class ImageProcessingPostProcess extends PostProcess {
  18378. /**
  18379. * Default configuration related to image processing available in the PBR Material.
  18380. */
  18381. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18382. /**
  18383. * Gets the image processing configuration used either in this material.
  18384. */
  18385. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18386. /**
  18387. * Sets the Default image processing configuration used either in the this material.
  18388. *
  18389. * If sets to null, the scene one is in use.
  18390. */
  18391. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18392. /**
  18393. * Keep track of the image processing observer to allow dispose and replace.
  18394. */
  18395. private _imageProcessingObserver;
  18396. /**
  18397. * Attaches a new image processing configuration to the PBR Material.
  18398. * @param configuration
  18399. */
  18400. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  18401. /**
  18402. * If the post process is supported.
  18403. */
  18404. get isSupported(): boolean;
  18405. /**
  18406. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18407. */
  18408. get colorCurves(): Nullable<ColorCurves>;
  18409. /**
  18410. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18411. */
  18412. set colorCurves(value: Nullable<ColorCurves>);
  18413. /**
  18414. * Gets wether the color curves effect is enabled.
  18415. */
  18416. get colorCurvesEnabled(): boolean;
  18417. /**
  18418. * Sets wether the color curves effect is enabled.
  18419. */
  18420. set colorCurvesEnabled(value: boolean);
  18421. /**
  18422. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18423. */
  18424. get colorGradingTexture(): Nullable<BaseTexture>;
  18425. /**
  18426. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18427. */
  18428. set colorGradingTexture(value: Nullable<BaseTexture>);
  18429. /**
  18430. * Gets wether the color grading effect is enabled.
  18431. */
  18432. get colorGradingEnabled(): boolean;
  18433. /**
  18434. * Gets wether the color grading effect is enabled.
  18435. */
  18436. set colorGradingEnabled(value: boolean);
  18437. /**
  18438. * Gets exposure used in the effect.
  18439. */
  18440. get exposure(): number;
  18441. /**
  18442. * Sets exposure used in the effect.
  18443. */
  18444. set exposure(value: number);
  18445. /**
  18446. * Gets wether tonemapping is enabled or not.
  18447. */
  18448. get toneMappingEnabled(): boolean;
  18449. /**
  18450. * Sets wether tonemapping is enabled or not
  18451. */
  18452. set toneMappingEnabled(value: boolean);
  18453. /**
  18454. * Gets the type of tone mapping effect.
  18455. */
  18456. get toneMappingType(): number;
  18457. /**
  18458. * Sets the type of tone mapping effect.
  18459. */
  18460. set toneMappingType(value: number);
  18461. /**
  18462. * Gets contrast used in the effect.
  18463. */
  18464. get contrast(): number;
  18465. /**
  18466. * Sets contrast used in the effect.
  18467. */
  18468. set contrast(value: number);
  18469. /**
  18470. * Gets Vignette stretch size.
  18471. */
  18472. get vignetteStretch(): number;
  18473. /**
  18474. * Sets Vignette stretch size.
  18475. */
  18476. set vignetteStretch(value: number);
  18477. /**
  18478. * Gets Vignette centre X Offset.
  18479. */
  18480. get vignetteCentreX(): number;
  18481. /**
  18482. * Sets Vignette centre X Offset.
  18483. */
  18484. set vignetteCentreX(value: number);
  18485. /**
  18486. * Gets Vignette centre Y Offset.
  18487. */
  18488. get vignetteCentreY(): number;
  18489. /**
  18490. * Sets Vignette centre Y Offset.
  18491. */
  18492. set vignetteCentreY(value: number);
  18493. /**
  18494. * Gets Vignette weight or intensity of the vignette effect.
  18495. */
  18496. get vignetteWeight(): number;
  18497. /**
  18498. * Sets Vignette weight or intensity of the vignette effect.
  18499. */
  18500. set vignetteWeight(value: number);
  18501. /**
  18502. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18503. * if vignetteEnabled is set to true.
  18504. */
  18505. get vignetteColor(): Color4;
  18506. /**
  18507. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18508. * if vignetteEnabled is set to true.
  18509. */
  18510. set vignetteColor(value: Color4);
  18511. /**
  18512. * Gets Camera field of view used by the Vignette effect.
  18513. */
  18514. get vignetteCameraFov(): number;
  18515. /**
  18516. * Sets Camera field of view used by the Vignette effect.
  18517. */
  18518. set vignetteCameraFov(value: number);
  18519. /**
  18520. * Gets the vignette blend mode allowing different kind of effect.
  18521. */
  18522. get vignetteBlendMode(): number;
  18523. /**
  18524. * Sets the vignette blend mode allowing different kind of effect.
  18525. */
  18526. set vignetteBlendMode(value: number);
  18527. /**
  18528. * Gets wether the vignette effect is enabled.
  18529. */
  18530. get vignetteEnabled(): boolean;
  18531. /**
  18532. * Sets wether the vignette effect is enabled.
  18533. */
  18534. set vignetteEnabled(value: boolean);
  18535. private _fromLinearSpace;
  18536. /**
  18537. * Gets wether the input of the processing is in Gamma or Linear Space.
  18538. */
  18539. get fromLinearSpace(): boolean;
  18540. /**
  18541. * Sets wether the input of the processing is in Gamma or Linear Space.
  18542. */
  18543. set fromLinearSpace(value: boolean);
  18544. /**
  18545. * Defines cache preventing GC.
  18546. */
  18547. private _defines;
  18548. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  18549. /**
  18550. * "ImageProcessingPostProcess"
  18551. * @returns "ImageProcessingPostProcess"
  18552. */
  18553. getClassName(): string;
  18554. /**
  18555. * @hidden
  18556. */
  18557. _updateParameters(): void;
  18558. dispose(camera?: Camera): void;
  18559. }
  18560. }
  18561. declare module BABYLON {
  18562. /**
  18563. * Interface for defining prepass effects in the prepass post-process pipeline
  18564. */
  18565. export interface PrePassEffectConfiguration {
  18566. /**
  18567. * Name of the effect
  18568. */
  18569. name: string;
  18570. /**
  18571. * Post process to attach for this effect
  18572. */
  18573. postProcess?: PostProcess;
  18574. /**
  18575. * Textures required in the MRT
  18576. */
  18577. texturesRequired: number[];
  18578. /**
  18579. * Is the effect enabled
  18580. */
  18581. enabled: boolean;
  18582. /**
  18583. * Disposes the effect configuration
  18584. */
  18585. dispose?: () => void;
  18586. /**
  18587. * Creates the associated post process
  18588. */
  18589. createPostProcess?: () => PostProcess;
  18590. }
  18591. }
  18592. declare module BABYLON {
  18593. /**
  18594. * Options to be used when creating a FresnelParameters.
  18595. */
  18596. export type IFresnelParametersCreationOptions = {
  18597. /**
  18598. * Define the color used on edges (grazing angle)
  18599. */
  18600. leftColor?: Color3;
  18601. /**
  18602. * Define the color used on center
  18603. */
  18604. rightColor?: Color3;
  18605. /**
  18606. * Define bias applied to computed fresnel term
  18607. */
  18608. bias?: number;
  18609. /**
  18610. * Defined the power exponent applied to fresnel term
  18611. */
  18612. power?: number;
  18613. /**
  18614. * Define if the fresnel effect is enable or not.
  18615. */
  18616. isEnabled?: boolean;
  18617. };
  18618. /**
  18619. * Serialized format for FresnelParameters.
  18620. */
  18621. export type IFresnelParametersSerialized = {
  18622. /**
  18623. * Define the color used on edges (grazing angle) [as an array]
  18624. */
  18625. leftColor: number[];
  18626. /**
  18627. * Define the color used on center [as an array]
  18628. */
  18629. rightColor: number[];
  18630. /**
  18631. * Define bias applied to computed fresnel term
  18632. */
  18633. bias: number;
  18634. /**
  18635. * Defined the power exponent applied to fresnel term
  18636. */
  18637. power?: number;
  18638. /**
  18639. * Define if the fresnel effect is enable or not.
  18640. */
  18641. isEnabled: boolean;
  18642. };
  18643. /**
  18644. * This represents all the required information to add a fresnel effect on a material:
  18645. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18646. */
  18647. export class FresnelParameters {
  18648. private _isEnabled;
  18649. /**
  18650. * Define if the fresnel effect is enable or not.
  18651. */
  18652. get isEnabled(): boolean;
  18653. set isEnabled(value: boolean);
  18654. /**
  18655. * Define the color used on edges (grazing angle)
  18656. */
  18657. leftColor: Color3;
  18658. /**
  18659. * Define the color used on center
  18660. */
  18661. rightColor: Color3;
  18662. /**
  18663. * Define bias applied to computed fresnel term
  18664. */
  18665. bias: number;
  18666. /**
  18667. * Defined the power exponent applied to fresnel term
  18668. */
  18669. power: number;
  18670. /**
  18671. * Creates a new FresnelParameters object.
  18672. *
  18673. * @param options provide your own settings to optionally to override defaults
  18674. */
  18675. constructor(options?: IFresnelParametersCreationOptions);
  18676. /**
  18677. * Clones the current fresnel and its valuues
  18678. * @returns a clone fresnel configuration
  18679. */
  18680. clone(): FresnelParameters;
  18681. /**
  18682. * Determines equality between FresnelParameters objects
  18683. * @param otherFresnelParameters defines the second operand
  18684. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  18685. */
  18686. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  18687. /**
  18688. * Serializes the current fresnel parameters to a JSON representation.
  18689. * @return the JSON serialization
  18690. */
  18691. serialize(): IFresnelParametersSerialized;
  18692. /**
  18693. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  18694. * @param parsedFresnelParameters Define the JSON representation
  18695. * @returns the parsed parameters
  18696. */
  18697. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  18698. }
  18699. }
  18700. declare module BABYLON {
  18701. /**
  18702. * This groups all the flags used to control the materials channel.
  18703. */
  18704. export class MaterialFlags {
  18705. private static _DiffuseTextureEnabled;
  18706. /**
  18707. * Are diffuse textures enabled in the application.
  18708. */
  18709. static get DiffuseTextureEnabled(): boolean;
  18710. static set DiffuseTextureEnabled(value: boolean);
  18711. private static _DetailTextureEnabled;
  18712. /**
  18713. * Are detail textures enabled in the application.
  18714. */
  18715. static get DetailTextureEnabled(): boolean;
  18716. static set DetailTextureEnabled(value: boolean);
  18717. private static _AmbientTextureEnabled;
  18718. /**
  18719. * Are ambient textures enabled in the application.
  18720. */
  18721. static get AmbientTextureEnabled(): boolean;
  18722. static set AmbientTextureEnabled(value: boolean);
  18723. private static _OpacityTextureEnabled;
  18724. /**
  18725. * Are opacity textures enabled in the application.
  18726. */
  18727. static get OpacityTextureEnabled(): boolean;
  18728. static set OpacityTextureEnabled(value: boolean);
  18729. private static _ReflectionTextureEnabled;
  18730. /**
  18731. * Are reflection textures enabled in the application.
  18732. */
  18733. static get ReflectionTextureEnabled(): boolean;
  18734. static set ReflectionTextureEnabled(value: boolean);
  18735. private static _EmissiveTextureEnabled;
  18736. /**
  18737. * Are emissive textures enabled in the application.
  18738. */
  18739. static get EmissiveTextureEnabled(): boolean;
  18740. static set EmissiveTextureEnabled(value: boolean);
  18741. private static _SpecularTextureEnabled;
  18742. /**
  18743. * Are specular textures enabled in the application.
  18744. */
  18745. static get SpecularTextureEnabled(): boolean;
  18746. static set SpecularTextureEnabled(value: boolean);
  18747. private static _BumpTextureEnabled;
  18748. /**
  18749. * Are bump textures enabled in the application.
  18750. */
  18751. static get BumpTextureEnabled(): boolean;
  18752. static set BumpTextureEnabled(value: boolean);
  18753. private static _LightmapTextureEnabled;
  18754. /**
  18755. * Are lightmap textures enabled in the application.
  18756. */
  18757. static get LightmapTextureEnabled(): boolean;
  18758. static set LightmapTextureEnabled(value: boolean);
  18759. private static _RefractionTextureEnabled;
  18760. /**
  18761. * Are refraction textures enabled in the application.
  18762. */
  18763. static get RefractionTextureEnabled(): boolean;
  18764. static set RefractionTextureEnabled(value: boolean);
  18765. private static _ColorGradingTextureEnabled;
  18766. /**
  18767. * Are color grading textures enabled in the application.
  18768. */
  18769. static get ColorGradingTextureEnabled(): boolean;
  18770. static set ColorGradingTextureEnabled(value: boolean);
  18771. private static _FresnelEnabled;
  18772. /**
  18773. * Are fresnels enabled in the application.
  18774. */
  18775. static get FresnelEnabled(): boolean;
  18776. static set FresnelEnabled(value: boolean);
  18777. private static _ClearCoatTextureEnabled;
  18778. /**
  18779. * Are clear coat textures enabled in the application.
  18780. */
  18781. static get ClearCoatTextureEnabled(): boolean;
  18782. static set ClearCoatTextureEnabled(value: boolean);
  18783. private static _ClearCoatBumpTextureEnabled;
  18784. /**
  18785. * Are clear coat bump textures enabled in the application.
  18786. */
  18787. static get ClearCoatBumpTextureEnabled(): boolean;
  18788. static set ClearCoatBumpTextureEnabled(value: boolean);
  18789. private static _ClearCoatTintTextureEnabled;
  18790. /**
  18791. * Are clear coat tint textures enabled in the application.
  18792. */
  18793. static get ClearCoatTintTextureEnabled(): boolean;
  18794. static set ClearCoatTintTextureEnabled(value: boolean);
  18795. private static _SheenTextureEnabled;
  18796. /**
  18797. * Are sheen textures enabled in the application.
  18798. */
  18799. static get SheenTextureEnabled(): boolean;
  18800. static set SheenTextureEnabled(value: boolean);
  18801. private static _AnisotropicTextureEnabled;
  18802. /**
  18803. * Are anisotropic textures enabled in the application.
  18804. */
  18805. static get AnisotropicTextureEnabled(): boolean;
  18806. static set AnisotropicTextureEnabled(value: boolean);
  18807. private static _ThicknessTextureEnabled;
  18808. /**
  18809. * Are thickness textures enabled in the application.
  18810. */
  18811. static get ThicknessTextureEnabled(): boolean;
  18812. static set ThicknessTextureEnabled(value: boolean);
  18813. }
  18814. }
  18815. declare module BABYLON {
  18816. /** @hidden */
  18817. export var defaultFragmentDeclaration: {
  18818. name: string;
  18819. shader: string;
  18820. };
  18821. }
  18822. declare module BABYLON {
  18823. /** @hidden */
  18824. export var sceneUboDeclaration: {
  18825. name: string;
  18826. shader: string;
  18827. };
  18828. }
  18829. declare module BABYLON {
  18830. /** @hidden */
  18831. export var meshUboDeclaration: {
  18832. name: string;
  18833. shader: string;
  18834. };
  18835. }
  18836. declare module BABYLON {
  18837. /** @hidden */
  18838. export var defaultUboDeclaration: {
  18839. name: string;
  18840. shader: string;
  18841. };
  18842. }
  18843. declare module BABYLON {
  18844. /** @hidden */
  18845. export var prePassDeclaration: {
  18846. name: string;
  18847. shader: string;
  18848. };
  18849. }
  18850. declare module BABYLON {
  18851. /** @hidden */
  18852. export var lightFragmentDeclaration: {
  18853. name: string;
  18854. shader: string;
  18855. };
  18856. }
  18857. declare module BABYLON {
  18858. /** @hidden */
  18859. export var lightUboDeclaration: {
  18860. name: string;
  18861. shader: string;
  18862. };
  18863. }
  18864. declare module BABYLON {
  18865. /** @hidden */
  18866. export var lightsFragmentFunctions: {
  18867. name: string;
  18868. shader: string;
  18869. };
  18870. }
  18871. declare module BABYLON {
  18872. /** @hidden */
  18873. export var shadowsFragmentFunctions: {
  18874. name: string;
  18875. shader: string;
  18876. };
  18877. }
  18878. declare module BABYLON {
  18879. /** @hidden */
  18880. export var fresnelFunction: {
  18881. name: string;
  18882. shader: string;
  18883. };
  18884. }
  18885. declare module BABYLON {
  18886. /** @hidden */
  18887. export var bumpFragmentMainFunctions: {
  18888. name: string;
  18889. shader: string;
  18890. };
  18891. }
  18892. declare module BABYLON {
  18893. /** @hidden */
  18894. export var bumpFragmentFunctions: {
  18895. name: string;
  18896. shader: string;
  18897. };
  18898. }
  18899. declare module BABYLON {
  18900. /** @hidden */
  18901. export var logDepthDeclaration: {
  18902. name: string;
  18903. shader: string;
  18904. };
  18905. }
  18906. declare module BABYLON {
  18907. /** @hidden */
  18908. export var fogFragmentDeclaration: {
  18909. name: string;
  18910. shader: string;
  18911. };
  18912. }
  18913. declare module BABYLON {
  18914. /** @hidden */
  18915. export var bumpFragment: {
  18916. name: string;
  18917. shader: string;
  18918. };
  18919. }
  18920. declare module BABYLON {
  18921. /** @hidden */
  18922. export var depthPrePass: {
  18923. name: string;
  18924. shader: string;
  18925. };
  18926. }
  18927. declare module BABYLON {
  18928. /** @hidden */
  18929. export var lightFragment: {
  18930. name: string;
  18931. shader: string;
  18932. };
  18933. }
  18934. declare module BABYLON {
  18935. /** @hidden */
  18936. export var logDepthFragment: {
  18937. name: string;
  18938. shader: string;
  18939. };
  18940. }
  18941. declare module BABYLON {
  18942. /** @hidden */
  18943. export var fogFragment: {
  18944. name: string;
  18945. shader: string;
  18946. };
  18947. }
  18948. declare module BABYLON {
  18949. /** @hidden */
  18950. export var defaultPixelShader: {
  18951. name: string;
  18952. shader: string;
  18953. };
  18954. }
  18955. declare module BABYLON {
  18956. /** @hidden */
  18957. export var defaultVertexDeclaration: {
  18958. name: string;
  18959. shader: string;
  18960. };
  18961. }
  18962. declare module BABYLON {
  18963. /** @hidden */
  18964. export var bonesDeclaration: {
  18965. name: string;
  18966. shader: string;
  18967. };
  18968. }
  18969. declare module BABYLON {
  18970. /** @hidden */
  18971. export var prePassVertexDeclaration: {
  18972. name: string;
  18973. shader: string;
  18974. };
  18975. }
  18976. declare module BABYLON {
  18977. /** @hidden */
  18978. export var bumpVertexDeclaration: {
  18979. name: string;
  18980. shader: string;
  18981. };
  18982. }
  18983. declare module BABYLON {
  18984. /** @hidden */
  18985. export var fogVertexDeclaration: {
  18986. name: string;
  18987. shader: string;
  18988. };
  18989. }
  18990. declare module BABYLON {
  18991. /** @hidden */
  18992. export var lightVxFragmentDeclaration: {
  18993. name: string;
  18994. shader: string;
  18995. };
  18996. }
  18997. declare module BABYLON {
  18998. /** @hidden */
  18999. export var lightVxUboDeclaration: {
  19000. name: string;
  19001. shader: string;
  19002. };
  19003. }
  19004. declare module BABYLON {
  19005. /** @hidden */
  19006. export var morphTargetsVertexGlobalDeclaration: {
  19007. name: string;
  19008. shader: string;
  19009. };
  19010. }
  19011. declare module BABYLON {
  19012. /** @hidden */
  19013. export var morphTargetsVertexDeclaration: {
  19014. name: string;
  19015. shader: string;
  19016. };
  19017. }
  19018. declare module BABYLON {
  19019. /** @hidden */
  19020. export var morphTargetsVertex: {
  19021. name: string;
  19022. shader: string;
  19023. };
  19024. }
  19025. declare module BABYLON {
  19026. /** @hidden */
  19027. export var instancesVertex: {
  19028. name: string;
  19029. shader: string;
  19030. };
  19031. }
  19032. declare module BABYLON {
  19033. /** @hidden */
  19034. export var bonesVertex: {
  19035. name: string;
  19036. shader: string;
  19037. };
  19038. }
  19039. declare module BABYLON {
  19040. /** @hidden */
  19041. export var prePassVertex: {
  19042. name: string;
  19043. shader: string;
  19044. };
  19045. }
  19046. declare module BABYLON {
  19047. /** @hidden */
  19048. export var bumpVertex: {
  19049. name: string;
  19050. shader: string;
  19051. };
  19052. }
  19053. declare module BABYLON {
  19054. /** @hidden */
  19055. export var fogVertex: {
  19056. name: string;
  19057. shader: string;
  19058. };
  19059. }
  19060. declare module BABYLON {
  19061. /** @hidden */
  19062. export var shadowsVertex: {
  19063. name: string;
  19064. shader: string;
  19065. };
  19066. }
  19067. declare module BABYLON {
  19068. /** @hidden */
  19069. export var pointCloudVertex: {
  19070. name: string;
  19071. shader: string;
  19072. };
  19073. }
  19074. declare module BABYLON {
  19075. /** @hidden */
  19076. export var logDepthVertex: {
  19077. name: string;
  19078. shader: string;
  19079. };
  19080. }
  19081. declare module BABYLON {
  19082. /** @hidden */
  19083. export var defaultVertexShader: {
  19084. name: string;
  19085. shader: string;
  19086. };
  19087. }
  19088. declare module BABYLON {
  19089. /**
  19090. * @hidden
  19091. */
  19092. export interface IMaterialDetailMapDefines {
  19093. DETAIL: boolean;
  19094. DETAILDIRECTUV: number;
  19095. DETAIL_NORMALBLENDMETHOD: number;
  19096. /** @hidden */
  19097. _areTexturesDirty: boolean;
  19098. }
  19099. /**
  19100. * Define the code related to the detail map parameters of a material
  19101. *
  19102. * Inspired from:
  19103. * Unity: https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@9.0/manual/Mask-Map-and-Detail-Map.html and https://docs.unity3d.com/Manual/StandardShaderMaterialParameterDetail.html
  19104. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  19105. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  19106. */
  19107. export class DetailMapConfiguration {
  19108. private _texture;
  19109. /**
  19110. * The detail texture of the material.
  19111. */
  19112. texture: Nullable<BaseTexture>;
  19113. /**
  19114. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  19115. * Bigger values mean stronger blending
  19116. */
  19117. diffuseBlendLevel: number;
  19118. /**
  19119. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  19120. * Bigger values mean stronger blending. Only used with PBR materials
  19121. */
  19122. roughnessBlendLevel: number;
  19123. /**
  19124. * Defines how strong the bump effect from the detail map is
  19125. * Bigger values mean stronger effect
  19126. */
  19127. bumpLevel: number;
  19128. private _normalBlendMethod;
  19129. /**
  19130. * The method used to blend the bump and detail normals together
  19131. */
  19132. normalBlendMethod: number;
  19133. private _isEnabled;
  19134. /**
  19135. * Enable or disable the detail map on this material
  19136. */
  19137. isEnabled: boolean;
  19138. /** @hidden */
  19139. private _internalMarkAllSubMeshesAsTexturesDirty;
  19140. /** @hidden */
  19141. _markAllSubMeshesAsTexturesDirty(): void;
  19142. /**
  19143. * Instantiate a new detail map
  19144. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19145. */
  19146. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19147. /**
  19148. * Gets whether the submesh is ready to be used or not.
  19149. * @param defines the list of "defines" to update.
  19150. * @param scene defines the scene the material belongs to.
  19151. * @returns - boolean indicating that the submesh is ready or not.
  19152. */
  19153. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  19154. /**
  19155. * Update the defines for detail map usage
  19156. * @param defines the list of "defines" to update.
  19157. * @param scene defines the scene the material belongs to.
  19158. */
  19159. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  19160. /**
  19161. * Binds the material data.
  19162. * @param uniformBuffer defines the Uniform buffer to fill in.
  19163. * @param scene defines the scene the material belongs to.
  19164. * @param isFrozen defines whether the material is frozen or not.
  19165. */
  19166. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19167. /**
  19168. * Checks to see if a texture is used in the material.
  19169. * @param texture - Base texture to use.
  19170. * @returns - Boolean specifying if a texture is used in the material.
  19171. */
  19172. hasTexture(texture: BaseTexture): boolean;
  19173. /**
  19174. * Returns an array of the actively used textures.
  19175. * @param activeTextures Array of BaseTextures
  19176. */
  19177. getActiveTextures(activeTextures: BaseTexture[]): void;
  19178. /**
  19179. * Returns the animatable textures.
  19180. * @param animatables Array of animatable textures.
  19181. */
  19182. getAnimatables(animatables: IAnimatable[]): void;
  19183. /**
  19184. * Disposes the resources of the material.
  19185. * @param forceDisposeTextures - Forces the disposal of all textures.
  19186. */
  19187. dispose(forceDisposeTextures?: boolean): void;
  19188. /**
  19189. * Get the current class name useful for serialization or dynamic coding.
  19190. * @returns "DetailMap"
  19191. */
  19192. getClassName(): string;
  19193. /**
  19194. * Add the required uniforms to the current list.
  19195. * @param uniforms defines the current uniform list.
  19196. */
  19197. static AddUniforms(uniforms: string[]): void;
  19198. /**
  19199. * Add the required samplers to the current list.
  19200. * @param samplers defines the current sampler list.
  19201. */
  19202. static AddSamplers(samplers: string[]): void;
  19203. /**
  19204. * Add the required uniforms to the current buffer.
  19205. * @param uniformBuffer defines the current uniform buffer.
  19206. */
  19207. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19208. /**
  19209. * Makes a duplicate of the current instance into another one.
  19210. * @param detailMap define the instance where to copy the info
  19211. */
  19212. copyTo(detailMap: DetailMapConfiguration): void;
  19213. /**
  19214. * Serializes this detail map instance
  19215. * @returns - An object with the serialized instance.
  19216. */
  19217. serialize(): any;
  19218. /**
  19219. * Parses a detail map setting from a serialized object.
  19220. * @param source - Serialized object.
  19221. * @param scene Defines the scene we are parsing for
  19222. * @param rootUrl Defines the rootUrl to load from
  19223. */
  19224. parse(source: any, scene: Scene, rootUrl: string): void;
  19225. }
  19226. }
  19227. declare module BABYLON {
  19228. /** @hidden */
  19229. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  19230. MAINUV1: boolean;
  19231. MAINUV2: boolean;
  19232. DIFFUSE: boolean;
  19233. DIFFUSEDIRECTUV: number;
  19234. DETAIL: boolean;
  19235. DETAILDIRECTUV: number;
  19236. DETAIL_NORMALBLENDMETHOD: number;
  19237. AMBIENT: boolean;
  19238. AMBIENTDIRECTUV: number;
  19239. OPACITY: boolean;
  19240. OPACITYDIRECTUV: number;
  19241. OPACITYRGB: boolean;
  19242. REFLECTION: boolean;
  19243. EMISSIVE: boolean;
  19244. EMISSIVEDIRECTUV: number;
  19245. SPECULAR: boolean;
  19246. SPECULARDIRECTUV: number;
  19247. BUMP: boolean;
  19248. BUMPDIRECTUV: number;
  19249. PARALLAX: boolean;
  19250. PARALLAXOCCLUSION: boolean;
  19251. SPECULAROVERALPHA: boolean;
  19252. CLIPPLANE: boolean;
  19253. CLIPPLANE2: boolean;
  19254. CLIPPLANE3: boolean;
  19255. CLIPPLANE4: boolean;
  19256. CLIPPLANE5: boolean;
  19257. CLIPPLANE6: boolean;
  19258. ALPHATEST: boolean;
  19259. DEPTHPREPASS: boolean;
  19260. ALPHAFROMDIFFUSE: boolean;
  19261. POINTSIZE: boolean;
  19262. FOG: boolean;
  19263. SPECULARTERM: boolean;
  19264. DIFFUSEFRESNEL: boolean;
  19265. OPACITYFRESNEL: boolean;
  19266. REFLECTIONFRESNEL: boolean;
  19267. REFRACTIONFRESNEL: boolean;
  19268. EMISSIVEFRESNEL: boolean;
  19269. FRESNEL: boolean;
  19270. NORMAL: boolean;
  19271. UV1: boolean;
  19272. UV2: boolean;
  19273. VERTEXCOLOR: boolean;
  19274. VERTEXALPHA: boolean;
  19275. NUM_BONE_INFLUENCERS: number;
  19276. BonesPerMesh: number;
  19277. BONETEXTURE: boolean;
  19278. BONES_VELOCITY_ENABLED: boolean;
  19279. INSTANCES: boolean;
  19280. THIN_INSTANCES: boolean;
  19281. GLOSSINESS: boolean;
  19282. ROUGHNESS: boolean;
  19283. EMISSIVEASILLUMINATION: boolean;
  19284. LINKEMISSIVEWITHDIFFUSE: boolean;
  19285. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19286. LIGHTMAP: boolean;
  19287. LIGHTMAPDIRECTUV: number;
  19288. OBJECTSPACE_NORMALMAP: boolean;
  19289. USELIGHTMAPASSHADOWMAP: boolean;
  19290. REFLECTIONMAP_3D: boolean;
  19291. REFLECTIONMAP_SPHERICAL: boolean;
  19292. REFLECTIONMAP_PLANAR: boolean;
  19293. REFLECTIONMAP_CUBIC: boolean;
  19294. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19295. REFLECTIONMAP_PROJECTION: boolean;
  19296. REFLECTIONMAP_SKYBOX: boolean;
  19297. REFLECTIONMAP_EXPLICIT: boolean;
  19298. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19299. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19300. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19301. INVERTCUBICMAP: boolean;
  19302. LOGARITHMICDEPTH: boolean;
  19303. REFRACTION: boolean;
  19304. REFRACTIONMAP_3D: boolean;
  19305. REFLECTIONOVERALPHA: boolean;
  19306. TWOSIDEDLIGHTING: boolean;
  19307. SHADOWFLOAT: boolean;
  19308. MORPHTARGETS: boolean;
  19309. MORPHTARGETS_NORMAL: boolean;
  19310. MORPHTARGETS_TANGENT: boolean;
  19311. MORPHTARGETS_UV: boolean;
  19312. NUM_MORPH_INFLUENCERS: number;
  19313. NONUNIFORMSCALING: boolean;
  19314. PREMULTIPLYALPHA: boolean;
  19315. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  19316. ALPHABLEND: boolean;
  19317. PREPASS: boolean;
  19318. PREPASS_IRRADIANCE: boolean;
  19319. PREPASS_IRRADIANCE_INDEX: number;
  19320. PREPASS_ALBEDO: boolean;
  19321. PREPASS_ALBEDO_INDEX: number;
  19322. PREPASS_DEPTHNORMAL: boolean;
  19323. PREPASS_DEPTHNORMAL_INDEX: number;
  19324. PREPASS_POSITION: boolean;
  19325. PREPASS_POSITION_INDEX: number;
  19326. PREPASS_VELOCITY: boolean;
  19327. PREPASS_VELOCITY_INDEX: number;
  19328. PREPASS_REFLECTIVITY: boolean;
  19329. PREPASS_REFLECTIVITY_INDEX: number;
  19330. SCENE_MRT_COUNT: number;
  19331. RGBDLIGHTMAP: boolean;
  19332. RGBDREFLECTION: boolean;
  19333. RGBDREFRACTION: boolean;
  19334. IMAGEPROCESSING: boolean;
  19335. VIGNETTE: boolean;
  19336. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19337. VIGNETTEBLENDMODEOPAQUE: boolean;
  19338. TONEMAPPING: boolean;
  19339. TONEMAPPING_ACES: boolean;
  19340. CONTRAST: boolean;
  19341. COLORCURVES: boolean;
  19342. COLORGRADING: boolean;
  19343. COLORGRADING3D: boolean;
  19344. SAMPLER3DGREENDEPTH: boolean;
  19345. SAMPLER3DBGRMAP: boolean;
  19346. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19347. MULTIVIEW: boolean;
  19348. /**
  19349. * If the reflection texture on this material is in linear color space
  19350. * @hidden
  19351. */
  19352. IS_REFLECTION_LINEAR: boolean;
  19353. /**
  19354. * If the refraction texture on this material is in linear color space
  19355. * @hidden
  19356. */
  19357. IS_REFRACTION_LINEAR: boolean;
  19358. EXPOSURE: boolean;
  19359. constructor();
  19360. setReflectionMode(modeToEnable: string): void;
  19361. }
  19362. /**
  19363. * This is the default material used in Babylon. It is the best trade off between quality
  19364. * and performances.
  19365. * @see https://doc.babylonjs.com/babylon101/materials
  19366. */
  19367. export class StandardMaterial extends PushMaterial {
  19368. private _diffuseTexture;
  19369. /**
  19370. * The basic texture of the material as viewed under a light.
  19371. */
  19372. diffuseTexture: Nullable<BaseTexture>;
  19373. private _ambientTexture;
  19374. /**
  19375. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19376. */
  19377. ambientTexture: Nullable<BaseTexture>;
  19378. private _opacityTexture;
  19379. /**
  19380. * Define the transparency of the material from a texture.
  19381. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19382. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19383. */
  19384. opacityTexture: Nullable<BaseTexture>;
  19385. private _reflectionTexture;
  19386. /**
  19387. * Define the texture used to display the reflection.
  19388. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19389. */
  19390. reflectionTexture: Nullable<BaseTexture>;
  19391. private _emissiveTexture;
  19392. /**
  19393. * Define texture of the material as if self lit.
  19394. * This will be mixed in the final result even in the absence of light.
  19395. */
  19396. emissiveTexture: Nullable<BaseTexture>;
  19397. private _specularTexture;
  19398. /**
  19399. * Define how the color and intensity of the highlight given by the light in the material.
  19400. */
  19401. specularTexture: Nullable<BaseTexture>;
  19402. private _bumpTexture;
  19403. /**
  19404. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19405. * These are made by creating a normal map from an image. The means to do this can be found on the web, a search for 'normal map generator' will bring up free and paid for methods of doing this.
  19406. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  19407. */
  19408. bumpTexture: Nullable<BaseTexture>;
  19409. private _lightmapTexture;
  19410. /**
  19411. * Complex lighting can be computationally expensive to compute at runtime.
  19412. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19413. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  19414. */
  19415. lightmapTexture: Nullable<BaseTexture>;
  19416. private _refractionTexture;
  19417. /**
  19418. * Define the texture used to display the refraction.
  19419. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19420. */
  19421. refractionTexture: Nullable<BaseTexture>;
  19422. /**
  19423. * The color of the material lit by the environmental background lighting.
  19424. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19425. */
  19426. ambientColor: Color3;
  19427. /**
  19428. * The basic color of the material as viewed under a light.
  19429. */
  19430. diffuseColor: Color3;
  19431. /**
  19432. * Define how the color and intensity of the highlight given by the light in the material.
  19433. */
  19434. specularColor: Color3;
  19435. /**
  19436. * Define the color of the material as if self lit.
  19437. * This will be mixed in the final result even in the absence of light.
  19438. */
  19439. emissiveColor: Color3;
  19440. /**
  19441. * Defines how sharp are the highlights in the material.
  19442. * The bigger the value the sharper giving a more glossy feeling to the result.
  19443. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19444. */
  19445. specularPower: number;
  19446. private _useAlphaFromDiffuseTexture;
  19447. /**
  19448. * Does the transparency come from the diffuse texture alpha channel.
  19449. */
  19450. useAlphaFromDiffuseTexture: boolean;
  19451. private _useEmissiveAsIllumination;
  19452. /**
  19453. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19454. */
  19455. useEmissiveAsIllumination: boolean;
  19456. private _linkEmissiveWithDiffuse;
  19457. /**
  19458. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19459. * the emissive level when the final color is close to one.
  19460. */
  19461. linkEmissiveWithDiffuse: boolean;
  19462. private _useSpecularOverAlpha;
  19463. /**
  19464. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  19465. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19466. */
  19467. useSpecularOverAlpha: boolean;
  19468. private _useReflectionOverAlpha;
  19469. /**
  19470. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  19471. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19472. */
  19473. useReflectionOverAlpha: boolean;
  19474. private _disableLighting;
  19475. /**
  19476. * Does lights from the scene impacts this material.
  19477. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19478. */
  19479. disableLighting: boolean;
  19480. private _useObjectSpaceNormalMap;
  19481. /**
  19482. * Allows using an object space normal map (instead of tangent space).
  19483. */
  19484. useObjectSpaceNormalMap: boolean;
  19485. private _useParallax;
  19486. /**
  19487. * Is parallax enabled or not.
  19488. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19489. */
  19490. useParallax: boolean;
  19491. private _useParallaxOcclusion;
  19492. /**
  19493. * Is parallax occlusion enabled or not.
  19494. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19495. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19496. */
  19497. useParallaxOcclusion: boolean;
  19498. /**
  19499. * Apply a scaling factor that determine which "depth" the height map should reprensent. A value between 0.05 and 0.1 is reasonnable in Parallax, you can reach 0.2 using Parallax Occlusion.
  19500. */
  19501. parallaxScaleBias: number;
  19502. private _roughness;
  19503. /**
  19504. * Helps to define how blurry the reflections should appears in the material.
  19505. */
  19506. roughness: number;
  19507. /**
  19508. * In case of refraction, define the value of the index of refraction.
  19509. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19510. */
  19511. indexOfRefraction: number;
  19512. /**
  19513. * Invert the refraction texture alongside the y axis.
  19514. * It can be useful with procedural textures or probe for instance.
  19515. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19516. */
  19517. invertRefractionY: boolean;
  19518. /**
  19519. * Defines the alpha limits in alpha test mode.
  19520. */
  19521. alphaCutOff: number;
  19522. private _useLightmapAsShadowmap;
  19523. /**
  19524. * In case of light mapping, define whether the map contains light or shadow informations.
  19525. */
  19526. useLightmapAsShadowmap: boolean;
  19527. private _diffuseFresnelParameters;
  19528. /**
  19529. * Define the diffuse fresnel parameters of the material.
  19530. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19531. */
  19532. diffuseFresnelParameters: FresnelParameters;
  19533. private _opacityFresnelParameters;
  19534. /**
  19535. * Define the opacity fresnel parameters of the material.
  19536. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19537. */
  19538. opacityFresnelParameters: FresnelParameters;
  19539. private _reflectionFresnelParameters;
  19540. /**
  19541. * Define the reflection fresnel parameters of the material.
  19542. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19543. */
  19544. reflectionFresnelParameters: FresnelParameters;
  19545. private _refractionFresnelParameters;
  19546. /**
  19547. * Define the refraction fresnel parameters of the material.
  19548. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19549. */
  19550. refractionFresnelParameters: FresnelParameters;
  19551. private _emissiveFresnelParameters;
  19552. /**
  19553. * Define the emissive fresnel parameters of the material.
  19554. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19555. */
  19556. emissiveFresnelParameters: FresnelParameters;
  19557. private _useReflectionFresnelFromSpecular;
  19558. /**
  19559. * If true automatically deducts the fresnels values from the material specularity.
  19560. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19561. */
  19562. useReflectionFresnelFromSpecular: boolean;
  19563. private _useGlossinessFromSpecularMapAlpha;
  19564. /**
  19565. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19566. */
  19567. useGlossinessFromSpecularMapAlpha: boolean;
  19568. private _maxSimultaneousLights;
  19569. /**
  19570. * Defines the maximum number of lights that can be used in the material
  19571. */
  19572. maxSimultaneousLights: number;
  19573. private _invertNormalMapX;
  19574. /**
  19575. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19576. */
  19577. invertNormalMapX: boolean;
  19578. private _invertNormalMapY;
  19579. /**
  19580. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19581. */
  19582. invertNormalMapY: boolean;
  19583. private _twoSidedLighting;
  19584. /**
  19585. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19586. */
  19587. twoSidedLighting: boolean;
  19588. /**
  19589. * Default configuration related to image processing available in the standard Material.
  19590. */
  19591. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19592. /**
  19593. * Gets the image processing configuration used either in this material.
  19594. */
  19595. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  19596. /**
  19597. * Sets the Default image processing configuration used either in the this material.
  19598. *
  19599. * If sets to null, the scene one is in use.
  19600. */
  19601. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  19602. /**
  19603. * Keep track of the image processing observer to allow dispose and replace.
  19604. */
  19605. private _imageProcessingObserver;
  19606. /**
  19607. * Attaches a new image processing configuration to the Standard Material.
  19608. * @param configuration
  19609. */
  19610. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19611. /**
  19612. * Defines additionnal PrePass parameters for the material.
  19613. */
  19614. readonly prePassConfiguration: PrePassConfiguration;
  19615. /**
  19616. * Gets wether the color curves effect is enabled.
  19617. */
  19618. get cameraColorCurvesEnabled(): boolean;
  19619. /**
  19620. * Sets wether the color curves effect is enabled.
  19621. */
  19622. set cameraColorCurvesEnabled(value: boolean);
  19623. /**
  19624. * Gets wether the color grading effect is enabled.
  19625. */
  19626. get cameraColorGradingEnabled(): boolean;
  19627. /**
  19628. * Gets wether the color grading effect is enabled.
  19629. */
  19630. set cameraColorGradingEnabled(value: boolean);
  19631. /**
  19632. * Gets wether tonemapping is enabled or not.
  19633. */
  19634. get cameraToneMappingEnabled(): boolean;
  19635. /**
  19636. * Sets wether tonemapping is enabled or not
  19637. */
  19638. set cameraToneMappingEnabled(value: boolean);
  19639. /**
  19640. * The camera exposure used on this material.
  19641. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19642. * This corresponds to a photographic exposure.
  19643. */
  19644. get cameraExposure(): number;
  19645. /**
  19646. * The camera exposure used on this material.
  19647. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19648. * This corresponds to a photographic exposure.
  19649. */
  19650. set cameraExposure(value: number);
  19651. /**
  19652. * Gets The camera contrast used on this material.
  19653. */
  19654. get cameraContrast(): number;
  19655. /**
  19656. * Sets The camera contrast used on this material.
  19657. */
  19658. set cameraContrast(value: number);
  19659. /**
  19660. * Gets the Color Grading 2D Lookup Texture.
  19661. */
  19662. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  19663. /**
  19664. * Sets the Color Grading 2D Lookup Texture.
  19665. */
  19666. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  19667. /**
  19668. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19669. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19670. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  19671. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19672. */
  19673. get cameraColorCurves(): Nullable<ColorCurves>;
  19674. /**
  19675. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19676. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19677. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  19678. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19679. */
  19680. set cameraColorCurves(value: Nullable<ColorCurves>);
  19681. /**
  19682. * Can this material render to several textures at once
  19683. */
  19684. get canRenderToMRT(): boolean;
  19685. /**
  19686. * Defines the detail map parameters for the material.
  19687. */
  19688. readonly detailMap: DetailMapConfiguration;
  19689. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19690. protected _worldViewProjectionMatrix: Matrix;
  19691. protected _globalAmbientColor: Color3;
  19692. protected _useLogarithmicDepth: boolean;
  19693. protected _rebuildInParallel: boolean;
  19694. /**
  19695. * Instantiates a new standard material.
  19696. * This is the default material used in Babylon. It is the best trade off between quality
  19697. * and performances.
  19698. * @see https://doc.babylonjs.com/babylon101/materials
  19699. * @param name Define the name of the material in the scene
  19700. * @param scene Define the scene the material belong to
  19701. */
  19702. constructor(name: string, scene: Scene);
  19703. /**
  19704. * Gets a boolean indicating that current material needs to register RTT
  19705. */
  19706. get hasRenderTargetTextures(): boolean;
  19707. /**
  19708. * Gets the current class name of the material e.g. "StandardMaterial"
  19709. * Mainly use in serialization.
  19710. * @returns the class name
  19711. */
  19712. getClassName(): string;
  19713. /**
  19714. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19715. * You can try switching to logarithmic depth.
  19716. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19717. */
  19718. get useLogarithmicDepth(): boolean;
  19719. set useLogarithmicDepth(value: boolean);
  19720. /**
  19721. * Specifies if the material will require alpha blending
  19722. * @returns a boolean specifying if alpha blending is needed
  19723. */
  19724. needAlphaBlending(): boolean;
  19725. /**
  19726. * Specifies if this material should be rendered in alpha test mode
  19727. * @returns a boolean specifying if an alpha test is needed.
  19728. */
  19729. needAlphaTesting(): boolean;
  19730. /**
  19731. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  19732. */
  19733. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19734. /**
  19735. * Specifies whether or not there is a usable alpha channel for transparency.
  19736. */
  19737. protected _hasAlphaChannel(): boolean;
  19738. /**
  19739. * Get the texture used for alpha test purpose.
  19740. * @returns the diffuse texture in case of the standard material.
  19741. */
  19742. getAlphaTestTexture(): Nullable<BaseTexture>;
  19743. /**
  19744. * Get if the submesh is ready to be used and all its information available.
  19745. * Child classes can use it to update shaders
  19746. * @param mesh defines the mesh to check
  19747. * @param subMesh defines which submesh to check
  19748. * @param useInstances specifies that instances should be used
  19749. * @returns a boolean indicating that the submesh is ready or not
  19750. */
  19751. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19752. /**
  19753. * Builds the material UBO layouts.
  19754. * Used internally during the effect preparation.
  19755. */
  19756. buildUniformLayout(): void;
  19757. /**
  19758. * Unbinds the material from the mesh
  19759. */
  19760. unbind(): void;
  19761. /**
  19762. * Binds the submesh to this material by preparing the effect and shader to draw
  19763. * @param world defines the world transformation matrix
  19764. * @param mesh defines the mesh containing the submesh
  19765. * @param subMesh defines the submesh to bind the material to
  19766. */
  19767. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19768. /**
  19769. * Get the list of animatables in the material.
  19770. * @returns the list of animatables object used in the material
  19771. */
  19772. getAnimatables(): IAnimatable[];
  19773. /**
  19774. * Gets the active textures from the material
  19775. * @returns an array of textures
  19776. */
  19777. getActiveTextures(): BaseTexture[];
  19778. /**
  19779. * Specifies if the material uses a texture
  19780. * @param texture defines the texture to check against the material
  19781. * @returns a boolean specifying if the material uses the texture
  19782. */
  19783. hasTexture(texture: BaseTexture): boolean;
  19784. /**
  19785. * Disposes the material
  19786. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19787. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19788. */
  19789. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19790. /**
  19791. * Makes a duplicate of the material, and gives it a new name
  19792. * @param name defines the new name for the duplicated material
  19793. * @returns the cloned material
  19794. */
  19795. clone(name: string): StandardMaterial;
  19796. /**
  19797. * Serializes this material in a JSON representation
  19798. * @returns the serialized material object
  19799. */
  19800. serialize(): any;
  19801. /**
  19802. * Creates a standard material from parsed material data
  19803. * @param source defines the JSON representation of the material
  19804. * @param scene defines the hosting scene
  19805. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19806. * @returns a new standard material
  19807. */
  19808. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19809. /**
  19810. * Are diffuse textures enabled in the application.
  19811. */
  19812. static get DiffuseTextureEnabled(): boolean;
  19813. static set DiffuseTextureEnabled(value: boolean);
  19814. /**
  19815. * Are detail textures enabled in the application.
  19816. */
  19817. static get DetailTextureEnabled(): boolean;
  19818. static set DetailTextureEnabled(value: boolean);
  19819. /**
  19820. * Are ambient textures enabled in the application.
  19821. */
  19822. static get AmbientTextureEnabled(): boolean;
  19823. static set AmbientTextureEnabled(value: boolean);
  19824. /**
  19825. * Are opacity textures enabled in the application.
  19826. */
  19827. static get OpacityTextureEnabled(): boolean;
  19828. static set OpacityTextureEnabled(value: boolean);
  19829. /**
  19830. * Are reflection textures enabled in the application.
  19831. */
  19832. static get ReflectionTextureEnabled(): boolean;
  19833. static set ReflectionTextureEnabled(value: boolean);
  19834. /**
  19835. * Are emissive textures enabled in the application.
  19836. */
  19837. static get EmissiveTextureEnabled(): boolean;
  19838. static set EmissiveTextureEnabled(value: boolean);
  19839. /**
  19840. * Are specular textures enabled in the application.
  19841. */
  19842. static get SpecularTextureEnabled(): boolean;
  19843. static set SpecularTextureEnabled(value: boolean);
  19844. /**
  19845. * Are bump textures enabled in the application.
  19846. */
  19847. static get BumpTextureEnabled(): boolean;
  19848. static set BumpTextureEnabled(value: boolean);
  19849. /**
  19850. * Are lightmap textures enabled in the application.
  19851. */
  19852. static get LightmapTextureEnabled(): boolean;
  19853. static set LightmapTextureEnabled(value: boolean);
  19854. /**
  19855. * Are refraction textures enabled in the application.
  19856. */
  19857. static get RefractionTextureEnabled(): boolean;
  19858. static set RefractionTextureEnabled(value: boolean);
  19859. /**
  19860. * Are color grading textures enabled in the application.
  19861. */
  19862. static get ColorGradingTextureEnabled(): boolean;
  19863. static set ColorGradingTextureEnabled(value: boolean);
  19864. /**
  19865. * Are fresnels enabled in the application.
  19866. */
  19867. static get FresnelEnabled(): boolean;
  19868. static set FresnelEnabled(value: boolean);
  19869. }
  19870. }
  19871. declare module BABYLON {
  19872. /** @hidden */
  19873. export var rgbdDecodePixelShader: {
  19874. name: string;
  19875. shader: string;
  19876. };
  19877. }
  19878. declare module BABYLON {
  19879. /** @hidden */
  19880. export var passPixelShader: {
  19881. name: string;
  19882. shader: string;
  19883. };
  19884. }
  19885. declare module BABYLON {
  19886. /** @hidden */
  19887. export var passCubePixelShader: {
  19888. name: string;
  19889. shader: string;
  19890. };
  19891. }
  19892. declare module BABYLON {
  19893. /**
  19894. * PassPostProcess which produces an output the same as it's input
  19895. */
  19896. export class PassPostProcess extends PostProcess {
  19897. /**
  19898. * Gets a string identifying the name of the class
  19899. * @returns "PassPostProcess" string
  19900. */
  19901. getClassName(): string;
  19902. /**
  19903. * Creates the PassPostProcess
  19904. * @param name The name of the effect.
  19905. * @param options The required width/height ratio to downsize to before computing the render pass.
  19906. * @param camera The camera to apply the render pass to.
  19907. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19908. * @param engine The engine which the post process will be applied. (default: current engine)
  19909. * @param reusable If the post process can be reused on the same frame. (default: false)
  19910. * @param textureType The type of texture to be used when performing the post processing.
  19911. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  19912. */
  19913. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  19914. /** @hidden */
  19915. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  19916. }
  19917. /**
  19918. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  19919. */
  19920. export class PassCubePostProcess extends PostProcess {
  19921. private _face;
  19922. /**
  19923. * Gets or sets the cube face to display.
  19924. * * 0 is +X
  19925. * * 1 is -X
  19926. * * 2 is +Y
  19927. * * 3 is -Y
  19928. * * 4 is +Z
  19929. * * 5 is -Z
  19930. */
  19931. get face(): number;
  19932. set face(value: number);
  19933. /**
  19934. * Gets a string identifying the name of the class
  19935. * @returns "PassCubePostProcess" string
  19936. */
  19937. getClassName(): string;
  19938. /**
  19939. * Creates the PassCubePostProcess
  19940. * @param name The name of the effect.
  19941. * @param options The required width/height ratio to downsize to before computing the render pass.
  19942. * @param camera The camera to apply the render pass to.
  19943. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19944. * @param engine The engine which the post process will be applied. (default: current engine)
  19945. * @param reusable If the post process can be reused on the same frame. (default: false)
  19946. * @param textureType The type of texture to be used when performing the post processing.
  19947. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  19948. */
  19949. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  19950. /** @hidden */
  19951. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  19952. }
  19953. }
  19954. declare module BABYLON {
  19955. /**
  19956. * Class used to host texture specific utilities
  19957. */
  19958. export class TextureTools {
  19959. /**
  19960. * Uses the GPU to create a copy texture rescaled at a given size
  19961. * @param texture Texture to copy from
  19962. * @param width defines the desired width
  19963. * @param height defines the desired height
  19964. * @param useBilinearMode defines if bilinear mode has to be used
  19965. * @return the generated texture
  19966. */
  19967. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  19968. /**
  19969. * Apply a post process to a texture
  19970. * @param postProcessName name of the fragment post process
  19971. * @param internalTexture the texture to encode
  19972. * @param scene the scene hosting the texture
  19973. * @param type type of the output texture. If not provided, use the one from internalTexture
  19974. * @param samplingMode sampling moode to use to sample the source texture. If not provided, use the one from internalTexture
  19975. * @param format format of the output texture. If not provided, use the one from internalTexture
  19976. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  19977. */
  19978. static ApplyPostProcess(postProcessName: string, internalTexture: InternalTexture, scene: Scene, type?: number, samplingMode?: number, format?: number): Promise<InternalTexture>;
  19979. }
  19980. }
  19981. declare module BABYLON {
  19982. /**
  19983. * Class used to host RGBD texture specific utilities
  19984. */
  19985. export class RGBDTextureTools {
  19986. /**
  19987. * Expand the RGBD Texture from RGBD to Half Float if possible.
  19988. * @param texture the texture to expand.
  19989. */
  19990. static ExpandRGBDTexture(texture: Texture): void;
  19991. /**
  19992. * Encode the texture to RGBD if possible.
  19993. * @param internalTexture the texture to encode
  19994. * @param scene the scene hosting the texture
  19995. * @param outputTextureType type of the texture in which the encoding is performed
  19996. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  19997. */
  19998. static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType?: number): Promise<InternalTexture>;
  19999. }
  20000. }
  20001. declare module BABYLON {
  20002. /**
  20003. * Class used to host texture specific utilities
  20004. */
  20005. export class BRDFTextureTools {
  20006. /**
  20007. * Prevents texture cache collision
  20008. */
  20009. private static _instanceNumber;
  20010. /**
  20011. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  20012. * @param scene defines the hosting scene
  20013. * @returns the environment BRDF texture
  20014. */
  20015. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  20016. private static _environmentBRDFBase64Texture;
  20017. }
  20018. }
  20019. declare module BABYLON {
  20020. /**
  20021. * @hidden
  20022. */
  20023. export interface IMaterialClearCoatDefines {
  20024. CLEARCOAT: boolean;
  20025. CLEARCOAT_DEFAULTIOR: boolean;
  20026. CLEARCOAT_TEXTURE: boolean;
  20027. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  20028. CLEARCOAT_TEXTUREDIRECTUV: number;
  20029. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  20030. CLEARCOAT_BUMP: boolean;
  20031. CLEARCOAT_BUMPDIRECTUV: number;
  20032. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20033. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20034. CLEARCOAT_REMAP_F0: boolean;
  20035. CLEARCOAT_TINT: boolean;
  20036. CLEARCOAT_TINT_TEXTURE: boolean;
  20037. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  20038. /** @hidden */
  20039. _areTexturesDirty: boolean;
  20040. }
  20041. /**
  20042. * Define the code related to the clear coat parameters of the pbr material.
  20043. */
  20044. export class PBRClearCoatConfiguration {
  20045. /**
  20046. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20047. * The default fits with a polyurethane material.
  20048. * @hidden
  20049. */
  20050. static readonly _DefaultIndexOfRefraction: number;
  20051. private _isEnabled;
  20052. /**
  20053. * Defines if the clear coat is enabled in the material.
  20054. */
  20055. isEnabled: boolean;
  20056. /**
  20057. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  20058. */
  20059. intensity: number;
  20060. /**
  20061. * Defines the clear coat layer roughness.
  20062. */
  20063. roughness: number;
  20064. private _indexOfRefraction;
  20065. /**
  20066. * Defines the index of refraction of the clear coat.
  20067. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20068. * The default fits with a polyurethane material.
  20069. * Changing the default value is more performance intensive.
  20070. */
  20071. indexOfRefraction: number;
  20072. private _texture;
  20073. /**
  20074. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  20075. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  20076. * if textureRoughness is not empty, else no texture roughness is used
  20077. */
  20078. texture: Nullable<BaseTexture>;
  20079. private _useRoughnessFromMainTexture;
  20080. /**
  20081. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  20082. * If false, the green channel from textureRoughness is used for roughness
  20083. */
  20084. useRoughnessFromMainTexture: boolean;
  20085. private _textureRoughness;
  20086. /**
  20087. * Stores the clear coat roughness in a texture (green channel)
  20088. * Not used if useRoughnessFromMainTexture is true
  20089. */
  20090. textureRoughness: Nullable<BaseTexture>;
  20091. private _remapF0OnInterfaceChange;
  20092. /**
  20093. * Defines if the F0 value should be remapped to account for the interface change in the material.
  20094. */
  20095. remapF0OnInterfaceChange: boolean;
  20096. private _bumpTexture;
  20097. /**
  20098. * Define the clear coat specific bump texture.
  20099. */
  20100. bumpTexture: Nullable<BaseTexture>;
  20101. private _isTintEnabled;
  20102. /**
  20103. * Defines if the clear coat tint is enabled in the material.
  20104. */
  20105. isTintEnabled: boolean;
  20106. /**
  20107. * Defines the clear coat tint of the material.
  20108. * This is only use if tint is enabled
  20109. */
  20110. tintColor: Color3;
  20111. /**
  20112. * Defines the distance at which the tint color should be found in the
  20113. * clear coat media.
  20114. * This is only use if tint is enabled
  20115. */
  20116. tintColorAtDistance: number;
  20117. /**
  20118. * Defines the clear coat layer thickness.
  20119. * This is only use if tint is enabled
  20120. */
  20121. tintThickness: number;
  20122. private _tintTexture;
  20123. /**
  20124. * Stores the clear tint values in a texture.
  20125. * rgb is tint
  20126. * a is a thickness factor
  20127. */
  20128. tintTexture: Nullable<BaseTexture>;
  20129. /** @hidden */
  20130. private _internalMarkAllSubMeshesAsTexturesDirty;
  20131. /** @hidden */
  20132. _markAllSubMeshesAsTexturesDirty(): void;
  20133. /**
  20134. * Instantiate a new istance of clear coat configuration.
  20135. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20136. */
  20137. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20138. /**
  20139. * Gets wehter the submesh is ready to be used or not.
  20140. * @param defines the list of "defines" to update.
  20141. * @param scene defines the scene the material belongs to.
  20142. * @param engine defines the engine the material belongs to.
  20143. * @param disableBumpMap defines wether the material disables bump or not.
  20144. * @returns - boolean indicating that the submesh is ready or not.
  20145. */
  20146. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  20147. /**
  20148. * Checks to see if a texture is used in the material.
  20149. * @param defines the list of "defines" to update.
  20150. * @param scene defines the scene to the material belongs to.
  20151. */
  20152. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  20153. /**
  20154. * Binds the material data.
  20155. * @param uniformBuffer defines the Uniform buffer to fill in.
  20156. * @param scene defines the scene the material belongs to.
  20157. * @param engine defines the engine the material belongs to.
  20158. * @param disableBumpMap defines wether the material disables bump or not.
  20159. * @param isFrozen defines wether the material is frozen or not.
  20160. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  20161. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  20162. * @param subMesh the submesh to bind data for
  20163. */
  20164. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  20165. /**
  20166. * Checks to see if a texture is used in the material.
  20167. * @param texture - Base texture to use.
  20168. * @returns - Boolean specifying if a texture is used in the material.
  20169. */
  20170. hasTexture(texture: BaseTexture): boolean;
  20171. /**
  20172. * Returns an array of the actively used textures.
  20173. * @param activeTextures Array of BaseTextures
  20174. */
  20175. getActiveTextures(activeTextures: BaseTexture[]): void;
  20176. /**
  20177. * Returns the animatable textures.
  20178. * @param animatables Array of animatable textures.
  20179. */
  20180. getAnimatables(animatables: IAnimatable[]): void;
  20181. /**
  20182. * Disposes the resources of the material.
  20183. * @param forceDisposeTextures - Forces the disposal of all textures.
  20184. */
  20185. dispose(forceDisposeTextures?: boolean): void;
  20186. /**
  20187. * Get the current class name of the texture useful for serialization or dynamic coding.
  20188. * @returns "PBRClearCoatConfiguration"
  20189. */
  20190. getClassName(): string;
  20191. /**
  20192. * Add fallbacks to the effect fallbacks list.
  20193. * @param defines defines the Base texture to use.
  20194. * @param fallbacks defines the current fallback list.
  20195. * @param currentRank defines the current fallback rank.
  20196. * @returns the new fallback rank.
  20197. */
  20198. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20199. /**
  20200. * Add the required uniforms to the current list.
  20201. * @param uniforms defines the current uniform list.
  20202. */
  20203. static AddUniforms(uniforms: string[]): void;
  20204. /**
  20205. * Add the required samplers to the current list.
  20206. * @param samplers defines the current sampler list.
  20207. */
  20208. static AddSamplers(samplers: string[]): void;
  20209. /**
  20210. * Add the required uniforms to the current buffer.
  20211. * @param uniformBuffer defines the current uniform buffer.
  20212. */
  20213. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20214. /**
  20215. * Makes a duplicate of the current configuration into another one.
  20216. * @param clearCoatConfiguration define the config where to copy the info
  20217. */
  20218. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  20219. /**
  20220. * Serializes this clear coat configuration.
  20221. * @returns - An object with the serialized config.
  20222. */
  20223. serialize(): any;
  20224. /**
  20225. * Parses a anisotropy Configuration from a serialized object.
  20226. * @param source - Serialized object.
  20227. * @param scene Defines the scene we are parsing for
  20228. * @param rootUrl Defines the rootUrl to load from
  20229. */
  20230. parse(source: any, scene: Scene, rootUrl: string): void;
  20231. }
  20232. }
  20233. declare module BABYLON {
  20234. /**
  20235. * @hidden
  20236. */
  20237. export interface IMaterialAnisotropicDefines {
  20238. ANISOTROPIC: boolean;
  20239. ANISOTROPIC_TEXTURE: boolean;
  20240. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20241. MAINUV1: boolean;
  20242. _areTexturesDirty: boolean;
  20243. _needUVs: boolean;
  20244. }
  20245. /**
  20246. * Define the code related to the anisotropic parameters of the pbr material.
  20247. */
  20248. export class PBRAnisotropicConfiguration {
  20249. private _isEnabled;
  20250. /**
  20251. * Defines if the anisotropy is enabled in the material.
  20252. */
  20253. isEnabled: boolean;
  20254. /**
  20255. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  20256. */
  20257. intensity: number;
  20258. /**
  20259. * Defines if the effect is along the tangents, bitangents or in between.
  20260. * By default, the effect is "strectching" the highlights along the tangents.
  20261. */
  20262. direction: Vector2;
  20263. private _texture;
  20264. /**
  20265. * Stores the anisotropy values in a texture.
  20266. * rg is direction (like normal from -1 to 1)
  20267. * b is a intensity
  20268. */
  20269. texture: Nullable<BaseTexture>;
  20270. /** @hidden */
  20271. private _internalMarkAllSubMeshesAsTexturesDirty;
  20272. /** @hidden */
  20273. _markAllSubMeshesAsTexturesDirty(): void;
  20274. /**
  20275. * Instantiate a new istance of anisotropy configuration.
  20276. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20277. */
  20278. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20279. /**
  20280. * Specifies that the submesh is ready to be used.
  20281. * @param defines the list of "defines" to update.
  20282. * @param scene defines the scene the material belongs to.
  20283. * @returns - boolean indicating that the submesh is ready or not.
  20284. */
  20285. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  20286. /**
  20287. * Checks to see if a texture is used in the material.
  20288. * @param defines the list of "defines" to update.
  20289. * @param mesh the mesh we are preparing the defines for.
  20290. * @param scene defines the scene the material belongs to.
  20291. */
  20292. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  20293. /**
  20294. * Binds the material data.
  20295. * @param uniformBuffer defines the Uniform buffer to fill in.
  20296. * @param scene defines the scene the material belongs to.
  20297. * @param isFrozen defines wether the material is frozen or not.
  20298. */
  20299. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  20300. /**
  20301. * Checks to see if a texture is used in the material.
  20302. * @param texture - Base texture to use.
  20303. * @returns - Boolean specifying if a texture is used in the material.
  20304. */
  20305. hasTexture(texture: BaseTexture): boolean;
  20306. /**
  20307. * Returns an array of the actively used textures.
  20308. * @param activeTextures Array of BaseTextures
  20309. */
  20310. getActiveTextures(activeTextures: BaseTexture[]): void;
  20311. /**
  20312. * Returns the animatable textures.
  20313. * @param animatables Array of animatable textures.
  20314. */
  20315. getAnimatables(animatables: IAnimatable[]): void;
  20316. /**
  20317. * Disposes the resources of the material.
  20318. * @param forceDisposeTextures - Forces the disposal of all textures.
  20319. */
  20320. dispose(forceDisposeTextures?: boolean): void;
  20321. /**
  20322. * Get the current class name of the texture useful for serialization or dynamic coding.
  20323. * @returns "PBRAnisotropicConfiguration"
  20324. */
  20325. getClassName(): string;
  20326. /**
  20327. * Add fallbacks to the effect fallbacks list.
  20328. * @param defines defines the Base texture to use.
  20329. * @param fallbacks defines the current fallback list.
  20330. * @param currentRank defines the current fallback rank.
  20331. * @returns the new fallback rank.
  20332. */
  20333. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20334. /**
  20335. * Add the required uniforms to the current list.
  20336. * @param uniforms defines the current uniform list.
  20337. */
  20338. static AddUniforms(uniforms: string[]): void;
  20339. /**
  20340. * Add the required uniforms to the current buffer.
  20341. * @param uniformBuffer defines the current uniform buffer.
  20342. */
  20343. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20344. /**
  20345. * Add the required samplers to the current list.
  20346. * @param samplers defines the current sampler list.
  20347. */
  20348. static AddSamplers(samplers: string[]): void;
  20349. /**
  20350. * Makes a duplicate of the current configuration into another one.
  20351. * @param anisotropicConfiguration define the config where to copy the info
  20352. */
  20353. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  20354. /**
  20355. * Serializes this anisotropy configuration.
  20356. * @returns - An object with the serialized config.
  20357. */
  20358. serialize(): any;
  20359. /**
  20360. * Parses a anisotropy Configuration from a serialized object.
  20361. * @param source - Serialized object.
  20362. * @param scene Defines the scene we are parsing for
  20363. * @param rootUrl Defines the rootUrl to load from
  20364. */
  20365. parse(source: any, scene: Scene, rootUrl: string): void;
  20366. }
  20367. }
  20368. declare module BABYLON {
  20369. /**
  20370. * @hidden
  20371. */
  20372. export interface IMaterialBRDFDefines {
  20373. BRDF_V_HEIGHT_CORRELATED: boolean;
  20374. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20375. SPHERICAL_HARMONICS: boolean;
  20376. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20377. /** @hidden */
  20378. _areMiscDirty: boolean;
  20379. }
  20380. /**
  20381. * Define the code related to the BRDF parameters of the pbr material.
  20382. */
  20383. export class PBRBRDFConfiguration {
  20384. /**
  20385. * Default value used for the energy conservation.
  20386. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20387. */
  20388. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  20389. /**
  20390. * Default value used for the Smith Visibility Height Correlated mode.
  20391. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20392. */
  20393. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  20394. /**
  20395. * Default value used for the IBL diffuse part.
  20396. * This can help switching back to the polynomials mode globally which is a tiny bit
  20397. * less GPU intensive at the drawback of a lower quality.
  20398. */
  20399. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  20400. /**
  20401. * Default value used for activating energy conservation for the specular workflow.
  20402. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20403. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20404. */
  20405. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  20406. private _useEnergyConservation;
  20407. /**
  20408. * Defines if the material uses energy conservation.
  20409. */
  20410. useEnergyConservation: boolean;
  20411. private _useSmithVisibilityHeightCorrelated;
  20412. /**
  20413. * LEGACY Mode set to false
  20414. * Defines if the material uses height smith correlated visibility term.
  20415. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  20416. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  20417. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  20418. * Not relying on height correlated will also disable energy conservation.
  20419. */
  20420. useSmithVisibilityHeightCorrelated: boolean;
  20421. private _useSphericalHarmonics;
  20422. /**
  20423. * LEGACY Mode set to false
  20424. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  20425. * diffuse part of the IBL.
  20426. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  20427. * to the ground truth.
  20428. */
  20429. useSphericalHarmonics: boolean;
  20430. private _useSpecularGlossinessInputEnergyConservation;
  20431. /**
  20432. * Defines if the material uses energy conservation, when the specular workflow is active.
  20433. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20434. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20435. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  20436. */
  20437. useSpecularGlossinessInputEnergyConservation: boolean;
  20438. /** @hidden */
  20439. private _internalMarkAllSubMeshesAsMiscDirty;
  20440. /** @hidden */
  20441. _markAllSubMeshesAsMiscDirty(): void;
  20442. /**
  20443. * Instantiate a new istance of clear coat configuration.
  20444. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  20445. */
  20446. constructor(markAllSubMeshesAsMiscDirty: () => void);
  20447. /**
  20448. * Checks to see if a texture is used in the material.
  20449. * @param defines the list of "defines" to update.
  20450. */
  20451. prepareDefines(defines: IMaterialBRDFDefines): void;
  20452. /**
  20453. * Get the current class name of the texture useful for serialization or dynamic coding.
  20454. * @returns "PBRClearCoatConfiguration"
  20455. */
  20456. getClassName(): string;
  20457. /**
  20458. * Makes a duplicate of the current configuration into another one.
  20459. * @param brdfConfiguration define the config where to copy the info
  20460. */
  20461. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  20462. /**
  20463. * Serializes this BRDF configuration.
  20464. * @returns - An object with the serialized config.
  20465. */
  20466. serialize(): any;
  20467. /**
  20468. * Parses a anisotropy Configuration from a serialized object.
  20469. * @param source - Serialized object.
  20470. * @param scene Defines the scene we are parsing for
  20471. * @param rootUrl Defines the rootUrl to load from
  20472. */
  20473. parse(source: any, scene: Scene, rootUrl: string): void;
  20474. }
  20475. }
  20476. declare module BABYLON {
  20477. /**
  20478. * @hidden
  20479. */
  20480. export interface IMaterialSheenDefines {
  20481. SHEEN: boolean;
  20482. SHEEN_TEXTURE: boolean;
  20483. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20484. SHEEN_TEXTUREDIRECTUV: number;
  20485. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20486. SHEEN_LINKWITHALBEDO: boolean;
  20487. SHEEN_ROUGHNESS: boolean;
  20488. SHEEN_ALBEDOSCALING: boolean;
  20489. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20490. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20491. /** @hidden */
  20492. _areTexturesDirty: boolean;
  20493. }
  20494. /**
  20495. * Define the code related to the Sheen parameters of the pbr material.
  20496. */
  20497. export class PBRSheenConfiguration {
  20498. private _isEnabled;
  20499. /**
  20500. * Defines if the material uses sheen.
  20501. */
  20502. isEnabled: boolean;
  20503. private _linkSheenWithAlbedo;
  20504. /**
  20505. * Defines if the sheen is linked to the sheen color.
  20506. */
  20507. linkSheenWithAlbedo: boolean;
  20508. /**
  20509. * Defines the sheen intensity.
  20510. */
  20511. intensity: number;
  20512. /**
  20513. * Defines the sheen color.
  20514. */
  20515. color: Color3;
  20516. private _texture;
  20517. /**
  20518. * Stores the sheen tint values in a texture.
  20519. * rgb is tint
  20520. * a is a intensity or roughness if the roughness property has been defined and useRoughnessFromTexture is true (in that case, textureRoughness won't be used)
  20521. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  20522. */
  20523. texture: Nullable<BaseTexture>;
  20524. private _useRoughnessFromMainTexture;
  20525. /**
  20526. * Indicates that the alpha channel of the texture property will be used for roughness.
  20527. * Has no effect if the roughness (and texture!) property is not defined
  20528. */
  20529. useRoughnessFromMainTexture: boolean;
  20530. private _roughness;
  20531. /**
  20532. * Defines the sheen roughness.
  20533. * It is not taken into account if linkSheenWithAlbedo is true.
  20534. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  20535. */
  20536. roughness: Nullable<number>;
  20537. private _textureRoughness;
  20538. /**
  20539. * Stores the sheen roughness in a texture.
  20540. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  20541. */
  20542. textureRoughness: Nullable<BaseTexture>;
  20543. private _albedoScaling;
  20544. /**
  20545. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  20546. * It allows the strength of the sheen effect to not depend on the base color of the material,
  20547. * making it easier to setup and tweak the effect
  20548. */
  20549. albedoScaling: boolean;
  20550. /** @hidden */
  20551. private _internalMarkAllSubMeshesAsTexturesDirty;
  20552. /** @hidden */
  20553. _markAllSubMeshesAsTexturesDirty(): void;
  20554. /**
  20555. * Instantiate a new istance of clear coat configuration.
  20556. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20557. */
  20558. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20559. /**
  20560. * Specifies that the submesh is ready to be used.
  20561. * @param defines the list of "defines" to update.
  20562. * @param scene defines the scene the material belongs to.
  20563. * @returns - boolean indicating that the submesh is ready or not.
  20564. */
  20565. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  20566. /**
  20567. * Checks to see if a texture is used in the material.
  20568. * @param defines the list of "defines" to update.
  20569. * @param scene defines the scene the material belongs to.
  20570. */
  20571. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  20572. /**
  20573. * Binds the material data.
  20574. * @param uniformBuffer defines the Uniform buffer to fill in.
  20575. * @param scene defines the scene the material belongs to.
  20576. * @param isFrozen defines wether the material is frozen or not.
  20577. * @param subMesh the submesh to bind data for
  20578. */
  20579. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  20580. /**
  20581. * Checks to see if a texture is used in the material.
  20582. * @param texture - Base texture to use.
  20583. * @returns - Boolean specifying if a texture is used in the material.
  20584. */
  20585. hasTexture(texture: BaseTexture): boolean;
  20586. /**
  20587. * Returns an array of the actively used textures.
  20588. * @param activeTextures Array of BaseTextures
  20589. */
  20590. getActiveTextures(activeTextures: BaseTexture[]): void;
  20591. /**
  20592. * Returns the animatable textures.
  20593. * @param animatables Array of animatable textures.
  20594. */
  20595. getAnimatables(animatables: IAnimatable[]): void;
  20596. /**
  20597. * Disposes the resources of the material.
  20598. * @param forceDisposeTextures - Forces the disposal of all textures.
  20599. */
  20600. dispose(forceDisposeTextures?: boolean): void;
  20601. /**
  20602. * Get the current class name of the texture useful for serialization or dynamic coding.
  20603. * @returns "PBRSheenConfiguration"
  20604. */
  20605. getClassName(): string;
  20606. /**
  20607. * Add fallbacks to the effect fallbacks list.
  20608. * @param defines defines the Base texture to use.
  20609. * @param fallbacks defines the current fallback list.
  20610. * @param currentRank defines the current fallback rank.
  20611. * @returns the new fallback rank.
  20612. */
  20613. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20614. /**
  20615. * Add the required uniforms to the current list.
  20616. * @param uniforms defines the current uniform list.
  20617. */
  20618. static AddUniforms(uniforms: string[]): void;
  20619. /**
  20620. * Add the required uniforms to the current buffer.
  20621. * @param uniformBuffer defines the current uniform buffer.
  20622. */
  20623. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20624. /**
  20625. * Add the required samplers to the current list.
  20626. * @param samplers defines the current sampler list.
  20627. */
  20628. static AddSamplers(samplers: string[]): void;
  20629. /**
  20630. * Makes a duplicate of the current configuration into another one.
  20631. * @param sheenConfiguration define the config where to copy the info
  20632. */
  20633. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  20634. /**
  20635. * Serializes this BRDF configuration.
  20636. * @returns - An object with the serialized config.
  20637. */
  20638. serialize(): any;
  20639. /**
  20640. * Parses a anisotropy Configuration from a serialized object.
  20641. * @param source - Serialized object.
  20642. * @param scene Defines the scene we are parsing for
  20643. * @param rootUrl Defines the rootUrl to load from
  20644. */
  20645. parse(source: any, scene: Scene, rootUrl: string): void;
  20646. }
  20647. }
  20648. declare module BABYLON {
  20649. /**
  20650. * @hidden
  20651. */
  20652. export interface IMaterialSubSurfaceDefines {
  20653. SUBSURFACE: boolean;
  20654. SS_REFRACTION: boolean;
  20655. SS_TRANSLUCENCY: boolean;
  20656. SS_SCATTERING: boolean;
  20657. SS_THICKNESSANDMASK_TEXTURE: boolean;
  20658. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  20659. SS_REFRACTIONMAP_3D: boolean;
  20660. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  20661. SS_LODINREFRACTIONALPHA: boolean;
  20662. SS_GAMMAREFRACTION: boolean;
  20663. SS_RGBDREFRACTION: boolean;
  20664. SS_LINEARSPECULARREFRACTION: boolean;
  20665. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  20666. SS_ALBEDOFORREFRACTIONTINT: boolean;
  20667. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  20668. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  20669. /** @hidden */
  20670. _areTexturesDirty: boolean;
  20671. }
  20672. /**
  20673. * Define the code related to the sub surface parameters of the pbr material.
  20674. */
  20675. export class PBRSubSurfaceConfiguration {
  20676. private _isRefractionEnabled;
  20677. /**
  20678. * Defines if the refraction is enabled in the material.
  20679. */
  20680. isRefractionEnabled: boolean;
  20681. private _isTranslucencyEnabled;
  20682. /**
  20683. * Defines if the translucency is enabled in the material.
  20684. */
  20685. isTranslucencyEnabled: boolean;
  20686. private _isScatteringEnabled;
  20687. /**
  20688. * Defines if the sub surface scattering is enabled in the material.
  20689. */
  20690. isScatteringEnabled: boolean;
  20691. private _scatteringDiffusionProfileIndex;
  20692. /**
  20693. * Diffusion profile for subsurface scattering.
  20694. * Useful for better scattering in the skins or foliages.
  20695. */
  20696. get scatteringDiffusionProfile(): Nullable<Color3>;
  20697. set scatteringDiffusionProfile(c: Nullable<Color3>);
  20698. /**
  20699. * Defines the refraction intensity of the material.
  20700. * The refraction when enabled replaces the Diffuse part of the material.
  20701. * The intensity helps transitionning between diffuse and refraction.
  20702. */
  20703. refractionIntensity: number;
  20704. /**
  20705. * Defines the translucency intensity of the material.
  20706. * When translucency has been enabled, this defines how much of the "translucency"
  20707. * is addded to the diffuse part of the material.
  20708. */
  20709. translucencyIntensity: number;
  20710. /**
  20711. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  20712. */
  20713. useAlbedoToTintRefraction: boolean;
  20714. private _thicknessTexture;
  20715. /**
  20716. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  20717. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  20718. * 0 would mean minimumThickness
  20719. * 1 would mean maximumThickness
  20720. * The other channels might be use as a mask to vary the different effects intensity.
  20721. */
  20722. thicknessTexture: Nullable<BaseTexture>;
  20723. private _refractionTexture;
  20724. /**
  20725. * Defines the texture to use for refraction.
  20726. */
  20727. refractionTexture: Nullable<BaseTexture>;
  20728. private _indexOfRefraction;
  20729. /**
  20730. * Index of refraction of the material base layer.
  20731. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20732. *
  20733. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  20734. *
  20735. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  20736. */
  20737. indexOfRefraction: number;
  20738. private _volumeIndexOfRefraction;
  20739. /**
  20740. * Index of refraction of the material's volume.
  20741. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20742. *
  20743. * This ONLY impacts refraction. If not provided or given a non-valid value,
  20744. * the volume will use the same IOR as the surface.
  20745. */
  20746. get volumeIndexOfRefraction(): number;
  20747. set volumeIndexOfRefraction(value: number);
  20748. private _invertRefractionY;
  20749. /**
  20750. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20751. */
  20752. invertRefractionY: boolean;
  20753. private _linkRefractionWithTransparency;
  20754. /**
  20755. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20756. * Materials half opaque for instance using refraction could benefit from this control.
  20757. */
  20758. linkRefractionWithTransparency: boolean;
  20759. /**
  20760. * Defines the minimum thickness stored in the thickness map.
  20761. * If no thickness map is defined, this value will be used to simulate thickness.
  20762. */
  20763. minimumThickness: number;
  20764. /**
  20765. * Defines the maximum thickness stored in the thickness map.
  20766. */
  20767. maximumThickness: number;
  20768. /**
  20769. * Defines the volume tint of the material.
  20770. * This is used for both translucency and scattering.
  20771. */
  20772. tintColor: Color3;
  20773. /**
  20774. * Defines the distance at which the tint color should be found in the media.
  20775. * This is used for refraction only.
  20776. */
  20777. tintColorAtDistance: number;
  20778. /**
  20779. * Defines how far each channel transmit through the media.
  20780. * It is defined as a color to simplify it selection.
  20781. */
  20782. diffusionDistance: Color3;
  20783. private _useMaskFromThicknessTexture;
  20784. /**
  20785. * Stores the intensity of the different subsurface effects in the thickness texture.
  20786. * * the green channel is the translucency intensity.
  20787. * * the blue channel is the scattering intensity.
  20788. * * the alpha channel is the refraction intensity.
  20789. */
  20790. useMaskFromThicknessTexture: boolean;
  20791. private _scene;
  20792. private _useMaskFromThicknessTextureGltf;
  20793. /**
  20794. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  20795. * matches the channel-packing that is used by glTF.
  20796. * * the red channel is the transmission/translucency intensity.
  20797. * * the green channel is the thickness.
  20798. */
  20799. useMaskFromThicknessTextureGltf: boolean;
  20800. /** @hidden */
  20801. private _internalMarkAllSubMeshesAsTexturesDirty;
  20802. private _internalMarkScenePrePassDirty;
  20803. /** @hidden */
  20804. _markAllSubMeshesAsTexturesDirty(): void;
  20805. /** @hidden */
  20806. _markScenePrePassDirty(): void;
  20807. /**
  20808. * Instantiate a new istance of sub surface configuration.
  20809. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20810. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  20811. * @param scene The scene
  20812. */
  20813. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  20814. /**
  20815. * Gets wehter the submesh is ready to be used or not.
  20816. * @param defines the list of "defines" to update.
  20817. * @param scene defines the scene the material belongs to.
  20818. * @returns - boolean indicating that the submesh is ready or not.
  20819. */
  20820. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  20821. /**
  20822. * Checks to see if a texture is used in the material.
  20823. * @param defines the list of "defines" to update.
  20824. * @param scene defines the scene to the material belongs to.
  20825. */
  20826. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  20827. /**
  20828. * Binds the material data.
  20829. * @param uniformBuffer defines the Uniform buffer to fill in.
  20830. * @param scene defines the scene the material belongs to.
  20831. * @param engine defines the engine the material belongs to.
  20832. * @param isFrozen defines whether the material is frozen or not.
  20833. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  20834. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  20835. */
  20836. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  20837. /**
  20838. * Unbinds the material from the mesh.
  20839. * @param activeEffect defines the effect that should be unbound from.
  20840. * @returns true if unbound, otherwise false
  20841. */
  20842. unbind(activeEffect: Effect): boolean;
  20843. /**
  20844. * Returns the texture used for refraction or null if none is used.
  20845. * @param scene defines the scene the material belongs to.
  20846. * @returns - Refraction texture if present. If no refraction texture and refraction
  20847. * is linked with transparency, returns environment texture. Otherwise, returns null.
  20848. */
  20849. private _getRefractionTexture;
  20850. /**
  20851. * Returns true if alpha blending should be disabled.
  20852. */
  20853. get disableAlphaBlending(): boolean;
  20854. /**
  20855. * Fills the list of render target textures.
  20856. * @param renderTargets the list of render targets to update
  20857. */
  20858. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  20859. /**
  20860. * Checks to see if a texture is used in the material.
  20861. * @param texture - Base texture to use.
  20862. * @returns - Boolean specifying if a texture is used in the material.
  20863. */
  20864. hasTexture(texture: BaseTexture): boolean;
  20865. /**
  20866. * Gets a boolean indicating that current material needs to register RTT
  20867. * @returns true if this uses a render target otherwise false.
  20868. */
  20869. hasRenderTargetTextures(): boolean;
  20870. /**
  20871. * Returns an array of the actively used textures.
  20872. * @param activeTextures Array of BaseTextures
  20873. */
  20874. getActiveTextures(activeTextures: BaseTexture[]): void;
  20875. /**
  20876. * Returns the animatable textures.
  20877. * @param animatables Array of animatable textures.
  20878. */
  20879. getAnimatables(animatables: IAnimatable[]): void;
  20880. /**
  20881. * Disposes the resources of the material.
  20882. * @param forceDisposeTextures - Forces the disposal of all textures.
  20883. */
  20884. dispose(forceDisposeTextures?: boolean): void;
  20885. /**
  20886. * Get the current class name of the texture useful for serialization or dynamic coding.
  20887. * @returns "PBRSubSurfaceConfiguration"
  20888. */
  20889. getClassName(): string;
  20890. /**
  20891. * Add fallbacks to the effect fallbacks list.
  20892. * @param defines defines the Base texture to use.
  20893. * @param fallbacks defines the current fallback list.
  20894. * @param currentRank defines the current fallback rank.
  20895. * @returns the new fallback rank.
  20896. */
  20897. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20898. /**
  20899. * Add the required uniforms to the current list.
  20900. * @param uniforms defines the current uniform list.
  20901. */
  20902. static AddUniforms(uniforms: string[]): void;
  20903. /**
  20904. * Add the required samplers to the current list.
  20905. * @param samplers defines the current sampler list.
  20906. */
  20907. static AddSamplers(samplers: string[]): void;
  20908. /**
  20909. * Add the required uniforms to the current buffer.
  20910. * @param uniformBuffer defines the current uniform buffer.
  20911. */
  20912. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20913. /**
  20914. * Makes a duplicate of the current configuration into another one.
  20915. * @param configuration define the config where to copy the info
  20916. */
  20917. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  20918. /**
  20919. * Serializes this Sub Surface configuration.
  20920. * @returns - An object with the serialized config.
  20921. */
  20922. serialize(): any;
  20923. /**
  20924. * Parses a anisotropy Configuration from a serialized object.
  20925. * @param source - Serialized object.
  20926. * @param scene Defines the scene we are parsing for
  20927. * @param rootUrl Defines the rootUrl to load from
  20928. */
  20929. parse(source: any, scene: Scene, rootUrl: string): void;
  20930. }
  20931. }
  20932. declare module BABYLON {
  20933. /**
  20934. * Class representing spherical harmonics coefficients to the 3rd degree
  20935. */
  20936. export class SphericalHarmonics {
  20937. /**
  20938. * Defines whether or not the harmonics have been prescaled for rendering.
  20939. */
  20940. preScaled: boolean;
  20941. /**
  20942. * The l0,0 coefficients of the spherical harmonics
  20943. */
  20944. l00: Vector3;
  20945. /**
  20946. * The l1,-1 coefficients of the spherical harmonics
  20947. */
  20948. l1_1: Vector3;
  20949. /**
  20950. * The l1,0 coefficients of the spherical harmonics
  20951. */
  20952. l10: Vector3;
  20953. /**
  20954. * The l1,1 coefficients of the spherical harmonics
  20955. */
  20956. l11: Vector3;
  20957. /**
  20958. * The l2,-2 coefficients of the spherical harmonics
  20959. */
  20960. l2_2: Vector3;
  20961. /**
  20962. * The l2,-1 coefficients of the spherical harmonics
  20963. */
  20964. l2_1: Vector3;
  20965. /**
  20966. * The l2,0 coefficients of the spherical harmonics
  20967. */
  20968. l20: Vector3;
  20969. /**
  20970. * The l2,1 coefficients of the spherical harmonics
  20971. */
  20972. l21: Vector3;
  20973. /**
  20974. * The l2,2 coefficients of the spherical harmonics
  20975. */
  20976. l22: Vector3;
  20977. /**
  20978. * Adds a light to the spherical harmonics
  20979. * @param direction the direction of the light
  20980. * @param color the color of the light
  20981. * @param deltaSolidAngle the delta solid angle of the light
  20982. */
  20983. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  20984. /**
  20985. * Scales the spherical harmonics by the given amount
  20986. * @param scale the amount to scale
  20987. */
  20988. scaleInPlace(scale: number): void;
  20989. /**
  20990. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  20991. *
  20992. * ```
  20993. * E_lm = A_l * L_lm
  20994. * ```
  20995. *
  20996. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  20997. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  20998. * the scaling factors are given in equation 9.
  20999. */
  21000. convertIncidentRadianceToIrradiance(): void;
  21001. /**
  21002. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  21003. *
  21004. * ```
  21005. * L = (1/pi) * E * rho
  21006. * ```
  21007. *
  21008. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  21009. */
  21010. convertIrradianceToLambertianRadiance(): void;
  21011. /**
  21012. * Integrates the reconstruction coefficients directly in to the SH preventing further
  21013. * required operations at run time.
  21014. *
  21015. * This is simply done by scaling back the SH with Ylm constants parameter.
  21016. * The trigonometric part being applied by the shader at run time.
  21017. */
  21018. preScaleForRendering(): void;
  21019. /**
  21020. * Constructs a spherical harmonics from an array.
  21021. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  21022. * @returns the spherical harmonics
  21023. */
  21024. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  21025. /**
  21026. * Gets the spherical harmonics from polynomial
  21027. * @param polynomial the spherical polynomial
  21028. * @returns the spherical harmonics
  21029. */
  21030. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  21031. }
  21032. /**
  21033. * Class representing spherical polynomial coefficients to the 3rd degree
  21034. */
  21035. export class SphericalPolynomial {
  21036. private _harmonics;
  21037. /**
  21038. * The spherical harmonics used to create the polynomials.
  21039. */
  21040. get preScaledHarmonics(): SphericalHarmonics;
  21041. /**
  21042. * The x coefficients of the spherical polynomial
  21043. */
  21044. x: Vector3;
  21045. /**
  21046. * The y coefficients of the spherical polynomial
  21047. */
  21048. y: Vector3;
  21049. /**
  21050. * The z coefficients of the spherical polynomial
  21051. */
  21052. z: Vector3;
  21053. /**
  21054. * The xx coefficients of the spherical polynomial
  21055. */
  21056. xx: Vector3;
  21057. /**
  21058. * The yy coefficients of the spherical polynomial
  21059. */
  21060. yy: Vector3;
  21061. /**
  21062. * The zz coefficients of the spherical polynomial
  21063. */
  21064. zz: Vector3;
  21065. /**
  21066. * The xy coefficients of the spherical polynomial
  21067. */
  21068. xy: Vector3;
  21069. /**
  21070. * The yz coefficients of the spherical polynomial
  21071. */
  21072. yz: Vector3;
  21073. /**
  21074. * The zx coefficients of the spherical polynomial
  21075. */
  21076. zx: Vector3;
  21077. /**
  21078. * Adds an ambient color to the spherical polynomial
  21079. * @param color the color to add
  21080. */
  21081. addAmbient(color: Color3): void;
  21082. /**
  21083. * Scales the spherical polynomial by the given amount
  21084. * @param scale the amount to scale
  21085. */
  21086. scaleInPlace(scale: number): void;
  21087. /**
  21088. * Gets the spherical polynomial from harmonics
  21089. * @param harmonics the spherical harmonics
  21090. * @returns the spherical polynomial
  21091. */
  21092. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  21093. /**
  21094. * Constructs a spherical polynomial from an array.
  21095. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  21096. * @returns the spherical polynomial
  21097. */
  21098. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  21099. }
  21100. }
  21101. declare module BABYLON {
  21102. /**
  21103. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  21104. */
  21105. export interface CubeMapInfo {
  21106. /**
  21107. * The pixel array for the front face.
  21108. * This is stored in format, left to right, up to down format.
  21109. */
  21110. front: Nullable<ArrayBufferView>;
  21111. /**
  21112. * The pixel array for the back face.
  21113. * This is stored in format, left to right, up to down format.
  21114. */
  21115. back: Nullable<ArrayBufferView>;
  21116. /**
  21117. * The pixel array for the left face.
  21118. * This is stored in format, left to right, up to down format.
  21119. */
  21120. left: Nullable<ArrayBufferView>;
  21121. /**
  21122. * The pixel array for the right face.
  21123. * This is stored in format, left to right, up to down format.
  21124. */
  21125. right: Nullable<ArrayBufferView>;
  21126. /**
  21127. * The pixel array for the up face.
  21128. * This is stored in format, left to right, up to down format.
  21129. */
  21130. up: Nullable<ArrayBufferView>;
  21131. /**
  21132. * The pixel array for the down face.
  21133. * This is stored in format, left to right, up to down format.
  21134. */
  21135. down: Nullable<ArrayBufferView>;
  21136. /**
  21137. * The size of the cubemap stored.
  21138. *
  21139. * Each faces will be size * size pixels.
  21140. */
  21141. size: number;
  21142. /**
  21143. * The format of the texture.
  21144. *
  21145. * RGBA, RGB.
  21146. */
  21147. format: number;
  21148. /**
  21149. * The type of the texture data.
  21150. *
  21151. * UNSIGNED_INT, FLOAT.
  21152. */
  21153. type: number;
  21154. /**
  21155. * Specifies whether the texture is in gamma space.
  21156. */
  21157. gammaSpace: boolean;
  21158. }
  21159. /**
  21160. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  21161. */
  21162. export class PanoramaToCubeMapTools {
  21163. private static FACE_LEFT;
  21164. private static FACE_RIGHT;
  21165. private static FACE_FRONT;
  21166. private static FACE_BACK;
  21167. private static FACE_DOWN;
  21168. private static FACE_UP;
  21169. /**
  21170. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  21171. *
  21172. * @param float32Array The source data.
  21173. * @param inputWidth The width of the input panorama.
  21174. * @param inputHeight The height of the input panorama.
  21175. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  21176. * @return The cubemap data
  21177. */
  21178. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  21179. private static CreateCubemapTexture;
  21180. private static CalcProjectionSpherical;
  21181. }
  21182. }
  21183. declare module BABYLON {
  21184. /**
  21185. * Helper class dealing with the extraction of spherical polynomial dataArray
  21186. * from a cube map.
  21187. */
  21188. export class CubeMapToSphericalPolynomialTools {
  21189. private static FileFaces;
  21190. /**
  21191. * Converts a texture to the according Spherical Polynomial data.
  21192. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21193. *
  21194. * @param texture The texture to extract the information from.
  21195. * @return The Spherical Polynomial data.
  21196. */
  21197. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<Promise<SphericalPolynomial>>;
  21198. /**
  21199. * Converts a cubemap to the according Spherical Polynomial data.
  21200. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21201. *
  21202. * @param cubeInfo The Cube map to extract the information from.
  21203. * @return The Spherical Polynomial data.
  21204. */
  21205. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  21206. }
  21207. }
  21208. declare module BABYLON {
  21209. interface BaseTexture {
  21210. /**
  21211. * Get the polynomial representation of the texture data.
  21212. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  21213. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  21214. */
  21215. sphericalPolynomial: Nullable<SphericalPolynomial>;
  21216. }
  21217. }
  21218. declare module BABYLON {
  21219. /** @hidden */
  21220. export var pbrFragmentDeclaration: {
  21221. name: string;
  21222. shader: string;
  21223. };
  21224. }
  21225. declare module BABYLON {
  21226. /** @hidden */
  21227. export var pbrUboDeclaration: {
  21228. name: string;
  21229. shader: string;
  21230. };
  21231. }
  21232. declare module BABYLON {
  21233. /** @hidden */
  21234. export var pbrFragmentExtraDeclaration: {
  21235. name: string;
  21236. shader: string;
  21237. };
  21238. }
  21239. declare module BABYLON {
  21240. /** @hidden */
  21241. export var pbrFragmentSamplersDeclaration: {
  21242. name: string;
  21243. shader: string;
  21244. };
  21245. }
  21246. declare module BABYLON {
  21247. /** @hidden */
  21248. export var subSurfaceScatteringFunctions: {
  21249. name: string;
  21250. shader: string;
  21251. };
  21252. }
  21253. declare module BABYLON {
  21254. /** @hidden */
  21255. export var importanceSampling: {
  21256. name: string;
  21257. shader: string;
  21258. };
  21259. }
  21260. declare module BABYLON {
  21261. /** @hidden */
  21262. export var pbrHelperFunctions: {
  21263. name: string;
  21264. shader: string;
  21265. };
  21266. }
  21267. declare module BABYLON {
  21268. /** @hidden */
  21269. export var harmonicsFunctions: {
  21270. name: string;
  21271. shader: string;
  21272. };
  21273. }
  21274. declare module BABYLON {
  21275. /** @hidden */
  21276. export var pbrDirectLightingSetupFunctions: {
  21277. name: string;
  21278. shader: string;
  21279. };
  21280. }
  21281. declare module BABYLON {
  21282. /** @hidden */
  21283. export var pbrDirectLightingFalloffFunctions: {
  21284. name: string;
  21285. shader: string;
  21286. };
  21287. }
  21288. declare module BABYLON {
  21289. /** @hidden */
  21290. export var pbrBRDFFunctions: {
  21291. name: string;
  21292. shader: string;
  21293. };
  21294. }
  21295. declare module BABYLON {
  21296. /** @hidden */
  21297. export var hdrFilteringFunctions: {
  21298. name: string;
  21299. shader: string;
  21300. };
  21301. }
  21302. declare module BABYLON {
  21303. /** @hidden */
  21304. export var pbrDirectLightingFunctions: {
  21305. name: string;
  21306. shader: string;
  21307. };
  21308. }
  21309. declare module BABYLON {
  21310. /** @hidden */
  21311. export var pbrIBLFunctions: {
  21312. name: string;
  21313. shader: string;
  21314. };
  21315. }
  21316. declare module BABYLON {
  21317. /** @hidden */
  21318. export var pbrBlockAlbedoOpacity: {
  21319. name: string;
  21320. shader: string;
  21321. };
  21322. }
  21323. declare module BABYLON {
  21324. /** @hidden */
  21325. export var pbrBlockReflectivity: {
  21326. name: string;
  21327. shader: string;
  21328. };
  21329. }
  21330. declare module BABYLON {
  21331. /** @hidden */
  21332. export var pbrBlockAmbientOcclusion: {
  21333. name: string;
  21334. shader: string;
  21335. };
  21336. }
  21337. declare module BABYLON {
  21338. /** @hidden */
  21339. export var pbrBlockAlphaFresnel: {
  21340. name: string;
  21341. shader: string;
  21342. };
  21343. }
  21344. declare module BABYLON {
  21345. /** @hidden */
  21346. export var pbrBlockAnisotropic: {
  21347. name: string;
  21348. shader: string;
  21349. };
  21350. }
  21351. declare module BABYLON {
  21352. /** @hidden */
  21353. export var pbrBlockReflection: {
  21354. name: string;
  21355. shader: string;
  21356. };
  21357. }
  21358. declare module BABYLON {
  21359. /** @hidden */
  21360. export var pbrBlockSheen: {
  21361. name: string;
  21362. shader: string;
  21363. };
  21364. }
  21365. declare module BABYLON {
  21366. /** @hidden */
  21367. export var pbrBlockClearcoat: {
  21368. name: string;
  21369. shader: string;
  21370. };
  21371. }
  21372. declare module BABYLON {
  21373. /** @hidden */
  21374. export var pbrBlockSubSurface: {
  21375. name: string;
  21376. shader: string;
  21377. };
  21378. }
  21379. declare module BABYLON {
  21380. /** @hidden */
  21381. export var pbrBlockNormalGeometric: {
  21382. name: string;
  21383. shader: string;
  21384. };
  21385. }
  21386. declare module BABYLON {
  21387. /** @hidden */
  21388. export var pbrBlockNormalFinal: {
  21389. name: string;
  21390. shader: string;
  21391. };
  21392. }
  21393. declare module BABYLON {
  21394. /** @hidden */
  21395. export var pbrBlockLightmapInit: {
  21396. name: string;
  21397. shader: string;
  21398. };
  21399. }
  21400. declare module BABYLON {
  21401. /** @hidden */
  21402. export var pbrBlockGeometryInfo: {
  21403. name: string;
  21404. shader: string;
  21405. };
  21406. }
  21407. declare module BABYLON {
  21408. /** @hidden */
  21409. export var pbrBlockReflectance0: {
  21410. name: string;
  21411. shader: string;
  21412. };
  21413. }
  21414. declare module BABYLON {
  21415. /** @hidden */
  21416. export var pbrBlockReflectance: {
  21417. name: string;
  21418. shader: string;
  21419. };
  21420. }
  21421. declare module BABYLON {
  21422. /** @hidden */
  21423. export var pbrBlockDirectLighting: {
  21424. name: string;
  21425. shader: string;
  21426. };
  21427. }
  21428. declare module BABYLON {
  21429. /** @hidden */
  21430. export var pbrBlockFinalLitComponents: {
  21431. name: string;
  21432. shader: string;
  21433. };
  21434. }
  21435. declare module BABYLON {
  21436. /** @hidden */
  21437. export var pbrBlockFinalUnlitComponents: {
  21438. name: string;
  21439. shader: string;
  21440. };
  21441. }
  21442. declare module BABYLON {
  21443. /** @hidden */
  21444. export var pbrBlockFinalColorComposition: {
  21445. name: string;
  21446. shader: string;
  21447. };
  21448. }
  21449. declare module BABYLON {
  21450. /** @hidden */
  21451. export var pbrBlockImageProcessing: {
  21452. name: string;
  21453. shader: string;
  21454. };
  21455. }
  21456. declare module BABYLON {
  21457. /** @hidden */
  21458. export var pbrDebug: {
  21459. name: string;
  21460. shader: string;
  21461. };
  21462. }
  21463. declare module BABYLON {
  21464. /** @hidden */
  21465. export var pbrPixelShader: {
  21466. name: string;
  21467. shader: string;
  21468. };
  21469. }
  21470. declare module BABYLON {
  21471. /** @hidden */
  21472. export var pbrVertexDeclaration: {
  21473. name: string;
  21474. shader: string;
  21475. };
  21476. }
  21477. declare module BABYLON {
  21478. /** @hidden */
  21479. export var pbrVertexShader: {
  21480. name: string;
  21481. shader: string;
  21482. };
  21483. }
  21484. declare module BABYLON {
  21485. /**
  21486. * Manages the defines for the PBR Material.
  21487. * @hidden
  21488. */
  21489. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  21490. PBR: boolean;
  21491. NUM_SAMPLES: string;
  21492. REALTIME_FILTERING: boolean;
  21493. MAINUV1: boolean;
  21494. MAINUV2: boolean;
  21495. UV1: boolean;
  21496. UV2: boolean;
  21497. ALBEDO: boolean;
  21498. GAMMAALBEDO: boolean;
  21499. ALBEDODIRECTUV: number;
  21500. VERTEXCOLOR: boolean;
  21501. DETAIL: boolean;
  21502. DETAILDIRECTUV: number;
  21503. DETAIL_NORMALBLENDMETHOD: number;
  21504. AMBIENT: boolean;
  21505. AMBIENTDIRECTUV: number;
  21506. AMBIENTINGRAYSCALE: boolean;
  21507. OPACITY: boolean;
  21508. VERTEXALPHA: boolean;
  21509. OPACITYDIRECTUV: number;
  21510. OPACITYRGB: boolean;
  21511. ALPHATEST: boolean;
  21512. DEPTHPREPASS: boolean;
  21513. ALPHABLEND: boolean;
  21514. ALPHAFROMALBEDO: boolean;
  21515. ALPHATESTVALUE: string;
  21516. SPECULAROVERALPHA: boolean;
  21517. RADIANCEOVERALPHA: boolean;
  21518. ALPHAFRESNEL: boolean;
  21519. LINEARALPHAFRESNEL: boolean;
  21520. PREMULTIPLYALPHA: boolean;
  21521. EMISSIVE: boolean;
  21522. EMISSIVEDIRECTUV: number;
  21523. REFLECTIVITY: boolean;
  21524. REFLECTIVITYDIRECTUV: number;
  21525. SPECULARTERM: boolean;
  21526. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  21527. MICROSURFACEAUTOMATIC: boolean;
  21528. LODBASEDMICROSFURACE: boolean;
  21529. MICROSURFACEMAP: boolean;
  21530. MICROSURFACEMAPDIRECTUV: number;
  21531. METALLICWORKFLOW: boolean;
  21532. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  21533. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  21534. METALLNESSSTOREINMETALMAPBLUE: boolean;
  21535. AOSTOREINMETALMAPRED: boolean;
  21536. METALLIC_REFLECTANCE: boolean;
  21537. METALLIC_REFLECTANCEDIRECTUV: number;
  21538. ENVIRONMENTBRDF: boolean;
  21539. ENVIRONMENTBRDF_RGBD: boolean;
  21540. NORMAL: boolean;
  21541. TANGENT: boolean;
  21542. BUMP: boolean;
  21543. BUMPDIRECTUV: number;
  21544. OBJECTSPACE_NORMALMAP: boolean;
  21545. PARALLAX: boolean;
  21546. PARALLAXOCCLUSION: boolean;
  21547. NORMALXYSCALE: boolean;
  21548. LIGHTMAP: boolean;
  21549. LIGHTMAPDIRECTUV: number;
  21550. USELIGHTMAPASSHADOWMAP: boolean;
  21551. GAMMALIGHTMAP: boolean;
  21552. RGBDLIGHTMAP: boolean;
  21553. REFLECTION: boolean;
  21554. REFLECTIONMAP_3D: boolean;
  21555. REFLECTIONMAP_SPHERICAL: boolean;
  21556. REFLECTIONMAP_PLANAR: boolean;
  21557. REFLECTIONMAP_CUBIC: boolean;
  21558. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  21559. REFLECTIONMAP_PROJECTION: boolean;
  21560. REFLECTIONMAP_SKYBOX: boolean;
  21561. REFLECTIONMAP_EXPLICIT: boolean;
  21562. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  21563. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  21564. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  21565. INVERTCUBICMAP: boolean;
  21566. USESPHERICALFROMREFLECTIONMAP: boolean;
  21567. USEIRRADIANCEMAP: boolean;
  21568. SPHERICAL_HARMONICS: boolean;
  21569. USESPHERICALINVERTEX: boolean;
  21570. REFLECTIONMAP_OPPOSITEZ: boolean;
  21571. LODINREFLECTIONALPHA: boolean;
  21572. GAMMAREFLECTION: boolean;
  21573. RGBDREFLECTION: boolean;
  21574. LINEARSPECULARREFLECTION: boolean;
  21575. RADIANCEOCCLUSION: boolean;
  21576. HORIZONOCCLUSION: boolean;
  21577. INSTANCES: boolean;
  21578. THIN_INSTANCES: boolean;
  21579. PREPASS: boolean;
  21580. PREPASS_IRRADIANCE: boolean;
  21581. PREPASS_IRRADIANCE_INDEX: number;
  21582. PREPASS_ALBEDO: boolean;
  21583. PREPASS_ALBEDO_INDEX: number;
  21584. PREPASS_DEPTHNORMAL: boolean;
  21585. PREPASS_DEPTHNORMAL_INDEX: number;
  21586. PREPASS_POSITION: boolean;
  21587. PREPASS_POSITION_INDEX: number;
  21588. PREPASS_VELOCITY: boolean;
  21589. PREPASS_VELOCITY_INDEX: number;
  21590. PREPASS_REFLECTIVITY: boolean;
  21591. PREPASS_REFLECTIVITY_INDEX: number;
  21592. SCENE_MRT_COUNT: number;
  21593. NUM_BONE_INFLUENCERS: number;
  21594. BonesPerMesh: number;
  21595. BONETEXTURE: boolean;
  21596. BONES_VELOCITY_ENABLED: boolean;
  21597. NONUNIFORMSCALING: boolean;
  21598. MORPHTARGETS: boolean;
  21599. MORPHTARGETS_NORMAL: boolean;
  21600. MORPHTARGETS_TANGENT: boolean;
  21601. MORPHTARGETS_UV: boolean;
  21602. NUM_MORPH_INFLUENCERS: number;
  21603. IMAGEPROCESSING: boolean;
  21604. VIGNETTE: boolean;
  21605. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21606. VIGNETTEBLENDMODEOPAQUE: boolean;
  21607. TONEMAPPING: boolean;
  21608. TONEMAPPING_ACES: boolean;
  21609. CONTRAST: boolean;
  21610. COLORCURVES: boolean;
  21611. COLORGRADING: boolean;
  21612. COLORGRADING3D: boolean;
  21613. SAMPLER3DGREENDEPTH: boolean;
  21614. SAMPLER3DBGRMAP: boolean;
  21615. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21616. EXPOSURE: boolean;
  21617. MULTIVIEW: boolean;
  21618. USEPHYSICALLIGHTFALLOFF: boolean;
  21619. USEGLTFLIGHTFALLOFF: boolean;
  21620. TWOSIDEDLIGHTING: boolean;
  21621. SHADOWFLOAT: boolean;
  21622. CLIPPLANE: boolean;
  21623. CLIPPLANE2: boolean;
  21624. CLIPPLANE3: boolean;
  21625. CLIPPLANE4: boolean;
  21626. CLIPPLANE5: boolean;
  21627. CLIPPLANE6: boolean;
  21628. POINTSIZE: boolean;
  21629. FOG: boolean;
  21630. LOGARITHMICDEPTH: boolean;
  21631. FORCENORMALFORWARD: boolean;
  21632. SPECULARAA: boolean;
  21633. CLEARCOAT: boolean;
  21634. CLEARCOAT_DEFAULTIOR: boolean;
  21635. CLEARCOAT_TEXTURE: boolean;
  21636. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  21637. CLEARCOAT_TEXTUREDIRECTUV: number;
  21638. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  21639. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21640. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21641. CLEARCOAT_BUMP: boolean;
  21642. CLEARCOAT_BUMPDIRECTUV: number;
  21643. CLEARCOAT_REMAP_F0: boolean;
  21644. CLEARCOAT_TINT: boolean;
  21645. CLEARCOAT_TINT_TEXTURE: boolean;
  21646. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  21647. ANISOTROPIC: boolean;
  21648. ANISOTROPIC_TEXTURE: boolean;
  21649. ANISOTROPIC_TEXTUREDIRECTUV: number;
  21650. BRDF_V_HEIGHT_CORRELATED: boolean;
  21651. MS_BRDF_ENERGY_CONSERVATION: boolean;
  21652. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  21653. SHEEN: boolean;
  21654. SHEEN_TEXTURE: boolean;
  21655. SHEEN_TEXTURE_ROUGHNESS: boolean;
  21656. SHEEN_TEXTUREDIRECTUV: number;
  21657. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  21658. SHEEN_LINKWITHALBEDO: boolean;
  21659. SHEEN_ROUGHNESS: boolean;
  21660. SHEEN_ALBEDOSCALING: boolean;
  21661. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21662. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21663. SUBSURFACE: boolean;
  21664. SS_REFRACTION: boolean;
  21665. SS_TRANSLUCENCY: boolean;
  21666. SS_SCATTERING: boolean;
  21667. SS_THICKNESSANDMASK_TEXTURE: boolean;
  21668. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  21669. SS_REFRACTIONMAP_3D: boolean;
  21670. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  21671. SS_LODINREFRACTIONALPHA: boolean;
  21672. SS_GAMMAREFRACTION: boolean;
  21673. SS_RGBDREFRACTION: boolean;
  21674. SS_LINEARSPECULARREFRACTION: boolean;
  21675. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  21676. SS_ALBEDOFORREFRACTIONTINT: boolean;
  21677. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  21678. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  21679. UNLIT: boolean;
  21680. DEBUGMODE: number;
  21681. /**
  21682. * Initializes the PBR Material defines.
  21683. */
  21684. constructor();
  21685. /**
  21686. * Resets the PBR Material defines.
  21687. */
  21688. reset(): void;
  21689. }
  21690. /**
  21691. * The Physically based material base class of BJS.
  21692. *
  21693. * This offers the main features of a standard PBR material.
  21694. * For more information, please refer to the documentation :
  21695. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21696. */
  21697. export abstract class PBRBaseMaterial extends PushMaterial {
  21698. /**
  21699. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21700. */
  21701. static readonly PBRMATERIAL_OPAQUE: number;
  21702. /**
  21703. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21704. */
  21705. static readonly PBRMATERIAL_ALPHATEST: number;
  21706. /**
  21707. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21708. */
  21709. static readonly PBRMATERIAL_ALPHABLEND: number;
  21710. /**
  21711. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21712. * They are also discarded below the alpha cutoff threshold to improve performances.
  21713. */
  21714. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21715. /**
  21716. * Defines the default value of how much AO map is occluding the analytical lights
  21717. * (point spot...).
  21718. */
  21719. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21720. /**
  21721. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  21722. */
  21723. static readonly LIGHTFALLOFF_PHYSICAL: number;
  21724. /**
  21725. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  21726. * to enhance interoperability with other engines.
  21727. */
  21728. static readonly LIGHTFALLOFF_GLTF: number;
  21729. /**
  21730. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  21731. * to enhance interoperability with other materials.
  21732. */
  21733. static readonly LIGHTFALLOFF_STANDARD: number;
  21734. /**
  21735. * Intensity of the direct lights e.g. the four lights available in your scene.
  21736. * This impacts both the direct diffuse and specular highlights.
  21737. */
  21738. protected _directIntensity: number;
  21739. /**
  21740. * Intensity of the emissive part of the material.
  21741. * This helps controlling the emissive effect without modifying the emissive color.
  21742. */
  21743. protected _emissiveIntensity: number;
  21744. /**
  21745. * Intensity of the environment e.g. how much the environment will light the object
  21746. * either through harmonics for rough material or through the refelction for shiny ones.
  21747. */
  21748. protected _environmentIntensity: number;
  21749. /**
  21750. * This is a special control allowing the reduction of the specular highlights coming from the
  21751. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21752. */
  21753. protected _specularIntensity: number;
  21754. /**
  21755. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  21756. */
  21757. private _lightingInfos;
  21758. /**
  21759. * Debug Control allowing disabling the bump map on this material.
  21760. */
  21761. protected _disableBumpMap: boolean;
  21762. /**
  21763. * AKA Diffuse Texture in standard nomenclature.
  21764. */
  21765. protected _albedoTexture: Nullable<BaseTexture>;
  21766. /**
  21767. * AKA Occlusion Texture in other nomenclature.
  21768. */
  21769. protected _ambientTexture: Nullable<BaseTexture>;
  21770. /**
  21771. * AKA Occlusion Texture Intensity in other nomenclature.
  21772. */
  21773. protected _ambientTextureStrength: number;
  21774. /**
  21775. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21776. * 1 means it completely occludes it
  21777. * 0 mean it has no impact
  21778. */
  21779. protected _ambientTextureImpactOnAnalyticalLights: number;
  21780. /**
  21781. * Stores the alpha values in a texture.
  21782. */
  21783. protected _opacityTexture: Nullable<BaseTexture>;
  21784. /**
  21785. * Stores the reflection values in a texture.
  21786. */
  21787. protected _reflectionTexture: Nullable<BaseTexture>;
  21788. /**
  21789. * Stores the emissive values in a texture.
  21790. */
  21791. protected _emissiveTexture: Nullable<BaseTexture>;
  21792. /**
  21793. * AKA Specular texture in other nomenclature.
  21794. */
  21795. protected _reflectivityTexture: Nullable<BaseTexture>;
  21796. /**
  21797. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21798. */
  21799. protected _metallicTexture: Nullable<BaseTexture>;
  21800. /**
  21801. * Specifies the metallic scalar of the metallic/roughness workflow.
  21802. * Can also be used to scale the metalness values of the metallic texture.
  21803. */
  21804. protected _metallic: Nullable<number>;
  21805. /**
  21806. * Specifies the roughness scalar of the metallic/roughness workflow.
  21807. * Can also be used to scale the roughness values of the metallic texture.
  21808. */
  21809. protected _roughness: Nullable<number>;
  21810. /**
  21811. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21812. * By default the indexOfrefraction is used to compute F0;
  21813. *
  21814. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21815. *
  21816. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21817. * F90 = metallicReflectanceColor;
  21818. */
  21819. protected _metallicF0Factor: number;
  21820. /**
  21821. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21822. * By default the F90 is always 1;
  21823. *
  21824. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21825. *
  21826. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21827. * F90 = metallicReflectanceColor;
  21828. */
  21829. protected _metallicReflectanceColor: Color3;
  21830. /**
  21831. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21832. * This is multiply against the scalar values defined in the material.
  21833. */
  21834. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  21835. /**
  21836. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21837. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21838. */
  21839. protected _microSurfaceTexture: Nullable<BaseTexture>;
  21840. /**
  21841. * Stores surface normal data used to displace a mesh in a texture.
  21842. */
  21843. protected _bumpTexture: Nullable<BaseTexture>;
  21844. /**
  21845. * Stores the pre-calculated light information of a mesh in a texture.
  21846. */
  21847. protected _lightmapTexture: Nullable<BaseTexture>;
  21848. /**
  21849. * The color of a material in ambient lighting.
  21850. */
  21851. protected _ambientColor: Color3;
  21852. /**
  21853. * AKA Diffuse Color in other nomenclature.
  21854. */
  21855. protected _albedoColor: Color3;
  21856. /**
  21857. * AKA Specular Color in other nomenclature.
  21858. */
  21859. protected _reflectivityColor: Color3;
  21860. /**
  21861. * The color applied when light is reflected from a material.
  21862. */
  21863. protected _reflectionColor: Color3;
  21864. /**
  21865. * The color applied when light is emitted from a material.
  21866. */
  21867. protected _emissiveColor: Color3;
  21868. /**
  21869. * AKA Glossiness in other nomenclature.
  21870. */
  21871. protected _microSurface: number;
  21872. /**
  21873. * Specifies that the material will use the light map as a show map.
  21874. */
  21875. protected _useLightmapAsShadowmap: boolean;
  21876. /**
  21877. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21878. * makes the reflect vector face the model (under horizon).
  21879. */
  21880. protected _useHorizonOcclusion: boolean;
  21881. /**
  21882. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21883. * too much the area relying on ambient texture to define their ambient occlusion.
  21884. */
  21885. protected _useRadianceOcclusion: boolean;
  21886. /**
  21887. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21888. */
  21889. protected _useAlphaFromAlbedoTexture: boolean;
  21890. /**
  21891. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  21892. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21893. */
  21894. protected _useSpecularOverAlpha: boolean;
  21895. /**
  21896. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21897. */
  21898. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21899. /**
  21900. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21901. */
  21902. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  21903. /**
  21904. * Specifies if the metallic texture contains the roughness information in its green channel.
  21905. */
  21906. protected _useRoughnessFromMetallicTextureGreen: boolean;
  21907. /**
  21908. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21909. */
  21910. protected _useMetallnessFromMetallicTextureBlue: boolean;
  21911. /**
  21912. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21913. */
  21914. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  21915. /**
  21916. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  21917. */
  21918. protected _useAmbientInGrayScale: boolean;
  21919. /**
  21920. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  21921. * The material will try to infer what glossiness each pixel should be.
  21922. */
  21923. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  21924. /**
  21925. * Defines the falloff type used in this material.
  21926. * It by default is Physical.
  21927. */
  21928. protected _lightFalloff: number;
  21929. /**
  21930. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  21931. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  21932. */
  21933. protected _useRadianceOverAlpha: boolean;
  21934. /**
  21935. * Allows using an object space normal map (instead of tangent space).
  21936. */
  21937. protected _useObjectSpaceNormalMap: boolean;
  21938. /**
  21939. * Allows using the bump map in parallax mode.
  21940. */
  21941. protected _useParallax: boolean;
  21942. /**
  21943. * Allows using the bump map in parallax occlusion mode.
  21944. */
  21945. protected _useParallaxOcclusion: boolean;
  21946. /**
  21947. * Controls the scale bias of the parallax mode.
  21948. */
  21949. protected _parallaxScaleBias: number;
  21950. /**
  21951. * If sets to true, disables all the lights affecting the material.
  21952. */
  21953. protected _disableLighting: boolean;
  21954. /**
  21955. * Number of Simultaneous lights allowed on the material.
  21956. */
  21957. protected _maxSimultaneousLights: number;
  21958. /**
  21959. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  21960. */
  21961. protected _invertNormalMapX: boolean;
  21962. /**
  21963. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  21964. */
  21965. protected _invertNormalMapY: boolean;
  21966. /**
  21967. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  21968. */
  21969. protected _twoSidedLighting: boolean;
  21970. /**
  21971. * Defines the alpha limits in alpha test mode.
  21972. */
  21973. protected _alphaCutOff: number;
  21974. /**
  21975. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21976. */
  21977. protected _forceAlphaTest: boolean;
  21978. /**
  21979. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21980. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  21981. */
  21982. protected _useAlphaFresnel: boolean;
  21983. /**
  21984. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21985. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  21986. */
  21987. protected _useLinearAlphaFresnel: boolean;
  21988. /**
  21989. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  21990. * from cos thetav and roughness:
  21991. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  21992. */
  21993. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  21994. /**
  21995. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  21996. */
  21997. protected _forceIrradianceInFragment: boolean;
  21998. private _realTimeFiltering;
  21999. /**
  22000. * Enables realtime filtering on the texture.
  22001. */
  22002. get realTimeFiltering(): boolean;
  22003. set realTimeFiltering(b: boolean);
  22004. private _realTimeFilteringQuality;
  22005. /**
  22006. * Quality switch for realtime filtering
  22007. */
  22008. get realTimeFilteringQuality(): number;
  22009. set realTimeFilteringQuality(n: number);
  22010. /**
  22011. * Can this material render to several textures at once
  22012. */
  22013. get canRenderToMRT(): boolean;
  22014. /**
  22015. * Force normal to face away from face.
  22016. */
  22017. protected _forceNormalForward: boolean;
  22018. /**
  22019. * Enables specular anti aliasing in the PBR shader.
  22020. * It will both interacts on the Geometry for analytical and IBL lighting.
  22021. * It also prefilter the roughness map based on the bump values.
  22022. */
  22023. protected _enableSpecularAntiAliasing: boolean;
  22024. /**
  22025. * Default configuration related to image processing available in the PBR Material.
  22026. */
  22027. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22028. /**
  22029. * Keep track of the image processing observer to allow dispose and replace.
  22030. */
  22031. private _imageProcessingObserver;
  22032. /**
  22033. * Attaches a new image processing configuration to the PBR Material.
  22034. * @param configuration
  22035. */
  22036. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22037. /**
  22038. * Stores the available render targets.
  22039. */
  22040. private _renderTargets;
  22041. /**
  22042. * Sets the global ambient color for the material used in lighting calculations.
  22043. */
  22044. private _globalAmbientColor;
  22045. /**
  22046. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  22047. */
  22048. private _useLogarithmicDepth;
  22049. /**
  22050. * If set to true, no lighting calculations will be applied.
  22051. */
  22052. private _unlit;
  22053. private _debugMode;
  22054. /**
  22055. * @hidden
  22056. * This is reserved for the inspector.
  22057. * Defines the material debug mode.
  22058. * It helps seeing only some components of the material while troubleshooting.
  22059. */
  22060. debugMode: number;
  22061. /**
  22062. * @hidden
  22063. * This is reserved for the inspector.
  22064. * Specify from where on screen the debug mode should start.
  22065. * The value goes from -1 (full screen) to 1 (not visible)
  22066. * It helps with side by side comparison against the final render
  22067. * This defaults to -1
  22068. */
  22069. private debugLimit;
  22070. /**
  22071. * @hidden
  22072. * This is reserved for the inspector.
  22073. * As the default viewing range might not be enough (if the ambient is really small for instance)
  22074. * You can use the factor to better multiply the final value.
  22075. */
  22076. private debugFactor;
  22077. /**
  22078. * Defines the clear coat layer parameters for the material.
  22079. */
  22080. readonly clearCoat: PBRClearCoatConfiguration;
  22081. /**
  22082. * Defines the anisotropic parameters for the material.
  22083. */
  22084. readonly anisotropy: PBRAnisotropicConfiguration;
  22085. /**
  22086. * Defines the BRDF parameters for the material.
  22087. */
  22088. readonly brdf: PBRBRDFConfiguration;
  22089. /**
  22090. * Defines the Sheen parameters for the material.
  22091. */
  22092. readonly sheen: PBRSheenConfiguration;
  22093. /**
  22094. * Defines the SubSurface parameters for the material.
  22095. */
  22096. readonly subSurface: PBRSubSurfaceConfiguration;
  22097. /**
  22098. * Defines additionnal PrePass parameters for the material.
  22099. */
  22100. readonly prePassConfiguration: PrePassConfiguration;
  22101. /**
  22102. * Defines the detail map parameters for the material.
  22103. */
  22104. readonly detailMap: DetailMapConfiguration;
  22105. protected _rebuildInParallel: boolean;
  22106. /**
  22107. * Instantiates a new PBRMaterial instance.
  22108. *
  22109. * @param name The material name
  22110. * @param scene The scene the material will be use in.
  22111. */
  22112. constructor(name: string, scene: Scene);
  22113. /**
  22114. * Gets a boolean indicating that current material needs to register RTT
  22115. */
  22116. get hasRenderTargetTextures(): boolean;
  22117. /**
  22118. * Gets the name of the material class.
  22119. */
  22120. getClassName(): string;
  22121. /**
  22122. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22123. */
  22124. get useLogarithmicDepth(): boolean;
  22125. /**
  22126. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22127. */
  22128. set useLogarithmicDepth(value: boolean);
  22129. /**
  22130. * Returns true if alpha blending should be disabled.
  22131. */
  22132. protected get _disableAlphaBlending(): boolean;
  22133. /**
  22134. * Specifies whether or not this material should be rendered in alpha blend mode.
  22135. */
  22136. needAlphaBlending(): boolean;
  22137. /**
  22138. * Specifies whether or not this material should be rendered in alpha test mode.
  22139. */
  22140. needAlphaTesting(): boolean;
  22141. /**
  22142. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  22143. */
  22144. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  22145. /**
  22146. * Specifies whether or not there is a usable alpha channel for transparency.
  22147. */
  22148. protected _hasAlphaChannel(): boolean;
  22149. /**
  22150. * Gets the texture used for the alpha test.
  22151. */
  22152. getAlphaTestTexture(): Nullable<BaseTexture>;
  22153. /**
  22154. * Specifies that the submesh is ready to be used.
  22155. * @param mesh - BJS mesh.
  22156. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  22157. * @param useInstances - Specifies that instances should be used.
  22158. * @returns - boolean indicating that the submesh is ready or not.
  22159. */
  22160. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22161. /**
  22162. * Specifies if the material uses metallic roughness workflow.
  22163. * @returns boolean specifiying if the material uses metallic roughness workflow.
  22164. */
  22165. isMetallicWorkflow(): boolean;
  22166. private _prepareEffect;
  22167. private _prepareDefines;
  22168. /**
  22169. * Force shader compilation
  22170. */
  22171. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  22172. /**
  22173. * Initializes the uniform buffer layout for the shader.
  22174. */
  22175. buildUniformLayout(): void;
  22176. /**
  22177. * Unbinds the material from the mesh
  22178. */
  22179. unbind(): void;
  22180. /**
  22181. * Binds the submesh data.
  22182. * @param world - The world matrix.
  22183. * @param mesh - The BJS mesh.
  22184. * @param subMesh - A submesh of the BJS mesh.
  22185. */
  22186. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22187. /**
  22188. * Returns the animatable textures.
  22189. * @returns - Array of animatable textures.
  22190. */
  22191. getAnimatables(): IAnimatable[];
  22192. /**
  22193. * Returns the texture used for reflections.
  22194. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  22195. */
  22196. private _getReflectionTexture;
  22197. /**
  22198. * Returns an array of the actively used textures.
  22199. * @returns - Array of BaseTextures
  22200. */
  22201. getActiveTextures(): BaseTexture[];
  22202. /**
  22203. * Checks to see if a texture is used in the material.
  22204. * @param texture - Base texture to use.
  22205. * @returns - Boolean specifying if a texture is used in the material.
  22206. */
  22207. hasTexture(texture: BaseTexture): boolean;
  22208. /**
  22209. * Sets the required values to the prepass renderer.
  22210. * @param prePassRenderer defines the prepass renderer to setup
  22211. */
  22212. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22213. /**
  22214. * Disposes the resources of the material.
  22215. * @param forceDisposeEffect - Forces the disposal of effects.
  22216. * @param forceDisposeTextures - Forces the disposal of all textures.
  22217. */
  22218. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  22219. }
  22220. }
  22221. declare module BABYLON {
  22222. /**
  22223. * The Physically based material of BJS.
  22224. *
  22225. * This offers the main features of a standard PBR material.
  22226. * For more information, please refer to the documentation :
  22227. * https://doc.babylonjs.com/how_to/physically_based_rendering
  22228. */
  22229. export class PBRMaterial extends PBRBaseMaterial {
  22230. /**
  22231. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  22232. */
  22233. static readonly PBRMATERIAL_OPAQUE: number;
  22234. /**
  22235. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  22236. */
  22237. static readonly PBRMATERIAL_ALPHATEST: number;
  22238. /**
  22239. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22240. */
  22241. static readonly PBRMATERIAL_ALPHABLEND: number;
  22242. /**
  22243. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22244. * They are also discarded below the alpha cutoff threshold to improve performances.
  22245. */
  22246. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  22247. /**
  22248. * Defines the default value of how much AO map is occluding the analytical lights
  22249. * (point spot...).
  22250. */
  22251. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  22252. /**
  22253. * Intensity of the direct lights e.g. the four lights available in your scene.
  22254. * This impacts both the direct diffuse and specular highlights.
  22255. */
  22256. directIntensity: number;
  22257. /**
  22258. * Intensity of the emissive part of the material.
  22259. * This helps controlling the emissive effect without modifying the emissive color.
  22260. */
  22261. emissiveIntensity: number;
  22262. /**
  22263. * Intensity of the environment e.g. how much the environment will light the object
  22264. * either through harmonics for rough material or through the refelction for shiny ones.
  22265. */
  22266. environmentIntensity: number;
  22267. /**
  22268. * This is a special control allowing the reduction of the specular highlights coming from the
  22269. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  22270. */
  22271. specularIntensity: number;
  22272. /**
  22273. * Debug Control allowing disabling the bump map on this material.
  22274. */
  22275. disableBumpMap: boolean;
  22276. /**
  22277. * AKA Diffuse Texture in standard nomenclature.
  22278. */
  22279. albedoTexture: BaseTexture;
  22280. /**
  22281. * AKA Occlusion Texture in other nomenclature.
  22282. */
  22283. ambientTexture: BaseTexture;
  22284. /**
  22285. * AKA Occlusion Texture Intensity in other nomenclature.
  22286. */
  22287. ambientTextureStrength: number;
  22288. /**
  22289. * Defines how much the AO map is occluding the analytical lights (point spot...).
  22290. * 1 means it completely occludes it
  22291. * 0 mean it has no impact
  22292. */
  22293. ambientTextureImpactOnAnalyticalLights: number;
  22294. /**
  22295. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  22296. */
  22297. opacityTexture: BaseTexture;
  22298. /**
  22299. * Stores the reflection values in a texture.
  22300. */
  22301. reflectionTexture: Nullable<BaseTexture>;
  22302. /**
  22303. * Stores the emissive values in a texture.
  22304. */
  22305. emissiveTexture: BaseTexture;
  22306. /**
  22307. * AKA Specular texture in other nomenclature.
  22308. */
  22309. reflectivityTexture: BaseTexture;
  22310. /**
  22311. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22312. */
  22313. metallicTexture: BaseTexture;
  22314. /**
  22315. * Specifies the metallic scalar of the metallic/roughness workflow.
  22316. * Can also be used to scale the metalness values of the metallic texture.
  22317. */
  22318. metallic: Nullable<number>;
  22319. /**
  22320. * Specifies the roughness scalar of the metallic/roughness workflow.
  22321. * Can also be used to scale the roughness values of the metallic texture.
  22322. */
  22323. roughness: Nullable<number>;
  22324. /**
  22325. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22326. * By default the indexOfrefraction is used to compute F0;
  22327. *
  22328. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22329. *
  22330. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22331. * F90 = metallicReflectanceColor;
  22332. */
  22333. metallicF0Factor: number;
  22334. /**
  22335. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22336. * By default the F90 is always 1;
  22337. *
  22338. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22339. *
  22340. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22341. * F90 = metallicReflectanceColor;
  22342. */
  22343. metallicReflectanceColor: Color3;
  22344. /**
  22345. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22346. * This is multiply against the scalar values defined in the material.
  22347. */
  22348. metallicReflectanceTexture: Nullable<BaseTexture>;
  22349. /**
  22350. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22351. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22352. */
  22353. microSurfaceTexture: BaseTexture;
  22354. /**
  22355. * Stores surface normal data used to displace a mesh in a texture.
  22356. */
  22357. bumpTexture: BaseTexture;
  22358. /**
  22359. * Stores the pre-calculated light information of a mesh in a texture.
  22360. */
  22361. lightmapTexture: BaseTexture;
  22362. /**
  22363. * Stores the refracted light information in a texture.
  22364. */
  22365. get refractionTexture(): Nullable<BaseTexture>;
  22366. set refractionTexture(value: Nullable<BaseTexture>);
  22367. /**
  22368. * The color of a material in ambient lighting.
  22369. */
  22370. ambientColor: Color3;
  22371. /**
  22372. * AKA Diffuse Color in other nomenclature.
  22373. */
  22374. albedoColor: Color3;
  22375. /**
  22376. * AKA Specular Color in other nomenclature.
  22377. */
  22378. reflectivityColor: Color3;
  22379. /**
  22380. * The color reflected from the material.
  22381. */
  22382. reflectionColor: Color3;
  22383. /**
  22384. * The color emitted from the material.
  22385. */
  22386. emissiveColor: Color3;
  22387. /**
  22388. * AKA Glossiness in other nomenclature.
  22389. */
  22390. microSurface: number;
  22391. /**
  22392. * Index of refraction of the material base layer.
  22393. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  22394. *
  22395. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  22396. *
  22397. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  22398. */
  22399. get indexOfRefraction(): number;
  22400. set indexOfRefraction(value: number);
  22401. /**
  22402. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  22403. */
  22404. get invertRefractionY(): boolean;
  22405. set invertRefractionY(value: boolean);
  22406. /**
  22407. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  22408. * Materials half opaque for instance using refraction could benefit from this control.
  22409. */
  22410. get linkRefractionWithTransparency(): boolean;
  22411. set linkRefractionWithTransparency(value: boolean);
  22412. /**
  22413. * If true, the light map contains occlusion information instead of lighting info.
  22414. */
  22415. useLightmapAsShadowmap: boolean;
  22416. /**
  22417. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22418. */
  22419. useAlphaFromAlbedoTexture: boolean;
  22420. /**
  22421. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22422. */
  22423. forceAlphaTest: boolean;
  22424. /**
  22425. * Defines the alpha limits in alpha test mode.
  22426. */
  22427. alphaCutOff: number;
  22428. /**
  22429. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  22430. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  22431. */
  22432. useSpecularOverAlpha: boolean;
  22433. /**
  22434. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22435. */
  22436. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22437. /**
  22438. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22439. */
  22440. useRoughnessFromMetallicTextureAlpha: boolean;
  22441. /**
  22442. * Specifies if the metallic texture contains the roughness information in its green channel.
  22443. */
  22444. useRoughnessFromMetallicTextureGreen: boolean;
  22445. /**
  22446. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22447. */
  22448. useMetallnessFromMetallicTextureBlue: boolean;
  22449. /**
  22450. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22451. */
  22452. useAmbientOcclusionFromMetallicTextureRed: boolean;
  22453. /**
  22454. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22455. */
  22456. useAmbientInGrayScale: boolean;
  22457. /**
  22458. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22459. * The material will try to infer what glossiness each pixel should be.
  22460. */
  22461. useAutoMicroSurfaceFromReflectivityMap: boolean;
  22462. /**
  22463. * BJS is using an harcoded light falloff based on a manually sets up range.
  22464. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  22465. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22466. */
  22467. get usePhysicalLightFalloff(): boolean;
  22468. /**
  22469. * BJS is using an harcoded light falloff based on a manually sets up range.
  22470. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  22471. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22472. */
  22473. set usePhysicalLightFalloff(value: boolean);
  22474. /**
  22475. * In order to support the falloff compatibility with gltf, a special mode has been added
  22476. * to reproduce the gltf light falloff.
  22477. */
  22478. get useGLTFLightFalloff(): boolean;
  22479. /**
  22480. * In order to support the falloff compatibility with gltf, a special mode has been added
  22481. * to reproduce the gltf light falloff.
  22482. */
  22483. set useGLTFLightFalloff(value: boolean);
  22484. /**
  22485. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  22486. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  22487. */
  22488. useRadianceOverAlpha: boolean;
  22489. /**
  22490. * Allows using an object space normal map (instead of tangent space).
  22491. */
  22492. useObjectSpaceNormalMap: boolean;
  22493. /**
  22494. * Allows using the bump map in parallax mode.
  22495. */
  22496. useParallax: boolean;
  22497. /**
  22498. * Allows using the bump map in parallax occlusion mode.
  22499. */
  22500. useParallaxOcclusion: boolean;
  22501. /**
  22502. * Controls the scale bias of the parallax mode.
  22503. */
  22504. parallaxScaleBias: number;
  22505. /**
  22506. * If sets to true, disables all the lights affecting the material.
  22507. */
  22508. disableLighting: boolean;
  22509. /**
  22510. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22511. */
  22512. forceIrradianceInFragment: boolean;
  22513. /**
  22514. * Number of Simultaneous lights allowed on the material.
  22515. */
  22516. maxSimultaneousLights: number;
  22517. /**
  22518. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  22519. */
  22520. invertNormalMapX: boolean;
  22521. /**
  22522. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  22523. */
  22524. invertNormalMapY: boolean;
  22525. /**
  22526. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22527. */
  22528. twoSidedLighting: boolean;
  22529. /**
  22530. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22531. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22532. */
  22533. useAlphaFresnel: boolean;
  22534. /**
  22535. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22536. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22537. */
  22538. useLinearAlphaFresnel: boolean;
  22539. /**
  22540. * Let user defines the brdf lookup texture used for IBL.
  22541. * A default 8bit version is embedded but you could point at :
  22542. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  22543. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  22544. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  22545. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  22546. */
  22547. environmentBRDFTexture: Nullable<BaseTexture>;
  22548. /**
  22549. * Force normal to face away from face.
  22550. */
  22551. forceNormalForward: boolean;
  22552. /**
  22553. * Enables specular anti aliasing in the PBR shader.
  22554. * It will both interacts on the Geometry for analytical and IBL lighting.
  22555. * It also prefilter the roughness map based on the bump values.
  22556. */
  22557. enableSpecularAntiAliasing: boolean;
  22558. /**
  22559. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22560. * makes the reflect vector face the model (under horizon).
  22561. */
  22562. useHorizonOcclusion: boolean;
  22563. /**
  22564. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22565. * too much the area relying on ambient texture to define their ambient occlusion.
  22566. */
  22567. useRadianceOcclusion: boolean;
  22568. /**
  22569. * If set to true, no lighting calculations will be applied.
  22570. */
  22571. unlit: boolean;
  22572. /**
  22573. * Gets the image processing configuration used either in this material.
  22574. */
  22575. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22576. /**
  22577. * Sets the Default image processing configuration used either in the this material.
  22578. *
  22579. * If sets to null, the scene one is in use.
  22580. */
  22581. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22582. /**
  22583. * Gets wether the color curves effect is enabled.
  22584. */
  22585. get cameraColorCurvesEnabled(): boolean;
  22586. /**
  22587. * Sets wether the color curves effect is enabled.
  22588. */
  22589. set cameraColorCurvesEnabled(value: boolean);
  22590. /**
  22591. * Gets wether the color grading effect is enabled.
  22592. */
  22593. get cameraColorGradingEnabled(): boolean;
  22594. /**
  22595. * Gets wether the color grading effect is enabled.
  22596. */
  22597. set cameraColorGradingEnabled(value: boolean);
  22598. /**
  22599. * Gets wether tonemapping is enabled or not.
  22600. */
  22601. get cameraToneMappingEnabled(): boolean;
  22602. /**
  22603. * Sets wether tonemapping is enabled or not
  22604. */
  22605. set cameraToneMappingEnabled(value: boolean);
  22606. /**
  22607. * The camera exposure used on this material.
  22608. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22609. * This corresponds to a photographic exposure.
  22610. */
  22611. get cameraExposure(): number;
  22612. /**
  22613. * The camera exposure used on this material.
  22614. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22615. * This corresponds to a photographic exposure.
  22616. */
  22617. set cameraExposure(value: number);
  22618. /**
  22619. * Gets The camera contrast used on this material.
  22620. */
  22621. get cameraContrast(): number;
  22622. /**
  22623. * Sets The camera contrast used on this material.
  22624. */
  22625. set cameraContrast(value: number);
  22626. /**
  22627. * Gets the Color Grading 2D Lookup Texture.
  22628. */
  22629. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  22630. /**
  22631. * Sets the Color Grading 2D Lookup Texture.
  22632. */
  22633. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  22634. /**
  22635. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22636. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22637. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  22638. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22639. */
  22640. get cameraColorCurves(): Nullable<ColorCurves>;
  22641. /**
  22642. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22643. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22644. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  22645. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22646. */
  22647. set cameraColorCurves(value: Nullable<ColorCurves>);
  22648. /**
  22649. * Instantiates a new PBRMaterial instance.
  22650. *
  22651. * @param name The material name
  22652. * @param scene The scene the material will be use in.
  22653. */
  22654. constructor(name: string, scene: Scene);
  22655. /**
  22656. * Returns the name of this material class.
  22657. */
  22658. getClassName(): string;
  22659. /**
  22660. * Makes a duplicate of the current material.
  22661. * @param name - name to use for the new material.
  22662. */
  22663. clone(name: string): PBRMaterial;
  22664. /**
  22665. * Serializes this PBR Material.
  22666. * @returns - An object with the serialized material.
  22667. */
  22668. serialize(): any;
  22669. /**
  22670. * Parses a PBR Material from a serialized object.
  22671. * @param source - Serialized object.
  22672. * @param scene - BJS scene instance.
  22673. * @param rootUrl - url for the scene object
  22674. * @returns - PBRMaterial
  22675. */
  22676. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  22677. }
  22678. }
  22679. declare module BABYLON {
  22680. /** @hidden */
  22681. export var mrtFragmentDeclaration: {
  22682. name: string;
  22683. shader: string;
  22684. };
  22685. }
  22686. declare module BABYLON {
  22687. /** @hidden */
  22688. export var geometryPixelShader: {
  22689. name: string;
  22690. shader: string;
  22691. };
  22692. }
  22693. declare module BABYLON {
  22694. /** @hidden */
  22695. export var instancesDeclaration: {
  22696. name: string;
  22697. shader: string;
  22698. };
  22699. }
  22700. declare module BABYLON {
  22701. /** @hidden */
  22702. export var geometryVertexShader: {
  22703. name: string;
  22704. shader: string;
  22705. };
  22706. }
  22707. declare module BABYLON {
  22708. /** @hidden */
  22709. interface ISavedTransformationMatrix {
  22710. world: Matrix;
  22711. viewProjection: Matrix;
  22712. }
  22713. /**
  22714. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  22715. */
  22716. export class GeometryBufferRenderer {
  22717. /**
  22718. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  22719. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  22720. */
  22721. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  22722. /**
  22723. * Constant used to retrieve the position texture index in the G-Buffer textures array
  22724. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  22725. */
  22726. static readonly POSITION_TEXTURE_TYPE: number;
  22727. /**
  22728. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  22729. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  22730. */
  22731. static readonly VELOCITY_TEXTURE_TYPE: number;
  22732. /**
  22733. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  22734. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  22735. */
  22736. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  22737. /**
  22738. * Dictionary used to store the previous transformation matrices of each rendered mesh
  22739. * in order to compute objects velocities when enableVelocity is set to "true"
  22740. * @hidden
  22741. */
  22742. _previousTransformationMatrices: {
  22743. [index: number]: ISavedTransformationMatrix;
  22744. };
  22745. /**
  22746. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  22747. * in order to compute objects velocities when enableVelocity is set to "true"
  22748. * @hidden
  22749. */
  22750. _previousBonesTransformationMatrices: {
  22751. [index: number]: Float32Array;
  22752. };
  22753. /**
  22754. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  22755. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  22756. */
  22757. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  22758. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  22759. renderTransparentMeshes: boolean;
  22760. private _scene;
  22761. private _resizeObserver;
  22762. private _multiRenderTarget;
  22763. private _ratio;
  22764. private _enablePosition;
  22765. private _enableVelocity;
  22766. private _enableReflectivity;
  22767. private _positionIndex;
  22768. private _velocityIndex;
  22769. private _reflectivityIndex;
  22770. private _depthNormalIndex;
  22771. private _linkedWithPrePass;
  22772. private _prePassRenderer;
  22773. private _attachments;
  22774. protected _effect: Effect;
  22775. protected _cachedDefines: string;
  22776. /**
  22777. * @hidden
  22778. * Sets up internal structures to share outputs with PrePassRenderer
  22779. * This method should only be called by the PrePassRenderer itself
  22780. */
  22781. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  22782. /**
  22783. * @hidden
  22784. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  22785. * This method should only be called by the PrePassRenderer itself
  22786. */
  22787. _unlinkPrePassRenderer(): void;
  22788. /**
  22789. * @hidden
  22790. * Resets the geometry buffer layout
  22791. */
  22792. _resetLayout(): void;
  22793. /**
  22794. * @hidden
  22795. * Replaces a texture in the geometry buffer renderer
  22796. * Useful when linking textures of the prepass renderer
  22797. */
  22798. _forceTextureType(geometryBufferType: number, index: number): void;
  22799. /**
  22800. * @hidden
  22801. * Sets texture attachments
  22802. * Useful when linking textures of the prepass renderer
  22803. */
  22804. _setAttachments(attachments: number[]): void;
  22805. /**
  22806. * @hidden
  22807. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  22808. * Useful when linking textures of the prepass renderer
  22809. */
  22810. _linkInternalTexture(internalTexture: InternalTexture): void;
  22811. /**
  22812. * Gets the render list (meshes to be rendered) used in the G buffer.
  22813. */
  22814. get renderList(): Nullable<AbstractMesh[]>;
  22815. /**
  22816. * Set the render list (meshes to be rendered) used in the G buffer.
  22817. */
  22818. set renderList(meshes: Nullable<AbstractMesh[]>);
  22819. /**
  22820. * Gets wether or not G buffer are supported by the running hardware.
  22821. * This requires draw buffer supports
  22822. */
  22823. get isSupported(): boolean;
  22824. /**
  22825. * Returns the index of the given texture type in the G-Buffer textures array
  22826. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  22827. * @returns the index of the given texture type in the G-Buffer textures array
  22828. */
  22829. getTextureIndex(textureType: number): number;
  22830. /**
  22831. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  22832. */
  22833. get enablePosition(): boolean;
  22834. /**
  22835. * Sets whether or not objects positions are enabled for the G buffer.
  22836. */
  22837. set enablePosition(enable: boolean);
  22838. /**
  22839. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  22840. */
  22841. get enableVelocity(): boolean;
  22842. /**
  22843. * Sets wether or not objects velocities are enabled for the G buffer.
  22844. */
  22845. set enableVelocity(enable: boolean);
  22846. /**
  22847. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  22848. */
  22849. get enableReflectivity(): boolean;
  22850. /**
  22851. * Sets wether or not objects roughness are enabled for the G buffer.
  22852. */
  22853. set enableReflectivity(enable: boolean);
  22854. /**
  22855. * Gets the scene associated with the buffer.
  22856. */
  22857. get scene(): Scene;
  22858. /**
  22859. * Gets the ratio used by the buffer during its creation.
  22860. * How big is the buffer related to the main canvas.
  22861. */
  22862. get ratio(): number;
  22863. /** @hidden */
  22864. static _SceneComponentInitialization: (scene: Scene) => void;
  22865. /**
  22866. * Creates a new G Buffer for the scene
  22867. * @param scene The scene the buffer belongs to
  22868. * @param ratio How big is the buffer related to the main canvas.
  22869. */
  22870. constructor(scene: Scene, ratio?: number);
  22871. /**
  22872. * Checks wether everything is ready to render a submesh to the G buffer.
  22873. * @param subMesh the submesh to check readiness for
  22874. * @param useInstances is the mesh drawn using instance or not
  22875. * @returns true if ready otherwise false
  22876. */
  22877. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  22878. /**
  22879. * Gets the current underlying G Buffer.
  22880. * @returns the buffer
  22881. */
  22882. getGBuffer(): MultiRenderTarget;
  22883. /**
  22884. * Gets the number of samples used to render the buffer (anti aliasing).
  22885. */
  22886. get samples(): number;
  22887. /**
  22888. * Sets the number of samples used to render the buffer (anti aliasing).
  22889. */
  22890. set samples(value: number);
  22891. /**
  22892. * Disposes the renderer and frees up associated resources.
  22893. */
  22894. dispose(): void;
  22895. private _assignRenderTargetIndices;
  22896. protected _createRenderTargets(): void;
  22897. private _copyBonesTransformationMatrices;
  22898. }
  22899. }
  22900. declare module BABYLON {
  22901. /**
  22902. * Renders a pre pass of the scene
  22903. * This means every mesh in the scene will be rendered to a render target texture
  22904. * And then this texture will be composited to the rendering canvas with post processes
  22905. * It is necessary for effects like subsurface scattering or deferred shading
  22906. */
  22907. export class PrePassRenderer {
  22908. /** @hidden */
  22909. static _SceneComponentInitialization: (scene: Scene) => void;
  22910. private _textureFormats;
  22911. /**
  22912. * To save performance, we can excluded skinned meshes from the prepass
  22913. */
  22914. excludedSkinnedMesh: AbstractMesh[];
  22915. /**
  22916. * Force material to be excluded from the prepass
  22917. * Can be useful when `useGeometryBufferFallback` is set to `true`
  22918. * and you don't want a material to show in the effect.
  22919. */
  22920. excludedMaterials: Material[];
  22921. private _textureIndices;
  22922. private _scene;
  22923. private _engine;
  22924. private _isDirty;
  22925. /**
  22926. * Number of textures in the multi render target texture where the scene is directly rendered
  22927. */
  22928. mrtCount: number;
  22929. /**
  22930. * The render target where the scene is directly rendered
  22931. */
  22932. prePassRT: MultiRenderTarget;
  22933. private _multiRenderAttachments;
  22934. private _defaultAttachments;
  22935. private _postProcesses;
  22936. private readonly _clearColor;
  22937. /**
  22938. * Image processing post process for composition
  22939. */
  22940. imageProcessingPostProcess: ImageProcessingPostProcess;
  22941. /**
  22942. * Configuration for prepass effects
  22943. */
  22944. private _effectConfigurations;
  22945. private _mrtFormats;
  22946. private _mrtLayout;
  22947. private _enabled;
  22948. /**
  22949. * Indicates if the prepass is enabled
  22950. */
  22951. get enabled(): boolean;
  22952. /**
  22953. * How many samples are used for MSAA of the scene render target
  22954. */
  22955. get samples(): number;
  22956. set samples(n: number);
  22957. private _geometryBuffer;
  22958. private _useGeometryBufferFallback;
  22959. /**
  22960. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  22961. */
  22962. get useGeometryBufferFallback(): boolean;
  22963. set useGeometryBufferFallback(value: boolean);
  22964. /**
  22965. * Set to true to disable gamma transform in PrePass.
  22966. * Can be useful in case you already proceed to gamma transform on a material level
  22967. * and your post processes don't need to be in linear color space.
  22968. */
  22969. disableGammaTransform: boolean;
  22970. /**
  22971. * Instanciates a prepass renderer
  22972. * @param scene The scene
  22973. */
  22974. constructor(scene: Scene);
  22975. private _initializeAttachments;
  22976. private _createCompositionEffect;
  22977. /**
  22978. * Indicates if rendering a prepass is supported
  22979. */
  22980. get isSupported(): boolean;
  22981. /**
  22982. * Sets the proper output textures to draw in the engine.
  22983. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  22984. * @param subMesh Submesh on which the effect is applied
  22985. */
  22986. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  22987. /**
  22988. * Restores attachments for single texture draw.
  22989. */
  22990. restoreAttachments(): void;
  22991. /**
  22992. * @hidden
  22993. */
  22994. _beforeCameraDraw(): void;
  22995. /**
  22996. * @hidden
  22997. */
  22998. _afterCameraDraw(): void;
  22999. private _checkRTSize;
  23000. private _bindFrameBuffer;
  23001. /**
  23002. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  23003. */
  23004. clear(): void;
  23005. private _setState;
  23006. private _updateGeometryBufferLayout;
  23007. /**
  23008. * Adds an effect configuration to the prepass.
  23009. * If an effect has already been added, it won't add it twice and will return the configuration
  23010. * already present.
  23011. * @param cfg the effect configuration
  23012. * @return the effect configuration now used by the prepass
  23013. */
  23014. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  23015. /**
  23016. * Returns the index of a texture in the multi render target texture array.
  23017. * @param type Texture type
  23018. * @return The index
  23019. */
  23020. getIndex(type: number): number;
  23021. private _enable;
  23022. private _disable;
  23023. private _resetLayout;
  23024. private _resetPostProcessChain;
  23025. private _bindPostProcessChain;
  23026. /**
  23027. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  23028. */
  23029. markAsDirty(): void;
  23030. /**
  23031. * Enables a texture on the MultiRenderTarget for prepass
  23032. */
  23033. private _enableTextures;
  23034. private _update;
  23035. private _markAllMaterialsAsPrePassDirty;
  23036. /**
  23037. * Disposes the prepass renderer.
  23038. */
  23039. dispose(): void;
  23040. }
  23041. }
  23042. declare module BABYLON {
  23043. /**
  23044. * Size options for a post process
  23045. */
  23046. export type PostProcessOptions = {
  23047. width: number;
  23048. height: number;
  23049. };
  23050. /**
  23051. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23052. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23053. */
  23054. export class PostProcess {
  23055. /**
  23056. * Gets or sets the unique id of the post process
  23057. */
  23058. uniqueId: number;
  23059. /** Name of the PostProcess. */
  23060. name: string;
  23061. /**
  23062. * Width of the texture to apply the post process on
  23063. */
  23064. width: number;
  23065. /**
  23066. * Height of the texture to apply the post process on
  23067. */
  23068. height: number;
  23069. /**
  23070. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23071. */
  23072. nodeMaterialSource: Nullable<NodeMaterial>;
  23073. /**
  23074. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23075. * @hidden
  23076. */
  23077. _outputTexture: Nullable<InternalTexture>;
  23078. /**
  23079. * Sampling mode used by the shader
  23080. * See https://doc.babylonjs.com/classes/3.1/texture
  23081. */
  23082. renderTargetSamplingMode: number;
  23083. /**
  23084. * Clear color to use when screen clearing
  23085. */
  23086. clearColor: Color4;
  23087. /**
  23088. * If the buffer needs to be cleared before applying the post process. (default: true)
  23089. * Should be set to false if shader will overwrite all previous pixels.
  23090. */
  23091. autoClear: boolean;
  23092. /**
  23093. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23094. */
  23095. alphaMode: number;
  23096. /**
  23097. * Sets the setAlphaBlendConstants of the babylon engine
  23098. */
  23099. alphaConstants: Color4;
  23100. /**
  23101. * Animations to be used for the post processing
  23102. */
  23103. animations: Animation[];
  23104. /**
  23105. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23106. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23107. */
  23108. enablePixelPerfectMode: boolean;
  23109. /**
  23110. * Force the postprocess to be applied without taking in account viewport
  23111. */
  23112. forceFullscreenViewport: boolean;
  23113. /**
  23114. * List of inspectable custom properties (used by the Inspector)
  23115. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23116. */
  23117. inspectableCustomProperties: IInspectable[];
  23118. /**
  23119. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23120. *
  23121. * | Value | Type | Description |
  23122. * | ----- | ----------------------------------- | ----------- |
  23123. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23124. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23125. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23126. *
  23127. */
  23128. scaleMode: number;
  23129. /**
  23130. * Force textures to be a power of two (default: false)
  23131. */
  23132. alwaysForcePOT: boolean;
  23133. private _samples;
  23134. /**
  23135. * Number of sample textures (default: 1)
  23136. */
  23137. get samples(): number;
  23138. set samples(n: number);
  23139. /**
  23140. * Modify the scale of the post process to be the same as the viewport (default: false)
  23141. */
  23142. adaptScaleToCurrentViewport: boolean;
  23143. private _camera;
  23144. protected _scene: Scene;
  23145. private _engine;
  23146. private _options;
  23147. private _reusable;
  23148. private _textureType;
  23149. private _textureFormat;
  23150. /**
  23151. * Smart array of input and output textures for the post process.
  23152. * @hidden
  23153. */
  23154. _textures: SmartArray<InternalTexture>;
  23155. /**
  23156. * The index in _textures that corresponds to the output texture.
  23157. * @hidden
  23158. */
  23159. _currentRenderTextureInd: number;
  23160. private _effect;
  23161. private _samplers;
  23162. private _fragmentUrl;
  23163. private _vertexUrl;
  23164. private _parameters;
  23165. private _scaleRatio;
  23166. protected _indexParameters: any;
  23167. private _shareOutputWithPostProcess;
  23168. private _texelSize;
  23169. private _forcedOutputTexture;
  23170. /**
  23171. * Prepass configuration in case this post process needs a texture from prepass
  23172. * @hidden
  23173. */
  23174. _prePassEffectConfiguration: PrePassEffectConfiguration;
  23175. /**
  23176. * Returns the fragment url or shader name used in the post process.
  23177. * @returns the fragment url or name in the shader store.
  23178. */
  23179. getEffectName(): string;
  23180. /**
  23181. * An event triggered when the postprocess is activated.
  23182. */
  23183. onActivateObservable: Observable<Camera>;
  23184. private _onActivateObserver;
  23185. /**
  23186. * A function that is added to the onActivateObservable
  23187. */
  23188. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23189. /**
  23190. * An event triggered when the postprocess changes its size.
  23191. */
  23192. onSizeChangedObservable: Observable<PostProcess>;
  23193. private _onSizeChangedObserver;
  23194. /**
  23195. * A function that is added to the onSizeChangedObservable
  23196. */
  23197. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23198. /**
  23199. * An event triggered when the postprocess applies its effect.
  23200. */
  23201. onApplyObservable: Observable<Effect>;
  23202. private _onApplyObserver;
  23203. /**
  23204. * A function that is added to the onApplyObservable
  23205. */
  23206. set onApply(callback: (effect: Effect) => void);
  23207. /**
  23208. * An event triggered before rendering the postprocess
  23209. */
  23210. onBeforeRenderObservable: Observable<Effect>;
  23211. private _onBeforeRenderObserver;
  23212. /**
  23213. * A function that is added to the onBeforeRenderObservable
  23214. */
  23215. set onBeforeRender(callback: (effect: Effect) => void);
  23216. /**
  23217. * An event triggered after rendering the postprocess
  23218. */
  23219. onAfterRenderObservable: Observable<Effect>;
  23220. private _onAfterRenderObserver;
  23221. /**
  23222. * A function that is added to the onAfterRenderObservable
  23223. */
  23224. set onAfterRender(callback: (efect: Effect) => void);
  23225. /**
  23226. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  23227. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23228. */
  23229. get inputTexture(): InternalTexture;
  23230. set inputTexture(value: InternalTexture);
  23231. /**
  23232. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23233. * the only way to unset it is to use this function to restore its internal state
  23234. */
  23235. restoreDefaultInputTexture(): void;
  23236. /**
  23237. * Gets the camera which post process is applied to.
  23238. * @returns The camera the post process is applied to.
  23239. */
  23240. getCamera(): Camera;
  23241. /**
  23242. * Gets the texel size of the postprocess.
  23243. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23244. */
  23245. get texelSize(): Vector2;
  23246. /**
  23247. * Creates a new instance PostProcess
  23248. * @param name The name of the PostProcess.
  23249. * @param fragmentUrl The url of the fragment shader to be used.
  23250. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23251. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23252. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23253. * @param camera The camera to apply the render pass to.
  23254. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23255. * @param engine The engine which the post process will be applied. (default: current engine)
  23256. * @param reusable If the post process can be reused on the same frame. (default: false)
  23257. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23258. * @param textureType Type of textures used when performing the post process. (default: 0)
  23259. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23260. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  23261. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23262. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23263. */
  23264. constructor(name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  23265. /**
  23266. * Gets a string identifying the name of the class
  23267. * @returns "PostProcess" string
  23268. */
  23269. getClassName(): string;
  23270. /**
  23271. * Gets the engine which this post process belongs to.
  23272. * @returns The engine the post process was enabled with.
  23273. */
  23274. getEngine(): Engine;
  23275. /**
  23276. * The effect that is created when initializing the post process.
  23277. * @returns The created effect corresponding the the postprocess.
  23278. */
  23279. getEffect(): Effect;
  23280. /**
  23281. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23282. * @param postProcess The post process to share the output with.
  23283. * @returns This post process.
  23284. */
  23285. shareOutputWith(postProcess: PostProcess): PostProcess;
  23286. /**
  23287. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23288. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23289. */
  23290. useOwnOutput(): void;
  23291. /**
  23292. * Updates the effect with the current post process compile time values and recompiles the shader.
  23293. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23294. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23295. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23296. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  23297. * @param onCompiled Called when the shader has been compiled.
  23298. * @param onError Called if there is an error when compiling a shader.
  23299. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23300. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23301. */
  23302. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, vertexUrl?: string, fragmentUrl?: string): void;
  23303. /**
  23304. * The post process is reusable if it can be used multiple times within one frame.
  23305. * @returns If the post process is reusable
  23306. */
  23307. isReusable(): boolean;
  23308. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23309. markTextureDirty(): void;
  23310. /**
  23311. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23312. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  23313. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23314. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23315. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23316. * @returns The target texture that was bound to be written to.
  23317. */
  23318. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23319. /**
  23320. * If the post process is supported.
  23321. */
  23322. get isSupported(): boolean;
  23323. /**
  23324. * The aspect ratio of the output texture.
  23325. */
  23326. get aspectRatio(): number;
  23327. /**
  23328. * Get a value indicating if the post-process is ready to be used
  23329. * @returns true if the post-process is ready (shader is compiled)
  23330. */
  23331. isReady(): boolean;
  23332. /**
  23333. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23334. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23335. */
  23336. apply(): Nullable<Effect>;
  23337. private _disposeTextures;
  23338. /**
  23339. * Sets the required values to the prepass renderer.
  23340. * @param prePassRenderer defines the prepass renderer to setup.
  23341. * @returns true if the pre pass is needed.
  23342. */
  23343. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  23344. /**
  23345. * Disposes the post process.
  23346. * @param camera The camera to dispose the post process on.
  23347. */
  23348. dispose(camera?: Camera): void;
  23349. /**
  23350. * Serializes the particle system to a JSON object
  23351. * @returns the JSON object
  23352. */
  23353. serialize(): any;
  23354. /**
  23355. * Creates a material from parsed material data
  23356. * @param parsedPostProcess defines parsed post process data
  23357. * @param scene defines the hosting scene
  23358. * @param rootUrl defines the root URL to use to load textures
  23359. * @returns a new post process
  23360. */
  23361. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23362. }
  23363. }
  23364. declare module BABYLON {
  23365. /** @hidden */
  23366. export var kernelBlurVaryingDeclaration: {
  23367. name: string;
  23368. shader: string;
  23369. };
  23370. }
  23371. declare module BABYLON {
  23372. /** @hidden */
  23373. export var packingFunctions: {
  23374. name: string;
  23375. shader: string;
  23376. };
  23377. }
  23378. declare module BABYLON {
  23379. /** @hidden */
  23380. export var kernelBlurFragment: {
  23381. name: string;
  23382. shader: string;
  23383. };
  23384. }
  23385. declare module BABYLON {
  23386. /** @hidden */
  23387. export var kernelBlurFragment2: {
  23388. name: string;
  23389. shader: string;
  23390. };
  23391. }
  23392. declare module BABYLON {
  23393. /** @hidden */
  23394. export var kernelBlurPixelShader: {
  23395. name: string;
  23396. shader: string;
  23397. };
  23398. }
  23399. declare module BABYLON {
  23400. /** @hidden */
  23401. export var kernelBlurVertex: {
  23402. name: string;
  23403. shader: string;
  23404. };
  23405. }
  23406. declare module BABYLON {
  23407. /** @hidden */
  23408. export var kernelBlurVertexShader: {
  23409. name: string;
  23410. shader: string;
  23411. };
  23412. }
  23413. declare module BABYLON {
  23414. /**
  23415. * The Blur Post Process which blurs an image based on a kernel and direction.
  23416. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23417. */
  23418. export class BlurPostProcess extends PostProcess {
  23419. private blockCompilation;
  23420. protected _kernel: number;
  23421. protected _idealKernel: number;
  23422. protected _packedFloat: boolean;
  23423. private _staticDefines;
  23424. /** The direction in which to blur the image. */
  23425. direction: Vector2;
  23426. /**
  23427. * Sets the length in pixels of the blur sample region
  23428. */
  23429. set kernel(v: number);
  23430. /**
  23431. * Gets the length in pixels of the blur sample region
  23432. */
  23433. get kernel(): number;
  23434. /**
  23435. * Sets wether or not the blur needs to unpack/repack floats
  23436. */
  23437. set packedFloat(v: boolean);
  23438. /**
  23439. * Gets wether or not the blur is unpacking/repacking floats
  23440. */
  23441. get packedFloat(): boolean;
  23442. /**
  23443. * Gets a string identifying the name of the class
  23444. * @returns "BlurPostProcess" string
  23445. */
  23446. getClassName(): string;
  23447. /**
  23448. * Creates a new instance BlurPostProcess
  23449. * @param name The name of the effect.
  23450. * @param direction The direction in which to blur the image.
  23451. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  23452. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23453. * @param camera The camera to apply the render pass to.
  23454. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23455. * @param engine The engine which the post process will be applied. (default: current engine)
  23456. * @param reusable If the post process can be reused on the same frame. (default: false)
  23457. * @param textureType Type of textures used when performing the post process. (default: 0)
  23458. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  23459. */
  23460. constructor(name: string, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23461. /**
  23462. * Updates the effect with the current post process compile time values and recompiles the shader.
  23463. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23464. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23465. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23466. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  23467. * @param onCompiled Called when the shader has been compiled.
  23468. * @param onError Called if there is an error when compiling a shader.
  23469. */
  23470. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23471. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23472. /**
  23473. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23474. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23475. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23476. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23477. * The gaps between physical kernels are compensated for in the weighting of the samples
  23478. * @param idealKernel Ideal blur kernel.
  23479. * @return Nearest best kernel.
  23480. */
  23481. protected _nearestBestKernel(idealKernel: number): number;
  23482. /**
  23483. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23484. * @param x The point on the Gaussian distribution to sample.
  23485. * @return the value of the Gaussian function at x.
  23486. */
  23487. protected _gaussianWeight(x: number): number;
  23488. /**
  23489. * Generates a string that can be used as a floating point number in GLSL.
  23490. * @param x Value to print.
  23491. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23492. * @return GLSL float string.
  23493. */
  23494. protected _glslFloat(x: number, decimalFigures?: number): string;
  23495. /** @hidden */
  23496. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23497. }
  23498. }
  23499. declare module BABYLON {
  23500. /**
  23501. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23502. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23503. * You can then easily use it as a reflectionTexture on a flat surface.
  23504. * In case the surface is not a plane, please consider relying on reflection probes.
  23505. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23506. */
  23507. export class MirrorTexture extends RenderTargetTexture {
  23508. private scene;
  23509. /**
  23510. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23511. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  23512. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23513. */
  23514. mirrorPlane: Plane;
  23515. /**
  23516. * Define the blur ratio used to blur the reflection if needed.
  23517. */
  23518. set blurRatio(value: number);
  23519. get blurRatio(): number;
  23520. /**
  23521. * Define the adaptive blur kernel used to blur the reflection if needed.
  23522. * This will autocompute the closest best match for the `blurKernel`
  23523. */
  23524. set adaptiveBlurKernel(value: number);
  23525. /**
  23526. * Define the blur kernel used to blur the reflection if needed.
  23527. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23528. */
  23529. set blurKernel(value: number);
  23530. /**
  23531. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23532. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23533. */
  23534. set blurKernelX(value: number);
  23535. get blurKernelX(): number;
  23536. /**
  23537. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23538. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23539. */
  23540. set blurKernelY(value: number);
  23541. get blurKernelY(): number;
  23542. private _autoComputeBlurKernel;
  23543. protected _onRatioRescale(): void;
  23544. private _updateGammaSpace;
  23545. private _imageProcessingConfigChangeObserver;
  23546. private _transformMatrix;
  23547. private _mirrorMatrix;
  23548. private _savedViewMatrix;
  23549. private _blurX;
  23550. private _blurY;
  23551. private _adaptiveBlurKernel;
  23552. private _blurKernelX;
  23553. private _blurKernelY;
  23554. private _blurRatio;
  23555. /**
  23556. * Instantiates a Mirror Texture.
  23557. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23558. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23559. * You can then easily use it as a reflectionTexture on a flat surface.
  23560. * In case the surface is not a plane, please consider relying on reflection probes.
  23561. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23562. * @param name
  23563. * @param size
  23564. * @param scene
  23565. * @param generateMipMaps
  23566. * @param type
  23567. * @param samplingMode
  23568. * @param generateDepthBuffer
  23569. */
  23570. constructor(name: string, size: number | {
  23571. width: number;
  23572. height: number;
  23573. } | {
  23574. ratio: number;
  23575. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23576. private _preparePostProcesses;
  23577. /**
  23578. * Clone the mirror texture.
  23579. * @returns the cloned texture
  23580. */
  23581. clone(): MirrorTexture;
  23582. /**
  23583. * Serialize the texture to a JSON representation you could use in Parse later on
  23584. * @returns the serialized JSON representation
  23585. */
  23586. serialize(): any;
  23587. /**
  23588. * Dispose the texture and release its associated resources.
  23589. */
  23590. dispose(): void;
  23591. }
  23592. }
  23593. declare module BABYLON {
  23594. /**
  23595. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23596. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23597. */
  23598. export class Texture extends BaseTexture {
  23599. /**
  23600. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23601. */
  23602. static SerializeBuffers: boolean;
  23603. /**
  23604. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  23605. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  23606. */
  23607. static ForceSerializeBuffers: boolean;
  23608. /** @hidden */
  23609. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23610. /** @hidden */
  23611. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23612. /** @hidden */
  23613. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23614. /** nearest is mag = nearest and min = nearest and mip = linear */
  23615. static readonly NEAREST_SAMPLINGMODE: number;
  23616. /** nearest is mag = nearest and min = nearest and mip = linear */
  23617. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23618. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23619. static readonly BILINEAR_SAMPLINGMODE: number;
  23620. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23621. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23622. /** Trilinear is mag = linear and min = linear and mip = linear */
  23623. static readonly TRILINEAR_SAMPLINGMODE: number;
  23624. /** Trilinear is mag = linear and min = linear and mip = linear */
  23625. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23626. /** mag = nearest and min = nearest and mip = nearest */
  23627. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23628. /** mag = nearest and min = linear and mip = nearest */
  23629. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23630. /** mag = nearest and min = linear and mip = linear */
  23631. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23632. /** mag = nearest and min = linear and mip = none */
  23633. static readonly NEAREST_LINEAR: number;
  23634. /** mag = nearest and min = nearest and mip = none */
  23635. static readonly NEAREST_NEAREST: number;
  23636. /** mag = linear and min = nearest and mip = nearest */
  23637. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23638. /** mag = linear and min = nearest and mip = linear */
  23639. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23640. /** mag = linear and min = linear and mip = none */
  23641. static readonly LINEAR_LINEAR: number;
  23642. /** mag = linear and min = nearest and mip = none */
  23643. static readonly LINEAR_NEAREST: number;
  23644. /** Explicit coordinates mode */
  23645. static readonly EXPLICIT_MODE: number;
  23646. /** Spherical coordinates mode */
  23647. static readonly SPHERICAL_MODE: number;
  23648. /** Planar coordinates mode */
  23649. static readonly PLANAR_MODE: number;
  23650. /** Cubic coordinates mode */
  23651. static readonly CUBIC_MODE: number;
  23652. /** Projection coordinates mode */
  23653. static readonly PROJECTION_MODE: number;
  23654. /** Inverse Cubic coordinates mode */
  23655. static readonly SKYBOX_MODE: number;
  23656. /** Inverse Cubic coordinates mode */
  23657. static readonly INVCUBIC_MODE: number;
  23658. /** Equirectangular coordinates mode */
  23659. static readonly EQUIRECTANGULAR_MODE: number;
  23660. /** Equirectangular Fixed coordinates mode */
  23661. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23662. /** Equirectangular Fixed Mirrored coordinates mode */
  23663. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23664. /** Texture is not repeating outside of 0..1 UVs */
  23665. static readonly CLAMP_ADDRESSMODE: number;
  23666. /** Texture is repeating outside of 0..1 UVs */
  23667. static readonly WRAP_ADDRESSMODE: number;
  23668. /** Texture is repeating and mirrored */
  23669. static readonly MIRROR_ADDRESSMODE: number;
  23670. /**
  23671. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  23672. */
  23673. static UseSerializedUrlIfAny: boolean;
  23674. /**
  23675. * Define the url of the texture.
  23676. */
  23677. url: Nullable<string>;
  23678. /**
  23679. * Define an offset on the texture to offset the u coordinates of the UVs
  23680. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23681. */
  23682. uOffset: number;
  23683. /**
  23684. * Define an offset on the texture to offset the v coordinates of the UVs
  23685. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23686. */
  23687. vOffset: number;
  23688. /**
  23689. * Define an offset on the texture to scale the u coordinates of the UVs
  23690. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23691. */
  23692. uScale: number;
  23693. /**
  23694. * Define an offset on the texture to scale the v coordinates of the UVs
  23695. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23696. */
  23697. vScale: number;
  23698. /**
  23699. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23700. * @see https://doc.babylonjs.com/how_to/more_materials
  23701. */
  23702. uAng: number;
  23703. /**
  23704. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23705. * @see https://doc.babylonjs.com/how_to/more_materials
  23706. */
  23707. vAng: number;
  23708. /**
  23709. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23710. * @see https://doc.babylonjs.com/how_to/more_materials
  23711. */
  23712. wAng: number;
  23713. /**
  23714. * Defines the center of rotation (U)
  23715. */
  23716. uRotationCenter: number;
  23717. /**
  23718. * Defines the center of rotation (V)
  23719. */
  23720. vRotationCenter: number;
  23721. /**
  23722. * Defines the center of rotation (W)
  23723. */
  23724. wRotationCenter: number;
  23725. /**
  23726. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  23727. */
  23728. homogeneousRotationInUVTransform: boolean;
  23729. /**
  23730. * Are mip maps generated for this texture or not.
  23731. */
  23732. get noMipmap(): boolean;
  23733. /**
  23734. * List of inspectable custom properties (used by the Inspector)
  23735. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23736. */
  23737. inspectableCustomProperties: Nullable<IInspectable[]>;
  23738. private _noMipmap;
  23739. /** @hidden */
  23740. _invertY: boolean;
  23741. private _rowGenerationMatrix;
  23742. private _cachedTextureMatrix;
  23743. private _projectionModeMatrix;
  23744. private _t0;
  23745. private _t1;
  23746. private _t2;
  23747. private _cachedUOffset;
  23748. private _cachedVOffset;
  23749. private _cachedUScale;
  23750. private _cachedVScale;
  23751. private _cachedUAng;
  23752. private _cachedVAng;
  23753. private _cachedWAng;
  23754. private _cachedProjectionMatrixId;
  23755. private _cachedURotationCenter;
  23756. private _cachedVRotationCenter;
  23757. private _cachedWRotationCenter;
  23758. private _cachedHomogeneousRotationInUVTransform;
  23759. private _cachedCoordinatesMode;
  23760. /** @hidden */
  23761. protected _initialSamplingMode: number;
  23762. /** @hidden */
  23763. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23764. private _deleteBuffer;
  23765. protected _format: Nullable<number>;
  23766. private _delayedOnLoad;
  23767. private _delayedOnError;
  23768. private _mimeType?;
  23769. private _loaderOptions?;
  23770. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23771. get mimeType(): string | undefined;
  23772. /**
  23773. * Observable triggered once the texture has been loaded.
  23774. */
  23775. onLoadObservable: Observable<Texture>;
  23776. protected _isBlocking: boolean;
  23777. /**
  23778. * Is the texture preventing material to render while loading.
  23779. * If false, a default texture will be used instead of the loading one during the preparation step.
  23780. */
  23781. set isBlocking(value: boolean);
  23782. get isBlocking(): boolean;
  23783. /**
  23784. * Get the current sampling mode associated with the texture.
  23785. */
  23786. get samplingMode(): number;
  23787. /**
  23788. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23789. */
  23790. get invertY(): boolean;
  23791. /**
  23792. * Instantiates a new texture.
  23793. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23794. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23795. * @param url defines the url of the picture to load as a texture
  23796. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23797. * @param noMipmap defines if the texture will require mip maps or not
  23798. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23799. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23800. * @param onLoad defines a callback triggered when the texture has been loaded
  23801. * @param onError defines a callback triggered when an error occurred during the loading session
  23802. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23803. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23804. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23805. * @param mimeType defines an optional mime type information
  23806. * @param loaderOptions options to be passed to the loader
  23807. */
  23808. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string, loaderOptions?: any);
  23809. /**
  23810. * Update the url (and optional buffer) of this texture if url was null during construction.
  23811. * @param url the url of the texture
  23812. * @param buffer the buffer of the texture (defaults to null)
  23813. * @param onLoad callback called when the texture is loaded (defaults to null)
  23814. */
  23815. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23816. /**
  23817. * Finish the loading sequence of a texture flagged as delayed load.
  23818. * @hidden
  23819. */
  23820. delayLoad(): void;
  23821. private _prepareRowForTextureGeneration;
  23822. /**
  23823. * Checks if the texture has the same transform matrix than another texture
  23824. * @param texture texture to check against
  23825. * @returns true if the transforms are the same, else false
  23826. */
  23827. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  23828. /**
  23829. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23830. * @returns the transform matrix of the texture.
  23831. */
  23832. getTextureMatrix(uBase?: number): Matrix;
  23833. /**
  23834. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23835. * @returns The reflection texture transform
  23836. */
  23837. getReflectionTextureMatrix(): Matrix;
  23838. /**
  23839. * Clones the texture.
  23840. * @returns the cloned texture
  23841. */
  23842. clone(): Texture;
  23843. /**
  23844. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23845. * @returns The JSON representation of the texture
  23846. */
  23847. serialize(): any;
  23848. /**
  23849. * Get the current class name of the texture useful for serialization or dynamic coding.
  23850. * @returns "Texture"
  23851. */
  23852. getClassName(): string;
  23853. /**
  23854. * Dispose the texture and release its associated resources.
  23855. */
  23856. dispose(): void;
  23857. /**
  23858. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23859. * @param parsedTexture Define the JSON representation of the texture
  23860. * @param scene Define the scene the parsed texture should be instantiated in
  23861. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23862. * @returns The parsed texture if successful
  23863. */
  23864. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23865. /**
  23866. * Creates a texture from its base 64 representation.
  23867. * @param data Define the base64 payload without the data: prefix
  23868. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23869. * @param scene Define the scene the texture should belong to
  23870. * @param noMipmap Forces the texture to not create mip map information if true
  23871. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23872. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23873. * @param onLoad define a callback triggered when the texture has been loaded
  23874. * @param onError define a callback triggered when an error occurred during the loading session
  23875. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23876. * @returns the created texture
  23877. */
  23878. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23879. /**
  23880. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23881. * @param data Define the base64 payload without the data: prefix
  23882. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23883. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23884. * @param scene Define the scene the texture should belong to
  23885. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23886. * @param noMipmap Forces the texture to not create mip map information if true
  23887. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23888. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23889. * @param onLoad define a callback triggered when the texture has been loaded
  23890. * @param onError define a callback triggered when an error occurred during the loading session
  23891. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23892. * @returns the created texture
  23893. */
  23894. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  23895. }
  23896. }
  23897. declare module BABYLON {
  23898. /**
  23899. * ThinSprite Class used to represent a thin sprite
  23900. * This is the base class for sprites but can also directly be used with ThinEngine
  23901. * @see https://doc.babylonjs.com/babylon101/sprites
  23902. */
  23903. export class ThinSprite {
  23904. /** Gets or sets the cell index in the sprite sheet */
  23905. cellIndex: number;
  23906. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  23907. cellRef: string;
  23908. /** Gets or sets the current world position */
  23909. position: IVector3Like;
  23910. /** Gets or sets the main color */
  23911. color: IColor4Like;
  23912. /** Gets or sets the width */
  23913. width: number;
  23914. /** Gets or sets the height */
  23915. height: number;
  23916. /** Gets or sets rotation angle */
  23917. angle: number;
  23918. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  23919. invertU: boolean;
  23920. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  23921. invertV: boolean;
  23922. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  23923. isVisible: boolean;
  23924. /**
  23925. * Returns a boolean indicating if the animation is started
  23926. */
  23927. get animationStarted(): boolean;
  23928. /** Gets the initial key for the animation (setting it will restart the animation) */
  23929. get fromIndex(): number;
  23930. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  23931. get toIndex(): number;
  23932. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  23933. get loopAnimation(): boolean;
  23934. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  23935. get delay(): number;
  23936. /** @hidden */
  23937. _xOffset: number;
  23938. /** @hidden */
  23939. _yOffset: number;
  23940. /** @hidden */
  23941. _xSize: number;
  23942. /** @hidden */
  23943. _ySize: number;
  23944. private _animationStarted;
  23945. protected _loopAnimation: boolean;
  23946. protected _fromIndex: number;
  23947. protected _toIndex: number;
  23948. protected _delay: number;
  23949. private _direction;
  23950. private _time;
  23951. private _onBaseAnimationEnd;
  23952. /**
  23953. * Creates a new Thin Sprite
  23954. */
  23955. constructor();
  23956. /**
  23957. * Starts an animation
  23958. * @param from defines the initial key
  23959. * @param to defines the end key
  23960. * @param loop defines if the animation must loop
  23961. * @param delay defines the start delay (in ms)
  23962. * @param onAnimationEnd defines a callback for when the animation ends
  23963. */
  23964. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  23965. /** Stops current animation (if any) */
  23966. stopAnimation(): void;
  23967. /** @hidden */
  23968. _animate(deltaTime: number): void;
  23969. }
  23970. }
  23971. declare module BABYLON {
  23972. /** @hidden */
  23973. export var imageProcessingCompatibility: {
  23974. name: string;
  23975. shader: string;
  23976. };
  23977. }
  23978. declare module BABYLON {
  23979. /** @hidden */
  23980. export var spritesPixelShader: {
  23981. name: string;
  23982. shader: string;
  23983. };
  23984. }
  23985. declare module BABYLON {
  23986. /** @hidden */
  23987. export var spritesVertexShader: {
  23988. name: string;
  23989. shader: string;
  23990. };
  23991. }
  23992. declare module BABYLON {
  23993. /**
  23994. * Class used to render sprites.
  23995. *
  23996. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  23997. */
  23998. export class SpriteRenderer {
  23999. /**
  24000. * Defines the texture of the spritesheet
  24001. */
  24002. texture: Nullable<ThinTexture>;
  24003. /**
  24004. * Defines the default width of a cell in the spritesheet
  24005. */
  24006. cellWidth: number;
  24007. /**
  24008. * Defines the default height of a cell in the spritesheet
  24009. */
  24010. cellHeight: number;
  24011. /**
  24012. * Blend mode use to render the particle, it can be any of
  24013. * the static Constants.ALPHA_x properties provided in this class.
  24014. * Default value is Constants.ALPHA_COMBINE
  24015. */
  24016. blendMode: number;
  24017. /**
  24018. * Gets or sets a boolean indicating if alpha mode is automatically
  24019. * reset.
  24020. */
  24021. autoResetAlpha: boolean;
  24022. /**
  24023. * Disables writing to the depth buffer when rendering the sprites.
  24024. * It can be handy to disable depth writing when using textures without alpha channel
  24025. * and setting some specific blend modes.
  24026. */
  24027. disableDepthWrite: boolean;
  24028. /**
  24029. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  24030. */
  24031. fogEnabled: boolean;
  24032. /**
  24033. * Gets the capacity of the manager
  24034. */
  24035. get capacity(): number;
  24036. private readonly _engine;
  24037. private readonly _useVAO;
  24038. private readonly _useInstancing;
  24039. private readonly _scene;
  24040. private readonly _capacity;
  24041. private readonly _epsilon;
  24042. private _vertexBufferSize;
  24043. private _vertexData;
  24044. private _buffer;
  24045. private _vertexBuffers;
  24046. private _spriteBuffer;
  24047. private _indexBuffer;
  24048. private _effectBase;
  24049. private _effectFog;
  24050. private _vertexArrayObject;
  24051. /**
  24052. * Creates a new sprite Renderer
  24053. * @param engine defines the engine the renderer works with
  24054. * @param capacity defines the maximum allowed number of sprites
  24055. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24056. * @param scene defines the hosting scene
  24057. */
  24058. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  24059. /**
  24060. * Render all child sprites
  24061. * @param sprites defines the list of sprites to render
  24062. * @param deltaTime defines the time since last frame
  24063. * @param viewMatrix defines the viewMatrix to use to render the sprites
  24064. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  24065. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  24066. */
  24067. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  24068. private _appendSpriteVertex;
  24069. /**
  24070. * Release associated resources
  24071. */
  24072. dispose(): void;
  24073. }
  24074. }
  24075. declare module BABYLON {
  24076. /**
  24077. * Defines the minimum interface to fullfil in order to be a sprite manager.
  24078. */
  24079. export interface ISpriteManager extends IDisposable {
  24080. /**
  24081. * Gets manager's name
  24082. */
  24083. name: string;
  24084. /**
  24085. * Restricts the camera to viewing objects with the same layerMask.
  24086. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  24087. */
  24088. layerMask: number;
  24089. /**
  24090. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24091. */
  24092. isPickable: boolean;
  24093. /**
  24094. * Gets the hosting scene
  24095. */
  24096. scene: Scene;
  24097. /**
  24098. * Specifies the rendering group id for this mesh (0 by default)
  24099. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24100. */
  24101. renderingGroupId: number;
  24102. /**
  24103. * Defines the list of sprites managed by the manager.
  24104. */
  24105. sprites: Array<Sprite>;
  24106. /**
  24107. * Gets or sets the spritesheet texture
  24108. */
  24109. texture: Texture;
  24110. /** Defines the default width of a cell in the spritesheet */
  24111. cellWidth: number;
  24112. /** Defines the default height of a cell in the spritesheet */
  24113. cellHeight: number;
  24114. /**
  24115. * Tests the intersection of a sprite with a specific ray.
  24116. * @param ray The ray we are sending to test the collision
  24117. * @param camera The camera space we are sending rays in
  24118. * @param predicate A predicate allowing excluding sprites from the list of object to test
  24119. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24120. * @returns picking info or null.
  24121. */
  24122. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24123. /**
  24124. * Intersects the sprites with a ray
  24125. * @param ray defines the ray to intersect with
  24126. * @param camera defines the current active camera
  24127. * @param predicate defines a predicate used to select candidate sprites
  24128. * @returns null if no hit or a PickingInfo array
  24129. */
  24130. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24131. /**
  24132. * Renders the list of sprites on screen.
  24133. */
  24134. render(): void;
  24135. }
  24136. /**
  24137. * Class used to manage multiple sprites on the same spritesheet
  24138. * @see https://doc.babylonjs.com/babylon101/sprites
  24139. */
  24140. export class SpriteManager implements ISpriteManager {
  24141. /** defines the manager's name */
  24142. name: string;
  24143. /** Define the Url to load snippets */
  24144. static SnippetUrl: string;
  24145. /** Snippet ID if the manager was created from the snippet server */
  24146. snippetId: string;
  24147. /** Gets the list of sprites */
  24148. sprites: Sprite[];
  24149. /** Gets or sets the rendering group id (0 by default) */
  24150. renderingGroupId: number;
  24151. /** Gets or sets camera layer mask */
  24152. layerMask: number;
  24153. /** Gets or sets a boolean indicating if the sprites are pickable */
  24154. isPickable: boolean;
  24155. /**
  24156. * An event triggered when the manager is disposed.
  24157. */
  24158. onDisposeObservable: Observable<SpriteManager>;
  24159. /**
  24160. * Callback called when the manager is disposed
  24161. */
  24162. set onDispose(callback: () => void);
  24163. /**
  24164. * Gets or sets the unique id of the sprite
  24165. */
  24166. uniqueId: number;
  24167. /**
  24168. * Gets the array of sprites
  24169. */
  24170. get children(): Sprite[];
  24171. /**
  24172. * Gets the hosting scene
  24173. */
  24174. get scene(): Scene;
  24175. /**
  24176. * Gets the capacity of the manager
  24177. */
  24178. get capacity(): number;
  24179. /**
  24180. * Gets or sets the spritesheet texture
  24181. */
  24182. get texture(): Texture;
  24183. set texture(value: Texture);
  24184. /** Defines the default width of a cell in the spritesheet */
  24185. get cellWidth(): number;
  24186. set cellWidth(value: number);
  24187. /** Defines the default height of a cell in the spritesheet */
  24188. get cellHeight(): number;
  24189. set cellHeight(value: number);
  24190. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  24191. get fogEnabled(): boolean;
  24192. set fogEnabled(value: boolean);
  24193. /**
  24194. * Blend mode use to render the particle, it can be any of
  24195. * the static Constants.ALPHA_x properties provided in this class.
  24196. * Default value is Constants.ALPHA_COMBINE
  24197. */
  24198. get blendMode(): number;
  24199. set blendMode(blendMode: number);
  24200. /** Disables writing to the depth buffer when rendering the sprites.
  24201. * It can be handy to disable depth writing when using textures without alpha channel
  24202. * and setting some specific blend modes.
  24203. */
  24204. disableDepthWrite: boolean;
  24205. private _spriteRenderer;
  24206. /** Associative array from JSON sprite data file */
  24207. private _cellData;
  24208. /** Array of sprite names from JSON sprite data file */
  24209. private _spriteMap;
  24210. /** True when packed cell data from JSON file is ready*/
  24211. private _packedAndReady;
  24212. private _textureContent;
  24213. private _onDisposeObserver;
  24214. private _fromPacked;
  24215. private _scene;
  24216. /**
  24217. * Creates a new sprite manager
  24218. * @param name defines the manager's name
  24219. * @param imgUrl defines the sprite sheet url
  24220. * @param capacity defines the maximum allowed number of sprites
  24221. * @param cellSize defines the size of a sprite cell
  24222. * @param scene defines the hosting scene
  24223. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24224. * @param samplingMode defines the smapling mode to use with spritesheet
  24225. * @param fromPacked set to false; do not alter
  24226. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  24227. */
  24228. constructor(
  24229. /** defines the manager's name */
  24230. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  24231. /**
  24232. * Returns the string "SpriteManager"
  24233. * @returns "SpriteManager"
  24234. */
  24235. getClassName(): string;
  24236. private _makePacked;
  24237. private _checkTextureAlpha;
  24238. /**
  24239. * Intersects the sprites with a ray
  24240. * @param ray defines the ray to intersect with
  24241. * @param camera defines the current active camera
  24242. * @param predicate defines a predicate used to select candidate sprites
  24243. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  24244. * @returns null if no hit or a PickingInfo
  24245. */
  24246. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24247. /**
  24248. * Intersects the sprites with a ray
  24249. * @param ray defines the ray to intersect with
  24250. * @param camera defines the current active camera
  24251. * @param predicate defines a predicate used to select candidate sprites
  24252. * @returns null if no hit or a PickingInfo array
  24253. */
  24254. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24255. /**
  24256. * Render all child sprites
  24257. */
  24258. render(): void;
  24259. private _customUpdate;
  24260. /**
  24261. * Release associated resources
  24262. */
  24263. dispose(): void;
  24264. /**
  24265. * Serializes the sprite manager to a JSON object
  24266. * @param serializeTexture defines if the texture must be serialized as well
  24267. * @returns the JSON object
  24268. */
  24269. serialize(serializeTexture?: boolean): any;
  24270. /**
  24271. * Parses a JSON object to create a new sprite manager.
  24272. * @param parsedManager The JSON object to parse
  24273. * @param scene The scene to create the sprite managerin
  24274. * @param rootUrl The root url to use to load external dependencies like texture
  24275. * @returns the new sprite manager
  24276. */
  24277. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  24278. /**
  24279. * Creates a sprite manager from a snippet saved in a remote file
  24280. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  24281. * @param url defines the url to load from
  24282. * @param scene defines the hosting scene
  24283. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24284. * @returns a promise that will resolve to the new sprite manager
  24285. */
  24286. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24287. /**
  24288. * Creates a sprite manager from a snippet saved by the sprite editor
  24289. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  24290. * @param scene defines the hosting scene
  24291. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24292. * @returns a promise that will resolve to the new sprite manager
  24293. */
  24294. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24295. }
  24296. }
  24297. declare module BABYLON {
  24298. /**
  24299. * Class used to represent a sprite
  24300. * @see https://doc.babylonjs.com/babylon101/sprites
  24301. */
  24302. export class Sprite extends ThinSprite implements IAnimatable {
  24303. /** defines the name */
  24304. name: string;
  24305. /** Gets or sets the current world position */
  24306. position: Vector3;
  24307. /** Gets or sets the main color */
  24308. color: Color4;
  24309. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  24310. disposeWhenFinishedAnimating: boolean;
  24311. /** Gets the list of attached animations */
  24312. animations: Nullable<Array<Animation>>;
  24313. /** Gets or sets a boolean indicating if the sprite can be picked */
  24314. isPickable: boolean;
  24315. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  24316. useAlphaForPicking: boolean;
  24317. /**
  24318. * Gets or sets the associated action manager
  24319. */
  24320. actionManager: Nullable<ActionManager>;
  24321. /**
  24322. * An event triggered when the control has been disposed
  24323. */
  24324. onDisposeObservable: Observable<Sprite>;
  24325. private _manager;
  24326. private _onAnimationEnd;
  24327. /**
  24328. * Gets or sets the sprite size
  24329. */
  24330. get size(): number;
  24331. set size(value: number);
  24332. /**
  24333. * Gets or sets the unique id of the sprite
  24334. */
  24335. uniqueId: number;
  24336. /**
  24337. * Gets the manager of this sprite
  24338. */
  24339. get manager(): ISpriteManager;
  24340. /**
  24341. * Creates a new Sprite
  24342. * @param name defines the name
  24343. * @param manager defines the manager
  24344. */
  24345. constructor(
  24346. /** defines the name */
  24347. name: string, manager: ISpriteManager);
  24348. /**
  24349. * Returns the string "Sprite"
  24350. * @returns "Sprite"
  24351. */
  24352. getClassName(): string;
  24353. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  24354. get fromIndex(): number;
  24355. set fromIndex(value: number);
  24356. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24357. get toIndex(): number;
  24358. set toIndex(value: number);
  24359. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24360. get loopAnimation(): boolean;
  24361. set loopAnimation(value: boolean);
  24362. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24363. get delay(): number;
  24364. set delay(value: number);
  24365. /**
  24366. * Starts an animation
  24367. * @param from defines the initial key
  24368. * @param to defines the end key
  24369. * @param loop defines if the animation must loop
  24370. * @param delay defines the start delay (in ms)
  24371. * @param onAnimationEnd defines a callback to call when animation ends
  24372. */
  24373. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  24374. private _endAnimation;
  24375. /** Release associated resources */
  24376. dispose(): void;
  24377. /**
  24378. * Serializes the sprite to a JSON object
  24379. * @returns the JSON object
  24380. */
  24381. serialize(): any;
  24382. /**
  24383. * Parses a JSON object to create a new sprite
  24384. * @param parsedSprite The JSON object to parse
  24385. * @param manager defines the hosting manager
  24386. * @returns the new sprite
  24387. */
  24388. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  24389. }
  24390. }
  24391. declare module BABYLON {
  24392. /**
  24393. * Information about the result of picking within a scene
  24394. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24395. */
  24396. export class PickingInfo {
  24397. /** @hidden */
  24398. _pickingUnavailable: boolean;
  24399. /**
  24400. * If the pick collided with an object
  24401. */
  24402. hit: boolean;
  24403. /**
  24404. * Distance away where the pick collided
  24405. */
  24406. distance: number;
  24407. /**
  24408. * The location of pick collision
  24409. */
  24410. pickedPoint: Nullable<Vector3>;
  24411. /**
  24412. * The mesh corresponding the the pick collision
  24413. */
  24414. pickedMesh: Nullable<AbstractMesh>;
  24415. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  24416. bu: number;
  24417. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  24418. bv: number;
  24419. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24420. faceId: number;
  24421. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24422. subMeshFaceId: number;
  24423. /** Id of the the submesh that was picked */
  24424. subMeshId: number;
  24425. /** If a sprite was picked, this will be the sprite the pick collided with */
  24426. pickedSprite: Nullable<Sprite>;
  24427. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  24428. thinInstanceIndex: number;
  24429. /**
  24430. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24431. */
  24432. originMesh: Nullable<AbstractMesh>;
  24433. /**
  24434. * The ray that was used to perform the picking.
  24435. */
  24436. ray: Nullable<Ray>;
  24437. /**
  24438. * Gets the normal correspodning to the face the pick collided with
  24439. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  24440. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  24441. * @returns The normal correspodning to the face the pick collided with
  24442. */
  24443. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  24444. /**
  24445. * Gets the texture coordinates of where the pick occured
  24446. * @returns the vector containing the coordnates of the texture
  24447. */
  24448. getTextureCoordinates(): Nullable<Vector2>;
  24449. }
  24450. }
  24451. declare module BABYLON {
  24452. /**
  24453. * Gather the list of pointer event types as constants.
  24454. */
  24455. export class PointerEventTypes {
  24456. /**
  24457. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  24458. */
  24459. static readonly POINTERDOWN: number;
  24460. /**
  24461. * The pointerup event is fired when a pointer is no longer active.
  24462. */
  24463. static readonly POINTERUP: number;
  24464. /**
  24465. * The pointermove event is fired when a pointer changes coordinates.
  24466. */
  24467. static readonly POINTERMOVE: number;
  24468. /**
  24469. * The pointerwheel event is fired when a mouse wheel has been rotated.
  24470. */
  24471. static readonly POINTERWHEEL: number;
  24472. /**
  24473. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  24474. */
  24475. static readonly POINTERPICK: number;
  24476. /**
  24477. * The pointertap event is fired when a the object has been touched and released without drag.
  24478. */
  24479. static readonly POINTERTAP: number;
  24480. /**
  24481. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  24482. */
  24483. static readonly POINTERDOUBLETAP: number;
  24484. }
  24485. /**
  24486. * Base class of pointer info types.
  24487. */
  24488. export class PointerInfoBase {
  24489. /**
  24490. * Defines the type of event (PointerEventTypes)
  24491. */
  24492. type: number;
  24493. /**
  24494. * Defines the related dom event
  24495. */
  24496. event: PointerEvent | MouseWheelEvent;
  24497. /**
  24498. * Instantiates the base class of pointers info.
  24499. * @param type Defines the type of event (PointerEventTypes)
  24500. * @param event Defines the related dom event
  24501. */
  24502. constructor(
  24503. /**
  24504. * Defines the type of event (PointerEventTypes)
  24505. */
  24506. type: number,
  24507. /**
  24508. * Defines the related dom event
  24509. */
  24510. event: PointerEvent | MouseWheelEvent);
  24511. }
  24512. /**
  24513. * This class is used to store pointer related info for the onPrePointerObservable event.
  24514. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  24515. */
  24516. export class PointerInfoPre extends PointerInfoBase {
  24517. /**
  24518. * Ray from a pointer if availible (eg. 6dof controller)
  24519. */
  24520. ray: Nullable<Ray>;
  24521. /**
  24522. * Defines the local position of the pointer on the canvas.
  24523. */
  24524. localPosition: Vector2;
  24525. /**
  24526. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  24527. */
  24528. skipOnPointerObservable: boolean;
  24529. /**
  24530. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  24531. * @param type Defines the type of event (PointerEventTypes)
  24532. * @param event Defines the related dom event
  24533. * @param localX Defines the local x coordinates of the pointer when the event occured
  24534. * @param localY Defines the local y coordinates of the pointer when the event occured
  24535. */
  24536. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  24537. }
  24538. /**
  24539. * This type contains all the data related to a pointer event in Babylon.js.
  24540. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  24541. */
  24542. export class PointerInfo extends PointerInfoBase {
  24543. /**
  24544. * Defines the picking info associated to the info (if any)\
  24545. */
  24546. pickInfo: Nullable<PickingInfo>;
  24547. /**
  24548. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  24549. * @param type Defines the type of event (PointerEventTypes)
  24550. * @param event Defines the related dom event
  24551. * @param pickInfo Defines the picking info associated to the info (if any)\
  24552. */
  24553. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  24554. /**
  24555. * Defines the picking info associated to the info (if any)\
  24556. */
  24557. pickInfo: Nullable<PickingInfo>);
  24558. }
  24559. /**
  24560. * Data relating to a touch event on the screen.
  24561. */
  24562. export interface PointerTouch {
  24563. /**
  24564. * X coordinate of touch.
  24565. */
  24566. x: number;
  24567. /**
  24568. * Y coordinate of touch.
  24569. */
  24570. y: number;
  24571. /**
  24572. * Id of touch. Unique for each finger.
  24573. */
  24574. pointerId: number;
  24575. /**
  24576. * Event type passed from DOM.
  24577. */
  24578. type: any;
  24579. }
  24580. }
  24581. declare module BABYLON {
  24582. /**
  24583. * Manage the mouse inputs to control the movement of a free camera.
  24584. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24585. */
  24586. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  24587. /**
  24588. * Define if touch is enabled in the mouse input
  24589. */
  24590. touchEnabled: boolean;
  24591. /**
  24592. * Defines the camera the input is attached to.
  24593. */
  24594. camera: FreeCamera;
  24595. /**
  24596. * Defines the buttons associated with the input to handle camera move.
  24597. */
  24598. buttons: number[];
  24599. /**
  24600. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  24601. */
  24602. angularSensibility: number;
  24603. private _pointerInput;
  24604. private _onMouseMove;
  24605. private _observer;
  24606. private previousPosition;
  24607. /**
  24608. * Observable for when a pointer move event occurs containing the move offset
  24609. */
  24610. onPointerMovedObservable: Observable<{
  24611. offsetX: number;
  24612. offsetY: number;
  24613. }>;
  24614. /**
  24615. * @hidden
  24616. * If the camera should be rotated automatically based on pointer movement
  24617. */
  24618. _allowCameraRotation: boolean;
  24619. /**
  24620. * Manage the mouse inputs to control the movement of a free camera.
  24621. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24622. * @param touchEnabled Defines if touch is enabled or not
  24623. */
  24624. constructor(
  24625. /**
  24626. * Define if touch is enabled in the mouse input
  24627. */
  24628. touchEnabled?: boolean);
  24629. /**
  24630. * Attach the input controls to a specific dom element to get the input from.
  24631. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24632. */
  24633. attachControl(noPreventDefault?: boolean): void;
  24634. /**
  24635. * Called on JS contextmenu event.
  24636. * Override this method to provide functionality.
  24637. */
  24638. protected onContextMenu(evt: PointerEvent): void;
  24639. /**
  24640. * Detach the current controls from the specified dom element.
  24641. */
  24642. detachControl(): void;
  24643. /**
  24644. * Gets the class name of the current intput.
  24645. * @returns the class name
  24646. */
  24647. getClassName(): string;
  24648. /**
  24649. * Get the friendly name associated with the input class.
  24650. * @returns the input friendly name
  24651. */
  24652. getSimpleName(): string;
  24653. }
  24654. }
  24655. declare module BABYLON {
  24656. /**
  24657. * Base class for mouse wheel input..
  24658. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  24659. * for example usage.
  24660. */
  24661. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  24662. /**
  24663. * Defines the camera the input is attached to.
  24664. */
  24665. abstract camera: Camera;
  24666. /**
  24667. * How fast is the camera moves in relation to X axis mouseWheel events.
  24668. * Use negative value to reverse direction.
  24669. */
  24670. wheelPrecisionX: number;
  24671. /**
  24672. * How fast is the camera moves in relation to Y axis mouseWheel events.
  24673. * Use negative value to reverse direction.
  24674. */
  24675. wheelPrecisionY: number;
  24676. /**
  24677. * How fast is the camera moves in relation to Z axis mouseWheel events.
  24678. * Use negative value to reverse direction.
  24679. */
  24680. wheelPrecisionZ: number;
  24681. /**
  24682. * Observable for when a mouse wheel move event occurs.
  24683. */
  24684. onChangedObservable: Observable<{
  24685. wheelDeltaX: number;
  24686. wheelDeltaY: number;
  24687. wheelDeltaZ: number;
  24688. }>;
  24689. private _wheel;
  24690. private _observer;
  24691. /**
  24692. * Attach the input controls to a specific dom element to get the input from.
  24693. * @param noPreventDefault Defines whether event caught by the controls
  24694. * should call preventdefault().
  24695. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24696. */
  24697. attachControl(noPreventDefault?: boolean): void;
  24698. /**
  24699. * Detach the current controls from the specified dom element.
  24700. */
  24701. detachControl(): void;
  24702. /**
  24703. * Called for each rendered frame.
  24704. */
  24705. checkInputs(): void;
  24706. /**
  24707. * Gets the class name of the current intput.
  24708. * @returns the class name
  24709. */
  24710. getClassName(): string;
  24711. /**
  24712. * Get the friendly name associated with the input class.
  24713. * @returns the input friendly name
  24714. */
  24715. getSimpleName(): string;
  24716. /**
  24717. * Incremental value of multiple mouse wheel movements of the X axis.
  24718. * Should be zero-ed when read.
  24719. */
  24720. protected _wheelDeltaX: number;
  24721. /**
  24722. * Incremental value of multiple mouse wheel movements of the Y axis.
  24723. * Should be zero-ed when read.
  24724. */
  24725. protected _wheelDeltaY: number;
  24726. /**
  24727. * Incremental value of multiple mouse wheel movements of the Z axis.
  24728. * Should be zero-ed when read.
  24729. */
  24730. protected _wheelDeltaZ: number;
  24731. /**
  24732. * Firefox uses a different scheme to report scroll distances to other
  24733. * browsers. Rather than use complicated methods to calculate the exact
  24734. * multiple we need to apply, let's just cheat and use a constant.
  24735. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  24736. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  24737. */
  24738. private readonly _ffMultiplier;
  24739. /**
  24740. * Different event attributes for wheel data fall into a few set ranges.
  24741. * Some relevant but dated date here:
  24742. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  24743. */
  24744. private readonly _normalize;
  24745. }
  24746. }
  24747. declare module BABYLON {
  24748. /**
  24749. * Manage the mouse wheel inputs to control a free camera.
  24750. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24751. */
  24752. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  24753. /**
  24754. * Defines the camera the input is attached to.
  24755. */
  24756. camera: FreeCamera;
  24757. /**
  24758. * Gets the class name of the current input.
  24759. * @returns the class name
  24760. */
  24761. getClassName(): string;
  24762. /**
  24763. * Set which movement axis (relative to camera's orientation) the mouse
  24764. * wheel's X axis controls.
  24765. * @param axis The axis to be moved. Set null to clear.
  24766. */
  24767. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  24768. /**
  24769. * Get the configured movement axis (relative to camera's orientation) the
  24770. * mouse wheel's X axis controls.
  24771. * @returns The configured axis or null if none.
  24772. */
  24773. get wheelXMoveRelative(): Nullable<Coordinate>;
  24774. /**
  24775. * Set which movement axis (relative to camera's orientation) the mouse
  24776. * wheel's Y axis controls.
  24777. * @param axis The axis to be moved. Set null to clear.
  24778. */
  24779. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  24780. /**
  24781. * Get the configured movement axis (relative to camera's orientation) the
  24782. * mouse wheel's Y axis controls.
  24783. * @returns The configured axis or null if none.
  24784. */
  24785. get wheelYMoveRelative(): Nullable<Coordinate>;
  24786. /**
  24787. * Set which movement axis (relative to camera's orientation) the mouse
  24788. * wheel's Z axis controls.
  24789. * @param axis The axis to be moved. Set null to clear.
  24790. */
  24791. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  24792. /**
  24793. * Get the configured movement axis (relative to camera's orientation) the
  24794. * mouse wheel's Z axis controls.
  24795. * @returns The configured axis or null if none.
  24796. */
  24797. get wheelZMoveRelative(): Nullable<Coordinate>;
  24798. /**
  24799. * Set which rotation axis (relative to camera's orientation) the mouse
  24800. * wheel's X axis controls.
  24801. * @param axis The axis to be moved. Set null to clear.
  24802. */
  24803. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  24804. /**
  24805. * Get the configured rotation axis (relative to camera's orientation) the
  24806. * mouse wheel's X axis controls.
  24807. * @returns The configured axis or null if none.
  24808. */
  24809. get wheelXRotateRelative(): Nullable<Coordinate>;
  24810. /**
  24811. * Set which rotation axis (relative to camera's orientation) the mouse
  24812. * wheel's Y axis controls.
  24813. * @param axis The axis to be moved. Set null to clear.
  24814. */
  24815. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  24816. /**
  24817. * Get the configured rotation axis (relative to camera's orientation) the
  24818. * mouse wheel's Y axis controls.
  24819. * @returns The configured axis or null if none.
  24820. */
  24821. get wheelYRotateRelative(): Nullable<Coordinate>;
  24822. /**
  24823. * Set which rotation axis (relative to camera's orientation) the mouse
  24824. * wheel's Z axis controls.
  24825. * @param axis The axis to be moved. Set null to clear.
  24826. */
  24827. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  24828. /**
  24829. * Get the configured rotation axis (relative to camera's orientation) the
  24830. * mouse wheel's Z axis controls.
  24831. * @returns The configured axis or null if none.
  24832. */
  24833. get wheelZRotateRelative(): Nullable<Coordinate>;
  24834. /**
  24835. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  24836. * controls.
  24837. * @param axis The axis to be moved. Set null to clear.
  24838. */
  24839. set wheelXMoveScene(axis: Nullable<Coordinate>);
  24840. /**
  24841. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24842. * X axis controls.
  24843. * @returns The configured axis or null if none.
  24844. */
  24845. get wheelXMoveScene(): Nullable<Coordinate>;
  24846. /**
  24847. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  24848. * controls.
  24849. * @param axis The axis to be moved. Set null to clear.
  24850. */
  24851. set wheelYMoveScene(axis: Nullable<Coordinate>);
  24852. /**
  24853. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24854. * Y axis controls.
  24855. * @returns The configured axis or null if none.
  24856. */
  24857. get wheelYMoveScene(): Nullable<Coordinate>;
  24858. /**
  24859. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  24860. * controls.
  24861. * @param axis The axis to be moved. Set null to clear.
  24862. */
  24863. set wheelZMoveScene(axis: Nullable<Coordinate>);
  24864. /**
  24865. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24866. * Z axis controls.
  24867. * @returns The configured axis or null if none.
  24868. */
  24869. get wheelZMoveScene(): Nullable<Coordinate>;
  24870. /**
  24871. * Called for each rendered frame.
  24872. */
  24873. checkInputs(): void;
  24874. private _moveRelative;
  24875. private _rotateRelative;
  24876. private _moveScene;
  24877. /**
  24878. * These are set to the desired default behaviour.
  24879. */
  24880. private _wheelXAction;
  24881. private _wheelXActionCoordinate;
  24882. private _wheelYAction;
  24883. private _wheelYActionCoordinate;
  24884. private _wheelZAction;
  24885. private _wheelZActionCoordinate;
  24886. /**
  24887. * Update the camera according to any configured properties for the 3
  24888. * mouse-wheel axis.
  24889. */
  24890. private _updateCamera;
  24891. }
  24892. }
  24893. declare module BABYLON {
  24894. /**
  24895. * Manage the touch inputs to control the movement of a free camera.
  24896. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24897. */
  24898. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  24899. /**
  24900. * Define if mouse events can be treated as touch events
  24901. */
  24902. allowMouse: boolean;
  24903. /**
  24904. * Defines the camera the input is attached to.
  24905. */
  24906. camera: FreeCamera;
  24907. /**
  24908. * Defines the touch sensibility for rotation.
  24909. * The higher the faster.
  24910. */
  24911. touchAngularSensibility: number;
  24912. /**
  24913. * Defines the touch sensibility for move.
  24914. * The higher the faster.
  24915. */
  24916. touchMoveSensibility: number;
  24917. private _offsetX;
  24918. private _offsetY;
  24919. private _pointerPressed;
  24920. private _pointerInput?;
  24921. private _observer;
  24922. private _onLostFocus;
  24923. /**
  24924. * Manage the touch inputs to control the movement of a free camera.
  24925. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24926. * @param allowMouse Defines if mouse events can be treated as touch events
  24927. */
  24928. constructor(
  24929. /**
  24930. * Define if mouse events can be treated as touch events
  24931. */
  24932. allowMouse?: boolean);
  24933. /**
  24934. * Attach the input controls to a specific dom element to get the input from.
  24935. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24936. */
  24937. attachControl(noPreventDefault?: boolean): void;
  24938. /**
  24939. * Detach the current controls from the specified dom element.
  24940. */
  24941. detachControl(): void;
  24942. /**
  24943. * Update the current camera state depending on the inputs that have been used this frame.
  24944. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  24945. */
  24946. checkInputs(): void;
  24947. /**
  24948. * Gets the class name of the current intput.
  24949. * @returns the class name
  24950. */
  24951. getClassName(): string;
  24952. /**
  24953. * Get the friendly name associated with the input class.
  24954. * @returns the input friendly name
  24955. */
  24956. getSimpleName(): string;
  24957. }
  24958. }
  24959. declare module BABYLON {
  24960. /**
  24961. * Default Inputs manager for the FreeCamera.
  24962. * It groups all the default supported inputs for ease of use.
  24963. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24964. */
  24965. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  24966. /**
  24967. * @hidden
  24968. */
  24969. _mouseInput: Nullable<FreeCameraMouseInput>;
  24970. /**
  24971. * @hidden
  24972. */
  24973. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  24974. /**
  24975. * Instantiates a new FreeCameraInputsManager.
  24976. * @param camera Defines the camera the inputs belong to
  24977. */
  24978. constructor(camera: FreeCamera);
  24979. /**
  24980. * Add keyboard input support to the input manager.
  24981. * @returns the current input manager
  24982. */
  24983. addKeyboard(): FreeCameraInputsManager;
  24984. /**
  24985. * Add mouse input support to the input manager.
  24986. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  24987. * @returns the current input manager
  24988. */
  24989. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  24990. /**
  24991. * Removes the mouse input support from the manager
  24992. * @returns the current input manager
  24993. */
  24994. removeMouse(): FreeCameraInputsManager;
  24995. /**
  24996. * Add mouse wheel input support to the input manager.
  24997. * @returns the current input manager
  24998. */
  24999. addMouseWheel(): FreeCameraInputsManager;
  25000. /**
  25001. * Removes the mouse wheel input support from the manager
  25002. * @returns the current input manager
  25003. */
  25004. removeMouseWheel(): FreeCameraInputsManager;
  25005. /**
  25006. * Add touch input support to the input manager.
  25007. * @returns the current input manager
  25008. */
  25009. addTouch(): FreeCameraInputsManager;
  25010. /**
  25011. * Remove all attached input methods from a camera
  25012. */
  25013. clear(): void;
  25014. }
  25015. }
  25016. declare module BABYLON {
  25017. /**
  25018. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25019. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  25020. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25021. */
  25022. export class FreeCamera extends TargetCamera {
  25023. /**
  25024. * Define the collision ellipsoid of the camera.
  25025. * This is helpful to simulate a camera body like the player body around the camera
  25026. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  25027. */
  25028. ellipsoid: Vector3;
  25029. /**
  25030. * Define an offset for the position of the ellipsoid around the camera.
  25031. * This can be helpful to determine the center of the body near the gravity center of the body
  25032. * instead of its head.
  25033. */
  25034. ellipsoidOffset: Vector3;
  25035. /**
  25036. * Enable or disable collisions of the camera with the rest of the scene objects.
  25037. */
  25038. checkCollisions: boolean;
  25039. /**
  25040. * Enable or disable gravity on the camera.
  25041. */
  25042. applyGravity: boolean;
  25043. /**
  25044. * Define the input manager associated to the camera.
  25045. */
  25046. inputs: FreeCameraInputsManager;
  25047. /**
  25048. * Gets the input sensibility for a mouse input. (default is 2000.0)
  25049. * Higher values reduce sensitivity.
  25050. */
  25051. get angularSensibility(): number;
  25052. /**
  25053. * Sets the input sensibility for a mouse input. (default is 2000.0)
  25054. * Higher values reduce sensitivity.
  25055. */
  25056. set angularSensibility(value: number);
  25057. /**
  25058. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  25059. */
  25060. get keysUp(): number[];
  25061. set keysUp(value: number[]);
  25062. /**
  25063. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  25064. */
  25065. get keysUpward(): number[];
  25066. set keysUpward(value: number[]);
  25067. /**
  25068. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  25069. */
  25070. get keysDown(): number[];
  25071. set keysDown(value: number[]);
  25072. /**
  25073. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  25074. */
  25075. get keysDownward(): number[];
  25076. set keysDownward(value: number[]);
  25077. /**
  25078. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  25079. */
  25080. get keysLeft(): number[];
  25081. set keysLeft(value: number[]);
  25082. /**
  25083. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  25084. */
  25085. get keysRight(): number[];
  25086. set keysRight(value: number[]);
  25087. /**
  25088. * Event raised when the camera collide with a mesh in the scene.
  25089. */
  25090. onCollide: (collidedMesh: AbstractMesh) => void;
  25091. private _collider;
  25092. private _needMoveForGravity;
  25093. private _oldPosition;
  25094. private _diffPosition;
  25095. private _newPosition;
  25096. /** @hidden */
  25097. _localDirection: Vector3;
  25098. /** @hidden */
  25099. _transformedDirection: Vector3;
  25100. /**
  25101. * Instantiates a Free Camera.
  25102. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25103. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  25104. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25105. * @param name Define the name of the camera in the scene
  25106. * @param position Define the start position of the camera in the scene
  25107. * @param scene Define the scene the camera belongs to
  25108. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  25109. */
  25110. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25111. /**
  25112. * Attach the input controls to a specific dom element to get the input from.
  25113. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25114. */
  25115. attachControl(noPreventDefault?: boolean): void;
  25116. /**
  25117. * Attach the input controls to a specific dom element to get the input from.
  25118. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  25119. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25120. * BACK COMPAT SIGNATURE ONLY.
  25121. */
  25122. attachControl(ignored: any, noPreventDefault?: boolean): void;
  25123. /**
  25124. * Detach the current controls from the specified dom element.
  25125. */
  25126. detachControl(): void;
  25127. /**
  25128. * Detach the current controls from the specified dom element.
  25129. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  25130. */
  25131. detachControl(ignored: any): void;
  25132. private _collisionMask;
  25133. /**
  25134. * Define a collision mask to limit the list of object the camera can collide with
  25135. */
  25136. get collisionMask(): number;
  25137. set collisionMask(mask: number);
  25138. /** @hidden */
  25139. _collideWithWorld(displacement: Vector3): void;
  25140. private _onCollisionPositionChange;
  25141. /** @hidden */
  25142. _checkInputs(): void;
  25143. /** @hidden */
  25144. _decideIfNeedsToMove(): boolean;
  25145. /** @hidden */
  25146. _updatePosition(): void;
  25147. /**
  25148. * Destroy the camera and release the current resources hold by it.
  25149. */
  25150. dispose(): void;
  25151. /**
  25152. * Gets the current object class name.
  25153. * @return the class name
  25154. */
  25155. getClassName(): string;
  25156. }
  25157. }
  25158. declare module BABYLON {
  25159. /**
  25160. * Represents a gamepad control stick position
  25161. */
  25162. export class StickValues {
  25163. /**
  25164. * The x component of the control stick
  25165. */
  25166. x: number;
  25167. /**
  25168. * The y component of the control stick
  25169. */
  25170. y: number;
  25171. /**
  25172. * Initializes the gamepad x and y control stick values
  25173. * @param x The x component of the gamepad control stick value
  25174. * @param y The y component of the gamepad control stick value
  25175. */
  25176. constructor(
  25177. /**
  25178. * The x component of the control stick
  25179. */
  25180. x: number,
  25181. /**
  25182. * The y component of the control stick
  25183. */
  25184. y: number);
  25185. }
  25186. /**
  25187. * An interface which manages callbacks for gamepad button changes
  25188. */
  25189. export interface GamepadButtonChanges {
  25190. /**
  25191. * Called when a gamepad has been changed
  25192. */
  25193. changed: boolean;
  25194. /**
  25195. * Called when a gamepad press event has been triggered
  25196. */
  25197. pressChanged: boolean;
  25198. /**
  25199. * Called when a touch event has been triggered
  25200. */
  25201. touchChanged: boolean;
  25202. /**
  25203. * Called when a value has changed
  25204. */
  25205. valueChanged: boolean;
  25206. }
  25207. /**
  25208. * Represents a gamepad
  25209. */
  25210. export class Gamepad {
  25211. /**
  25212. * The id of the gamepad
  25213. */
  25214. id: string;
  25215. /**
  25216. * The index of the gamepad
  25217. */
  25218. index: number;
  25219. /**
  25220. * The browser gamepad
  25221. */
  25222. browserGamepad: any;
  25223. /**
  25224. * Specifies what type of gamepad this represents
  25225. */
  25226. type: number;
  25227. private _leftStick;
  25228. private _rightStick;
  25229. /** @hidden */
  25230. _isConnected: boolean;
  25231. private _leftStickAxisX;
  25232. private _leftStickAxisY;
  25233. private _rightStickAxisX;
  25234. private _rightStickAxisY;
  25235. /**
  25236. * Triggered when the left control stick has been changed
  25237. */
  25238. private _onleftstickchanged;
  25239. /**
  25240. * Triggered when the right control stick has been changed
  25241. */
  25242. private _onrightstickchanged;
  25243. /**
  25244. * Represents a gamepad controller
  25245. */
  25246. static GAMEPAD: number;
  25247. /**
  25248. * Represents a generic controller
  25249. */
  25250. static GENERIC: number;
  25251. /**
  25252. * Represents an XBox controller
  25253. */
  25254. static XBOX: number;
  25255. /**
  25256. * Represents a pose-enabled controller
  25257. */
  25258. static POSE_ENABLED: number;
  25259. /**
  25260. * Represents an Dual Shock controller
  25261. */
  25262. static DUALSHOCK: number;
  25263. /**
  25264. * Specifies whether the left control stick should be Y-inverted
  25265. */
  25266. protected _invertLeftStickY: boolean;
  25267. /**
  25268. * Specifies if the gamepad has been connected
  25269. */
  25270. get isConnected(): boolean;
  25271. /**
  25272. * Initializes the gamepad
  25273. * @param id The id of the gamepad
  25274. * @param index The index of the gamepad
  25275. * @param browserGamepad The browser gamepad
  25276. * @param leftStickX The x component of the left joystick
  25277. * @param leftStickY The y component of the left joystick
  25278. * @param rightStickX The x component of the right joystick
  25279. * @param rightStickY The y component of the right joystick
  25280. */
  25281. constructor(
  25282. /**
  25283. * The id of the gamepad
  25284. */
  25285. id: string,
  25286. /**
  25287. * The index of the gamepad
  25288. */
  25289. index: number,
  25290. /**
  25291. * The browser gamepad
  25292. */
  25293. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  25294. /**
  25295. * Callback triggered when the left joystick has changed
  25296. * @param callback
  25297. */
  25298. onleftstickchanged(callback: (values: StickValues) => void): void;
  25299. /**
  25300. * Callback triggered when the right joystick has changed
  25301. * @param callback
  25302. */
  25303. onrightstickchanged(callback: (values: StickValues) => void): void;
  25304. /**
  25305. * Gets the left joystick
  25306. */
  25307. get leftStick(): StickValues;
  25308. /**
  25309. * Sets the left joystick values
  25310. */
  25311. set leftStick(newValues: StickValues);
  25312. /**
  25313. * Gets the right joystick
  25314. */
  25315. get rightStick(): StickValues;
  25316. /**
  25317. * Sets the right joystick value
  25318. */
  25319. set rightStick(newValues: StickValues);
  25320. /**
  25321. * Updates the gamepad joystick positions
  25322. */
  25323. update(): void;
  25324. /**
  25325. * Disposes the gamepad
  25326. */
  25327. dispose(): void;
  25328. }
  25329. /**
  25330. * Represents a generic gamepad
  25331. */
  25332. export class GenericPad extends Gamepad {
  25333. private _buttons;
  25334. private _onbuttondown;
  25335. private _onbuttonup;
  25336. /**
  25337. * Observable triggered when a button has been pressed
  25338. */
  25339. onButtonDownObservable: Observable<number>;
  25340. /**
  25341. * Observable triggered when a button has been released
  25342. */
  25343. onButtonUpObservable: Observable<number>;
  25344. /**
  25345. * Callback triggered when a button has been pressed
  25346. * @param callback Called when a button has been pressed
  25347. */
  25348. onbuttondown(callback: (buttonPressed: number) => void): void;
  25349. /**
  25350. * Callback triggered when a button has been released
  25351. * @param callback Called when a button has been released
  25352. */
  25353. onbuttonup(callback: (buttonReleased: number) => void): void;
  25354. /**
  25355. * Initializes the generic gamepad
  25356. * @param id The id of the generic gamepad
  25357. * @param index The index of the generic gamepad
  25358. * @param browserGamepad The browser gamepad
  25359. */
  25360. constructor(id: string, index: number, browserGamepad: any);
  25361. private _setButtonValue;
  25362. /**
  25363. * Updates the generic gamepad
  25364. */
  25365. update(): void;
  25366. /**
  25367. * Disposes the generic gamepad
  25368. */
  25369. dispose(): void;
  25370. }
  25371. }
  25372. declare module BABYLON {
  25373. /**
  25374. * Defines a runtime animation
  25375. */
  25376. export class RuntimeAnimation {
  25377. private _events;
  25378. /**
  25379. * The current frame of the runtime animation
  25380. */
  25381. private _currentFrame;
  25382. /**
  25383. * The animation used by the runtime animation
  25384. */
  25385. private _animation;
  25386. /**
  25387. * The target of the runtime animation
  25388. */
  25389. private _target;
  25390. /**
  25391. * The initiating animatable
  25392. */
  25393. private _host;
  25394. /**
  25395. * The original value of the runtime animation
  25396. */
  25397. private _originalValue;
  25398. /**
  25399. * The original blend value of the runtime animation
  25400. */
  25401. private _originalBlendValue;
  25402. /**
  25403. * The offsets cache of the runtime animation
  25404. */
  25405. private _offsetsCache;
  25406. /**
  25407. * The high limits cache of the runtime animation
  25408. */
  25409. private _highLimitsCache;
  25410. /**
  25411. * Specifies if the runtime animation has been stopped
  25412. */
  25413. private _stopped;
  25414. /**
  25415. * The blending factor of the runtime animation
  25416. */
  25417. private _blendingFactor;
  25418. /**
  25419. * The BabylonJS scene
  25420. */
  25421. private _scene;
  25422. /**
  25423. * The current value of the runtime animation
  25424. */
  25425. private _currentValue;
  25426. /** @hidden */
  25427. _animationState: _IAnimationState;
  25428. /**
  25429. * The active target of the runtime animation
  25430. */
  25431. private _activeTargets;
  25432. private _currentActiveTarget;
  25433. private _directTarget;
  25434. /**
  25435. * The target path of the runtime animation
  25436. */
  25437. private _targetPath;
  25438. /**
  25439. * The weight of the runtime animation
  25440. */
  25441. private _weight;
  25442. /**
  25443. * The ratio offset of the runtime animation
  25444. */
  25445. private _ratioOffset;
  25446. /**
  25447. * The previous delay of the runtime animation
  25448. */
  25449. private _previousDelay;
  25450. /**
  25451. * The previous ratio of the runtime animation
  25452. */
  25453. private _previousRatio;
  25454. private _enableBlending;
  25455. private _keys;
  25456. private _minFrame;
  25457. private _maxFrame;
  25458. private _minValue;
  25459. private _maxValue;
  25460. private _targetIsArray;
  25461. /**
  25462. * Gets the current frame of the runtime animation
  25463. */
  25464. get currentFrame(): number;
  25465. /**
  25466. * Gets the weight of the runtime animation
  25467. */
  25468. get weight(): number;
  25469. /**
  25470. * Gets the current value of the runtime animation
  25471. */
  25472. get currentValue(): any;
  25473. /**
  25474. * Gets the target path of the runtime animation
  25475. */
  25476. get targetPath(): string;
  25477. /**
  25478. * Gets the actual target of the runtime animation
  25479. */
  25480. get target(): any;
  25481. /**
  25482. * Gets the additive state of the runtime animation
  25483. */
  25484. get isAdditive(): boolean;
  25485. /** @hidden */
  25486. _onLoop: () => void;
  25487. /**
  25488. * Create a new RuntimeAnimation object
  25489. * @param target defines the target of the animation
  25490. * @param animation defines the source animation object
  25491. * @param scene defines the hosting scene
  25492. * @param host defines the initiating Animatable
  25493. */
  25494. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  25495. private _preparePath;
  25496. /**
  25497. * Gets the animation from the runtime animation
  25498. */
  25499. get animation(): Animation;
  25500. /**
  25501. * Resets the runtime animation to the beginning
  25502. * @param restoreOriginal defines whether to restore the target property to the original value
  25503. */
  25504. reset(restoreOriginal?: boolean): void;
  25505. /**
  25506. * Specifies if the runtime animation is stopped
  25507. * @returns Boolean specifying if the runtime animation is stopped
  25508. */
  25509. isStopped(): boolean;
  25510. /**
  25511. * Disposes of the runtime animation
  25512. */
  25513. dispose(): void;
  25514. /**
  25515. * Apply the interpolated value to the target
  25516. * @param currentValue defines the value computed by the animation
  25517. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  25518. */
  25519. setValue(currentValue: any, weight: number): void;
  25520. private _getOriginalValues;
  25521. private _setValue;
  25522. /**
  25523. * Gets the loop pmode of the runtime animation
  25524. * @returns Loop Mode
  25525. */
  25526. private _getCorrectLoopMode;
  25527. /**
  25528. * Move the current animation to a given frame
  25529. * @param frame defines the frame to move to
  25530. */
  25531. goToFrame(frame: number): void;
  25532. /**
  25533. * @hidden Internal use only
  25534. */
  25535. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  25536. /**
  25537. * Execute the current animation
  25538. * @param delay defines the delay to add to the current frame
  25539. * @param from defines the lower bound of the animation range
  25540. * @param to defines the upper bound of the animation range
  25541. * @param loop defines if the current animation must loop
  25542. * @param speedRatio defines the current speed ratio
  25543. * @param weight defines the weight of the animation (default is -1 so no weight)
  25544. * @param onLoop optional callback called when animation loops
  25545. * @returns a boolean indicating if the animation is running
  25546. */
  25547. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  25548. }
  25549. }
  25550. declare module BABYLON {
  25551. /**
  25552. * Class used to store an actual running animation
  25553. */
  25554. export class Animatable {
  25555. /** defines the target object */
  25556. target: any;
  25557. /** defines the starting frame number (default is 0) */
  25558. fromFrame: number;
  25559. /** defines the ending frame number (default is 100) */
  25560. toFrame: number;
  25561. /** defines if the animation must loop (default is false) */
  25562. loopAnimation: boolean;
  25563. /** defines a callback to call when animation ends if it is not looping */
  25564. onAnimationEnd?: (() => void) | null | undefined;
  25565. /** defines a callback to call when animation loops */
  25566. onAnimationLoop?: (() => void) | null | undefined;
  25567. /** defines whether the animation should be evaluated additively */
  25568. isAdditive: boolean;
  25569. private _localDelayOffset;
  25570. private _pausedDelay;
  25571. private _runtimeAnimations;
  25572. private _paused;
  25573. private _scene;
  25574. private _speedRatio;
  25575. private _weight;
  25576. private _syncRoot;
  25577. /**
  25578. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  25579. * This will only apply for non looping animation (default is true)
  25580. */
  25581. disposeOnEnd: boolean;
  25582. /**
  25583. * Gets a boolean indicating if the animation has started
  25584. */
  25585. animationStarted: boolean;
  25586. /**
  25587. * Observer raised when the animation ends
  25588. */
  25589. onAnimationEndObservable: Observable<Animatable>;
  25590. /**
  25591. * Observer raised when the animation loops
  25592. */
  25593. onAnimationLoopObservable: Observable<Animatable>;
  25594. /**
  25595. * Gets the root Animatable used to synchronize and normalize animations
  25596. */
  25597. get syncRoot(): Nullable<Animatable>;
  25598. /**
  25599. * Gets the current frame of the first RuntimeAnimation
  25600. * Used to synchronize Animatables
  25601. */
  25602. get masterFrame(): number;
  25603. /**
  25604. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  25605. */
  25606. get weight(): number;
  25607. set weight(value: number);
  25608. /**
  25609. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  25610. */
  25611. get speedRatio(): number;
  25612. set speedRatio(value: number);
  25613. /**
  25614. * Creates a new Animatable
  25615. * @param scene defines the hosting scene
  25616. * @param target defines the target object
  25617. * @param fromFrame defines the starting frame number (default is 0)
  25618. * @param toFrame defines the ending frame number (default is 100)
  25619. * @param loopAnimation defines if the animation must loop (default is false)
  25620. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  25621. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  25622. * @param animations defines a group of animation to add to the new Animatable
  25623. * @param onAnimationLoop defines a callback to call when animation loops
  25624. * @param isAdditive defines whether the animation should be evaluated additively
  25625. */
  25626. constructor(scene: Scene,
  25627. /** defines the target object */
  25628. target: any,
  25629. /** defines the starting frame number (default is 0) */
  25630. fromFrame?: number,
  25631. /** defines the ending frame number (default is 100) */
  25632. toFrame?: number,
  25633. /** defines if the animation must loop (default is false) */
  25634. loopAnimation?: boolean, speedRatio?: number,
  25635. /** defines a callback to call when animation ends if it is not looping */
  25636. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  25637. /** defines a callback to call when animation loops */
  25638. onAnimationLoop?: (() => void) | null | undefined,
  25639. /** defines whether the animation should be evaluated additively */
  25640. isAdditive?: boolean);
  25641. /**
  25642. * Synchronize and normalize current Animatable with a source Animatable
  25643. * This is useful when using animation weights and when animations are not of the same length
  25644. * @param root defines the root Animatable to synchronize with
  25645. * @returns the current Animatable
  25646. */
  25647. syncWith(root: Animatable): Animatable;
  25648. /**
  25649. * Gets the list of runtime animations
  25650. * @returns an array of RuntimeAnimation
  25651. */
  25652. getAnimations(): RuntimeAnimation[];
  25653. /**
  25654. * Adds more animations to the current animatable
  25655. * @param target defines the target of the animations
  25656. * @param animations defines the new animations to add
  25657. */
  25658. appendAnimations(target: any, animations: Animation[]): void;
  25659. /**
  25660. * Gets the source animation for a specific property
  25661. * @param property defines the propertyu to look for
  25662. * @returns null or the source animation for the given property
  25663. */
  25664. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  25665. /**
  25666. * Gets the runtime animation for a specific property
  25667. * @param property defines the propertyu to look for
  25668. * @returns null or the runtime animation for the given property
  25669. */
  25670. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  25671. /**
  25672. * Resets the animatable to its original state
  25673. */
  25674. reset(): void;
  25675. /**
  25676. * Allows the animatable to blend with current running animations
  25677. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25678. * @param blendingSpeed defines the blending speed to use
  25679. */
  25680. enableBlending(blendingSpeed: number): void;
  25681. /**
  25682. * Disable animation blending
  25683. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25684. */
  25685. disableBlending(): void;
  25686. /**
  25687. * Jump directly to a given frame
  25688. * @param frame defines the frame to jump to
  25689. */
  25690. goToFrame(frame: number): void;
  25691. /**
  25692. * Pause the animation
  25693. */
  25694. pause(): void;
  25695. /**
  25696. * Restart the animation
  25697. */
  25698. restart(): void;
  25699. private _raiseOnAnimationEnd;
  25700. /**
  25701. * Stop and delete the current animation
  25702. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  25703. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  25704. */
  25705. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  25706. /**
  25707. * Wait asynchronously for the animation to end
  25708. * @returns a promise which will be fullfilled when the animation ends
  25709. */
  25710. waitAsync(): Promise<Animatable>;
  25711. /** @hidden */
  25712. _animate(delay: number): boolean;
  25713. }
  25714. interface Scene {
  25715. /** @hidden */
  25716. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  25717. /** @hidden */
  25718. _processLateAnimationBindingsForMatrices(holder: {
  25719. totalWeight: number;
  25720. totalAdditiveWeight: number;
  25721. animations: RuntimeAnimation[];
  25722. additiveAnimations: RuntimeAnimation[];
  25723. originalValue: Matrix;
  25724. }): any;
  25725. /** @hidden */
  25726. _processLateAnimationBindingsForQuaternions(holder: {
  25727. totalWeight: number;
  25728. totalAdditiveWeight: number;
  25729. animations: RuntimeAnimation[];
  25730. additiveAnimations: RuntimeAnimation[];
  25731. originalValue: Quaternion;
  25732. }, refQuaternion: Quaternion): Quaternion;
  25733. /** @hidden */
  25734. _processLateAnimationBindings(): void;
  25735. /**
  25736. * Will start the animation sequence of a given target
  25737. * @param target defines the target
  25738. * @param from defines from which frame should animation start
  25739. * @param to defines until which frame should animation run.
  25740. * @param weight defines the weight to apply to the animation (1.0 by default)
  25741. * @param loop defines if the animation loops
  25742. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25743. * @param onAnimationEnd defines the function to be executed when the animation ends
  25744. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25745. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25746. * @param onAnimationLoop defines the callback to call when an animation loops
  25747. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25748. * @returns the animatable object created for this animation
  25749. */
  25750. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  25751. /**
  25752. * Will start the animation sequence of a given target
  25753. * @param target defines the target
  25754. * @param from defines from which frame should animation start
  25755. * @param to defines until which frame should animation run.
  25756. * @param loop defines if the animation loops
  25757. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25758. * @param onAnimationEnd defines the function to be executed when the animation ends
  25759. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25760. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25761. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  25762. * @param onAnimationLoop defines the callback to call when an animation loops
  25763. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25764. * @returns the animatable object created for this animation
  25765. */
  25766. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  25767. /**
  25768. * Will start the animation sequence of a given target and its hierarchy
  25769. * @param target defines the target
  25770. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  25771. * @param from defines from which frame should animation start
  25772. * @param to defines until which frame should animation run.
  25773. * @param loop defines if the animation loops
  25774. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25775. * @param onAnimationEnd defines the function to be executed when the animation ends
  25776. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25777. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25778. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25779. * @param onAnimationLoop defines the callback to call when an animation loops
  25780. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25781. * @returns the list of created animatables
  25782. */
  25783. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  25784. /**
  25785. * Begin a new animation on a given node
  25786. * @param target defines the target where the animation will take place
  25787. * @param animations defines the list of animations to start
  25788. * @param from defines the initial value
  25789. * @param to defines the final value
  25790. * @param loop defines if you want animation to loop (off by default)
  25791. * @param speedRatio defines the speed ratio to apply to all animations
  25792. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25793. * @param onAnimationLoop defines the callback to call when an animation loops
  25794. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25795. * @returns the list of created animatables
  25796. */
  25797. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  25798. /**
  25799. * Begin a new animation on a given node and its hierarchy
  25800. * @param target defines the root node where the animation will take place
  25801. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  25802. * @param animations defines the list of animations to start
  25803. * @param from defines the initial value
  25804. * @param to defines the final value
  25805. * @param loop defines if you want animation to loop (off by default)
  25806. * @param speedRatio defines the speed ratio to apply to all animations
  25807. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25808. * @param onAnimationLoop defines the callback to call when an animation loops
  25809. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25810. * @returns the list of animatables created for all nodes
  25811. */
  25812. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  25813. /**
  25814. * Gets the animatable associated with a specific target
  25815. * @param target defines the target of the animatable
  25816. * @returns the required animatable if found
  25817. */
  25818. getAnimatableByTarget(target: any): Nullable<Animatable>;
  25819. /**
  25820. * Gets all animatables associated with a given target
  25821. * @param target defines the target to look animatables for
  25822. * @returns an array of Animatables
  25823. */
  25824. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  25825. /**
  25826. * Stops and removes all animations that have been applied to the scene
  25827. */
  25828. stopAllAnimations(): void;
  25829. /**
  25830. * Gets the current delta time used by animation engine
  25831. */
  25832. deltaTime: number;
  25833. }
  25834. interface Bone {
  25835. /**
  25836. * Copy an animation range from another bone
  25837. * @param source defines the source bone
  25838. * @param rangeName defines the range name to copy
  25839. * @param frameOffset defines the frame offset
  25840. * @param rescaleAsRequired defines if rescaling must be applied if required
  25841. * @param skelDimensionsRatio defines the scaling ratio
  25842. * @returns true if operation was successful
  25843. */
  25844. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  25845. }
  25846. }
  25847. declare module BABYLON {
  25848. /**
  25849. * Class used to override all child animations of a given target
  25850. */
  25851. export class AnimationPropertiesOverride {
  25852. /**
  25853. * Gets or sets a value indicating if animation blending must be used
  25854. */
  25855. enableBlending: boolean;
  25856. /**
  25857. * Gets or sets the blending speed to use when enableBlending is true
  25858. */
  25859. blendingSpeed: number;
  25860. /**
  25861. * Gets or sets the default loop mode to use
  25862. */
  25863. loopMode: number;
  25864. }
  25865. }
  25866. declare module BABYLON {
  25867. /**
  25868. * Class used to handle skinning animations
  25869. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25870. */
  25871. export class Skeleton implements IAnimatable {
  25872. /** defines the skeleton name */
  25873. name: string;
  25874. /** defines the skeleton Id */
  25875. id: string;
  25876. /**
  25877. * Defines the list of child bones
  25878. */
  25879. bones: Bone[];
  25880. /**
  25881. * Defines an estimate of the dimension of the skeleton at rest
  25882. */
  25883. dimensionsAtRest: Vector3;
  25884. /**
  25885. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  25886. */
  25887. needInitialSkinMatrix: boolean;
  25888. /**
  25889. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  25890. */
  25891. overrideMesh: Nullable<AbstractMesh>;
  25892. /**
  25893. * Gets the list of animations attached to this skeleton
  25894. */
  25895. animations: Array<Animation>;
  25896. private _scene;
  25897. private _isDirty;
  25898. private _transformMatrices;
  25899. private _transformMatrixTexture;
  25900. private _meshesWithPoseMatrix;
  25901. private _animatables;
  25902. private _identity;
  25903. private _synchronizedWithMesh;
  25904. private _ranges;
  25905. private _lastAbsoluteTransformsUpdateId;
  25906. private _canUseTextureForBones;
  25907. private _uniqueId;
  25908. /** @hidden */
  25909. _numBonesWithLinkedTransformNode: number;
  25910. /** @hidden */
  25911. _hasWaitingData: Nullable<boolean>;
  25912. /** @hidden */
  25913. _waitingOverrideMeshId: Nullable<string>;
  25914. /**
  25915. * Specifies if the skeleton should be serialized
  25916. */
  25917. doNotSerialize: boolean;
  25918. private _useTextureToStoreBoneMatrices;
  25919. /**
  25920. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  25921. * Please note that this option is not available if the hardware does not support it
  25922. */
  25923. get useTextureToStoreBoneMatrices(): boolean;
  25924. set useTextureToStoreBoneMatrices(value: boolean);
  25925. private _animationPropertiesOverride;
  25926. /**
  25927. * Gets or sets the animation properties override
  25928. */
  25929. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25930. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25931. /**
  25932. * List of inspectable custom properties (used by the Inspector)
  25933. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25934. */
  25935. inspectableCustomProperties: IInspectable[];
  25936. /**
  25937. * An observable triggered before computing the skeleton's matrices
  25938. */
  25939. onBeforeComputeObservable: Observable<Skeleton>;
  25940. /**
  25941. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  25942. */
  25943. get isUsingTextureForMatrices(): boolean;
  25944. /**
  25945. * Gets the unique ID of this skeleton
  25946. */
  25947. get uniqueId(): number;
  25948. /**
  25949. * Creates a new skeleton
  25950. * @param name defines the skeleton name
  25951. * @param id defines the skeleton Id
  25952. * @param scene defines the hosting scene
  25953. */
  25954. constructor(
  25955. /** defines the skeleton name */
  25956. name: string,
  25957. /** defines the skeleton Id */
  25958. id: string, scene: Scene);
  25959. /**
  25960. * Gets the current object class name.
  25961. * @return the class name
  25962. */
  25963. getClassName(): string;
  25964. /**
  25965. * Returns an array containing the root bones
  25966. * @returns an array containing the root bones
  25967. */
  25968. getChildren(): Array<Bone>;
  25969. /**
  25970. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  25971. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  25972. * @returns a Float32Array containing matrices data
  25973. */
  25974. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  25975. /**
  25976. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  25977. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  25978. * @returns a raw texture containing the data
  25979. */
  25980. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  25981. /**
  25982. * Gets the current hosting scene
  25983. * @returns a scene object
  25984. */
  25985. getScene(): Scene;
  25986. /**
  25987. * Gets a string representing the current skeleton data
  25988. * @param fullDetails defines a boolean indicating if we want a verbose version
  25989. * @returns a string representing the current skeleton data
  25990. */
  25991. toString(fullDetails?: boolean): string;
  25992. /**
  25993. * Get bone's index searching by name
  25994. * @param name defines bone's name to search for
  25995. * @return the indice of the bone. Returns -1 if not found
  25996. */
  25997. getBoneIndexByName(name: string): number;
  25998. /**
  25999. * Creater a new animation range
  26000. * @param name defines the name of the range
  26001. * @param from defines the start key
  26002. * @param to defines the end key
  26003. */
  26004. createAnimationRange(name: string, from: number, to: number): void;
  26005. /**
  26006. * Delete a specific animation range
  26007. * @param name defines the name of the range
  26008. * @param deleteFrames defines if frames must be removed as well
  26009. */
  26010. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26011. /**
  26012. * Gets a specific animation range
  26013. * @param name defines the name of the range to look for
  26014. * @returns the requested animation range or null if not found
  26015. */
  26016. getAnimationRange(name: string): Nullable<AnimationRange>;
  26017. /**
  26018. * Gets the list of all animation ranges defined on this skeleton
  26019. * @returns an array
  26020. */
  26021. getAnimationRanges(): Nullable<AnimationRange>[];
  26022. /**
  26023. * Copy animation range from a source skeleton.
  26024. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  26025. * @param source defines the source skeleton
  26026. * @param name defines the name of the range to copy
  26027. * @param rescaleAsRequired defines if rescaling must be applied if required
  26028. * @returns true if operation was successful
  26029. */
  26030. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  26031. /**
  26032. * Forces the skeleton to go to rest pose
  26033. */
  26034. returnToRest(): void;
  26035. private _getHighestAnimationFrame;
  26036. /**
  26037. * Begin a specific animation range
  26038. * @param name defines the name of the range to start
  26039. * @param loop defines if looping must be turned on (false by default)
  26040. * @param speedRatio defines the speed ratio to apply (1 by default)
  26041. * @param onAnimationEnd defines a callback which will be called when animation will end
  26042. * @returns a new animatable
  26043. */
  26044. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26045. /**
  26046. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  26047. * @param skeleton defines the Skeleton containing the animation range to convert
  26048. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  26049. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  26050. * @returns the original skeleton
  26051. */
  26052. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  26053. /** @hidden */
  26054. _markAsDirty(): void;
  26055. /** @hidden */
  26056. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26057. /** @hidden */
  26058. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26059. private _computeTransformMatrices;
  26060. /**
  26061. * Build all resources required to render a skeleton
  26062. */
  26063. prepare(): void;
  26064. /**
  26065. * Gets the list of animatables currently running for this skeleton
  26066. * @returns an array of animatables
  26067. */
  26068. getAnimatables(): IAnimatable[];
  26069. /**
  26070. * Clone the current skeleton
  26071. * @param name defines the name of the new skeleton
  26072. * @param id defines the id of the new skeleton
  26073. * @returns the new skeleton
  26074. */
  26075. clone(name: string, id?: string): Skeleton;
  26076. /**
  26077. * Enable animation blending for this skeleton
  26078. * @param blendingSpeed defines the blending speed to apply
  26079. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26080. */
  26081. enableBlending(blendingSpeed?: number): void;
  26082. /**
  26083. * Releases all resources associated with the current skeleton
  26084. */
  26085. dispose(): void;
  26086. /**
  26087. * Serialize the skeleton in a JSON object
  26088. * @returns a JSON object
  26089. */
  26090. serialize(): any;
  26091. /**
  26092. * Creates a new skeleton from serialized data
  26093. * @param parsedSkeleton defines the serialized data
  26094. * @param scene defines the hosting scene
  26095. * @returns a new skeleton
  26096. */
  26097. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  26098. /**
  26099. * Compute all node absolute transforms
  26100. * @param forceUpdate defines if computation must be done even if cache is up to date
  26101. */
  26102. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  26103. /**
  26104. * Gets the root pose matrix
  26105. * @returns a matrix
  26106. */
  26107. getPoseMatrix(): Nullable<Matrix>;
  26108. /**
  26109. * Sorts bones per internal index
  26110. */
  26111. sortBones(): void;
  26112. private _sortBones;
  26113. /**
  26114. * Set the current local matrix as the restPose for all bones in the skeleton.
  26115. */
  26116. setCurrentPoseAsRest(): void;
  26117. }
  26118. }
  26119. declare module BABYLON {
  26120. /**
  26121. * Class used to store bone information
  26122. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26123. */
  26124. export class Bone extends Node {
  26125. /**
  26126. * defines the bone name
  26127. */
  26128. name: string;
  26129. private static _tmpVecs;
  26130. private static _tmpQuat;
  26131. private static _tmpMats;
  26132. /**
  26133. * Gets the list of child bones
  26134. */
  26135. children: Bone[];
  26136. /** Gets the animations associated with this bone */
  26137. animations: Animation[];
  26138. /**
  26139. * Gets or sets bone length
  26140. */
  26141. length: number;
  26142. /**
  26143. * @hidden Internal only
  26144. * Set this value to map this bone to a different index in the transform matrices
  26145. * Set this value to -1 to exclude the bone from the transform matrices
  26146. */
  26147. _index: Nullable<number>;
  26148. private _skeleton;
  26149. private _localMatrix;
  26150. private _restPose;
  26151. private _bindPose;
  26152. private _baseMatrix;
  26153. private _absoluteTransform;
  26154. private _invertedAbsoluteTransform;
  26155. private _parent;
  26156. private _scalingDeterminant;
  26157. private _worldTransform;
  26158. private _localScaling;
  26159. private _localRotation;
  26160. private _localPosition;
  26161. private _needToDecompose;
  26162. private _needToCompose;
  26163. /** @hidden */
  26164. _linkedTransformNode: Nullable<TransformNode>;
  26165. /** @hidden */
  26166. _waitingTransformNodeId: Nullable<string>;
  26167. /** @hidden */
  26168. get _matrix(): Matrix;
  26169. /** @hidden */
  26170. set _matrix(value: Matrix);
  26171. /**
  26172. * Create a new bone
  26173. * @param name defines the bone name
  26174. * @param skeleton defines the parent skeleton
  26175. * @param parentBone defines the parent (can be null if the bone is the root)
  26176. * @param localMatrix defines the local matrix
  26177. * @param restPose defines the rest pose matrix
  26178. * @param baseMatrix defines the base matrix
  26179. * @param index defines index of the bone in the hiearchy
  26180. */
  26181. constructor(
  26182. /**
  26183. * defines the bone name
  26184. */
  26185. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  26186. /**
  26187. * Gets the current object class name.
  26188. * @return the class name
  26189. */
  26190. getClassName(): string;
  26191. /**
  26192. * Gets the parent skeleton
  26193. * @returns a skeleton
  26194. */
  26195. getSkeleton(): Skeleton;
  26196. /**
  26197. * Gets parent bone
  26198. * @returns a bone or null if the bone is the root of the bone hierarchy
  26199. */
  26200. getParent(): Nullable<Bone>;
  26201. /**
  26202. * Returns an array containing the root bones
  26203. * @returns an array containing the root bones
  26204. */
  26205. getChildren(): Array<Bone>;
  26206. /**
  26207. * Gets the node index in matrix array generated for rendering
  26208. * @returns the node index
  26209. */
  26210. getIndex(): number;
  26211. /**
  26212. * Sets the parent bone
  26213. * @param parent defines the parent (can be null if the bone is the root)
  26214. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26215. */
  26216. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  26217. /**
  26218. * Gets the local matrix
  26219. * @returns a matrix
  26220. */
  26221. getLocalMatrix(): Matrix;
  26222. /**
  26223. * Gets the base matrix (initial matrix which remains unchanged)
  26224. * @returns a matrix
  26225. */
  26226. getBaseMatrix(): Matrix;
  26227. /**
  26228. * Gets the rest pose matrix
  26229. * @returns a matrix
  26230. */
  26231. getRestPose(): Matrix;
  26232. /**
  26233. * Sets the rest pose matrix
  26234. * @param matrix the local-space rest pose to set for this bone
  26235. */
  26236. setRestPose(matrix: Matrix): void;
  26237. /**
  26238. * Gets the bind pose matrix
  26239. * @returns the bind pose matrix
  26240. */
  26241. getBindPose(): Matrix;
  26242. /**
  26243. * Sets the bind pose matrix
  26244. * @param matrix the local-space bind pose to set for this bone
  26245. */
  26246. setBindPose(matrix: Matrix): void;
  26247. /**
  26248. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  26249. */
  26250. getWorldMatrix(): Matrix;
  26251. /**
  26252. * Sets the local matrix to rest pose matrix
  26253. */
  26254. returnToRest(): void;
  26255. /**
  26256. * Gets the inverse of the absolute transform matrix.
  26257. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  26258. * @returns a matrix
  26259. */
  26260. getInvertedAbsoluteTransform(): Matrix;
  26261. /**
  26262. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  26263. * @returns a matrix
  26264. */
  26265. getAbsoluteTransform(): Matrix;
  26266. /**
  26267. * Links with the given transform node.
  26268. * The local matrix of this bone is copied from the transform node every frame.
  26269. * @param transformNode defines the transform node to link to
  26270. */
  26271. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  26272. /**
  26273. * Gets the node used to drive the bone's transformation
  26274. * @returns a transform node or null
  26275. */
  26276. getTransformNode(): Nullable<TransformNode>;
  26277. /** Gets or sets current position (in local space) */
  26278. get position(): Vector3;
  26279. set position(newPosition: Vector3);
  26280. /** Gets or sets current rotation (in local space) */
  26281. get rotation(): Vector3;
  26282. set rotation(newRotation: Vector3);
  26283. /** Gets or sets current rotation quaternion (in local space) */
  26284. get rotationQuaternion(): Quaternion;
  26285. set rotationQuaternion(newRotation: Quaternion);
  26286. /** Gets or sets current scaling (in local space) */
  26287. get scaling(): Vector3;
  26288. set scaling(newScaling: Vector3);
  26289. /**
  26290. * Gets the animation properties override
  26291. */
  26292. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26293. private _decompose;
  26294. private _compose;
  26295. /**
  26296. * Update the base and local matrices
  26297. * @param matrix defines the new base or local matrix
  26298. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26299. * @param updateLocalMatrix defines if the local matrix should be updated
  26300. */
  26301. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  26302. /** @hidden */
  26303. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  26304. /**
  26305. * Flag the bone as dirty (Forcing it to update everything)
  26306. */
  26307. markAsDirty(): void;
  26308. /** @hidden */
  26309. _markAsDirtyAndCompose(): void;
  26310. private _markAsDirtyAndDecompose;
  26311. /**
  26312. * Translate the bone in local or world space
  26313. * @param vec The amount to translate the bone
  26314. * @param space The space that the translation is in
  26315. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26316. */
  26317. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26318. /**
  26319. * Set the postion of the bone in local or world space
  26320. * @param position The position to set the bone
  26321. * @param space The space that the position is in
  26322. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26323. */
  26324. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26325. /**
  26326. * Set the absolute position of the bone (world space)
  26327. * @param position The position to set the bone
  26328. * @param mesh The mesh that this bone is attached to
  26329. */
  26330. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  26331. /**
  26332. * Scale the bone on the x, y and z axes (in local space)
  26333. * @param x The amount to scale the bone on the x axis
  26334. * @param y The amount to scale the bone on the y axis
  26335. * @param z The amount to scale the bone on the z axis
  26336. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  26337. */
  26338. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  26339. /**
  26340. * Set the bone scaling in local space
  26341. * @param scale defines the scaling vector
  26342. */
  26343. setScale(scale: Vector3): void;
  26344. /**
  26345. * Gets the current scaling in local space
  26346. * @returns the current scaling vector
  26347. */
  26348. getScale(): Vector3;
  26349. /**
  26350. * Gets the current scaling in local space and stores it in a target vector
  26351. * @param result defines the target vector
  26352. */
  26353. getScaleToRef(result: Vector3): void;
  26354. /**
  26355. * Set the yaw, pitch, and roll of the bone in local or world space
  26356. * @param yaw The rotation of the bone on the y axis
  26357. * @param pitch The rotation of the bone on the x axis
  26358. * @param roll The rotation of the bone on the z axis
  26359. * @param space The space that the axes of rotation are in
  26360. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26361. */
  26362. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  26363. /**
  26364. * Add a rotation to the bone on an axis in local or world space
  26365. * @param axis The axis to rotate the bone on
  26366. * @param amount The amount to rotate the bone
  26367. * @param space The space that the axis is in
  26368. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26369. */
  26370. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  26371. /**
  26372. * Set the rotation of the bone to a particular axis angle in local or world space
  26373. * @param axis The axis to rotate the bone on
  26374. * @param angle The angle that the bone should be rotated to
  26375. * @param space The space that the axis is in
  26376. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26377. */
  26378. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  26379. /**
  26380. * Set the euler rotation of the bone in local or world space
  26381. * @param rotation The euler rotation that the bone should be set to
  26382. * @param space The space that the rotation is in
  26383. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26384. */
  26385. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26386. /**
  26387. * Set the quaternion rotation of the bone in local or world space
  26388. * @param quat The quaternion rotation that the bone should be set to
  26389. * @param space The space that the rotation is in
  26390. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26391. */
  26392. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  26393. /**
  26394. * Set the rotation matrix of the bone in local or world space
  26395. * @param rotMat The rotation matrix that the bone should be set to
  26396. * @param space The space that the rotation is in
  26397. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26398. */
  26399. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  26400. private _rotateWithMatrix;
  26401. private _getNegativeRotationToRef;
  26402. /**
  26403. * Get the position of the bone in local or world space
  26404. * @param space The space that the returned position is in
  26405. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26406. * @returns The position of the bone
  26407. */
  26408. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26409. /**
  26410. * Copy the position of the bone to a vector3 in local or world space
  26411. * @param space The space that the returned position is in
  26412. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26413. * @param result The vector3 to copy the position to
  26414. */
  26415. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  26416. /**
  26417. * Get the absolute position of the bone (world space)
  26418. * @param mesh The mesh that this bone is attached to
  26419. * @returns The absolute position of the bone
  26420. */
  26421. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  26422. /**
  26423. * Copy the absolute position of the bone (world space) to the result param
  26424. * @param mesh The mesh that this bone is attached to
  26425. * @param result The vector3 to copy the absolute position to
  26426. */
  26427. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  26428. /**
  26429. * Compute the absolute transforms of this bone and its children
  26430. */
  26431. computeAbsoluteTransforms(): void;
  26432. /**
  26433. * Get the world direction from an axis that is in the local space of the bone
  26434. * @param localAxis The local direction that is used to compute the world direction
  26435. * @param mesh The mesh that this bone is attached to
  26436. * @returns The world direction
  26437. */
  26438. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26439. /**
  26440. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  26441. * @param localAxis The local direction that is used to compute the world direction
  26442. * @param mesh The mesh that this bone is attached to
  26443. * @param result The vector3 that the world direction will be copied to
  26444. */
  26445. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26446. /**
  26447. * Get the euler rotation of the bone in local or world space
  26448. * @param space The space that the rotation should be in
  26449. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26450. * @returns The euler rotation
  26451. */
  26452. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26453. /**
  26454. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  26455. * @param space The space that the rotation should be in
  26456. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26457. * @param result The vector3 that the rotation should be copied to
  26458. */
  26459. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26460. /**
  26461. * Get the quaternion rotation of the bone in either local or world space
  26462. * @param space The space that the rotation should be in
  26463. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26464. * @returns The quaternion rotation
  26465. */
  26466. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  26467. /**
  26468. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  26469. * @param space The space that the rotation should be in
  26470. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26471. * @param result The quaternion that the rotation should be copied to
  26472. */
  26473. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  26474. /**
  26475. * Get the rotation matrix of the bone in local or world space
  26476. * @param space The space that the rotation should be in
  26477. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26478. * @returns The rotation matrix
  26479. */
  26480. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  26481. /**
  26482. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  26483. * @param space The space that the rotation should be in
  26484. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26485. * @param result The quaternion that the rotation should be copied to
  26486. */
  26487. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  26488. /**
  26489. * Get the world position of a point that is in the local space of the bone
  26490. * @param position The local position
  26491. * @param mesh The mesh that this bone is attached to
  26492. * @returns The world position
  26493. */
  26494. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26495. /**
  26496. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  26497. * @param position The local position
  26498. * @param mesh The mesh that this bone is attached to
  26499. * @param result The vector3 that the world position should be copied to
  26500. */
  26501. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26502. /**
  26503. * Get the local position of a point that is in world space
  26504. * @param position The world position
  26505. * @param mesh The mesh that this bone is attached to
  26506. * @returns The local position
  26507. */
  26508. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26509. /**
  26510. * Get the local position of a point that is in world space and copy it to the result param
  26511. * @param position The world position
  26512. * @param mesh The mesh that this bone is attached to
  26513. * @param result The vector3 that the local position should be copied to
  26514. */
  26515. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26516. /**
  26517. * Set the current local matrix as the restPose for this bone.
  26518. */
  26519. setCurrentPoseAsRest(): void;
  26520. }
  26521. }
  26522. declare module BABYLON {
  26523. /**
  26524. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  26525. * @see https://doc.babylonjs.com/how_to/transformnode
  26526. */
  26527. export class TransformNode extends Node {
  26528. /**
  26529. * Object will not rotate to face the camera
  26530. */
  26531. static BILLBOARDMODE_NONE: number;
  26532. /**
  26533. * Object will rotate to face the camera but only on the x axis
  26534. */
  26535. static BILLBOARDMODE_X: number;
  26536. /**
  26537. * Object will rotate to face the camera but only on the y axis
  26538. */
  26539. static BILLBOARDMODE_Y: number;
  26540. /**
  26541. * Object will rotate to face the camera but only on the z axis
  26542. */
  26543. static BILLBOARDMODE_Z: number;
  26544. /**
  26545. * Object will rotate to face the camera
  26546. */
  26547. static BILLBOARDMODE_ALL: number;
  26548. /**
  26549. * Object will rotate to face the camera's position instead of orientation
  26550. */
  26551. static BILLBOARDMODE_USE_POSITION: number;
  26552. private static _TmpRotation;
  26553. private static _TmpScaling;
  26554. private static _TmpTranslation;
  26555. private _forward;
  26556. private _forwardInverted;
  26557. private _up;
  26558. private _right;
  26559. private _rightInverted;
  26560. private _position;
  26561. private _rotation;
  26562. private _rotationQuaternion;
  26563. protected _scaling: Vector3;
  26564. protected _isDirty: boolean;
  26565. private _transformToBoneReferal;
  26566. private _isAbsoluteSynced;
  26567. private _billboardMode;
  26568. /**
  26569. * Gets or sets the billboard mode. Default is 0.
  26570. *
  26571. * | Value | Type | Description |
  26572. * | --- | --- | --- |
  26573. * | 0 | BILLBOARDMODE_NONE | |
  26574. * | 1 | BILLBOARDMODE_X | |
  26575. * | 2 | BILLBOARDMODE_Y | |
  26576. * | 4 | BILLBOARDMODE_Z | |
  26577. * | 7 | BILLBOARDMODE_ALL | |
  26578. *
  26579. */
  26580. get billboardMode(): number;
  26581. set billboardMode(value: number);
  26582. private _preserveParentRotationForBillboard;
  26583. /**
  26584. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  26585. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  26586. */
  26587. get preserveParentRotationForBillboard(): boolean;
  26588. set preserveParentRotationForBillboard(value: boolean);
  26589. /**
  26590. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  26591. */
  26592. scalingDeterminant: number;
  26593. private _infiniteDistance;
  26594. /**
  26595. * Gets or sets the distance of the object to max, often used by skybox
  26596. */
  26597. get infiniteDistance(): boolean;
  26598. set infiniteDistance(value: boolean);
  26599. /**
  26600. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  26601. * By default the system will update normals to compensate
  26602. */
  26603. ignoreNonUniformScaling: boolean;
  26604. /**
  26605. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  26606. */
  26607. reIntegrateRotationIntoRotationQuaternion: boolean;
  26608. /** @hidden */
  26609. _poseMatrix: Nullable<Matrix>;
  26610. /** @hidden */
  26611. _localMatrix: Matrix;
  26612. private _usePivotMatrix;
  26613. private _absolutePosition;
  26614. private _absoluteScaling;
  26615. private _absoluteRotationQuaternion;
  26616. private _pivotMatrix;
  26617. private _pivotMatrixInverse;
  26618. /** @hidden */
  26619. _postMultiplyPivotMatrix: boolean;
  26620. protected _isWorldMatrixFrozen: boolean;
  26621. /** @hidden */
  26622. _indexInSceneTransformNodesArray: number;
  26623. /**
  26624. * An event triggered after the world matrix is updated
  26625. */
  26626. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  26627. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  26628. /**
  26629. * Gets a string identifying the name of the class
  26630. * @returns "TransformNode" string
  26631. */
  26632. getClassName(): string;
  26633. /**
  26634. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  26635. */
  26636. get position(): Vector3;
  26637. set position(newPosition: Vector3);
  26638. /**
  26639. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  26640. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  26641. */
  26642. get rotation(): Vector3;
  26643. set rotation(newRotation: Vector3);
  26644. /**
  26645. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  26646. */
  26647. get scaling(): Vector3;
  26648. set scaling(newScaling: Vector3);
  26649. /**
  26650. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  26651. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  26652. */
  26653. get rotationQuaternion(): Nullable<Quaternion>;
  26654. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  26655. /**
  26656. * The forward direction of that transform in world space.
  26657. */
  26658. get forward(): Vector3;
  26659. /**
  26660. * The up direction of that transform in world space.
  26661. */
  26662. get up(): Vector3;
  26663. /**
  26664. * The right direction of that transform in world space.
  26665. */
  26666. get right(): Vector3;
  26667. /**
  26668. * Copies the parameter passed Matrix into the mesh Pose matrix.
  26669. * @param matrix the matrix to copy the pose from
  26670. * @returns this TransformNode.
  26671. */
  26672. updatePoseMatrix(matrix: Matrix): TransformNode;
  26673. /**
  26674. * Returns the mesh Pose matrix.
  26675. * @returns the pose matrix
  26676. */
  26677. getPoseMatrix(): Matrix;
  26678. /** @hidden */
  26679. _isSynchronized(): boolean;
  26680. /** @hidden */
  26681. _initCache(): void;
  26682. /**
  26683. * Flag the transform node as dirty (Forcing it to update everything)
  26684. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  26685. * @returns this transform node
  26686. */
  26687. markAsDirty(property: string): TransformNode;
  26688. /**
  26689. * Returns the current mesh absolute position.
  26690. * Returns a Vector3.
  26691. */
  26692. get absolutePosition(): Vector3;
  26693. /**
  26694. * Returns the current mesh absolute scaling.
  26695. * Returns a Vector3.
  26696. */
  26697. get absoluteScaling(): Vector3;
  26698. /**
  26699. * Returns the current mesh absolute rotation.
  26700. * Returns a Quaternion.
  26701. */
  26702. get absoluteRotationQuaternion(): Quaternion;
  26703. /**
  26704. * Sets a new matrix to apply before all other transformation
  26705. * @param matrix defines the transform matrix
  26706. * @returns the current TransformNode
  26707. */
  26708. setPreTransformMatrix(matrix: Matrix): TransformNode;
  26709. /**
  26710. * Sets a new pivot matrix to the current node
  26711. * @param matrix defines the new pivot matrix to use
  26712. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  26713. * @returns the current TransformNode
  26714. */
  26715. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  26716. /**
  26717. * Returns the mesh pivot matrix.
  26718. * Default : Identity.
  26719. * @returns the matrix
  26720. */
  26721. getPivotMatrix(): Matrix;
  26722. /**
  26723. * Instantiate (when possible) or clone that node with its hierarchy
  26724. * @param newParent defines the new parent to use for the instance (or clone)
  26725. * @param options defines options to configure how copy is done
  26726. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  26727. * @returns an instance (or a clone) of the current node with its hiearchy
  26728. */
  26729. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  26730. doNotInstantiate: boolean;
  26731. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  26732. /**
  26733. * Prevents the World matrix to be computed any longer
  26734. * @param newWorldMatrix defines an optional matrix to use as world matrix
  26735. * @returns the TransformNode.
  26736. */
  26737. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  26738. /**
  26739. * Allows back the World matrix computation.
  26740. * @returns the TransformNode.
  26741. */
  26742. unfreezeWorldMatrix(): this;
  26743. /**
  26744. * True if the World matrix has been frozen.
  26745. */
  26746. get isWorldMatrixFrozen(): boolean;
  26747. /**
  26748. * Retuns the mesh absolute position in the World.
  26749. * @returns a Vector3.
  26750. */
  26751. getAbsolutePosition(): Vector3;
  26752. /**
  26753. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  26754. * @param absolutePosition the absolute position to set
  26755. * @returns the TransformNode.
  26756. */
  26757. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26758. /**
  26759. * Sets the mesh position in its local space.
  26760. * @param vector3 the position to set in localspace
  26761. * @returns the TransformNode.
  26762. */
  26763. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  26764. /**
  26765. * Returns the mesh position in the local space from the current World matrix values.
  26766. * @returns a new Vector3.
  26767. */
  26768. getPositionExpressedInLocalSpace(): Vector3;
  26769. /**
  26770. * Translates the mesh along the passed Vector3 in its local space.
  26771. * @param vector3 the distance to translate in localspace
  26772. * @returns the TransformNode.
  26773. */
  26774. locallyTranslate(vector3: Vector3): TransformNode;
  26775. private static _lookAtVectorCache;
  26776. /**
  26777. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  26778. * @param targetPoint the position (must be in same space as current mesh) to look at
  26779. * @param yawCor optional yaw (y-axis) correction in radians
  26780. * @param pitchCor optional pitch (x-axis) correction in radians
  26781. * @param rollCor optional roll (z-axis) correction in radians
  26782. * @param space the choosen space of the target
  26783. * @returns the TransformNode.
  26784. */
  26785. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  26786. /**
  26787. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26788. * This Vector3 is expressed in the World space.
  26789. * @param localAxis axis to rotate
  26790. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26791. */
  26792. getDirection(localAxis: Vector3): Vector3;
  26793. /**
  26794. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  26795. * localAxis is expressed in the mesh local space.
  26796. * result is computed in the Wordl space from the mesh World matrix.
  26797. * @param localAxis axis to rotate
  26798. * @param result the resulting transformnode
  26799. * @returns this TransformNode.
  26800. */
  26801. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  26802. /**
  26803. * Sets this transform node rotation to the given local axis.
  26804. * @param localAxis the axis in local space
  26805. * @param yawCor optional yaw (y-axis) correction in radians
  26806. * @param pitchCor optional pitch (x-axis) correction in radians
  26807. * @param rollCor optional roll (z-axis) correction in radians
  26808. * @returns this TransformNode
  26809. */
  26810. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  26811. /**
  26812. * Sets a new pivot point to the current node
  26813. * @param point defines the new pivot point to use
  26814. * @param space defines if the point is in world or local space (local by default)
  26815. * @returns the current TransformNode
  26816. */
  26817. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  26818. /**
  26819. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  26820. * @returns the pivot point
  26821. */
  26822. getPivotPoint(): Vector3;
  26823. /**
  26824. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  26825. * @param result the vector3 to store the result
  26826. * @returns this TransformNode.
  26827. */
  26828. getPivotPointToRef(result: Vector3): TransformNode;
  26829. /**
  26830. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  26831. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  26832. */
  26833. getAbsolutePivotPoint(): Vector3;
  26834. /**
  26835. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  26836. * @param result vector3 to store the result
  26837. * @returns this TransformNode.
  26838. */
  26839. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  26840. /**
  26841. * Defines the passed node as the parent of the current node.
  26842. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  26843. * @see https://doc.babylonjs.com/how_to/parenting
  26844. * @param node the node ot set as the parent
  26845. * @returns this TransformNode.
  26846. */
  26847. setParent(node: Nullable<Node>): TransformNode;
  26848. private _nonUniformScaling;
  26849. /**
  26850. * True if the scaling property of this object is non uniform eg. (1,2,1)
  26851. */
  26852. get nonUniformScaling(): boolean;
  26853. /** @hidden */
  26854. _updateNonUniformScalingState(value: boolean): boolean;
  26855. /**
  26856. * Attach the current TransformNode to another TransformNode associated with a bone
  26857. * @param bone Bone affecting the TransformNode
  26858. * @param affectedTransformNode TransformNode associated with the bone
  26859. * @returns this object
  26860. */
  26861. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  26862. /**
  26863. * Detach the transform node if its associated with a bone
  26864. * @returns this object
  26865. */
  26866. detachFromBone(): TransformNode;
  26867. private static _rotationAxisCache;
  26868. /**
  26869. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  26870. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26871. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26872. * The passed axis is also normalized.
  26873. * @param axis the axis to rotate around
  26874. * @param amount the amount to rotate in radians
  26875. * @param space Space to rotate in (Default: local)
  26876. * @returns the TransformNode.
  26877. */
  26878. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26879. /**
  26880. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  26881. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26882. * The passed axis is also normalized. .
  26883. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  26884. * @param point the point to rotate around
  26885. * @param axis the axis to rotate around
  26886. * @param amount the amount to rotate in radians
  26887. * @returns the TransformNode
  26888. */
  26889. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  26890. /**
  26891. * Translates the mesh along the axis vector for the passed distance in the given space.
  26892. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26893. * @param axis the axis to translate in
  26894. * @param distance the distance to translate
  26895. * @param space Space to rotate in (Default: local)
  26896. * @returns the TransformNode.
  26897. */
  26898. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26899. /**
  26900. * Adds a rotation step to the mesh current rotation.
  26901. * x, y, z are Euler angles expressed in radians.
  26902. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  26903. * This means this rotation is made in the mesh local space only.
  26904. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  26905. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  26906. * ```javascript
  26907. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  26908. * ```
  26909. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  26910. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  26911. * @param x Rotation to add
  26912. * @param y Rotation to add
  26913. * @param z Rotation to add
  26914. * @returns the TransformNode.
  26915. */
  26916. addRotation(x: number, y: number, z: number): TransformNode;
  26917. /**
  26918. * @hidden
  26919. */
  26920. protected _getEffectiveParent(): Nullable<Node>;
  26921. /**
  26922. * Computes the world matrix of the node
  26923. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26924. * @returns the world matrix
  26925. */
  26926. computeWorldMatrix(force?: boolean): Matrix;
  26927. /**
  26928. * Resets this nodeTransform's local matrix to Matrix.Identity().
  26929. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  26930. */
  26931. resetLocalMatrix(independentOfChildren?: boolean): void;
  26932. protected _afterComputeWorldMatrix(): void;
  26933. /**
  26934. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  26935. * @param func callback function to add
  26936. *
  26937. * @returns the TransformNode.
  26938. */
  26939. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26940. /**
  26941. * Removes a registered callback function.
  26942. * @param func callback function to remove
  26943. * @returns the TransformNode.
  26944. */
  26945. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26946. /**
  26947. * Gets the position of the current mesh in camera space
  26948. * @param camera defines the camera to use
  26949. * @returns a position
  26950. */
  26951. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  26952. /**
  26953. * Returns the distance from the mesh to the active camera
  26954. * @param camera defines the camera to use
  26955. * @returns the distance
  26956. */
  26957. getDistanceToCamera(camera?: Nullable<Camera>): number;
  26958. /**
  26959. * Clone the current transform node
  26960. * @param name Name of the new clone
  26961. * @param newParent New parent for the clone
  26962. * @param doNotCloneChildren Do not clone children hierarchy
  26963. * @returns the new transform node
  26964. */
  26965. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  26966. /**
  26967. * Serializes the objects information.
  26968. * @param currentSerializationObject defines the object to serialize in
  26969. * @returns the serialized object
  26970. */
  26971. serialize(currentSerializationObject?: any): any;
  26972. /**
  26973. * Returns a new TransformNode object parsed from the source provided.
  26974. * @param parsedTransformNode is the source.
  26975. * @param scene the scne the object belongs to
  26976. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  26977. * @returns a new TransformNode object parsed from the source provided.
  26978. */
  26979. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  26980. /**
  26981. * Get all child-transformNodes of this node
  26982. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  26983. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  26984. * @returns an array of TransformNode
  26985. */
  26986. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  26987. /**
  26988. * Releases resources associated with this transform node.
  26989. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26990. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26991. */
  26992. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26993. /**
  26994. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26995. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26996. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26997. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26998. * @returns the current mesh
  26999. */
  27000. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  27001. private _syncAbsoluteScalingAndRotation;
  27002. }
  27003. }
  27004. declare module BABYLON {
  27005. /**
  27006. * Defines the types of pose enabled controllers that are supported
  27007. */
  27008. export enum PoseEnabledControllerType {
  27009. /**
  27010. * HTC Vive
  27011. */
  27012. VIVE = 0,
  27013. /**
  27014. * Oculus Rift
  27015. */
  27016. OCULUS = 1,
  27017. /**
  27018. * Windows mixed reality
  27019. */
  27020. WINDOWS = 2,
  27021. /**
  27022. * Samsung gear VR
  27023. */
  27024. GEAR_VR = 3,
  27025. /**
  27026. * Google Daydream
  27027. */
  27028. DAYDREAM = 4,
  27029. /**
  27030. * Generic
  27031. */
  27032. GENERIC = 5
  27033. }
  27034. /**
  27035. * Defines the MutableGamepadButton interface for the state of a gamepad button
  27036. */
  27037. export interface MutableGamepadButton {
  27038. /**
  27039. * Value of the button/trigger
  27040. */
  27041. value: number;
  27042. /**
  27043. * If the button/trigger is currently touched
  27044. */
  27045. touched: boolean;
  27046. /**
  27047. * If the button/trigger is currently pressed
  27048. */
  27049. pressed: boolean;
  27050. }
  27051. /**
  27052. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  27053. * @hidden
  27054. */
  27055. export interface ExtendedGamepadButton extends GamepadButton {
  27056. /**
  27057. * If the button/trigger is currently pressed
  27058. */
  27059. readonly pressed: boolean;
  27060. /**
  27061. * If the button/trigger is currently touched
  27062. */
  27063. readonly touched: boolean;
  27064. /**
  27065. * Value of the button/trigger
  27066. */
  27067. readonly value: number;
  27068. }
  27069. /** @hidden */
  27070. export interface _GamePadFactory {
  27071. /**
  27072. * Returns whether or not the current gamepad can be created for this type of controller.
  27073. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27074. * @returns true if it can be created, otherwise false
  27075. */
  27076. canCreate(gamepadInfo: any): boolean;
  27077. /**
  27078. * Creates a new instance of the Gamepad.
  27079. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27080. * @returns the new gamepad instance
  27081. */
  27082. create(gamepadInfo: any): Gamepad;
  27083. }
  27084. /**
  27085. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27086. */
  27087. export class PoseEnabledControllerHelper {
  27088. /** @hidden */
  27089. static _ControllerFactories: _GamePadFactory[];
  27090. /** @hidden */
  27091. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  27092. /**
  27093. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27094. * @param vrGamepad the gamepad to initialized
  27095. * @returns a vr controller of the type the gamepad identified as
  27096. */
  27097. static InitiateController(vrGamepad: any): Gamepad;
  27098. }
  27099. /**
  27100. * Defines the PoseEnabledController object that contains state of a vr capable controller
  27101. */
  27102. export class PoseEnabledController extends Gamepad implements PoseControlled {
  27103. /**
  27104. * If the controller is used in a webXR session
  27105. */
  27106. isXR: boolean;
  27107. private _deviceRoomPosition;
  27108. private _deviceRoomRotationQuaternion;
  27109. /**
  27110. * The device position in babylon space
  27111. */
  27112. devicePosition: Vector3;
  27113. /**
  27114. * The device rotation in babylon space
  27115. */
  27116. deviceRotationQuaternion: Quaternion;
  27117. /**
  27118. * The scale factor of the device in babylon space
  27119. */
  27120. deviceScaleFactor: number;
  27121. /**
  27122. * (Likely devicePosition should be used instead) The device position in its room space
  27123. */
  27124. position: Vector3;
  27125. /**
  27126. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  27127. */
  27128. rotationQuaternion: Quaternion;
  27129. /**
  27130. * The type of controller (Eg. Windows mixed reality)
  27131. */
  27132. controllerType: PoseEnabledControllerType;
  27133. protected _calculatedPosition: Vector3;
  27134. private _calculatedRotation;
  27135. /**
  27136. * The raw pose from the device
  27137. */
  27138. rawPose: DevicePose;
  27139. private _trackPosition;
  27140. private _maxRotationDistFromHeadset;
  27141. private _draggedRoomRotation;
  27142. /**
  27143. * @hidden
  27144. */
  27145. _disableTrackPosition(fixedPosition: Vector3): void;
  27146. /**
  27147. * Internal, the mesh attached to the controller
  27148. * @hidden
  27149. */
  27150. _mesh: Nullable<AbstractMesh>;
  27151. private _poseControlledCamera;
  27152. private _leftHandSystemQuaternion;
  27153. /**
  27154. * Internal, matrix used to convert room space to babylon space
  27155. * @hidden
  27156. */
  27157. _deviceToWorld: Matrix;
  27158. /**
  27159. * Node to be used when casting a ray from the controller
  27160. * @hidden
  27161. */
  27162. _pointingPoseNode: Nullable<TransformNode>;
  27163. /**
  27164. * Name of the child mesh that can be used to cast a ray from the controller
  27165. */
  27166. static readonly POINTING_POSE: string;
  27167. /**
  27168. * Creates a new PoseEnabledController from a gamepad
  27169. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  27170. */
  27171. constructor(browserGamepad: any);
  27172. private _workingMatrix;
  27173. /**
  27174. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  27175. */
  27176. update(): void;
  27177. /**
  27178. * Updates only the pose device and mesh without doing any button event checking
  27179. */
  27180. protected _updatePoseAndMesh(): void;
  27181. /**
  27182. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  27183. * @param poseData raw pose fromthe device
  27184. */
  27185. updateFromDevice(poseData: DevicePose): void;
  27186. /**
  27187. * @hidden
  27188. */
  27189. _meshAttachedObservable: Observable<AbstractMesh>;
  27190. /**
  27191. * Attaches a mesh to the controller
  27192. * @param mesh the mesh to be attached
  27193. */
  27194. attachToMesh(mesh: AbstractMesh): void;
  27195. /**
  27196. * Attaches the controllers mesh to a camera
  27197. * @param camera the camera the mesh should be attached to
  27198. */
  27199. attachToPoseControlledCamera(camera: TargetCamera): void;
  27200. /**
  27201. * Disposes of the controller
  27202. */
  27203. dispose(): void;
  27204. /**
  27205. * The mesh that is attached to the controller
  27206. */
  27207. get mesh(): Nullable<AbstractMesh>;
  27208. /**
  27209. * Gets the ray of the controller in the direction the controller is pointing
  27210. * @param length the length the resulting ray should be
  27211. * @returns a ray in the direction the controller is pointing
  27212. */
  27213. getForwardRay(length?: number): Ray;
  27214. }
  27215. }
  27216. declare module BABYLON {
  27217. /**
  27218. * Defines the WebVRController object that represents controllers tracked in 3D space
  27219. */
  27220. export abstract class WebVRController extends PoseEnabledController {
  27221. /**
  27222. * Internal, the default controller model for the controller
  27223. */
  27224. protected _defaultModel: Nullable<AbstractMesh>;
  27225. /**
  27226. * Fired when the trigger state has changed
  27227. */
  27228. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  27229. /**
  27230. * Fired when the main button state has changed
  27231. */
  27232. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27233. /**
  27234. * Fired when the secondary button state has changed
  27235. */
  27236. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27237. /**
  27238. * Fired when the pad state has changed
  27239. */
  27240. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  27241. /**
  27242. * Fired when controllers stick values have changed
  27243. */
  27244. onPadValuesChangedObservable: Observable<StickValues>;
  27245. /**
  27246. * Array of button availible on the controller
  27247. */
  27248. protected _buttons: Array<MutableGamepadButton>;
  27249. private _onButtonStateChange;
  27250. /**
  27251. * Fired when a controller button's state has changed
  27252. * @param callback the callback containing the button that was modified
  27253. */
  27254. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  27255. /**
  27256. * X and Y axis corresponding to the controllers joystick
  27257. */
  27258. pad: StickValues;
  27259. /**
  27260. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  27261. */
  27262. hand: string;
  27263. /**
  27264. * The default controller model for the controller
  27265. */
  27266. get defaultModel(): Nullable<AbstractMesh>;
  27267. /**
  27268. * Creates a new WebVRController from a gamepad
  27269. * @param vrGamepad the gamepad that the WebVRController should be created from
  27270. */
  27271. constructor(vrGamepad: any);
  27272. /**
  27273. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  27274. */
  27275. update(): void;
  27276. /**
  27277. * Function to be called when a button is modified
  27278. */
  27279. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  27280. /**
  27281. * Loads a mesh and attaches it to the controller
  27282. * @param scene the scene the mesh should be added to
  27283. * @param meshLoaded callback for when the mesh has been loaded
  27284. */
  27285. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  27286. private _setButtonValue;
  27287. private _changes;
  27288. private _checkChanges;
  27289. /**
  27290. * Disposes of th webVRCOntroller
  27291. */
  27292. dispose(): void;
  27293. }
  27294. }
  27295. declare module BABYLON {
  27296. /**
  27297. * The HemisphericLight simulates the ambient environment light,
  27298. * so the passed direction is the light reflection direction, not the incoming direction.
  27299. */
  27300. export class HemisphericLight extends Light {
  27301. /**
  27302. * The groundColor is the light in the opposite direction to the one specified during creation.
  27303. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  27304. */
  27305. groundColor: Color3;
  27306. /**
  27307. * The light reflection direction, not the incoming direction.
  27308. */
  27309. direction: Vector3;
  27310. /**
  27311. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  27312. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  27313. * The HemisphericLight can't cast shadows.
  27314. * Documentation : https://doc.babylonjs.com/babylon101/lights
  27315. * @param name The friendly name of the light
  27316. * @param direction The direction of the light reflection
  27317. * @param scene The scene the light belongs to
  27318. */
  27319. constructor(name: string, direction: Vector3, scene: Scene);
  27320. protected _buildUniformLayout(): void;
  27321. /**
  27322. * Returns the string "HemisphericLight".
  27323. * @return The class name
  27324. */
  27325. getClassName(): string;
  27326. /**
  27327. * Sets the HemisphericLight direction towards the passed target (Vector3).
  27328. * Returns the updated direction.
  27329. * @param target The target the direction should point to
  27330. * @return The computed direction
  27331. */
  27332. setDirectionToTarget(target: Vector3): Vector3;
  27333. /**
  27334. * Returns the shadow generator associated to the light.
  27335. * @returns Always null for hemispheric lights because it does not support shadows.
  27336. */
  27337. getShadowGenerator(): Nullable<IShadowGenerator>;
  27338. /**
  27339. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  27340. * @param effect The effect to update
  27341. * @param lightIndex The index of the light in the effect to update
  27342. * @returns The hemispheric light
  27343. */
  27344. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  27345. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  27346. /**
  27347. * Computes the world matrix of the node
  27348. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27349. * @param useWasUpdatedFlag defines a reserved property
  27350. * @returns the world matrix
  27351. */
  27352. computeWorldMatrix(): Matrix;
  27353. /**
  27354. * Returns the integer 3.
  27355. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  27356. */
  27357. getTypeID(): number;
  27358. /**
  27359. * Prepares the list of defines specific to the light type.
  27360. * @param defines the list of defines
  27361. * @param lightIndex defines the index of the light for the effect
  27362. */
  27363. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  27364. }
  27365. }
  27366. declare module BABYLON {
  27367. /** @hidden */
  27368. export var vrMultiviewToSingleviewPixelShader: {
  27369. name: string;
  27370. shader: string;
  27371. };
  27372. }
  27373. declare module BABYLON {
  27374. /**
  27375. * Renders to multiple views with a single draw call
  27376. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  27377. */
  27378. export class MultiviewRenderTarget extends RenderTargetTexture {
  27379. /**
  27380. * Creates a multiview render target
  27381. * @param scene scene used with the render target
  27382. * @param size the size of the render target (used for each view)
  27383. */
  27384. constructor(scene: Scene, size?: number | {
  27385. width: number;
  27386. height: number;
  27387. } | {
  27388. ratio: number;
  27389. });
  27390. /**
  27391. * @hidden
  27392. * @param faceIndex the face index, if its a cube texture
  27393. */
  27394. _bindFrameBuffer(faceIndex?: number): void;
  27395. /**
  27396. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  27397. * @returns the view count
  27398. */
  27399. getViewCount(): number;
  27400. }
  27401. }
  27402. declare module BABYLON {
  27403. interface Engine {
  27404. /**
  27405. * Creates a new multiview render target
  27406. * @param width defines the width of the texture
  27407. * @param height defines the height of the texture
  27408. * @returns the created multiview texture
  27409. */
  27410. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  27411. /**
  27412. * Binds a multiview framebuffer to be drawn to
  27413. * @param multiviewTexture texture to bind
  27414. */
  27415. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  27416. }
  27417. interface Camera {
  27418. /**
  27419. * @hidden
  27420. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  27421. */
  27422. _useMultiviewToSingleView: boolean;
  27423. /**
  27424. * @hidden
  27425. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  27426. */
  27427. _multiviewTexture: Nullable<RenderTargetTexture>;
  27428. /**
  27429. * @hidden
  27430. * ensures the multiview texture of the camera exists and has the specified width/height
  27431. * @param width height to set on the multiview texture
  27432. * @param height width to set on the multiview texture
  27433. */
  27434. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  27435. }
  27436. interface Scene {
  27437. /** @hidden */
  27438. _transformMatrixR: Matrix;
  27439. /** @hidden */
  27440. _multiviewSceneUbo: Nullable<UniformBuffer>;
  27441. /** @hidden */
  27442. _createMultiviewUbo(): void;
  27443. /** @hidden */
  27444. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  27445. /** @hidden */
  27446. _renderMultiviewToSingleView(camera: Camera): void;
  27447. }
  27448. }
  27449. declare module BABYLON {
  27450. /**
  27451. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  27452. * This will not be used for webXR as it supports displaying texture arrays directly
  27453. */
  27454. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  27455. /**
  27456. * Gets a string identifying the name of the class
  27457. * @returns "VRMultiviewToSingleviewPostProcess" string
  27458. */
  27459. getClassName(): string;
  27460. /**
  27461. * Initializes a VRMultiviewToSingleview
  27462. * @param name name of the post process
  27463. * @param camera camera to be applied to
  27464. * @param scaleFactor scaling factor to the size of the output texture
  27465. */
  27466. constructor(name: string, camera: Camera, scaleFactor: number);
  27467. }
  27468. }
  27469. declare module BABYLON {
  27470. /**
  27471. * Interface used to define additional presentation attributes
  27472. */
  27473. export interface IVRPresentationAttributes {
  27474. /**
  27475. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  27476. */
  27477. highRefreshRate: boolean;
  27478. /**
  27479. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  27480. */
  27481. foveationLevel: number;
  27482. }
  27483. interface Engine {
  27484. /** @hidden */
  27485. _vrDisplay: any;
  27486. /** @hidden */
  27487. _vrSupported: boolean;
  27488. /** @hidden */
  27489. _oldSize: Size;
  27490. /** @hidden */
  27491. _oldHardwareScaleFactor: number;
  27492. /** @hidden */
  27493. _vrExclusivePointerMode: boolean;
  27494. /** @hidden */
  27495. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  27496. /** @hidden */
  27497. _onVRDisplayPointerRestricted: () => void;
  27498. /** @hidden */
  27499. _onVRDisplayPointerUnrestricted: () => void;
  27500. /** @hidden */
  27501. _onVrDisplayConnect: Nullable<(display: any) => void>;
  27502. /** @hidden */
  27503. _onVrDisplayDisconnect: Nullable<() => void>;
  27504. /** @hidden */
  27505. _onVrDisplayPresentChange: Nullable<() => void>;
  27506. /**
  27507. * Observable signaled when VR display mode changes
  27508. */
  27509. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27510. /**
  27511. * Observable signaled when VR request present is complete
  27512. */
  27513. onVRRequestPresentComplete: Observable<boolean>;
  27514. /**
  27515. * Observable signaled when VR request present starts
  27516. */
  27517. onVRRequestPresentStart: Observable<Engine>;
  27518. /**
  27519. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27520. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27521. */
  27522. isInVRExclusivePointerMode: boolean;
  27523. /**
  27524. * Gets a boolean indicating if a webVR device was detected
  27525. * @returns true if a webVR device was detected
  27526. */
  27527. isVRDevicePresent(): boolean;
  27528. /**
  27529. * Gets the current webVR device
  27530. * @returns the current webVR device (or null)
  27531. */
  27532. getVRDevice(): any;
  27533. /**
  27534. * Initializes a webVR display and starts listening to display change events
  27535. * The onVRDisplayChangedObservable will be notified upon these changes
  27536. * @returns A promise containing a VRDisplay and if vr is supported
  27537. */
  27538. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27539. /** @hidden */
  27540. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  27541. /**
  27542. * Gets or sets the presentation attributes used to configure VR rendering
  27543. */
  27544. vrPresentationAttributes?: IVRPresentationAttributes;
  27545. /**
  27546. * Call this function to switch to webVR mode
  27547. * Will do nothing if webVR is not supported or if there is no webVR device
  27548. * @param options the webvr options provided to the camera. mainly used for multiview
  27549. * @see https://doc.babylonjs.com/how_to/webvr_camera
  27550. */
  27551. enableVR(options: WebVROptions): void;
  27552. /** @hidden */
  27553. _onVRFullScreenTriggered(): void;
  27554. }
  27555. }
  27556. declare module BABYLON {
  27557. /**
  27558. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  27559. * IMPORTANT!! The data is right-hand data.
  27560. * @export
  27561. * @interface DevicePose
  27562. */
  27563. export interface DevicePose {
  27564. /**
  27565. * The position of the device, values in array are [x,y,z].
  27566. */
  27567. readonly position: Nullable<Float32Array>;
  27568. /**
  27569. * The linearVelocity of the device, values in array are [x,y,z].
  27570. */
  27571. readonly linearVelocity: Nullable<Float32Array>;
  27572. /**
  27573. * The linearAcceleration of the device, values in array are [x,y,z].
  27574. */
  27575. readonly linearAcceleration: Nullable<Float32Array>;
  27576. /**
  27577. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  27578. */
  27579. readonly orientation: Nullable<Float32Array>;
  27580. /**
  27581. * The angularVelocity of the device, values in array are [x,y,z].
  27582. */
  27583. readonly angularVelocity: Nullable<Float32Array>;
  27584. /**
  27585. * The angularAcceleration of the device, values in array are [x,y,z].
  27586. */
  27587. readonly angularAcceleration: Nullable<Float32Array>;
  27588. }
  27589. /**
  27590. * Interface representing a pose controlled object in Babylon.
  27591. * A pose controlled object has both regular pose values as well as pose values
  27592. * from an external device such as a VR head mounted display
  27593. */
  27594. export interface PoseControlled {
  27595. /**
  27596. * The position of the object in babylon space.
  27597. */
  27598. position: Vector3;
  27599. /**
  27600. * The rotation quaternion of the object in babylon space.
  27601. */
  27602. rotationQuaternion: Quaternion;
  27603. /**
  27604. * The position of the device in babylon space.
  27605. */
  27606. devicePosition?: Vector3;
  27607. /**
  27608. * The rotation quaternion of the device in babylon space.
  27609. */
  27610. deviceRotationQuaternion: Quaternion;
  27611. /**
  27612. * The raw pose coming from the device.
  27613. */
  27614. rawPose: Nullable<DevicePose>;
  27615. /**
  27616. * The scale of the device to be used when translating from device space to babylon space.
  27617. */
  27618. deviceScaleFactor: number;
  27619. /**
  27620. * Updates the poseControlled values based on the input device pose.
  27621. * @param poseData the pose data to update the object with
  27622. */
  27623. updateFromDevice(poseData: DevicePose): void;
  27624. }
  27625. /**
  27626. * Set of options to customize the webVRCamera
  27627. */
  27628. export interface WebVROptions {
  27629. /**
  27630. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  27631. */
  27632. trackPosition?: boolean;
  27633. /**
  27634. * Sets the scale of the vrDevice in babylon space. (default: 1)
  27635. */
  27636. positionScale?: number;
  27637. /**
  27638. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  27639. */
  27640. displayName?: string;
  27641. /**
  27642. * Should the native controller meshes be initialized. (default: true)
  27643. */
  27644. controllerMeshes?: boolean;
  27645. /**
  27646. * Creating a default HemiLight only on controllers. (default: true)
  27647. */
  27648. defaultLightingOnControllers?: boolean;
  27649. /**
  27650. * If you don't want to use the default VR button of the helper. (default: false)
  27651. */
  27652. useCustomVRButton?: boolean;
  27653. /**
  27654. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  27655. */
  27656. customVRButton?: HTMLButtonElement;
  27657. /**
  27658. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  27659. */
  27660. rayLength?: number;
  27661. /**
  27662. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  27663. */
  27664. defaultHeight?: number;
  27665. /**
  27666. * If multiview should be used if availible (default: false)
  27667. */
  27668. useMultiview?: boolean;
  27669. }
  27670. /**
  27671. * This represents a WebVR camera.
  27672. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  27673. * @example https://doc.babylonjs.com/how_to/webvr_camera
  27674. */
  27675. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  27676. private webVROptions;
  27677. /**
  27678. * @hidden
  27679. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  27680. */
  27681. _vrDevice: any;
  27682. /**
  27683. * The rawPose of the vrDevice.
  27684. */
  27685. rawPose: Nullable<DevicePose>;
  27686. private _onVREnabled;
  27687. private _specsVersion;
  27688. private _attached;
  27689. private _frameData;
  27690. protected _descendants: Array<Node>;
  27691. private _deviceRoomPosition;
  27692. /** @hidden */
  27693. _deviceRoomRotationQuaternion: Quaternion;
  27694. private _standingMatrix;
  27695. /**
  27696. * Represents device position in babylon space.
  27697. */
  27698. devicePosition: Vector3;
  27699. /**
  27700. * Represents device rotation in babylon space.
  27701. */
  27702. deviceRotationQuaternion: Quaternion;
  27703. /**
  27704. * The scale of the device to be used when translating from device space to babylon space.
  27705. */
  27706. deviceScaleFactor: number;
  27707. private _deviceToWorld;
  27708. private _worldToDevice;
  27709. /**
  27710. * References to the webVR controllers for the vrDevice.
  27711. */
  27712. controllers: Array<WebVRController>;
  27713. /**
  27714. * Emits an event when a controller is attached.
  27715. */
  27716. onControllersAttachedObservable: Observable<WebVRController[]>;
  27717. /**
  27718. * Emits an event when a controller's mesh has been loaded;
  27719. */
  27720. onControllerMeshLoadedObservable: Observable<WebVRController>;
  27721. /**
  27722. * Emits an event when the HMD's pose has been updated.
  27723. */
  27724. onPoseUpdatedFromDeviceObservable: Observable<any>;
  27725. private _poseSet;
  27726. /**
  27727. * If the rig cameras be used as parent instead of this camera.
  27728. */
  27729. rigParenting: boolean;
  27730. private _lightOnControllers;
  27731. private _defaultHeight?;
  27732. /**
  27733. * Instantiates a WebVRFreeCamera.
  27734. * @param name The name of the WebVRFreeCamera
  27735. * @param position The starting anchor position for the camera
  27736. * @param scene The scene the camera belongs to
  27737. * @param webVROptions a set of customizable options for the webVRCamera
  27738. */
  27739. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  27740. /**
  27741. * Gets the device distance from the ground in meters.
  27742. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  27743. */
  27744. deviceDistanceToRoomGround(): number;
  27745. /**
  27746. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27747. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  27748. */
  27749. useStandingMatrix(callback?: (bool: boolean) => void): void;
  27750. /**
  27751. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27752. * @returns A promise with a boolean set to if the standing matrix is supported.
  27753. */
  27754. useStandingMatrixAsync(): Promise<boolean>;
  27755. /**
  27756. * Disposes the camera
  27757. */
  27758. dispose(): void;
  27759. /**
  27760. * Gets a vrController by name.
  27761. * @param name The name of the controller to retreive
  27762. * @returns the controller matching the name specified or null if not found
  27763. */
  27764. getControllerByName(name: string): Nullable<WebVRController>;
  27765. private _leftController;
  27766. /**
  27767. * The controller corresponding to the users left hand.
  27768. */
  27769. get leftController(): Nullable<WebVRController>;
  27770. private _rightController;
  27771. /**
  27772. * The controller corresponding to the users right hand.
  27773. */
  27774. get rightController(): Nullable<WebVRController>;
  27775. /**
  27776. * Casts a ray forward from the vrCamera's gaze.
  27777. * @param length Length of the ray (default: 100)
  27778. * @returns the ray corresponding to the gaze
  27779. */
  27780. getForwardRay(length?: number): Ray;
  27781. /**
  27782. * @hidden
  27783. * Updates the camera based on device's frame data
  27784. */
  27785. _checkInputs(): void;
  27786. /**
  27787. * Updates the poseControlled values based on the input device pose.
  27788. * @param poseData Pose coming from the device
  27789. */
  27790. updateFromDevice(poseData: DevicePose): void;
  27791. private _detachIfAttached;
  27792. /**
  27793. * WebVR's attach control will start broadcasting frames to the device.
  27794. * Note that in certain browsers (chrome for example) this function must be called
  27795. * within a user-interaction callback. Example:
  27796. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  27797. *
  27798. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  27799. */
  27800. attachControl(noPreventDefault?: boolean): void;
  27801. /**
  27802. * Detach the current controls from the specified dom element.
  27803. */
  27804. detachControl(): void;
  27805. /**
  27806. * @returns the name of this class
  27807. */
  27808. getClassName(): string;
  27809. /**
  27810. * Calls resetPose on the vrDisplay
  27811. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  27812. */
  27813. resetToCurrentRotation(): void;
  27814. /**
  27815. * @hidden
  27816. * Updates the rig cameras (left and right eye)
  27817. */
  27818. _updateRigCameras(): void;
  27819. private _workingVector;
  27820. private _oneVector;
  27821. private _workingMatrix;
  27822. private updateCacheCalled;
  27823. private _correctPositionIfNotTrackPosition;
  27824. /**
  27825. * @hidden
  27826. * Updates the cached values of the camera
  27827. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  27828. */
  27829. _updateCache(ignoreParentClass?: boolean): void;
  27830. /**
  27831. * @hidden
  27832. * Get current device position in babylon world
  27833. */
  27834. _computeDevicePosition(): void;
  27835. /**
  27836. * Updates the current device position and rotation in the babylon world
  27837. */
  27838. update(): void;
  27839. /**
  27840. * @hidden
  27841. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  27842. * @returns an identity matrix
  27843. */
  27844. _getViewMatrix(): Matrix;
  27845. private _tmpMatrix;
  27846. /**
  27847. * This function is called by the two RIG cameras.
  27848. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  27849. * @hidden
  27850. */
  27851. _getWebVRViewMatrix(): Matrix;
  27852. /** @hidden */
  27853. _getWebVRProjectionMatrix(): Matrix;
  27854. private _onGamepadConnectedObserver;
  27855. private _onGamepadDisconnectedObserver;
  27856. private _updateCacheWhenTrackingDisabledObserver;
  27857. /**
  27858. * Initializes the controllers and their meshes
  27859. */
  27860. initControllers(): void;
  27861. }
  27862. }
  27863. declare module BABYLON {
  27864. /**
  27865. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  27866. *
  27867. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  27868. *
  27869. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  27870. */
  27871. export class MaterialHelper {
  27872. /**
  27873. * Bind the current view position to an effect.
  27874. * @param effect The effect to be bound
  27875. * @param scene The scene the eyes position is used from
  27876. * @param variableName name of the shader variable that will hold the eye position
  27877. * @param isVector3 true to indicates that variableName is a Vector3 and not a Vector4
  27878. * @return the computed eye position
  27879. */
  27880. static BindEyePosition(effect: Nullable<Effect>, scene: Scene, variableName?: string, isVector3?: boolean): Vector4;
  27881. /**
  27882. * Helps preparing the defines values about the UVs in used in the effect.
  27883. * UVs are shared as much as we can accross channels in the shaders.
  27884. * @param texture The texture we are preparing the UVs for
  27885. * @param defines The defines to update
  27886. * @param key The channel key "diffuse", "specular"... used in the shader
  27887. */
  27888. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  27889. /**
  27890. * Binds a texture matrix value to its corrsponding uniform
  27891. * @param texture The texture to bind the matrix for
  27892. * @param uniformBuffer The uniform buffer receivin the data
  27893. * @param key The channel key "diffuse", "specular"... used in the shader
  27894. */
  27895. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  27896. /**
  27897. * Gets the current status of the fog (should it be enabled?)
  27898. * @param mesh defines the mesh to evaluate for fog support
  27899. * @param scene defines the hosting scene
  27900. * @returns true if fog must be enabled
  27901. */
  27902. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  27903. /**
  27904. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  27905. * @param mesh defines the current mesh
  27906. * @param scene defines the current scene
  27907. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  27908. * @param pointsCloud defines if point cloud rendering has to be turned on
  27909. * @param fogEnabled defines if fog has to be turned on
  27910. * @param alphaTest defines if alpha testing has to be turned on
  27911. * @param defines defines the current list of defines
  27912. */
  27913. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  27914. /**
  27915. * Helper used to prepare the list of defines associated with frame values for shader compilation
  27916. * @param scene defines the current scene
  27917. * @param engine defines the current engine
  27918. * @param defines specifies the list of active defines
  27919. * @param useInstances defines if instances have to be turned on
  27920. * @param useClipPlane defines if clip plane have to be turned on
  27921. * @param useInstances defines if instances have to be turned on
  27922. * @param useThinInstances defines if thin instances have to be turned on
  27923. */
  27924. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  27925. /**
  27926. * Prepares the defines for bones
  27927. * @param mesh The mesh containing the geometry data we will draw
  27928. * @param defines The defines to update
  27929. */
  27930. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  27931. /**
  27932. * Prepares the defines for morph targets
  27933. * @param mesh The mesh containing the geometry data we will draw
  27934. * @param defines The defines to update
  27935. */
  27936. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  27937. /**
  27938. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  27939. * @param mesh The mesh containing the geometry data we will draw
  27940. * @param defines The defines to update
  27941. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  27942. * @param useBones Precise whether bones should be used or not (override mesh info)
  27943. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  27944. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  27945. * @returns false if defines are considered not dirty and have not been checked
  27946. */
  27947. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  27948. /**
  27949. * Prepares the defines related to multiview
  27950. * @param scene The scene we are intending to draw
  27951. * @param defines The defines to update
  27952. */
  27953. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  27954. /**
  27955. * Prepares the defines related to the prepass
  27956. * @param scene The scene we are intending to draw
  27957. * @param defines The defines to update
  27958. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  27959. */
  27960. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  27961. /**
  27962. * Prepares the defines related to the light information passed in parameter
  27963. * @param scene The scene we are intending to draw
  27964. * @param mesh The mesh the effect is compiling for
  27965. * @param light The light the effect is compiling for
  27966. * @param lightIndex The index of the light
  27967. * @param defines The defines to update
  27968. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  27969. * @param state Defines the current state regarding what is needed (normals, etc...)
  27970. */
  27971. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  27972. needNormals: boolean;
  27973. needRebuild: boolean;
  27974. shadowEnabled: boolean;
  27975. specularEnabled: boolean;
  27976. lightmapMode: boolean;
  27977. }): void;
  27978. /**
  27979. * Prepares the defines related to the light information passed in parameter
  27980. * @param scene The scene we are intending to draw
  27981. * @param mesh The mesh the effect is compiling for
  27982. * @param defines The defines to update
  27983. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  27984. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  27985. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  27986. * @returns true if normals will be required for the rest of the effect
  27987. */
  27988. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  27989. /**
  27990. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  27991. * @param lightIndex defines the light index
  27992. * @param uniformsList The uniform list
  27993. * @param samplersList The sampler list
  27994. * @param projectedLightTexture defines if projected texture must be used
  27995. * @param uniformBuffersList defines an optional list of uniform buffers
  27996. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  27997. */
  27998. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  27999. /**
  28000. * Prepares the uniforms and samplers list to be used in the effect
  28001. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  28002. * @param samplersList The sampler list
  28003. * @param defines The defines helping in the list generation
  28004. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  28005. */
  28006. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  28007. /**
  28008. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  28009. * @param defines The defines to update while falling back
  28010. * @param fallbacks The authorized effect fallbacks
  28011. * @param maxSimultaneousLights The maximum number of lights allowed
  28012. * @param rank the current rank of the Effect
  28013. * @returns The newly affected rank
  28014. */
  28015. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  28016. private static _TmpMorphInfluencers;
  28017. /**
  28018. * Prepares the list of attributes required for morph targets according to the effect defines.
  28019. * @param attribs The current list of supported attribs
  28020. * @param mesh The mesh to prepare the morph targets attributes for
  28021. * @param influencers The number of influencers
  28022. */
  28023. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  28024. /**
  28025. * Prepares the list of attributes required for morph targets according to the effect defines.
  28026. * @param attribs The current list of supported attribs
  28027. * @param mesh The mesh to prepare the morph targets attributes for
  28028. * @param defines The current Defines of the effect
  28029. */
  28030. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  28031. /**
  28032. * Prepares the list of attributes required for bones according to the effect defines.
  28033. * @param attribs The current list of supported attribs
  28034. * @param mesh The mesh to prepare the bones attributes for
  28035. * @param defines The current Defines of the effect
  28036. * @param fallbacks The current efffect fallback strategy
  28037. */
  28038. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  28039. /**
  28040. * Check and prepare the list of attributes required for instances according to the effect defines.
  28041. * @param attribs The current list of supported attribs
  28042. * @param defines The current MaterialDefines of the effect
  28043. */
  28044. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  28045. /**
  28046. * Add the list of attributes required for instances to the attribs array.
  28047. * @param attribs The current list of supported attribs
  28048. */
  28049. static PushAttributesForInstances(attribs: string[]): void;
  28050. /**
  28051. * Binds the light information to the effect.
  28052. * @param light The light containing the generator
  28053. * @param effect The effect we are binding the data to
  28054. * @param lightIndex The light index in the effect used to render
  28055. */
  28056. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  28057. /**
  28058. * Binds the lights information from the scene to the effect for the given mesh.
  28059. * @param light Light to bind
  28060. * @param lightIndex Light index
  28061. * @param scene The scene where the light belongs to
  28062. * @param effect The effect we are binding the data to
  28063. * @param useSpecular Defines if specular is supported
  28064. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28065. */
  28066. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  28067. /**
  28068. * Binds the lights information from the scene to the effect for the given mesh.
  28069. * @param scene The scene the lights belongs to
  28070. * @param mesh The mesh we are binding the information to render
  28071. * @param effect The effect we are binding the data to
  28072. * @param defines The generated defines for the effect
  28073. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  28074. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28075. */
  28076. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  28077. private static _tempFogColor;
  28078. /**
  28079. * Binds the fog information from the scene to the effect for the given mesh.
  28080. * @param scene The scene the lights belongs to
  28081. * @param mesh The mesh we are binding the information to render
  28082. * @param effect The effect we are binding the data to
  28083. * @param linearSpace Defines if the fog effect is applied in linear space
  28084. */
  28085. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  28086. /**
  28087. * Binds the bones information from the mesh to the effect.
  28088. * @param mesh The mesh we are binding the information to render
  28089. * @param effect The effect we are binding the data to
  28090. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  28091. */
  28092. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  28093. private static _CopyBonesTransformationMatrices;
  28094. /**
  28095. * Binds the morph targets information from the mesh to the effect.
  28096. * @param abstractMesh The mesh we are binding the information to render
  28097. * @param effect The effect we are binding the data to
  28098. */
  28099. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  28100. /**
  28101. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  28102. * @param defines The generated defines used in the effect
  28103. * @param effect The effect we are binding the data to
  28104. * @param scene The scene we are willing to render with logarithmic scale for
  28105. */
  28106. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  28107. /**
  28108. * Binds the clip plane information from the scene to the effect.
  28109. * @param scene The scene the clip plane information are extracted from
  28110. * @param effect The effect we are binding the data to
  28111. */
  28112. static BindClipPlane(effect: Effect, scene: Scene): void;
  28113. }
  28114. }
  28115. declare module BABYLON {
  28116. /** @hidden */
  28117. export var bayerDitherFunctions: {
  28118. name: string;
  28119. shader: string;
  28120. };
  28121. }
  28122. declare module BABYLON {
  28123. /** @hidden */
  28124. export var shadowMapFragmentDeclaration: {
  28125. name: string;
  28126. shader: string;
  28127. };
  28128. }
  28129. declare module BABYLON {
  28130. /** @hidden */
  28131. export var shadowMapFragment: {
  28132. name: string;
  28133. shader: string;
  28134. };
  28135. }
  28136. declare module BABYLON {
  28137. /** @hidden */
  28138. export var shadowMapPixelShader: {
  28139. name: string;
  28140. shader: string;
  28141. };
  28142. }
  28143. declare module BABYLON {
  28144. /** @hidden */
  28145. export var shadowMapVertexDeclaration: {
  28146. name: string;
  28147. shader: string;
  28148. };
  28149. }
  28150. declare module BABYLON {
  28151. /** @hidden */
  28152. export var shadowMapVertexNormalBias: {
  28153. name: string;
  28154. shader: string;
  28155. };
  28156. }
  28157. declare module BABYLON {
  28158. /** @hidden */
  28159. export var shadowMapVertexMetric: {
  28160. name: string;
  28161. shader: string;
  28162. };
  28163. }
  28164. declare module BABYLON {
  28165. /** @hidden */
  28166. export var shadowMapVertexShader: {
  28167. name: string;
  28168. shader: string;
  28169. };
  28170. }
  28171. declare module BABYLON {
  28172. /** @hidden */
  28173. export var depthBoxBlurPixelShader: {
  28174. name: string;
  28175. shader: string;
  28176. };
  28177. }
  28178. declare module BABYLON {
  28179. /** @hidden */
  28180. export var shadowMapFragmentSoftTransparentShadow: {
  28181. name: string;
  28182. shader: string;
  28183. };
  28184. }
  28185. declare module BABYLON {
  28186. /**
  28187. * Creates an instance based on a source mesh.
  28188. */
  28189. export class InstancedMesh extends AbstractMesh {
  28190. private _sourceMesh;
  28191. private _currentLOD;
  28192. /** @hidden */
  28193. _indexInSourceMeshInstanceArray: number;
  28194. constructor(name: string, source: Mesh);
  28195. /**
  28196. * Returns the string "InstancedMesh".
  28197. */
  28198. getClassName(): string;
  28199. /** Gets the list of lights affecting that mesh */
  28200. get lightSources(): Light[];
  28201. _resyncLightSources(): void;
  28202. _resyncLightSource(light: Light): void;
  28203. _removeLightSource(light: Light, dispose: boolean): void;
  28204. /**
  28205. * If the source mesh receives shadows
  28206. */
  28207. get receiveShadows(): boolean;
  28208. /**
  28209. * The material of the source mesh
  28210. */
  28211. get material(): Nullable<Material>;
  28212. /**
  28213. * Visibility of the source mesh
  28214. */
  28215. get visibility(): number;
  28216. /**
  28217. * Skeleton of the source mesh
  28218. */
  28219. get skeleton(): Nullable<Skeleton>;
  28220. /**
  28221. * Rendering ground id of the source mesh
  28222. */
  28223. get renderingGroupId(): number;
  28224. set renderingGroupId(value: number);
  28225. /**
  28226. * Returns the total number of vertices (integer).
  28227. */
  28228. getTotalVertices(): number;
  28229. /**
  28230. * Returns a positive integer : the total number of indices in this mesh geometry.
  28231. * @returns the numner of indices or zero if the mesh has no geometry.
  28232. */
  28233. getTotalIndices(): number;
  28234. /**
  28235. * The source mesh of the instance
  28236. */
  28237. get sourceMesh(): Mesh;
  28238. /**
  28239. * Creates a new InstancedMesh object from the mesh model.
  28240. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28241. * @param name defines the name of the new instance
  28242. * @returns a new InstancedMesh
  28243. */
  28244. createInstance(name: string): InstancedMesh;
  28245. /**
  28246. * Is this node ready to be used/rendered
  28247. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28248. * @return {boolean} is it ready
  28249. */
  28250. isReady(completeCheck?: boolean): boolean;
  28251. /**
  28252. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28253. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  28254. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  28255. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  28256. */
  28257. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  28258. /**
  28259. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28260. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28261. * The `data` are either a numeric array either a Float32Array.
  28262. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  28263. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  28264. * Note that a new underlying VertexBuffer object is created each call.
  28265. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28266. *
  28267. * Possible `kind` values :
  28268. * - VertexBuffer.PositionKind
  28269. * - VertexBuffer.UVKind
  28270. * - VertexBuffer.UV2Kind
  28271. * - VertexBuffer.UV3Kind
  28272. * - VertexBuffer.UV4Kind
  28273. * - VertexBuffer.UV5Kind
  28274. * - VertexBuffer.UV6Kind
  28275. * - VertexBuffer.ColorKind
  28276. * - VertexBuffer.MatricesIndicesKind
  28277. * - VertexBuffer.MatricesIndicesExtraKind
  28278. * - VertexBuffer.MatricesWeightsKind
  28279. * - VertexBuffer.MatricesWeightsExtraKind
  28280. *
  28281. * Returns the Mesh.
  28282. */
  28283. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28284. /**
  28285. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28286. * If the mesh has no geometry, it is simply returned as it is.
  28287. * The `data` are either a numeric array either a Float32Array.
  28288. * No new underlying VertexBuffer object is created.
  28289. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28290. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  28291. *
  28292. * Possible `kind` values :
  28293. * - VertexBuffer.PositionKind
  28294. * - VertexBuffer.UVKind
  28295. * - VertexBuffer.UV2Kind
  28296. * - VertexBuffer.UV3Kind
  28297. * - VertexBuffer.UV4Kind
  28298. * - VertexBuffer.UV5Kind
  28299. * - VertexBuffer.UV6Kind
  28300. * - VertexBuffer.ColorKind
  28301. * - VertexBuffer.MatricesIndicesKind
  28302. * - VertexBuffer.MatricesIndicesExtraKind
  28303. * - VertexBuffer.MatricesWeightsKind
  28304. * - VertexBuffer.MatricesWeightsExtraKind
  28305. *
  28306. * Returns the Mesh.
  28307. */
  28308. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  28309. /**
  28310. * Sets the mesh indices.
  28311. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  28312. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28313. * This method creates a new index buffer each call.
  28314. * Returns the Mesh.
  28315. */
  28316. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  28317. /**
  28318. * Boolean : True if the mesh owns the requested kind of data.
  28319. */
  28320. isVerticesDataPresent(kind: string): boolean;
  28321. /**
  28322. * Returns an array of indices (IndicesArray).
  28323. */
  28324. getIndices(): Nullable<IndicesArray>;
  28325. get _positions(): Nullable<Vector3[]>;
  28326. /**
  28327. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28328. * This means the mesh underlying bounding box and sphere are recomputed.
  28329. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28330. * @returns the current mesh
  28331. */
  28332. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  28333. /** @hidden */
  28334. _preActivate(): InstancedMesh;
  28335. /** @hidden */
  28336. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28337. /** @hidden */
  28338. _postActivate(): void;
  28339. getWorldMatrix(): Matrix;
  28340. get isAnInstance(): boolean;
  28341. /**
  28342. * Returns the current associated LOD AbstractMesh.
  28343. */
  28344. getLOD(camera: Camera): AbstractMesh;
  28345. /** @hidden */
  28346. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28347. /** @hidden */
  28348. _syncSubMeshes(): InstancedMesh;
  28349. /** @hidden */
  28350. _generatePointsArray(): boolean;
  28351. /** @hidden */
  28352. _updateBoundingInfo(): AbstractMesh;
  28353. /**
  28354. * Creates a new InstancedMesh from the current mesh.
  28355. * - name (string) : the cloned mesh name
  28356. * - newParent (optional Node) : the optional Node to parent the clone to.
  28357. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  28358. *
  28359. * Returns the clone.
  28360. */
  28361. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  28362. /**
  28363. * Disposes the InstancedMesh.
  28364. * Returns nothing.
  28365. */
  28366. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28367. }
  28368. interface Mesh {
  28369. /**
  28370. * Register a custom buffer that will be instanced
  28371. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28372. * @param kind defines the buffer kind
  28373. * @param stride defines the stride in floats
  28374. */
  28375. registerInstancedBuffer(kind: string, stride: number): void;
  28376. /**
  28377. * true to use the edge renderer for all instances of this mesh
  28378. */
  28379. edgesShareWithInstances: boolean;
  28380. /** @hidden */
  28381. _userInstancedBuffersStorage: {
  28382. data: {
  28383. [key: string]: Float32Array;
  28384. };
  28385. sizes: {
  28386. [key: string]: number;
  28387. };
  28388. vertexBuffers: {
  28389. [key: string]: Nullable<VertexBuffer>;
  28390. };
  28391. strides: {
  28392. [key: string]: number;
  28393. };
  28394. };
  28395. }
  28396. interface AbstractMesh {
  28397. /**
  28398. * Object used to store instanced buffers defined by user
  28399. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28400. */
  28401. instancedBuffers: {
  28402. [key: string]: any;
  28403. };
  28404. }
  28405. }
  28406. declare module BABYLON {
  28407. /**
  28408. * Defines the options associated with the creation of a shader material.
  28409. */
  28410. export interface IShaderMaterialOptions {
  28411. /**
  28412. * Does the material work in alpha blend mode
  28413. */
  28414. needAlphaBlending: boolean;
  28415. /**
  28416. * Does the material work in alpha test mode
  28417. */
  28418. needAlphaTesting: boolean;
  28419. /**
  28420. * The list of attribute names used in the shader
  28421. */
  28422. attributes: string[];
  28423. /**
  28424. * The list of unifrom names used in the shader
  28425. */
  28426. uniforms: string[];
  28427. /**
  28428. * The list of UBO names used in the shader
  28429. */
  28430. uniformBuffers: string[];
  28431. /**
  28432. * The list of sampler names used in the shader
  28433. */
  28434. samplers: string[];
  28435. /**
  28436. * The list of defines used in the shader
  28437. */
  28438. defines: string[];
  28439. }
  28440. /**
  28441. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  28442. *
  28443. * This returned material effects how the mesh will look based on the code in the shaders.
  28444. *
  28445. * @see https://doc.babylonjs.com/how_to/shader_material
  28446. */
  28447. export class ShaderMaterial extends Material {
  28448. private _shaderPath;
  28449. private _options;
  28450. private _textures;
  28451. private _textureArrays;
  28452. private _floats;
  28453. private _ints;
  28454. private _floatsArrays;
  28455. private _colors3;
  28456. private _colors3Arrays;
  28457. private _colors4;
  28458. private _colors4Arrays;
  28459. private _vectors2;
  28460. private _vectors3;
  28461. private _vectors4;
  28462. private _matrices;
  28463. private _matrixArrays;
  28464. private _matrices3x3;
  28465. private _matrices2x2;
  28466. private _vectors2Arrays;
  28467. private _vectors3Arrays;
  28468. private _vectors4Arrays;
  28469. private _cachedWorldViewMatrix;
  28470. private _cachedWorldViewProjectionMatrix;
  28471. private _renderId;
  28472. private _multiview;
  28473. private _cachedDefines;
  28474. /** Define the Url to load snippets */
  28475. static SnippetUrl: string;
  28476. /** Snippet ID if the material was created from the snippet server */
  28477. snippetId: string;
  28478. /**
  28479. * Instantiate a new shader material.
  28480. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  28481. * This returned material effects how the mesh will look based on the code in the shaders.
  28482. * @see https://doc.babylonjs.com/how_to/shader_material
  28483. * @param name Define the name of the material in the scene
  28484. * @param scene Define the scene the material belongs to
  28485. * @param shaderPath Defines the route to the shader code in one of three ways:
  28486. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  28487. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  28488. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  28489. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  28490. * @param options Define the options used to create the shader
  28491. */
  28492. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  28493. /**
  28494. * Gets the shader path used to define the shader code
  28495. * It can be modified to trigger a new compilation
  28496. */
  28497. get shaderPath(): any;
  28498. /**
  28499. * Sets the shader path used to define the shader code
  28500. * It can be modified to trigger a new compilation
  28501. */
  28502. set shaderPath(shaderPath: any);
  28503. /**
  28504. * Gets the options used to compile the shader.
  28505. * They can be modified to trigger a new compilation
  28506. */
  28507. get options(): IShaderMaterialOptions;
  28508. /**
  28509. * Gets the current class name of the material e.g. "ShaderMaterial"
  28510. * Mainly use in serialization.
  28511. * @returns the class name
  28512. */
  28513. getClassName(): string;
  28514. /**
  28515. * Specifies if the material will require alpha blending
  28516. * @returns a boolean specifying if alpha blending is needed
  28517. */
  28518. needAlphaBlending(): boolean;
  28519. /**
  28520. * Specifies if this material should be rendered in alpha test mode
  28521. * @returns a boolean specifying if an alpha test is needed.
  28522. */
  28523. needAlphaTesting(): boolean;
  28524. private _checkUniform;
  28525. /**
  28526. * Set a texture in the shader.
  28527. * @param name Define the name of the uniform samplers as defined in the shader
  28528. * @param texture Define the texture to bind to this sampler
  28529. * @return the material itself allowing "fluent" like uniform updates
  28530. */
  28531. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  28532. /**
  28533. * Set a texture array in the shader.
  28534. * @param name Define the name of the uniform sampler array as defined in the shader
  28535. * @param textures Define the list of textures to bind to this sampler
  28536. * @return the material itself allowing "fluent" like uniform updates
  28537. */
  28538. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  28539. /**
  28540. * Set a float in the shader.
  28541. * @param name Define the name of the uniform as defined in the shader
  28542. * @param value Define the value to give to the uniform
  28543. * @return the material itself allowing "fluent" like uniform updates
  28544. */
  28545. setFloat(name: string, value: number): ShaderMaterial;
  28546. /**
  28547. * Set a int in the shader.
  28548. * @param name Define the name of the uniform as defined in the shader
  28549. * @param value Define the value to give to the uniform
  28550. * @return the material itself allowing "fluent" like uniform updates
  28551. */
  28552. setInt(name: string, value: number): ShaderMaterial;
  28553. /**
  28554. * Set an array of floats in the shader.
  28555. * @param name Define the name of the uniform as defined in the shader
  28556. * @param value Define the value to give to the uniform
  28557. * @return the material itself allowing "fluent" like uniform updates
  28558. */
  28559. setFloats(name: string, value: number[]): ShaderMaterial;
  28560. /**
  28561. * Set a vec3 in the shader from a Color3.
  28562. * @param name Define the name of the uniform as defined in the shader
  28563. * @param value Define the value to give to the uniform
  28564. * @return the material itself allowing "fluent" like uniform updates
  28565. */
  28566. setColor3(name: string, value: Color3): ShaderMaterial;
  28567. /**
  28568. * Set a vec3 array in the shader from a Color3 array.
  28569. * @param name Define the name of the uniform as defined in the shader
  28570. * @param value Define the value to give to the uniform
  28571. * @return the material itself allowing "fluent" like uniform updates
  28572. */
  28573. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  28574. /**
  28575. * Set a vec4 in the shader from a Color4.
  28576. * @param name Define the name of the uniform as defined in the shader
  28577. * @param value Define the value to give to the uniform
  28578. * @return the material itself allowing "fluent" like uniform updates
  28579. */
  28580. setColor4(name: string, value: Color4): ShaderMaterial;
  28581. /**
  28582. * Set a vec4 array in the shader from a Color4 array.
  28583. * @param name Define the name of the uniform as defined in the shader
  28584. * @param value Define the value to give to the uniform
  28585. * @return the material itself allowing "fluent" like uniform updates
  28586. */
  28587. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  28588. /**
  28589. * Set a vec2 in the shader from a Vector2.
  28590. * @param name Define the name of the uniform as defined in the shader
  28591. * @param value Define the value to give to the uniform
  28592. * @return the material itself allowing "fluent" like uniform updates
  28593. */
  28594. setVector2(name: string, value: Vector2): ShaderMaterial;
  28595. /**
  28596. * Set a vec3 in the shader from a Vector3.
  28597. * @param name Define the name of the uniform as defined in the shader
  28598. * @param value Define the value to give to the uniform
  28599. * @return the material itself allowing "fluent" like uniform updates
  28600. */
  28601. setVector3(name: string, value: Vector3): ShaderMaterial;
  28602. /**
  28603. * Set a vec4 in the shader from a Vector4.
  28604. * @param name Define the name of the uniform as defined in the shader
  28605. * @param value Define the value to give to the uniform
  28606. * @return the material itself allowing "fluent" like uniform updates
  28607. */
  28608. setVector4(name: string, value: Vector4): ShaderMaterial;
  28609. /**
  28610. * Set a mat4 in the shader from a Matrix.
  28611. * @param name Define the name of the uniform as defined in the shader
  28612. * @param value Define the value to give to the uniform
  28613. * @return the material itself allowing "fluent" like uniform updates
  28614. */
  28615. setMatrix(name: string, value: Matrix): ShaderMaterial;
  28616. /**
  28617. * Set a float32Array in the shader from a matrix array.
  28618. * @param name Define the name of the uniform as defined in the shader
  28619. * @param value Define the value to give to the uniform
  28620. * @return the material itself allowing "fluent" like uniform updates
  28621. */
  28622. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  28623. /**
  28624. * Set a mat3 in the shader from a Float32Array.
  28625. * @param name Define the name of the uniform as defined in the shader
  28626. * @param value Define the value to give to the uniform
  28627. * @return the material itself allowing "fluent" like uniform updates
  28628. */
  28629. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28630. /**
  28631. * Set a mat2 in the shader from a Float32Array.
  28632. * @param name Define the name of the uniform as defined in the shader
  28633. * @param value Define the value to give to the uniform
  28634. * @return the material itself allowing "fluent" like uniform updates
  28635. */
  28636. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28637. /**
  28638. * Set a vec2 array in the shader from a number array.
  28639. * @param name Define the name of the uniform as defined in the shader
  28640. * @param value Define the value to give to the uniform
  28641. * @return the material itself allowing "fluent" like uniform updates
  28642. */
  28643. setArray2(name: string, value: number[]): ShaderMaterial;
  28644. /**
  28645. * Set a vec3 array in the shader from a number array.
  28646. * @param name Define the name of the uniform as defined in the shader
  28647. * @param value Define the value to give to the uniform
  28648. * @return the material itself allowing "fluent" like uniform updates
  28649. */
  28650. setArray3(name: string, value: number[]): ShaderMaterial;
  28651. /**
  28652. * Set a vec4 array in the shader from a number array.
  28653. * @param name Define the name of the uniform as defined in the shader
  28654. * @param value Define the value to give to the uniform
  28655. * @return the material itself allowing "fluent" like uniform updates
  28656. */
  28657. setArray4(name: string, value: number[]): ShaderMaterial;
  28658. private _checkCache;
  28659. /**
  28660. * Specifies that the submesh is ready to be used
  28661. * @param mesh defines the mesh to check
  28662. * @param subMesh defines which submesh to check
  28663. * @param useInstances specifies that instances should be used
  28664. * @returns a boolean indicating that the submesh is ready or not
  28665. */
  28666. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  28667. /**
  28668. * Checks if the material is ready to render the requested mesh
  28669. * @param mesh Define the mesh to render
  28670. * @param useInstances Define whether or not the material is used with instances
  28671. * @returns true if ready, otherwise false
  28672. */
  28673. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  28674. /**
  28675. * Binds the world matrix to the material
  28676. * @param world defines the world transformation matrix
  28677. * @param effectOverride - If provided, use this effect instead of internal effect
  28678. */
  28679. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  28680. /**
  28681. * Binds the submesh to this material by preparing the effect and shader to draw
  28682. * @param world defines the world transformation matrix
  28683. * @param mesh defines the mesh containing the submesh
  28684. * @param subMesh defines the submesh to bind the material to
  28685. */
  28686. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  28687. /**
  28688. * Binds the material to the mesh
  28689. * @param world defines the world transformation matrix
  28690. * @param mesh defines the mesh to bind the material to
  28691. * @param effectOverride - If provided, use this effect instead of internal effect
  28692. */
  28693. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  28694. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  28695. /**
  28696. * Gets the active textures from the material
  28697. * @returns an array of textures
  28698. */
  28699. getActiveTextures(): BaseTexture[];
  28700. /**
  28701. * Specifies if the material uses a texture
  28702. * @param texture defines the texture to check against the material
  28703. * @returns a boolean specifying if the material uses the texture
  28704. */
  28705. hasTexture(texture: BaseTexture): boolean;
  28706. /**
  28707. * Makes a duplicate of the material, and gives it a new name
  28708. * @param name defines the new name for the duplicated material
  28709. * @returns the cloned material
  28710. */
  28711. clone(name: string): ShaderMaterial;
  28712. /**
  28713. * Disposes the material
  28714. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  28715. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  28716. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  28717. */
  28718. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  28719. /**
  28720. * Serializes this material in a JSON representation
  28721. * @returns the serialized material object
  28722. */
  28723. serialize(): any;
  28724. /**
  28725. * Creates a shader material from parsed shader material data
  28726. * @param source defines the JSON represnetation of the material
  28727. * @param scene defines the hosting scene
  28728. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28729. * @returns a new material
  28730. */
  28731. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  28732. /**
  28733. * Creates a new ShaderMaterial from a snippet saved in a remote file
  28734. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  28735. * @param url defines the url to load from
  28736. * @param scene defines the hosting scene
  28737. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28738. * @returns a promise that will resolve to the new ShaderMaterial
  28739. */
  28740. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28741. /**
  28742. * Creates a ShaderMaterial from a snippet saved by the Inspector
  28743. * @param snippetId defines the snippet to load
  28744. * @param scene defines the hosting scene
  28745. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28746. * @returns a promise that will resolve to the new ShaderMaterial
  28747. */
  28748. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28749. }
  28750. }
  28751. declare module BABYLON {
  28752. /** @hidden */
  28753. export var colorPixelShader: {
  28754. name: string;
  28755. shader: string;
  28756. };
  28757. }
  28758. declare module BABYLON {
  28759. /** @hidden */
  28760. export var colorVertexShader: {
  28761. name: string;
  28762. shader: string;
  28763. };
  28764. }
  28765. declare module BABYLON {
  28766. /**
  28767. * Line mesh
  28768. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  28769. */
  28770. export class LinesMesh extends Mesh {
  28771. /**
  28772. * If vertex color should be applied to the mesh
  28773. */
  28774. readonly useVertexColor?: boolean | undefined;
  28775. /**
  28776. * If vertex alpha should be applied to the mesh
  28777. */
  28778. readonly useVertexAlpha?: boolean | undefined;
  28779. /**
  28780. * Color of the line (Default: White)
  28781. */
  28782. color: Color3;
  28783. /**
  28784. * Alpha of the line (Default: 1)
  28785. */
  28786. alpha: number;
  28787. /**
  28788. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28789. * This margin is expressed in world space coordinates, so its value may vary.
  28790. * Default value is 0.1
  28791. */
  28792. intersectionThreshold: number;
  28793. private _colorShader;
  28794. private color4;
  28795. /**
  28796. * Creates a new LinesMesh
  28797. * @param name defines the name
  28798. * @param scene defines the hosting scene
  28799. * @param parent defines the parent mesh if any
  28800. * @param source defines the optional source LinesMesh used to clone data from
  28801. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28802. * When false, achieved by calling a clone(), also passing False.
  28803. * This will make creation of children, recursive.
  28804. * @param useVertexColor defines if this LinesMesh supports vertex color
  28805. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  28806. */
  28807. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  28808. /**
  28809. * If vertex color should be applied to the mesh
  28810. */
  28811. useVertexColor?: boolean | undefined,
  28812. /**
  28813. * If vertex alpha should be applied to the mesh
  28814. */
  28815. useVertexAlpha?: boolean | undefined);
  28816. private _addClipPlaneDefine;
  28817. private _removeClipPlaneDefine;
  28818. isReady(): boolean;
  28819. /**
  28820. * Returns the string "LineMesh"
  28821. */
  28822. getClassName(): string;
  28823. /**
  28824. * @hidden
  28825. */
  28826. get material(): Material;
  28827. /**
  28828. * @hidden
  28829. */
  28830. set material(value: Material);
  28831. /**
  28832. * @hidden
  28833. */
  28834. get checkCollisions(): boolean;
  28835. set checkCollisions(value: boolean);
  28836. /** @hidden */
  28837. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28838. /** @hidden */
  28839. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28840. /**
  28841. * Disposes of the line mesh
  28842. * @param doNotRecurse If children should be disposed
  28843. */
  28844. dispose(doNotRecurse?: boolean): void;
  28845. /**
  28846. * Returns a new LineMesh object cloned from the current one.
  28847. */
  28848. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  28849. /**
  28850. * Creates a new InstancedLinesMesh object from the mesh model.
  28851. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28852. * @param name defines the name of the new instance
  28853. * @returns a new InstancedLinesMesh
  28854. */
  28855. createInstance(name: string): InstancedLinesMesh;
  28856. }
  28857. /**
  28858. * Creates an instance based on a source LinesMesh
  28859. */
  28860. export class InstancedLinesMesh extends InstancedMesh {
  28861. /**
  28862. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28863. * This margin is expressed in world space coordinates, so its value may vary.
  28864. * Initilized with the intersectionThreshold value of the source LinesMesh
  28865. */
  28866. intersectionThreshold: number;
  28867. constructor(name: string, source: LinesMesh);
  28868. /**
  28869. * Returns the string "InstancedLinesMesh".
  28870. */
  28871. getClassName(): string;
  28872. }
  28873. }
  28874. declare module BABYLON {
  28875. /** @hidden */
  28876. export var linePixelShader: {
  28877. name: string;
  28878. shader: string;
  28879. };
  28880. }
  28881. declare module BABYLON {
  28882. /** @hidden */
  28883. export var lineVertexShader: {
  28884. name: string;
  28885. shader: string;
  28886. };
  28887. }
  28888. declare module BABYLON {
  28889. interface Scene {
  28890. /** @hidden */
  28891. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  28892. }
  28893. interface AbstractMesh {
  28894. /**
  28895. * Gets the edgesRenderer associated with the mesh
  28896. */
  28897. edgesRenderer: Nullable<EdgesRenderer>;
  28898. }
  28899. interface LinesMesh {
  28900. /**
  28901. * Enables the edge rendering mode on the mesh.
  28902. * This mode makes the mesh edges visible
  28903. * @param epsilon defines the maximal distance between two angles to detect a face
  28904. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28905. * @returns the currentAbstractMesh
  28906. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28907. */
  28908. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28909. }
  28910. interface InstancedLinesMesh {
  28911. /**
  28912. * Enables the edge rendering mode on the mesh.
  28913. * This mode makes the mesh edges visible
  28914. * @param epsilon defines the maximal distance between two angles to detect a face
  28915. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28916. * @returns the current InstancedLinesMesh
  28917. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28918. */
  28919. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  28920. }
  28921. /**
  28922. * Defines the minimum contract an Edges renderer should follow.
  28923. */
  28924. export interface IEdgesRenderer extends IDisposable {
  28925. /**
  28926. * Gets or sets a boolean indicating if the edgesRenderer is active
  28927. */
  28928. isEnabled: boolean;
  28929. /**
  28930. * Renders the edges of the attached mesh,
  28931. */
  28932. render(): void;
  28933. /**
  28934. * Checks wether or not the edges renderer is ready to render.
  28935. * @return true if ready, otherwise false.
  28936. */
  28937. isReady(): boolean;
  28938. /**
  28939. * List of instances to render in case the source mesh has instances
  28940. */
  28941. customInstances: SmartArray<Matrix>;
  28942. }
  28943. /**
  28944. * Defines the additional options of the edges renderer
  28945. */
  28946. export interface IEdgesRendererOptions {
  28947. /**
  28948. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  28949. * If not defined, the default value is true
  28950. */
  28951. useAlternateEdgeFinder?: boolean;
  28952. /**
  28953. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  28954. * If not defined, the default value is true.
  28955. * You should normally leave it undefined (or set it to true), except if you see some artifacts in the edges rendering (can happen with complex geometries)
  28956. * This option is used only if useAlternateEdgeFinder = true
  28957. */
  28958. useFastVertexMerger?: boolean;
  28959. /**
  28960. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  28961. * The default value is 1e-6
  28962. * This option is used only if useAlternateEdgeFinder = true
  28963. */
  28964. epsilonVertexMerge?: number;
  28965. /**
  28966. * Gets or sets a boolean indicating that tessellation should be applied before finding the edges. You may need to activate this option if your geometry is a bit
  28967. * unusual, like having a vertex of a triangle in-between two vertices of an edge of another triangle. It happens often when using CSG to construct meshes.
  28968. * This option is used only if useAlternateEdgeFinder = true
  28969. */
  28970. applyTessellation?: boolean;
  28971. /**
  28972. * The limit under which 3 vertices are considered to be aligned. 3 vertices PQR are considered aligned if distance(PQ) + distance(QR) - distance(PR) < epsilonVertexAligned
  28973. * The default value is 1e-6
  28974. * This option is used only if useAlternateEdgeFinder = true
  28975. */
  28976. epsilonVertexAligned?: number;
  28977. }
  28978. /**
  28979. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  28980. */
  28981. export class EdgesRenderer implements IEdgesRenderer {
  28982. /**
  28983. * Define the size of the edges with an orthographic camera
  28984. */
  28985. edgesWidthScalerForOrthographic: number;
  28986. /**
  28987. * Define the size of the edges with a perspective camera
  28988. */
  28989. edgesWidthScalerForPerspective: number;
  28990. protected _source: AbstractMesh;
  28991. protected _linesPositions: number[];
  28992. protected _linesNormals: number[];
  28993. protected _linesIndices: number[];
  28994. protected _epsilon: number;
  28995. protected _indicesCount: number;
  28996. protected _lineShader: ShaderMaterial;
  28997. protected _ib: DataBuffer;
  28998. protected _buffers: {
  28999. [key: string]: Nullable<VertexBuffer>;
  29000. };
  29001. protected _buffersForInstances: {
  29002. [key: string]: Nullable<VertexBuffer>;
  29003. };
  29004. protected _checkVerticesInsteadOfIndices: boolean;
  29005. protected _options: Nullable<IEdgesRendererOptions>;
  29006. private _meshRebuildObserver;
  29007. private _meshDisposeObserver;
  29008. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  29009. isEnabled: boolean;
  29010. /** Gets the vertices generated by the edge renderer */
  29011. get linesPositions(): Immutable<Array<number>>;
  29012. /** Gets the normals generated by the edge renderer */
  29013. get linesNormals(): Immutable<Array<number>>;
  29014. /** Gets the indices generated by the edge renderer */
  29015. get linesIndices(): Immutable<Array<number>>;
  29016. /**
  29017. * List of instances to render in case the source mesh has instances
  29018. */
  29019. customInstances: SmartArray<Matrix>;
  29020. private static GetShader;
  29021. /**
  29022. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  29023. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  29024. * @param source Mesh used to create edges
  29025. * @param epsilon sum of angles in adjacency to check for edge
  29026. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  29027. * @param generateEdgesLines - should generate Lines or only prepare resources.
  29028. * @param options The options to apply when generating the edges
  29029. */
  29030. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  29031. protected _prepareRessources(): void;
  29032. /** @hidden */
  29033. _rebuild(): void;
  29034. /**
  29035. * Releases the required resources for the edges renderer
  29036. */
  29037. dispose(): void;
  29038. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  29039. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  29040. /**
  29041. * Checks if the pair of p0 and p1 is en edge
  29042. * @param faceIndex
  29043. * @param edge
  29044. * @param faceNormals
  29045. * @param p0
  29046. * @param p1
  29047. * @private
  29048. */
  29049. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  29050. /**
  29051. * push line into the position, normal and index buffer
  29052. * @protected
  29053. */
  29054. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  29055. /**
  29056. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  29057. */
  29058. private _tessellateTriangle;
  29059. private _generateEdgesLinesAlternate;
  29060. /**
  29061. * Generates lines edges from adjacencjes
  29062. * @private
  29063. */
  29064. _generateEdgesLines(): void;
  29065. /**
  29066. * Checks wether or not the edges renderer is ready to render.
  29067. * @return true if ready, otherwise false.
  29068. */
  29069. isReady(): boolean;
  29070. /**
  29071. * Renders the edges of the attached mesh,
  29072. */
  29073. render(): void;
  29074. }
  29075. /**
  29076. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  29077. */
  29078. export class LineEdgesRenderer extends EdgesRenderer {
  29079. /**
  29080. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  29081. * @param source LineMesh used to generate edges
  29082. * @param epsilon not important (specified angle for edge detection)
  29083. * @param checkVerticesInsteadOfIndices not important for LineMesh
  29084. */
  29085. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  29086. /**
  29087. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  29088. */
  29089. _generateEdgesLines(): void;
  29090. }
  29091. }
  29092. declare module BABYLON {
  29093. /**
  29094. * This represents the object necessary to create a rendering group.
  29095. * This is exclusively used and created by the rendering manager.
  29096. * To modify the behavior, you use the available helpers in your scene or meshes.
  29097. * @hidden
  29098. */
  29099. export class RenderingGroup {
  29100. index: number;
  29101. private static _zeroVector;
  29102. private _scene;
  29103. private _opaqueSubMeshes;
  29104. private _transparentSubMeshes;
  29105. private _alphaTestSubMeshes;
  29106. private _depthOnlySubMeshes;
  29107. private _particleSystems;
  29108. private _spriteManagers;
  29109. private _opaqueSortCompareFn;
  29110. private _alphaTestSortCompareFn;
  29111. private _transparentSortCompareFn;
  29112. private _renderOpaque;
  29113. private _renderAlphaTest;
  29114. private _renderTransparent;
  29115. /** @hidden */
  29116. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  29117. onBeforeTransparentRendering: () => void;
  29118. /**
  29119. * Set the opaque sort comparison function.
  29120. * If null the sub meshes will be render in the order they were created
  29121. */
  29122. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29123. /**
  29124. * Set the alpha test sort comparison function.
  29125. * If null the sub meshes will be render in the order they were created
  29126. */
  29127. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29128. /**
  29129. * Set the transparent sort comparison function.
  29130. * If null the sub meshes will be render in the order they were created
  29131. */
  29132. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29133. /**
  29134. * Creates a new rendering group.
  29135. * @param index The rendering group index
  29136. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  29137. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  29138. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  29139. */
  29140. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29141. /**
  29142. * Render all the sub meshes contained in the group.
  29143. * @param customRenderFunction Used to override the default render behaviour of the group.
  29144. * @returns true if rendered some submeshes.
  29145. */
  29146. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  29147. /**
  29148. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  29149. * @param subMeshes The submeshes to render
  29150. */
  29151. private renderOpaqueSorted;
  29152. /**
  29153. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  29154. * @param subMeshes The submeshes to render
  29155. */
  29156. private renderAlphaTestSorted;
  29157. /**
  29158. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  29159. * @param subMeshes The submeshes to render
  29160. */
  29161. private renderTransparentSorted;
  29162. /**
  29163. * Renders the submeshes in a specified order.
  29164. * @param subMeshes The submeshes to sort before render
  29165. * @param sortCompareFn The comparison function use to sort
  29166. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  29167. * @param transparent Specifies to activate blending if true
  29168. */
  29169. private static renderSorted;
  29170. /**
  29171. * Renders the submeshes in the order they were dispatched (no sort applied).
  29172. * @param subMeshes The submeshes to render
  29173. */
  29174. private static renderUnsorted;
  29175. /**
  29176. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29177. * are rendered back to front if in the same alpha index.
  29178. *
  29179. * @param a The first submesh
  29180. * @param b The second submesh
  29181. * @returns The result of the comparison
  29182. */
  29183. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  29184. /**
  29185. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29186. * are rendered back to front.
  29187. *
  29188. * @param a The first submesh
  29189. * @param b The second submesh
  29190. * @returns The result of the comparison
  29191. */
  29192. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  29193. /**
  29194. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29195. * are rendered front to back (prevent overdraw).
  29196. *
  29197. * @param a The first submesh
  29198. * @param b The second submesh
  29199. * @returns The result of the comparison
  29200. */
  29201. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  29202. /**
  29203. * Resets the different lists of submeshes to prepare a new frame.
  29204. */
  29205. prepare(): void;
  29206. dispose(): void;
  29207. /**
  29208. * Inserts the submesh in its correct queue depending on its material.
  29209. * @param subMesh The submesh to dispatch
  29210. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29211. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29212. */
  29213. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29214. dispatchSprites(spriteManager: ISpriteManager): void;
  29215. dispatchParticles(particleSystem: IParticleSystem): void;
  29216. private _renderParticles;
  29217. private _renderSprites;
  29218. }
  29219. }
  29220. declare module BABYLON {
  29221. /**
  29222. * Interface describing the different options available in the rendering manager
  29223. * regarding Auto Clear between groups.
  29224. */
  29225. export interface IRenderingManagerAutoClearSetup {
  29226. /**
  29227. * Defines whether or not autoclear is enable.
  29228. */
  29229. autoClear: boolean;
  29230. /**
  29231. * Defines whether or not to autoclear the depth buffer.
  29232. */
  29233. depth: boolean;
  29234. /**
  29235. * Defines whether or not to autoclear the stencil buffer.
  29236. */
  29237. stencil: boolean;
  29238. }
  29239. /**
  29240. * This class is used by the onRenderingGroupObservable
  29241. */
  29242. export class RenderingGroupInfo {
  29243. /**
  29244. * The Scene that being rendered
  29245. */
  29246. scene: Scene;
  29247. /**
  29248. * The camera currently used for the rendering pass
  29249. */
  29250. camera: Nullable<Camera>;
  29251. /**
  29252. * The ID of the renderingGroup being processed
  29253. */
  29254. renderingGroupId: number;
  29255. }
  29256. /**
  29257. * This is the manager responsible of all the rendering for meshes sprites and particles.
  29258. * It is enable to manage the different groups as well as the different necessary sort functions.
  29259. * This should not be used directly aside of the few static configurations
  29260. */
  29261. export class RenderingManager {
  29262. /**
  29263. * The max id used for rendering groups (not included)
  29264. */
  29265. static MAX_RENDERINGGROUPS: number;
  29266. /**
  29267. * The min id used for rendering groups (included)
  29268. */
  29269. static MIN_RENDERINGGROUPS: number;
  29270. /**
  29271. * Used to globally prevent autoclearing scenes.
  29272. */
  29273. static AUTOCLEAR: boolean;
  29274. /**
  29275. * @hidden
  29276. */
  29277. _useSceneAutoClearSetup: boolean;
  29278. private _scene;
  29279. private _renderingGroups;
  29280. private _depthStencilBufferAlreadyCleaned;
  29281. private _autoClearDepthStencil;
  29282. private _customOpaqueSortCompareFn;
  29283. private _customAlphaTestSortCompareFn;
  29284. private _customTransparentSortCompareFn;
  29285. private _renderingGroupInfo;
  29286. /**
  29287. * Instantiates a new rendering group for a particular scene
  29288. * @param scene Defines the scene the groups belongs to
  29289. */
  29290. constructor(scene: Scene);
  29291. private _clearDepthStencilBuffer;
  29292. /**
  29293. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  29294. * @hidden
  29295. */
  29296. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  29297. /**
  29298. * Resets the different information of the group to prepare a new frame
  29299. * @hidden
  29300. */
  29301. reset(): void;
  29302. /**
  29303. * Dispose and release the group and its associated resources.
  29304. * @hidden
  29305. */
  29306. dispose(): void;
  29307. /**
  29308. * Clear the info related to rendering groups preventing retention points during dispose.
  29309. */
  29310. freeRenderingGroups(): void;
  29311. private _prepareRenderingGroup;
  29312. /**
  29313. * Add a sprite manager to the rendering manager in order to render it this frame.
  29314. * @param spriteManager Define the sprite manager to render
  29315. */
  29316. dispatchSprites(spriteManager: ISpriteManager): void;
  29317. /**
  29318. * Add a particle system to the rendering manager in order to render it this frame.
  29319. * @param particleSystem Define the particle system to render
  29320. */
  29321. dispatchParticles(particleSystem: IParticleSystem): void;
  29322. /**
  29323. * Add a submesh to the manager in order to render it this frame
  29324. * @param subMesh The submesh to dispatch
  29325. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29326. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29327. */
  29328. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29329. /**
  29330. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29331. * This allowed control for front to back rendering or reversly depending of the special needs.
  29332. *
  29333. * @param renderingGroupId The rendering group id corresponding to its index
  29334. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29335. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29336. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29337. */
  29338. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  29339. /**
  29340. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29341. *
  29342. * @param renderingGroupId The rendering group id corresponding to its index
  29343. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29344. * @param depth Automatically clears depth between groups if true and autoClear is true.
  29345. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  29346. */
  29347. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  29348. /**
  29349. * Gets the current auto clear configuration for one rendering group of the rendering
  29350. * manager.
  29351. * @param index the rendering group index to get the information for
  29352. * @returns The auto clear setup for the requested rendering group
  29353. */
  29354. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  29355. }
  29356. }
  29357. declare module BABYLON {
  29358. /**
  29359. * Defines the options associated with the creation of a custom shader for a shadow generator.
  29360. */
  29361. export interface ICustomShaderOptions {
  29362. /**
  29363. * Gets or sets the custom shader name to use
  29364. */
  29365. shaderName: string;
  29366. /**
  29367. * The list of attribute names used in the shader
  29368. */
  29369. attributes?: string[];
  29370. /**
  29371. * The list of unifrom names used in the shader
  29372. */
  29373. uniforms?: string[];
  29374. /**
  29375. * The list of sampler names used in the shader
  29376. */
  29377. samplers?: string[];
  29378. /**
  29379. * The list of defines used in the shader
  29380. */
  29381. defines?: string[];
  29382. }
  29383. /**
  29384. * Interface to implement to create a shadow generator compatible with BJS.
  29385. */
  29386. export interface IShadowGenerator {
  29387. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29388. id: string;
  29389. /**
  29390. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29391. * @returns The render target texture if present otherwise, null
  29392. */
  29393. getShadowMap(): Nullable<RenderTargetTexture>;
  29394. /**
  29395. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29396. * @param subMesh The submesh we want to render in the shadow map
  29397. * @param useInstances Defines wether will draw in the map using instances
  29398. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29399. * @returns true if ready otherwise, false
  29400. */
  29401. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29402. /**
  29403. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29404. * @param defines Defines of the material we want to update
  29405. * @param lightIndex Index of the light in the enabled light list of the material
  29406. */
  29407. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  29408. /**
  29409. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29410. * defined in the generator but impacting the effect).
  29411. * It implies the unifroms available on the materials are the standard BJS ones.
  29412. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29413. * @param effect The effect we are binfing the information for
  29414. */
  29415. bindShadowLight(lightIndex: string, effect: Effect): void;
  29416. /**
  29417. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29418. * (eq to shadow prjection matrix * light transform matrix)
  29419. * @returns The transform matrix used to create the shadow map
  29420. */
  29421. getTransformMatrix(): Matrix;
  29422. /**
  29423. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29424. * Cube and 2D textures for instance.
  29425. */
  29426. recreateShadowMap(): void;
  29427. /**
  29428. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29429. * @param onCompiled Callback triggered at the and of the effects compilation
  29430. * @param options Sets of optional options forcing the compilation with different modes
  29431. */
  29432. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29433. useInstances: boolean;
  29434. }>): void;
  29435. /**
  29436. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29437. * @param options Sets of optional options forcing the compilation with different modes
  29438. * @returns A promise that resolves when the compilation completes
  29439. */
  29440. forceCompilationAsync(options?: Partial<{
  29441. useInstances: boolean;
  29442. }>): Promise<void>;
  29443. /**
  29444. * Serializes the shadow generator setup to a json object.
  29445. * @returns The serialized JSON object
  29446. */
  29447. serialize(): any;
  29448. /**
  29449. * Disposes the Shadow map and related Textures and effects.
  29450. */
  29451. dispose(): void;
  29452. }
  29453. /**
  29454. * Default implementation IShadowGenerator.
  29455. * This is the main object responsible of generating shadows in the framework.
  29456. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  29457. */
  29458. export class ShadowGenerator implements IShadowGenerator {
  29459. private static _Counter;
  29460. /**
  29461. * Name of the shadow generator class
  29462. */
  29463. static CLASSNAME: string;
  29464. /**
  29465. * Shadow generator mode None: no filtering applied.
  29466. */
  29467. static readonly FILTER_NONE: number;
  29468. /**
  29469. * Shadow generator mode ESM: Exponential Shadow Mapping.
  29470. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29471. */
  29472. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  29473. /**
  29474. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  29475. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  29476. */
  29477. static readonly FILTER_POISSONSAMPLING: number;
  29478. /**
  29479. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  29480. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29481. */
  29482. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  29483. /**
  29484. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  29485. * edge artifacts on steep falloff.
  29486. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29487. */
  29488. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  29489. /**
  29490. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  29491. * edge artifacts on steep falloff.
  29492. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29493. */
  29494. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  29495. /**
  29496. * Shadow generator mode PCF: Percentage Closer Filtering
  29497. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29498. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  29499. */
  29500. static readonly FILTER_PCF: number;
  29501. /**
  29502. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  29503. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29504. * Contact Hardening
  29505. */
  29506. static readonly FILTER_PCSS: number;
  29507. /**
  29508. * Reserved for PCF and PCSS
  29509. * Highest Quality.
  29510. *
  29511. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  29512. *
  29513. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  29514. */
  29515. static readonly QUALITY_HIGH: number;
  29516. /**
  29517. * Reserved for PCF and PCSS
  29518. * Good tradeoff for quality/perf cross devices
  29519. *
  29520. * Execute PCF on a 3*3 kernel.
  29521. *
  29522. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  29523. */
  29524. static readonly QUALITY_MEDIUM: number;
  29525. /**
  29526. * Reserved for PCF and PCSS
  29527. * The lowest quality but the fastest.
  29528. *
  29529. * Execute PCF on a 1*1 kernel.
  29530. *
  29531. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  29532. */
  29533. static readonly QUALITY_LOW: number;
  29534. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29535. id: string;
  29536. /** Gets or sets the custom shader name to use */
  29537. customShaderOptions: ICustomShaderOptions;
  29538. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  29539. customAllowRendering: (subMesh: SubMesh) => boolean;
  29540. /**
  29541. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  29542. */
  29543. onBeforeShadowMapRenderObservable: Observable<Effect>;
  29544. /**
  29545. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  29546. */
  29547. onAfterShadowMapRenderObservable: Observable<Effect>;
  29548. /**
  29549. * Observable triggered before a mesh is rendered in the shadow map.
  29550. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  29551. */
  29552. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  29553. /**
  29554. * Observable triggered after a mesh is rendered in the shadow map.
  29555. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  29556. */
  29557. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  29558. protected _bias: number;
  29559. /**
  29560. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  29561. */
  29562. get bias(): number;
  29563. /**
  29564. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  29565. */
  29566. set bias(bias: number);
  29567. protected _normalBias: number;
  29568. /**
  29569. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  29570. */
  29571. get normalBias(): number;
  29572. /**
  29573. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  29574. */
  29575. set normalBias(normalBias: number);
  29576. protected _blurBoxOffset: number;
  29577. /**
  29578. * Gets the blur box offset: offset applied during the blur pass.
  29579. * Only useful if useKernelBlur = false
  29580. */
  29581. get blurBoxOffset(): number;
  29582. /**
  29583. * Sets the blur box offset: offset applied during the blur pass.
  29584. * Only useful if useKernelBlur = false
  29585. */
  29586. set blurBoxOffset(value: number);
  29587. protected _blurScale: number;
  29588. /**
  29589. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  29590. * 2 means half of the size.
  29591. */
  29592. get blurScale(): number;
  29593. /**
  29594. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  29595. * 2 means half of the size.
  29596. */
  29597. set blurScale(value: number);
  29598. protected _blurKernel: number;
  29599. /**
  29600. * Gets the blur kernel: kernel size of the blur pass.
  29601. * Only useful if useKernelBlur = true
  29602. */
  29603. get blurKernel(): number;
  29604. /**
  29605. * Sets the blur kernel: kernel size of the blur pass.
  29606. * Only useful if useKernelBlur = true
  29607. */
  29608. set blurKernel(value: number);
  29609. protected _useKernelBlur: boolean;
  29610. /**
  29611. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  29612. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  29613. */
  29614. get useKernelBlur(): boolean;
  29615. /**
  29616. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  29617. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  29618. */
  29619. set useKernelBlur(value: boolean);
  29620. protected _depthScale: number;
  29621. /**
  29622. * Gets the depth scale used in ESM mode.
  29623. */
  29624. get depthScale(): number;
  29625. /**
  29626. * Sets the depth scale used in ESM mode.
  29627. * This can override the scale stored on the light.
  29628. */
  29629. set depthScale(value: number);
  29630. protected _validateFilter(filter: number): number;
  29631. protected _filter: number;
  29632. /**
  29633. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  29634. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29635. */
  29636. get filter(): number;
  29637. /**
  29638. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  29639. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29640. */
  29641. set filter(value: number);
  29642. /**
  29643. * Gets if the current filter is set to Poisson Sampling.
  29644. */
  29645. get usePoissonSampling(): boolean;
  29646. /**
  29647. * Sets the current filter to Poisson Sampling.
  29648. */
  29649. set usePoissonSampling(value: boolean);
  29650. /**
  29651. * Gets if the current filter is set to ESM.
  29652. */
  29653. get useExponentialShadowMap(): boolean;
  29654. /**
  29655. * Sets the current filter is to ESM.
  29656. */
  29657. set useExponentialShadowMap(value: boolean);
  29658. /**
  29659. * Gets if the current filter is set to filtered ESM.
  29660. */
  29661. get useBlurExponentialShadowMap(): boolean;
  29662. /**
  29663. * Gets if the current filter is set to filtered ESM.
  29664. */
  29665. set useBlurExponentialShadowMap(value: boolean);
  29666. /**
  29667. * Gets if the current filter is set to "close ESM" (using the inverse of the
  29668. * exponential to prevent steep falloff artifacts).
  29669. */
  29670. get useCloseExponentialShadowMap(): boolean;
  29671. /**
  29672. * Sets the current filter to "close ESM" (using the inverse of the
  29673. * exponential to prevent steep falloff artifacts).
  29674. */
  29675. set useCloseExponentialShadowMap(value: boolean);
  29676. /**
  29677. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  29678. * exponential to prevent steep falloff artifacts).
  29679. */
  29680. get useBlurCloseExponentialShadowMap(): boolean;
  29681. /**
  29682. * Sets the current filter to filtered "close ESM" (using the inverse of the
  29683. * exponential to prevent steep falloff artifacts).
  29684. */
  29685. set useBlurCloseExponentialShadowMap(value: boolean);
  29686. /**
  29687. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  29688. */
  29689. get usePercentageCloserFiltering(): boolean;
  29690. /**
  29691. * Sets the current filter to "PCF" (percentage closer filtering).
  29692. */
  29693. set usePercentageCloserFiltering(value: boolean);
  29694. protected _filteringQuality: number;
  29695. /**
  29696. * Gets the PCF or PCSS Quality.
  29697. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  29698. */
  29699. get filteringQuality(): number;
  29700. /**
  29701. * Sets the PCF or PCSS Quality.
  29702. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  29703. */
  29704. set filteringQuality(filteringQuality: number);
  29705. /**
  29706. * Gets if the current filter is set to "PCSS" (contact hardening).
  29707. */
  29708. get useContactHardeningShadow(): boolean;
  29709. /**
  29710. * Sets the current filter to "PCSS" (contact hardening).
  29711. */
  29712. set useContactHardeningShadow(value: boolean);
  29713. protected _contactHardeningLightSizeUVRatio: number;
  29714. /**
  29715. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  29716. * Using a ratio helps keeping shape stability independently of the map size.
  29717. *
  29718. * It does not account for the light projection as it was having too much
  29719. * instability during the light setup or during light position changes.
  29720. *
  29721. * Only valid if useContactHardeningShadow is true.
  29722. */
  29723. get contactHardeningLightSizeUVRatio(): number;
  29724. /**
  29725. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  29726. * Using a ratio helps keeping shape stability independently of the map size.
  29727. *
  29728. * It does not account for the light projection as it was having too much
  29729. * instability during the light setup or during light position changes.
  29730. *
  29731. * Only valid if useContactHardeningShadow is true.
  29732. */
  29733. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  29734. protected _darkness: number;
  29735. /** Gets or sets the actual darkness of a shadow */
  29736. get darkness(): number;
  29737. set darkness(value: number);
  29738. /**
  29739. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  29740. * 0 means strongest and 1 would means no shadow.
  29741. * @returns the darkness.
  29742. */
  29743. getDarkness(): number;
  29744. /**
  29745. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  29746. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  29747. * @returns the shadow generator allowing fluent coding.
  29748. */
  29749. setDarkness(darkness: number): ShadowGenerator;
  29750. protected _transparencyShadow: boolean;
  29751. /** Gets or sets the ability to have transparent shadow */
  29752. get transparencyShadow(): boolean;
  29753. set transparencyShadow(value: boolean);
  29754. /**
  29755. * Sets the ability to have transparent shadow (boolean).
  29756. * @param transparent True if transparent else False
  29757. * @returns the shadow generator allowing fluent coding
  29758. */
  29759. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  29760. /**
  29761. * Enables or disables shadows with varying strength based on the transparency
  29762. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  29763. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  29764. * mesh.visibility * alphaTexture.a
  29765. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  29766. */
  29767. enableSoftTransparentShadow: boolean;
  29768. protected _shadowMap: Nullable<RenderTargetTexture>;
  29769. protected _shadowMap2: Nullable<RenderTargetTexture>;
  29770. /**
  29771. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29772. * @returns The render target texture if present otherwise, null
  29773. */
  29774. getShadowMap(): Nullable<RenderTargetTexture>;
  29775. /**
  29776. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  29777. * @returns The render target texture if the shadow map is present otherwise, null
  29778. */
  29779. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  29780. /**
  29781. * Gets the class name of that object
  29782. * @returns "ShadowGenerator"
  29783. */
  29784. getClassName(): string;
  29785. /**
  29786. * Helper function to add a mesh and its descendants to the list of shadow casters.
  29787. * @param mesh Mesh to add
  29788. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  29789. * @returns the Shadow Generator itself
  29790. */
  29791. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29792. /**
  29793. * Helper function to remove a mesh and its descendants from the list of shadow casters
  29794. * @param mesh Mesh to remove
  29795. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  29796. * @returns the Shadow Generator itself
  29797. */
  29798. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29799. /**
  29800. * Controls the extent to which the shadows fade out at the edge of the frustum
  29801. */
  29802. frustumEdgeFalloff: number;
  29803. protected _light: IShadowLight;
  29804. /**
  29805. * Returns the associated light object.
  29806. * @returns the light generating the shadow
  29807. */
  29808. getLight(): IShadowLight;
  29809. /**
  29810. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  29811. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  29812. * It might on the other hand introduce peter panning.
  29813. */
  29814. forceBackFacesOnly: boolean;
  29815. protected _scene: Scene;
  29816. protected _lightDirection: Vector3;
  29817. protected _viewMatrix: Matrix;
  29818. protected _projectionMatrix: Matrix;
  29819. protected _transformMatrix: Matrix;
  29820. protected _cachedPosition: Vector3;
  29821. protected _cachedDirection: Vector3;
  29822. protected _cachedDefines: string;
  29823. protected _currentRenderID: number;
  29824. protected _boxBlurPostprocess: Nullable<PostProcess>;
  29825. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  29826. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  29827. protected _blurPostProcesses: PostProcess[];
  29828. protected _mapSize: number;
  29829. protected _currentFaceIndex: number;
  29830. protected _currentFaceIndexCache: number;
  29831. protected _textureType: number;
  29832. protected _defaultTextureMatrix: Matrix;
  29833. protected _storedUniqueId: Nullable<number>;
  29834. protected _nameForCustomEffect: string;
  29835. /** @hidden */
  29836. static _SceneComponentInitialization: (scene: Scene) => void;
  29837. /**
  29838. * Gets or sets the size of the texture what stores the shadows
  29839. */
  29840. get mapSize(): number;
  29841. set mapSize(size: number);
  29842. /**
  29843. * Creates a ShadowGenerator object.
  29844. * A ShadowGenerator is the required tool to use the shadows.
  29845. * Each light casting shadows needs to use its own ShadowGenerator.
  29846. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  29847. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  29848. * @param light The light object generating the shadows.
  29849. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  29850. */
  29851. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  29852. protected _initializeGenerator(): void;
  29853. protected _createTargetRenderTexture(): void;
  29854. protected _initializeShadowMap(): void;
  29855. protected _initializeBlurRTTAndPostProcesses(): void;
  29856. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  29857. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  29858. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  29859. protected _applyFilterValues(): void;
  29860. /**
  29861. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29862. * @param onCompiled Callback triggered at the and of the effects compilation
  29863. * @param options Sets of optional options forcing the compilation with different modes
  29864. */
  29865. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29866. useInstances: boolean;
  29867. }>): void;
  29868. /**
  29869. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29870. * @param options Sets of optional options forcing the compilation with different modes
  29871. * @returns A promise that resolves when the compilation completes
  29872. */
  29873. forceCompilationAsync(options?: Partial<{
  29874. useInstances: boolean;
  29875. }>): Promise<void>;
  29876. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  29877. private _prepareShadowDefines;
  29878. /**
  29879. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29880. * @param subMesh The submesh we want to render in the shadow map
  29881. * @param useInstances Defines wether will draw in the map using instances
  29882. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29883. * @returns true if ready otherwise, false
  29884. */
  29885. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29886. /**
  29887. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29888. * @param defines Defines of the material we want to update
  29889. * @param lightIndex Index of the light in the enabled light list of the material
  29890. */
  29891. prepareDefines(defines: any, lightIndex: number): void;
  29892. /**
  29893. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29894. * defined in the generator but impacting the effect).
  29895. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29896. * @param effect The effect we are binfing the information for
  29897. */
  29898. bindShadowLight(lightIndex: string, effect: Effect): void;
  29899. /**
  29900. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29901. * (eq to shadow prjection matrix * light transform matrix)
  29902. * @returns The transform matrix used to create the shadow map
  29903. */
  29904. getTransformMatrix(): Matrix;
  29905. /**
  29906. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29907. * Cube and 2D textures for instance.
  29908. */
  29909. recreateShadowMap(): void;
  29910. protected _disposeBlurPostProcesses(): void;
  29911. protected _disposeRTTandPostProcesses(): void;
  29912. /**
  29913. * Disposes the ShadowGenerator.
  29914. * Returns nothing.
  29915. */
  29916. dispose(): void;
  29917. /**
  29918. * Serializes the shadow generator setup to a json object.
  29919. * @returns The serialized JSON object
  29920. */
  29921. serialize(): any;
  29922. /**
  29923. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  29924. * @param parsedShadowGenerator The JSON object to parse
  29925. * @param scene The scene to create the shadow map for
  29926. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  29927. * @returns The parsed shadow generator
  29928. */
  29929. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  29930. }
  29931. }
  29932. declare module BABYLON {
  29933. /**
  29934. * Options to be used when creating a shadow depth material
  29935. */
  29936. export interface IIOptionShadowDepthMaterial {
  29937. /** Variables in the vertex shader code that need to have their names remapped.
  29938. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29939. * "var_name" should be either: worldPos or vNormalW
  29940. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29941. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29942. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29943. */
  29944. remappedVariables?: string[];
  29945. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29946. standalone?: boolean;
  29947. }
  29948. /**
  29949. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29950. */
  29951. export class ShadowDepthWrapper {
  29952. private _scene;
  29953. private _options?;
  29954. private _baseMaterial;
  29955. private _onEffectCreatedObserver;
  29956. private _subMeshToEffect;
  29957. private _subMeshToDepthEffect;
  29958. private _meshes;
  29959. /** @hidden */
  29960. _matriceNames: any;
  29961. /** Gets the standalone status of the wrapper */
  29962. get standalone(): boolean;
  29963. /** Gets the base material the wrapper is built upon */
  29964. get baseMaterial(): Material;
  29965. /**
  29966. * Instantiate a new shadow depth wrapper.
  29967. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29968. * generate the shadow depth map. For more information, please refer to the documentation:
  29969. * https://doc.babylonjs.com/babylon101/shadows
  29970. * @param baseMaterial Material to wrap
  29971. * @param scene Define the scene the material belongs to
  29972. * @param options Options used to create the wrapper
  29973. */
  29974. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29975. /**
  29976. * Gets the effect to use to generate the depth map
  29977. * @param subMesh subMesh to get the effect for
  29978. * @param shadowGenerator shadow generator to get the effect for
  29979. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29980. */
  29981. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29982. /**
  29983. * Specifies that the submesh is ready to be used for depth rendering
  29984. * @param subMesh submesh to check
  29985. * @param defines the list of defines to take into account when checking the effect
  29986. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29987. * @param useInstances specifies that instances should be used
  29988. * @returns a boolean indicating that the submesh is ready or not
  29989. */
  29990. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29991. /**
  29992. * Disposes the resources
  29993. */
  29994. dispose(): void;
  29995. private _makeEffect;
  29996. }
  29997. }
  29998. declare module BABYLON {
  29999. /**
  30000. * Options for compiling materials.
  30001. */
  30002. export interface IMaterialCompilationOptions {
  30003. /**
  30004. * Defines whether clip planes are enabled.
  30005. */
  30006. clipPlane: boolean;
  30007. /**
  30008. * Defines whether instances are enabled.
  30009. */
  30010. useInstances: boolean;
  30011. }
  30012. /**
  30013. * Options passed when calling customShaderNameResolve
  30014. */
  30015. export interface ICustomShaderNameResolveOptions {
  30016. /**
  30017. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  30018. */
  30019. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30020. }
  30021. /**
  30022. * Base class for the main features of a material in Babylon.js
  30023. */
  30024. export class Material implements IAnimatable {
  30025. /**
  30026. * Returns the triangle fill mode
  30027. */
  30028. static readonly TriangleFillMode: number;
  30029. /**
  30030. * Returns the wireframe mode
  30031. */
  30032. static readonly WireFrameFillMode: number;
  30033. /**
  30034. * Returns the point fill mode
  30035. */
  30036. static readonly PointFillMode: number;
  30037. /**
  30038. * Returns the point list draw mode
  30039. */
  30040. static readonly PointListDrawMode: number;
  30041. /**
  30042. * Returns the line list draw mode
  30043. */
  30044. static readonly LineListDrawMode: number;
  30045. /**
  30046. * Returns the line loop draw mode
  30047. */
  30048. static readonly LineLoopDrawMode: number;
  30049. /**
  30050. * Returns the line strip draw mode
  30051. */
  30052. static readonly LineStripDrawMode: number;
  30053. /**
  30054. * Returns the triangle strip draw mode
  30055. */
  30056. static readonly TriangleStripDrawMode: number;
  30057. /**
  30058. * Returns the triangle fan draw mode
  30059. */
  30060. static readonly TriangleFanDrawMode: number;
  30061. /**
  30062. * Stores the clock-wise side orientation
  30063. */
  30064. static readonly ClockWiseSideOrientation: number;
  30065. /**
  30066. * Stores the counter clock-wise side orientation
  30067. */
  30068. static readonly CounterClockWiseSideOrientation: number;
  30069. /**
  30070. * The dirty texture flag value
  30071. */
  30072. static readonly TextureDirtyFlag: number;
  30073. /**
  30074. * The dirty light flag value
  30075. */
  30076. static readonly LightDirtyFlag: number;
  30077. /**
  30078. * The dirty fresnel flag value
  30079. */
  30080. static readonly FresnelDirtyFlag: number;
  30081. /**
  30082. * The dirty attribute flag value
  30083. */
  30084. static readonly AttributesDirtyFlag: number;
  30085. /**
  30086. * The dirty misc flag value
  30087. */
  30088. static readonly MiscDirtyFlag: number;
  30089. /**
  30090. * The dirty prepass flag value
  30091. */
  30092. static readonly PrePassDirtyFlag: number;
  30093. /**
  30094. * The all dirty flag value
  30095. */
  30096. static readonly AllDirtyFlag: number;
  30097. /**
  30098. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30099. */
  30100. static readonly MATERIAL_OPAQUE: number;
  30101. /**
  30102. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30103. */
  30104. static readonly MATERIAL_ALPHATEST: number;
  30105. /**
  30106. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30107. */
  30108. static readonly MATERIAL_ALPHABLEND: number;
  30109. /**
  30110. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30111. * They are also discarded below the alpha cutoff threshold to improve performances.
  30112. */
  30113. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30114. /**
  30115. * The Whiteout method is used to blend normals.
  30116. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30117. */
  30118. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30119. /**
  30120. * The Reoriented Normal Mapping method is used to blend normals.
  30121. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30122. */
  30123. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30124. /**
  30125. * Custom callback helping to override the default shader used in the material.
  30126. */
  30127. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30128. /**
  30129. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30130. */
  30131. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30132. /**
  30133. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30134. * This means that the material can keep using a previous shader while a new one is being compiled.
  30135. * This is mostly used when shader parallel compilation is supported (true by default)
  30136. */
  30137. allowShaderHotSwapping: boolean;
  30138. /**
  30139. * The ID of the material
  30140. */
  30141. id: string;
  30142. /**
  30143. * Gets or sets the unique id of the material
  30144. */
  30145. uniqueId: number;
  30146. /**
  30147. * The name of the material
  30148. */
  30149. name: string;
  30150. /**
  30151. * Gets or sets user defined metadata
  30152. */
  30153. metadata: any;
  30154. /**
  30155. * For internal use only. Please do not use.
  30156. */
  30157. reservedDataStore: any;
  30158. /**
  30159. * Specifies if the ready state should be checked on each call
  30160. */
  30161. checkReadyOnEveryCall: boolean;
  30162. /**
  30163. * Specifies if the ready state should be checked once
  30164. */
  30165. checkReadyOnlyOnce: boolean;
  30166. /**
  30167. * The state of the material
  30168. */
  30169. state: string;
  30170. /**
  30171. * If the material can be rendered to several textures with MRT extension
  30172. */
  30173. get canRenderToMRT(): boolean;
  30174. /**
  30175. * The alpha value of the material
  30176. */
  30177. protected _alpha: number;
  30178. /**
  30179. * List of inspectable custom properties (used by the Inspector)
  30180. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30181. */
  30182. inspectableCustomProperties: IInspectable[];
  30183. /**
  30184. * Sets the alpha value of the material
  30185. */
  30186. set alpha(value: number);
  30187. /**
  30188. * Gets the alpha value of the material
  30189. */
  30190. get alpha(): number;
  30191. /**
  30192. * Specifies if back face culling is enabled
  30193. */
  30194. protected _backFaceCulling: boolean;
  30195. /**
  30196. * Sets the back-face culling state
  30197. */
  30198. set backFaceCulling(value: boolean);
  30199. /**
  30200. * Gets the back-face culling state
  30201. */
  30202. get backFaceCulling(): boolean;
  30203. /**
  30204. * Stores the value for side orientation
  30205. */
  30206. sideOrientation: number;
  30207. /**
  30208. * Callback triggered when the material is compiled
  30209. */
  30210. onCompiled: Nullable<(effect: Effect) => void>;
  30211. /**
  30212. * Callback triggered when an error occurs
  30213. */
  30214. onError: Nullable<(effect: Effect, errors: string) => void>;
  30215. /**
  30216. * Callback triggered to get the render target textures
  30217. */
  30218. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30219. /**
  30220. * Gets a boolean indicating that current material needs to register RTT
  30221. */
  30222. get hasRenderTargetTextures(): boolean;
  30223. /**
  30224. * Specifies if the material should be serialized
  30225. */
  30226. doNotSerialize: boolean;
  30227. /**
  30228. * @hidden
  30229. */
  30230. _storeEffectOnSubMeshes: boolean;
  30231. /**
  30232. * Stores the animations for the material
  30233. */
  30234. animations: Nullable<Array<Animation>>;
  30235. /**
  30236. * An event triggered when the material is disposed
  30237. */
  30238. onDisposeObservable: Observable<Material>;
  30239. /**
  30240. * An observer which watches for dispose events
  30241. */
  30242. private _onDisposeObserver;
  30243. private _onUnBindObservable;
  30244. /**
  30245. * Called during a dispose event
  30246. */
  30247. set onDispose(callback: () => void);
  30248. private _onBindObservable;
  30249. /**
  30250. * An event triggered when the material is bound
  30251. */
  30252. get onBindObservable(): Observable<AbstractMesh>;
  30253. /**
  30254. * An observer which watches for bind events
  30255. */
  30256. private _onBindObserver;
  30257. /**
  30258. * Called during a bind event
  30259. */
  30260. set onBind(callback: (Mesh: AbstractMesh) => void);
  30261. /**
  30262. * An event triggered when the material is unbound
  30263. */
  30264. get onUnBindObservable(): Observable<Material>;
  30265. protected _onEffectCreatedObservable: Nullable<Observable<{
  30266. effect: Effect;
  30267. subMesh: Nullable<SubMesh>;
  30268. }>>;
  30269. /**
  30270. * An event triggered when the effect is (re)created
  30271. */
  30272. get onEffectCreatedObservable(): Observable<{
  30273. effect: Effect;
  30274. subMesh: Nullable<SubMesh>;
  30275. }>;
  30276. /**
  30277. * Stores the value of the alpha mode
  30278. */
  30279. private _alphaMode;
  30280. /**
  30281. * Sets the value of the alpha mode.
  30282. *
  30283. * | Value | Type | Description |
  30284. * | --- | --- | --- |
  30285. * | 0 | ALPHA_DISABLE | |
  30286. * | 1 | ALPHA_ADD | |
  30287. * | 2 | ALPHA_COMBINE | |
  30288. * | 3 | ALPHA_SUBTRACT | |
  30289. * | 4 | ALPHA_MULTIPLY | |
  30290. * | 5 | ALPHA_MAXIMIZED | |
  30291. * | 6 | ALPHA_ONEONE | |
  30292. * | 7 | ALPHA_PREMULTIPLIED | |
  30293. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30294. * | 9 | ALPHA_INTERPOLATE | |
  30295. * | 10 | ALPHA_SCREENMODE | |
  30296. *
  30297. */
  30298. set alphaMode(value: number);
  30299. /**
  30300. * Gets the value of the alpha mode
  30301. */
  30302. get alphaMode(): number;
  30303. /**
  30304. * Stores the state of the need depth pre-pass value
  30305. */
  30306. private _needDepthPrePass;
  30307. /**
  30308. * Sets the need depth pre-pass value
  30309. */
  30310. set needDepthPrePass(value: boolean);
  30311. /**
  30312. * Gets the depth pre-pass value
  30313. */
  30314. get needDepthPrePass(): boolean;
  30315. /**
  30316. * Specifies if depth writing should be disabled
  30317. */
  30318. disableDepthWrite: boolean;
  30319. /**
  30320. * Specifies if color writing should be disabled
  30321. */
  30322. disableColorWrite: boolean;
  30323. /**
  30324. * Specifies if depth writing should be forced
  30325. */
  30326. forceDepthWrite: boolean;
  30327. /**
  30328. * Specifies the depth function that should be used. 0 means the default engine function
  30329. */
  30330. depthFunction: number;
  30331. /**
  30332. * Specifies if there should be a separate pass for culling
  30333. */
  30334. separateCullingPass: boolean;
  30335. /**
  30336. * Stores the state specifing if fog should be enabled
  30337. */
  30338. private _fogEnabled;
  30339. /**
  30340. * Sets the state for enabling fog
  30341. */
  30342. set fogEnabled(value: boolean);
  30343. /**
  30344. * Gets the value of the fog enabled state
  30345. */
  30346. get fogEnabled(): boolean;
  30347. /**
  30348. * Stores the size of points
  30349. */
  30350. pointSize: number;
  30351. /**
  30352. * Stores the z offset value
  30353. */
  30354. zOffset: number;
  30355. get wireframe(): boolean;
  30356. /**
  30357. * Sets the state of wireframe mode
  30358. */
  30359. set wireframe(value: boolean);
  30360. /**
  30361. * Gets the value specifying if point clouds are enabled
  30362. */
  30363. get pointsCloud(): boolean;
  30364. /**
  30365. * Sets the state of point cloud mode
  30366. */
  30367. set pointsCloud(value: boolean);
  30368. /**
  30369. * Gets the material fill mode
  30370. */
  30371. get fillMode(): number;
  30372. /**
  30373. * Sets the material fill mode
  30374. */
  30375. set fillMode(value: number);
  30376. /**
  30377. * @hidden
  30378. * Stores the effects for the material
  30379. */
  30380. _effect: Nullable<Effect>;
  30381. /**
  30382. * Specifies if uniform buffers should be used
  30383. */
  30384. private _useUBO;
  30385. /**
  30386. * Stores a reference to the scene
  30387. */
  30388. private _scene;
  30389. private _needToBindSceneUbo;
  30390. /**
  30391. * Stores the fill mode state
  30392. */
  30393. private _fillMode;
  30394. /**
  30395. * Specifies if the depth write state should be cached
  30396. */
  30397. private _cachedDepthWriteState;
  30398. /**
  30399. * Specifies if the color write state should be cached
  30400. */
  30401. private _cachedColorWriteState;
  30402. /**
  30403. * Specifies if the depth function state should be cached
  30404. */
  30405. private _cachedDepthFunctionState;
  30406. /**
  30407. * Stores the uniform buffer
  30408. */
  30409. protected _uniformBuffer: UniformBuffer;
  30410. /** @hidden */
  30411. _indexInSceneMaterialArray: number;
  30412. /** @hidden */
  30413. meshMap: Nullable<{
  30414. [id: string]: AbstractMesh | undefined;
  30415. }>;
  30416. /**
  30417. * Creates a material instance
  30418. * @param name defines the name of the material
  30419. * @param scene defines the scene to reference
  30420. * @param doNotAdd specifies if the material should be added to the scene
  30421. */
  30422. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30423. /**
  30424. * Returns a string representation of the current material
  30425. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30426. * @returns a string with material information
  30427. */
  30428. toString(fullDetails?: boolean): string;
  30429. /**
  30430. * Gets the class name of the material
  30431. * @returns a string with the class name of the material
  30432. */
  30433. getClassName(): string;
  30434. /**
  30435. * Specifies if updates for the material been locked
  30436. */
  30437. get isFrozen(): boolean;
  30438. /**
  30439. * Locks updates for the material
  30440. */
  30441. freeze(): void;
  30442. /**
  30443. * Unlocks updates for the material
  30444. */
  30445. unfreeze(): void;
  30446. /**
  30447. * Specifies if the material is ready to be used
  30448. * @param mesh defines the mesh to check
  30449. * @param useInstances specifies if instances should be used
  30450. * @returns a boolean indicating if the material is ready to be used
  30451. */
  30452. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30453. /**
  30454. * Specifies that the submesh is ready to be used
  30455. * @param mesh defines the mesh to check
  30456. * @param subMesh defines which submesh to check
  30457. * @param useInstances specifies that instances should be used
  30458. * @returns a boolean indicating that the submesh is ready or not
  30459. */
  30460. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30461. /**
  30462. * Returns the material effect
  30463. * @returns the effect associated with the material
  30464. */
  30465. getEffect(): Nullable<Effect>;
  30466. /**
  30467. * Returns the current scene
  30468. * @returns a Scene
  30469. */
  30470. getScene(): Scene;
  30471. /**
  30472. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30473. */
  30474. protected _forceAlphaTest: boolean;
  30475. /**
  30476. * The transparency mode of the material.
  30477. */
  30478. protected _transparencyMode: Nullable<number>;
  30479. /**
  30480. * Gets the current transparency mode.
  30481. */
  30482. get transparencyMode(): Nullable<number>;
  30483. /**
  30484. * Sets the transparency mode of the material.
  30485. *
  30486. * | Value | Type | Description |
  30487. * | ----- | ----------------------------------- | ----------- |
  30488. * | 0 | OPAQUE | |
  30489. * | 1 | ALPHATEST | |
  30490. * | 2 | ALPHABLEND | |
  30491. * | 3 | ALPHATESTANDBLEND | |
  30492. *
  30493. */
  30494. set transparencyMode(value: Nullable<number>);
  30495. /**
  30496. * Returns true if alpha blending should be disabled.
  30497. */
  30498. protected get _disableAlphaBlending(): boolean;
  30499. /**
  30500. * Specifies whether or not this material should be rendered in alpha blend mode.
  30501. * @returns a boolean specifying if alpha blending is needed
  30502. */
  30503. needAlphaBlending(): boolean;
  30504. /**
  30505. * Specifies if the mesh will require alpha blending
  30506. * @param mesh defines the mesh to check
  30507. * @returns a boolean specifying if alpha blending is needed for the mesh
  30508. */
  30509. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30510. /**
  30511. * Specifies whether or not this material should be rendered in alpha test mode.
  30512. * @returns a boolean specifying if an alpha test is needed.
  30513. */
  30514. needAlphaTesting(): boolean;
  30515. /**
  30516. * Specifies if material alpha testing should be turned on for the mesh
  30517. * @param mesh defines the mesh to check
  30518. */
  30519. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30520. /**
  30521. * Gets the texture used for the alpha test
  30522. * @returns the texture to use for alpha testing
  30523. */
  30524. getAlphaTestTexture(): Nullable<BaseTexture>;
  30525. /**
  30526. * Marks the material to indicate that it needs to be re-calculated
  30527. */
  30528. markDirty(): void;
  30529. /** @hidden */
  30530. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30531. /**
  30532. * Binds the material to the mesh
  30533. * @param world defines the world transformation matrix
  30534. * @param mesh defines the mesh to bind the material to
  30535. */
  30536. bind(world: Matrix, mesh?: Mesh): void;
  30537. /**
  30538. * Binds the submesh to the material
  30539. * @param world defines the world transformation matrix
  30540. * @param mesh defines the mesh containing the submesh
  30541. * @param subMesh defines the submesh to bind the material to
  30542. */
  30543. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30544. /**
  30545. * Binds the world matrix to the material
  30546. * @param world defines the world transformation matrix
  30547. */
  30548. bindOnlyWorldMatrix(world: Matrix): void;
  30549. /**
  30550. * Update the scene ubo before it can be used in rendering processing
  30551. * @param scene the scene to retrieve the ubo from
  30552. * @returns the scene UniformBuffer
  30553. */
  30554. finalizeSceneUbo(scene: Scene): UniformBuffer;
  30555. /**
  30556. * Binds the scene's uniform buffer to the effect.
  30557. * @param effect defines the effect to bind to the scene uniform buffer
  30558. * @param sceneUbo defines the uniform buffer storing scene data
  30559. */
  30560. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  30561. /**
  30562. * Binds the view matrix to the effect
  30563. * @param effect defines the effect to bind the view matrix to
  30564. */
  30565. bindView(effect: Effect): void;
  30566. /**
  30567. * Binds the view projection and projection matrices to the effect
  30568. * @param effect defines the effect to bind the view projection and projection matrices to
  30569. */
  30570. bindViewProjection(effect: Effect): void;
  30571. /**
  30572. * Binds the view matrix to the effect
  30573. * @param effect defines the effect to bind the view matrix to
  30574. * @param variableName name of the shader variable that will hold the eye position
  30575. */
  30576. bindEyePosition(effect: Effect, variableName?: string): void;
  30577. /**
  30578. * Processes to execute after binding the material to a mesh
  30579. * @param mesh defines the rendered mesh
  30580. */
  30581. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  30582. /**
  30583. * Unbinds the material from the mesh
  30584. */
  30585. unbind(): void;
  30586. /**
  30587. * Gets the active textures from the material
  30588. * @returns an array of textures
  30589. */
  30590. getActiveTextures(): BaseTexture[];
  30591. /**
  30592. * Specifies if the material uses a texture
  30593. * @param texture defines the texture to check against the material
  30594. * @returns a boolean specifying if the material uses the texture
  30595. */
  30596. hasTexture(texture: BaseTexture): boolean;
  30597. /**
  30598. * Makes a duplicate of the material, and gives it a new name
  30599. * @param name defines the new name for the duplicated material
  30600. * @returns the cloned material
  30601. */
  30602. clone(name: string): Nullable<Material>;
  30603. /**
  30604. * Gets the meshes bound to the material
  30605. * @returns an array of meshes bound to the material
  30606. */
  30607. getBindedMeshes(): AbstractMesh[];
  30608. /**
  30609. * Force shader compilation
  30610. * @param mesh defines the mesh associated with this material
  30611. * @param onCompiled defines a function to execute once the material is compiled
  30612. * @param options defines the options to configure the compilation
  30613. * @param onError defines a function to execute if the material fails compiling
  30614. */
  30615. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  30616. /**
  30617. * Force shader compilation
  30618. * @param mesh defines the mesh that will use this material
  30619. * @param options defines additional options for compiling the shaders
  30620. * @returns a promise that resolves when the compilation completes
  30621. */
  30622. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  30623. private static readonly _AllDirtyCallBack;
  30624. private static readonly _ImageProcessingDirtyCallBack;
  30625. private static readonly _TextureDirtyCallBack;
  30626. private static readonly _FresnelDirtyCallBack;
  30627. private static readonly _MiscDirtyCallBack;
  30628. private static readonly _PrePassDirtyCallBack;
  30629. private static readonly _LightsDirtyCallBack;
  30630. private static readonly _AttributeDirtyCallBack;
  30631. private static _FresnelAndMiscDirtyCallBack;
  30632. private static _TextureAndMiscDirtyCallBack;
  30633. private static readonly _DirtyCallbackArray;
  30634. private static readonly _RunDirtyCallBacks;
  30635. /**
  30636. * Marks a define in the material to indicate that it needs to be re-computed
  30637. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  30638. */
  30639. markAsDirty(flag: number): void;
  30640. /**
  30641. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  30642. * @param func defines a function which checks material defines against the submeshes
  30643. */
  30644. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  30645. /**
  30646. * Indicates that the scene should check if the rendering now needs a prepass
  30647. */
  30648. protected _markScenePrePassDirty(): void;
  30649. /**
  30650. * Indicates that we need to re-calculated for all submeshes
  30651. */
  30652. protected _markAllSubMeshesAsAllDirty(): void;
  30653. /**
  30654. * Indicates that image processing needs to be re-calculated for all submeshes
  30655. */
  30656. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  30657. /**
  30658. * Indicates that textures need to be re-calculated for all submeshes
  30659. */
  30660. protected _markAllSubMeshesAsTexturesDirty(): void;
  30661. /**
  30662. * Indicates that fresnel needs to be re-calculated for all submeshes
  30663. */
  30664. protected _markAllSubMeshesAsFresnelDirty(): void;
  30665. /**
  30666. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  30667. */
  30668. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  30669. /**
  30670. * Indicates that lights need to be re-calculated for all submeshes
  30671. */
  30672. protected _markAllSubMeshesAsLightsDirty(): void;
  30673. /**
  30674. * Indicates that attributes need to be re-calculated for all submeshes
  30675. */
  30676. protected _markAllSubMeshesAsAttributesDirty(): void;
  30677. /**
  30678. * Indicates that misc needs to be re-calculated for all submeshes
  30679. */
  30680. protected _markAllSubMeshesAsMiscDirty(): void;
  30681. /**
  30682. * Indicates that prepass needs to be re-calculated for all submeshes
  30683. */
  30684. protected _markAllSubMeshesAsPrePassDirty(): void;
  30685. /**
  30686. * Indicates that textures and misc need to be re-calculated for all submeshes
  30687. */
  30688. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  30689. /**
  30690. * Sets the required values to the prepass renderer.
  30691. * @param prePassRenderer defines the prepass renderer to setup.
  30692. * @returns true if the pre pass is needed.
  30693. */
  30694. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  30695. /**
  30696. * Disposes the material
  30697. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30698. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30699. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  30700. */
  30701. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  30702. /** @hidden */
  30703. private releaseVertexArrayObject;
  30704. /**
  30705. * Serializes this material
  30706. * @returns the serialized material object
  30707. */
  30708. serialize(): any;
  30709. /**
  30710. * Creates a material from parsed material data
  30711. * @param parsedMaterial defines parsed material data
  30712. * @param scene defines the hosting scene
  30713. * @param rootUrl defines the root URL to use to load textures
  30714. * @returns a new material
  30715. */
  30716. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  30717. }
  30718. }
  30719. declare module BABYLON {
  30720. /**
  30721. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30722. * separate meshes. This can be use to improve performances.
  30723. * @see https://doc.babylonjs.com/how_to/multi_materials
  30724. */
  30725. export class MultiMaterial extends Material {
  30726. private _subMaterials;
  30727. /**
  30728. * Gets or Sets the list of Materials used within the multi material.
  30729. * They need to be ordered according to the submeshes order in the associated mesh
  30730. */
  30731. get subMaterials(): Nullable<Material>[];
  30732. set subMaterials(value: Nullable<Material>[]);
  30733. /**
  30734. * Function used to align with Node.getChildren()
  30735. * @returns the list of Materials used within the multi material
  30736. */
  30737. getChildren(): Nullable<Material>[];
  30738. /**
  30739. * Instantiates a new Multi Material
  30740. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30741. * separate meshes. This can be use to improve performances.
  30742. * @see https://doc.babylonjs.com/how_to/multi_materials
  30743. * @param name Define the name in the scene
  30744. * @param scene Define the scene the material belongs to
  30745. */
  30746. constructor(name: string, scene: Scene);
  30747. private _hookArray;
  30748. /**
  30749. * Get one of the submaterial by its index in the submaterials array
  30750. * @param index The index to look the sub material at
  30751. * @returns The Material if the index has been defined
  30752. */
  30753. getSubMaterial(index: number): Nullable<Material>;
  30754. /**
  30755. * Get the list of active textures for the whole sub materials list.
  30756. * @returns All the textures that will be used during the rendering
  30757. */
  30758. getActiveTextures(): BaseTexture[];
  30759. /**
  30760. * Specifies if any sub-materials of this multi-material use a given texture.
  30761. * @param texture Defines the texture to check against this multi-material's sub-materials.
  30762. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  30763. */
  30764. hasTexture(texture: BaseTexture): boolean;
  30765. /**
  30766. * Gets the current class name of the material e.g. "MultiMaterial"
  30767. * Mainly use in serialization.
  30768. * @returns the class name
  30769. */
  30770. getClassName(): string;
  30771. /**
  30772. * Checks if the material is ready to render the requested sub mesh
  30773. * @param mesh Define the mesh the submesh belongs to
  30774. * @param subMesh Define the sub mesh to look readyness for
  30775. * @param useInstances Define whether or not the material is used with instances
  30776. * @returns true if ready, otherwise false
  30777. */
  30778. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30779. /**
  30780. * Clones the current material and its related sub materials
  30781. * @param name Define the name of the newly cloned material
  30782. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  30783. * @returns the cloned material
  30784. */
  30785. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  30786. /**
  30787. * Serializes the materials into a JSON representation.
  30788. * @returns the JSON representation
  30789. */
  30790. serialize(): any;
  30791. /**
  30792. * Dispose the material and release its associated resources
  30793. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  30794. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  30795. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  30796. */
  30797. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  30798. /**
  30799. * Creates a MultiMaterial from parsed MultiMaterial data.
  30800. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  30801. * @param scene defines the hosting scene
  30802. * @returns a new MultiMaterial
  30803. */
  30804. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  30805. }
  30806. }
  30807. declare module BABYLON {
  30808. /** @hidden */
  30809. export interface ICustomEffect {
  30810. effect: Effect;
  30811. defines: string;
  30812. }
  30813. /**
  30814. * Defines a subdivision inside a mesh
  30815. */
  30816. export class SubMesh implements ICullable {
  30817. /** the material index to use */
  30818. materialIndex: number;
  30819. /** vertex index start */
  30820. verticesStart: number;
  30821. /** vertices count */
  30822. verticesCount: number;
  30823. /** index start */
  30824. indexStart: number;
  30825. /** indices count */
  30826. indexCount: number;
  30827. /** @hidden */
  30828. _materialDefines: Nullable<MaterialDefines>;
  30829. /** @hidden */
  30830. _materialEffect: Nullable<Effect>;
  30831. /** @hidden */
  30832. _effectOverride: Nullable<Effect>;
  30833. private _customEffects;
  30834. /**
  30835. * Gets material defines used by the effect associated to the sub mesh
  30836. */
  30837. get materialDefines(): Nullable<MaterialDefines>;
  30838. /**
  30839. * Sets material defines used by the effect associated to the sub mesh
  30840. */
  30841. set materialDefines(defines: Nullable<MaterialDefines>);
  30842. /** @hidden */
  30843. _getCustomEffect(name: string, createIfNotExisting?: boolean): Nullable<ICustomEffect>;
  30844. /** @hidden */
  30845. _removeCustomEffect(name: string): void;
  30846. /**
  30847. * Gets associated effect
  30848. */
  30849. get effect(): Nullable<Effect>;
  30850. /**
  30851. * Sets associated effect (effect used to render this submesh)
  30852. * @param effect defines the effect to associate with
  30853. * @param defines defines the set of defines used to compile this effect
  30854. */
  30855. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  30856. /** @hidden */
  30857. _linesIndexCount: number;
  30858. private _mesh;
  30859. private _renderingMesh;
  30860. private _boundingInfo;
  30861. private _linesIndexBuffer;
  30862. /** @hidden */
  30863. _lastColliderWorldVertices: Nullable<Vector3[]>;
  30864. /** @hidden */
  30865. _trianglePlanes: Plane[];
  30866. /** @hidden */
  30867. _lastColliderTransformMatrix: Nullable<Matrix>;
  30868. /** @hidden */
  30869. _renderId: number;
  30870. /** @hidden */
  30871. _alphaIndex: number;
  30872. /** @hidden */
  30873. _distanceToCamera: number;
  30874. /** @hidden */
  30875. _id: number;
  30876. private _currentMaterial;
  30877. /**
  30878. * Add a new submesh to a mesh
  30879. * @param materialIndex defines the material index to use
  30880. * @param verticesStart defines vertex index start
  30881. * @param verticesCount defines vertices count
  30882. * @param indexStart defines index start
  30883. * @param indexCount defines indices count
  30884. * @param mesh defines the parent mesh
  30885. * @param renderingMesh defines an optional rendering mesh
  30886. * @param createBoundingBox defines if bounding box should be created for this submesh
  30887. * @returns the new submesh
  30888. */
  30889. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  30890. /**
  30891. * Creates a new submesh
  30892. * @param materialIndex defines the material index to use
  30893. * @param verticesStart defines vertex index start
  30894. * @param verticesCount defines vertices count
  30895. * @param indexStart defines index start
  30896. * @param indexCount defines indices count
  30897. * @param mesh defines the parent mesh
  30898. * @param renderingMesh defines an optional rendering mesh
  30899. * @param createBoundingBox defines if bounding box should be created for this submesh
  30900. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  30901. */
  30902. constructor(
  30903. /** the material index to use */
  30904. materialIndex: number,
  30905. /** vertex index start */
  30906. verticesStart: number,
  30907. /** vertices count */
  30908. verticesCount: number,
  30909. /** index start */
  30910. indexStart: number,
  30911. /** indices count */
  30912. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  30913. /**
  30914. * Returns true if this submesh covers the entire parent mesh
  30915. * @ignorenaming
  30916. */
  30917. get IsGlobal(): boolean;
  30918. /**
  30919. * Returns the submesh BoudingInfo object
  30920. * @returns current bounding info (or mesh's one if the submesh is global)
  30921. */
  30922. getBoundingInfo(): BoundingInfo;
  30923. /**
  30924. * Sets the submesh BoundingInfo
  30925. * @param boundingInfo defines the new bounding info to use
  30926. * @returns the SubMesh
  30927. */
  30928. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  30929. /**
  30930. * Returns the mesh of the current submesh
  30931. * @return the parent mesh
  30932. */
  30933. getMesh(): AbstractMesh;
  30934. /**
  30935. * Returns the rendering mesh of the submesh
  30936. * @returns the rendering mesh (could be different from parent mesh)
  30937. */
  30938. getRenderingMesh(): Mesh;
  30939. /**
  30940. * Returns the replacement mesh of the submesh
  30941. * @returns the replacement mesh (could be different from parent mesh)
  30942. */
  30943. getReplacementMesh(): Nullable<AbstractMesh>;
  30944. /**
  30945. * Returns the effective mesh of the submesh
  30946. * @returns the effective mesh (could be different from parent mesh)
  30947. */
  30948. getEffectiveMesh(): AbstractMesh;
  30949. /**
  30950. * Returns the submesh material
  30951. * @returns null or the current material
  30952. */
  30953. getMaterial(): Nullable<Material>;
  30954. private _IsMultiMaterial;
  30955. /**
  30956. * Sets a new updated BoundingInfo object to the submesh
  30957. * @param data defines an optional position array to use to determine the bounding info
  30958. * @returns the SubMesh
  30959. */
  30960. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30961. /** @hidden */
  30962. _checkCollision(collider: Collider): boolean;
  30963. /**
  30964. * Updates the submesh BoundingInfo
  30965. * @param world defines the world matrix to use to update the bounding info
  30966. * @returns the submesh
  30967. */
  30968. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30969. /**
  30970. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30971. * @param frustumPlanes defines the frustum planes
  30972. * @returns true if the submesh is intersecting with the frustum
  30973. */
  30974. isInFrustum(frustumPlanes: Plane[]): boolean;
  30975. /**
  30976. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30977. * @param frustumPlanes defines the frustum planes
  30978. * @returns true if the submesh is inside the frustum
  30979. */
  30980. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30981. /**
  30982. * Renders the submesh
  30983. * @param enableAlphaMode defines if alpha needs to be used
  30984. * @returns the submesh
  30985. */
  30986. render(enableAlphaMode: boolean): SubMesh;
  30987. /**
  30988. * @hidden
  30989. */
  30990. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30991. /**
  30992. * Checks if the submesh intersects with a ray
  30993. * @param ray defines the ray to test
  30994. * @returns true is the passed ray intersects the submesh bounding box
  30995. */
  30996. canIntersects(ray: Ray): boolean;
  30997. /**
  30998. * Intersects current submesh with a ray
  30999. * @param ray defines the ray to test
  31000. * @param positions defines mesh's positions array
  31001. * @param indices defines mesh's indices array
  31002. * @param fastCheck defines if the first intersection will be used (and not the closest)
  31003. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31004. * @returns intersection info or null if no intersection
  31005. */
  31006. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  31007. /** @hidden */
  31008. private _intersectLines;
  31009. /** @hidden */
  31010. private _intersectUnIndexedLines;
  31011. /** @hidden */
  31012. private _intersectTriangles;
  31013. /** @hidden */
  31014. private _intersectUnIndexedTriangles;
  31015. /** @hidden */
  31016. _rebuild(): void;
  31017. /**
  31018. * Creates a new submesh from the passed mesh
  31019. * @param newMesh defines the new hosting mesh
  31020. * @param newRenderingMesh defines an optional rendering mesh
  31021. * @returns the new submesh
  31022. */
  31023. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31024. /**
  31025. * Release associated resources
  31026. */
  31027. dispose(): void;
  31028. /**
  31029. * Gets the class name
  31030. * @returns the string "SubMesh".
  31031. */
  31032. getClassName(): string;
  31033. /**
  31034. * Creates a new submesh from indices data
  31035. * @param materialIndex the index of the main mesh material
  31036. * @param startIndex the index where to start the copy in the mesh indices array
  31037. * @param indexCount the number of indices to copy then from the startIndex
  31038. * @param mesh the main mesh to create the submesh from
  31039. * @param renderingMesh the optional rendering mesh
  31040. * @returns a new submesh
  31041. */
  31042. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31043. }
  31044. }
  31045. declare module BABYLON {
  31046. /**
  31047. * Class used to represent data loading progression
  31048. */
  31049. export class SceneLoaderFlags {
  31050. private static _ForceFullSceneLoadingForIncremental;
  31051. private static _ShowLoadingScreen;
  31052. private static _CleanBoneMatrixWeights;
  31053. private static _loggingLevel;
  31054. /**
  31055. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31056. */
  31057. static get ForceFullSceneLoadingForIncremental(): boolean;
  31058. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31059. /**
  31060. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31061. */
  31062. static get ShowLoadingScreen(): boolean;
  31063. static set ShowLoadingScreen(value: boolean);
  31064. /**
  31065. * Defines the current logging level (while loading the scene)
  31066. * @ignorenaming
  31067. */
  31068. static get loggingLevel(): number;
  31069. static set loggingLevel(value: number);
  31070. /**
  31071. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31072. */
  31073. static get CleanBoneMatrixWeights(): boolean;
  31074. static set CleanBoneMatrixWeights(value: boolean);
  31075. }
  31076. }
  31077. declare module BABYLON {
  31078. /**
  31079. * Class used to store geometry data (vertex buffers + index buffer)
  31080. */
  31081. export class Geometry implements IGetSetVerticesData {
  31082. /**
  31083. * Gets or sets the ID of the geometry
  31084. */
  31085. id: string;
  31086. /**
  31087. * Gets or sets the unique ID of the geometry
  31088. */
  31089. uniqueId: number;
  31090. /**
  31091. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31092. */
  31093. delayLoadState: number;
  31094. /**
  31095. * Gets the file containing the data to load when running in delay load state
  31096. */
  31097. delayLoadingFile: Nullable<string>;
  31098. /**
  31099. * Callback called when the geometry is updated
  31100. */
  31101. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31102. private _scene;
  31103. private _engine;
  31104. private _meshes;
  31105. private _totalVertices;
  31106. /** @hidden */
  31107. _indices: IndicesArray;
  31108. /** @hidden */
  31109. _vertexBuffers: {
  31110. [key: string]: VertexBuffer;
  31111. };
  31112. private _isDisposed;
  31113. private _extend;
  31114. private _boundingBias;
  31115. /** @hidden */
  31116. _delayInfo: Array<string>;
  31117. private _indexBuffer;
  31118. private _indexBufferIsUpdatable;
  31119. /** @hidden */
  31120. _boundingInfo: Nullable<BoundingInfo>;
  31121. /** @hidden */
  31122. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31123. /** @hidden */
  31124. _softwareSkinningFrameId: number;
  31125. private _vertexArrayObjects;
  31126. private _updatable;
  31127. /** @hidden */
  31128. _positions: Nullable<Vector3[]>;
  31129. private _positionsCache;
  31130. /**
  31131. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  31132. */
  31133. get boundingBias(): Vector2;
  31134. /**
  31135. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  31136. */
  31137. set boundingBias(value: Vector2);
  31138. /**
  31139. * Static function used to attach a new empty geometry to a mesh
  31140. * @param mesh defines the mesh to attach the geometry to
  31141. * @returns the new Geometry
  31142. */
  31143. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31144. /** Get the list of meshes using this geometry */
  31145. get meshes(): Mesh[];
  31146. /**
  31147. * If set to true (false by defaut), the bounding info applied to the meshes sharing this geometry will be the bounding info defined at the class level
  31148. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31149. */
  31150. useBoundingInfoFromGeometry: boolean;
  31151. /**
  31152. * Creates a new geometry
  31153. * @param id defines the unique ID
  31154. * @param scene defines the hosting scene
  31155. * @param vertexData defines the VertexData used to get geometry data
  31156. * @param updatable defines if geometry must be updatable (false by default)
  31157. * @param mesh defines the mesh that will be associated with the geometry
  31158. */
  31159. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31160. /**
  31161. * Gets the current extend of the geometry
  31162. */
  31163. get extend(): {
  31164. minimum: Vector3;
  31165. maximum: Vector3;
  31166. };
  31167. /**
  31168. * Gets the hosting scene
  31169. * @returns the hosting Scene
  31170. */
  31171. getScene(): Scene;
  31172. /**
  31173. * Gets the hosting engine
  31174. * @returns the hosting Engine
  31175. */
  31176. getEngine(): Engine;
  31177. /**
  31178. * Defines if the geometry is ready to use
  31179. * @returns true if the geometry is ready to be used
  31180. */
  31181. isReady(): boolean;
  31182. /**
  31183. * Gets a value indicating that the geometry should not be serialized
  31184. */
  31185. get doNotSerialize(): boolean;
  31186. /** @hidden */
  31187. _rebuild(): void;
  31188. /**
  31189. * Affects all geometry data in one call
  31190. * @param vertexData defines the geometry data
  31191. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31192. */
  31193. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31194. /**
  31195. * Set specific vertex data
  31196. * @param kind defines the data kind (Position, normal, etc...)
  31197. * @param data defines the vertex data to use
  31198. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31199. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31200. */
  31201. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31202. /**
  31203. * Removes a specific vertex data
  31204. * @param kind defines the data kind (Position, normal, etc...)
  31205. */
  31206. removeVerticesData(kind: string): void;
  31207. /**
  31208. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31209. * @param buffer defines the vertex buffer to use
  31210. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31211. */
  31212. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31213. /**
  31214. * Update a specific vertex buffer
  31215. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31216. * It will do nothing if the buffer is not updatable
  31217. * @param kind defines the data kind (Position, normal, etc...)
  31218. * @param data defines the data to use
  31219. * @param offset defines the offset in the target buffer where to store the data
  31220. * @param useBytes set to true if the offset is in bytes
  31221. */
  31222. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31223. /**
  31224. * Update a specific vertex buffer
  31225. * This function will create a new buffer if the current one is not updatable
  31226. * @param kind defines the data kind (Position, normal, etc...)
  31227. * @param data defines the data to use
  31228. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31229. */
  31230. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31231. private _updateBoundingInfo;
  31232. /** @hidden */
  31233. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  31234. /**
  31235. * Gets total number of vertices
  31236. * @returns the total number of vertices
  31237. */
  31238. getTotalVertices(): number;
  31239. /**
  31240. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31241. * @param kind defines the data kind (Position, normal, etc...)
  31242. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31243. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31244. * @returns a float array containing vertex data
  31245. */
  31246. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31247. /**
  31248. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31249. * @param kind defines the data kind (Position, normal, etc...)
  31250. * @returns true if the vertex buffer with the specified kind is updatable
  31251. */
  31252. isVertexBufferUpdatable(kind: string): boolean;
  31253. /**
  31254. * Gets a specific vertex buffer
  31255. * @param kind defines the data kind (Position, normal, etc...)
  31256. * @returns a VertexBuffer
  31257. */
  31258. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31259. /**
  31260. * Returns all vertex buffers
  31261. * @return an object holding all vertex buffers indexed by kind
  31262. */
  31263. getVertexBuffers(): Nullable<{
  31264. [key: string]: VertexBuffer;
  31265. }>;
  31266. /**
  31267. * Gets a boolean indicating if specific vertex buffer is present
  31268. * @param kind defines the data kind (Position, normal, etc...)
  31269. * @returns true if data is present
  31270. */
  31271. isVerticesDataPresent(kind: string): boolean;
  31272. /**
  31273. * Gets a list of all attached data kinds (Position, normal, etc...)
  31274. * @returns a list of string containing all kinds
  31275. */
  31276. getVerticesDataKinds(): string[];
  31277. /**
  31278. * Update index buffer
  31279. * @param indices defines the indices to store in the index buffer
  31280. * @param offset defines the offset in the target buffer where to store the data
  31281. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  31282. */
  31283. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31284. /**
  31285. * Creates a new index buffer
  31286. * @param indices defines the indices to store in the index buffer
  31287. * @param totalVertices defines the total number of vertices (could be null)
  31288. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31289. */
  31290. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31291. /**
  31292. * Return the total number of indices
  31293. * @returns the total number of indices
  31294. */
  31295. getTotalIndices(): number;
  31296. /**
  31297. * Gets the index buffer array
  31298. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31299. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31300. * @returns the index buffer array
  31301. */
  31302. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31303. /**
  31304. * Gets the index buffer
  31305. * @return the index buffer
  31306. */
  31307. getIndexBuffer(): Nullable<DataBuffer>;
  31308. /** @hidden */
  31309. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31310. /**
  31311. * Release the associated resources for a specific mesh
  31312. * @param mesh defines the source mesh
  31313. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31314. */
  31315. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31316. /**
  31317. * Apply current geometry to a given mesh
  31318. * @param mesh defines the mesh to apply geometry to
  31319. */
  31320. applyToMesh(mesh: Mesh): void;
  31321. private _updateExtend;
  31322. private _applyToMesh;
  31323. private notifyUpdate;
  31324. /**
  31325. * Load the geometry if it was flagged as delay loaded
  31326. * @param scene defines the hosting scene
  31327. * @param onLoaded defines a callback called when the geometry is loaded
  31328. */
  31329. load(scene: Scene, onLoaded?: () => void): void;
  31330. private _queueLoad;
  31331. /**
  31332. * Invert the geometry to move from a right handed system to a left handed one.
  31333. */
  31334. toLeftHanded(): void;
  31335. /** @hidden */
  31336. _resetPointsArrayCache(): void;
  31337. /** @hidden */
  31338. _generatePointsArray(): boolean;
  31339. /**
  31340. * Gets a value indicating if the geometry is disposed
  31341. * @returns true if the geometry was disposed
  31342. */
  31343. isDisposed(): boolean;
  31344. private _disposeVertexArrayObjects;
  31345. /**
  31346. * Free all associated resources
  31347. */
  31348. dispose(): void;
  31349. /**
  31350. * Clone the current geometry into a new geometry
  31351. * @param id defines the unique ID of the new geometry
  31352. * @returns a new geometry object
  31353. */
  31354. copy(id: string): Geometry;
  31355. /**
  31356. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31357. * @return a JSON representation of the current geometry data (without the vertices data)
  31358. */
  31359. serialize(): any;
  31360. private toNumberArray;
  31361. /**
  31362. * Serialize all vertices data into a JSON oject
  31363. * @returns a JSON representation of the current geometry data
  31364. */
  31365. serializeVerticeData(): any;
  31366. /**
  31367. * Extracts a clone of a mesh geometry
  31368. * @param mesh defines the source mesh
  31369. * @param id defines the unique ID of the new geometry object
  31370. * @returns the new geometry object
  31371. */
  31372. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31373. /**
  31374. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31375. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31376. * Be aware Math.random() could cause collisions, but:
  31377. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  31378. * @returns a string containing a new GUID
  31379. */
  31380. static RandomId(): string;
  31381. /** @hidden */
  31382. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31383. private static _CleanMatricesWeights;
  31384. /**
  31385. * Create a new geometry from persisted data (Using .babylon file format)
  31386. * @param parsedVertexData defines the persisted data
  31387. * @param scene defines the hosting scene
  31388. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31389. * @returns the new geometry object
  31390. */
  31391. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31392. }
  31393. }
  31394. declare module BABYLON {
  31395. /**
  31396. * Defines a target to use with MorphTargetManager
  31397. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31398. */
  31399. export class MorphTarget implements IAnimatable {
  31400. /** defines the name of the target */
  31401. name: string;
  31402. /**
  31403. * Gets or sets the list of animations
  31404. */
  31405. animations: Animation[];
  31406. private _scene;
  31407. private _positions;
  31408. private _normals;
  31409. private _tangents;
  31410. private _uvs;
  31411. private _influence;
  31412. private _uniqueId;
  31413. /**
  31414. * Observable raised when the influence changes
  31415. */
  31416. onInfluenceChanged: Observable<boolean>;
  31417. /** @hidden */
  31418. _onDataLayoutChanged: Observable<void>;
  31419. /**
  31420. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  31421. */
  31422. get influence(): number;
  31423. set influence(influence: number);
  31424. /**
  31425. * Gets or sets the id of the morph Target
  31426. */
  31427. id: string;
  31428. private _animationPropertiesOverride;
  31429. /**
  31430. * Gets or sets the animation properties override
  31431. */
  31432. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31433. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31434. /**
  31435. * Creates a new MorphTarget
  31436. * @param name defines the name of the target
  31437. * @param influence defines the influence to use
  31438. * @param scene defines the scene the morphtarget belongs to
  31439. */
  31440. constructor(
  31441. /** defines the name of the target */
  31442. name: string, influence?: number, scene?: Nullable<Scene>);
  31443. /**
  31444. * Gets the unique ID of this manager
  31445. */
  31446. get uniqueId(): number;
  31447. /**
  31448. * Gets a boolean defining if the target contains position data
  31449. */
  31450. get hasPositions(): boolean;
  31451. /**
  31452. * Gets a boolean defining if the target contains normal data
  31453. */
  31454. get hasNormals(): boolean;
  31455. /**
  31456. * Gets a boolean defining if the target contains tangent data
  31457. */
  31458. get hasTangents(): boolean;
  31459. /**
  31460. * Gets a boolean defining if the target contains texture coordinates data
  31461. */
  31462. get hasUVs(): boolean;
  31463. /**
  31464. * Affects position data to this target
  31465. * @param data defines the position data to use
  31466. */
  31467. setPositions(data: Nullable<FloatArray>): void;
  31468. /**
  31469. * Gets the position data stored in this target
  31470. * @returns a FloatArray containing the position data (or null if not present)
  31471. */
  31472. getPositions(): Nullable<FloatArray>;
  31473. /**
  31474. * Affects normal data to this target
  31475. * @param data defines the normal data to use
  31476. */
  31477. setNormals(data: Nullable<FloatArray>): void;
  31478. /**
  31479. * Gets the normal data stored in this target
  31480. * @returns a FloatArray containing the normal data (or null if not present)
  31481. */
  31482. getNormals(): Nullable<FloatArray>;
  31483. /**
  31484. * Affects tangent data to this target
  31485. * @param data defines the tangent data to use
  31486. */
  31487. setTangents(data: Nullable<FloatArray>): void;
  31488. /**
  31489. * Gets the tangent data stored in this target
  31490. * @returns a FloatArray containing the tangent data (or null if not present)
  31491. */
  31492. getTangents(): Nullable<FloatArray>;
  31493. /**
  31494. * Affects texture coordinates data to this target
  31495. * @param data defines the texture coordinates data to use
  31496. */
  31497. setUVs(data: Nullable<FloatArray>): void;
  31498. /**
  31499. * Gets the texture coordinates data stored in this target
  31500. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  31501. */
  31502. getUVs(): Nullable<FloatArray>;
  31503. /**
  31504. * Clone the current target
  31505. * @returns a new MorphTarget
  31506. */
  31507. clone(): MorphTarget;
  31508. /**
  31509. * Serializes the current target into a Serialization object
  31510. * @returns the serialized object
  31511. */
  31512. serialize(): any;
  31513. /**
  31514. * Returns the string "MorphTarget"
  31515. * @returns "MorphTarget"
  31516. */
  31517. getClassName(): string;
  31518. /**
  31519. * Creates a new target from serialized data
  31520. * @param serializationObject defines the serialized data to use
  31521. * @returns a new MorphTarget
  31522. */
  31523. static Parse(serializationObject: any): MorphTarget;
  31524. /**
  31525. * Creates a MorphTarget from mesh data
  31526. * @param mesh defines the source mesh
  31527. * @param name defines the name to use for the new target
  31528. * @param influence defines the influence to attach to the target
  31529. * @returns a new MorphTarget
  31530. */
  31531. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  31532. }
  31533. }
  31534. declare module BABYLON {
  31535. /**
  31536. * This class is used to deform meshes using morphing between different targets
  31537. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31538. */
  31539. export class MorphTargetManager {
  31540. private _targets;
  31541. private _targetInfluenceChangedObservers;
  31542. private _targetDataLayoutChangedObservers;
  31543. private _activeTargets;
  31544. private _scene;
  31545. private _influences;
  31546. private _supportsNormals;
  31547. private _supportsTangents;
  31548. private _supportsUVs;
  31549. private _vertexCount;
  31550. private _uniqueId;
  31551. private _tempInfluences;
  31552. /**
  31553. * Gets or sets a boolean indicating if normals must be morphed
  31554. */
  31555. enableNormalMorphing: boolean;
  31556. /**
  31557. * Gets or sets a boolean indicating if tangents must be morphed
  31558. */
  31559. enableTangentMorphing: boolean;
  31560. /**
  31561. * Gets or sets a boolean indicating if UV must be morphed
  31562. */
  31563. enableUVMorphing: boolean;
  31564. /**
  31565. * Creates a new MorphTargetManager
  31566. * @param scene defines the current scene
  31567. */
  31568. constructor(scene?: Nullable<Scene>);
  31569. /**
  31570. * Gets the unique ID of this manager
  31571. */
  31572. get uniqueId(): number;
  31573. /**
  31574. * Gets the number of vertices handled by this manager
  31575. */
  31576. get vertexCount(): number;
  31577. /**
  31578. * Gets a boolean indicating if this manager supports morphing of normals
  31579. */
  31580. get supportsNormals(): boolean;
  31581. /**
  31582. * Gets a boolean indicating if this manager supports morphing of tangents
  31583. */
  31584. get supportsTangents(): boolean;
  31585. /**
  31586. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  31587. */
  31588. get supportsUVs(): boolean;
  31589. /**
  31590. * Gets the number of targets stored in this manager
  31591. */
  31592. get numTargets(): number;
  31593. /**
  31594. * Gets the number of influencers (ie. the number of targets with influences > 0)
  31595. */
  31596. get numInfluencers(): number;
  31597. /**
  31598. * Gets the list of influences (one per target)
  31599. */
  31600. get influences(): Float32Array;
  31601. /**
  31602. * Gets the active target at specified index. An active target is a target with an influence > 0
  31603. * @param index defines the index to check
  31604. * @returns the requested target
  31605. */
  31606. getActiveTarget(index: number): MorphTarget;
  31607. /**
  31608. * Gets the target at specified index
  31609. * @param index defines the index to check
  31610. * @returns the requested target
  31611. */
  31612. getTarget(index: number): MorphTarget;
  31613. /**
  31614. * Add a new target to this manager
  31615. * @param target defines the target to add
  31616. */
  31617. addTarget(target: MorphTarget): void;
  31618. /**
  31619. * Removes a target from the manager
  31620. * @param target defines the target to remove
  31621. */
  31622. removeTarget(target: MorphTarget): void;
  31623. /**
  31624. * Clone the current manager
  31625. * @returns a new MorphTargetManager
  31626. */
  31627. clone(): MorphTargetManager;
  31628. /**
  31629. * Serializes the current manager into a Serialization object
  31630. * @returns the serialized object
  31631. */
  31632. serialize(): any;
  31633. private _syncActiveTargets;
  31634. /**
  31635. * Syncrhonize the targets with all the meshes using this morph target manager
  31636. */
  31637. synchronize(): void;
  31638. /**
  31639. * Creates a new MorphTargetManager from serialized data
  31640. * @param serializationObject defines the serialized data
  31641. * @param scene defines the hosting scene
  31642. * @returns the new MorphTargetManager
  31643. */
  31644. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  31645. }
  31646. }
  31647. declare module BABYLON {
  31648. /**
  31649. * Class used to represent a specific level of detail of a mesh
  31650. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  31651. */
  31652. export class MeshLODLevel {
  31653. /** Defines the distance where this level should start being displayed */
  31654. distance: number;
  31655. /** Defines the mesh to use to render this level */
  31656. mesh: Nullable<Mesh>;
  31657. /**
  31658. * Creates a new LOD level
  31659. * @param distance defines the distance where this level should star being displayed
  31660. * @param mesh defines the mesh to use to render this level
  31661. */
  31662. constructor(
  31663. /** Defines the distance where this level should start being displayed */
  31664. distance: number,
  31665. /** Defines the mesh to use to render this level */
  31666. mesh: Nullable<Mesh>);
  31667. }
  31668. }
  31669. declare module BABYLON {
  31670. /**
  31671. * Helper class used to generate a canvas to manipulate images
  31672. */
  31673. export class CanvasGenerator {
  31674. /**
  31675. * Create a new canvas (or offscreen canvas depending on the context)
  31676. * @param width defines the expected width
  31677. * @param height defines the expected height
  31678. * @return a new canvas or offscreen canvas
  31679. */
  31680. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  31681. }
  31682. }
  31683. declare module BABYLON {
  31684. /**
  31685. * Mesh representing the gorund
  31686. */
  31687. export class GroundMesh extends Mesh {
  31688. /** If octree should be generated */
  31689. generateOctree: boolean;
  31690. private _heightQuads;
  31691. /** @hidden */
  31692. _subdivisionsX: number;
  31693. /** @hidden */
  31694. _subdivisionsY: number;
  31695. /** @hidden */
  31696. _width: number;
  31697. /** @hidden */
  31698. _height: number;
  31699. /** @hidden */
  31700. _minX: number;
  31701. /** @hidden */
  31702. _maxX: number;
  31703. /** @hidden */
  31704. _minZ: number;
  31705. /** @hidden */
  31706. _maxZ: number;
  31707. constructor(name: string, scene: Scene);
  31708. /**
  31709. * "GroundMesh"
  31710. * @returns "GroundMesh"
  31711. */
  31712. getClassName(): string;
  31713. /**
  31714. * The minimum of x and y subdivisions
  31715. */
  31716. get subdivisions(): number;
  31717. /**
  31718. * X subdivisions
  31719. */
  31720. get subdivisionsX(): number;
  31721. /**
  31722. * Y subdivisions
  31723. */
  31724. get subdivisionsY(): number;
  31725. /**
  31726. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  31727. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  31728. * @param chunksCount the number of subdivisions for x and y
  31729. * @param octreeBlocksSize (Default: 32)
  31730. */
  31731. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  31732. /**
  31733. * Returns a height (y) value in the Worl system :
  31734. * the ground altitude at the coordinates (x, z) expressed in the World system.
  31735. * @param x x coordinate
  31736. * @param z z coordinate
  31737. * @returns the ground y position if (x, z) are outside the ground surface.
  31738. */
  31739. getHeightAtCoordinates(x: number, z: number): number;
  31740. /**
  31741. * Returns a normalized vector (Vector3) orthogonal to the ground
  31742. * at the ground coordinates (x, z) expressed in the World system.
  31743. * @param x x coordinate
  31744. * @param z z coordinate
  31745. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  31746. */
  31747. getNormalAtCoordinates(x: number, z: number): Vector3;
  31748. /**
  31749. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  31750. * at the ground coordinates (x, z) expressed in the World system.
  31751. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  31752. * @param x x coordinate
  31753. * @param z z coordinate
  31754. * @param ref vector to store the result
  31755. * @returns the GroundMesh.
  31756. */
  31757. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  31758. /**
  31759. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  31760. * if the ground has been updated.
  31761. * This can be used in the render loop.
  31762. * @returns the GroundMesh.
  31763. */
  31764. updateCoordinateHeights(): GroundMesh;
  31765. private _getFacetAt;
  31766. private _initHeightQuads;
  31767. private _computeHeightQuads;
  31768. /**
  31769. * Serializes this ground mesh
  31770. * @param serializationObject object to write serialization to
  31771. */
  31772. serialize(serializationObject: any): void;
  31773. /**
  31774. * Parses a serialized ground mesh
  31775. * @param parsedMesh the serialized mesh
  31776. * @param scene the scene to create the ground mesh in
  31777. * @returns the created ground mesh
  31778. */
  31779. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31780. }
  31781. }
  31782. declare module BABYLON {
  31783. /**
  31784. * Interface for Physics-Joint data
  31785. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31786. */
  31787. export interface PhysicsJointData {
  31788. /**
  31789. * The main pivot of the joint
  31790. */
  31791. mainPivot?: Vector3;
  31792. /**
  31793. * The connected pivot of the joint
  31794. */
  31795. connectedPivot?: Vector3;
  31796. /**
  31797. * The main axis of the joint
  31798. */
  31799. mainAxis?: Vector3;
  31800. /**
  31801. * The connected axis of the joint
  31802. */
  31803. connectedAxis?: Vector3;
  31804. /**
  31805. * The collision of the joint
  31806. */
  31807. collision?: boolean;
  31808. /**
  31809. * Native Oimo/Cannon/Energy data
  31810. */
  31811. nativeParams?: any;
  31812. }
  31813. /**
  31814. * This is a holder class for the physics joint created by the physics plugin
  31815. * It holds a set of functions to control the underlying joint
  31816. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31817. */
  31818. export class PhysicsJoint {
  31819. /**
  31820. * The type of the physics joint
  31821. */
  31822. type: number;
  31823. /**
  31824. * The data for the physics joint
  31825. */
  31826. jointData: PhysicsJointData;
  31827. private _physicsJoint;
  31828. protected _physicsPlugin: IPhysicsEnginePlugin;
  31829. /**
  31830. * Initializes the physics joint
  31831. * @param type The type of the physics joint
  31832. * @param jointData The data for the physics joint
  31833. */
  31834. constructor(
  31835. /**
  31836. * The type of the physics joint
  31837. */
  31838. type: number,
  31839. /**
  31840. * The data for the physics joint
  31841. */
  31842. jointData: PhysicsJointData);
  31843. /**
  31844. * Gets the physics joint
  31845. */
  31846. get physicsJoint(): any;
  31847. /**
  31848. * Sets the physics joint
  31849. */
  31850. set physicsJoint(newJoint: any);
  31851. /**
  31852. * Sets the physics plugin
  31853. */
  31854. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31855. /**
  31856. * Execute a function that is physics-plugin specific.
  31857. * @param {Function} func the function that will be executed.
  31858. * It accepts two parameters: the physics world and the physics joint
  31859. */
  31860. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31861. /**
  31862. * Distance-Joint type
  31863. */
  31864. static DistanceJoint: number;
  31865. /**
  31866. * Hinge-Joint type
  31867. */
  31868. static HingeJoint: number;
  31869. /**
  31870. * Ball-and-Socket joint type
  31871. */
  31872. static BallAndSocketJoint: number;
  31873. /**
  31874. * Wheel-Joint type
  31875. */
  31876. static WheelJoint: number;
  31877. /**
  31878. * Slider-Joint type
  31879. */
  31880. static SliderJoint: number;
  31881. /**
  31882. * Prismatic-Joint type
  31883. */
  31884. static PrismaticJoint: number;
  31885. /**
  31886. * Universal-Joint type
  31887. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31888. */
  31889. static UniversalJoint: number;
  31890. /**
  31891. * Hinge-Joint 2 type
  31892. */
  31893. static Hinge2Joint: number;
  31894. /**
  31895. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31896. */
  31897. static PointToPointJoint: number;
  31898. /**
  31899. * Spring-Joint type
  31900. */
  31901. static SpringJoint: number;
  31902. /**
  31903. * Lock-Joint type
  31904. */
  31905. static LockJoint: number;
  31906. }
  31907. /**
  31908. * A class representing a physics distance joint
  31909. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31910. */
  31911. export class DistanceJoint extends PhysicsJoint {
  31912. /**
  31913. *
  31914. * @param jointData The data for the Distance-Joint
  31915. */
  31916. constructor(jointData: DistanceJointData);
  31917. /**
  31918. * Update the predefined distance.
  31919. * @param maxDistance The maximum preferred distance
  31920. * @param minDistance The minimum preferred distance
  31921. */
  31922. updateDistance(maxDistance: number, minDistance?: number): void;
  31923. }
  31924. /**
  31925. * Represents a Motor-Enabled Joint
  31926. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31927. */
  31928. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31929. /**
  31930. * Initializes the Motor-Enabled Joint
  31931. * @param type The type of the joint
  31932. * @param jointData The physica joint data for the joint
  31933. */
  31934. constructor(type: number, jointData: PhysicsJointData);
  31935. /**
  31936. * Set the motor values.
  31937. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31938. * @param force the force to apply
  31939. * @param maxForce max force for this motor.
  31940. */
  31941. setMotor(force?: number, maxForce?: number): void;
  31942. /**
  31943. * Set the motor's limits.
  31944. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31945. * @param upperLimit The upper limit of the motor
  31946. * @param lowerLimit The lower limit of the motor
  31947. */
  31948. setLimit(upperLimit: number, lowerLimit?: number): void;
  31949. }
  31950. /**
  31951. * This class represents a single physics Hinge-Joint
  31952. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31953. */
  31954. export class HingeJoint extends MotorEnabledJoint {
  31955. /**
  31956. * Initializes the Hinge-Joint
  31957. * @param jointData The joint data for the Hinge-Joint
  31958. */
  31959. constructor(jointData: PhysicsJointData);
  31960. /**
  31961. * Set the motor values.
  31962. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31963. * @param {number} force the force to apply
  31964. * @param {number} maxForce max force for this motor.
  31965. */
  31966. setMotor(force?: number, maxForce?: number): void;
  31967. /**
  31968. * Set the motor's limits.
  31969. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31970. * @param upperLimit The upper limit of the motor
  31971. * @param lowerLimit The lower limit of the motor
  31972. */
  31973. setLimit(upperLimit: number, lowerLimit?: number): void;
  31974. }
  31975. /**
  31976. * This class represents a dual hinge physics joint (same as wheel joint)
  31977. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31978. */
  31979. export class Hinge2Joint extends MotorEnabledJoint {
  31980. /**
  31981. * Initializes the Hinge2-Joint
  31982. * @param jointData The joint data for the Hinge2-Joint
  31983. */
  31984. constructor(jointData: PhysicsJointData);
  31985. /**
  31986. * Set the motor values.
  31987. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31988. * @param {number} targetSpeed the speed the motor is to reach
  31989. * @param {number} maxForce max force for this motor.
  31990. * @param {motorIndex} the motor's index, 0 or 1.
  31991. */
  31992. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  31993. /**
  31994. * Set the motor limits.
  31995. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31996. * @param {number} upperLimit the upper limit
  31997. * @param {number} lowerLimit lower limit
  31998. * @param {motorIndex} the motor's index, 0 or 1.
  31999. */
  32000. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32001. }
  32002. /**
  32003. * Interface for a motor enabled joint
  32004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32005. */
  32006. export interface IMotorEnabledJoint {
  32007. /**
  32008. * Physics joint
  32009. */
  32010. physicsJoint: any;
  32011. /**
  32012. * Sets the motor of the motor-enabled joint
  32013. * @param force The force of the motor
  32014. * @param maxForce The maximum force of the motor
  32015. * @param motorIndex The index of the motor
  32016. */
  32017. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32018. /**
  32019. * Sets the limit of the motor
  32020. * @param upperLimit The upper limit of the motor
  32021. * @param lowerLimit The lower limit of the motor
  32022. * @param motorIndex The index of the motor
  32023. */
  32024. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32025. }
  32026. /**
  32027. * Joint data for a Distance-Joint
  32028. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32029. */
  32030. export interface DistanceJointData extends PhysicsJointData {
  32031. /**
  32032. * Max distance the 2 joint objects can be apart
  32033. */
  32034. maxDistance: number;
  32035. }
  32036. /**
  32037. * Joint data from a spring joint
  32038. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32039. */
  32040. export interface SpringJointData extends PhysicsJointData {
  32041. /**
  32042. * Length of the spring
  32043. */
  32044. length: number;
  32045. /**
  32046. * Stiffness of the spring
  32047. */
  32048. stiffness: number;
  32049. /**
  32050. * Damping of the spring
  32051. */
  32052. damping: number;
  32053. /** this callback will be called when applying the force to the impostors. */
  32054. forceApplicationCallback: () => void;
  32055. }
  32056. }
  32057. declare module BABYLON {
  32058. /**
  32059. * Holds the data for the raycast result
  32060. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32061. */
  32062. export class PhysicsRaycastResult {
  32063. private _hasHit;
  32064. private _hitDistance;
  32065. private _hitNormalWorld;
  32066. private _hitPointWorld;
  32067. private _rayFromWorld;
  32068. private _rayToWorld;
  32069. /**
  32070. * Gets if there was a hit
  32071. */
  32072. get hasHit(): boolean;
  32073. /**
  32074. * Gets the distance from the hit
  32075. */
  32076. get hitDistance(): number;
  32077. /**
  32078. * Gets the hit normal/direction in the world
  32079. */
  32080. get hitNormalWorld(): Vector3;
  32081. /**
  32082. * Gets the hit point in the world
  32083. */
  32084. get hitPointWorld(): Vector3;
  32085. /**
  32086. * Gets the ray "start point" of the ray in the world
  32087. */
  32088. get rayFromWorld(): Vector3;
  32089. /**
  32090. * Gets the ray "end point" of the ray in the world
  32091. */
  32092. get rayToWorld(): Vector3;
  32093. /**
  32094. * Sets the hit data (normal & point in world space)
  32095. * @param hitNormalWorld defines the normal in world space
  32096. * @param hitPointWorld defines the point in world space
  32097. */
  32098. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32099. /**
  32100. * Sets the distance from the start point to the hit point
  32101. * @param distance
  32102. */
  32103. setHitDistance(distance: number): void;
  32104. /**
  32105. * Calculates the distance manually
  32106. */
  32107. calculateHitDistance(): void;
  32108. /**
  32109. * Resets all the values to default
  32110. * @param from The from point on world space
  32111. * @param to The to point on world space
  32112. */
  32113. reset(from?: Vector3, to?: Vector3): void;
  32114. }
  32115. /**
  32116. * Interface for the size containing width and height
  32117. */
  32118. interface IXYZ {
  32119. /**
  32120. * X
  32121. */
  32122. x: number;
  32123. /**
  32124. * Y
  32125. */
  32126. y: number;
  32127. /**
  32128. * Z
  32129. */
  32130. z: number;
  32131. }
  32132. }
  32133. declare module BABYLON {
  32134. /**
  32135. * Interface used to describe a physics joint
  32136. */
  32137. export interface PhysicsImpostorJoint {
  32138. /** Defines the main impostor to which the joint is linked */
  32139. mainImpostor: PhysicsImpostor;
  32140. /** Defines the impostor that is connected to the main impostor using this joint */
  32141. connectedImpostor: PhysicsImpostor;
  32142. /** Defines the joint itself */
  32143. joint: PhysicsJoint;
  32144. }
  32145. /** @hidden */
  32146. export interface IPhysicsEnginePlugin {
  32147. world: any;
  32148. name: string;
  32149. setGravity(gravity: Vector3): void;
  32150. setTimeStep(timeStep: number): void;
  32151. getTimeStep(): number;
  32152. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32153. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32154. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32155. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32156. removePhysicsBody(impostor: PhysicsImpostor): void;
  32157. generateJoint(joint: PhysicsImpostorJoint): void;
  32158. removeJoint(joint: PhysicsImpostorJoint): void;
  32159. isSupported(): boolean;
  32160. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32161. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32162. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32163. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32164. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32165. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32166. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32167. getBodyMass(impostor: PhysicsImpostor): number;
  32168. getBodyFriction(impostor: PhysicsImpostor): number;
  32169. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32170. getBodyRestitution(impostor: PhysicsImpostor): number;
  32171. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32172. getBodyPressure?(impostor: PhysicsImpostor): number;
  32173. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32174. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32175. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32176. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32177. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32178. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32179. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32180. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32181. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32182. sleepBody(impostor: PhysicsImpostor): void;
  32183. wakeUpBody(impostor: PhysicsImpostor): void;
  32184. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32185. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32186. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32187. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32188. getRadius(impostor: PhysicsImpostor): number;
  32189. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32190. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32191. dispose(): void;
  32192. }
  32193. /**
  32194. * Interface used to define a physics engine
  32195. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32196. */
  32197. export interface IPhysicsEngine {
  32198. /**
  32199. * Gets the gravity vector used by the simulation
  32200. */
  32201. gravity: Vector3;
  32202. /**
  32203. * Sets the gravity vector used by the simulation
  32204. * @param gravity defines the gravity vector to use
  32205. */
  32206. setGravity(gravity: Vector3): void;
  32207. /**
  32208. * Set the time step of the physics engine.
  32209. * Default is 1/60.
  32210. * To slow it down, enter 1/600 for example.
  32211. * To speed it up, 1/30
  32212. * @param newTimeStep the new timestep to apply to this world.
  32213. */
  32214. setTimeStep(newTimeStep: number): void;
  32215. /**
  32216. * Get the time step of the physics engine.
  32217. * @returns the current time step
  32218. */
  32219. getTimeStep(): number;
  32220. /**
  32221. * Set the sub time step of the physics engine.
  32222. * Default is 0 meaning there is no sub steps
  32223. * To increase physics resolution precision, set a small value (like 1 ms)
  32224. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32225. */
  32226. setSubTimeStep(subTimeStep: number): void;
  32227. /**
  32228. * Get the sub time step of the physics engine.
  32229. * @returns the current sub time step
  32230. */
  32231. getSubTimeStep(): number;
  32232. /**
  32233. * Release all resources
  32234. */
  32235. dispose(): void;
  32236. /**
  32237. * Gets the name of the current physics plugin
  32238. * @returns the name of the plugin
  32239. */
  32240. getPhysicsPluginName(): string;
  32241. /**
  32242. * Adding a new impostor for the impostor tracking.
  32243. * This will be done by the impostor itself.
  32244. * @param impostor the impostor to add
  32245. */
  32246. addImpostor(impostor: PhysicsImpostor): void;
  32247. /**
  32248. * Remove an impostor from the engine.
  32249. * This impostor and its mesh will not longer be updated by the physics engine.
  32250. * @param impostor the impostor to remove
  32251. */
  32252. removeImpostor(impostor: PhysicsImpostor): void;
  32253. /**
  32254. * Add a joint to the physics engine
  32255. * @param mainImpostor defines the main impostor to which the joint is added.
  32256. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32257. * @param joint defines the joint that will connect both impostors.
  32258. */
  32259. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32260. /**
  32261. * Removes a joint from the simulation
  32262. * @param mainImpostor defines the impostor used with the joint
  32263. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32264. * @param joint defines the joint to remove
  32265. */
  32266. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32267. /**
  32268. * Gets the current plugin used to run the simulation
  32269. * @returns current plugin
  32270. */
  32271. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32272. /**
  32273. * Gets the list of physic impostors
  32274. * @returns an array of PhysicsImpostor
  32275. */
  32276. getImpostors(): Array<PhysicsImpostor>;
  32277. /**
  32278. * Gets the impostor for a physics enabled object
  32279. * @param object defines the object impersonated by the impostor
  32280. * @returns the PhysicsImpostor or null if not found
  32281. */
  32282. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32283. /**
  32284. * Gets the impostor for a physics body object
  32285. * @param body defines physics body used by the impostor
  32286. * @returns the PhysicsImpostor or null if not found
  32287. */
  32288. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32289. /**
  32290. * Does a raycast in the physics world
  32291. * @param from when should the ray start?
  32292. * @param to when should the ray end?
  32293. * @returns PhysicsRaycastResult
  32294. */
  32295. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32296. /**
  32297. * Called by the scene. No need to call it.
  32298. * @param delta defines the timespam between frames
  32299. */
  32300. _step(delta: number): void;
  32301. }
  32302. }
  32303. declare module BABYLON {
  32304. /**
  32305. * The interface for the physics imposter parameters
  32306. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32307. */
  32308. export interface PhysicsImpostorParameters {
  32309. /**
  32310. * The mass of the physics imposter
  32311. */
  32312. mass: number;
  32313. /**
  32314. * The friction of the physics imposter
  32315. */
  32316. friction?: number;
  32317. /**
  32318. * The coefficient of restitution of the physics imposter
  32319. */
  32320. restitution?: number;
  32321. /**
  32322. * The native options of the physics imposter
  32323. */
  32324. nativeOptions?: any;
  32325. /**
  32326. * Specifies if the parent should be ignored
  32327. */
  32328. ignoreParent?: boolean;
  32329. /**
  32330. * Specifies if bi-directional transformations should be disabled
  32331. */
  32332. disableBidirectionalTransformation?: boolean;
  32333. /**
  32334. * The pressure inside the physics imposter, soft object only
  32335. */
  32336. pressure?: number;
  32337. /**
  32338. * The stiffness the physics imposter, soft object only
  32339. */
  32340. stiffness?: number;
  32341. /**
  32342. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32343. */
  32344. velocityIterations?: number;
  32345. /**
  32346. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32347. */
  32348. positionIterations?: number;
  32349. /**
  32350. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32351. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32352. * Add to fix multiple points
  32353. */
  32354. fixedPoints?: number;
  32355. /**
  32356. * The collision margin around a soft object
  32357. */
  32358. margin?: number;
  32359. /**
  32360. * The collision margin around a soft object
  32361. */
  32362. damping?: number;
  32363. /**
  32364. * The path for a rope based on an extrusion
  32365. */
  32366. path?: any;
  32367. /**
  32368. * The shape of an extrusion used for a rope based on an extrusion
  32369. */
  32370. shape?: any;
  32371. }
  32372. /**
  32373. * Interface for a physics-enabled object
  32374. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32375. */
  32376. export interface IPhysicsEnabledObject {
  32377. /**
  32378. * The position of the physics-enabled object
  32379. */
  32380. position: Vector3;
  32381. /**
  32382. * The rotation of the physics-enabled object
  32383. */
  32384. rotationQuaternion: Nullable<Quaternion>;
  32385. /**
  32386. * The scale of the physics-enabled object
  32387. */
  32388. scaling: Vector3;
  32389. /**
  32390. * The rotation of the physics-enabled object
  32391. */
  32392. rotation?: Vector3;
  32393. /**
  32394. * The parent of the physics-enabled object
  32395. */
  32396. parent?: any;
  32397. /**
  32398. * The bounding info of the physics-enabled object
  32399. * @returns The bounding info of the physics-enabled object
  32400. */
  32401. getBoundingInfo(): BoundingInfo;
  32402. /**
  32403. * Computes the world matrix
  32404. * @param force Specifies if the world matrix should be computed by force
  32405. * @returns A world matrix
  32406. */
  32407. computeWorldMatrix(force: boolean): Matrix;
  32408. /**
  32409. * Gets the world matrix
  32410. * @returns A world matrix
  32411. */
  32412. getWorldMatrix?(): Matrix;
  32413. /**
  32414. * Gets the child meshes
  32415. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32416. * @returns An array of abstract meshes
  32417. */
  32418. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32419. /**
  32420. * Gets the vertex data
  32421. * @param kind The type of vertex data
  32422. * @returns A nullable array of numbers, or a float32 array
  32423. */
  32424. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32425. /**
  32426. * Gets the indices from the mesh
  32427. * @returns A nullable array of index arrays
  32428. */
  32429. getIndices?(): Nullable<IndicesArray>;
  32430. /**
  32431. * Gets the scene from the mesh
  32432. * @returns the indices array or null
  32433. */
  32434. getScene?(): Scene;
  32435. /**
  32436. * Gets the absolute position from the mesh
  32437. * @returns the absolute position
  32438. */
  32439. getAbsolutePosition(): Vector3;
  32440. /**
  32441. * Gets the absolute pivot point from the mesh
  32442. * @returns the absolute pivot point
  32443. */
  32444. getAbsolutePivotPoint(): Vector3;
  32445. /**
  32446. * Rotates the mesh
  32447. * @param axis The axis of rotation
  32448. * @param amount The amount of rotation
  32449. * @param space The space of the rotation
  32450. * @returns The rotation transform node
  32451. */
  32452. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32453. /**
  32454. * Translates the mesh
  32455. * @param axis The axis of translation
  32456. * @param distance The distance of translation
  32457. * @param space The space of the translation
  32458. * @returns The transform node
  32459. */
  32460. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32461. /**
  32462. * Sets the absolute position of the mesh
  32463. * @param absolutePosition The absolute position of the mesh
  32464. * @returns The transform node
  32465. */
  32466. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  32467. /**
  32468. * Gets the class name of the mesh
  32469. * @returns The class name
  32470. */
  32471. getClassName(): string;
  32472. }
  32473. /**
  32474. * Represents a physics imposter
  32475. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32476. */
  32477. export class PhysicsImpostor {
  32478. /**
  32479. * The physics-enabled object used as the physics imposter
  32480. */
  32481. object: IPhysicsEnabledObject;
  32482. /**
  32483. * The type of the physics imposter
  32484. */
  32485. type: number;
  32486. private _options;
  32487. private _scene?;
  32488. /**
  32489. * The default object size of the imposter
  32490. */
  32491. static DEFAULT_OBJECT_SIZE: Vector3;
  32492. /**
  32493. * The identity quaternion of the imposter
  32494. */
  32495. static IDENTITY_QUATERNION: Quaternion;
  32496. /** @hidden */
  32497. _pluginData: any;
  32498. private _physicsEngine;
  32499. private _physicsBody;
  32500. private _bodyUpdateRequired;
  32501. private _onBeforePhysicsStepCallbacks;
  32502. private _onAfterPhysicsStepCallbacks;
  32503. /** @hidden */
  32504. _onPhysicsCollideCallbacks: Array<{
  32505. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  32506. otherImpostors: Array<PhysicsImpostor>;
  32507. }>;
  32508. private _deltaPosition;
  32509. private _deltaRotation;
  32510. private _deltaRotationConjugated;
  32511. /** @hidden */
  32512. _isFromLine: boolean;
  32513. private _parent;
  32514. private _isDisposed;
  32515. private static _tmpVecs;
  32516. private static _tmpQuat;
  32517. /**
  32518. * Specifies if the physics imposter is disposed
  32519. */
  32520. get isDisposed(): boolean;
  32521. /**
  32522. * Gets the mass of the physics imposter
  32523. */
  32524. get mass(): number;
  32525. set mass(value: number);
  32526. /**
  32527. * Gets the coefficient of friction
  32528. */
  32529. get friction(): number;
  32530. /**
  32531. * Sets the coefficient of friction
  32532. */
  32533. set friction(value: number);
  32534. /**
  32535. * Gets the coefficient of restitution
  32536. */
  32537. get restitution(): number;
  32538. /**
  32539. * Sets the coefficient of restitution
  32540. */
  32541. set restitution(value: number);
  32542. /**
  32543. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  32544. */
  32545. get pressure(): number;
  32546. /**
  32547. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  32548. */
  32549. set pressure(value: number);
  32550. /**
  32551. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32552. */
  32553. get stiffness(): number;
  32554. /**
  32555. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32556. */
  32557. set stiffness(value: number);
  32558. /**
  32559. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32560. */
  32561. get velocityIterations(): number;
  32562. /**
  32563. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32564. */
  32565. set velocityIterations(value: number);
  32566. /**
  32567. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32568. */
  32569. get positionIterations(): number;
  32570. /**
  32571. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32572. */
  32573. set positionIterations(value: number);
  32574. /**
  32575. * The unique id of the physics imposter
  32576. * set by the physics engine when adding this impostor to the array
  32577. */
  32578. uniqueId: number;
  32579. /**
  32580. * @hidden
  32581. */
  32582. soft: boolean;
  32583. /**
  32584. * @hidden
  32585. */
  32586. segments: number;
  32587. private _joints;
  32588. /**
  32589. * Initializes the physics imposter
  32590. * @param object The physics-enabled object used as the physics imposter
  32591. * @param type The type of the physics imposter
  32592. * @param _options The options for the physics imposter
  32593. * @param _scene The Babylon scene
  32594. */
  32595. constructor(
  32596. /**
  32597. * The physics-enabled object used as the physics imposter
  32598. */
  32599. object: IPhysicsEnabledObject,
  32600. /**
  32601. * The type of the physics imposter
  32602. */
  32603. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  32604. /**
  32605. * This function will completly initialize this impostor.
  32606. * It will create a new body - but only if this mesh has no parent.
  32607. * If it has, this impostor will not be used other than to define the impostor
  32608. * of the child mesh.
  32609. * @hidden
  32610. */
  32611. _init(): void;
  32612. private _getPhysicsParent;
  32613. /**
  32614. * Should a new body be generated.
  32615. * @returns boolean specifying if body initialization is required
  32616. */
  32617. isBodyInitRequired(): boolean;
  32618. /**
  32619. * Sets the updated scaling
  32620. * @param updated Specifies if the scaling is updated
  32621. */
  32622. setScalingUpdated(): void;
  32623. /**
  32624. * Force a regeneration of this or the parent's impostor's body.
  32625. * Use under cautious - This will remove all joints already implemented.
  32626. */
  32627. forceUpdate(): void;
  32628. /**
  32629. * Gets the body that holds this impostor. Either its own, or its parent.
  32630. */
  32631. get physicsBody(): any;
  32632. /**
  32633. * Get the parent of the physics imposter
  32634. * @returns Physics imposter or null
  32635. */
  32636. get parent(): Nullable<PhysicsImpostor>;
  32637. /**
  32638. * Sets the parent of the physics imposter
  32639. */
  32640. set parent(value: Nullable<PhysicsImpostor>);
  32641. /**
  32642. * Set the physics body. Used mainly by the physics engine/plugin
  32643. */
  32644. set physicsBody(physicsBody: any);
  32645. /**
  32646. * Resets the update flags
  32647. */
  32648. resetUpdateFlags(): void;
  32649. /**
  32650. * Gets the object extend size
  32651. * @returns the object extend size
  32652. */
  32653. getObjectExtendSize(): Vector3;
  32654. /**
  32655. * Gets the object center
  32656. * @returns The object center
  32657. */
  32658. getObjectCenter(): Vector3;
  32659. /**
  32660. * Get a specific parameter from the options parameters
  32661. * @param paramName The object parameter name
  32662. * @returns The object parameter
  32663. */
  32664. getParam(paramName: string): any;
  32665. /**
  32666. * Sets a specific parameter in the options given to the physics plugin
  32667. * @param paramName The parameter name
  32668. * @param value The value of the parameter
  32669. */
  32670. setParam(paramName: string, value: number): void;
  32671. /**
  32672. * Specifically change the body's mass option. Won't recreate the physics body object
  32673. * @param mass The mass of the physics imposter
  32674. */
  32675. setMass(mass: number): void;
  32676. /**
  32677. * Gets the linear velocity
  32678. * @returns linear velocity or null
  32679. */
  32680. getLinearVelocity(): Nullable<Vector3>;
  32681. /**
  32682. * Sets the linear velocity
  32683. * @param velocity linear velocity or null
  32684. */
  32685. setLinearVelocity(velocity: Nullable<Vector3>): void;
  32686. /**
  32687. * Gets the angular velocity
  32688. * @returns angular velocity or null
  32689. */
  32690. getAngularVelocity(): Nullable<Vector3>;
  32691. /**
  32692. * Sets the angular velocity
  32693. * @param velocity The velocity or null
  32694. */
  32695. setAngularVelocity(velocity: Nullable<Vector3>): void;
  32696. /**
  32697. * Execute a function with the physics plugin native code
  32698. * Provide a function the will have two variables - the world object and the physics body object
  32699. * @param func The function to execute with the physics plugin native code
  32700. */
  32701. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  32702. /**
  32703. * Register a function that will be executed before the physics world is stepping forward
  32704. * @param func The function to execute before the physics world is stepped forward
  32705. */
  32706. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32707. /**
  32708. * Unregister a function that will be executed before the physics world is stepping forward
  32709. * @param func The function to execute before the physics world is stepped forward
  32710. */
  32711. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32712. /**
  32713. * Register a function that will be executed after the physics step
  32714. * @param func The function to execute after physics step
  32715. */
  32716. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32717. /**
  32718. * Unregisters a function that will be executed after the physics step
  32719. * @param func The function to execute after physics step
  32720. */
  32721. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32722. /**
  32723. * register a function that will be executed when this impostor collides against a different body
  32724. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  32725. * @param func Callback that is executed on collision
  32726. */
  32727. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  32728. /**
  32729. * Unregisters the physics imposter on contact
  32730. * @param collideAgainst The physics object to collide against
  32731. * @param func Callback to execute on collision
  32732. */
  32733. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  32734. private _tmpQuat;
  32735. private _tmpQuat2;
  32736. /**
  32737. * Get the parent rotation
  32738. * @returns The parent rotation
  32739. */
  32740. getParentsRotation(): Quaternion;
  32741. /**
  32742. * this function is executed by the physics engine.
  32743. */
  32744. beforeStep: () => void;
  32745. /**
  32746. * this function is executed by the physics engine
  32747. */
  32748. afterStep: () => void;
  32749. /**
  32750. * Legacy collision detection event support
  32751. */
  32752. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  32753. /**
  32754. * event and body object due to cannon's event-based architecture.
  32755. */
  32756. onCollide: (e: {
  32757. body: any;
  32758. point: Nullable<Vector3>;
  32759. }) => void;
  32760. /**
  32761. * Apply a force
  32762. * @param force The force to apply
  32763. * @param contactPoint The contact point for the force
  32764. * @returns The physics imposter
  32765. */
  32766. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32767. /**
  32768. * Apply an impulse
  32769. * @param force The impulse force
  32770. * @param contactPoint The contact point for the impulse force
  32771. * @returns The physics imposter
  32772. */
  32773. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32774. /**
  32775. * A help function to create a joint
  32776. * @param otherImpostor A physics imposter used to create a joint
  32777. * @param jointType The type of joint
  32778. * @param jointData The data for the joint
  32779. * @returns The physics imposter
  32780. */
  32781. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32782. /**
  32783. * Add a joint to this impostor with a different impostor
  32784. * @param otherImpostor A physics imposter used to add a joint
  32785. * @param joint The joint to add
  32786. * @returns The physics imposter
  32787. */
  32788. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32789. /**
  32790. * Add an anchor to a cloth impostor
  32791. * @param otherImpostor rigid impostor to anchor to
  32792. * @param width ratio across width from 0 to 1
  32793. * @param height ratio up height from 0 to 1
  32794. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32795. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32796. * @returns impostor the soft imposter
  32797. */
  32798. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32799. /**
  32800. * Add a hook to a rope impostor
  32801. * @param otherImpostor rigid impostor to anchor to
  32802. * @param length ratio across rope from 0 to 1
  32803. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32804. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32805. * @returns impostor the rope imposter
  32806. */
  32807. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32808. /**
  32809. * Will keep this body still, in a sleep mode.
  32810. * @returns the physics imposter
  32811. */
  32812. sleep(): PhysicsImpostor;
  32813. /**
  32814. * Wake the body up.
  32815. * @returns The physics imposter
  32816. */
  32817. wakeUp(): PhysicsImpostor;
  32818. /**
  32819. * Clones the physics imposter
  32820. * @param newObject The physics imposter clones to this physics-enabled object
  32821. * @returns A nullable physics imposter
  32822. */
  32823. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32824. /**
  32825. * Disposes the physics imposter
  32826. */
  32827. dispose(): void;
  32828. /**
  32829. * Sets the delta position
  32830. * @param position The delta position amount
  32831. */
  32832. setDeltaPosition(position: Vector3): void;
  32833. /**
  32834. * Sets the delta rotation
  32835. * @param rotation The delta rotation amount
  32836. */
  32837. setDeltaRotation(rotation: Quaternion): void;
  32838. /**
  32839. * Gets the box size of the physics imposter and stores the result in the input parameter
  32840. * @param result Stores the box size
  32841. * @returns The physics imposter
  32842. */
  32843. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32844. /**
  32845. * Gets the radius of the physics imposter
  32846. * @returns Radius of the physics imposter
  32847. */
  32848. getRadius(): number;
  32849. /**
  32850. * Sync a bone with this impostor
  32851. * @param bone The bone to sync to the impostor.
  32852. * @param boneMesh The mesh that the bone is influencing.
  32853. * @param jointPivot The pivot of the joint / bone in local space.
  32854. * @param distToJoint Optional distance from the impostor to the joint.
  32855. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32856. */
  32857. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32858. /**
  32859. * Sync impostor to a bone
  32860. * @param bone The bone that the impostor will be synced to.
  32861. * @param boneMesh The mesh that the bone is influencing.
  32862. * @param jointPivot The pivot of the joint / bone in local space.
  32863. * @param distToJoint Optional distance from the impostor to the joint.
  32864. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32865. * @param boneAxis Optional vector3 axis the bone is aligned with
  32866. */
  32867. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32868. /**
  32869. * No-Imposter type
  32870. */
  32871. static NoImpostor: number;
  32872. /**
  32873. * Sphere-Imposter type
  32874. */
  32875. static SphereImpostor: number;
  32876. /**
  32877. * Box-Imposter type
  32878. */
  32879. static BoxImpostor: number;
  32880. /**
  32881. * Plane-Imposter type
  32882. */
  32883. static PlaneImpostor: number;
  32884. /**
  32885. * Mesh-imposter type
  32886. */
  32887. static MeshImpostor: number;
  32888. /**
  32889. * Capsule-Impostor type (Ammo.js plugin only)
  32890. */
  32891. static CapsuleImpostor: number;
  32892. /**
  32893. * Cylinder-Imposter type
  32894. */
  32895. static CylinderImpostor: number;
  32896. /**
  32897. * Particle-Imposter type
  32898. */
  32899. static ParticleImpostor: number;
  32900. /**
  32901. * Heightmap-Imposter type
  32902. */
  32903. static HeightmapImpostor: number;
  32904. /**
  32905. * ConvexHull-Impostor type (Ammo.js plugin only)
  32906. */
  32907. static ConvexHullImpostor: number;
  32908. /**
  32909. * Custom-Imposter type (Ammo.js plugin only)
  32910. */
  32911. static CustomImpostor: number;
  32912. /**
  32913. * Rope-Imposter type
  32914. */
  32915. static RopeImpostor: number;
  32916. /**
  32917. * Cloth-Imposter type
  32918. */
  32919. static ClothImpostor: number;
  32920. /**
  32921. * Softbody-Imposter type
  32922. */
  32923. static SoftbodyImpostor: number;
  32924. }
  32925. }
  32926. declare module BABYLON {
  32927. /**
  32928. * @hidden
  32929. **/
  32930. export class _CreationDataStorage {
  32931. closePath?: boolean;
  32932. closeArray?: boolean;
  32933. idx: number[];
  32934. dashSize: number;
  32935. gapSize: number;
  32936. path3D: Path3D;
  32937. pathArray: Vector3[][];
  32938. arc: number;
  32939. radius: number;
  32940. cap: number;
  32941. tessellation: number;
  32942. }
  32943. /**
  32944. * @hidden
  32945. **/
  32946. class _InstanceDataStorage {
  32947. visibleInstances: any;
  32948. batchCache: _InstancesBatch;
  32949. instancesBufferSize: number;
  32950. instancesBuffer: Nullable<Buffer>;
  32951. instancesData: Float32Array;
  32952. overridenInstanceCount: number;
  32953. isFrozen: boolean;
  32954. previousBatch: Nullable<_InstancesBatch>;
  32955. hardwareInstancedRendering: boolean;
  32956. sideOrientation: number;
  32957. manualUpdate: boolean;
  32958. previousRenderId: number;
  32959. }
  32960. /**
  32961. * @hidden
  32962. **/
  32963. export class _InstancesBatch {
  32964. mustReturn: boolean;
  32965. visibleInstances: Nullable<InstancedMesh[]>[];
  32966. renderSelf: boolean[];
  32967. hardwareInstancedRendering: boolean[];
  32968. }
  32969. /**
  32970. * @hidden
  32971. **/
  32972. class _ThinInstanceDataStorage {
  32973. instancesCount: number;
  32974. matrixBuffer: Nullable<Buffer>;
  32975. matrixBufferSize: number;
  32976. matrixData: Nullable<Float32Array>;
  32977. boundingVectors: Array<Vector3>;
  32978. worldMatrices: Nullable<Matrix[]>;
  32979. }
  32980. /**
  32981. * Class used to represent renderable models
  32982. */
  32983. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  32984. /**
  32985. * Mesh side orientation : usually the external or front surface
  32986. */
  32987. static readonly FRONTSIDE: number;
  32988. /**
  32989. * Mesh side orientation : usually the internal or back surface
  32990. */
  32991. static readonly BACKSIDE: number;
  32992. /**
  32993. * Mesh side orientation : both internal and external or front and back surfaces
  32994. */
  32995. static readonly DOUBLESIDE: number;
  32996. /**
  32997. * Mesh side orientation : by default, `FRONTSIDE`
  32998. */
  32999. static readonly DEFAULTSIDE: number;
  33000. /**
  33001. * Mesh cap setting : no cap
  33002. */
  33003. static readonly NO_CAP: number;
  33004. /**
  33005. * Mesh cap setting : one cap at the beginning of the mesh
  33006. */
  33007. static readonly CAP_START: number;
  33008. /**
  33009. * Mesh cap setting : one cap at the end of the mesh
  33010. */
  33011. static readonly CAP_END: number;
  33012. /**
  33013. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33014. */
  33015. static readonly CAP_ALL: number;
  33016. /**
  33017. * Mesh pattern setting : no flip or rotate
  33018. */
  33019. static readonly NO_FLIP: number;
  33020. /**
  33021. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33022. */
  33023. static readonly FLIP_TILE: number;
  33024. /**
  33025. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33026. */
  33027. static readonly ROTATE_TILE: number;
  33028. /**
  33029. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33030. */
  33031. static readonly FLIP_ROW: number;
  33032. /**
  33033. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33034. */
  33035. static readonly ROTATE_ROW: number;
  33036. /**
  33037. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33038. */
  33039. static readonly FLIP_N_ROTATE_TILE: number;
  33040. /**
  33041. * Mesh pattern setting : rotate pattern and rotate
  33042. */
  33043. static readonly FLIP_N_ROTATE_ROW: number;
  33044. /**
  33045. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33046. */
  33047. static readonly CENTER: number;
  33048. /**
  33049. * Mesh tile positioning : part tiles on left
  33050. */
  33051. static readonly LEFT: number;
  33052. /**
  33053. * Mesh tile positioning : part tiles on right
  33054. */
  33055. static readonly RIGHT: number;
  33056. /**
  33057. * Mesh tile positioning : part tiles on top
  33058. */
  33059. static readonly TOP: number;
  33060. /**
  33061. * Mesh tile positioning : part tiles on bottom
  33062. */
  33063. static readonly BOTTOM: number;
  33064. /**
  33065. * Gets the default side orientation.
  33066. * @param orientation the orientation to value to attempt to get
  33067. * @returns the default orientation
  33068. * @hidden
  33069. */
  33070. static _GetDefaultSideOrientation(orientation?: number): number;
  33071. private _internalMeshDataInfo;
  33072. get computeBonesUsingShaders(): boolean;
  33073. set computeBonesUsingShaders(value: boolean);
  33074. /**
  33075. * An event triggered before rendering the mesh
  33076. */
  33077. get onBeforeRenderObservable(): Observable<Mesh>;
  33078. /**
  33079. * An event triggered before binding the mesh
  33080. */
  33081. get onBeforeBindObservable(): Observable<Mesh>;
  33082. /**
  33083. * An event triggered after rendering the mesh
  33084. */
  33085. get onAfterRenderObservable(): Observable<Mesh>;
  33086. /**
  33087. * An event triggered before drawing the mesh
  33088. */
  33089. get onBeforeDrawObservable(): Observable<Mesh>;
  33090. private _onBeforeDrawObserver;
  33091. /**
  33092. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33093. */
  33094. set onBeforeDraw(callback: () => void);
  33095. get hasInstances(): boolean;
  33096. get hasThinInstances(): boolean;
  33097. /**
  33098. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33099. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33100. */
  33101. delayLoadState: number;
  33102. /**
  33103. * Gets the list of instances created from this mesh
  33104. * it is not supposed to be modified manually.
  33105. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33106. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33107. */
  33108. instances: InstancedMesh[];
  33109. /**
  33110. * Gets the file containing delay loading data for this mesh
  33111. */
  33112. delayLoadingFile: string;
  33113. /** @hidden */
  33114. _binaryInfo: any;
  33115. /**
  33116. * User defined function used to change how LOD level selection is done
  33117. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33118. */
  33119. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33120. /**
  33121. * Gets or sets the morph target manager
  33122. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33123. */
  33124. get morphTargetManager(): Nullable<MorphTargetManager>;
  33125. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33126. /** @hidden */
  33127. _creationDataStorage: Nullable<_CreationDataStorage>;
  33128. /** @hidden */
  33129. _geometry: Nullable<Geometry>;
  33130. /** @hidden */
  33131. _delayInfo: Array<string>;
  33132. /** @hidden */
  33133. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33134. /** @hidden */
  33135. _instanceDataStorage: _InstanceDataStorage;
  33136. /** @hidden */
  33137. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33138. private _effectiveMaterial;
  33139. /** @hidden */
  33140. _shouldGenerateFlatShading: boolean;
  33141. /** @hidden */
  33142. _originalBuilderSideOrientation: number;
  33143. /**
  33144. * Use this property to change the original side orientation defined at construction time
  33145. */
  33146. overrideMaterialSideOrientation: Nullable<number>;
  33147. /**
  33148. * Gets the source mesh (the one used to clone this one from)
  33149. */
  33150. get source(): Nullable<Mesh>;
  33151. /**
  33152. * Gets the list of clones of this mesh
  33153. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33154. * Note that useClonedMeshMap=true is the default setting
  33155. */
  33156. get cloneMeshMap(): Nullable<{
  33157. [id: string]: Mesh | undefined;
  33158. }>;
  33159. /**
  33160. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33161. */
  33162. get isUnIndexed(): boolean;
  33163. set isUnIndexed(value: boolean);
  33164. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33165. get worldMatrixInstancedBuffer(): Float32Array;
  33166. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33167. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33168. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33169. /**
  33170. * @constructor
  33171. * @param name The value used by scene.getMeshByName() to do a lookup.
  33172. * @param scene The scene to add this mesh to.
  33173. * @param parent The parent of this mesh, if it has one
  33174. * @param source An optional Mesh from which geometry is shared, cloned.
  33175. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33176. * When false, achieved by calling a clone(), also passing False.
  33177. * This will make creation of children, recursive.
  33178. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33179. */
  33180. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33181. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33182. doNotInstantiate: boolean;
  33183. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33184. /**
  33185. * Gets the class name
  33186. * @returns the string "Mesh".
  33187. */
  33188. getClassName(): string;
  33189. /** @hidden */
  33190. get _isMesh(): boolean;
  33191. /**
  33192. * Returns a description of this mesh
  33193. * @param fullDetails define if full details about this mesh must be used
  33194. * @returns a descriptive string representing this mesh
  33195. */
  33196. toString(fullDetails?: boolean): string;
  33197. /** @hidden */
  33198. _unBindEffect(): void;
  33199. /**
  33200. * Gets a boolean indicating if this mesh has LOD
  33201. */
  33202. get hasLODLevels(): boolean;
  33203. /**
  33204. * Gets the list of MeshLODLevel associated with the current mesh
  33205. * @returns an array of MeshLODLevel
  33206. */
  33207. getLODLevels(): MeshLODLevel[];
  33208. private _sortLODLevels;
  33209. /**
  33210. * Add a mesh as LOD level triggered at the given distance.
  33211. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33212. * @param distance The distance from the center of the object to show this level
  33213. * @param mesh The mesh to be added as LOD level (can be null)
  33214. * @return This mesh (for chaining)
  33215. */
  33216. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33217. /**
  33218. * Returns the LOD level mesh at the passed distance or null if not found.
  33219. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33220. * @param distance The distance from the center of the object to show this level
  33221. * @returns a Mesh or `null`
  33222. */
  33223. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33224. /**
  33225. * Remove a mesh from the LOD array
  33226. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33227. * @param mesh defines the mesh to be removed
  33228. * @return This mesh (for chaining)
  33229. */
  33230. removeLODLevel(mesh: Mesh): Mesh;
  33231. /**
  33232. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33233. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33234. * @param camera defines the camera to use to compute distance
  33235. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33236. * @return This mesh (for chaining)
  33237. */
  33238. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33239. /**
  33240. * Gets the mesh internal Geometry object
  33241. */
  33242. get geometry(): Nullable<Geometry>;
  33243. /**
  33244. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33245. * @returns the total number of vertices
  33246. */
  33247. getTotalVertices(): number;
  33248. /**
  33249. * Returns the content of an associated vertex buffer
  33250. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33251. * - VertexBuffer.PositionKind
  33252. * - VertexBuffer.UVKind
  33253. * - VertexBuffer.UV2Kind
  33254. * - VertexBuffer.UV3Kind
  33255. * - VertexBuffer.UV4Kind
  33256. * - VertexBuffer.UV5Kind
  33257. * - VertexBuffer.UV6Kind
  33258. * - VertexBuffer.ColorKind
  33259. * - VertexBuffer.MatricesIndicesKind
  33260. * - VertexBuffer.MatricesIndicesExtraKind
  33261. * - VertexBuffer.MatricesWeightsKind
  33262. * - VertexBuffer.MatricesWeightsExtraKind
  33263. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  33264. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33265. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33266. */
  33267. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33268. /**
  33269. * Returns the mesh VertexBuffer object from the requested `kind`
  33270. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33271. * - VertexBuffer.PositionKind
  33272. * - VertexBuffer.NormalKind
  33273. * - VertexBuffer.UVKind
  33274. * - VertexBuffer.UV2Kind
  33275. * - VertexBuffer.UV3Kind
  33276. * - VertexBuffer.UV4Kind
  33277. * - VertexBuffer.UV5Kind
  33278. * - VertexBuffer.UV6Kind
  33279. * - VertexBuffer.ColorKind
  33280. * - VertexBuffer.MatricesIndicesKind
  33281. * - VertexBuffer.MatricesIndicesExtraKind
  33282. * - VertexBuffer.MatricesWeightsKind
  33283. * - VertexBuffer.MatricesWeightsExtraKind
  33284. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33285. */
  33286. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33287. /**
  33288. * Tests if a specific vertex buffer is associated with this mesh
  33289. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33290. * - VertexBuffer.PositionKind
  33291. * - VertexBuffer.NormalKind
  33292. * - VertexBuffer.UVKind
  33293. * - VertexBuffer.UV2Kind
  33294. * - VertexBuffer.UV3Kind
  33295. * - VertexBuffer.UV4Kind
  33296. * - VertexBuffer.UV5Kind
  33297. * - VertexBuffer.UV6Kind
  33298. * - VertexBuffer.ColorKind
  33299. * - VertexBuffer.MatricesIndicesKind
  33300. * - VertexBuffer.MatricesIndicesExtraKind
  33301. * - VertexBuffer.MatricesWeightsKind
  33302. * - VertexBuffer.MatricesWeightsExtraKind
  33303. * @returns a boolean
  33304. */
  33305. isVerticesDataPresent(kind: string): boolean;
  33306. /**
  33307. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33308. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33309. * - VertexBuffer.PositionKind
  33310. * - VertexBuffer.UVKind
  33311. * - VertexBuffer.UV2Kind
  33312. * - VertexBuffer.UV3Kind
  33313. * - VertexBuffer.UV4Kind
  33314. * - VertexBuffer.UV5Kind
  33315. * - VertexBuffer.UV6Kind
  33316. * - VertexBuffer.ColorKind
  33317. * - VertexBuffer.MatricesIndicesKind
  33318. * - VertexBuffer.MatricesIndicesExtraKind
  33319. * - VertexBuffer.MatricesWeightsKind
  33320. * - VertexBuffer.MatricesWeightsExtraKind
  33321. * @returns a boolean
  33322. */
  33323. isVertexBufferUpdatable(kind: string): boolean;
  33324. /**
  33325. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33326. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33327. * - VertexBuffer.PositionKind
  33328. * - VertexBuffer.NormalKind
  33329. * - VertexBuffer.UVKind
  33330. * - VertexBuffer.UV2Kind
  33331. * - VertexBuffer.UV3Kind
  33332. * - VertexBuffer.UV4Kind
  33333. * - VertexBuffer.UV5Kind
  33334. * - VertexBuffer.UV6Kind
  33335. * - VertexBuffer.ColorKind
  33336. * - VertexBuffer.MatricesIndicesKind
  33337. * - VertexBuffer.MatricesIndicesExtraKind
  33338. * - VertexBuffer.MatricesWeightsKind
  33339. * - VertexBuffer.MatricesWeightsExtraKind
  33340. * @returns an array of strings
  33341. */
  33342. getVerticesDataKinds(): string[];
  33343. /**
  33344. * Returns a positive integer : the total number of indices in this mesh geometry.
  33345. * @returns the numner of indices or zero if the mesh has no geometry.
  33346. */
  33347. getTotalIndices(): number;
  33348. /**
  33349. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33350. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  33351. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33352. * @returns the indices array or an empty array if the mesh has no geometry
  33353. */
  33354. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33355. get isBlocked(): boolean;
  33356. /**
  33357. * Determine if the current mesh is ready to be rendered
  33358. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33359. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  33360. * @returns true if all associated assets are ready (material, textures, shaders)
  33361. */
  33362. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  33363. /**
  33364. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  33365. */
  33366. get areNormalsFrozen(): boolean;
  33367. /**
  33368. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  33369. * @returns the current mesh
  33370. */
  33371. freezeNormals(): Mesh;
  33372. /**
  33373. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  33374. * @returns the current mesh
  33375. */
  33376. unfreezeNormals(): Mesh;
  33377. /**
  33378. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  33379. */
  33380. set overridenInstanceCount(count: number);
  33381. /** @hidden */
  33382. _preActivate(): Mesh;
  33383. /** @hidden */
  33384. _preActivateForIntermediateRendering(renderId: number): Mesh;
  33385. /** @hidden */
  33386. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  33387. protected _afterComputeWorldMatrix(): void;
  33388. /** @hidden */
  33389. _postActivate(): void;
  33390. /**
  33391. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33392. * This means the mesh underlying bounding box and sphere are recomputed.
  33393. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33394. * @returns the current mesh
  33395. */
  33396. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  33397. /** @hidden */
  33398. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  33399. /**
  33400. * This function will subdivide the mesh into multiple submeshes
  33401. * @param count defines the expected number of submeshes
  33402. */
  33403. subdivide(count: number): void;
  33404. /**
  33405. * Copy a FloatArray into a specific associated vertex buffer
  33406. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33407. * - VertexBuffer.PositionKind
  33408. * - VertexBuffer.UVKind
  33409. * - VertexBuffer.UV2Kind
  33410. * - VertexBuffer.UV3Kind
  33411. * - VertexBuffer.UV4Kind
  33412. * - VertexBuffer.UV5Kind
  33413. * - VertexBuffer.UV6Kind
  33414. * - VertexBuffer.ColorKind
  33415. * - VertexBuffer.MatricesIndicesKind
  33416. * - VertexBuffer.MatricesIndicesExtraKind
  33417. * - VertexBuffer.MatricesWeightsKind
  33418. * - VertexBuffer.MatricesWeightsExtraKind
  33419. * @param data defines the data source
  33420. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33421. * @param stride defines the data stride size (can be null)
  33422. * @returns the current mesh
  33423. */
  33424. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33425. /**
  33426. * Delete a vertex buffer associated with this mesh
  33427. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  33428. * - VertexBuffer.PositionKind
  33429. * - VertexBuffer.UVKind
  33430. * - VertexBuffer.UV2Kind
  33431. * - VertexBuffer.UV3Kind
  33432. * - VertexBuffer.UV4Kind
  33433. * - VertexBuffer.UV5Kind
  33434. * - VertexBuffer.UV6Kind
  33435. * - VertexBuffer.ColorKind
  33436. * - VertexBuffer.MatricesIndicesKind
  33437. * - VertexBuffer.MatricesIndicesExtraKind
  33438. * - VertexBuffer.MatricesWeightsKind
  33439. * - VertexBuffer.MatricesWeightsExtraKind
  33440. */
  33441. removeVerticesData(kind: string): void;
  33442. /**
  33443. * Flags an associated vertex buffer as updatable
  33444. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  33445. * - VertexBuffer.PositionKind
  33446. * - VertexBuffer.UVKind
  33447. * - VertexBuffer.UV2Kind
  33448. * - VertexBuffer.UV3Kind
  33449. * - VertexBuffer.UV4Kind
  33450. * - VertexBuffer.UV5Kind
  33451. * - VertexBuffer.UV6Kind
  33452. * - VertexBuffer.ColorKind
  33453. * - VertexBuffer.MatricesIndicesKind
  33454. * - VertexBuffer.MatricesIndicesExtraKind
  33455. * - VertexBuffer.MatricesWeightsKind
  33456. * - VertexBuffer.MatricesWeightsExtraKind
  33457. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33458. */
  33459. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  33460. /**
  33461. * Sets the mesh global Vertex Buffer
  33462. * @param buffer defines the buffer to use
  33463. * @returns the current mesh
  33464. */
  33465. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  33466. /**
  33467. * Update a specific associated vertex buffer
  33468. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33469. * - VertexBuffer.PositionKind
  33470. * - VertexBuffer.UVKind
  33471. * - VertexBuffer.UV2Kind
  33472. * - VertexBuffer.UV3Kind
  33473. * - VertexBuffer.UV4Kind
  33474. * - VertexBuffer.UV5Kind
  33475. * - VertexBuffer.UV6Kind
  33476. * - VertexBuffer.ColorKind
  33477. * - VertexBuffer.MatricesIndicesKind
  33478. * - VertexBuffer.MatricesIndicesExtraKind
  33479. * - VertexBuffer.MatricesWeightsKind
  33480. * - VertexBuffer.MatricesWeightsExtraKind
  33481. * @param data defines the data source
  33482. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33483. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  33484. * @returns the current mesh
  33485. */
  33486. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33487. /**
  33488. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  33489. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  33490. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  33491. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  33492. * @returns the current mesh
  33493. */
  33494. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  33495. /**
  33496. * Creates a un-shared specific occurence of the geometry for the mesh.
  33497. * @returns the current mesh
  33498. */
  33499. makeGeometryUnique(): Mesh;
  33500. /**
  33501. * Set the index buffer of this mesh
  33502. * @param indices defines the source data
  33503. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  33504. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  33505. * @returns the current mesh
  33506. */
  33507. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  33508. /**
  33509. * Update the current index buffer
  33510. * @param indices defines the source data
  33511. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33512. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  33513. * @returns the current mesh
  33514. */
  33515. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33516. /**
  33517. * Invert the geometry to move from a right handed system to a left handed one.
  33518. * @returns the current mesh
  33519. */
  33520. toLeftHanded(): Mesh;
  33521. /** @hidden */
  33522. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  33523. /** @hidden */
  33524. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  33525. /**
  33526. * Registers for this mesh a javascript function called just before the rendering process
  33527. * @param func defines the function to call before rendering this mesh
  33528. * @returns the current mesh
  33529. */
  33530. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33531. /**
  33532. * Disposes a previously registered javascript function called before the rendering
  33533. * @param func defines the function to remove
  33534. * @returns the current mesh
  33535. */
  33536. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33537. /**
  33538. * Registers for this mesh a javascript function called just after the rendering is complete
  33539. * @param func defines the function to call after rendering this mesh
  33540. * @returns the current mesh
  33541. */
  33542. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33543. /**
  33544. * Disposes a previously registered javascript function called after the rendering.
  33545. * @param func defines the function to remove
  33546. * @returns the current mesh
  33547. */
  33548. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33549. /** @hidden */
  33550. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  33551. /** @hidden */
  33552. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  33553. /** @hidden */
  33554. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  33555. /** @hidden */
  33556. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  33557. /** @hidden */
  33558. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  33559. /** @hidden */
  33560. _rebuild(): void;
  33561. /** @hidden */
  33562. _freeze(): void;
  33563. /** @hidden */
  33564. _unFreeze(): void;
  33565. /**
  33566. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  33567. * @param subMesh defines the subMesh to render
  33568. * @param enableAlphaMode defines if alpha mode can be changed
  33569. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  33570. * @returns the current mesh
  33571. */
  33572. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  33573. private _onBeforeDraw;
  33574. /**
  33575. * Renormalize the mesh and patch it up if there are no weights
  33576. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  33577. * However in the case of zero weights then we set just a single influence to 1.
  33578. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  33579. */
  33580. cleanMatrixWeights(): void;
  33581. private normalizeSkinFourWeights;
  33582. private normalizeSkinWeightsAndExtra;
  33583. /**
  33584. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  33585. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  33586. * the user know there was an issue with importing the mesh
  33587. * @returns a validation object with skinned, valid and report string
  33588. */
  33589. validateSkinning(): {
  33590. skinned: boolean;
  33591. valid: boolean;
  33592. report: string;
  33593. };
  33594. /** @hidden */
  33595. _checkDelayState(): Mesh;
  33596. private _queueLoad;
  33597. /**
  33598. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33599. * A mesh is in the frustum if its bounding box intersects the frustum
  33600. * @param frustumPlanes defines the frustum to test
  33601. * @returns true if the mesh is in the frustum planes
  33602. */
  33603. isInFrustum(frustumPlanes: Plane[]): boolean;
  33604. /**
  33605. * Sets the mesh material by the material or multiMaterial `id` property
  33606. * @param id is a string identifying the material or the multiMaterial
  33607. * @returns the current mesh
  33608. */
  33609. setMaterialByID(id: string): Mesh;
  33610. /**
  33611. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  33612. * @returns an array of IAnimatable
  33613. */
  33614. getAnimatables(): IAnimatable[];
  33615. /**
  33616. * Modifies the mesh geometry according to the passed transformation matrix.
  33617. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  33618. * The mesh normals are modified using the same transformation.
  33619. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33620. * @param transform defines the transform matrix to use
  33621. * @see https://doc.babylonjs.com/resources/baking_transformations
  33622. * @returns the current mesh
  33623. */
  33624. bakeTransformIntoVertices(transform: Matrix): Mesh;
  33625. /**
  33626. * Modifies the mesh geometry according to its own current World Matrix.
  33627. * The mesh World Matrix is then reset.
  33628. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  33629. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33630. * @see https://doc.babylonjs.com/resources/baking_transformations
  33631. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  33632. * @returns the current mesh
  33633. */
  33634. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  33635. /** @hidden */
  33636. get _positions(): Nullable<Vector3[]>;
  33637. /** @hidden */
  33638. _resetPointsArrayCache(): Mesh;
  33639. /** @hidden */
  33640. _generatePointsArray(): boolean;
  33641. /**
  33642. * Returns a new Mesh object generated from the current mesh properties.
  33643. * This method must not get confused with createInstance()
  33644. * @param name is a string, the name given to the new mesh
  33645. * @param newParent can be any Node object (default `null`)
  33646. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  33647. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  33648. * @returns a new mesh
  33649. */
  33650. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  33651. /**
  33652. * Releases resources associated with this mesh.
  33653. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33654. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33655. */
  33656. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33657. /** @hidden */
  33658. _disposeInstanceSpecificData(): void;
  33659. /** @hidden */
  33660. _disposeThinInstanceSpecificData(): void;
  33661. /**
  33662. * Modifies the mesh geometry according to a displacement map.
  33663. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  33664. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33665. * @param url is a string, the URL from the image file is to be downloaded.
  33666. * @param minHeight is the lower limit of the displacement.
  33667. * @param maxHeight is the upper limit of the displacement.
  33668. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  33669. * @param uvOffset is an optional vector2 used to offset UV.
  33670. * @param uvScale is an optional vector2 used to scale UV.
  33671. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  33672. * @returns the Mesh.
  33673. */
  33674. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33675. /**
  33676. * Modifies the mesh geometry according to a displacementMap buffer.
  33677. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  33678. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33679. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  33680. * @param heightMapWidth is the width of the buffer image.
  33681. * @param heightMapHeight is the height of the buffer image.
  33682. * @param minHeight is the lower limit of the displacement.
  33683. * @param maxHeight is the upper limit of the displacement.
  33684. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  33685. * @param uvOffset is an optional vector2 used to offset UV.
  33686. * @param uvScale is an optional vector2 used to scale UV.
  33687. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  33688. * @returns the Mesh.
  33689. */
  33690. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33691. /**
  33692. * Modify the mesh to get a flat shading rendering.
  33693. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  33694. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  33695. * @returns current mesh
  33696. */
  33697. convertToFlatShadedMesh(): Mesh;
  33698. /**
  33699. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  33700. * In other words, more vertices, no more indices and a single bigger VBO.
  33701. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  33702. * @returns current mesh
  33703. */
  33704. convertToUnIndexedMesh(): Mesh;
  33705. /**
  33706. * Inverses facet orientations.
  33707. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33708. * @param flipNormals will also inverts the normals
  33709. * @returns current mesh
  33710. */
  33711. flipFaces(flipNormals?: boolean): Mesh;
  33712. /**
  33713. * Increase the number of facets and hence vertices in a mesh
  33714. * Vertex normals are interpolated from existing vertex normals
  33715. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33716. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  33717. */
  33718. increaseVertices(numberPerEdge: number): void;
  33719. /**
  33720. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  33721. * This will undo any application of covertToFlatShadedMesh
  33722. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33723. */
  33724. forceSharedVertices(): void;
  33725. /** @hidden */
  33726. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  33727. /** @hidden */
  33728. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  33729. /**
  33730. * Creates a new InstancedMesh object from the mesh model.
  33731. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33732. * @param name defines the name of the new instance
  33733. * @returns a new InstancedMesh
  33734. */
  33735. createInstance(name: string): InstancedMesh;
  33736. /**
  33737. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  33738. * After this call, all the mesh instances have the same submeshes than the current mesh.
  33739. * @returns the current mesh
  33740. */
  33741. synchronizeInstances(): Mesh;
  33742. /**
  33743. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  33744. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  33745. * This should be used together with the simplification to avoid disappearing triangles.
  33746. * @param successCallback an optional success callback to be called after the optimization finished.
  33747. * @returns the current mesh
  33748. */
  33749. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  33750. /**
  33751. * Serialize current mesh
  33752. * @param serializationObject defines the object which will receive the serialization data
  33753. */
  33754. serialize(serializationObject: any): void;
  33755. /** @hidden */
  33756. _syncGeometryWithMorphTargetManager(): void;
  33757. /** @hidden */
  33758. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  33759. /**
  33760. * Returns a new Mesh object parsed from the source provided.
  33761. * @param parsedMesh is the source
  33762. * @param scene defines the hosting scene
  33763. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  33764. * @returns a new Mesh
  33765. */
  33766. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33767. /**
  33768. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33769. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33770. * @param name defines the name of the mesh to create
  33771. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33772. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33773. * @param closePath creates a seam between the first and the last points of each path of the path array
  33774. * @param offset is taken in account only if the `pathArray` is containing a single path
  33775. * @param scene defines the hosting scene
  33776. * @param updatable defines if the mesh must be flagged as updatable
  33777. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33778. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  33779. * @returns a new Mesh
  33780. */
  33781. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33782. /**
  33783. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33784. * @param name defines the name of the mesh to create
  33785. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33786. * @param tessellation sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  33787. * @param scene defines the hosting scene
  33788. * @param updatable defines if the mesh must be flagged as updatable
  33789. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33790. * @returns a new Mesh
  33791. */
  33792. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33793. /**
  33794. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33795. * @param name defines the name of the mesh to create
  33796. * @param size sets the size (float) of each box side (default 1)
  33797. * @param scene defines the hosting scene
  33798. * @param updatable defines if the mesh must be flagged as updatable
  33799. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33800. * @returns a new Mesh
  33801. */
  33802. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33803. /**
  33804. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33805. * @param name defines the name of the mesh to create
  33806. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33807. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33808. * @param scene defines the hosting scene
  33809. * @param updatable defines if the mesh must be flagged as updatable
  33810. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33811. * @returns a new Mesh
  33812. */
  33813. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33814. /**
  33815. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33816. * @param name defines the name of the mesh to create
  33817. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33818. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33819. * @param scene defines the hosting scene
  33820. * @returns a new Mesh
  33821. */
  33822. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33823. /**
  33824. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  33825. * @param name defines the name of the mesh to create
  33826. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  33827. * @param diameterTop set the top cap diameter (floats, default 1)
  33828. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33829. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33830. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33831. * @param scene defines the hosting scene
  33832. * @param updatable defines if the mesh must be flagged as updatable
  33833. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33834. * @returns a new Mesh
  33835. */
  33836. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33837. /**
  33838. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33839. * @param name defines the name of the mesh to create
  33840. * @param diameter sets the diameter size (float) of the torus (default 1)
  33841. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33842. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33843. * @param scene defines the hosting scene
  33844. * @param updatable defines if the mesh must be flagged as updatable
  33845. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33846. * @returns a new Mesh
  33847. */
  33848. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33849. /**
  33850. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33851. * @param name defines the name of the mesh to create
  33852. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33853. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33854. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33855. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33856. * @param p the number of windings on X axis (positive integers, default 2)
  33857. * @param q the number of windings on Y axis (positive integers, default 3)
  33858. * @param scene defines the hosting scene
  33859. * @param updatable defines if the mesh must be flagged as updatable
  33860. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33861. * @returns a new Mesh
  33862. */
  33863. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33864. /**
  33865. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33866. * @param name defines the name of the mesh to create
  33867. * @param points is an array successive Vector3
  33868. * @param scene defines the hosting scene
  33869. * @param updatable defines if the mesh must be flagged as updatable
  33870. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  33871. * @returns a new Mesh
  33872. */
  33873. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33874. /**
  33875. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33876. * @param name defines the name of the mesh to create
  33877. * @param points is an array successive Vector3
  33878. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33879. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33880. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33881. * @param scene defines the hosting scene
  33882. * @param updatable defines if the mesh must be flagged as updatable
  33883. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  33884. * @returns a new Mesh
  33885. */
  33886. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33887. /**
  33888. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33889. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33890. * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors.
  33891. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33892. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33893. * Remember you can only change the shape positions, not their number when updating a polygon.
  33894. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33895. * @param name defines the name of the mesh to create
  33896. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  33897. * @param scene defines the hosting scene
  33898. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33899. * @param updatable defines if the mesh must be flagged as updatable
  33900. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33901. * @param earcutInjection can be used to inject your own earcut reference
  33902. * @returns a new Mesh
  33903. */
  33904. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33905. /**
  33906. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33907. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33908. * @param name defines the name of the mesh to create
  33909. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  33910. * @param depth defines the height of extrusion
  33911. * @param scene defines the hosting scene
  33912. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33913. * @param updatable defines if the mesh must be flagged as updatable
  33914. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33915. * @param earcutInjection can be used to inject your own earcut reference
  33916. * @returns a new Mesh
  33917. */
  33918. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33919. /**
  33920. * Creates an extruded shape mesh.
  33921. * The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters. Please consider using the same method from the MeshBuilder class instead
  33922. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33923. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33924. * @param name defines the name of the mesh to create
  33925. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  33926. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33927. * @param scale is the value to scale the shape
  33928. * @param rotation is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve
  33929. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  33930. * @param scene defines the hosting scene
  33931. * @param updatable defines if the mesh must be flagged as updatable
  33932. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33933. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  33934. * @returns a new Mesh
  33935. */
  33936. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33937. /**
  33938. * Creates an custom extruded shape mesh.
  33939. * The custom extrusion is a parametric shape.
  33940. * It has no predefined shape. Its final shape will depend on the input parameters.
  33941. * Please consider using the same method from the MeshBuilder class instead
  33942. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33943. * @param name defines the name of the mesh to create
  33944. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  33945. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33946. * @param scaleFunction is a custom Javascript function called on each path point
  33947. * @param rotationFunction is a custom Javascript function called on each path point
  33948. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33949. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33950. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  33951. * @param scene defines the hosting scene
  33952. * @param updatable defines if the mesh must be flagged as updatable
  33953. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33954. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  33955. * @returns a new Mesh
  33956. */
  33957. static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction: Function, rotationFunction: Function, ribbonCloseArray: boolean, ribbonClosePath: boolean, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33958. /**
  33959. * Creates lathe mesh.
  33960. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  33961. * Please consider using the same method from the MeshBuilder class instead
  33962. * @param name defines the name of the mesh to create
  33963. * @param shape is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  33964. * @param radius is the radius value of the lathe
  33965. * @param tessellation is the side number of the lathe.
  33966. * @param scene defines the hosting scene
  33967. * @param updatable defines if the mesh must be flagged as updatable
  33968. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33969. * @returns a new Mesh
  33970. */
  33971. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33972. /**
  33973. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  33974. * @param name defines the name of the mesh to create
  33975. * @param size sets the size (float) of both sides of the plane at once (default 1)
  33976. * @param scene defines the hosting scene
  33977. * @param updatable defines if the mesh must be flagged as updatable
  33978. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33979. * @returns a new Mesh
  33980. */
  33981. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33982. /**
  33983. * Creates a ground mesh.
  33984. * Please consider using the same method from the MeshBuilder class instead
  33985. * @param name defines the name of the mesh to create
  33986. * @param width set the width of the ground
  33987. * @param height set the height of the ground
  33988. * @param subdivisions sets the number of subdivisions per side
  33989. * @param scene defines the hosting scene
  33990. * @param updatable defines if the mesh must be flagged as updatable
  33991. * @returns a new Mesh
  33992. */
  33993. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  33994. /**
  33995. * Creates a tiled ground mesh.
  33996. * Please consider using the same method from the MeshBuilder class instead
  33997. * @param name defines the name of the mesh to create
  33998. * @param xmin set the ground minimum X coordinate
  33999. * @param zmin set the ground minimum Y coordinate
  34000. * @param xmax set the ground maximum X coordinate
  34001. * @param zmax set the ground maximum Z coordinate
  34002. * @param subdivisions is an object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  34003. * @param precision is an object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  34004. * @param scene defines the hosting scene
  34005. * @param updatable defines if the mesh must be flagged as updatable
  34006. * @returns a new Mesh
  34007. */
  34008. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34009. w: number;
  34010. h: number;
  34011. }, precision: {
  34012. w: number;
  34013. h: number;
  34014. }, scene: Scene, updatable?: boolean): Mesh;
  34015. /**
  34016. * Creates a ground mesh from a height map.
  34017. * Please consider using the same method from the MeshBuilder class instead
  34018. * @see https://doc.babylonjs.com/babylon101/height_map
  34019. * @param name defines the name of the mesh to create
  34020. * @param url sets the URL of the height map image resource
  34021. * @param width set the ground width size
  34022. * @param height set the ground height size
  34023. * @param subdivisions sets the number of subdivision per side
  34024. * @param minHeight is the minimum altitude on the ground
  34025. * @param maxHeight is the maximum altitude on the ground
  34026. * @param scene defines the hosting scene
  34027. * @param updatable defines if the mesh must be flagged as updatable
  34028. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34029. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34030. * @returns a new Mesh
  34031. */
  34032. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void, alphaFilter?: number): GroundMesh;
  34033. /**
  34034. * Creates a tube mesh.
  34035. * The tube is a parametric shape.
  34036. * It has no predefined shape. Its final shape will depend on the input parameters.
  34037. * Please consider using the same method from the MeshBuilder class instead
  34038. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34039. * @param name defines the name of the mesh to create
  34040. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34041. * @param radius sets the tube radius size
  34042. * @param tessellation is the number of sides on the tubular surface
  34043. * @param radiusFunction is a custom function. If it is not null, it overwrittes the parameter `radius`. This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path
  34044. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  34045. * @param scene defines the hosting scene
  34046. * @param updatable defines if the mesh must be flagged as updatable
  34047. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34048. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  34049. * @returns a new Mesh
  34050. */
  34051. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34052. (i: number, distance: number): number;
  34053. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34054. /**
  34055. * Creates a polyhedron mesh.
  34056. * Please consider using the same method from the MeshBuilder class instead.
  34057. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  34058. * * The parameter `size` (positive float, default 1) sets the polygon size
  34059. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34060. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  34061. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  34062. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  34063. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  34064. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  34065. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34066. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34068. * @param name defines the name of the mesh to create
  34069. * @param options defines the options used to create the mesh
  34070. * @param scene defines the hosting scene
  34071. * @returns a new Mesh
  34072. */
  34073. static CreatePolyhedron(name: string, options: {
  34074. type?: number;
  34075. size?: number;
  34076. sizeX?: number;
  34077. sizeY?: number;
  34078. sizeZ?: number;
  34079. custom?: any;
  34080. faceUV?: Vector4[];
  34081. faceColors?: Color4[];
  34082. updatable?: boolean;
  34083. sideOrientation?: number;
  34084. }, scene: Scene): Mesh;
  34085. /**
  34086. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34087. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34088. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value than `radius`)
  34089. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34090. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  34091. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34092. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34094. * @param name defines the name of the mesh
  34095. * @param options defines the options used to create the mesh
  34096. * @param scene defines the hosting scene
  34097. * @returns a new Mesh
  34098. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34099. */
  34100. static CreateIcoSphere(name: string, options: {
  34101. radius?: number;
  34102. flat?: boolean;
  34103. subdivisions?: number;
  34104. sideOrientation?: number;
  34105. updatable?: boolean;
  34106. }, scene: Scene): Mesh;
  34107. /**
  34108. * Creates a decal mesh.
  34109. * Please consider using the same method from the MeshBuilder class instead.
  34110. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34111. * @param name defines the name of the mesh
  34112. * @param sourceMesh defines the mesh receiving the decal
  34113. * @param position sets the position of the decal in world coordinates
  34114. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34115. * @param size sets the decal scaling
  34116. * @param angle sets the angle to rotate the decal
  34117. * @returns a new Mesh
  34118. */
  34119. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34120. /** Creates a Capsule Mesh
  34121. * @param name defines the name of the mesh.
  34122. * @param options the constructors options used to shape the mesh.
  34123. * @param scene defines the scene the mesh is scoped to.
  34124. * @returns the capsule mesh
  34125. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34126. */
  34127. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34128. /**
  34129. * Prepare internal position array for software CPU skinning
  34130. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34131. */
  34132. setPositionsForCPUSkinning(): Float32Array;
  34133. /**
  34134. * Prepare internal normal array for software CPU skinning
  34135. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34136. */
  34137. setNormalsForCPUSkinning(): Float32Array;
  34138. /**
  34139. * Updates the vertex buffer by applying transformation from the bones
  34140. * @param skeleton defines the skeleton to apply to current mesh
  34141. * @returns the current mesh
  34142. */
  34143. applySkeleton(skeleton: Skeleton): Mesh;
  34144. /**
  34145. * Returns an object containing a min and max Vector3 which are the minimum and maximum vectors of each mesh bounding box from the passed array, in the world coordinates
  34146. * @param meshes defines the list of meshes to scan
  34147. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34148. */
  34149. static MinMax(meshes: AbstractMesh[]): {
  34150. min: Vector3;
  34151. max: Vector3;
  34152. };
  34153. /**
  34154. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34155. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34156. * @returns a vector3
  34157. */
  34158. static Center(meshesOrMinMaxVector: {
  34159. min: Vector3;
  34160. max: Vector3;
  34161. } | AbstractMesh[]): Vector3;
  34162. /**
  34163. * Merge the array of meshes into a single mesh for performance reasons.
  34164. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34165. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34166. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34167. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34168. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34169. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34170. * @returns a new mesh
  34171. */
  34172. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34173. /** @hidden */
  34174. addInstance(instance: InstancedMesh): void;
  34175. /** @hidden */
  34176. removeInstance(instance: InstancedMesh): void;
  34177. }
  34178. }
  34179. declare module BABYLON {
  34180. /**
  34181. * The options Interface for creating a Capsule Mesh
  34182. */
  34183. export interface ICreateCapsuleOptions {
  34184. /** The Orientation of the capsule. Default : Vector3.Up() */
  34185. orientation?: Vector3;
  34186. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  34187. subdivisions: number;
  34188. /** Number of cylindrical segments on the capsule. */
  34189. tessellation: number;
  34190. /** Height or Length of the capsule. */
  34191. height: number;
  34192. /** Radius of the capsule. */
  34193. radius: number;
  34194. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  34195. capSubdivisions: number;
  34196. /** Overwrite for the top radius. */
  34197. radiusTop?: number;
  34198. /** Overwrite for the bottom radius. */
  34199. radiusBottom?: number;
  34200. /** Overwrite for the top capSubdivisions. */
  34201. topCapSubdivisions?: number;
  34202. /** Overwrite for the bottom capSubdivisions. */
  34203. bottomCapSubdivisions?: number;
  34204. }
  34205. /**
  34206. * Class containing static functions to help procedurally build meshes
  34207. */
  34208. export class CapsuleBuilder {
  34209. /**
  34210. * Creates a capsule or a pill mesh
  34211. * @param name defines the name of the mesh
  34212. * @param options The constructors options.
  34213. * @param scene The scene the mesh is scoped to.
  34214. * @returns Capsule Mesh
  34215. */
  34216. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  34217. }
  34218. }
  34219. declare module BABYLON {
  34220. /**
  34221. * Define an interface for all classes that will get and set the data on vertices
  34222. */
  34223. export interface IGetSetVerticesData {
  34224. /**
  34225. * Gets a boolean indicating if specific vertex data is present
  34226. * @param kind defines the vertex data kind to use
  34227. * @returns true is data kind is present
  34228. */
  34229. isVerticesDataPresent(kind: string): boolean;
  34230. /**
  34231. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  34232. * @param kind defines the data kind (Position, normal, etc...)
  34233. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  34234. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34235. * @returns a float array containing vertex data
  34236. */
  34237. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34238. /**
  34239. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34240. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  34241. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34242. * @returns the indices array or an empty array if the mesh has no geometry
  34243. */
  34244. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34245. /**
  34246. * Set specific vertex data
  34247. * @param kind defines the data kind (Position, normal, etc...)
  34248. * @param data defines the vertex data to use
  34249. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  34250. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  34251. */
  34252. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  34253. /**
  34254. * Update a specific associated vertex buffer
  34255. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34256. * - VertexBuffer.PositionKind
  34257. * - VertexBuffer.UVKind
  34258. * - VertexBuffer.UV2Kind
  34259. * - VertexBuffer.UV3Kind
  34260. * - VertexBuffer.UV4Kind
  34261. * - VertexBuffer.UV5Kind
  34262. * - VertexBuffer.UV6Kind
  34263. * - VertexBuffer.ColorKind
  34264. * - VertexBuffer.MatricesIndicesKind
  34265. * - VertexBuffer.MatricesIndicesExtraKind
  34266. * - VertexBuffer.MatricesWeightsKind
  34267. * - VertexBuffer.MatricesWeightsExtraKind
  34268. * @param data defines the data source
  34269. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34270. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  34271. */
  34272. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  34273. /**
  34274. * Creates a new index buffer
  34275. * @param indices defines the indices to store in the index buffer
  34276. * @param totalVertices defines the total number of vertices (could be null)
  34277. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  34278. */
  34279. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  34280. }
  34281. /**
  34282. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  34283. */
  34284. export class VertexData {
  34285. /**
  34286. * Mesh side orientation : usually the external or front surface
  34287. */
  34288. static readonly FRONTSIDE: number;
  34289. /**
  34290. * Mesh side orientation : usually the internal or back surface
  34291. */
  34292. static readonly BACKSIDE: number;
  34293. /**
  34294. * Mesh side orientation : both internal and external or front and back surfaces
  34295. */
  34296. static readonly DOUBLESIDE: number;
  34297. /**
  34298. * Mesh side orientation : by default, `FRONTSIDE`
  34299. */
  34300. static readonly DEFAULTSIDE: number;
  34301. /**
  34302. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  34303. */
  34304. positions: Nullable<FloatArray>;
  34305. /**
  34306. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  34307. */
  34308. normals: Nullable<FloatArray>;
  34309. /**
  34310. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  34311. */
  34312. tangents: Nullable<FloatArray>;
  34313. /**
  34314. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34315. */
  34316. uvs: Nullable<FloatArray>;
  34317. /**
  34318. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34319. */
  34320. uvs2: Nullable<FloatArray>;
  34321. /**
  34322. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34323. */
  34324. uvs3: Nullable<FloatArray>;
  34325. /**
  34326. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34327. */
  34328. uvs4: Nullable<FloatArray>;
  34329. /**
  34330. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34331. */
  34332. uvs5: Nullable<FloatArray>;
  34333. /**
  34334. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34335. */
  34336. uvs6: Nullable<FloatArray>;
  34337. /**
  34338. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  34339. */
  34340. colors: Nullable<FloatArray>;
  34341. /**
  34342. * An array containing the list of indices to the array of matrices produced by bones, each vertex have up to 4 indices (8 if the matricesIndicesExtra is set).
  34343. */
  34344. matricesIndices: Nullable<FloatArray>;
  34345. /**
  34346. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  34347. */
  34348. matricesWeights: Nullable<FloatArray>;
  34349. /**
  34350. * An array extending the number of possible indices
  34351. */
  34352. matricesIndicesExtra: Nullable<FloatArray>;
  34353. /**
  34354. * An array extending the number of possible weights when the number of indices is extended
  34355. */
  34356. matricesWeightsExtra: Nullable<FloatArray>;
  34357. /**
  34358. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  34359. */
  34360. indices: Nullable<IndicesArray>;
  34361. /**
  34362. * Uses the passed data array to set the set the values for the specified kind of data
  34363. * @param data a linear array of floating numbers
  34364. * @param kind the type of data that is being set, eg positions, colors etc
  34365. */
  34366. set(data: FloatArray, kind: string): void;
  34367. /**
  34368. * Associates the vertexData to the passed Mesh.
  34369. * Sets it as updatable or not (default `false`)
  34370. * @param mesh the mesh the vertexData is applied to
  34371. * @param updatable when used and having the value true allows new data to update the vertexData
  34372. * @returns the VertexData
  34373. */
  34374. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  34375. /**
  34376. * Associates the vertexData to the passed Geometry.
  34377. * Sets it as updatable or not (default `false`)
  34378. * @param geometry the geometry the vertexData is applied to
  34379. * @param updatable when used and having the value true allows new data to update the vertexData
  34380. * @returns VertexData
  34381. */
  34382. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  34383. /**
  34384. * Updates the associated mesh
  34385. * @param mesh the mesh to be updated
  34386. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34387. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  34388. * @returns VertexData
  34389. */
  34390. updateMesh(mesh: Mesh): VertexData;
  34391. /**
  34392. * Updates the associated geometry
  34393. * @param geometry the geometry to be updated
  34394. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34395. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  34396. * @returns VertexData.
  34397. */
  34398. updateGeometry(geometry: Geometry): VertexData;
  34399. private _applyTo;
  34400. private _update;
  34401. /**
  34402. * Transforms each position and each normal of the vertexData according to the passed Matrix
  34403. * @param matrix the transforming matrix
  34404. * @returns the VertexData
  34405. */
  34406. transform(matrix: Matrix): VertexData;
  34407. /**
  34408. * Merges the passed VertexData into the current one
  34409. * @param other the VertexData to be merged into the current one
  34410. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  34411. * @returns the modified VertexData
  34412. */
  34413. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  34414. private _mergeElement;
  34415. private _validate;
  34416. /**
  34417. * Serializes the VertexData
  34418. * @returns a serialized object
  34419. */
  34420. serialize(): any;
  34421. /**
  34422. * Extracts the vertexData from a mesh
  34423. * @param mesh the mesh from which to extract the VertexData
  34424. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  34425. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34426. * @returns the object VertexData associated to the passed mesh
  34427. */
  34428. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34429. /**
  34430. * Extracts the vertexData from the geometry
  34431. * @param geometry the geometry from which to extract the VertexData
  34432. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  34433. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34434. * @returns the object VertexData associated to the passed mesh
  34435. */
  34436. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34437. private static _ExtractFrom;
  34438. /**
  34439. * Creates the VertexData for a Ribbon
  34440. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  34441. * * pathArray array of paths, each of which an array of successive Vector3
  34442. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  34443. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  34444. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  34445. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34446. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  34447. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  34448. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  34449. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  34450. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  34451. * @returns the VertexData of the ribbon
  34452. */
  34453. static CreateRibbon(options: {
  34454. pathArray: Vector3[][];
  34455. closeArray?: boolean;
  34456. closePath?: boolean;
  34457. offset?: number;
  34458. sideOrientation?: number;
  34459. frontUVs?: Vector4;
  34460. backUVs?: Vector4;
  34461. invertUV?: boolean;
  34462. uvs?: Vector2[];
  34463. colors?: Color4[];
  34464. }): VertexData;
  34465. /**
  34466. * Creates the VertexData for a box
  34467. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34468. * * size sets the width, height and depth of the box to the value of size, optional default 1
  34469. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  34470. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  34471. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  34472. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34473. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34474. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34475. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  34476. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  34477. * @returns the VertexData of the box
  34478. */
  34479. static CreateBox(options: {
  34480. size?: number;
  34481. width?: number;
  34482. height?: number;
  34483. depth?: number;
  34484. faceUV?: Vector4[];
  34485. faceColors?: Color4[];
  34486. sideOrientation?: number;
  34487. frontUVs?: Vector4;
  34488. backUVs?: Vector4;
  34489. }): VertexData;
  34490. /**
  34491. * Creates the VertexData for a tiled box
  34492. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34493. * * faceTiles sets the pattern, tile size and number of tiles for a face
  34494. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34495. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34496. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34497. * @returns the VertexData of the box
  34498. */
  34499. static CreateTiledBox(options: {
  34500. pattern?: number;
  34501. width?: number;
  34502. height?: number;
  34503. depth?: number;
  34504. tileSize?: number;
  34505. tileWidth?: number;
  34506. tileHeight?: number;
  34507. alignHorizontal?: number;
  34508. alignVertical?: number;
  34509. faceUV?: Vector4[];
  34510. faceColors?: Color4[];
  34511. sideOrientation?: number;
  34512. }): VertexData;
  34513. /**
  34514. * Creates the VertexData for a tiled plane
  34515. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34516. * * pattern a limited pattern arrangement depending on the number
  34517. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  34518. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  34519. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  34520. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34521. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  34522. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  34523. * @returns the VertexData of the tiled plane
  34524. */
  34525. static CreateTiledPlane(options: {
  34526. pattern?: number;
  34527. tileSize?: number;
  34528. tileWidth?: number;
  34529. tileHeight?: number;
  34530. size?: number;
  34531. width?: number;
  34532. height?: number;
  34533. alignHorizontal?: number;
  34534. alignVertical?: number;
  34535. sideOrientation?: number;
  34536. frontUVs?: Vector4;
  34537. backUVs?: Vector4;
  34538. }): VertexData;
  34539. /**
  34540. * Creates the VertexData for an ellipsoid, defaults to a sphere
  34541. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34542. * * segments sets the number of horizontal strips optional, default 32
  34543. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  34544. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  34545. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  34546. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  34547. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  34548. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  34549. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34550. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  34551. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  34552. * @returns the VertexData of the ellipsoid
  34553. */
  34554. static CreateSphere(options: {
  34555. segments?: number;
  34556. diameter?: number;
  34557. diameterX?: number;
  34558. diameterY?: number;
  34559. diameterZ?: number;
  34560. arc?: number;
  34561. slice?: number;
  34562. sideOrientation?: number;
  34563. frontUVs?: Vector4;
  34564. backUVs?: Vector4;
  34565. }): VertexData;
  34566. /**
  34567. * Creates the VertexData for a cylinder, cone or prism
  34568. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34569. * * height sets the height (y direction) of the cylinder, optional, default 2
  34570. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  34571. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  34572. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  34573. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  34574. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  34575. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  34576. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34577. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34578. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  34579. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  34580. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34581. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  34582. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  34583. * @returns the VertexData of the cylinder, cone or prism
  34584. */
  34585. static CreateCylinder(options: {
  34586. height?: number;
  34587. diameterTop?: number;
  34588. diameterBottom?: number;
  34589. diameter?: number;
  34590. tessellation?: number;
  34591. subdivisions?: number;
  34592. arc?: number;
  34593. faceColors?: Color4[];
  34594. faceUV?: Vector4[];
  34595. hasRings?: boolean;
  34596. enclose?: boolean;
  34597. sideOrientation?: number;
  34598. frontUVs?: Vector4;
  34599. backUVs?: Vector4;
  34600. }): VertexData;
  34601. /**
  34602. * Creates the VertexData for a torus
  34603. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34604. * * diameter the diameter of the torus, optional default 1
  34605. * * thickness the diameter of the tube forming the torus, optional default 0.5
  34606. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  34607. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34608. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  34609. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  34610. * @returns the VertexData of the torus
  34611. */
  34612. static CreateTorus(options: {
  34613. diameter?: number;
  34614. thickness?: number;
  34615. tessellation?: number;
  34616. sideOrientation?: number;
  34617. frontUVs?: Vector4;
  34618. backUVs?: Vector4;
  34619. }): VertexData;
  34620. /**
  34621. * Creates the VertexData of the LineSystem
  34622. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  34623. * - lines an array of lines, each line being an array of successive Vector3
  34624. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  34625. * @returns the VertexData of the LineSystem
  34626. */
  34627. static CreateLineSystem(options: {
  34628. lines: Vector3[][];
  34629. colors?: Nullable<Color4[][]>;
  34630. }): VertexData;
  34631. /**
  34632. * Create the VertexData for a DashedLines
  34633. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  34634. * - points an array successive Vector3
  34635. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  34636. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  34637. * - dashNb the intended total number of dashes, optional, default 200
  34638. * @returns the VertexData for the DashedLines
  34639. */
  34640. static CreateDashedLines(options: {
  34641. points: Vector3[];
  34642. dashSize?: number;
  34643. gapSize?: number;
  34644. dashNb?: number;
  34645. }): VertexData;
  34646. /**
  34647. * Creates the VertexData for a Ground
  34648. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  34649. * - width the width (x direction) of the ground, optional, default 1
  34650. * - height the height (z direction) of the ground, optional, default 1
  34651. * - subdivisions the number of subdivisions per side, optional, default 1
  34652. * @returns the VertexData of the Ground
  34653. */
  34654. static CreateGround(options: {
  34655. width?: number;
  34656. height?: number;
  34657. subdivisions?: number;
  34658. subdivisionsX?: number;
  34659. subdivisionsY?: number;
  34660. }): VertexData;
  34661. /**
  34662. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  34663. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  34664. * * xmin the ground minimum X coordinate, optional, default -1
  34665. * * zmin the ground minimum Z coordinate, optional, default -1
  34666. * * xmax the ground maximum X coordinate, optional, default 1
  34667. * * zmax the ground maximum Z coordinate, optional, default 1
  34668. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  34669. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  34670. * @returns the VertexData of the TiledGround
  34671. */
  34672. static CreateTiledGround(options: {
  34673. xmin: number;
  34674. zmin: number;
  34675. xmax: number;
  34676. zmax: number;
  34677. subdivisions?: {
  34678. w: number;
  34679. h: number;
  34680. };
  34681. precision?: {
  34682. w: number;
  34683. h: number;
  34684. };
  34685. }): VertexData;
  34686. /**
  34687. * Creates the VertexData of the Ground designed from a heightmap
  34688. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  34689. * * width the width (x direction) of the ground
  34690. * * height the height (z direction) of the ground
  34691. * * subdivisions the number of subdivisions per side
  34692. * * minHeight the minimum altitude on the ground, optional, default 0
  34693. * * maxHeight the maximum altitude on the ground, optional default 1
  34694. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  34695. * * buffer the array holding the image color data
  34696. * * bufferWidth the width of image
  34697. * * bufferHeight the height of image
  34698. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  34699. * @returns the VertexData of the Ground designed from a heightmap
  34700. */
  34701. static CreateGroundFromHeightMap(options: {
  34702. width: number;
  34703. height: number;
  34704. subdivisions: number;
  34705. minHeight: number;
  34706. maxHeight: number;
  34707. colorFilter: Color3;
  34708. buffer: Uint8Array;
  34709. bufferWidth: number;
  34710. bufferHeight: number;
  34711. alphaFilter: number;
  34712. }): VertexData;
  34713. /**
  34714. * Creates the VertexData for a Plane
  34715. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  34716. * * size sets the width and height of the plane to the value of size, optional default 1
  34717. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  34718. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  34719. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34720. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  34721. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  34722. * @returns the VertexData of the box
  34723. */
  34724. static CreatePlane(options: {
  34725. size?: number;
  34726. width?: number;
  34727. height?: number;
  34728. sideOrientation?: number;
  34729. frontUVs?: Vector4;
  34730. backUVs?: Vector4;
  34731. }): VertexData;
  34732. /**
  34733. * Creates the VertexData of the Disc or regular Polygon
  34734. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  34735. * * radius the radius of the disc, optional default 0.5
  34736. * * tessellation the number of polygon sides, optional, default 64
  34737. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  34738. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34739. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  34740. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  34741. * @returns the VertexData of the box
  34742. */
  34743. static CreateDisc(options: {
  34744. radius?: number;
  34745. tessellation?: number;
  34746. arc?: number;
  34747. sideOrientation?: number;
  34748. frontUVs?: Vector4;
  34749. backUVs?: Vector4;
  34750. }): VertexData;
  34751. /**
  34752. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  34753. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  34754. * @param polygon a mesh built from polygonTriangulation.build()
  34755. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34756. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34757. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34758. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  34759. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  34760. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  34761. * @returns the VertexData of the Polygon
  34762. */
  34763. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  34764. /**
  34765. * Creates the VertexData of the IcoSphere
  34766. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  34767. * * radius the radius of the IcoSphere, optional default 1
  34768. * * radiusX allows stretching in the x direction, optional, default radius
  34769. * * radiusY allows stretching in the y direction, optional, default radius
  34770. * * radiusZ allows stretching in the z direction, optional, default radius
  34771. * * flat when true creates a flat shaded mesh, optional, default true
  34772. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34773. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34774. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  34775. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  34776. * @returns the VertexData of the IcoSphere
  34777. */
  34778. static CreateIcoSphere(options: {
  34779. radius?: number;
  34780. radiusX?: number;
  34781. radiusY?: number;
  34782. radiusZ?: number;
  34783. flat?: boolean;
  34784. subdivisions?: number;
  34785. sideOrientation?: number;
  34786. frontUVs?: Vector4;
  34787. backUVs?: Vector4;
  34788. }): VertexData;
  34789. /**
  34790. * Creates the VertexData for a Polyhedron
  34791. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  34792. * * type provided types are:
  34793. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  34794. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  34795. * * size the size of the IcoSphere, optional default 1
  34796. * * sizeX allows stretching in the x direction, optional, default size
  34797. * * sizeY allows stretching in the y direction, optional, default size
  34798. * * sizeZ allows stretching in the z direction, optional, default size
  34799. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  34800. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34801. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34802. * * flat when true creates a flat shaded mesh, optional, default true
  34803. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34804. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34805. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  34806. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  34807. * @returns the VertexData of the Polyhedron
  34808. */
  34809. static CreatePolyhedron(options: {
  34810. type?: number;
  34811. size?: number;
  34812. sizeX?: number;
  34813. sizeY?: number;
  34814. sizeZ?: number;
  34815. custom?: any;
  34816. faceUV?: Vector4[];
  34817. faceColors?: Color4[];
  34818. flat?: boolean;
  34819. sideOrientation?: number;
  34820. frontUVs?: Vector4;
  34821. backUVs?: Vector4;
  34822. }): VertexData;
  34823. /**
  34824. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  34825. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  34826. * @returns the VertexData of the Capsule
  34827. */
  34828. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  34829. /**
  34830. * Creates the VertexData for a TorusKnot
  34831. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  34832. * * radius the radius of the torus knot, optional, default 2
  34833. * * tube the thickness of the tube, optional, default 0.5
  34834. * * radialSegments the number of sides on each tube segments, optional, default 32
  34835. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  34836. * * p the number of windings around the z axis, optional, default 2
  34837. * * q the number of windings around the x axis, optional, default 3
  34838. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34839. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  34840. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  34841. * @returns the VertexData of the Torus Knot
  34842. */
  34843. static CreateTorusKnot(options: {
  34844. radius?: number;
  34845. tube?: number;
  34846. radialSegments?: number;
  34847. tubularSegments?: number;
  34848. p?: number;
  34849. q?: number;
  34850. sideOrientation?: number;
  34851. frontUVs?: Vector4;
  34852. backUVs?: Vector4;
  34853. }): VertexData;
  34854. /**
  34855. * Compute normals for given positions and indices
  34856. * @param positions an array of vertex positions, [...., x, y, z, ......]
  34857. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  34858. * @param normals an array of vertex normals, [...., x, y, z, ......]
  34859. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  34860. * * facetNormals : optional array of facet normals (vector3)
  34861. * * facetPositions : optional array of facet positions (vector3)
  34862. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  34863. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  34864. * * bInfo : optional bounding info, required for facetPartitioning computation
  34865. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  34866. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  34867. * * useRightHandedSystem: optional boolean to for right handed system computation
  34868. * * depthSort : optional boolean to enable the facet depth sort computation
  34869. * * distanceTo : optional Vector3 to compute the facet depth from this location
  34870. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  34871. */
  34872. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  34873. facetNormals?: any;
  34874. facetPositions?: any;
  34875. facetPartitioning?: any;
  34876. ratio?: number;
  34877. bInfo?: any;
  34878. bbSize?: Vector3;
  34879. subDiv?: any;
  34880. useRightHandedSystem?: boolean;
  34881. depthSort?: boolean;
  34882. distanceTo?: Vector3;
  34883. depthSortedFacets?: any;
  34884. }): void;
  34885. /** @hidden */
  34886. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  34887. /**
  34888. * Applies VertexData created from the imported parameters to the geometry
  34889. * @param parsedVertexData the parsed data from an imported file
  34890. * @param geometry the geometry to apply the VertexData to
  34891. */
  34892. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  34893. }
  34894. }
  34895. declare module BABYLON {
  34896. /**
  34897. * Class containing static functions to help procedurally build meshes
  34898. */
  34899. export class DiscBuilder {
  34900. /**
  34901. * Creates a plane polygonal mesh. By default, this is a disc
  34902. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34903. * * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  34904. * * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  34905. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34906. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34908. * @param name defines the name of the mesh
  34909. * @param options defines the options used to create the mesh
  34910. * @param scene defines the hosting scene
  34911. * @returns the plane polygonal mesh
  34912. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34913. */
  34914. static CreateDisc(name: string, options: {
  34915. radius?: number;
  34916. tessellation?: number;
  34917. arc?: number;
  34918. updatable?: boolean;
  34919. sideOrientation?: number;
  34920. frontUVs?: Vector4;
  34921. backUVs?: Vector4;
  34922. }, scene?: Nullable<Scene>): Mesh;
  34923. }
  34924. }
  34925. declare module BABYLON {
  34926. /**
  34927. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34928. *As it is just a mesh, the SPS has all the same properties than any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  34929. * The SPS is also a particle system. It provides some methods to manage the particles.
  34930. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34931. *
  34932. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34933. */
  34934. export class SolidParticleSystem implements IDisposable {
  34935. /**
  34936. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34937. * Example : var p = SPS.particles[i];
  34938. */
  34939. particles: SolidParticle[];
  34940. /**
  34941. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34942. */
  34943. nbParticles: number;
  34944. /**
  34945. * If the particles must ever face the camera (default false). Useful for planar particles.
  34946. */
  34947. billboard: boolean;
  34948. /**
  34949. * Recompute normals when adding a shape
  34950. */
  34951. recomputeNormals: boolean;
  34952. /**
  34953. * This a counter ofr your own usage. It's not set by any SPS functions.
  34954. */
  34955. counter: number;
  34956. /**
  34957. * The SPS name. This name is also given to the underlying mesh.
  34958. */
  34959. name: string;
  34960. /**
  34961. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34962. */
  34963. mesh: Mesh;
  34964. /**
  34965. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34966. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  34967. */
  34968. vars: any;
  34969. /**
  34970. * This array is populated when the SPS is set as 'pickable'.
  34971. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34972. * Each element of this array is an object `{idx: int, faceId: int}`.
  34973. * `idx` is the picked particle index in the `SPS.particles` array
  34974. * `faceId` is the picked face index counted within this particle.
  34975. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  34976. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  34977. * Use the method SPS.pickedParticle(pickingInfo) instead.
  34978. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34979. */
  34980. pickedParticles: {
  34981. idx: number;
  34982. faceId: number;
  34983. }[];
  34984. /**
  34985. * This array is populated when the SPS is set as 'pickable'
  34986. * Each key of this array is a submesh index.
  34987. * Each element of this array is a second array defined like this :
  34988. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  34989. * Each element of this second array is an object `{idx: int, faceId: int}`.
  34990. * `idx` is the picked particle index in the `SPS.particles` array
  34991. * `faceId` is the picked face index counted within this particle.
  34992. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  34993. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34994. */
  34995. pickedBySubMesh: {
  34996. idx: number;
  34997. faceId: number;
  34998. }[][];
  34999. /**
  35000. * This array is populated when `enableDepthSort` is set to true.
  35001. * Each element of this array is an instance of the class DepthSortedParticle.
  35002. */
  35003. depthSortedParticles: DepthSortedParticle[];
  35004. /**
  35005. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35006. * @hidden
  35007. */
  35008. _bSphereOnly: boolean;
  35009. /**
  35010. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  35011. * @hidden
  35012. */
  35013. _bSphereRadiusFactor: number;
  35014. private _scene;
  35015. private _positions;
  35016. private _indices;
  35017. private _normals;
  35018. private _colors;
  35019. private _uvs;
  35020. private _indices32;
  35021. private _positions32;
  35022. private _normals32;
  35023. private _fixedNormal32;
  35024. private _colors32;
  35025. private _uvs32;
  35026. private _index;
  35027. private _updatable;
  35028. private _pickable;
  35029. private _isVisibilityBoxLocked;
  35030. private _alwaysVisible;
  35031. private _depthSort;
  35032. private _expandable;
  35033. private _shapeCounter;
  35034. private _copy;
  35035. private _color;
  35036. private _computeParticleColor;
  35037. private _computeParticleTexture;
  35038. private _computeParticleRotation;
  35039. private _computeParticleVertex;
  35040. private _computeBoundingBox;
  35041. private _depthSortParticles;
  35042. private _camera;
  35043. private _mustUnrotateFixedNormals;
  35044. private _particlesIntersect;
  35045. private _needs32Bits;
  35046. private _isNotBuilt;
  35047. private _lastParticleId;
  35048. private _idxOfId;
  35049. private _multimaterialEnabled;
  35050. private _useModelMaterial;
  35051. private _indicesByMaterial;
  35052. private _materialIndexes;
  35053. private _depthSortFunction;
  35054. private _materialSortFunction;
  35055. private _materials;
  35056. private _multimaterial;
  35057. private _materialIndexesById;
  35058. private _defaultMaterial;
  35059. private _autoUpdateSubMeshes;
  35060. private _tmpVertex;
  35061. /**
  35062. * Creates a SPS (Solid Particle System) object.
  35063. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35064. * @param scene (Scene) is the scene in which the SPS is added.
  35065. * @param options defines the options of the sps e.g.
  35066. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35067. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35068. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35069. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  35070. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35071. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35072. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35073. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35074. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  35075. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35076. */
  35077. constructor(name: string, scene: Scene, options?: {
  35078. updatable?: boolean;
  35079. isPickable?: boolean;
  35080. enableDepthSort?: boolean;
  35081. particleIntersection?: boolean;
  35082. boundingSphereOnly?: boolean;
  35083. bSphereRadiusFactor?: number;
  35084. expandable?: boolean;
  35085. useModelMaterial?: boolean;
  35086. enableMultiMaterial?: boolean;
  35087. });
  35088. /**
  35089. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35090. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35091. * @returns the created mesh
  35092. */
  35093. buildMesh(): Mesh;
  35094. /**
  35095. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35096. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35097. * Thus the particles generated from `digest()` have their property `position` set yet.
  35098. * @param mesh ( Mesh ) is the mesh to be digested
  35099. * @param options {facetNb} (optional integer, default 1) is the number of mesh facets per particle, this parameter is overriden by the parameter `number` if any
  35100. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35101. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35102. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35103. * @returns the current SPS
  35104. */
  35105. digest(mesh: Mesh, options?: {
  35106. facetNb?: number;
  35107. number?: number;
  35108. delta?: number;
  35109. storage?: [];
  35110. }): SolidParticleSystem;
  35111. /**
  35112. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35113. * @hidden
  35114. */
  35115. private _unrotateFixedNormals;
  35116. /**
  35117. * Resets the temporary working copy particle
  35118. * @hidden
  35119. */
  35120. private _resetCopy;
  35121. /**
  35122. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35123. * @param p the current index in the positions array to be updated
  35124. * @param ind the current index in the indices array
  35125. * @param shape a Vector3 array, the shape geometry
  35126. * @param positions the positions array to be updated
  35127. * @param meshInd the shape indices array
  35128. * @param indices the indices array to be updated
  35129. * @param meshUV the shape uv array
  35130. * @param uvs the uv array to be updated
  35131. * @param meshCol the shape color array
  35132. * @param colors the color array to be updated
  35133. * @param meshNor the shape normals array
  35134. * @param normals the normals array to be updated
  35135. * @param idx the particle index
  35136. * @param idxInShape the particle index in its shape
  35137. * @param options the addShape() method passed options
  35138. * @model the particle model
  35139. * @hidden
  35140. */
  35141. private _meshBuilder;
  35142. /**
  35143. * Returns a shape Vector3 array from positions float array
  35144. * @param positions float array
  35145. * @returns a vector3 array
  35146. * @hidden
  35147. */
  35148. private _posToShape;
  35149. /**
  35150. * Returns a shapeUV array from a float uvs (array deep copy)
  35151. * @param uvs as a float array
  35152. * @returns a shapeUV array
  35153. * @hidden
  35154. */
  35155. private _uvsToShapeUV;
  35156. /**
  35157. * Adds a new particle object in the particles array
  35158. * @param idx particle index in particles array
  35159. * @param id particle id
  35160. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35161. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35162. * @param model particle ModelShape object
  35163. * @param shapeId model shape identifier
  35164. * @param idxInShape index of the particle in the current model
  35165. * @param bInfo model bounding info object
  35166. * @param storage target storage array, if any
  35167. * @hidden
  35168. */
  35169. private _addParticle;
  35170. /**
  35171. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35172. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35173. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35174. * @param nb (positive integer) the number of particles to be created from this model
  35175. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35176. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35177. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35178. * @returns the number of shapes in the system
  35179. */
  35180. addShape(mesh: Mesh, nb: number, options?: {
  35181. positionFunction?: any;
  35182. vertexFunction?: any;
  35183. storage?: [];
  35184. }): number;
  35185. /**
  35186. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35187. * @hidden
  35188. */
  35189. private _rebuildParticle;
  35190. /**
  35191. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35192. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  35193. * @returns the SPS.
  35194. */
  35195. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35196. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35197. * Returns an array with the removed particles.
  35198. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  35199. * The SPS can't be empty so at least one particle needs to remain in place.
  35200. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35201. * @param start index of the first particle to remove
  35202. * @param end index of the last particle to remove (included)
  35203. * @returns an array populated with the removed particles
  35204. */
  35205. removeParticles(start: number, end: number): SolidParticle[];
  35206. /**
  35207. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35208. * @param solidParticleArray an array populated with Solid Particles objects
  35209. * @returns the SPS
  35210. */
  35211. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35212. /**
  35213. * Creates a new particle and modifies the SPS mesh geometry :
  35214. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35215. * - calls _addParticle() to populate the particle array
  35216. * factorized code from addShape() and insertParticlesFromArray()
  35217. * @param idx particle index in the particles array
  35218. * @param i particle index in its shape
  35219. * @param modelShape particle ModelShape object
  35220. * @param shape shape vertex array
  35221. * @param meshInd shape indices array
  35222. * @param meshUV shape uv array
  35223. * @param meshCol shape color array
  35224. * @param meshNor shape normals array
  35225. * @param bbInfo shape bounding info
  35226. * @param storage target particle storage
  35227. * @options addShape() passed options
  35228. * @hidden
  35229. */
  35230. private _insertNewParticle;
  35231. /**
  35232. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35233. * This method calls `updateParticle()` for each particle of the SPS.
  35234. * For an animated SPS, it is usually called within the render loop.
  35235. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  35236. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35237. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35238. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35239. * @returns the SPS.
  35240. */
  35241. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35242. /**
  35243. * Disposes the SPS.
  35244. */
  35245. dispose(): void;
  35246. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  35247. * idx is the particle index in the SPS
  35248. * faceId is the picked face index counted within this particle.
  35249. * Returns null if the pickInfo can't identify a picked particle.
  35250. * @param pickingInfo (PickingInfo object)
  35251. * @returns {idx: number, faceId: number} or null
  35252. */
  35253. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35254. idx: number;
  35255. faceId: number;
  35256. }>;
  35257. /**
  35258. * Returns a SolidParticle object from its identifier : particle.id
  35259. * @param id (integer) the particle Id
  35260. * @returns the searched particle or null if not found in the SPS.
  35261. */
  35262. getParticleById(id: number): Nullable<SolidParticle>;
  35263. /**
  35264. * Returns a new array populated with the particles having the passed shapeId.
  35265. * @param shapeId (integer) the shape identifier
  35266. * @returns a new solid particle array
  35267. */
  35268. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35269. /**
  35270. * Populates the passed array "ref" with the particles having the passed shapeId.
  35271. * @param shapeId the shape identifier
  35272. * @returns the SPS
  35273. * @param ref
  35274. */
  35275. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35276. /**
  35277. * Computes the required SubMeshes according the materials assigned to the particles.
  35278. * @returns the solid particle system.
  35279. * Does nothing if called before the SPS mesh is built.
  35280. */
  35281. computeSubMeshes(): SolidParticleSystem;
  35282. /**
  35283. * Sorts the solid particles by material when MultiMaterial is enabled.
  35284. * Updates the indices32 array.
  35285. * Updates the indicesByMaterial array.
  35286. * Updates the mesh indices array.
  35287. * @returns the SPS
  35288. * @hidden
  35289. */
  35290. private _sortParticlesByMaterial;
  35291. /**
  35292. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35293. * @hidden
  35294. */
  35295. private _setMaterialIndexesById;
  35296. /**
  35297. * Returns an array with unique values of Materials from the passed array
  35298. * @param array the material array to be checked and filtered
  35299. * @hidden
  35300. */
  35301. private _filterUniqueMaterialId;
  35302. /**
  35303. * Sets a new Standard Material as _defaultMaterial if not already set.
  35304. * @hidden
  35305. */
  35306. private _setDefaultMaterial;
  35307. /**
  35308. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  35309. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35310. * @returns the SPS.
  35311. */
  35312. refreshVisibleSize(): SolidParticleSystem;
  35313. /**
  35314. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35315. * @param size the size (float) of the visibility box
  35316. * note : this doesn't lock the SPS mesh bounding box.
  35317. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35318. */
  35319. setVisibilityBox(size: number): void;
  35320. /**
  35321. * Gets whether the SPS as always visible or not
  35322. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35323. */
  35324. get isAlwaysVisible(): boolean;
  35325. /**
  35326. * Sets the SPS as always visible or not
  35327. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35328. */
  35329. set isAlwaysVisible(val: boolean);
  35330. /**
  35331. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35332. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35333. */
  35334. set isVisibilityBoxLocked(val: boolean);
  35335. /**
  35336. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35337. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35338. */
  35339. get isVisibilityBoxLocked(): boolean;
  35340. /**
  35341. * Tells to `setParticles()` to compute the particle rotations or not.
  35342. * Default value : true. The SPS is faster when it's set to false.
  35343. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35344. */
  35345. set computeParticleRotation(val: boolean);
  35346. /**
  35347. * Tells to `setParticles()` to compute the particle colors or not.
  35348. * Default value : true. The SPS is faster when it's set to false.
  35349. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35350. */
  35351. set computeParticleColor(val: boolean);
  35352. set computeParticleTexture(val: boolean);
  35353. /**
  35354. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  35355. * Default value : false. The SPS is faster when it's set to false.
  35356. * Note : the particle custom vertex positions aren't stored values.
  35357. */
  35358. set computeParticleVertex(val: boolean);
  35359. /**
  35360. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  35361. */
  35362. set computeBoundingBox(val: boolean);
  35363. /**
  35364. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  35365. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35366. * Default : `true`
  35367. */
  35368. set depthSortParticles(val: boolean);
  35369. /**
  35370. * Gets if `setParticles()` computes the particle rotations or not.
  35371. * Default value : true. The SPS is faster when it's set to false.
  35372. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35373. */
  35374. get computeParticleRotation(): boolean;
  35375. /**
  35376. * Gets if `setParticles()` computes the particle colors or not.
  35377. * Default value : true. The SPS is faster when it's set to false.
  35378. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35379. */
  35380. get computeParticleColor(): boolean;
  35381. /**
  35382. * Gets if `setParticles()` computes the particle textures or not.
  35383. * Default value : true. The SPS is faster when it's set to false.
  35384. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  35385. */
  35386. get computeParticleTexture(): boolean;
  35387. /**
  35388. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  35389. * Default value : false. The SPS is faster when it's set to false.
  35390. * Note : the particle custom vertex positions aren't stored values.
  35391. */
  35392. get computeParticleVertex(): boolean;
  35393. /**
  35394. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  35395. */
  35396. get computeBoundingBox(): boolean;
  35397. /**
  35398. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  35399. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35400. * Default : `true`
  35401. */
  35402. get depthSortParticles(): boolean;
  35403. /**
  35404. * Gets if the SPS is created as expandable at construction time.
  35405. * Default : `false`
  35406. */
  35407. get expandable(): boolean;
  35408. /**
  35409. * Gets if the SPS supports the Multi Materials
  35410. */
  35411. get multimaterialEnabled(): boolean;
  35412. /**
  35413. * Gets if the SPS uses the model materials for its own multimaterial.
  35414. */
  35415. get useModelMaterial(): boolean;
  35416. /**
  35417. * The SPS used material array.
  35418. */
  35419. get materials(): Material[];
  35420. /**
  35421. * Sets the SPS MultiMaterial from the passed materials.
  35422. * Note : the passed array is internally copied and not used then by reference.
  35423. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  35424. */
  35425. setMultiMaterial(materials: Material[]): void;
  35426. /**
  35427. * The SPS computed multimaterial object
  35428. */
  35429. get multimaterial(): MultiMaterial;
  35430. set multimaterial(mm: MultiMaterial);
  35431. /**
  35432. * If the subMeshes must be updated on the next call to setParticles()
  35433. */
  35434. get autoUpdateSubMeshes(): boolean;
  35435. set autoUpdateSubMeshes(val: boolean);
  35436. /**
  35437. * This function does nothing. It may be overwritten to set all the particle first values.
  35438. * The SPS doesn't call this function, you may have to call it by your own.
  35439. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35440. */
  35441. initParticles(): void;
  35442. /**
  35443. * This function does nothing. It may be overwritten to recycle a particle.
  35444. * The SPS doesn't call this function, you may have to call it by your own.
  35445. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35446. * @param particle The particle to recycle
  35447. * @returns the recycled particle
  35448. */
  35449. recycleParticle(particle: SolidParticle): SolidParticle;
  35450. /**
  35451. * Updates a particle : this function should be overwritten by the user.
  35452. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  35453. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35454. * @example : just set a particle position or velocity and recycle conditions
  35455. * @param particle The particle to update
  35456. * @returns the updated particle
  35457. */
  35458. updateParticle(particle: SolidParticle): SolidParticle;
  35459. /**
  35460. * Updates a vertex of a particle : it can be overwritten by the user.
  35461. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  35462. * @param particle the current particle
  35463. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  35464. * @param pt the index of the current vertex in the particle shape
  35465. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  35466. * @example : just set a vertex particle position or color
  35467. * @returns the sps
  35468. */
  35469. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  35470. /**
  35471. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  35472. * This does nothing and may be overwritten by the user.
  35473. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35474. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35475. * @param update the boolean update value actually passed to setParticles()
  35476. */
  35477. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35478. /**
  35479. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  35480. * This will be passed three parameters.
  35481. * This does nothing and may be overwritten by the user.
  35482. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35483. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35484. * @param update the boolean update value actually passed to setParticles()
  35485. */
  35486. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35487. }
  35488. }
  35489. declare module BABYLON {
  35490. /**
  35491. * Represents one particle of a solid particle system.
  35492. */
  35493. export class SolidParticle {
  35494. /**
  35495. * particle global index
  35496. */
  35497. idx: number;
  35498. /**
  35499. * particle identifier
  35500. */
  35501. id: number;
  35502. /**
  35503. * The color of the particle
  35504. */
  35505. color: Nullable<Color4>;
  35506. /**
  35507. * The world space position of the particle.
  35508. */
  35509. position: Vector3;
  35510. /**
  35511. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  35512. */
  35513. rotation: Vector3;
  35514. /**
  35515. * The world space rotation quaternion of the particle.
  35516. */
  35517. rotationQuaternion: Nullable<Quaternion>;
  35518. /**
  35519. * The scaling of the particle.
  35520. */
  35521. scaling: Vector3;
  35522. /**
  35523. * The uvs of the particle.
  35524. */
  35525. uvs: Vector4;
  35526. /**
  35527. * The current speed of the particle.
  35528. */
  35529. velocity: Vector3;
  35530. /**
  35531. * The pivot point in the particle local space.
  35532. */
  35533. pivot: Vector3;
  35534. /**
  35535. * Must the particle be translated from its pivot point in its local space ?
  35536. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  35537. * Default : false
  35538. */
  35539. translateFromPivot: boolean;
  35540. /**
  35541. * Is the particle active or not ?
  35542. */
  35543. alive: boolean;
  35544. /**
  35545. * Is the particle visible or not ?
  35546. */
  35547. isVisible: boolean;
  35548. /**
  35549. * Index of this particle in the global "positions" array (Internal use)
  35550. * @hidden
  35551. */
  35552. _pos: number;
  35553. /**
  35554. * @hidden Index of this particle in the global "indices" array (Internal use)
  35555. */
  35556. _ind: number;
  35557. /**
  35558. * @hidden ModelShape of this particle (Internal use)
  35559. */
  35560. _model: ModelShape;
  35561. /**
  35562. * ModelShape id of this particle
  35563. */
  35564. shapeId: number;
  35565. /**
  35566. * Index of the particle in its shape id
  35567. */
  35568. idxInShape: number;
  35569. /**
  35570. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  35571. */
  35572. _modelBoundingInfo: BoundingInfo;
  35573. /**
  35574. * @hidden Particle BoundingInfo object (Internal use)
  35575. */
  35576. _boundingInfo: BoundingInfo;
  35577. /**
  35578. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  35579. */
  35580. _sps: SolidParticleSystem;
  35581. /**
  35582. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  35583. */
  35584. _stillInvisible: boolean;
  35585. /**
  35586. * @hidden Last computed particle rotation matrix
  35587. */
  35588. _rotationMatrix: number[];
  35589. /**
  35590. * Parent particle Id, if any.
  35591. * Default null.
  35592. */
  35593. parentId: Nullable<number>;
  35594. /**
  35595. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  35596. */
  35597. materialIndex: Nullable<number>;
  35598. /**
  35599. * Custom object or properties.
  35600. */
  35601. props: Nullable<any>;
  35602. /**
  35603. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  35604. * The possible values are :
  35605. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35606. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35607. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35608. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35609. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35610. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  35611. * */
  35612. cullingStrategy: number;
  35613. /**
  35614. * @hidden Internal global position in the SPS.
  35615. */
  35616. _globalPosition: Vector3;
  35617. /**
  35618. * Creates a Solid Particle object.
  35619. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  35620. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  35621. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  35622. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  35623. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  35624. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  35625. * @param shapeId (integer) is the model shape identifier in the SPS.
  35626. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  35627. * @param sps defines the sps it is associated to
  35628. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  35629. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  35630. */
  35631. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  35632. /**
  35633. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  35634. * @param target the particle target
  35635. * @returns the current particle
  35636. */
  35637. copyToRef(target: SolidParticle): SolidParticle;
  35638. /**
  35639. * Legacy support, changed scale to scaling
  35640. */
  35641. get scale(): Vector3;
  35642. /**
  35643. * Legacy support, changed scale to scaling
  35644. */
  35645. set scale(scale: Vector3);
  35646. /**
  35647. * Legacy support, changed quaternion to rotationQuaternion
  35648. */
  35649. get quaternion(): Nullable<Quaternion>;
  35650. /**
  35651. * Legacy support, changed quaternion to rotationQuaternion
  35652. */
  35653. set quaternion(q: Nullable<Quaternion>);
  35654. /**
  35655. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  35656. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  35657. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  35658. * @returns true if it intersects
  35659. */
  35660. intersectsMesh(target: Mesh | SolidParticle): boolean;
  35661. /**
  35662. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  35663. * A particle is in the frustum if its bounding box intersects the frustum
  35664. * @param frustumPlanes defines the frustum to test
  35665. * @returns true if the particle is in the frustum planes
  35666. */
  35667. isInFrustum(frustumPlanes: Plane[]): boolean;
  35668. /**
  35669. * get the rotation matrix of the particle
  35670. * @hidden
  35671. */
  35672. getRotationMatrix(m: Matrix): void;
  35673. }
  35674. /**
  35675. * Represents the shape of the model used by one particle of a solid particle system.
  35676. * SPS internal tool, don't use it manually.
  35677. */
  35678. export class ModelShape {
  35679. /**
  35680. * The shape id
  35681. * @hidden
  35682. */
  35683. shapeID: number;
  35684. /**
  35685. * flat array of model positions (internal use)
  35686. * @hidden
  35687. */
  35688. _shape: Vector3[];
  35689. /**
  35690. * flat array of model UVs (internal use)
  35691. * @hidden
  35692. */
  35693. _shapeUV: number[];
  35694. /**
  35695. * color array of the model
  35696. * @hidden
  35697. */
  35698. _shapeColors: number[];
  35699. /**
  35700. * indices array of the model
  35701. * @hidden
  35702. */
  35703. _indices: number[];
  35704. /**
  35705. * normals array of the model
  35706. * @hidden
  35707. */
  35708. _normals: number[];
  35709. /**
  35710. * length of the shape in the model indices array (internal use)
  35711. * @hidden
  35712. */
  35713. _indicesLength: number;
  35714. /**
  35715. * Custom position function (internal use)
  35716. * @hidden
  35717. */
  35718. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  35719. /**
  35720. * Custom vertex function (internal use)
  35721. * @hidden
  35722. */
  35723. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  35724. /**
  35725. * Model material (internal use)
  35726. * @hidden
  35727. */
  35728. _material: Nullable<Material>;
  35729. /**
  35730. * Creates a ModelShape object. This is an internal simplified reference to a mesh used as for a model to replicate particles from by the SPS.
  35731. * SPS internal tool, don't use it manually.
  35732. * @hidden
  35733. */
  35734. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  35735. }
  35736. /**
  35737. * Represents a Depth Sorted Particle in the solid particle system.
  35738. * @hidden
  35739. */
  35740. export class DepthSortedParticle {
  35741. /**
  35742. * Particle index
  35743. */
  35744. idx: number;
  35745. /**
  35746. * Index of the particle in the "indices" array
  35747. */
  35748. ind: number;
  35749. /**
  35750. * Length of the particle shape in the "indices" array
  35751. */
  35752. indicesLength: number;
  35753. /**
  35754. * Squared distance from the particle to the camera
  35755. */
  35756. sqDistance: number;
  35757. /**
  35758. * Material index when used with MultiMaterials
  35759. */
  35760. materialIndex: number;
  35761. /**
  35762. * Creates a new sorted particle
  35763. * @param materialIndex
  35764. */
  35765. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  35766. }
  35767. /**
  35768. * Represents a solid particle vertex
  35769. */
  35770. export class SolidParticleVertex {
  35771. /**
  35772. * Vertex position
  35773. */
  35774. position: Vector3;
  35775. /**
  35776. * Vertex color
  35777. */
  35778. color: Color4;
  35779. /**
  35780. * Vertex UV
  35781. */
  35782. uv: Vector2;
  35783. /**
  35784. * Creates a new solid particle vertex
  35785. */
  35786. constructor();
  35787. /** Vertex x coordinate */
  35788. get x(): number;
  35789. set x(val: number);
  35790. /** Vertex y coordinate */
  35791. get y(): number;
  35792. set y(val: number);
  35793. /** Vertex z coordinate */
  35794. get z(): number;
  35795. set z(val: number);
  35796. }
  35797. }
  35798. declare module BABYLON {
  35799. /**
  35800. * @hidden
  35801. */
  35802. export class _MeshCollisionData {
  35803. _checkCollisions: boolean;
  35804. _collisionMask: number;
  35805. _collisionGroup: number;
  35806. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35807. _collider: Nullable<Collider>;
  35808. _oldPositionForCollisions: Vector3;
  35809. _diffPositionForCollisions: Vector3;
  35810. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35811. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35812. _collisionResponse: boolean;
  35813. }
  35814. }
  35815. declare module BABYLON {
  35816. /** @hidden */
  35817. class _FacetDataStorage {
  35818. facetPositions: Vector3[];
  35819. facetNormals: Vector3[];
  35820. facetPartitioning: number[][];
  35821. facetNb: number;
  35822. partitioningSubdivisions: number;
  35823. partitioningBBoxRatio: number;
  35824. facetDataEnabled: boolean;
  35825. facetParameters: any;
  35826. bbSize: Vector3;
  35827. subDiv: {
  35828. max: number;
  35829. X: number;
  35830. Y: number;
  35831. Z: number;
  35832. };
  35833. facetDepthSort: boolean;
  35834. facetDepthSortEnabled: boolean;
  35835. depthSortedIndices: IndicesArray;
  35836. depthSortedFacets: {
  35837. ind: number;
  35838. sqDistance: number;
  35839. }[];
  35840. facetDepthSortFunction: (f1: {
  35841. ind: number;
  35842. sqDistance: number;
  35843. }, f2: {
  35844. ind: number;
  35845. sqDistance: number;
  35846. }) => number;
  35847. facetDepthSortFrom: Vector3;
  35848. facetDepthSortOrigin: Vector3;
  35849. invertedMatrix: Matrix;
  35850. }
  35851. /**
  35852. * @hidden
  35853. **/
  35854. class _InternalAbstractMeshDataInfo {
  35855. _hasVertexAlpha: boolean;
  35856. _useVertexColors: boolean;
  35857. _numBoneInfluencers: number;
  35858. _applyFog: boolean;
  35859. _receiveShadows: boolean;
  35860. _facetData: _FacetDataStorage;
  35861. _visibility: number;
  35862. _skeleton: Nullable<Skeleton>;
  35863. _layerMask: number;
  35864. _computeBonesUsingShaders: boolean;
  35865. _isActive: boolean;
  35866. _onlyForInstances: boolean;
  35867. _isActiveIntermediate: boolean;
  35868. _onlyForInstancesIntermediate: boolean;
  35869. _actAsRegularMesh: boolean;
  35870. _currentLOD: Nullable<AbstractMesh>;
  35871. _currentLODIsUpToDate: boolean;
  35872. }
  35873. /**
  35874. * Class used to store all common mesh properties
  35875. */
  35876. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35877. /** No occlusion */
  35878. static OCCLUSION_TYPE_NONE: number;
  35879. /** Occlusion set to optimisitic */
  35880. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35881. /** Occlusion set to strict */
  35882. static OCCLUSION_TYPE_STRICT: number;
  35883. /** Use an accurante occlusion algorithm */
  35884. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35885. /** Use a conservative occlusion algorithm */
  35886. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35887. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35888. * Test order :
  35889. * Is the bounding sphere outside the frustum ?
  35890. * If not, are the bounding box vertices outside the frustum ?
  35891. * It not, then the cullable object is in the frustum.
  35892. */
  35893. static readonly CULLINGSTRATEGY_STANDARD: number;
  35894. /** Culling strategy : Bounding Sphere Only.
  35895. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35896. * It's also less accurate than the standard because some not visible objects can still be selected.
  35897. * Test : is the bounding sphere outside the frustum ?
  35898. * If not, then the cullable object is in the frustum.
  35899. */
  35900. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35901. /** Culling strategy : Optimistic Inclusion.
  35902. * This in an inclusion test first, then the standard exclusion test.
  35903. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35904. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  35905. * Anyway, it's as accurate as the standard strategy.
  35906. * Test :
  35907. * Is the cullable object bounding sphere center in the frustum ?
  35908. * If not, apply the default culling strategy.
  35909. */
  35910. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35911. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35912. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35913. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35914. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  35915. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35916. * Test :
  35917. * Is the cullable object bounding sphere center in the frustum ?
  35918. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35919. */
  35920. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35921. /**
  35922. * No billboard
  35923. */
  35924. static get BILLBOARDMODE_NONE(): number;
  35925. /** Billboard on X axis */
  35926. static get BILLBOARDMODE_X(): number;
  35927. /** Billboard on Y axis */
  35928. static get BILLBOARDMODE_Y(): number;
  35929. /** Billboard on Z axis */
  35930. static get BILLBOARDMODE_Z(): number;
  35931. /** Billboard on all axes */
  35932. static get BILLBOARDMODE_ALL(): number;
  35933. /** Billboard on using position instead of orientation */
  35934. static get BILLBOARDMODE_USE_POSITION(): number;
  35935. /** @hidden */
  35936. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35937. /**
  35938. * The culling strategy to use to check whether the mesh must be rendered or not.
  35939. * This value can be changed at any time and will be used on the next render mesh selection.
  35940. * The possible values are :
  35941. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35942. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35943. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35944. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35945. * Please read each static variable documentation to get details about the culling process.
  35946. * */
  35947. cullingStrategy: number;
  35948. /**
  35949. * Gets the number of facets in the mesh
  35950. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35951. */
  35952. get facetNb(): number;
  35953. /**
  35954. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35955. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35956. */
  35957. get partitioningSubdivisions(): number;
  35958. set partitioningSubdivisions(nb: number);
  35959. /**
  35960. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  35961. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  35962. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35963. */
  35964. get partitioningBBoxRatio(): number;
  35965. set partitioningBBoxRatio(ratio: number);
  35966. /**
  35967. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  35968. * Works only for updatable meshes.
  35969. * Doesn't work with multi-materials
  35970. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35971. */
  35972. get mustDepthSortFacets(): boolean;
  35973. set mustDepthSortFacets(sort: boolean);
  35974. /**
  35975. * The location (Vector3) where the facet depth sort must be computed from.
  35976. * By default, the active camera position.
  35977. * Used only when facet depth sort is enabled
  35978. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35979. */
  35980. get facetDepthSortFrom(): Vector3;
  35981. set facetDepthSortFrom(location: Vector3);
  35982. /**
  35983. * gets a boolean indicating if facetData is enabled
  35984. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35985. */
  35986. get isFacetDataEnabled(): boolean;
  35987. /** @hidden */
  35988. _updateNonUniformScalingState(value: boolean): boolean;
  35989. /**
  35990. * An event triggered when this mesh collides with another one
  35991. */
  35992. onCollideObservable: Observable<AbstractMesh>;
  35993. /** Set a function to call when this mesh collides with another one */
  35994. set onCollide(callback: () => void);
  35995. /**
  35996. * An event triggered when the collision's position changes
  35997. */
  35998. onCollisionPositionChangeObservable: Observable<Vector3>;
  35999. /** Set a function to call when the collision's position changes */
  36000. set onCollisionPositionChange(callback: () => void);
  36001. /**
  36002. * An event triggered when material is changed
  36003. */
  36004. onMaterialChangedObservable: Observable<AbstractMesh>;
  36005. /**
  36006. * Gets or sets the orientation for POV movement & rotation
  36007. */
  36008. definedFacingForward: boolean;
  36009. /** @hidden */
  36010. _occlusionQuery: Nullable<WebGLQuery>;
  36011. /** @hidden */
  36012. _renderingGroup: Nullable<RenderingGroup>;
  36013. /**
  36014. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36015. */
  36016. get visibility(): number;
  36017. /**
  36018. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36019. */
  36020. set visibility(value: number);
  36021. /** Gets or sets the alpha index used to sort transparent meshes
  36022. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36023. */
  36024. alphaIndex: number;
  36025. /**
  36026. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36027. */
  36028. isVisible: boolean;
  36029. /**
  36030. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36031. */
  36032. isPickable: boolean;
  36033. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36034. showSubMeshesBoundingBox: boolean;
  36035. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36036. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36037. */
  36038. isBlocker: boolean;
  36039. /**
  36040. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36041. */
  36042. enablePointerMoveEvents: boolean;
  36043. private _renderingGroupId;
  36044. /**
  36045. * Specifies the rendering group id for this mesh (0 by default)
  36046. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36047. */
  36048. get renderingGroupId(): number;
  36049. set renderingGroupId(value: number);
  36050. private _material;
  36051. /** Gets or sets current material */
  36052. get material(): Nullable<Material>;
  36053. set material(value: Nullable<Material>);
  36054. /**
  36055. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36056. * @see https://doc.babylonjs.com/babylon101/shadows
  36057. */
  36058. get receiveShadows(): boolean;
  36059. set receiveShadows(value: boolean);
  36060. /** Defines color to use when rendering outline */
  36061. outlineColor: Color3;
  36062. /** Define width to use when rendering outline */
  36063. outlineWidth: number;
  36064. /** Defines color to use when rendering overlay */
  36065. overlayColor: Color3;
  36066. /** Defines alpha to use when rendering overlay */
  36067. overlayAlpha: number;
  36068. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36069. get hasVertexAlpha(): boolean;
  36070. set hasVertexAlpha(value: boolean);
  36071. /** Gets or sets a boolean indicating that this mesh needs to use vertex color data to render (if this kind of vertex data is available in the geometry) */
  36072. get useVertexColors(): boolean;
  36073. set useVertexColors(value: boolean);
  36074. /**
  36075. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36076. */
  36077. get computeBonesUsingShaders(): boolean;
  36078. set computeBonesUsingShaders(value: boolean);
  36079. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36080. get numBoneInfluencers(): number;
  36081. set numBoneInfluencers(value: number);
  36082. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36083. get applyFog(): boolean;
  36084. set applyFog(value: boolean);
  36085. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36086. useOctreeForRenderingSelection: boolean;
  36087. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36088. useOctreeForPicking: boolean;
  36089. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36090. useOctreeForCollisions: boolean;
  36091. /**
  36092. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36093. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36094. */
  36095. get layerMask(): number;
  36096. set layerMask(value: number);
  36097. /**
  36098. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36099. */
  36100. alwaysSelectAsActiveMesh: boolean;
  36101. /**
  36102. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36103. */
  36104. doNotSyncBoundingInfo: boolean;
  36105. /**
  36106. * Gets or sets the current action manager
  36107. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36108. */
  36109. actionManager: Nullable<AbstractActionManager>;
  36110. private _meshCollisionData;
  36111. /**
  36112. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36113. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36114. */
  36115. ellipsoid: Vector3;
  36116. /**
  36117. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36118. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36119. */
  36120. ellipsoidOffset: Vector3;
  36121. /**
  36122. * Gets or sets a collision mask used to mask collisions (default is -1).
  36123. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36124. */
  36125. get collisionMask(): number;
  36126. set collisionMask(mask: number);
  36127. /**
  36128. * Gets or sets a collision response flag (default is true).
  36129. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36130. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36131. * to respond to the collision.
  36132. */
  36133. get collisionResponse(): boolean;
  36134. set collisionResponse(response: boolean);
  36135. /**
  36136. * Gets or sets the current collision group mask (-1 by default).
  36137. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36138. */
  36139. get collisionGroup(): number;
  36140. set collisionGroup(mask: number);
  36141. /**
  36142. * Gets or sets current surrounding meshes (null by default).
  36143. *
  36144. * By default collision detection is tested against every mesh in the scene.
  36145. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36146. * meshes will be tested for the collision.
  36147. *
  36148. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36149. */
  36150. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36151. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36152. /**
  36153. * Defines edge width used when edgesRenderer is enabled
  36154. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36155. */
  36156. edgesWidth: number;
  36157. /**
  36158. * Defines edge color used when edgesRenderer is enabled
  36159. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36160. */
  36161. edgesColor: Color4;
  36162. /** @hidden */
  36163. _edgesRenderer: Nullable<IEdgesRenderer>;
  36164. /** @hidden */
  36165. _masterMesh: Nullable<AbstractMesh>;
  36166. /** @hidden */
  36167. _boundingInfo: Nullable<BoundingInfo>;
  36168. /** @hidden */
  36169. _renderId: number;
  36170. /**
  36171. * Gets or sets the list of subMeshes
  36172. * @see https://doc.babylonjs.com/how_to/multi_materials
  36173. */
  36174. subMeshes: SubMesh[];
  36175. /** @hidden */
  36176. _intersectionsInProgress: AbstractMesh[];
  36177. /** @hidden */
  36178. _unIndexed: boolean;
  36179. /** @hidden */
  36180. _lightSources: Light[];
  36181. /** Gets the list of lights affecting that mesh */
  36182. get lightSources(): Light[];
  36183. /** @hidden */
  36184. get _positions(): Nullable<Vector3[]>;
  36185. /** @hidden */
  36186. _waitingData: {
  36187. lods: Nullable<any>;
  36188. actions: Nullable<any>;
  36189. freezeWorldMatrix: Nullable<boolean>;
  36190. };
  36191. /** @hidden */
  36192. _bonesTransformMatrices: Nullable<Float32Array>;
  36193. /** @hidden */
  36194. _transformMatrixTexture: Nullable<RawTexture>;
  36195. /**
  36196. * Gets or sets a skeleton to apply skining transformations
  36197. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36198. */
  36199. set skeleton(value: Nullable<Skeleton>);
  36200. get skeleton(): Nullable<Skeleton>;
  36201. /**
  36202. * An event triggered when the mesh is rebuilt.
  36203. */
  36204. onRebuildObservable: Observable<AbstractMesh>;
  36205. /**
  36206. * The current mesh unifom buffer.
  36207. * @hidden Internal use only.
  36208. */
  36209. _uniformBuffer: UniformBuffer;
  36210. /**
  36211. * Creates a new AbstractMesh
  36212. * @param name defines the name of the mesh
  36213. * @param scene defines the hosting scene
  36214. */
  36215. constructor(name: string, scene?: Nullable<Scene>);
  36216. protected _buildUniformLayout(): void;
  36217. /**
  36218. * Transfer the mesh values to its UBO.
  36219. * @param world The world matrix associated with the mesh
  36220. */
  36221. transferToEffect(world: Matrix): void;
  36222. /**
  36223. * Gets the mesh uniform buffer.
  36224. * @return the uniform buffer of the mesh.
  36225. */
  36226. getMeshUniformBuffer(): UniformBuffer;
  36227. /**
  36228. * Returns the string "AbstractMesh"
  36229. * @returns "AbstractMesh"
  36230. */
  36231. getClassName(): string;
  36232. /**
  36233. * Gets a string representation of the current mesh
  36234. * @param fullDetails defines a boolean indicating if full details must be included
  36235. * @returns a string representation of the current mesh
  36236. */
  36237. toString(fullDetails?: boolean): string;
  36238. /**
  36239. * @hidden
  36240. */
  36241. protected _getEffectiveParent(): Nullable<Node>;
  36242. /** @hidden */
  36243. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36244. /** @hidden */
  36245. _rebuild(): void;
  36246. /** @hidden */
  36247. _resyncLightSources(): void;
  36248. /** @hidden */
  36249. _resyncLightSource(light: Light): void;
  36250. /** @hidden */
  36251. _unBindEffect(): void;
  36252. /** @hidden */
  36253. _removeLightSource(light: Light, dispose: boolean): void;
  36254. private _markSubMeshesAsDirty;
  36255. /** @hidden */
  36256. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36257. /** @hidden */
  36258. _markSubMeshesAsAttributesDirty(): void;
  36259. /** @hidden */
  36260. _markSubMeshesAsMiscDirty(): void;
  36261. /**
  36262. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36263. */
  36264. get scaling(): Vector3;
  36265. set scaling(newScaling: Vector3);
  36266. /**
  36267. * Returns true if the mesh is blocked. Implemented by child classes
  36268. */
  36269. get isBlocked(): boolean;
  36270. /**
  36271. * Returns the mesh itself by default. Implemented by child classes
  36272. * @param camera defines the camera to use to pick the right LOD level
  36273. * @returns the currentAbstractMesh
  36274. */
  36275. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36276. /**
  36277. * Returns 0 by default. Implemented by child classes
  36278. * @returns an integer
  36279. */
  36280. getTotalVertices(): number;
  36281. /**
  36282. * Returns a positive integer : the total number of indices in this mesh geometry.
  36283. * @returns the numner of indices or zero if the mesh has no geometry.
  36284. */
  36285. getTotalIndices(): number;
  36286. /**
  36287. * Returns null by default. Implemented by child classes
  36288. * @returns null
  36289. */
  36290. getIndices(): Nullable<IndicesArray>;
  36291. /**
  36292. * Returns the array of the requested vertex data kind. Implemented by child classes
  36293. * @param kind defines the vertex data kind to use
  36294. * @returns null
  36295. */
  36296. getVerticesData(kind: string): Nullable<FloatArray>;
  36297. /**
  36298. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36299. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36300. * Note that a new underlying VertexBuffer object is created each call.
  36301. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36302. * @param kind defines vertex data kind:
  36303. * * VertexBuffer.PositionKind
  36304. * * VertexBuffer.UVKind
  36305. * * VertexBuffer.UV2Kind
  36306. * * VertexBuffer.UV3Kind
  36307. * * VertexBuffer.UV4Kind
  36308. * * VertexBuffer.UV5Kind
  36309. * * VertexBuffer.UV6Kind
  36310. * * VertexBuffer.ColorKind
  36311. * * VertexBuffer.MatricesIndicesKind
  36312. * * VertexBuffer.MatricesIndicesExtraKind
  36313. * * VertexBuffer.MatricesWeightsKind
  36314. * * VertexBuffer.MatricesWeightsExtraKind
  36315. * @param data defines the data source
  36316. * @param updatable defines if the data must be flagged as updatable (or static)
  36317. * @param stride defines the vertex stride (size of an entire vertex). Can be null and in this case will be deduced from vertex data kind
  36318. * @returns the current mesh
  36319. */
  36320. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36321. /**
  36322. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36323. * If the mesh has no geometry, it is simply returned as it is.
  36324. * @param kind defines vertex data kind:
  36325. * * VertexBuffer.PositionKind
  36326. * * VertexBuffer.UVKind
  36327. * * VertexBuffer.UV2Kind
  36328. * * VertexBuffer.UV3Kind
  36329. * * VertexBuffer.UV4Kind
  36330. * * VertexBuffer.UV5Kind
  36331. * * VertexBuffer.UV6Kind
  36332. * * VertexBuffer.ColorKind
  36333. * * VertexBuffer.MatricesIndicesKind
  36334. * * VertexBuffer.MatricesIndicesExtraKind
  36335. * * VertexBuffer.MatricesWeightsKind
  36336. * * VertexBuffer.MatricesWeightsExtraKind
  36337. * @param data defines the data source
  36338. * @param updateExtends If `kind` is `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed
  36339. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  36340. * @returns the current mesh
  36341. */
  36342. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  36343. /**
  36344. * Sets the mesh indices,
  36345. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  36346. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  36347. * @param totalVertices Defines the total number of vertices
  36348. * @returns the current mesh
  36349. */
  36350. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  36351. /**
  36352. * Gets a boolean indicating if specific vertex data is present
  36353. * @param kind defines the vertex data kind to use
  36354. * @returns true is data kind is present
  36355. */
  36356. isVerticesDataPresent(kind: string): boolean;
  36357. /**
  36358. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  36359. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  36360. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  36361. * @returns a BoundingInfo
  36362. */
  36363. getBoundingInfo(): BoundingInfo;
  36364. /**
  36365. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  36366. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  36367. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  36368. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  36369. * @returns the current mesh
  36370. */
  36371. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  36372. /**
  36373. * Overwrite the current bounding info
  36374. * @param boundingInfo defines the new bounding info
  36375. * @returns the current mesh
  36376. */
  36377. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  36378. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  36379. get useBones(): boolean;
  36380. /** @hidden */
  36381. _preActivate(): void;
  36382. /** @hidden */
  36383. _preActivateForIntermediateRendering(renderId: number): void;
  36384. /** @hidden */
  36385. _activate(renderId: number, intermediateRendering: boolean): boolean;
  36386. /** @hidden */
  36387. _postActivate(): void;
  36388. /** @hidden */
  36389. _freeze(): void;
  36390. /** @hidden */
  36391. _unFreeze(): void;
  36392. /**
  36393. * Gets the current world matrix
  36394. * @returns a Matrix
  36395. */
  36396. getWorldMatrix(): Matrix;
  36397. /** @hidden */
  36398. _getWorldMatrixDeterminant(): number;
  36399. /**
  36400. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  36401. */
  36402. get isAnInstance(): boolean;
  36403. /**
  36404. * Gets a boolean indicating if this mesh has instances
  36405. */
  36406. get hasInstances(): boolean;
  36407. /**
  36408. * Gets a boolean indicating if this mesh has thin instances
  36409. */
  36410. get hasThinInstances(): boolean;
  36411. /**
  36412. * Perform relative position change from the point of view of behind the front of the mesh.
  36413. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36414. * Supports definition of mesh facing forward or backward
  36415. * @param amountRight defines the distance on the right axis
  36416. * @param amountUp defines the distance on the up axis
  36417. * @param amountForward defines the distance on the forward axis
  36418. * @returns the current mesh
  36419. */
  36420. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  36421. /**
  36422. * Calculate relative position change from the point of view of behind the front of the mesh.
  36423. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36424. * Supports definition of mesh facing forward or backward
  36425. * @param amountRight defines the distance on the right axis
  36426. * @param amountUp defines the distance on the up axis
  36427. * @param amountForward defines the distance on the forward axis
  36428. * @returns the new displacement vector
  36429. */
  36430. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  36431. /**
  36432. * Perform relative rotation change from the point of view of behind the front of the mesh.
  36433. * Supports definition of mesh facing forward or backward
  36434. * @param flipBack defines the flip
  36435. * @param twirlClockwise defines the twirl
  36436. * @param tiltRight defines the tilt
  36437. * @returns the current mesh
  36438. */
  36439. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  36440. /**
  36441. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  36442. * Supports definition of mesh facing forward or backward.
  36443. * @param flipBack defines the flip
  36444. * @param twirlClockwise defines the twirl
  36445. * @param tiltRight defines the tilt
  36446. * @returns the new rotation vector
  36447. */
  36448. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  36449. /**
  36450. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  36451. * This means the mesh underlying bounding box and sphere are recomputed.
  36452. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  36453. * @returns the current mesh
  36454. */
  36455. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  36456. /** @hidden */
  36457. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  36458. /** @hidden */
  36459. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  36460. /** @hidden */
  36461. _updateBoundingInfo(): AbstractMesh;
  36462. /** @hidden */
  36463. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  36464. /** @hidden */
  36465. protected _afterComputeWorldMatrix(): void;
  36466. /** @hidden */
  36467. get _effectiveMesh(): AbstractMesh;
  36468. /**
  36469. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  36470. * A mesh is in the frustum if its bounding box intersects the frustum
  36471. * @param frustumPlanes defines the frustum to test
  36472. * @returns true if the mesh is in the frustum planes
  36473. */
  36474. isInFrustum(frustumPlanes: Plane[]): boolean;
  36475. /**
  36476. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  36477. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  36478. * @param frustumPlanes defines the frustum to test
  36479. * @returns true if the mesh is completely in the frustum planes
  36480. */
  36481. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  36482. /**
  36483. * True if the mesh intersects another mesh or a SolidParticle object
  36484. * @param mesh defines a target mesh or SolidParticle to test
  36485. * @param precise Unless the parameter `precise` is set to `true` the intersection is computed according to Axis Aligned Bounding Boxes (AABB), else according to OBB (Oriented BBoxes)
  36486. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  36487. * @returns true if there is an intersection
  36488. */
  36489. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  36490. /**
  36491. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  36492. * @param point defines the point to test
  36493. * @returns true if there is an intersection
  36494. */
  36495. intersectsPoint(point: Vector3): boolean;
  36496. /**
  36497. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  36498. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36499. */
  36500. get checkCollisions(): boolean;
  36501. set checkCollisions(collisionEnabled: boolean);
  36502. /**
  36503. * Gets Collider object used to compute collisions (not physics)
  36504. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36505. */
  36506. get collider(): Nullable<Collider>;
  36507. /**
  36508. * Move the mesh using collision engine
  36509. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36510. * @param displacement defines the requested displacement vector
  36511. * @returns the current mesh
  36512. */
  36513. moveWithCollisions(displacement: Vector3): AbstractMesh;
  36514. private _onCollisionPositionChange;
  36515. /** @hidden */
  36516. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  36517. /** @hidden */
  36518. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  36519. /** @hidden */
  36520. _checkCollision(collider: Collider): AbstractMesh;
  36521. /** @hidden */
  36522. _generatePointsArray(): boolean;
  36523. /**
  36524. * Checks if the passed Ray intersects with the mesh
  36525. * @param ray defines the ray to use
  36526. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  36527. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36528. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  36529. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  36530. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  36531. * @returns the picking info
  36532. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  36533. */
  36534. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  36535. /**
  36536. * Clones the current mesh
  36537. * @param name defines the mesh name
  36538. * @param newParent defines the new mesh parent
  36539. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  36540. * @returns the new mesh
  36541. */
  36542. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  36543. /**
  36544. * Disposes all the submeshes of the current meshnp
  36545. * @returns the current mesh
  36546. */
  36547. releaseSubMeshes(): AbstractMesh;
  36548. /**
  36549. * Releases resources associated with this abstract mesh.
  36550. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36551. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36552. */
  36553. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36554. /**
  36555. * Adds the passed mesh as a child to the current mesh
  36556. * @param mesh defines the child mesh
  36557. * @returns the current mesh
  36558. */
  36559. addChild(mesh: AbstractMesh): AbstractMesh;
  36560. /**
  36561. * Removes the passed mesh from the current mesh children list
  36562. * @param mesh defines the child mesh
  36563. * @returns the current mesh
  36564. */
  36565. removeChild(mesh: AbstractMesh): AbstractMesh;
  36566. /** @hidden */
  36567. private _initFacetData;
  36568. /**
  36569. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  36570. * This method can be called within the render loop.
  36571. * You don't need to call this method by yourself in the render loop when you update/morph a mesh with the methods CreateXXX() as they automatically manage this computation
  36572. * @returns the current mesh
  36573. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36574. */
  36575. updateFacetData(): AbstractMesh;
  36576. /**
  36577. * Returns the facetLocalNormals array.
  36578. * The normals are expressed in the mesh local spac
  36579. * @returns an array of Vector3
  36580. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36581. */
  36582. getFacetLocalNormals(): Vector3[];
  36583. /**
  36584. * Returns the facetLocalPositions array.
  36585. * The facet positions are expressed in the mesh local space
  36586. * @returns an array of Vector3
  36587. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36588. */
  36589. getFacetLocalPositions(): Vector3[];
  36590. /**
  36591. * Returns the facetLocalPartioning array
  36592. * @returns an array of array of numbers
  36593. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36594. */
  36595. getFacetLocalPartitioning(): number[][];
  36596. /**
  36597. * Returns the i-th facet position in the world system.
  36598. * This method allocates a new Vector3 per call
  36599. * @param i defines the facet index
  36600. * @returns a new Vector3
  36601. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36602. */
  36603. getFacetPosition(i: number): Vector3;
  36604. /**
  36605. * Sets the reference Vector3 with the i-th facet position in the world system
  36606. * @param i defines the facet index
  36607. * @param ref defines the target vector
  36608. * @returns the current mesh
  36609. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36610. */
  36611. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  36612. /**
  36613. * Returns the i-th facet normal in the world system.
  36614. * This method allocates a new Vector3 per call
  36615. * @param i defines the facet index
  36616. * @returns a new Vector3
  36617. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36618. */
  36619. getFacetNormal(i: number): Vector3;
  36620. /**
  36621. * Sets the reference Vector3 with the i-th facet normal in the world system
  36622. * @param i defines the facet index
  36623. * @param ref defines the target vector
  36624. * @returns the current mesh
  36625. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36626. */
  36627. getFacetNormalToRef(i: number, ref: Vector3): this;
  36628. /**
  36629. * Returns the facets (in an array) in the same partitioning block than the one the passed coordinates are located (expressed in the mesh local system)
  36630. * @param x defines x coordinate
  36631. * @param y defines y coordinate
  36632. * @param z defines z coordinate
  36633. * @returns the array of facet indexes
  36634. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36635. */
  36636. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  36637. /**
  36638. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  36639. * @param projected sets as the (x,y,z) world projection on the facet
  36640. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  36641. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  36642. * @param x defines x coordinate
  36643. * @param y defines y coordinate
  36644. * @param z defines z coordinate
  36645. * @returns the face index if found (or null instead)
  36646. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36647. */
  36648. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36649. /**
  36650. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  36651. * @param projected sets as the (x,y,z) local projection on the facet
  36652. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  36653. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  36654. * @param x defines x coordinate
  36655. * @param y defines y coordinate
  36656. * @param z defines z coordinate
  36657. * @returns the face index if found (or null instead)
  36658. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36659. */
  36660. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36661. /**
  36662. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  36663. * @returns the parameters
  36664. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36665. */
  36666. getFacetDataParameters(): any;
  36667. /**
  36668. * Disables the feature FacetData and frees the related memory
  36669. * @returns the current mesh
  36670. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36671. */
  36672. disableFacetData(): AbstractMesh;
  36673. /**
  36674. * Updates the AbstractMesh indices array
  36675. * @param indices defines the data source
  36676. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  36677. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  36678. * @returns the current mesh
  36679. */
  36680. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  36681. /**
  36682. * Creates new normals data for the mesh
  36683. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  36684. * @returns the current mesh
  36685. */
  36686. createNormals(updatable: boolean): AbstractMesh;
  36687. /**
  36688. * Align the mesh with a normal
  36689. * @param normal defines the normal to use
  36690. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  36691. * @returns the current mesh
  36692. */
  36693. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  36694. /** @hidden */
  36695. _checkOcclusionQuery(): boolean;
  36696. /**
  36697. * Disables the mesh edge rendering mode
  36698. * @returns the currentAbstractMesh
  36699. */
  36700. disableEdgesRendering(): AbstractMesh;
  36701. /**
  36702. * Enables the edge rendering mode on the mesh.
  36703. * This mode makes the mesh edges visible
  36704. * @param epsilon defines the maximal distance between two angles to detect a face
  36705. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36706. * @param options options to the edge renderer
  36707. * @returns the currentAbstractMesh
  36708. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36709. */
  36710. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  36711. /**
  36712. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  36713. * @returns an array of particle systems in the scene that use the mesh as an emitter
  36714. */
  36715. getConnectedParticleSystems(): IParticleSystem[];
  36716. }
  36717. }
  36718. declare module BABYLON {
  36719. /**
  36720. * Interface used to define ActionEvent
  36721. */
  36722. export interface IActionEvent {
  36723. /** The mesh or sprite that triggered the action */
  36724. source: any;
  36725. /** The X mouse cursor position at the time of the event */
  36726. pointerX: number;
  36727. /** The Y mouse cursor position at the time of the event */
  36728. pointerY: number;
  36729. /** The mesh that is currently pointed at (can be null) */
  36730. meshUnderPointer: Nullable<AbstractMesh>;
  36731. /** the original (browser) event that triggered the ActionEvent */
  36732. sourceEvent?: any;
  36733. /** additional data for the event */
  36734. additionalData?: any;
  36735. }
  36736. /**
  36737. * ActionEvent is the event being sent when an action is triggered.
  36738. */
  36739. export class ActionEvent implements IActionEvent {
  36740. /** The mesh or sprite that triggered the action */
  36741. source: any;
  36742. /** The X mouse cursor position at the time of the event */
  36743. pointerX: number;
  36744. /** The Y mouse cursor position at the time of the event */
  36745. pointerY: number;
  36746. /** The mesh that is currently pointed at (can be null) */
  36747. meshUnderPointer: Nullable<AbstractMesh>;
  36748. /** the original (browser) event that triggered the ActionEvent */
  36749. sourceEvent?: any;
  36750. /** additional data for the event */
  36751. additionalData?: any;
  36752. /**
  36753. * Creates a new ActionEvent
  36754. * @param source The mesh or sprite that triggered the action
  36755. * @param pointerX The X mouse cursor position at the time of the event
  36756. * @param pointerY The Y mouse cursor position at the time of the event
  36757. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  36758. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  36759. * @param additionalData additional data for the event
  36760. */
  36761. constructor(
  36762. /** The mesh or sprite that triggered the action */
  36763. source: any,
  36764. /** The X mouse cursor position at the time of the event */
  36765. pointerX: number,
  36766. /** The Y mouse cursor position at the time of the event */
  36767. pointerY: number,
  36768. /** The mesh that is currently pointed at (can be null) */
  36769. meshUnderPointer: Nullable<AbstractMesh>,
  36770. /** the original (browser) event that triggered the ActionEvent */
  36771. sourceEvent?: any,
  36772. /** additional data for the event */
  36773. additionalData?: any);
  36774. /**
  36775. * Helper function to auto-create an ActionEvent from a source mesh.
  36776. * @param source The source mesh that triggered the event
  36777. * @param evt The original (browser) event
  36778. * @param additionalData additional data for the event
  36779. * @returns the new ActionEvent
  36780. */
  36781. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  36782. /**
  36783. * Helper function to auto-create an ActionEvent from a source sprite
  36784. * @param source The source sprite that triggered the event
  36785. * @param scene Scene associated with the sprite
  36786. * @param evt The original (browser) event
  36787. * @param additionalData additional data for the event
  36788. * @returns the new ActionEvent
  36789. */
  36790. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  36791. /**
  36792. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  36793. * @param scene the scene where the event occurred
  36794. * @param evt The original (browser) event
  36795. * @returns the new ActionEvent
  36796. */
  36797. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  36798. /**
  36799. * Helper function to auto-create an ActionEvent from a primitive
  36800. * @param prim defines the target primitive
  36801. * @param pointerPos defines the pointer position
  36802. * @param evt The original (browser) event
  36803. * @param additionalData additional data for the event
  36804. * @returns the new ActionEvent
  36805. */
  36806. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  36807. }
  36808. }
  36809. declare module BABYLON {
  36810. /**
  36811. * Abstract class used to decouple action Manager from scene and meshes.
  36812. * Do not instantiate.
  36813. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36814. */
  36815. export abstract class AbstractActionManager implements IDisposable {
  36816. /** Gets the list of active triggers */
  36817. static Triggers: {
  36818. [key: string]: number;
  36819. };
  36820. /** Gets the cursor to use when hovering items */
  36821. hoverCursor: string;
  36822. /** Gets the list of actions */
  36823. actions: IAction[];
  36824. /**
  36825. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36826. */
  36827. isRecursive: boolean;
  36828. /**
  36829. * Releases all associated resources
  36830. */
  36831. abstract dispose(): void;
  36832. /**
  36833. * Does this action manager has pointer triggers
  36834. */
  36835. abstract get hasPointerTriggers(): boolean;
  36836. /**
  36837. * Does this action manager has pick triggers
  36838. */
  36839. abstract get hasPickTriggers(): boolean;
  36840. /**
  36841. * Process a specific trigger
  36842. * @param trigger defines the trigger to process
  36843. * @param evt defines the event details to be processed
  36844. */
  36845. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36846. /**
  36847. * Does this action manager handles actions of any of the given triggers
  36848. * @param triggers defines the triggers to be tested
  36849. * @return a boolean indicating whether one (or more) of the triggers is handled
  36850. */
  36851. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36852. /**
  36853. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36854. * speed.
  36855. * @param triggerA defines the trigger to be tested
  36856. * @param triggerB defines the trigger to be tested
  36857. * @return a boolean indicating whether one (or more) of the triggers is handled
  36858. */
  36859. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36860. /**
  36861. * Does this action manager handles actions of a given trigger
  36862. * @param trigger defines the trigger to be tested
  36863. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36864. * @return whether the trigger is handled
  36865. */
  36866. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36867. /**
  36868. * Serialize this manager to a JSON object
  36869. * @param name defines the property name to store this manager
  36870. * @returns a JSON representation of this manager
  36871. */
  36872. abstract serialize(name: string): any;
  36873. /**
  36874. * Registers an action to this action manager
  36875. * @param action defines the action to be registered
  36876. * @return the action amended (prepared) after registration
  36877. */
  36878. abstract registerAction(action: IAction): Nullable<IAction>;
  36879. /**
  36880. * Unregisters an action to this action manager
  36881. * @param action defines the action to be unregistered
  36882. * @return a boolean indicating whether the action has been unregistered
  36883. */
  36884. abstract unregisterAction(action: IAction): Boolean;
  36885. /**
  36886. * Does exist one action manager with at least one trigger
  36887. **/
  36888. static get HasTriggers(): boolean;
  36889. /**
  36890. * Does exist one action manager with at least one pick trigger
  36891. **/
  36892. static get HasPickTriggers(): boolean;
  36893. /**
  36894. * Does exist one action manager that handles actions of a given trigger
  36895. * @param trigger defines the trigger to be tested
  36896. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36897. **/
  36898. static HasSpecificTrigger(trigger: number): boolean;
  36899. }
  36900. }
  36901. declare module BABYLON {
  36902. /**
  36903. * Defines how a node can be built from a string name.
  36904. */
  36905. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36906. /**
  36907. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36908. */
  36909. export class Node implements IBehaviorAware<Node> {
  36910. /** @hidden */
  36911. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36912. private static _NodeConstructors;
  36913. /**
  36914. * Add a new node constructor
  36915. * @param type defines the type name of the node to construct
  36916. * @param constructorFunc defines the constructor function
  36917. */
  36918. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36919. /**
  36920. * Returns a node constructor based on type name
  36921. * @param type defines the type name
  36922. * @param name defines the new node name
  36923. * @param scene defines the hosting scene
  36924. * @param options defines optional options to transmit to constructors
  36925. * @returns the new constructor or null
  36926. */
  36927. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36928. /**
  36929. * Gets or sets the name of the node
  36930. */
  36931. name: string;
  36932. /**
  36933. * Gets or sets the id of the node
  36934. */
  36935. id: string;
  36936. /**
  36937. * Gets or sets the unique id of the node
  36938. */
  36939. uniqueId: number;
  36940. /**
  36941. * Gets or sets a string used to store user defined state for the node
  36942. */
  36943. state: string;
  36944. /**
  36945. * Gets or sets an object used to store user defined information for the node
  36946. */
  36947. metadata: any;
  36948. /**
  36949. * For internal use only. Please do not use.
  36950. */
  36951. reservedDataStore: any;
  36952. /**
  36953. * List of inspectable custom properties (used by the Inspector)
  36954. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36955. */
  36956. inspectableCustomProperties: IInspectable[];
  36957. private _doNotSerialize;
  36958. /**
  36959. * Gets or sets a boolean used to define if the node must be serialized
  36960. */
  36961. get doNotSerialize(): boolean;
  36962. set doNotSerialize(value: boolean);
  36963. /** @hidden */
  36964. _isDisposed: boolean;
  36965. /**
  36966. * Gets a list of Animations associated with the node
  36967. */
  36968. animations: Animation[];
  36969. protected _ranges: {
  36970. [name: string]: Nullable<AnimationRange>;
  36971. };
  36972. /**
  36973. * Callback raised when the node is ready to be used
  36974. */
  36975. onReady: Nullable<(node: Node) => void>;
  36976. private _isEnabled;
  36977. private _isParentEnabled;
  36978. private _isReady;
  36979. /** @hidden */
  36980. _currentRenderId: number;
  36981. private _parentUpdateId;
  36982. /** @hidden */
  36983. _childUpdateId: number;
  36984. /** @hidden */
  36985. _waitingParentId: Nullable<string>;
  36986. /** @hidden */
  36987. _scene: Scene;
  36988. /** @hidden */
  36989. _cache: any;
  36990. private _parentNode;
  36991. private _children;
  36992. /** @hidden */
  36993. _worldMatrix: Matrix;
  36994. /** @hidden */
  36995. _worldMatrixDeterminant: number;
  36996. /** @hidden */
  36997. _worldMatrixDeterminantIsDirty: boolean;
  36998. /** @hidden */
  36999. private _sceneRootNodesIndex;
  37000. /**
  37001. * Gets a boolean indicating if the node has been disposed
  37002. * @returns true if the node was disposed
  37003. */
  37004. isDisposed(): boolean;
  37005. /**
  37006. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37007. * @see https://doc.babylonjs.com/how_to/parenting
  37008. */
  37009. set parent(parent: Nullable<Node>);
  37010. get parent(): Nullable<Node>;
  37011. /** @hidden */
  37012. _addToSceneRootNodes(): void;
  37013. /** @hidden */
  37014. _removeFromSceneRootNodes(): void;
  37015. private _animationPropertiesOverride;
  37016. /**
  37017. * Gets or sets the animation properties override
  37018. */
  37019. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37020. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37021. /**
  37022. * Gets a string identifying the name of the class
  37023. * @returns "Node" string
  37024. */
  37025. getClassName(): string;
  37026. /** @hidden */
  37027. readonly _isNode: boolean;
  37028. /**
  37029. * An event triggered when the mesh is disposed
  37030. */
  37031. onDisposeObservable: Observable<Node>;
  37032. private _onDisposeObserver;
  37033. /**
  37034. * Sets a callback that will be raised when the node will be disposed
  37035. */
  37036. set onDispose(callback: () => void);
  37037. /**
  37038. * Creates a new Node
  37039. * @param name the name and id to be given to this node
  37040. * @param scene the scene this node will be added to
  37041. */
  37042. constructor(name: string, scene?: Nullable<Scene>);
  37043. /**
  37044. * Gets the scene of the node
  37045. * @returns a scene
  37046. */
  37047. getScene(): Scene;
  37048. /**
  37049. * Gets the engine of the node
  37050. * @returns a Engine
  37051. */
  37052. getEngine(): Engine;
  37053. private _behaviors;
  37054. /**
  37055. * Attach a behavior to the node
  37056. * @see https://doc.babylonjs.com/features/behaviour
  37057. * @param behavior defines the behavior to attach
  37058. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37059. * @returns the current Node
  37060. */
  37061. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37062. /**
  37063. * Remove an attached behavior
  37064. * @see https://doc.babylonjs.com/features/behaviour
  37065. * @param behavior defines the behavior to attach
  37066. * @returns the current Node
  37067. */
  37068. removeBehavior(behavior: Behavior<Node>): Node;
  37069. /**
  37070. * Gets the list of attached behaviors
  37071. * @see https://doc.babylonjs.com/features/behaviour
  37072. */
  37073. get behaviors(): Behavior<Node>[];
  37074. /**
  37075. * Gets an attached behavior by name
  37076. * @param name defines the name of the behavior to look for
  37077. * @see https://doc.babylonjs.com/features/behaviour
  37078. * @returns null if behavior was not found else the requested behavior
  37079. */
  37080. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37081. /**
  37082. * Returns the latest update of the World matrix
  37083. * @returns a Matrix
  37084. */
  37085. getWorldMatrix(): Matrix;
  37086. /** @hidden */
  37087. _getWorldMatrixDeterminant(): number;
  37088. /**
  37089. * Returns directly the latest state of the mesh World matrix.
  37090. * A Matrix is returned.
  37091. */
  37092. get worldMatrixFromCache(): Matrix;
  37093. /** @hidden */
  37094. _initCache(): void;
  37095. /** @hidden */
  37096. updateCache(force?: boolean): void;
  37097. /** @hidden */
  37098. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37099. /** @hidden */
  37100. _updateCache(ignoreParentClass?: boolean): void;
  37101. /** @hidden */
  37102. _isSynchronized(): boolean;
  37103. /** @hidden */
  37104. _markSyncedWithParent(): void;
  37105. /** @hidden */
  37106. isSynchronizedWithParent(): boolean;
  37107. /** @hidden */
  37108. isSynchronized(): boolean;
  37109. /**
  37110. * Is this node ready to be used/rendered
  37111. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37112. * @return true if the node is ready
  37113. */
  37114. isReady(completeCheck?: boolean): boolean;
  37115. /**
  37116. * Is this node enabled?
  37117. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  37118. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  37119. * @return whether this node (and its parent) is enabled
  37120. */
  37121. isEnabled(checkAncestors?: boolean): boolean;
  37122. /** @hidden */
  37123. protected _syncParentEnabledState(): void;
  37124. /**
  37125. * Set the enabled state of this node
  37126. * @param value defines the new enabled state
  37127. */
  37128. setEnabled(value: boolean): void;
  37129. /**
  37130. * Is this node a descendant of the given node?
  37131. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37132. * @param ancestor defines the parent node to inspect
  37133. * @returns a boolean indicating if this node is a descendant of the given node
  37134. */
  37135. isDescendantOf(ancestor: Node): boolean;
  37136. /** @hidden */
  37137. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37138. /**
  37139. * Will return all nodes that have this node as ascendant
  37140. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  37141. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  37142. * @return all children nodes of all types
  37143. */
  37144. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37145. /**
  37146. * Get all child-meshes of this node
  37147. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  37148. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  37149. * @returns an array of AbstractMesh
  37150. */
  37151. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37152. /**
  37153. * Get all direct children of this node
  37154. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  37155. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  37156. * @returns an array of Node
  37157. */
  37158. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37159. /** @hidden */
  37160. _setReady(state: boolean): void;
  37161. /**
  37162. * Get an animation by name
  37163. * @param name defines the name of the animation to look for
  37164. * @returns null if not found else the requested animation
  37165. */
  37166. getAnimationByName(name: string): Nullable<Animation>;
  37167. /**
  37168. * Creates an animation range for this node
  37169. * @param name defines the name of the range
  37170. * @param from defines the starting key
  37171. * @param to defines the end key
  37172. */
  37173. createAnimationRange(name: string, from: number, to: number): void;
  37174. /**
  37175. * Delete a specific animation range
  37176. * @param name defines the name of the range to delete
  37177. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37178. */
  37179. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37180. /**
  37181. * Get an animation range by name
  37182. * @param name defines the name of the animation range to look for
  37183. * @returns null if not found else the requested animation range
  37184. */
  37185. getAnimationRange(name: string): Nullable<AnimationRange>;
  37186. /**
  37187. * Gets the list of all animation ranges defined on this node
  37188. * @returns an array
  37189. */
  37190. getAnimationRanges(): Nullable<AnimationRange>[];
  37191. /**
  37192. * Will start the animation sequence
  37193. * @param name defines the range frames for animation sequence
  37194. * @param loop defines if the animation should loop (false by default)
  37195. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37196. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37197. * @returns the object created for this animation. If range does not exist, it will return null
  37198. */
  37199. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37200. /**
  37201. * Serialize animation ranges into a JSON compatible object
  37202. * @returns serialization object
  37203. */
  37204. serializeAnimationRanges(): any;
  37205. /**
  37206. * Computes the world matrix of the node
  37207. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37208. * @returns the world matrix
  37209. */
  37210. computeWorldMatrix(force?: boolean): Matrix;
  37211. /**
  37212. * Releases resources associated with this node.
  37213. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37214. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37215. */
  37216. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37217. /**
  37218. * Parse animation range data from a serialization object and store them into a given node
  37219. * @param node defines where to store the animation ranges
  37220. * @param parsedNode defines the serialization object to read data from
  37221. * @param scene defines the hosting scene
  37222. */
  37223. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37224. /**
  37225. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37226. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37227. * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
  37228. * @returns the new bounding vectors
  37229. */
  37230. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37231. min: Vector3;
  37232. max: Vector3;
  37233. };
  37234. }
  37235. }
  37236. declare module BABYLON {
  37237. /**
  37238. * @hidden
  37239. */
  37240. export class _IAnimationState {
  37241. key: number;
  37242. repeatCount: number;
  37243. workValue?: any;
  37244. loopMode?: number;
  37245. offsetValue?: any;
  37246. highLimitValue?: any;
  37247. }
  37248. /**
  37249. * Class used to store any kind of animation
  37250. */
  37251. export class Animation {
  37252. /**Name of the animation */
  37253. name: string;
  37254. /**Property to animate */
  37255. targetProperty: string;
  37256. /**The frames per second of the animation */
  37257. framePerSecond: number;
  37258. /**The data type of the animation */
  37259. dataType: number;
  37260. /**The loop mode of the animation */
  37261. loopMode?: number | undefined;
  37262. /**Specifies if blending should be enabled */
  37263. enableBlending?: boolean | undefined;
  37264. /**
  37265. * Use matrix interpolation instead of using direct key value when animating matrices
  37266. */
  37267. static AllowMatricesInterpolation: boolean;
  37268. /**
  37269. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37270. */
  37271. static AllowMatrixDecomposeForInterpolation: boolean;
  37272. /** Define the Url to load snippets */
  37273. static SnippetUrl: string;
  37274. /** Snippet ID if the animation was created from the snippet server */
  37275. snippetId: string;
  37276. /**
  37277. * Stores the key frames of the animation
  37278. */
  37279. private _keys;
  37280. /**
  37281. * Stores the easing function of the animation
  37282. */
  37283. private _easingFunction;
  37284. /**
  37285. * @hidden Internal use only
  37286. */
  37287. _runtimeAnimations: RuntimeAnimation[];
  37288. /**
  37289. * The set of event that will be linked to this animation
  37290. */
  37291. private _events;
  37292. /**
  37293. * Stores an array of target property paths
  37294. */
  37295. targetPropertyPath: string[];
  37296. /**
  37297. * Stores the blending speed of the animation
  37298. */
  37299. blendingSpeed: number;
  37300. /**
  37301. * Stores the animation ranges for the animation
  37302. */
  37303. private _ranges;
  37304. /**
  37305. * @hidden Internal use
  37306. */
  37307. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37308. /**
  37309. * Sets up an animation
  37310. * @param property The property to animate
  37311. * @param animationType The animation type to apply
  37312. * @param framePerSecond The frames per second of the animation
  37313. * @param easingFunction The easing function used in the animation
  37314. * @returns The created animation
  37315. */
  37316. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37317. /**
  37318. * Create and start an animation on a node
  37319. * @param name defines the name of the global animation that will be run on all nodes
  37320. * @param node defines the root node where the animation will take place
  37321. * @param targetProperty defines property to animate
  37322. * @param framePerSecond defines the number of frame per second yo use
  37323. * @param totalFrame defines the number of frames in total
  37324. * @param from defines the initial value
  37325. * @param to defines the final value
  37326. * @param loopMode defines which loop mode you want to use (off by default)
  37327. * @param easingFunction defines the easing function to use (linear by default)
  37328. * @param onAnimationEnd defines the callback to call when animation end
  37329. * @returns the animatable created for this animation
  37330. */
  37331. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37332. /**
  37333. * Create and start an animation on a node and its descendants
  37334. * @param name defines the name of the global animation that will be run on all nodes
  37335. * @param node defines the root node where the animation will take place
  37336. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  37337. * @param targetProperty defines property to animate
  37338. * @param framePerSecond defines the number of frame per second to use
  37339. * @param totalFrame defines the number of frames in total
  37340. * @param from defines the initial value
  37341. * @param to defines the final value
  37342. * @param loopMode defines which loop mode you want to use (off by default)
  37343. * @param easingFunction defines the easing function to use (linear by default)
  37344. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  37345. * @returns the list of animatables created for all nodes
  37346. * @example https://www.babylonjs-playground.com/#MH0VLI
  37347. */
  37348. static CreateAndStartHierarchyAnimation(name: string, node: Node, directDescendantsOnly: boolean, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable[]>;
  37349. /**
  37350. * Creates a new animation, merges it with the existing animations and starts it
  37351. * @param name Name of the animation
  37352. * @param node Node which contains the scene that begins the animations
  37353. * @param targetProperty Specifies which property to animate
  37354. * @param framePerSecond The frames per second of the animation
  37355. * @param totalFrame The total number of frames
  37356. * @param from The frame at the beginning of the animation
  37357. * @param to The frame at the end of the animation
  37358. * @param loopMode Specifies the loop mode of the animation
  37359. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  37360. * @param onAnimationEnd Callback to run once the animation is complete
  37361. * @returns Nullable animation
  37362. */
  37363. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37364. /**
  37365. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  37366. * @param sourceAnimation defines the Animation containing keyframes to convert
  37367. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  37368. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  37369. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  37370. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  37371. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  37372. */
  37373. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  37374. /**
  37375. * Transition property of an host to the target Value
  37376. * @param property The property to transition
  37377. * @param targetValue The target Value of the property
  37378. * @param host The object where the property to animate belongs
  37379. * @param scene Scene used to run the animation
  37380. * @param frameRate Framerate (in frame/s) to use
  37381. * @param transition The transition type we want to use
  37382. * @param duration The duration of the animation, in milliseconds
  37383. * @param onAnimationEnd Callback trigger at the end of the animation
  37384. * @returns Nullable animation
  37385. */
  37386. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  37387. /**
  37388. * Return the array of runtime animations currently using this animation
  37389. */
  37390. get runtimeAnimations(): RuntimeAnimation[];
  37391. /**
  37392. * Specifies if any of the runtime animations are currently running
  37393. */
  37394. get hasRunningRuntimeAnimations(): boolean;
  37395. /**
  37396. * Initializes the animation
  37397. * @param name Name of the animation
  37398. * @param targetProperty Property to animate
  37399. * @param framePerSecond The frames per second of the animation
  37400. * @param dataType The data type of the animation
  37401. * @param loopMode The loop mode of the animation
  37402. * @param enableBlending Specifies if blending should be enabled
  37403. */
  37404. constructor(
  37405. /**Name of the animation */
  37406. name: string,
  37407. /**Property to animate */
  37408. targetProperty: string,
  37409. /**The frames per second of the animation */
  37410. framePerSecond: number,
  37411. /**The data type of the animation */
  37412. dataType: number,
  37413. /**The loop mode of the animation */
  37414. loopMode?: number | undefined,
  37415. /**Specifies if blending should be enabled */
  37416. enableBlending?: boolean | undefined);
  37417. /**
  37418. * Converts the animation to a string
  37419. * @param fullDetails support for multiple levels of logging within scene loading
  37420. * @returns String form of the animation
  37421. */
  37422. toString(fullDetails?: boolean): string;
  37423. /**
  37424. * Add an event to this animation
  37425. * @param event Event to add
  37426. */
  37427. addEvent(event: AnimationEvent): void;
  37428. /**
  37429. * Remove all events found at the given frame
  37430. * @param frame The frame to remove events from
  37431. */
  37432. removeEvents(frame: number): void;
  37433. /**
  37434. * Retrieves all the events from the animation
  37435. * @returns Events from the animation
  37436. */
  37437. getEvents(): AnimationEvent[];
  37438. /**
  37439. * Creates an animation range
  37440. * @param name Name of the animation range
  37441. * @param from Starting frame of the animation range
  37442. * @param to Ending frame of the animation
  37443. */
  37444. createRange(name: string, from: number, to: number): void;
  37445. /**
  37446. * Deletes an animation range by name
  37447. * @param name Name of the animation range to delete
  37448. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  37449. */
  37450. deleteRange(name: string, deleteFrames?: boolean): void;
  37451. /**
  37452. * Gets the animation range by name, or null if not defined
  37453. * @param name Name of the animation range
  37454. * @returns Nullable animation range
  37455. */
  37456. getRange(name: string): Nullable<AnimationRange>;
  37457. /**
  37458. * Gets the key frames from the animation
  37459. * @returns The key frames of the animation
  37460. */
  37461. getKeys(): Array<IAnimationKey>;
  37462. /**
  37463. * Gets the highest frame rate of the animation
  37464. * @returns Highest frame rate of the animation
  37465. */
  37466. getHighestFrame(): number;
  37467. /**
  37468. * Gets the easing function of the animation
  37469. * @returns Easing function of the animation
  37470. */
  37471. getEasingFunction(): IEasingFunction;
  37472. /**
  37473. * Sets the easing function of the animation
  37474. * @param easingFunction A custom mathematical formula for animation
  37475. */
  37476. setEasingFunction(easingFunction: EasingFunction): void;
  37477. /**
  37478. * Interpolates a scalar linearly
  37479. * @param startValue Start value of the animation curve
  37480. * @param endValue End value of the animation curve
  37481. * @param gradient Scalar amount to interpolate
  37482. * @returns Interpolated scalar value
  37483. */
  37484. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  37485. /**
  37486. * Interpolates a scalar cubically
  37487. * @param startValue Start value of the animation curve
  37488. * @param outTangent End tangent of the animation
  37489. * @param endValue End value of the animation curve
  37490. * @param inTangent Start tangent of the animation curve
  37491. * @param gradient Scalar amount to interpolate
  37492. * @returns Interpolated scalar value
  37493. */
  37494. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  37495. /**
  37496. * Interpolates a quaternion using a spherical linear interpolation
  37497. * @param startValue Start value of the animation curve
  37498. * @param endValue End value of the animation curve
  37499. * @param gradient Scalar amount to interpolate
  37500. * @returns Interpolated quaternion value
  37501. */
  37502. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  37503. /**
  37504. * Interpolates a quaternion cubically
  37505. * @param startValue Start value of the animation curve
  37506. * @param outTangent End tangent of the animation curve
  37507. * @param endValue End value of the animation curve
  37508. * @param inTangent Start tangent of the animation curve
  37509. * @param gradient Scalar amount to interpolate
  37510. * @returns Interpolated quaternion value
  37511. */
  37512. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  37513. /**
  37514. * Interpolates a Vector3 linearl
  37515. * @param startValue Start value of the animation curve
  37516. * @param endValue End value of the animation curve
  37517. * @param gradient Scalar amount to interpolate
  37518. * @returns Interpolated scalar value
  37519. */
  37520. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  37521. /**
  37522. * Interpolates a Vector3 cubically
  37523. * @param startValue Start value of the animation curve
  37524. * @param outTangent End tangent of the animation
  37525. * @param endValue End value of the animation curve
  37526. * @param inTangent Start tangent of the animation curve
  37527. * @param gradient Scalar amount to interpolate
  37528. * @returns InterpolatedVector3 value
  37529. */
  37530. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  37531. /**
  37532. * Interpolates a Vector2 linearly
  37533. * @param startValue Start value of the animation curve
  37534. * @param endValue End value of the animation curve
  37535. * @param gradient Scalar amount to interpolate
  37536. * @returns Interpolated Vector2 value
  37537. */
  37538. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  37539. /**
  37540. * Interpolates a Vector2 cubically
  37541. * @param startValue Start value of the animation curve
  37542. * @param outTangent End tangent of the animation
  37543. * @param endValue End value of the animation curve
  37544. * @param inTangent Start tangent of the animation curve
  37545. * @param gradient Scalar amount to interpolate
  37546. * @returns Interpolated Vector2 value
  37547. */
  37548. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  37549. /**
  37550. * Interpolates a size linearly
  37551. * @param startValue Start value of the animation curve
  37552. * @param endValue End value of the animation curve
  37553. * @param gradient Scalar amount to interpolate
  37554. * @returns Interpolated Size value
  37555. */
  37556. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  37557. /**
  37558. * Interpolates a Color3 linearly
  37559. * @param startValue Start value of the animation curve
  37560. * @param endValue End value of the animation curve
  37561. * @param gradient Scalar amount to interpolate
  37562. * @returns Interpolated Color3 value
  37563. */
  37564. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  37565. /**
  37566. * Interpolates a Color4 linearly
  37567. * @param startValue Start value of the animation curve
  37568. * @param endValue End value of the animation curve
  37569. * @param gradient Scalar amount to interpolate
  37570. * @returns Interpolated Color3 value
  37571. */
  37572. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  37573. /**
  37574. * @hidden Internal use only
  37575. */
  37576. _getKeyValue(value: any): any;
  37577. /**
  37578. * @hidden Internal use only
  37579. */
  37580. _interpolate(currentFrame: number, state: _IAnimationState): any;
  37581. /**
  37582. * Defines the function to use to interpolate matrices
  37583. * @param startValue defines the start matrix
  37584. * @param endValue defines the end matrix
  37585. * @param gradient defines the gradient between both matrices
  37586. * @param result defines an optional target matrix where to store the interpolation
  37587. * @returns the interpolated matrix
  37588. */
  37589. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  37590. /**
  37591. * Makes a copy of the animation
  37592. * @returns Cloned animation
  37593. */
  37594. clone(): Animation;
  37595. /**
  37596. * Sets the key frames of the animation
  37597. * @param values The animation key frames to set
  37598. */
  37599. setKeys(values: Array<IAnimationKey>): void;
  37600. /**
  37601. * Serializes the animation to an object
  37602. * @returns Serialized object
  37603. */
  37604. serialize(): any;
  37605. /**
  37606. * Float animation type
  37607. */
  37608. static readonly ANIMATIONTYPE_FLOAT: number;
  37609. /**
  37610. * Vector3 animation type
  37611. */
  37612. static readonly ANIMATIONTYPE_VECTOR3: number;
  37613. /**
  37614. * Quaternion animation type
  37615. */
  37616. static readonly ANIMATIONTYPE_QUATERNION: number;
  37617. /**
  37618. * Matrix animation type
  37619. */
  37620. static readonly ANIMATIONTYPE_MATRIX: number;
  37621. /**
  37622. * Color3 animation type
  37623. */
  37624. static readonly ANIMATIONTYPE_COLOR3: number;
  37625. /**
  37626. * Color3 animation type
  37627. */
  37628. static readonly ANIMATIONTYPE_COLOR4: number;
  37629. /**
  37630. * Vector2 animation type
  37631. */
  37632. static readonly ANIMATIONTYPE_VECTOR2: number;
  37633. /**
  37634. * Size animation type
  37635. */
  37636. static readonly ANIMATIONTYPE_SIZE: number;
  37637. /**
  37638. * Relative Loop Mode
  37639. */
  37640. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  37641. /**
  37642. * Cycle Loop Mode
  37643. */
  37644. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  37645. /**
  37646. * Constant Loop Mode
  37647. */
  37648. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  37649. /** @hidden */
  37650. static _UniversalLerp(left: any, right: any, amount: number): any;
  37651. /**
  37652. * Parses an animation object and creates an animation
  37653. * @param parsedAnimation Parsed animation object
  37654. * @returns Animation object
  37655. */
  37656. static Parse(parsedAnimation: any): Animation;
  37657. /**
  37658. * Appends the serialized animations from the source animations
  37659. * @param source Source containing the animations
  37660. * @param destination Target to store the animations
  37661. */
  37662. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37663. /**
  37664. * Creates a new animation or an array of animations from a snippet saved in a remote file
  37665. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  37666. * @param url defines the url to load from
  37667. * @returns a promise that will resolve to the new animation or an array of animations
  37668. */
  37669. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  37670. /**
  37671. * Creates an animation or an array of animations from a snippet saved by the Inspector
  37672. * @param snippetId defines the snippet to load
  37673. * @returns a promise that will resolve to the new animation or a new array of animations
  37674. */
  37675. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  37676. }
  37677. }
  37678. declare module BABYLON {
  37679. /**
  37680. * Interface containing an array of animations
  37681. */
  37682. export interface IAnimatable {
  37683. /**
  37684. * Array of animations
  37685. */
  37686. animations: Nullable<Array<Animation>>;
  37687. }
  37688. }
  37689. declare module BABYLON {
  37690. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37691. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37692. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37693. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37694. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37695. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37696. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37697. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37698. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37699. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37700. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37701. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37702. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37703. /**
  37704. * Decorator used to define property that can be serialized as reference to a camera
  37705. * @param sourceName defines the name of the property to decorate
  37706. */
  37707. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37708. /**
  37709. * Class used to help serialization objects
  37710. */
  37711. export class SerializationHelper {
  37712. /** @hidden */
  37713. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  37714. /** @hidden */
  37715. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  37716. /** @hidden */
  37717. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  37718. /** @hidden */
  37719. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  37720. /**
  37721. * Appends the serialized animations from the source animations
  37722. * @param source Source containing the animations
  37723. * @param destination Target to store the animations
  37724. */
  37725. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37726. /**
  37727. * Static function used to serialized a specific entity
  37728. * @param entity defines the entity to serialize
  37729. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  37730. * @returns a JSON compatible object representing the serialization of the entity
  37731. */
  37732. static Serialize<T>(entity: T, serializationObject?: any): any;
  37733. /**
  37734. * Creates a new entity from a serialization data object
  37735. * @param creationFunction defines a function used to instanciated the new entity
  37736. * @param source defines the source serialization data
  37737. * @param scene defines the hosting scene
  37738. * @param rootUrl defines the root url for resources
  37739. * @returns a new entity
  37740. */
  37741. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37742. /**
  37743. * Clones an object
  37744. * @param creationFunction defines the function used to instanciate the new object
  37745. * @param source defines the source object
  37746. * @returns the cloned object
  37747. */
  37748. static Clone<T>(creationFunction: () => T, source: T): T;
  37749. /**
  37750. * Instanciates a new object based on a source one (some data will be shared between both object)
  37751. * @param creationFunction defines the function used to instanciate the new object
  37752. * @param source defines the source object
  37753. * @returns the new object
  37754. */
  37755. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37756. }
  37757. }
  37758. declare module BABYLON {
  37759. /**
  37760. * This is the base class of all the camera used in the application.
  37761. * @see https://doc.babylonjs.com/features/cameras
  37762. */
  37763. export class Camera extends Node {
  37764. /** @hidden */
  37765. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  37766. /**
  37767. * This is the default projection mode used by the cameras.
  37768. * It helps recreating a feeling of perspective and better appreciate depth.
  37769. * This is the best way to simulate real life cameras.
  37770. */
  37771. static readonly PERSPECTIVE_CAMERA: number;
  37772. /**
  37773. * This helps creating camera with an orthographic mode.
  37774. * Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object.
  37775. */
  37776. static readonly ORTHOGRAPHIC_CAMERA: number;
  37777. /**
  37778. * This is the default FOV mode for perspective cameras.
  37779. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  37780. */
  37781. static readonly FOVMODE_VERTICAL_FIXED: number;
  37782. /**
  37783. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  37784. */
  37785. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  37786. /**
  37787. * This specifies ther is no need for a camera rig.
  37788. * Basically only one eye is rendered corresponding to the camera.
  37789. */
  37790. static readonly RIG_MODE_NONE: number;
  37791. /**
  37792. * Simulates a camera Rig with one blue eye and one red eye.
  37793. * This can be use with 3d blue and red glasses.
  37794. */
  37795. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  37796. /**
  37797. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  37798. */
  37799. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  37800. /**
  37801. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  37802. */
  37803. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  37804. /**
  37805. * Defines that both eyes of the camera will be rendered over under each other.
  37806. */
  37807. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  37808. /**
  37809. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  37810. */
  37811. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  37812. /**
  37813. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  37814. */
  37815. static readonly RIG_MODE_VR: number;
  37816. /**
  37817. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  37818. */
  37819. static readonly RIG_MODE_WEBVR: number;
  37820. /**
  37821. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  37822. */
  37823. static readonly RIG_MODE_CUSTOM: number;
  37824. /**
  37825. * Defines if by default attaching controls should prevent the default javascript event to continue.
  37826. */
  37827. static ForceAttachControlToAlwaysPreventDefault: boolean;
  37828. /**
  37829. * Define the input manager associated with the camera.
  37830. */
  37831. inputs: CameraInputsManager<Camera>;
  37832. /** @hidden */
  37833. _position: Vector3;
  37834. /**
  37835. * Define the current local position of the camera in the scene
  37836. */
  37837. get position(): Vector3;
  37838. set position(newPosition: Vector3);
  37839. protected _upVector: Vector3;
  37840. /**
  37841. * The vector the camera should consider as up.
  37842. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  37843. */
  37844. set upVector(vec: Vector3);
  37845. get upVector(): Vector3;
  37846. /**
  37847. * Define the current limit on the left side for an orthographic camera
  37848. * In scene unit
  37849. */
  37850. orthoLeft: Nullable<number>;
  37851. /**
  37852. * Define the current limit on the right side for an orthographic camera
  37853. * In scene unit
  37854. */
  37855. orthoRight: Nullable<number>;
  37856. /**
  37857. * Define the current limit on the bottom side for an orthographic camera
  37858. * In scene unit
  37859. */
  37860. orthoBottom: Nullable<number>;
  37861. /**
  37862. * Define the current limit on the top side for an orthographic camera
  37863. * In scene unit
  37864. */
  37865. orthoTop: Nullable<number>;
  37866. /**
  37867. * Field Of View is set in Radians. (default is 0.8)
  37868. */
  37869. fov: number;
  37870. /**
  37871. * Define the minimum distance the camera can see from.
  37872. * This is important to note that the depth buffer are not infinite and the closer it starts
  37873. * the more your scene might encounter depth fighting issue.
  37874. */
  37875. minZ: number;
  37876. /**
  37877. * Define the maximum distance the camera can see to.
  37878. * This is important to note that the depth buffer are not infinite and the further it end
  37879. * the more your scene might encounter depth fighting issue.
  37880. */
  37881. maxZ: number;
  37882. /**
  37883. * Define the default inertia of the camera.
  37884. * This helps giving a smooth feeling to the camera movement.
  37885. */
  37886. inertia: number;
  37887. /**
  37888. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  37889. */
  37890. mode: number;
  37891. /**
  37892. * Define whether the camera is intermediate.
  37893. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  37894. */
  37895. isIntermediate: boolean;
  37896. /**
  37897. * Define the viewport of the camera.
  37898. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  37899. */
  37900. viewport: Viewport;
  37901. /**
  37902. * Restricts the camera to viewing objects with the same layerMask.
  37903. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  37904. */
  37905. layerMask: number;
  37906. /**
  37907. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  37908. */
  37909. fovMode: number;
  37910. /**
  37911. * Rig mode of the camera.
  37912. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  37913. * This is normally controlled byt the camera themselves as internal use.
  37914. */
  37915. cameraRigMode: number;
  37916. /**
  37917. * Defines the distance between both "eyes" in case of a RIG
  37918. */
  37919. interaxialDistance: number;
  37920. /**
  37921. * Defines if stereoscopic rendering is done side by side or over under.
  37922. */
  37923. isStereoscopicSideBySide: boolean;
  37924. /**
  37925. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  37926. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  37927. * else in the scene. (Eg. security camera)
  37928. *
  37929. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  37930. */
  37931. customRenderTargets: RenderTargetTexture[];
  37932. /**
  37933. * When set, the camera will render to this render target instead of the default canvas
  37934. *
  37935. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  37936. */
  37937. outputRenderTarget: Nullable<RenderTargetTexture>;
  37938. /**
  37939. * Observable triggered when the camera view matrix has changed.
  37940. */
  37941. onViewMatrixChangedObservable: Observable<Camera>;
  37942. /**
  37943. * Observable triggered when the camera Projection matrix has changed.
  37944. */
  37945. onProjectionMatrixChangedObservable: Observable<Camera>;
  37946. /**
  37947. * Observable triggered when the inputs have been processed.
  37948. */
  37949. onAfterCheckInputsObservable: Observable<Camera>;
  37950. /**
  37951. * Observable triggered when reset has been called and applied to the camera.
  37952. */
  37953. onRestoreStateObservable: Observable<Camera>;
  37954. /**
  37955. * Is this camera a part of a rig system?
  37956. */
  37957. isRigCamera: boolean;
  37958. /**
  37959. * If isRigCamera set to true this will be set with the parent camera.
  37960. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  37961. */
  37962. rigParent?: Camera;
  37963. /** @hidden */
  37964. _cameraRigParams: any;
  37965. /** @hidden */
  37966. _rigCameras: Camera[];
  37967. /** @hidden */
  37968. _rigPostProcess: Nullable<PostProcess>;
  37969. protected _webvrViewMatrix: Matrix;
  37970. /** @hidden */
  37971. _skipRendering: boolean;
  37972. /** @hidden */
  37973. _projectionMatrix: Matrix;
  37974. /** @hidden */
  37975. _postProcesses: Nullable<PostProcess>[];
  37976. /** @hidden */
  37977. _activeMeshes: SmartArray<AbstractMesh>;
  37978. protected _globalPosition: Vector3;
  37979. /** @hidden */
  37980. _computedViewMatrix: Matrix;
  37981. private _doNotComputeProjectionMatrix;
  37982. private _transformMatrix;
  37983. private _frustumPlanes;
  37984. private _refreshFrustumPlanes;
  37985. private _storedFov;
  37986. private _stateStored;
  37987. /**
  37988. * Instantiates a new camera object.
  37989. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  37990. * @see https://doc.babylonjs.com/features/cameras
  37991. * @param name Defines the name of the camera in the scene
  37992. * @param position Defines the position of the camera
  37993. * @param scene Defines the scene the camera belongs too
  37994. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  37995. */
  37996. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37997. /**
  37998. * Store current camera state (fov, position, etc..)
  37999. * @returns the camera
  38000. */
  38001. storeState(): Camera;
  38002. /**
  38003. * Restores the camera state values if it has been stored. You must call storeState() first
  38004. */
  38005. protected _restoreStateValues(): boolean;
  38006. /**
  38007. * Restored camera state. You must call storeState() first.
  38008. * @returns true if restored and false otherwise
  38009. */
  38010. restoreState(): boolean;
  38011. /**
  38012. * Gets the class name of the camera.
  38013. * @returns the class name
  38014. */
  38015. getClassName(): string;
  38016. /** @hidden */
  38017. readonly _isCamera: boolean;
  38018. /**
  38019. * Gets a string representation of the camera useful for debug purpose.
  38020. * @param fullDetails Defines that a more verboe level of logging is required
  38021. * @returns the string representation
  38022. */
  38023. toString(fullDetails?: boolean): string;
  38024. /**
  38025. * Gets the current world space position of the camera.
  38026. */
  38027. get globalPosition(): Vector3;
  38028. /**
  38029. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  38030. * @returns the active meshe list
  38031. */
  38032. getActiveMeshes(): SmartArray<AbstractMesh>;
  38033. /**
  38034. * Check whether a mesh is part of the current active mesh list of the camera
  38035. * @param mesh Defines the mesh to check
  38036. * @returns true if active, false otherwise
  38037. */
  38038. isActiveMesh(mesh: Mesh): boolean;
  38039. /**
  38040. * Is this camera ready to be used/rendered
  38041. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  38042. * @return true if the camera is ready
  38043. */
  38044. isReady(completeCheck?: boolean): boolean;
  38045. /** @hidden */
  38046. _initCache(): void;
  38047. /** @hidden */
  38048. _updateCache(ignoreParentClass?: boolean): void;
  38049. /** @hidden */
  38050. _isSynchronized(): boolean;
  38051. /** @hidden */
  38052. _isSynchronizedViewMatrix(): boolean;
  38053. /** @hidden */
  38054. _isSynchronizedProjectionMatrix(): boolean;
  38055. /**
  38056. * Attach the input controls to a specific dom element to get the input from.
  38057. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38058. */
  38059. attachControl(noPreventDefault?: boolean): void;
  38060. /**
  38061. * Attach the input controls to a specific dom element to get the input from.
  38062. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  38063. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38064. * BACK COMPAT SIGNATURE ONLY.
  38065. */
  38066. attachControl(ignored: any, noPreventDefault?: boolean): void;
  38067. /**
  38068. * Detach the current controls from the specified dom element.
  38069. */
  38070. detachControl(): void;
  38071. /**
  38072. * Detach the current controls from the specified dom element.
  38073. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  38074. */
  38075. detachControl(ignored: any): void;
  38076. /**
  38077. * Update the camera state according to the different inputs gathered during the frame.
  38078. */
  38079. update(): void;
  38080. /** @hidden */
  38081. _checkInputs(): void;
  38082. /** @hidden */
  38083. get rigCameras(): Camera[];
  38084. /**
  38085. * Gets the post process used by the rig cameras
  38086. */
  38087. get rigPostProcess(): Nullable<PostProcess>;
  38088. /**
  38089. * Internal, gets the first post proces.
  38090. * @returns the first post process to be run on this camera.
  38091. */
  38092. _getFirstPostProcess(): Nullable<PostProcess>;
  38093. private _cascadePostProcessesToRigCams;
  38094. /**
  38095. * Attach a post process to the camera.
  38096. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38097. * @param postProcess The post process to attach to the camera
  38098. * @param insertAt The position of the post process in case several of them are in use in the scene
  38099. * @returns the position the post process has been inserted at
  38100. */
  38101. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  38102. /**
  38103. * Detach a post process to the camera.
  38104. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38105. * @param postProcess The post process to detach from the camera
  38106. */
  38107. detachPostProcess(postProcess: PostProcess): void;
  38108. /**
  38109. * Gets the current world matrix of the camera
  38110. */
  38111. getWorldMatrix(): Matrix;
  38112. /** @hidden */
  38113. _getViewMatrix(): Matrix;
  38114. /**
  38115. * Gets the current view matrix of the camera.
  38116. * @param force forces the camera to recompute the matrix without looking at the cached state
  38117. * @returns the view matrix
  38118. */
  38119. getViewMatrix(force?: boolean): Matrix;
  38120. /**
  38121. * Freeze the projection matrix.
  38122. * It will prevent the cache check of the camera projection compute and can speed up perf
  38123. * if no parameter of the camera are meant to change
  38124. * @param projection Defines manually a projection if necessary
  38125. */
  38126. freezeProjectionMatrix(projection?: Matrix): void;
  38127. /**
  38128. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  38129. */
  38130. unfreezeProjectionMatrix(): void;
  38131. /**
  38132. * Gets the current projection matrix of the camera.
  38133. * @param force forces the camera to recompute the matrix without looking at the cached state
  38134. * @returns the projection matrix
  38135. */
  38136. getProjectionMatrix(force?: boolean): Matrix;
  38137. /**
  38138. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  38139. * @returns a Matrix
  38140. */
  38141. getTransformationMatrix(): Matrix;
  38142. private _updateFrustumPlanes;
  38143. /**
  38144. * Checks if a cullable object (mesh...) is in the camera frustum
  38145. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  38146. * @param target The object to check
  38147. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  38148. * @returns true if the object is in frustum otherwise false
  38149. */
  38150. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  38151. /**
  38152. * Checks if a cullable object (mesh...) is in the camera frustum
  38153. * Unlike isInFrustum this cheks the full bounding box
  38154. * @param target The object to check
  38155. * @returns true if the object is in frustum otherwise false
  38156. */
  38157. isCompletelyInFrustum(target: ICullable): boolean;
  38158. /**
  38159. * Gets a ray in the forward direction from the camera.
  38160. * @param length Defines the length of the ray to create
  38161. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38162. * @param origin Defines the start point of the ray which defaults to the camera position
  38163. * @returns the forward ray
  38164. */
  38165. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38166. /**
  38167. * Gets a ray in the forward direction from the camera.
  38168. * @param refRay the ray to (re)use when setting the values
  38169. * @param length Defines the length of the ray to create
  38170. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38171. * @param origin Defines the start point of the ray which defaults to the camera position
  38172. * @returns the forward ray
  38173. */
  38174. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38175. /**
  38176. * Releases resources associated with this node.
  38177. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38178. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38179. */
  38180. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38181. /** @hidden */
  38182. _isLeftCamera: boolean;
  38183. /**
  38184. * Gets the left camera of a rig setup in case of Rigged Camera
  38185. */
  38186. get isLeftCamera(): boolean;
  38187. /** @hidden */
  38188. _isRightCamera: boolean;
  38189. /**
  38190. * Gets the right camera of a rig setup in case of Rigged Camera
  38191. */
  38192. get isRightCamera(): boolean;
  38193. /**
  38194. * Gets the left camera of a rig setup in case of Rigged Camera
  38195. */
  38196. get leftCamera(): Nullable<FreeCamera>;
  38197. /**
  38198. * Gets the right camera of a rig setup in case of Rigged Camera
  38199. */
  38200. get rightCamera(): Nullable<FreeCamera>;
  38201. /**
  38202. * Gets the left camera target of a rig setup in case of Rigged Camera
  38203. * @returns the target position
  38204. */
  38205. getLeftTarget(): Nullable<Vector3>;
  38206. /**
  38207. * Gets the right camera target of a rig setup in case of Rigged Camera
  38208. * @returns the target position
  38209. */
  38210. getRightTarget(): Nullable<Vector3>;
  38211. /**
  38212. * @hidden
  38213. */
  38214. setCameraRigMode(mode: number, rigParams: any): void;
  38215. /** @hidden */
  38216. static _setStereoscopicRigMode(camera: Camera): void;
  38217. /** @hidden */
  38218. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  38219. /** @hidden */
  38220. static _setVRRigMode(camera: Camera, rigParams: any): void;
  38221. /** @hidden */
  38222. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  38223. /** @hidden */
  38224. _getVRProjectionMatrix(): Matrix;
  38225. protected _updateCameraRotationMatrix(): void;
  38226. protected _updateWebVRCameraRotationMatrix(): void;
  38227. /**
  38228. * This function MUST be overwritten by the different WebVR cameras available.
  38229. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38230. * @hidden
  38231. */
  38232. _getWebVRProjectionMatrix(): Matrix;
  38233. /**
  38234. * This function MUST be overwritten by the different WebVR cameras available.
  38235. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38236. * @hidden
  38237. */
  38238. _getWebVRViewMatrix(): Matrix;
  38239. /** @hidden */
  38240. setCameraRigParameter(name: string, value: any): void;
  38241. /**
  38242. * needs to be overridden by children so sub has required properties to be copied
  38243. * @hidden
  38244. */
  38245. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  38246. /**
  38247. * May need to be overridden by children
  38248. * @hidden
  38249. */
  38250. _updateRigCameras(): void;
  38251. /** @hidden */
  38252. _setupInputs(): void;
  38253. /**
  38254. * Serialiaze the camera setup to a json represention
  38255. * @returns the JSON representation
  38256. */
  38257. serialize(): any;
  38258. /**
  38259. * Clones the current camera.
  38260. * @param name The cloned camera name
  38261. * @returns the cloned camera
  38262. */
  38263. clone(name: string): Camera;
  38264. /**
  38265. * Gets the direction of the camera relative to a given local axis.
  38266. * @param localAxis Defines the reference axis to provide a relative direction.
  38267. * @return the direction
  38268. */
  38269. getDirection(localAxis: Vector3): Vector3;
  38270. /**
  38271. * Returns the current camera absolute rotation
  38272. */
  38273. get absoluteRotation(): Quaternion;
  38274. /**
  38275. * Gets the direction of the camera relative to a given local axis into a passed vector.
  38276. * @param localAxis Defines the reference axis to provide a relative direction.
  38277. * @param result Defines the vector to store the result in
  38278. */
  38279. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  38280. /**
  38281. * Gets a camera constructor for a given camera type
  38282. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  38283. * @param name The name of the camera the result will be able to instantiate
  38284. * @param scene The scene the result will construct the camera in
  38285. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  38286. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  38287. * @returns a factory method to construc the camera
  38288. */
  38289. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  38290. /**
  38291. * Compute the world matrix of the camera.
  38292. * @returns the camera world matrix
  38293. */
  38294. computeWorldMatrix(): Matrix;
  38295. /**
  38296. * Parse a JSON and creates the camera from the parsed information
  38297. * @param parsedCamera The JSON to parse
  38298. * @param scene The scene to instantiate the camera in
  38299. * @returns the newly constructed camera
  38300. */
  38301. static Parse(parsedCamera: any, scene: Scene): Camera;
  38302. }
  38303. }
  38304. declare module BABYLON {
  38305. /**
  38306. * PostProcessManager is used to manage one or more post processes or post process pipelines
  38307. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  38308. */
  38309. export class PostProcessManager {
  38310. private _scene;
  38311. private _indexBuffer;
  38312. private _vertexBuffers;
  38313. /**
  38314. * Creates a new instance PostProcess
  38315. * @param scene The scene that the post process is associated with.
  38316. */
  38317. constructor(scene: Scene);
  38318. private _prepareBuffers;
  38319. private _buildIndexBuffer;
  38320. /**
  38321. * Rebuilds the vertex buffers of the manager.
  38322. * @hidden
  38323. */
  38324. _rebuild(): void;
  38325. /**
  38326. * Prepares a frame to be run through a post process.
  38327. * @param sourceTexture The input texture to the post procesess. (default: null)
  38328. * @param postProcesses An array of post processes to be run. (default: null)
  38329. * @returns True if the post processes were able to be run.
  38330. * @hidden
  38331. */
  38332. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  38333. /**
  38334. * Manually render a set of post processes to a texture.
  38335. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  38336. * @param postProcesses An array of post processes to be run.
  38337. * @param targetTexture The target texture to render to.
  38338. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  38339. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  38340. * @param lodLevel defines which lod of the texture to render to
  38341. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  38342. */
  38343. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  38344. /**
  38345. * Finalize the result of the output of the postprocesses.
  38346. * @param doNotPresent If true the result will not be displayed to the screen.
  38347. * @param targetTexture The target texture to render to.
  38348. * @param faceIndex The index of the face to bind the target texture to.
  38349. * @param postProcesses The array of post processes to render.
  38350. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  38351. * @hidden
  38352. */
  38353. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  38354. /**
  38355. * Disposes of the post process manager.
  38356. */
  38357. dispose(): void;
  38358. }
  38359. }
  38360. declare module BABYLON {
  38361. /**
  38362. * This Helps creating a texture that will be created from a camera in your scene.
  38363. * It is basically a dynamic texture that could be used to create special effects for instance.
  38364. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  38365. */
  38366. export class RenderTargetTexture extends Texture {
  38367. /**
  38368. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  38369. */
  38370. static readonly REFRESHRATE_RENDER_ONCE: number;
  38371. /**
  38372. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  38373. */
  38374. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  38375. /**
  38376. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  38377. * the central point of your effect and can save a lot of performances.
  38378. */
  38379. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  38380. /**
  38381. * Use this predicate to dynamically define the list of mesh you want to render.
  38382. * If set, the renderList property will be overwritten.
  38383. */
  38384. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  38385. private _renderList;
  38386. /**
  38387. * Use this list to define the list of mesh you want to render.
  38388. */
  38389. get renderList(): Nullable<Array<AbstractMesh>>;
  38390. set renderList(value: Nullable<Array<AbstractMesh>>);
  38391. /**
  38392. * Use this function to overload the renderList array at rendering time.
  38393. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  38394. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  38395. * the cube (if the RTT is a cube, else layerOrFace=0).
  38396. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  38397. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  38398. * hold dummy elements!
  38399. */
  38400. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  38401. private _hookArray;
  38402. /**
  38403. * Define if particles should be rendered in your texture.
  38404. */
  38405. renderParticles: boolean;
  38406. /**
  38407. * Define if sprites should be rendered in your texture.
  38408. */
  38409. renderSprites: boolean;
  38410. /**
  38411. * Define the camera used to render the texture.
  38412. */
  38413. activeCamera: Nullable<Camera>;
  38414. /**
  38415. * Override the mesh isReady function with your own one.
  38416. */
  38417. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  38418. /**
  38419. * Override the render function of the texture with your own one.
  38420. */
  38421. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  38422. /**
  38423. * Define if camera post processes should be use while rendering the texture.
  38424. */
  38425. useCameraPostProcesses: boolean;
  38426. /**
  38427. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  38428. */
  38429. ignoreCameraViewport: boolean;
  38430. private _postProcessManager;
  38431. private _postProcesses;
  38432. private _resizeObserver;
  38433. /**
  38434. * An event triggered when the texture is unbind.
  38435. */
  38436. onBeforeBindObservable: Observable<RenderTargetTexture>;
  38437. /**
  38438. * An event triggered when the texture is unbind.
  38439. */
  38440. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  38441. private _onAfterUnbindObserver;
  38442. /**
  38443. * Set a after unbind callback in the texture.
  38444. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  38445. */
  38446. set onAfterUnbind(callback: () => void);
  38447. /**
  38448. * An event triggered before rendering the texture
  38449. */
  38450. onBeforeRenderObservable: Observable<number>;
  38451. private _onBeforeRenderObserver;
  38452. /**
  38453. * Set a before render callback in the texture.
  38454. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  38455. */
  38456. set onBeforeRender(callback: (faceIndex: number) => void);
  38457. /**
  38458. * An event triggered after rendering the texture
  38459. */
  38460. onAfterRenderObservable: Observable<number>;
  38461. private _onAfterRenderObserver;
  38462. /**
  38463. * Set a after render callback in the texture.
  38464. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  38465. */
  38466. set onAfterRender(callback: (faceIndex: number) => void);
  38467. /**
  38468. * An event triggered after the texture clear
  38469. */
  38470. onClearObservable: Observable<Engine>;
  38471. private _onClearObserver;
  38472. /**
  38473. * Set a clear callback in the texture.
  38474. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  38475. */
  38476. set onClear(callback: (Engine: Engine) => void);
  38477. /**
  38478. * An event triggered when the texture is resized.
  38479. */
  38480. onResizeObservable: Observable<RenderTargetTexture>;
  38481. /**
  38482. * Define the clear color of the Render Target if it should be different from the scene.
  38483. */
  38484. clearColor: Color4;
  38485. protected _size: number | {
  38486. width: number;
  38487. height: number;
  38488. layers?: number;
  38489. };
  38490. protected _initialSizeParameter: number | {
  38491. width: number;
  38492. height: number;
  38493. } | {
  38494. ratio: number;
  38495. };
  38496. protected _sizeRatio: Nullable<number>;
  38497. /** @hidden */
  38498. _generateMipMaps: boolean;
  38499. protected _renderingManager: RenderingManager;
  38500. /** @hidden */
  38501. _waitingRenderList?: string[];
  38502. protected _doNotChangeAspectRatio: boolean;
  38503. protected _currentRefreshId: number;
  38504. protected _refreshRate: number;
  38505. protected _textureMatrix: Matrix;
  38506. protected _samples: number;
  38507. protected _renderTargetOptions: RenderTargetCreationOptions;
  38508. /**
  38509. * Gets render target creation options that were used.
  38510. */
  38511. get renderTargetOptions(): RenderTargetCreationOptions;
  38512. protected _onRatioRescale(): void;
  38513. /**
  38514. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  38515. * It must define where the camera used to render the texture is set
  38516. */
  38517. boundingBoxPosition: Vector3;
  38518. private _boundingBoxSize;
  38519. /**
  38520. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  38521. * When defined, the cubemap will switch to local mode
  38522. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  38523. * @example https://www.babylonjs-playground.com/#RNASML
  38524. */
  38525. set boundingBoxSize(value: Vector3);
  38526. get boundingBoxSize(): Vector3;
  38527. /**
  38528. * In case the RTT has been created with a depth texture, get the associated
  38529. * depth texture.
  38530. * Otherwise, return null.
  38531. */
  38532. get depthStencilTexture(): Nullable<InternalTexture>;
  38533. /**
  38534. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  38535. * or used a shadow, depth texture...
  38536. * @param name The friendly name of the texture
  38537. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  38538. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  38539. * @param generateMipMaps True if mip maps need to be generated after render.
  38540. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  38541. * @param type The type of the buffer in the RTT (int, half float, float...)
  38542. * @param isCube True if a cube texture needs to be created
  38543. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  38544. * @param generateDepthBuffer True to generate a depth buffer
  38545. * @param generateStencilBuffer True to generate a stencil buffer
  38546. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  38547. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  38548. * @param delayAllocation if the texture allocation should be delayed (default: false)
  38549. * @param samples sample count to use when creating the RTT
  38550. */
  38551. constructor(name: string, size: number | {
  38552. width: number;
  38553. height: number;
  38554. layers?: number;
  38555. } | {
  38556. ratio: number;
  38557. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean, samples?: number);
  38558. /**
  38559. * Creates a depth stencil texture.
  38560. * This is only available in WebGL 2 or with the depth texture extension available.
  38561. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  38562. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  38563. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  38564. * @param samples sample count of the depth/stencil texture
  38565. */
  38566. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number): void;
  38567. private _processSizeParameter;
  38568. /**
  38569. * Define the number of samples to use in case of MSAA.
  38570. * It defaults to one meaning no MSAA has been enabled.
  38571. */
  38572. get samples(): number;
  38573. set samples(value: number);
  38574. /**
  38575. * Resets the refresh counter of the texture and start bak from scratch.
  38576. * Could be useful to regenerate the texture if it is setup to render only once.
  38577. */
  38578. resetRefreshCounter(): void;
  38579. /**
  38580. * Define the refresh rate of the texture or the rendering frequency.
  38581. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  38582. */
  38583. get refreshRate(): number;
  38584. set refreshRate(value: number);
  38585. /**
  38586. * Adds a post process to the render target rendering passes.
  38587. * @param postProcess define the post process to add
  38588. */
  38589. addPostProcess(postProcess: PostProcess): void;
  38590. /**
  38591. * Clear all the post processes attached to the render target
  38592. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  38593. */
  38594. clearPostProcesses(dispose?: boolean): void;
  38595. /**
  38596. * Remove one of the post process from the list of attached post processes to the texture
  38597. * @param postProcess define the post process to remove from the list
  38598. */
  38599. removePostProcess(postProcess: PostProcess): void;
  38600. /** @hidden */
  38601. _shouldRender(): boolean;
  38602. /**
  38603. * Gets the actual render size of the texture.
  38604. * @returns the width of the render size
  38605. */
  38606. getRenderSize(): number;
  38607. /**
  38608. * Gets the actual render width of the texture.
  38609. * @returns the width of the render size
  38610. */
  38611. getRenderWidth(): number;
  38612. /**
  38613. * Gets the actual render height of the texture.
  38614. * @returns the height of the render size
  38615. */
  38616. getRenderHeight(): number;
  38617. /**
  38618. * Gets the actual number of layers of the texture.
  38619. * @returns the number of layers
  38620. */
  38621. getRenderLayers(): number;
  38622. /**
  38623. * Get if the texture can be rescaled or not.
  38624. */
  38625. get canRescale(): boolean;
  38626. /**
  38627. * Resize the texture using a ratio.
  38628. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  38629. */
  38630. scale(ratio: number): void;
  38631. /**
  38632. * Get the texture reflection matrix used to rotate/transform the reflection.
  38633. * @returns the reflection matrix
  38634. */
  38635. getReflectionTextureMatrix(): Matrix;
  38636. /**
  38637. * Resize the texture to a new desired size.
  38638. * Be carrefull as it will recreate all the data in the new texture.
  38639. * @param size Define the new size. It can be:
  38640. * - a number for squared texture,
  38641. * - an object containing { width: number, height: number }
  38642. * - or an object containing a ratio { ratio: number }
  38643. */
  38644. resize(size: number | {
  38645. width: number;
  38646. height: number;
  38647. } | {
  38648. ratio: number;
  38649. }): void;
  38650. private _defaultRenderListPrepared;
  38651. /**
  38652. * Renders all the objects from the render list into the texture.
  38653. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  38654. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  38655. */
  38656. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  38657. private _bestReflectionRenderTargetDimension;
  38658. private _prepareRenderingManager;
  38659. /**
  38660. * @hidden
  38661. * @param faceIndex face index to bind to if this is a cubetexture
  38662. * @param layer defines the index of the texture to bind in the array
  38663. */
  38664. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  38665. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  38666. private renderToTarget;
  38667. /**
  38668. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38669. * This allowed control for front to back rendering or reversly depending of the special needs.
  38670. *
  38671. * @param renderingGroupId The rendering group id corresponding to its index
  38672. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38673. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38674. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38675. */
  38676. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  38677. /**
  38678. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38679. *
  38680. * @param renderingGroupId The rendering group id corresponding to its index
  38681. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38682. */
  38683. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  38684. /**
  38685. * Clones the texture.
  38686. * @returns the cloned texture
  38687. */
  38688. clone(): RenderTargetTexture;
  38689. /**
  38690. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  38691. * @returns The JSON representation of the texture
  38692. */
  38693. serialize(): any;
  38694. /**
  38695. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  38696. */
  38697. disposeFramebufferObjects(): void;
  38698. /**
  38699. * Dispose the texture and release its associated resources.
  38700. */
  38701. dispose(): void;
  38702. /** @hidden */
  38703. _rebuild(): void;
  38704. /**
  38705. * Clear the info related to rendering groups preventing retention point in material dispose.
  38706. */
  38707. freeRenderingGroups(): void;
  38708. /**
  38709. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  38710. * @returns the view count
  38711. */
  38712. getViewCount(): number;
  38713. }
  38714. }
  38715. declare module BABYLON {
  38716. /**
  38717. * Options to be used when creating an effect.
  38718. */
  38719. export interface IEffectCreationOptions {
  38720. /**
  38721. * Atrributes that will be used in the shader.
  38722. */
  38723. attributes: string[];
  38724. /**
  38725. * Uniform varible names that will be set in the shader.
  38726. */
  38727. uniformsNames: string[];
  38728. /**
  38729. * Uniform buffer variable names that will be set in the shader.
  38730. */
  38731. uniformBuffersNames: string[];
  38732. /**
  38733. * Sampler texture variable names that will be set in the shader.
  38734. */
  38735. samplers: string[];
  38736. /**
  38737. * Define statements that will be set in the shader.
  38738. */
  38739. defines: any;
  38740. /**
  38741. * Possible fallbacks for this effect to improve performance when needed.
  38742. */
  38743. fallbacks: Nullable<IEffectFallbacks>;
  38744. /**
  38745. * Callback that will be called when the shader is compiled.
  38746. */
  38747. onCompiled: Nullable<(effect: Effect) => void>;
  38748. /**
  38749. * Callback that will be called if an error occurs during shader compilation.
  38750. */
  38751. onError: Nullable<(effect: Effect, errors: string) => void>;
  38752. /**
  38753. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38754. */
  38755. indexParameters?: any;
  38756. /**
  38757. * Max number of lights that can be used in the shader.
  38758. */
  38759. maxSimultaneousLights?: number;
  38760. /**
  38761. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  38762. */
  38763. transformFeedbackVaryings?: Nullable<string[]>;
  38764. /**
  38765. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  38766. */
  38767. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  38768. /**
  38769. * Is this effect rendering to several color attachments ?
  38770. */
  38771. multiTarget?: boolean;
  38772. }
  38773. /**
  38774. * Effect containing vertex and fragment shader that can be executed on an object.
  38775. */
  38776. export class Effect implements IDisposable {
  38777. /**
  38778. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38779. */
  38780. static ShadersRepository: string;
  38781. /**
  38782. * Enable logging of the shader code when a compilation error occurs
  38783. */
  38784. static LogShaderCodeOnCompilationError: boolean;
  38785. /**
  38786. * Name of the effect.
  38787. */
  38788. name: any;
  38789. /**
  38790. * String container all the define statements that should be set on the shader.
  38791. */
  38792. defines: string;
  38793. /**
  38794. * Callback that will be called when the shader is compiled.
  38795. */
  38796. onCompiled: Nullable<(effect: Effect) => void>;
  38797. /**
  38798. * Callback that will be called if an error occurs during shader compilation.
  38799. */
  38800. onError: Nullable<(effect: Effect, errors: string) => void>;
  38801. /**
  38802. * Callback that will be called when effect is bound.
  38803. */
  38804. onBind: Nullable<(effect: Effect) => void>;
  38805. /**
  38806. * Unique ID of the effect.
  38807. */
  38808. uniqueId: number;
  38809. /**
  38810. * Observable that will be called when the shader is compiled.
  38811. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  38812. */
  38813. onCompileObservable: Observable<Effect>;
  38814. /**
  38815. * Observable that will be called if an error occurs during shader compilation.
  38816. */
  38817. onErrorObservable: Observable<Effect>;
  38818. /** @hidden */
  38819. _onBindObservable: Nullable<Observable<Effect>>;
  38820. /**
  38821. * @hidden
  38822. * Specifies if the effect was previously ready
  38823. */
  38824. _wasPreviouslyReady: boolean;
  38825. /**
  38826. * Observable that will be called when effect is bound.
  38827. */
  38828. get onBindObservable(): Observable<Effect>;
  38829. /** @hidden */
  38830. _bonesComputationForcedToCPU: boolean;
  38831. /** @hidden */
  38832. _uniformBuffersNames: {
  38833. [key: string]: number;
  38834. };
  38835. /** @hidden */
  38836. _samplerList: string[];
  38837. /** @hidden */
  38838. _multiTarget: boolean;
  38839. private static _uniqueIdSeed;
  38840. private _engine;
  38841. private _uniformBuffersNamesList;
  38842. private _uniformsNames;
  38843. private _samplers;
  38844. private _isReady;
  38845. private _compilationError;
  38846. private _allFallbacksProcessed;
  38847. private _attributesNames;
  38848. private _attributes;
  38849. private _attributeLocationByName;
  38850. private _uniforms;
  38851. /**
  38852. * Key for the effect.
  38853. * @hidden
  38854. */
  38855. _key: string;
  38856. private _indexParameters;
  38857. private _fallbacks;
  38858. private _vertexSourceCodeOverride;
  38859. private _fragmentSourceCodeOverride;
  38860. private _transformFeedbackVaryings;
  38861. /**
  38862. * Compiled shader to webGL program.
  38863. * @hidden
  38864. */
  38865. _pipelineContext: Nullable<IPipelineContext>;
  38866. /** @hidden */
  38867. _vertexSourceCode: string;
  38868. /** @hidden */
  38869. _fragmentSourceCode: string;
  38870. /** @hidden */
  38871. private _rawVertexSourceCode;
  38872. /** @hidden */
  38873. private _rawFragmentSourceCode;
  38874. private static _baseCache;
  38875. private _processingContext;
  38876. /**
  38877. * Instantiates an effect.
  38878. * An effect can be used to create/manage/execute vertex and fragment shaders.
  38879. * @param baseName Name of the effect.
  38880. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  38881. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  38882. * @param samplers List of sampler variables that will be passed to the shader.
  38883. * @param engine Engine to be used to render the effect
  38884. * @param defines Define statements to be added to the shader.
  38885. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  38886. * @param onCompiled Callback that will be called when the shader is compiled.
  38887. * @param onError Callback that will be called if an error occurs during shader compilation.
  38888. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38889. * @param key Effect Key identifying uniquely compiled shader variants
  38890. */
  38891. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any, key?: string);
  38892. private _useFinalCode;
  38893. /**
  38894. * Unique key for this effect
  38895. */
  38896. get key(): string;
  38897. /**
  38898. * If the effect has been compiled and prepared.
  38899. * @returns if the effect is compiled and prepared.
  38900. */
  38901. isReady(): boolean;
  38902. private _isReadyInternal;
  38903. /**
  38904. * The engine the effect was initialized with.
  38905. * @returns the engine.
  38906. */
  38907. getEngine(): Engine;
  38908. /**
  38909. * The pipeline context for this effect
  38910. * @returns the associated pipeline context
  38911. */
  38912. getPipelineContext(): Nullable<IPipelineContext>;
  38913. /**
  38914. * The set of names of attribute variables for the shader.
  38915. * @returns An array of attribute names.
  38916. */
  38917. getAttributesNames(): string[];
  38918. /**
  38919. * Returns the attribute at the given index.
  38920. * @param index The index of the attribute.
  38921. * @returns The location of the attribute.
  38922. */
  38923. getAttributeLocation(index: number): number;
  38924. /**
  38925. * Returns the attribute based on the name of the variable.
  38926. * @param name of the attribute to look up.
  38927. * @returns the attribute location.
  38928. */
  38929. getAttributeLocationByName(name: string): number;
  38930. /**
  38931. * The number of attributes.
  38932. * @returns the numnber of attributes.
  38933. */
  38934. getAttributesCount(): number;
  38935. /**
  38936. * Gets the index of a uniform variable.
  38937. * @param uniformName of the uniform to look up.
  38938. * @returns the index.
  38939. */
  38940. getUniformIndex(uniformName: string): number;
  38941. /**
  38942. * Returns the attribute based on the name of the variable.
  38943. * @param uniformName of the uniform to look up.
  38944. * @returns the location of the uniform.
  38945. */
  38946. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  38947. /**
  38948. * Returns an array of sampler variable names
  38949. * @returns The array of sampler variable names.
  38950. */
  38951. getSamplers(): string[];
  38952. /**
  38953. * Returns an array of uniform variable names
  38954. * @returns The array of uniform variable names.
  38955. */
  38956. getUniformNames(): string[];
  38957. /**
  38958. * Returns an array of uniform buffer variable names
  38959. * @returns The array of uniform buffer variable names.
  38960. */
  38961. getUniformBuffersNames(): string[];
  38962. /**
  38963. * Returns the index parameters used to create the effect
  38964. * @returns The index parameters object
  38965. */
  38966. getIndexParameters(): any;
  38967. /**
  38968. * The error from the last compilation.
  38969. * @returns the error string.
  38970. */
  38971. getCompilationError(): string;
  38972. /**
  38973. * Gets a boolean indicating that all fallbacks were used during compilation
  38974. * @returns true if all fallbacks were used
  38975. */
  38976. allFallbacksProcessed(): boolean;
  38977. /**
  38978. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  38979. * @param func The callback to be used.
  38980. */
  38981. executeWhenCompiled(func: (effect: Effect) => void): void;
  38982. private _checkIsReady;
  38983. private _loadShader;
  38984. /**
  38985. * Gets the vertex shader source code of this effect
  38986. */
  38987. get vertexSourceCode(): string;
  38988. /**
  38989. * Gets the fragment shader source code of this effect
  38990. */
  38991. get fragmentSourceCode(): string;
  38992. /**
  38993. * Gets the vertex shader source code before it has been processed by the preprocessor
  38994. */
  38995. get rawVertexSourceCode(): string;
  38996. /**
  38997. * Gets the fragment shader source code before it has been processed by the preprocessor
  38998. */
  38999. get rawFragmentSourceCode(): string;
  39000. /**
  39001. * Recompiles the webGL program
  39002. * @param vertexSourceCode The source code for the vertex shader.
  39003. * @param fragmentSourceCode The source code for the fragment shader.
  39004. * @param onCompiled Callback called when completed.
  39005. * @param onError Callback called on error.
  39006. * @hidden
  39007. */
  39008. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39009. /**
  39010. * Prepares the effect
  39011. * @hidden
  39012. */
  39013. _prepareEffect(): void;
  39014. private _getShaderCodeAndErrorLine;
  39015. private _processCompilationErrors;
  39016. /**
  39017. * Checks if the effect is supported. (Must be called after compilation)
  39018. */
  39019. get isSupported(): boolean;
  39020. /**
  39021. * Binds a texture to the engine to be used as output of the shader.
  39022. * @param channel Name of the output variable.
  39023. * @param texture Texture to bind.
  39024. * @hidden
  39025. */
  39026. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39027. /**
  39028. * Sets a texture on the engine to be used in the shader.
  39029. * @param channel Name of the sampler variable.
  39030. * @param texture Texture to set.
  39031. */
  39032. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  39033. /**
  39034. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39035. * @param channel Name of the sampler variable.
  39036. * @param texture Texture to set.
  39037. */
  39038. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39039. /**
  39040. * Sets an array of textures on the engine to be used in the shader.
  39041. * @param channel Name of the variable.
  39042. * @param textures Textures to set.
  39043. */
  39044. setTextureArray(channel: string, textures: ThinTexture[]): void;
  39045. /**
  39046. * Sets a texture to be the input of the specified post process. (To use the output, pass in the next post process in the pipeline)
  39047. * @param channel Name of the sampler variable.
  39048. * @param postProcess Post process to get the input texture from.
  39049. */
  39050. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39051. /**
  39052. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39053. * Sets the input texture of the passed in post process to be input of this effect. (To use the output of the passed in post process use setTextureFromPostProcessOutput)
  39054. * @param channel Name of the sampler variable.
  39055. * @param postProcess Post process to get the output texture from.
  39056. */
  39057. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39058. /**
  39059. * Binds a buffer to a uniform.
  39060. * @param buffer Buffer to bind.
  39061. * @param name Name of the uniform variable to bind to.
  39062. */
  39063. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39064. /**
  39065. * Binds block to a uniform.
  39066. * @param blockName Name of the block to bind.
  39067. * @param index Index to bind.
  39068. */
  39069. bindUniformBlock(blockName: string, index: number): void;
  39070. /**
  39071. * Sets an interger value on a uniform variable.
  39072. * @param uniformName Name of the variable.
  39073. * @param value Value to be set.
  39074. * @returns this effect.
  39075. */
  39076. setInt(uniformName: string, value: number): Effect;
  39077. /**
  39078. * Sets an int2 value on a uniform variable.
  39079. * @param uniformName Name of the variable.
  39080. * @param x First int in int2.
  39081. * @param y Second int in int2.
  39082. * @returns this effect.
  39083. */
  39084. setInt2(uniformName: string, x: number, y: number): Effect;
  39085. /**
  39086. * Sets an int3 value on a uniform variable.
  39087. * @param uniformName Name of the variable.
  39088. * @param x First int in int3.
  39089. * @param y Second int in int3.
  39090. * @param z Third int in int3.
  39091. * @returns this effect.
  39092. */
  39093. setInt3(uniformName: string, x: number, y: number, z: number): Effect;
  39094. /**
  39095. * Sets an int4 value on a uniform variable.
  39096. * @param uniformName Name of the variable.
  39097. * @param x First int in int4.
  39098. * @param y Second int in int4.
  39099. * @param z Third int in int4.
  39100. * @param w Fourth int in int4.
  39101. * @returns this effect.
  39102. */
  39103. setInt4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39104. /**
  39105. * Sets an int array on a uniform variable.
  39106. * @param uniformName Name of the variable.
  39107. * @param array array to be set.
  39108. * @returns this effect.
  39109. */
  39110. setIntArray(uniformName: string, array: Int32Array): Effect;
  39111. /**
  39112. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  39113. * @param uniformName Name of the variable.
  39114. * @param array array to be set.
  39115. * @returns this effect.
  39116. */
  39117. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39118. /**
  39119. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  39120. * @param uniformName Name of the variable.
  39121. * @param array array to be set.
  39122. * @returns this effect.
  39123. */
  39124. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39125. /**
  39126. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  39127. * @param uniformName Name of the variable.
  39128. * @param array array to be set.
  39129. * @returns this effect.
  39130. */
  39131. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39132. /**
  39133. * Sets an float array on a uniform variable.
  39134. * @param uniformName Name of the variable.
  39135. * @param array array to be set.
  39136. * @returns this effect.
  39137. */
  39138. setFloatArray(uniformName: string, array: FloatArray): Effect;
  39139. /**
  39140. * Sets an float array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  39141. * @param uniformName Name of the variable.
  39142. * @param array array to be set.
  39143. * @returns this effect.
  39144. */
  39145. setFloatArray2(uniformName: string, array: FloatArray): Effect;
  39146. /**
  39147. * Sets an float array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  39148. * @param uniformName Name of the variable.
  39149. * @param array array to be set.
  39150. * @returns this effect.
  39151. */
  39152. setFloatArray3(uniformName: string, array: FloatArray): Effect;
  39153. /**
  39154. * Sets an float array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  39155. * @param uniformName Name of the variable.
  39156. * @param array array to be set.
  39157. * @returns this effect.
  39158. */
  39159. setFloatArray4(uniformName: string, array: FloatArray): Effect;
  39160. /**
  39161. * Sets an array on a uniform variable.
  39162. * @param uniformName Name of the variable.
  39163. * @param array array to be set.
  39164. * @returns this effect.
  39165. */
  39166. setArray(uniformName: string, array: number[]): Effect;
  39167. /**
  39168. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  39169. * @param uniformName Name of the variable.
  39170. * @param array array to be set.
  39171. * @returns this effect.
  39172. */
  39173. setArray2(uniformName: string, array: number[]): Effect;
  39174. /**
  39175. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  39176. * @param uniformName Name of the variable.
  39177. * @param array array to be set.
  39178. * @returns this effect.
  39179. */
  39180. setArray3(uniformName: string, array: number[]): Effect;
  39181. /**
  39182. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  39183. * @param uniformName Name of the variable.
  39184. * @param array array to be set.
  39185. * @returns this effect.
  39186. */
  39187. setArray4(uniformName: string, array: number[]): Effect;
  39188. /**
  39189. * Sets matrices on a uniform variable.
  39190. * @param uniformName Name of the variable.
  39191. * @param matrices matrices to be set.
  39192. * @returns this effect.
  39193. */
  39194. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39195. /**
  39196. * Sets matrix on a uniform variable.
  39197. * @param uniformName Name of the variable.
  39198. * @param matrix matrix to be set.
  39199. * @returns this effect.
  39200. */
  39201. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39202. /**
  39203. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  39204. * @param uniformName Name of the variable.
  39205. * @param matrix matrix to be set.
  39206. * @returns this effect.
  39207. */
  39208. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39209. /**
  39210. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39211. * @param uniformName Name of the variable.
  39212. * @param matrix matrix to be set.
  39213. * @returns this effect.
  39214. */
  39215. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39216. /**
  39217. * Sets a float on a uniform variable.
  39218. * @param uniformName Name of the variable.
  39219. * @param value value to be set.
  39220. * @returns this effect.
  39221. */
  39222. setFloat(uniformName: string, value: number): Effect;
  39223. /**
  39224. * Sets a boolean on a uniform variable.
  39225. * @param uniformName Name of the variable.
  39226. * @param bool value to be set.
  39227. * @returns this effect.
  39228. */
  39229. setBool(uniformName: string, bool: boolean): Effect;
  39230. /**
  39231. * Sets a Vector2 on a uniform variable.
  39232. * @param uniformName Name of the variable.
  39233. * @param vector2 vector2 to be set.
  39234. * @returns this effect.
  39235. */
  39236. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39237. /**
  39238. * Sets a float2 on a uniform variable.
  39239. * @param uniformName Name of the variable.
  39240. * @param x First float in float2.
  39241. * @param y Second float in float2.
  39242. * @returns this effect.
  39243. */
  39244. setFloat2(uniformName: string, x: number, y: number): Effect;
  39245. /**
  39246. * Sets a Vector3 on a uniform variable.
  39247. * @param uniformName Name of the variable.
  39248. * @param vector3 Value to be set.
  39249. * @returns this effect.
  39250. */
  39251. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39252. /**
  39253. * Sets a float3 on a uniform variable.
  39254. * @param uniformName Name of the variable.
  39255. * @param x First float in float3.
  39256. * @param y Second float in float3.
  39257. * @param z Third float in float3.
  39258. * @returns this effect.
  39259. */
  39260. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39261. /**
  39262. * Sets a Vector4 on a uniform variable.
  39263. * @param uniformName Name of the variable.
  39264. * @param vector4 Value to be set.
  39265. * @returns this effect.
  39266. */
  39267. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39268. /**
  39269. * Sets a float4 on a uniform variable.
  39270. * @param uniformName Name of the variable.
  39271. * @param x First float in float4.
  39272. * @param y Second float in float4.
  39273. * @param z Third float in float4.
  39274. * @param w Fourth float in float4.
  39275. * @returns this effect.
  39276. */
  39277. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39278. /**
  39279. * Sets a Color3 on a uniform variable.
  39280. * @param uniformName Name of the variable.
  39281. * @param color3 Value to be set.
  39282. * @returns this effect.
  39283. */
  39284. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39285. /**
  39286. * Sets a Color4 on a uniform variable.
  39287. * @param uniformName Name of the variable.
  39288. * @param color3 Value to be set.
  39289. * @param alpha Alpha value to be set.
  39290. * @returns this effect.
  39291. */
  39292. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39293. /**
  39294. * Sets a Color4 on a uniform variable
  39295. * @param uniformName defines the name of the variable
  39296. * @param color4 defines the value to be set
  39297. * @returns this effect.
  39298. */
  39299. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39300. /**
  39301. * Release all associated resources.
  39302. **/
  39303. dispose(): void;
  39304. /**
  39305. * This function will add a new shader to the shader store
  39306. * @param name the name of the shader
  39307. * @param pixelShader optional pixel shader content
  39308. * @param vertexShader optional vertex shader content
  39309. */
  39310. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39311. /**
  39312. * Store of each shader (The can be looked up using effect.key)
  39313. */
  39314. static ShadersStore: {
  39315. [key: string]: string;
  39316. };
  39317. /**
  39318. * Store of each included file for a shader (The can be looked up using effect.key)
  39319. */
  39320. static IncludesShadersStore: {
  39321. [key: string]: string;
  39322. };
  39323. /**
  39324. * Resets the cache of effects.
  39325. */
  39326. static ResetCache(): void;
  39327. }
  39328. }
  39329. declare module BABYLON {
  39330. /**
  39331. * Interface used to describe the capabilities of the engine relatively to the current browser
  39332. */
  39333. export interface EngineCapabilities {
  39334. /** Maximum textures units per fragment shader */
  39335. maxTexturesImageUnits: number;
  39336. /** Maximum texture units per vertex shader */
  39337. maxVertexTextureImageUnits: number;
  39338. /** Maximum textures units in the entire pipeline */
  39339. maxCombinedTexturesImageUnits: number;
  39340. /** Maximum texture size */
  39341. maxTextureSize: number;
  39342. /** Maximum texture samples */
  39343. maxSamples?: number;
  39344. /** Maximum cube texture size */
  39345. maxCubemapTextureSize: number;
  39346. /** Maximum render texture size */
  39347. maxRenderTextureSize: number;
  39348. /** Maximum number of vertex attributes */
  39349. maxVertexAttribs: number;
  39350. /** Maximum number of varyings */
  39351. maxVaryingVectors: number;
  39352. /** Maximum number of uniforms per vertex shader */
  39353. maxVertexUniformVectors: number;
  39354. /** Maximum number of uniforms per fragment shader */
  39355. maxFragmentUniformVectors: number;
  39356. /** Defines if standard derivates (dx/dy) are supported */
  39357. standardDerivatives: boolean;
  39358. /** Defines if s3tc texture compression is supported */
  39359. s3tc?: WEBGL_compressed_texture_s3tc;
  39360. /** Defines if pvrtc texture compression is supported */
  39361. pvrtc: any;
  39362. /** Defines if etc1 texture compression is supported */
  39363. etc1: any;
  39364. /** Defines if etc2 texture compression is supported */
  39365. etc2: any;
  39366. /** Defines if astc texture compression is supported */
  39367. astc: any;
  39368. /** Defines if bptc texture compression is supported */
  39369. bptc: any;
  39370. /** Defines if float textures are supported */
  39371. textureFloat: boolean;
  39372. /** Defines if vertex array objects are supported */
  39373. vertexArrayObject: boolean;
  39374. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  39375. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  39376. /** Gets the maximum level of anisotropy supported */
  39377. maxAnisotropy: number;
  39378. /** Defines if instancing is supported */
  39379. instancedArrays: boolean;
  39380. /** Defines if 32 bits indices are supported */
  39381. uintIndices: boolean;
  39382. /** Defines if high precision shaders are supported */
  39383. highPrecisionShaderSupported: boolean;
  39384. /** Defines if depth reading in the fragment shader is supported */
  39385. fragmentDepthSupported: boolean;
  39386. /** Defines if float texture linear filtering is supported*/
  39387. textureFloatLinearFiltering: boolean;
  39388. /** Defines if rendering to float textures is supported */
  39389. textureFloatRender: boolean;
  39390. /** Defines if half float textures are supported*/
  39391. textureHalfFloat: boolean;
  39392. /** Defines if half float texture linear filtering is supported*/
  39393. textureHalfFloatLinearFiltering: boolean;
  39394. /** Defines if rendering to half float textures is supported */
  39395. textureHalfFloatRender: boolean;
  39396. /** Defines if textureLOD shader command is supported */
  39397. textureLOD: boolean;
  39398. /** Defines if draw buffers extension is supported */
  39399. drawBuffersExtension: boolean;
  39400. /** Defines if depth textures are supported */
  39401. depthTextureExtension: boolean;
  39402. /** Defines if float color buffer are supported */
  39403. colorBufferFloat: boolean;
  39404. /** Gets disjoint timer query extension (null if not supported) */
  39405. timerQuery?: EXT_disjoint_timer_query;
  39406. /** Defines if timestamp can be used with timer query */
  39407. canUseTimestampForTimerQuery: boolean;
  39408. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  39409. multiview?: any;
  39410. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  39411. oculusMultiview?: any;
  39412. /** Function used to let the system compiles shaders in background */
  39413. parallelShaderCompile?: {
  39414. COMPLETION_STATUS_KHR: number;
  39415. };
  39416. /** Max number of texture samples for MSAA */
  39417. maxMSAASamples: number;
  39418. /** Defines if the blend min max extension is supported */
  39419. blendMinMax: boolean;
  39420. /** In some iOS + WebGL1, gl_InstanceID (and gl_InstanceIDEXT) is undefined even if instancedArrays is true. So don't use gl_InstanceID in those cases */
  39421. canUseGLInstanceID: boolean;
  39422. }
  39423. }
  39424. declare module BABYLON {
  39425. /**
  39426. * @hidden
  39427. **/
  39428. export class DepthCullingState {
  39429. private _isDepthTestDirty;
  39430. private _isDepthMaskDirty;
  39431. private _isDepthFuncDirty;
  39432. private _isCullFaceDirty;
  39433. private _isCullDirty;
  39434. private _isZOffsetDirty;
  39435. private _isFrontFaceDirty;
  39436. private _depthTest;
  39437. private _depthMask;
  39438. private _depthFunc;
  39439. private _cull;
  39440. private _cullFace;
  39441. private _zOffset;
  39442. private _frontFace;
  39443. /**
  39444. * Initializes the state.
  39445. */
  39446. constructor();
  39447. get isDirty(): boolean;
  39448. get zOffset(): number;
  39449. set zOffset(value: number);
  39450. get cullFace(): Nullable<number>;
  39451. set cullFace(value: Nullable<number>);
  39452. get cull(): Nullable<boolean>;
  39453. set cull(value: Nullable<boolean>);
  39454. get depthFunc(): Nullable<number>;
  39455. set depthFunc(value: Nullable<number>);
  39456. get depthMask(): boolean;
  39457. set depthMask(value: boolean);
  39458. get depthTest(): boolean;
  39459. set depthTest(value: boolean);
  39460. get frontFace(): Nullable<number>;
  39461. set frontFace(value: Nullable<number>);
  39462. reset(): void;
  39463. apply(gl: WebGLRenderingContext): void;
  39464. }
  39465. }
  39466. declare module BABYLON {
  39467. /**
  39468. * @hidden
  39469. **/
  39470. export class StencilState {
  39471. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  39472. static readonly ALWAYS: number;
  39473. /** Passed to stencilOperation to specify that stencil value must be kept */
  39474. static readonly KEEP: number;
  39475. /** Passed to stencilOperation to specify that stencil value must be replaced */
  39476. static readonly REPLACE: number;
  39477. private _isStencilTestDirty;
  39478. private _isStencilMaskDirty;
  39479. private _isStencilFuncDirty;
  39480. private _isStencilOpDirty;
  39481. private _stencilTest;
  39482. private _stencilMask;
  39483. private _stencilFunc;
  39484. private _stencilFuncRef;
  39485. private _stencilFuncMask;
  39486. private _stencilOpStencilFail;
  39487. private _stencilOpDepthFail;
  39488. private _stencilOpStencilDepthPass;
  39489. get isDirty(): boolean;
  39490. get stencilFunc(): number;
  39491. set stencilFunc(value: number);
  39492. get stencilFuncRef(): number;
  39493. set stencilFuncRef(value: number);
  39494. get stencilFuncMask(): number;
  39495. set stencilFuncMask(value: number);
  39496. get stencilOpStencilFail(): number;
  39497. set stencilOpStencilFail(value: number);
  39498. get stencilOpDepthFail(): number;
  39499. set stencilOpDepthFail(value: number);
  39500. get stencilOpStencilDepthPass(): number;
  39501. set stencilOpStencilDepthPass(value: number);
  39502. get stencilMask(): number;
  39503. set stencilMask(value: number);
  39504. get stencilTest(): boolean;
  39505. set stencilTest(value: boolean);
  39506. constructor();
  39507. reset(): void;
  39508. apply(gl: WebGLRenderingContext): void;
  39509. }
  39510. }
  39511. declare module BABYLON {
  39512. /**
  39513. * @hidden
  39514. **/
  39515. export class AlphaState {
  39516. _blendFunctionParameters: Nullable<number>[];
  39517. _blendEquationParameters: Nullable<number>[];
  39518. _blendConstants: Nullable<number>[];
  39519. _isBlendConstantsDirty: boolean;
  39520. private _alphaBlend;
  39521. private _isAlphaBlendDirty;
  39522. private _isBlendFunctionParametersDirty;
  39523. private _isBlendEquationParametersDirty;
  39524. /**
  39525. * Initializes the state.
  39526. */
  39527. constructor();
  39528. get isDirty(): boolean;
  39529. get alphaBlend(): boolean;
  39530. set alphaBlend(value: boolean);
  39531. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  39532. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  39533. setAlphaEquationParameters(rgb: number, alpha: number): void;
  39534. reset(): void;
  39535. apply(gl: WebGLRenderingContext): void;
  39536. }
  39537. }
  39538. declare module BABYLON {
  39539. /** @hidden */
  39540. export class WebGLShaderProcessor implements IShaderProcessor {
  39541. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  39542. }
  39543. }
  39544. declare module BABYLON {
  39545. /** @hidden */
  39546. export class WebGL2ShaderProcessor implements IShaderProcessor {
  39547. attributeProcessor(attribute: string): string;
  39548. varyingProcessor(varying: string, isFragment: boolean): string;
  39549. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  39550. }
  39551. }
  39552. declare module BABYLON {
  39553. /**
  39554. * Interface for attribute information associated with buffer instanciation
  39555. */
  39556. export interface InstancingAttributeInfo {
  39557. /**
  39558. * Name of the GLSL attribute
  39559. * if attribute index is not specified, this is used to retrieve the index from the effect
  39560. */
  39561. attributeName: string;
  39562. /**
  39563. * Index/offset of the attribute in the vertex shader
  39564. * if not specified, this will be computes from the name.
  39565. */
  39566. index?: number;
  39567. /**
  39568. * size of the attribute, 1, 2, 3 or 4
  39569. */
  39570. attributeSize: number;
  39571. /**
  39572. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  39573. */
  39574. offset: number;
  39575. /**
  39576. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  39577. * default to 1
  39578. */
  39579. divisor?: number;
  39580. /**
  39581. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  39582. * default is FLOAT
  39583. */
  39584. attributeType?: number;
  39585. /**
  39586. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  39587. */
  39588. normalized?: boolean;
  39589. }
  39590. }
  39591. declare module BABYLON {
  39592. /** @hidden */
  39593. export interface EngineFeatures {
  39594. /** Force using Bitmap when Bitmap or HTMLImageElement can be used */
  39595. forceBitmapOverHTMLImageElement: boolean;
  39596. /** Indicates that the engine support rendering to as well as copying to lod float textures */
  39597. supportRenderAndCopyToLodForFloatTextures: boolean;
  39598. /** Indicates that the engine support handling depth/stencil textures */
  39599. supportDepthStencilTexture: boolean;
  39600. /** Indicates that the engine support shadow samplers */
  39601. supportShadowSamplers: boolean;
  39602. /** Indicates to check the matrix bytes per bytes to know if it has changed or not. If false, only the updateFlag of the matrix is checked */
  39603. uniformBufferHardCheckMatrix: boolean;
  39604. /** Indicates that prefiltered mipmaps can be generated in some processes (for eg when loading an HDR cube texture) */
  39605. allowTexturePrefiltering: boolean;
  39606. /** Indicates to track the usage of ubos and to create new ones as necessary during a frame duration */
  39607. trackUbosInFrame: boolean;
  39608. /** Indicates that the Cascaded Shadow Map technic is supported */
  39609. supportCSM: boolean;
  39610. /** Indicates that the textures transcoded by the basis transcoder must have power of 2 width and height */
  39611. basisNeedsPOT: boolean;
  39612. /** Indicates that the engine supports 3D textures */
  39613. support3DTextures: boolean;
  39614. /** Indicates that constants need a type suffix in shaders (used by realtime filtering...) */
  39615. needTypeSuffixInShaderConstants: boolean;
  39616. /** Indicates that MSAA is supported */
  39617. supportMSAA: boolean;
  39618. /** Indicates that SSAO2 is supported */
  39619. supportSSAO2: boolean;
  39620. /** Indicates that some additional texture formats are supported (like TEXTUREFORMAT_R for eg) */
  39621. supportExtendedTextureFormats: boolean;
  39622. /** Indicates that the switch/case construct is supported in shaders */
  39623. supportSwitchCaseInShader: boolean;
  39624. /** @hidden */
  39625. _collectUbosUpdatedInFrame: boolean;
  39626. }
  39627. }
  39628. declare module BABYLON {
  39629. /** @hidden */
  39630. export class WebGLHardwareTexture implements HardwareTextureWrapper {
  39631. private _webGLTexture;
  39632. private _context;
  39633. get underlyingResource(): Nullable<WebGLTexture>;
  39634. constructor(existingTexture: WebGLTexture | null | undefined, context: WebGLRenderingContext);
  39635. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  39636. set(hardwareTexture: WebGLTexture): void;
  39637. reset(): void;
  39638. release(): void;
  39639. }
  39640. }
  39641. declare module BABYLON {
  39642. interface ThinEngine {
  39643. /**
  39644. * Update a video texture
  39645. * @param texture defines the texture to update
  39646. * @param video defines the video element to use
  39647. * @param invertY defines if data must be stored with Y axis inverted
  39648. */
  39649. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  39650. }
  39651. }
  39652. declare module BABYLON {
  39653. interface ThinEngine {
  39654. /**
  39655. * Creates a dynamic texture
  39656. * @param width defines the width of the texture
  39657. * @param height defines the height of the texture
  39658. * @param generateMipMaps defines if the engine should generate the mip levels
  39659. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  39660. * @returns the dynamic texture inside an InternalTexture
  39661. */
  39662. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  39663. /**
  39664. * Update the content of a dynamic texture
  39665. * @param texture defines the texture to update
  39666. * @param source defines the source containing the data
  39667. * @param invertY defines if data must be stored with Y axis inverted
  39668. * @param premulAlpha defines if alpha is stored as premultiplied
  39669. * @param format defines the format of the data
  39670. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  39671. */
  39672. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  39673. }
  39674. }
  39675. declare module BABYLON {
  39676. /**
  39677. * Settings for finer control over video usage
  39678. */
  39679. export interface VideoTextureSettings {
  39680. /**
  39681. * Applies `autoplay` to video, if specified
  39682. */
  39683. autoPlay?: boolean;
  39684. /**
  39685. * Applies `muted` to video, if specified
  39686. */
  39687. muted?: boolean;
  39688. /**
  39689. * Applies `loop` to video, if specified
  39690. */
  39691. loop?: boolean;
  39692. /**
  39693. * Automatically updates internal texture from video at every frame in the render loop
  39694. */
  39695. autoUpdateTexture: boolean;
  39696. /**
  39697. * Image src displayed during the video loading or until the user interacts with the video.
  39698. */
  39699. poster?: string;
  39700. }
  39701. /**
  39702. * If you want to display a video in your scene, this is the special texture for that.
  39703. * This special texture works similar to other textures, with the exception of a few parameters.
  39704. * @see https://doc.babylonjs.com/how_to/video_texture
  39705. */
  39706. export class VideoTexture extends Texture {
  39707. /**
  39708. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  39709. */
  39710. readonly autoUpdateTexture: boolean;
  39711. /**
  39712. * The video instance used by the texture internally
  39713. */
  39714. readonly video: HTMLVideoElement;
  39715. private _onUserActionRequestedObservable;
  39716. /**
  39717. * Event triggerd when a dom action is required by the user to play the video.
  39718. * This happens due to recent changes in browser policies preventing video to auto start.
  39719. */
  39720. get onUserActionRequestedObservable(): Observable<Texture>;
  39721. private _generateMipMaps;
  39722. private _stillImageCaptured;
  39723. private _displayingPosterTexture;
  39724. private _settings;
  39725. private _createInternalTextureOnEvent;
  39726. private _frameId;
  39727. private _currentSrc;
  39728. /**
  39729. * Creates a video texture.
  39730. * If you want to display a video in your scene, this is the special texture for that.
  39731. * This special texture works similar to other textures, with the exception of a few parameters.
  39732. * @see https://doc.babylonjs.com/how_to/video_texture
  39733. * @param name optional name, will detect from video source, if not defined
  39734. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  39735. * @param scene is obviously the current scene.
  39736. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  39737. * @param invertY is false by default but can be used to invert video on Y axis
  39738. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  39739. * @param settings allows finer control over video usage
  39740. */
  39741. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  39742. private _getName;
  39743. private _getVideo;
  39744. private _createInternalTexture;
  39745. private reset;
  39746. /**
  39747. * @hidden Internal method to initiate `update`.
  39748. */
  39749. _rebuild(): void;
  39750. /**
  39751. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  39752. */
  39753. update(): void;
  39754. /**
  39755. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  39756. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  39757. */
  39758. updateTexture(isVisible: boolean): void;
  39759. protected _updateInternalTexture: () => void;
  39760. /**
  39761. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  39762. * @param url New url.
  39763. */
  39764. updateURL(url: string): void;
  39765. /**
  39766. * Clones the texture.
  39767. * @returns the cloned texture
  39768. */
  39769. clone(): VideoTexture;
  39770. /**
  39771. * Dispose the texture and release its associated resources.
  39772. */
  39773. dispose(): void;
  39774. /**
  39775. * Creates a video texture straight from a stream.
  39776. * @param scene Define the scene the texture should be created in
  39777. * @param stream Define the stream the texture should be created from
  39778. * @returns The created video texture as a promise
  39779. */
  39780. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  39781. /**
  39782. * Creates a video texture straight from your WebCam video feed.
  39783. * @param scene Define the scene the texture should be created in
  39784. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39785. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39786. * @returns The created video texture as a promise
  39787. */
  39788. static CreateFromWebCamAsync(scene: Scene, constraints: {
  39789. minWidth: number;
  39790. maxWidth: number;
  39791. minHeight: number;
  39792. maxHeight: number;
  39793. deviceId: string;
  39794. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  39795. /**
  39796. * Creates a video texture straight from your WebCam video feed.
  39797. * @param scene Define the scene the texture should be created in
  39798. * @param onReady Define a callback to triggered once the texture will be ready
  39799. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39800. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39801. */
  39802. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  39803. minWidth: number;
  39804. maxWidth: number;
  39805. minHeight: number;
  39806. maxHeight: number;
  39807. deviceId: string;
  39808. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  39809. }
  39810. }
  39811. declare module BABYLON {
  39812. /**
  39813. * Defines the interface used by objects working like Scene
  39814. * @hidden
  39815. */
  39816. export interface ISceneLike {
  39817. _addPendingData(data: any): void;
  39818. _removePendingData(data: any): void;
  39819. offlineProvider: IOfflineProvider;
  39820. }
  39821. /**
  39822. * Information about the current host
  39823. */
  39824. export interface HostInformation {
  39825. /**
  39826. * Defines if the current host is a mobile
  39827. */
  39828. isMobile: boolean;
  39829. }
  39830. /** Interface defining initialization parameters for Engine class */
  39831. export interface EngineOptions extends WebGLContextAttributes {
  39832. /**
  39833. * Defines if the engine should no exceed a specified device ratio
  39834. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  39835. */
  39836. limitDeviceRatio?: number;
  39837. /**
  39838. * Defines if webvr should be enabled automatically
  39839. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39840. */
  39841. autoEnableWebVR?: boolean;
  39842. /**
  39843. * Defines if webgl2 should be turned off even if supported
  39844. * @see https://doc.babylonjs.com/features/webgl2
  39845. */
  39846. disableWebGL2Support?: boolean;
  39847. /**
  39848. * Defines if webaudio should be initialized as well
  39849. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39850. */
  39851. audioEngine?: boolean;
  39852. /**
  39853. * Defines if animations should run using a deterministic lock step
  39854. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39855. */
  39856. deterministicLockstep?: boolean;
  39857. /** Defines the maximum steps to use with deterministic lock step mode */
  39858. lockstepMaxSteps?: number;
  39859. /** Defines the seconds between each deterministic lock step */
  39860. timeStep?: number;
  39861. /**
  39862. * Defines that engine should ignore context lost events
  39863. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  39864. */
  39865. doNotHandleContextLost?: boolean;
  39866. /**
  39867. * Defines that engine should ignore modifying touch action attribute and style
  39868. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  39869. */
  39870. doNotHandleTouchAction?: boolean;
  39871. /**
  39872. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  39873. */
  39874. useHighPrecisionFloats?: boolean;
  39875. /**
  39876. * Make the canvas XR Compatible for XR sessions
  39877. */
  39878. xrCompatible?: boolean;
  39879. /**
  39880. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  39881. */
  39882. useHighPrecisionMatrix?: boolean;
  39883. /**
  39884. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  39885. */
  39886. failIfMajorPerformanceCaveat?: boolean;
  39887. }
  39888. /**
  39889. * The base engine class (root of all engines)
  39890. */
  39891. export class ThinEngine {
  39892. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  39893. static ExceptionList: ({
  39894. key: string;
  39895. capture: string;
  39896. captureConstraint: number;
  39897. targets: string[];
  39898. } | {
  39899. key: string;
  39900. capture: null;
  39901. captureConstraint: null;
  39902. targets: string[];
  39903. })[];
  39904. /** @hidden */
  39905. static _TextureLoaders: IInternalTextureLoader[];
  39906. /**
  39907. * Returns the current npm package of the sdk
  39908. */
  39909. static get NpmPackage(): string;
  39910. /**
  39911. * Returns the current version of the framework
  39912. */
  39913. static get Version(): string;
  39914. /**
  39915. * Returns a string describing the current engine
  39916. */
  39917. get description(): string;
  39918. /**
  39919. * Returns the name of the engine
  39920. */
  39921. get name(): string;
  39922. /**
  39923. * Returns the version of the engine
  39924. */
  39925. get version(): number;
  39926. /**
  39927. * Gets or sets the epsilon value used by collision engine
  39928. */
  39929. static CollisionsEpsilon: number;
  39930. /**
  39931. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39932. */
  39933. static get ShadersRepository(): string;
  39934. static set ShadersRepository(value: string);
  39935. /** @hidden */
  39936. _shaderProcessor: Nullable<IShaderProcessor>;
  39937. /**
  39938. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  39939. */
  39940. forcePOTTextures: boolean;
  39941. /**
  39942. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  39943. */
  39944. isFullscreen: boolean;
  39945. /**
  39946. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  39947. */
  39948. cullBackFaces: boolean;
  39949. /**
  39950. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  39951. */
  39952. renderEvenInBackground: boolean;
  39953. /**
  39954. * Gets or sets a boolean indicating that cache can be kept between frames
  39955. */
  39956. preventCacheWipeBetweenFrames: boolean;
  39957. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  39958. validateShaderPrograms: boolean;
  39959. /**
  39960. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  39961. * This can provide greater z depth for distant objects.
  39962. */
  39963. useReverseDepthBuffer: boolean;
  39964. /**
  39965. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  39966. */
  39967. disableUniformBuffers: boolean;
  39968. private _frameId;
  39969. /**
  39970. * Gets the current frame id
  39971. */
  39972. get frameId(): number;
  39973. /** @hidden */
  39974. _uniformBuffers: UniformBuffer[];
  39975. /**
  39976. * Gets a boolean indicating that the engine supports uniform buffers
  39977. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  39978. */
  39979. get supportsUniformBuffers(): boolean;
  39980. /** @hidden */
  39981. _gl: WebGLRenderingContext;
  39982. /** @hidden */
  39983. _webGLVersion: number;
  39984. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  39985. protected _windowIsBackground: boolean;
  39986. protected _creationOptions: EngineOptions;
  39987. protected _highPrecisionShadersAllowed: boolean;
  39988. /** @hidden */
  39989. get _shouldUseHighPrecisionShader(): boolean;
  39990. /**
  39991. * Gets a boolean indicating that only power of 2 textures are supported
  39992. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  39993. */
  39994. get needPOTTextures(): boolean;
  39995. /** @hidden */
  39996. _badOS: boolean;
  39997. /** @hidden */
  39998. _badDesktopOS: boolean;
  39999. protected _hardwareScalingLevel: number;
  40000. /** @hidden */
  40001. _caps: EngineCapabilities;
  40002. /** @hidden */
  40003. _features: EngineFeatures;
  40004. protected _isStencilEnable: boolean;
  40005. private _glVersion;
  40006. private _glRenderer;
  40007. private _glVendor;
  40008. /** @hidden */
  40009. _videoTextureSupported: boolean;
  40010. protected _renderingQueueLaunched: boolean;
  40011. protected _activeRenderLoops: (() => void)[];
  40012. /**
  40013. * Observable signaled when a context lost event is raised
  40014. */
  40015. onContextLostObservable: Observable<ThinEngine>;
  40016. /**
  40017. * Observable signaled when a context restored event is raised
  40018. */
  40019. onContextRestoredObservable: Observable<ThinEngine>;
  40020. private _onContextLost;
  40021. private _onContextRestored;
  40022. protected _contextWasLost: boolean;
  40023. /** @hidden */
  40024. _doNotHandleContextLost: boolean;
  40025. /**
  40026. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40027. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40028. */
  40029. get doNotHandleContextLost(): boolean;
  40030. set doNotHandleContextLost(value: boolean);
  40031. /**
  40032. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40033. */
  40034. disableVertexArrayObjects: boolean;
  40035. /** @hidden */
  40036. protected _colorWrite: boolean;
  40037. /** @hidden */
  40038. protected _colorWriteChanged: boolean;
  40039. /** @hidden */
  40040. protected _depthCullingState: DepthCullingState;
  40041. /** @hidden */
  40042. protected _stencilState: StencilState;
  40043. /** @hidden */
  40044. _alphaState: AlphaState;
  40045. /** @hidden */
  40046. _alphaMode: number;
  40047. /** @hidden */
  40048. _alphaEquation: number;
  40049. /** @hidden */
  40050. _internalTexturesCache: InternalTexture[];
  40051. /** @hidden */
  40052. protected _activeChannel: number;
  40053. private _currentTextureChannel;
  40054. /** @hidden */
  40055. protected _boundTexturesCache: {
  40056. [key: string]: Nullable<InternalTexture>;
  40057. };
  40058. /** @hidden */
  40059. protected _currentEffect: Nullable<Effect>;
  40060. /** @hidden */
  40061. protected _currentProgram: Nullable<WebGLProgram>;
  40062. protected _compiledEffects: {
  40063. [key: string]: Effect;
  40064. };
  40065. private _vertexAttribArraysEnabled;
  40066. /** @hidden */
  40067. protected _cachedViewport: Nullable<IViewportLike>;
  40068. private _cachedVertexArrayObject;
  40069. /** @hidden */
  40070. protected _cachedVertexBuffers: any;
  40071. /** @hidden */
  40072. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40073. /** @hidden */
  40074. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40075. /** @hidden */
  40076. _currentRenderTarget: Nullable<InternalTexture>;
  40077. private _uintIndicesCurrentlySet;
  40078. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40079. /** @hidden */
  40080. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40081. /** @hidden */
  40082. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40083. private _currentBufferPointers;
  40084. private _currentInstanceLocations;
  40085. private _currentInstanceBuffers;
  40086. private _textureUnits;
  40087. /** @hidden */
  40088. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40089. /** @hidden */
  40090. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40091. /** @hidden */
  40092. _boundRenderFunction: any;
  40093. private _vaoRecordInProgress;
  40094. private _mustWipeVertexAttributes;
  40095. private _emptyTexture;
  40096. private _emptyCubeTexture;
  40097. private _emptyTexture3D;
  40098. private _emptyTexture2DArray;
  40099. /** @hidden */
  40100. _frameHandler: number;
  40101. private _nextFreeTextureSlots;
  40102. private _maxSimultaneousTextures;
  40103. private _activeRequests;
  40104. /** @hidden */
  40105. _transformTextureUrl: Nullable<(url: string) => string>;
  40106. /**
  40107. * Gets information about the current host
  40108. */
  40109. hostInformation: HostInformation;
  40110. protected get _supportsHardwareTextureRescaling(): boolean;
  40111. private _framebufferDimensionsObject;
  40112. /**
  40113. * sets the object from which width and height will be taken from when getting render width and height
  40114. * Will fallback to the gl object
  40115. * @param dimensions the framebuffer width and height that will be used.
  40116. */
  40117. set framebufferDimensionsObject(dimensions: Nullable<{
  40118. framebufferWidth: number;
  40119. framebufferHeight: number;
  40120. }>);
  40121. /**
  40122. * Gets the current viewport
  40123. */
  40124. get currentViewport(): Nullable<IViewportLike>;
  40125. /**
  40126. * Gets the default empty texture
  40127. */
  40128. get emptyTexture(): InternalTexture;
  40129. /**
  40130. * Gets the default empty 3D texture
  40131. */
  40132. get emptyTexture3D(): InternalTexture;
  40133. /**
  40134. * Gets the default empty 2D array texture
  40135. */
  40136. get emptyTexture2DArray(): InternalTexture;
  40137. /**
  40138. * Gets the default empty cube texture
  40139. */
  40140. get emptyCubeTexture(): InternalTexture;
  40141. /**
  40142. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40143. */
  40144. premultipliedAlpha: boolean;
  40145. /**
  40146. * Observable event triggered before each texture is initialized
  40147. */
  40148. onBeforeTextureInitObservable: Observable<Texture>;
  40149. /** @hidden */
  40150. protected _isWebGPU: boolean;
  40151. /**
  40152. * Gets a boolean indicating if the engine runs in WebGPU or not.
  40153. */
  40154. get isWebGPU(): boolean;
  40155. /** @hidden */
  40156. protected _shaderPlatformName: string;
  40157. /**
  40158. * Gets the shader platfrom name used by the effects.
  40159. */
  40160. get shaderPlatformName(): string;
  40161. /**
  40162. * Creates a new engine
  40163. * @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
  40164. * @param antialias defines enable antialiasing (default: false)
  40165. * @param options defines further options to be sent to the getContext() function
  40166. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40167. */
  40168. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40169. /**
  40170. * @hidden
  40171. */
  40172. _debugPushGroup(groupName: string, targetObject?: number): void;
  40173. /**
  40174. * @hidden
  40175. */
  40176. _debugPopGroup(targetObject?: number): void;
  40177. /**
  40178. * @hidden
  40179. */
  40180. _debugInsertMarker(text: string, targetObject?: number): void;
  40181. /**
  40182. * Shared initialization across engines types.
  40183. * @param canvas The canvas associated with this instance of the engine.
  40184. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  40185. * @param audioEngine Defines if an audio engine should be created by default
  40186. */
  40187. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  40188. /**
  40189. * Gets a shader processor implementation fitting with the current engine type.
  40190. * @returns The shader processor implementation.
  40191. */
  40192. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  40193. /** @hidden */
  40194. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  40195. private _rebuildInternalTextures;
  40196. private _rebuildEffects;
  40197. /**
  40198. * Gets a boolean indicating if all created effects are ready
  40199. * @returns true if all effects are ready
  40200. */
  40201. areAllEffectsReady(): boolean;
  40202. protected _rebuildBuffers(): void;
  40203. protected _initGLContext(): void;
  40204. protected _initFeatures(): void;
  40205. /**
  40206. * Gets version of the current webGL context
  40207. * Keep it for back compat - use version instead
  40208. */
  40209. get webGLVersion(): number;
  40210. /**
  40211. * Gets a string identifying the name of the class
  40212. * @returns "Engine" string
  40213. */
  40214. getClassName(): string;
  40215. /**
  40216. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40217. */
  40218. get isStencilEnable(): boolean;
  40219. /** @hidden */
  40220. _prepareWorkingCanvas(): void;
  40221. /**
  40222. * Reset the texture cache to empty state
  40223. */
  40224. resetTextureCache(): void;
  40225. /**
  40226. * Gets an object containing information about the current webGL context
  40227. * @returns an object containing the vender, the renderer and the version of the current webGL context
  40228. */
  40229. getGlInfo(): {
  40230. vendor: string;
  40231. renderer: string;
  40232. version: string;
  40233. };
  40234. /**
  40235. * Defines the hardware scaling level.
  40236. * By default the hardware scaling level is computed from the window device ratio.
  40237. * 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.
  40238. * @param level defines the level to use
  40239. */
  40240. setHardwareScalingLevel(level: number): void;
  40241. /**
  40242. * Gets the current hardware scaling level.
  40243. * By default the hardware scaling level is computed from the window device ratio.
  40244. * 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.
  40245. * @returns a number indicating the current hardware scaling level
  40246. */
  40247. getHardwareScalingLevel(): number;
  40248. /**
  40249. * Gets the list of loaded textures
  40250. * @returns an array containing all loaded textures
  40251. */
  40252. getLoadedTexturesCache(): InternalTexture[];
  40253. /**
  40254. * Gets the object containing all engine capabilities
  40255. * @returns the EngineCapabilities object
  40256. */
  40257. getCaps(): EngineCapabilities;
  40258. /**
  40259. * stop executing a render loop function and remove it from the execution array
  40260. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40261. */
  40262. stopRenderLoop(renderFunction?: () => void): void;
  40263. /** @hidden */
  40264. _renderLoop(): void;
  40265. /**
  40266. * Gets the HTML canvas attached with the current webGL context
  40267. * @returns a HTML canvas
  40268. */
  40269. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40270. /**
  40271. * Gets host window
  40272. * @returns the host window object
  40273. */
  40274. getHostWindow(): Nullable<Window>;
  40275. /**
  40276. * Gets the current render width
  40277. * @param useScreen defines if screen size must be used (or the current render target if any)
  40278. * @returns a number defining the current render width
  40279. */
  40280. getRenderWidth(useScreen?: boolean): number;
  40281. /**
  40282. * Gets the current render height
  40283. * @param useScreen defines if screen size must be used (or the current render target if any)
  40284. * @returns a number defining the current render height
  40285. */
  40286. getRenderHeight(useScreen?: boolean): number;
  40287. /**
  40288. * Can be used to override the current requestAnimationFrame requester.
  40289. * @hidden
  40290. */
  40291. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40292. /**
  40293. * Register and execute a render loop. The engine can have more than one render function
  40294. * @param renderFunction defines the function to continuously execute
  40295. */
  40296. runRenderLoop(renderFunction: () => void): void;
  40297. /**
  40298. * Clear the current render buffer or the current render target (if any is set up)
  40299. * @param color defines the color to use
  40300. * @param backBuffer defines if the back buffer must be cleared
  40301. * @param depth defines if the depth buffer must be cleared
  40302. * @param stencil defines if the stencil buffer must be cleared
  40303. */
  40304. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40305. protected _viewportCached: {
  40306. x: number;
  40307. y: number;
  40308. z: number;
  40309. w: number;
  40310. };
  40311. /** @hidden */
  40312. _viewport(x: number, y: number, width: number, height: number): void;
  40313. /**
  40314. * Set the WebGL's viewport
  40315. * @param viewport defines the viewport element to be used
  40316. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40317. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40318. */
  40319. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40320. /**
  40321. * Begin a new frame
  40322. */
  40323. beginFrame(): void;
  40324. /**
  40325. * Enf the current frame
  40326. */
  40327. endFrame(): void;
  40328. /**
  40329. * Resize the view according to the canvas' size
  40330. * @param forceSetSize true to force setting the sizes of the underlying canvas
  40331. */
  40332. resize(forceSetSize?: boolean): void;
  40333. /**
  40334. * Force a specific size of the canvas
  40335. * @param width defines the new canvas' width
  40336. * @param height defines the new canvas' height
  40337. * @param forceSetSize true to force setting the sizes of the underlying canvas
  40338. * @returns true if the size was changed
  40339. */
  40340. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  40341. /**
  40342. * Binds the frame buffer to the specified texture.
  40343. * @param texture The texture to render to or null for the default canvas
  40344. * @param faceIndex The face of the texture to render to in case of cube texture
  40345. * @param requiredWidth The width of the target to render to
  40346. * @param requiredHeight The height of the target to render to
  40347. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40348. * @param lodLevel defines the lod level to bind to the frame buffer
  40349. * @param layer defines the 2d array index to bind to frame buffer to
  40350. */
  40351. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40352. /** @hidden */
  40353. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40354. /**
  40355. * Unbind the current render target texture from the webGL context
  40356. * @param texture defines the render target texture to unbind
  40357. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40358. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40359. */
  40360. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40361. /**
  40362. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40363. */
  40364. flushFramebuffer(): void;
  40365. /**
  40366. * Unbind the current render target and bind the default framebuffer
  40367. */
  40368. restoreDefaultFramebuffer(): void;
  40369. /** @hidden */
  40370. protected _resetVertexBufferBinding(): void;
  40371. /**
  40372. * Creates a vertex buffer
  40373. * @param data the data for the vertex buffer
  40374. * @returns the new WebGL static buffer
  40375. */
  40376. createVertexBuffer(data: DataArray): DataBuffer;
  40377. private _createVertexBuffer;
  40378. /**
  40379. * Creates a dynamic vertex buffer
  40380. * @param data the data for the dynamic vertex buffer
  40381. * @returns the new WebGL dynamic buffer
  40382. */
  40383. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40384. protected _resetIndexBufferBinding(): void;
  40385. /**
  40386. * Creates a new index buffer
  40387. * @param indices defines the content of the index buffer
  40388. * @param updatable defines if the index buffer must be updatable
  40389. * @returns a new webGL buffer
  40390. */
  40391. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40392. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40393. /**
  40394. * Bind a webGL buffer to the webGL context
  40395. * @param buffer defines the buffer to bind
  40396. */
  40397. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40398. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40399. private bindBuffer;
  40400. /**
  40401. * update the bound buffer with the given data
  40402. * @param data defines the data to update
  40403. */
  40404. updateArrayBuffer(data: Float32Array): void;
  40405. private _vertexAttribPointer;
  40406. /** @hidden */
  40407. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40408. private _bindVertexBuffersAttributes;
  40409. /**
  40410. * Records a vertex array object
  40411. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40412. * @param vertexBuffers defines the list of vertex buffers to store
  40413. * @param indexBuffer defines the index buffer to store
  40414. * @param effect defines the effect to store
  40415. * @returns the new vertex array object
  40416. */
  40417. recordVertexArrayObject(vertexBuffers: {
  40418. [key: string]: VertexBuffer;
  40419. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  40420. /**
  40421. * Bind a specific vertex array object
  40422. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40423. * @param vertexArrayObject defines the vertex array object to bind
  40424. * @param indexBuffer defines the index buffer to bind
  40425. */
  40426. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40427. /**
  40428. * Bind webGl buffers directly to the webGL context
  40429. * @param vertexBuffer defines the vertex buffer to bind
  40430. * @param indexBuffer defines the index buffer to bind
  40431. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40432. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40433. * @param effect defines the effect associated with the vertex buffer
  40434. */
  40435. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40436. private _unbindVertexArrayObject;
  40437. /**
  40438. * Bind a list of vertex buffers to the webGL context
  40439. * @param vertexBuffers defines the list of vertex buffers to bind
  40440. * @param indexBuffer defines the index buffer to bind
  40441. * @param effect defines the effect associated with the vertex buffers
  40442. */
  40443. bindBuffers(vertexBuffers: {
  40444. [key: string]: Nullable<VertexBuffer>;
  40445. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  40446. /**
  40447. * Unbind all instance attributes
  40448. */
  40449. unbindInstanceAttributes(): void;
  40450. /**
  40451. * Release and free the memory of a vertex array object
  40452. * @param vao defines the vertex array object to delete
  40453. */
  40454. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  40455. /** @hidden */
  40456. _releaseBuffer(buffer: DataBuffer): boolean;
  40457. protected _deleteBuffer(buffer: DataBuffer): void;
  40458. /**
  40459. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  40460. * @param instancesBuffer defines the webGL buffer to update and bind
  40461. * @param data defines the data to store in the buffer
  40462. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  40463. */
  40464. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  40465. /**
  40466. * Bind the content of a webGL buffer used with instantiation
  40467. * @param instancesBuffer defines the webGL buffer to bind
  40468. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  40469. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  40470. */
  40471. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  40472. /**
  40473. * Disable the instance attribute corresponding to the name in parameter
  40474. * @param name defines the name of the attribute to disable
  40475. */
  40476. disableInstanceAttributeByName(name: string): void;
  40477. /**
  40478. * Disable the instance attribute corresponding to the location in parameter
  40479. * @param attributeLocation defines the attribute location of the attribute to disable
  40480. */
  40481. disableInstanceAttribute(attributeLocation: number): void;
  40482. /**
  40483. * Disable the attribute corresponding to the location in parameter
  40484. * @param attributeLocation defines the attribute location of the attribute to disable
  40485. */
  40486. disableAttributeByIndex(attributeLocation: number): void;
  40487. /**
  40488. * Send a draw order
  40489. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40490. * @param indexStart defines the starting index
  40491. * @param indexCount defines the number of index to draw
  40492. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40493. */
  40494. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40495. /**
  40496. * Draw a list of points
  40497. * @param verticesStart defines the index of first vertex to draw
  40498. * @param verticesCount defines the count of vertices to draw
  40499. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40500. */
  40501. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40502. /**
  40503. * Draw a list of unindexed primitives
  40504. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40505. * @param verticesStart defines the index of first vertex to draw
  40506. * @param verticesCount defines the count of vertices to draw
  40507. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40508. */
  40509. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40510. /**
  40511. * Draw a list of indexed primitives
  40512. * @param fillMode defines the primitive to use
  40513. * @param indexStart defines the starting index
  40514. * @param indexCount defines the number of index to draw
  40515. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40516. */
  40517. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40518. /**
  40519. * Draw a list of unindexed primitives
  40520. * @param fillMode defines the primitive to use
  40521. * @param verticesStart defines the index of first vertex to draw
  40522. * @param verticesCount defines the count of vertices to draw
  40523. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40524. */
  40525. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40526. private _drawMode;
  40527. /** @hidden */
  40528. protected _reportDrawCall(): void;
  40529. /** @hidden */
  40530. _releaseEffect(effect: Effect): void;
  40531. /** @hidden */
  40532. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  40533. /**
  40534. * Create a new effect (used to store vertex/fragment shaders)
  40535. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  40536. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  40537. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  40538. * @param samplers defines an array of string used to represent textures
  40539. * @param defines defines the string containing the defines to use to compile the shaders
  40540. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  40541. * @param onCompiled defines a function to call when the effect creation is successful
  40542. * @param onError defines a function to call when the effect creation has failed
  40543. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  40544. * @returns the new Effect
  40545. */
  40546. 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;
  40547. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  40548. private _compileShader;
  40549. private _compileRawShader;
  40550. /** @hidden */
  40551. _getShaderSource(shader: WebGLShader): Nullable<string>;
  40552. /**
  40553. * Directly creates a webGL program
  40554. * @param pipelineContext defines the pipeline context to attach to
  40555. * @param vertexCode defines the vertex shader code to use
  40556. * @param fragmentCode defines the fragment shader code to use
  40557. * @param context defines the webGL context to use (if not set, the current one will be used)
  40558. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40559. * @returns the new webGL program
  40560. */
  40561. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40562. /**
  40563. * Creates a webGL program
  40564. * @param pipelineContext defines the pipeline context to attach to
  40565. * @param vertexCode defines the vertex shader code to use
  40566. * @param fragmentCode defines the fragment shader code to use
  40567. * @param defines defines the string containing the defines to use to compile the shaders
  40568. * @param context defines the webGL context to use (if not set, the current one will be used)
  40569. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40570. * @returns the new webGL program
  40571. */
  40572. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40573. /**
  40574. * Creates a new pipeline context
  40575. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  40576. * @returns the new pipeline
  40577. */
  40578. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  40579. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40580. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  40581. /** @hidden */
  40582. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  40583. /** @hidden */
  40584. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  40585. /** @hidden */
  40586. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  40587. /**
  40588. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  40589. * @param pipelineContext defines the pipeline context to use
  40590. * @param uniformsNames defines the list of uniform names
  40591. * @returns an array of webGL uniform locations
  40592. */
  40593. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40594. /**
  40595. * Gets the list of active attributes for a given webGL program
  40596. * @param pipelineContext defines the pipeline context to use
  40597. * @param attributesNames defines the list of attribute names to get
  40598. * @returns an array of indices indicating the offset of each attribute
  40599. */
  40600. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40601. /**
  40602. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  40603. * @param effect defines the effect to activate
  40604. */
  40605. enableEffect(effect: Nullable<Effect>): void;
  40606. /**
  40607. * Set the value of an uniform to a number (int)
  40608. * @param uniform defines the webGL uniform location where to store the value
  40609. * @param value defines the int number to store
  40610. * @returns true if the value was set
  40611. */
  40612. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40613. /**
  40614. * Set the value of an uniform to a int2
  40615. * @param uniform defines the webGL uniform location where to store the value
  40616. * @param x defines the 1st component of the value
  40617. * @param y defines the 2nd component of the value
  40618. * @returns true if the value was set
  40619. */
  40620. setInt2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40621. /**
  40622. * Set the value of an uniform to a int3
  40623. * @param uniform defines the webGL uniform location where to store the value
  40624. * @param x defines the 1st component of the value
  40625. * @param y defines the 2nd component of the value
  40626. * @param z defines the 3rd component of the value
  40627. * @returns true if the value was set
  40628. */
  40629. setInt3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40630. /**
  40631. * Set the value of an uniform to a int4
  40632. * @param uniform defines the webGL uniform location where to store the value
  40633. * @param x defines the 1st component of the value
  40634. * @param y defines the 2nd component of the value
  40635. * @param z defines the 3rd component of the value
  40636. * @param w defines the 4th component of the value
  40637. * @returns true if the value was set
  40638. */
  40639. setInt4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40640. /**
  40641. * Set the value of an uniform to an array of int32
  40642. * @param uniform defines the webGL uniform location where to store the value
  40643. * @param array defines the array of int32 to store
  40644. * @returns true if the value was set
  40645. */
  40646. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40647. /**
  40648. * Set the value of an uniform to an array of int32 (stored as vec2)
  40649. * @param uniform defines the webGL uniform location where to store the value
  40650. * @param array defines the array of int32 to store
  40651. * @returns true if the value was set
  40652. */
  40653. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40654. /**
  40655. * Set the value of an uniform to an array of int32 (stored as vec3)
  40656. * @param uniform defines the webGL uniform location where to store the value
  40657. * @param array defines the array of int32 to store
  40658. * @returns true if the value was set
  40659. */
  40660. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40661. /**
  40662. * Set the value of an uniform to an array of int32 (stored as vec4)
  40663. * @param uniform defines the webGL uniform location where to store the value
  40664. * @param array defines the array of int32 to store
  40665. * @returns true if the value was set
  40666. */
  40667. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40668. /**
  40669. * Set the value of an uniform to an array of number
  40670. * @param uniform defines the webGL uniform location where to store the value
  40671. * @param array defines the array of number to store
  40672. * @returns true if the value was set
  40673. */
  40674. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40675. /**
  40676. * Set the value of an uniform to an array of number (stored as vec2)
  40677. * @param uniform defines the webGL uniform location where to store the value
  40678. * @param array defines the array of number to store
  40679. * @returns true if the value was set
  40680. */
  40681. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40682. /**
  40683. * Set the value of an uniform to an array of number (stored as vec3)
  40684. * @param uniform defines the webGL uniform location where to store the value
  40685. * @param array defines the array of number to store
  40686. * @returns true if the value was set
  40687. */
  40688. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40689. /**
  40690. * Set the value of an uniform to an array of number (stored as vec4)
  40691. * @param uniform defines the webGL uniform location where to store the value
  40692. * @param array defines the array of number to store
  40693. * @returns true if the value was set
  40694. */
  40695. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40696. /**
  40697. * Set the value of an uniform to an array of float32 (stored as matrices)
  40698. * @param uniform defines the webGL uniform location where to store the value
  40699. * @param matrices defines the array of float32 to store
  40700. * @returns true if the value was set
  40701. */
  40702. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  40703. /**
  40704. * Set the value of an uniform to a matrix (3x3)
  40705. * @param uniform defines the webGL uniform location where to store the value
  40706. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  40707. * @returns true if the value was set
  40708. */
  40709. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40710. /**
  40711. * Set the value of an uniform to a matrix (2x2)
  40712. * @param uniform defines the webGL uniform location where to store the value
  40713. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  40714. * @returns true if the value was set
  40715. */
  40716. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40717. /**
  40718. * Set the value of an uniform to a number (float)
  40719. * @param uniform defines the webGL uniform location where to store the value
  40720. * @param value defines the float number to store
  40721. * @returns true if the value was transfered
  40722. */
  40723. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40724. /**
  40725. * Set the value of an uniform to a vec2
  40726. * @param uniform defines the webGL uniform location where to store the value
  40727. * @param x defines the 1st component of the value
  40728. * @param y defines the 2nd component of the value
  40729. * @returns true if the value was set
  40730. */
  40731. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40732. /**
  40733. * Set the value of an uniform to a vec3
  40734. * @param uniform defines the webGL uniform location where to store the value
  40735. * @param x defines the 1st component of the value
  40736. * @param y defines the 2nd component of the value
  40737. * @param z defines the 3rd component of the value
  40738. * @returns true if the value was set
  40739. */
  40740. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40741. /**
  40742. * Set the value of an uniform to a vec4
  40743. * @param uniform defines the webGL uniform location where to store the value
  40744. * @param x defines the 1st component of the value
  40745. * @param y defines the 2nd component of the value
  40746. * @param z defines the 3rd component of the value
  40747. * @param w defines the 4th component of the value
  40748. * @returns true if the value was set
  40749. */
  40750. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40751. /**
  40752. * Apply all cached states (depth, culling, stencil and alpha)
  40753. */
  40754. applyStates(): void;
  40755. /**
  40756. * Enable or disable color writing
  40757. * @param enable defines the state to set
  40758. */
  40759. setColorWrite(enable: boolean): void;
  40760. /**
  40761. * Gets a boolean indicating if color writing is enabled
  40762. * @returns the current color writing state
  40763. */
  40764. getColorWrite(): boolean;
  40765. /**
  40766. * Gets the depth culling state manager
  40767. */
  40768. get depthCullingState(): DepthCullingState;
  40769. /**
  40770. * Gets the alpha state manager
  40771. */
  40772. get alphaState(): AlphaState;
  40773. /**
  40774. * Gets the stencil state manager
  40775. */
  40776. get stencilState(): StencilState;
  40777. /**
  40778. * Clears the list of texture accessible through engine.
  40779. * This can help preventing texture load conflict due to name collision.
  40780. */
  40781. clearInternalTexturesCache(): void;
  40782. /**
  40783. * Force the entire cache to be cleared
  40784. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  40785. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  40786. */
  40787. wipeCaches(bruteForce?: boolean): void;
  40788. /** @hidden */
  40789. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  40790. min: number;
  40791. mag: number;
  40792. };
  40793. /** @hidden */
  40794. protected _createTexture(): WebGLTexture;
  40795. /** @hidden */
  40796. _createHardwareTexture(): HardwareTextureWrapper;
  40797. 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 | {
  40798. width: number;
  40799. height: number;
  40800. }, invertY: boolean, noMipmap: boolean, isCompressed: boolean, processFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  40801. width: number;
  40802. height: number;
  40803. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, samplingMode: number) => void, prepareTextureProcessFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  40804. width: number;
  40805. height: number;
  40806. }, 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;
  40807. /**
  40808. * Usually called from Texture.ts.
  40809. * Passed information to create a WebGLTexture
  40810. * @param url defines a value which contains one of the following:
  40811. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  40812. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  40813. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  40814. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  40815. * @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)
  40816. * @param scene needed for loading to the correct scene
  40817. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  40818. * @param onLoad optional callback to be called upon successful completion
  40819. * @param onError optional callback to be called upon failure
  40820. * @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
  40821. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  40822. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  40823. * @param forcedExtension defines the extension to use to pick the right loader
  40824. * @param mimeType defines an optional mime type
  40825. * @param loaderOptions options to be passed to the loader
  40826. * @returns a InternalTexture for assignment back into BABYLON.Texture
  40827. */
  40828. 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;
  40829. /**
  40830. * Loads an image as an HTMLImageElement.
  40831. * @param input url string, ArrayBuffer, or Blob to load
  40832. * @param onLoad callback called when the image successfully loads
  40833. * @param onError callback called when the image fails to load
  40834. * @param offlineProvider offline provider for caching
  40835. * @param mimeType optional mime type
  40836. * @returns the HTMLImageElement of the loaded image
  40837. * @hidden
  40838. */
  40839. 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>;
  40840. /**
  40841. * @hidden
  40842. */
  40843. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  40844. private _unpackFlipYCached;
  40845. /**
  40846. * In case you are sharing the context with other applications, it might
  40847. * be interested to not cache the unpack flip y state to ensure a consistent
  40848. * value would be set.
  40849. */
  40850. enableUnpackFlipYCached: boolean;
  40851. /** @hidden */
  40852. _unpackFlipY(value: boolean): void;
  40853. /** @hidden */
  40854. _getUnpackAlignement(): number;
  40855. private _getTextureTarget;
  40856. /**
  40857. * Update the sampling mode of a given texture
  40858. * @param samplingMode defines the required sampling mode
  40859. * @param texture defines the texture to update
  40860. * @param generateMipMaps defines whether to generate mipmaps for the texture
  40861. */
  40862. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  40863. /**
  40864. * Update the dimensions of a texture
  40865. * @param texture texture to update
  40866. * @param width new width of the texture
  40867. * @param height new height of the texture
  40868. * @param depth new depth of the texture
  40869. */
  40870. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  40871. /**
  40872. * Update the sampling mode of a given texture
  40873. * @param texture defines the texture to update
  40874. * @param wrapU defines the texture wrap mode of the u coordinates
  40875. * @param wrapV defines the texture wrap mode of the v coordinates
  40876. * @param wrapR defines the texture wrap mode of the r coordinates
  40877. */
  40878. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  40879. /** @hidden */
  40880. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  40881. width: number;
  40882. height: number;
  40883. layers?: number;
  40884. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  40885. /** @hidden */
  40886. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40887. /** @hidden */
  40888. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  40889. /**
  40890. * Update a portion of an internal texture
  40891. * @param texture defines the texture to update
  40892. * @param imageData defines the data to store into the texture
  40893. * @param xOffset defines the x coordinates of the update rectangle
  40894. * @param yOffset defines the y coordinates of the update rectangle
  40895. * @param width defines the width of the update rectangle
  40896. * @param height defines the height of the update rectangle
  40897. * @param faceIndex defines the face index if texture is a cube (0 by default)
  40898. * @param lod defines the lod level to update (0 by default)
  40899. */
  40900. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  40901. /** @hidden */
  40902. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40903. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  40904. private _prepareWebGLTexture;
  40905. /** @hidden */
  40906. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  40907. private _getDepthStencilBuffer;
  40908. /** @hidden */
  40909. _releaseFramebufferObjects(texture: InternalTexture): void;
  40910. /** @hidden */
  40911. _releaseTexture(texture: InternalTexture): void;
  40912. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  40913. protected _setProgram(program: WebGLProgram): void;
  40914. protected _boundUniforms: {
  40915. [key: number]: WebGLUniformLocation;
  40916. };
  40917. /**
  40918. * Binds an effect to the webGL context
  40919. * @param effect defines the effect to bind
  40920. */
  40921. bindSamplers(effect: Effect): void;
  40922. private _activateCurrentTexture;
  40923. /** @hidden */
  40924. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  40925. /** @hidden */
  40926. _bindTexture(channel: number, texture: Nullable<InternalTexture>, name: string): void;
  40927. /**
  40928. * Unbind all textures from the webGL context
  40929. */
  40930. unbindAllTextures(): void;
  40931. /**
  40932. * Sets a texture to the according uniform.
  40933. * @param channel The texture channel
  40934. * @param uniform The uniform to set
  40935. * @param texture The texture to apply
  40936. * @param name The name of the uniform in the effect
  40937. */
  40938. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>, name: string): void;
  40939. private _bindSamplerUniformToChannel;
  40940. private _getTextureWrapMode;
  40941. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string): boolean;
  40942. /**
  40943. * Sets an array of texture to the webGL context
  40944. * @param channel defines the channel where the texture array must be set
  40945. * @param uniform defines the associated uniform location
  40946. * @param textures defines the array of textures to bind
  40947. * @param name name of the channel
  40948. */
  40949. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[], name: string): void;
  40950. /** @hidden */
  40951. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  40952. private _setTextureParameterFloat;
  40953. private _setTextureParameterInteger;
  40954. /**
  40955. * Unbind all vertex attributes from the webGL context
  40956. */
  40957. unbindAllAttributes(): void;
  40958. /**
  40959. * 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
  40960. */
  40961. releaseEffects(): void;
  40962. /**
  40963. * Dispose and release all associated resources
  40964. */
  40965. dispose(): void;
  40966. /**
  40967. * Attach a new callback raised when context lost event is fired
  40968. * @param callback defines the callback to call
  40969. */
  40970. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40971. /**
  40972. * Attach a new callback raised when context restored event is fired
  40973. * @param callback defines the callback to call
  40974. */
  40975. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40976. /**
  40977. * Get the current error code of the webGL context
  40978. * @returns the error code
  40979. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40980. */
  40981. getError(): number;
  40982. private _canRenderToFloatFramebuffer;
  40983. private _canRenderToHalfFloatFramebuffer;
  40984. private _canRenderToFramebuffer;
  40985. /** @hidden */
  40986. _getWebGLTextureType(type: number): number;
  40987. /** @hidden */
  40988. _getInternalFormat(format: number): number;
  40989. /** @hidden */
  40990. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  40991. /** @hidden */
  40992. _getRGBAMultiSampleBufferFormat(type: number): number;
  40993. /** @hidden */
  40994. _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;
  40995. /**
  40996. * Loads a file from a url
  40997. * @param url url to load
  40998. * @param onSuccess callback called when the file successfully loads
  40999. * @param onProgress callback called while file is loading (if the server supports this mode)
  41000. * @param offlineProvider defines the offline provider for caching
  41001. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41002. * @param onError callback called when the file fails to load
  41003. * @returns a file request object
  41004. * @hidden
  41005. */
  41006. 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;
  41007. /**
  41008. * Reads pixels from the current frame buffer. Please note that this function can be slow
  41009. * @param x defines the x coordinate of the rectangle where pixels must be read
  41010. * @param y defines the y coordinate of the rectangle where pixels must be read
  41011. * @param width defines the width of the rectangle where pixels must be read
  41012. * @param height defines the height of the rectangle where pixels must be read
  41013. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  41014. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  41015. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  41016. */
  41017. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  41018. private static _IsSupported;
  41019. private static _HasMajorPerformanceCaveat;
  41020. /**
  41021. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41022. */
  41023. static get IsSupported(): boolean;
  41024. /**
  41025. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41026. * @returns true if the engine can be created
  41027. * @ignorenaming
  41028. */
  41029. static isSupported(): boolean;
  41030. /**
  41031. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  41032. */
  41033. static get HasMajorPerformanceCaveat(): boolean;
  41034. /**
  41035. * Find the next highest power of two.
  41036. * @param x Number to start search from.
  41037. * @return Next highest power of two.
  41038. */
  41039. static CeilingPOT(x: number): number;
  41040. /**
  41041. * Find the next lowest power of two.
  41042. * @param x Number to start search from.
  41043. * @return Next lowest power of two.
  41044. */
  41045. static FloorPOT(x: number): number;
  41046. /**
  41047. * Find the nearest power of two.
  41048. * @param x Number to start search from.
  41049. * @return Next nearest power of two.
  41050. */
  41051. static NearestPOT(x: number): number;
  41052. /**
  41053. * Get the closest exponent of two
  41054. * @param value defines the value to approximate
  41055. * @param max defines the maximum value to return
  41056. * @param mode defines how to define the closest value
  41057. * @returns closest exponent of two of the given value
  41058. */
  41059. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  41060. /**
  41061. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  41062. * @param func - the function to be called
  41063. * @param requester - the object that will request the next frame. Falls back to window.
  41064. * @returns frame number
  41065. */
  41066. static QueueNewFrame(func: () => void, requester?: any): number;
  41067. /**
  41068. * Gets host document
  41069. * @returns the host document object
  41070. */
  41071. getHostDocument(): Nullable<Document>;
  41072. }
  41073. }
  41074. declare module BABYLON {
  41075. /**
  41076. * Defines the source of the internal texture
  41077. */
  41078. export enum InternalTextureSource {
  41079. /**
  41080. * The source of the texture data is unknown
  41081. */
  41082. Unknown = 0,
  41083. /**
  41084. * Texture data comes from an URL
  41085. */
  41086. Url = 1,
  41087. /**
  41088. * Texture data is only used for temporary storage
  41089. */
  41090. Temp = 2,
  41091. /**
  41092. * Texture data comes from raw data (ArrayBuffer)
  41093. */
  41094. Raw = 3,
  41095. /**
  41096. * Texture content is dynamic (video or dynamic texture)
  41097. */
  41098. Dynamic = 4,
  41099. /**
  41100. * Texture content is generated by rendering to it
  41101. */
  41102. RenderTarget = 5,
  41103. /**
  41104. * Texture content is part of a multi render target process
  41105. */
  41106. MultiRenderTarget = 6,
  41107. /**
  41108. * Texture data comes from a cube data file
  41109. */
  41110. Cube = 7,
  41111. /**
  41112. * Texture data comes from a raw cube data
  41113. */
  41114. CubeRaw = 8,
  41115. /**
  41116. * Texture data come from a prefiltered cube data file
  41117. */
  41118. CubePrefiltered = 9,
  41119. /**
  41120. * Texture content is raw 3D data
  41121. */
  41122. Raw3D = 10,
  41123. /**
  41124. * Texture content is raw 2D array data
  41125. */
  41126. Raw2DArray = 11,
  41127. /**
  41128. * Texture content is a depth texture
  41129. */
  41130. Depth = 12,
  41131. /**
  41132. * Texture data comes from a raw cube data encoded with RGBD
  41133. */
  41134. CubeRawRGBD = 13
  41135. }
  41136. /**
  41137. * Class used to store data associated with WebGL texture data for the engine
  41138. * This class should not be used directly
  41139. */
  41140. export class InternalTexture {
  41141. /** @hidden */
  41142. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41143. /**
  41144. * Defines if the texture is ready
  41145. */
  41146. isReady: boolean;
  41147. /**
  41148. * Defines if the texture is a cube texture
  41149. */
  41150. isCube: boolean;
  41151. /**
  41152. * Defines if the texture contains 3D data
  41153. */
  41154. is3D: boolean;
  41155. /**
  41156. * Defines if the texture contains 2D array data
  41157. */
  41158. is2DArray: boolean;
  41159. /**
  41160. * Defines if the texture contains multiview data
  41161. */
  41162. isMultiview: boolean;
  41163. /**
  41164. * Gets the URL used to load this texture
  41165. */
  41166. url: string;
  41167. /** @hidden */
  41168. _originalUrl: string;
  41169. /**
  41170. * Gets the sampling mode of the texture
  41171. */
  41172. samplingMode: number;
  41173. /**
  41174. * Gets a boolean indicating if the texture needs mipmaps generation
  41175. */
  41176. generateMipMaps: boolean;
  41177. /**
  41178. * Gets the number of samples used by the texture (WebGL2+ only)
  41179. */
  41180. samples: number;
  41181. /**
  41182. * Gets the type of the texture (int, float...)
  41183. */
  41184. type: number;
  41185. /**
  41186. * Gets the format of the texture (RGB, RGBA...)
  41187. */
  41188. format: number;
  41189. /**
  41190. * Observable called when the texture is loaded
  41191. */
  41192. onLoadedObservable: Observable<InternalTexture>;
  41193. /**
  41194. * Gets the width of the texture
  41195. */
  41196. width: number;
  41197. /**
  41198. * Gets the height of the texture
  41199. */
  41200. height: number;
  41201. /**
  41202. * Gets the depth of the texture
  41203. */
  41204. depth: number;
  41205. /**
  41206. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41207. */
  41208. baseWidth: number;
  41209. /**
  41210. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41211. */
  41212. baseHeight: number;
  41213. /**
  41214. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41215. */
  41216. baseDepth: number;
  41217. /**
  41218. * Gets a boolean indicating if the texture is inverted on Y axis
  41219. */
  41220. invertY: boolean;
  41221. /** @hidden */
  41222. _invertVScale: boolean;
  41223. /** @hidden */
  41224. _associatedChannel: number;
  41225. /** @hidden */
  41226. _source: InternalTextureSource;
  41227. /** @hidden */
  41228. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41229. /** @hidden */
  41230. _bufferView: Nullable<ArrayBufferView>;
  41231. /** @hidden */
  41232. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41233. /** @hidden */
  41234. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41235. /** @hidden */
  41236. _size: number;
  41237. /** @hidden */
  41238. _extension: string;
  41239. /** @hidden */
  41240. _files: Nullable<string[]>;
  41241. /** @hidden */
  41242. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41243. /** @hidden */
  41244. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41245. /** @hidden */
  41246. _framebuffer: Nullable<WebGLFramebuffer>;
  41247. /** @hidden */
  41248. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41249. /** @hidden */
  41250. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41251. /** @hidden */
  41252. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41253. /** @hidden */
  41254. _attachments: Nullable<number[]>;
  41255. /** @hidden */
  41256. _textureArray: Nullable<InternalTexture[]>;
  41257. /** @hidden */
  41258. _cachedCoordinatesMode: Nullable<number>;
  41259. /** @hidden */
  41260. _cachedWrapU: Nullable<number>;
  41261. /** @hidden */
  41262. _cachedWrapV: Nullable<number>;
  41263. /** @hidden */
  41264. _cachedWrapR: Nullable<number>;
  41265. /** @hidden */
  41266. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41267. /** @hidden */
  41268. _isDisabled: boolean;
  41269. /** @hidden */
  41270. _compression: Nullable<string>;
  41271. /** @hidden */
  41272. _generateStencilBuffer: boolean;
  41273. /** @hidden */
  41274. _generateDepthBuffer: boolean;
  41275. /** @hidden */
  41276. _comparisonFunction: number;
  41277. /** @hidden */
  41278. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41279. /** @hidden */
  41280. _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>>;
  41281. /** @hidden */
  41282. _sphericalPolynomialComputed: boolean;
  41283. /** @hidden */
  41284. _lodGenerationScale: number;
  41285. /** @hidden */
  41286. _lodGenerationOffset: number;
  41287. /** @hidden */
  41288. _depthStencilTexture: Nullable<InternalTexture>;
  41289. /** @hidden */
  41290. _colorTextureArray: Nullable<WebGLTexture>;
  41291. /** @hidden */
  41292. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41293. /** @hidden */
  41294. _lodTextureHigh: Nullable<BaseTexture>;
  41295. /** @hidden */
  41296. _lodTextureMid: Nullable<BaseTexture>;
  41297. /** @hidden */
  41298. _lodTextureLow: Nullable<BaseTexture>;
  41299. /** @hidden */
  41300. _isRGBD: boolean;
  41301. /** @hidden */
  41302. _linearSpecularLOD: boolean;
  41303. /** @hidden */
  41304. _irradianceTexture: Nullable<BaseTexture>;
  41305. /** @hidden */
  41306. _hardwareTexture: Nullable<HardwareTextureWrapper>;
  41307. /** @hidden */
  41308. _references: number;
  41309. /** @hidden */
  41310. _gammaSpace: Nullable<boolean>;
  41311. private _engine;
  41312. private _uniqueId;
  41313. private static _Counter;
  41314. /** Gets the unique id of the internal texture */
  41315. get uniqueId(): number;
  41316. /**
  41317. * Gets the Engine the texture belongs to.
  41318. * @returns The babylon engine
  41319. */
  41320. getEngine(): ThinEngine;
  41321. /**
  41322. * Gets the data source type of the texture
  41323. */
  41324. get source(): InternalTextureSource;
  41325. /**
  41326. * Creates a new InternalTexture
  41327. * @param engine defines the engine to use
  41328. * @param source defines the type of data that will be used
  41329. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41330. */
  41331. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41332. /**
  41333. * Increments the number of references (ie. the number of Texture that point to it)
  41334. */
  41335. incrementReferences(): void;
  41336. /**
  41337. * Change the size of the texture (not the size of the content)
  41338. * @param width defines the new width
  41339. * @param height defines the new height
  41340. * @param depth defines the new depth (1 by default)
  41341. */
  41342. updateSize(width: int, height: int, depth?: int): void;
  41343. /** @hidden */
  41344. _rebuild(): void;
  41345. /** @hidden */
  41346. _swapAndDie(target: InternalTexture): void;
  41347. /**
  41348. * Dispose the current allocated resources
  41349. */
  41350. dispose(): void;
  41351. }
  41352. }
  41353. declare module BABYLON {
  41354. /**
  41355. * Interface used to present a loading screen while loading a scene
  41356. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41357. */
  41358. export interface ILoadingScreen {
  41359. /**
  41360. * Function called to display the loading screen
  41361. */
  41362. displayLoadingUI: () => void;
  41363. /**
  41364. * Function called to hide the loading screen
  41365. */
  41366. hideLoadingUI: () => void;
  41367. /**
  41368. * Gets or sets the color to use for the background
  41369. */
  41370. loadingUIBackgroundColor: string;
  41371. /**
  41372. * Gets or sets the text to display while loading
  41373. */
  41374. loadingUIText: string;
  41375. }
  41376. /**
  41377. * Class used for the default loading screen
  41378. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41379. */
  41380. export class DefaultLoadingScreen implements ILoadingScreen {
  41381. private _renderingCanvas;
  41382. private _loadingText;
  41383. private _loadingDivBackgroundColor;
  41384. private _loadingDiv;
  41385. private _loadingTextDiv;
  41386. /** Gets or sets the logo url to use for the default loading screen */
  41387. static DefaultLogoUrl: string;
  41388. /** Gets or sets the spinner url to use for the default loading screen */
  41389. static DefaultSpinnerUrl: string;
  41390. /**
  41391. * Creates a new default loading screen
  41392. * @param _renderingCanvas defines the canvas used to render the scene
  41393. * @param _loadingText defines the default text to display
  41394. * @param _loadingDivBackgroundColor defines the default background color
  41395. */
  41396. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41397. /**
  41398. * Function called to display the loading screen
  41399. */
  41400. displayLoadingUI(): void;
  41401. /**
  41402. * Function called to hide the loading screen
  41403. */
  41404. hideLoadingUI(): void;
  41405. /**
  41406. * Gets or sets the text to display while loading
  41407. */
  41408. set loadingUIText(text: string);
  41409. get loadingUIText(): string;
  41410. /**
  41411. * Gets or sets the color to use for the background
  41412. */
  41413. get loadingUIBackgroundColor(): string;
  41414. set loadingUIBackgroundColor(color: string);
  41415. private _resizeLoadingUI;
  41416. }
  41417. }
  41418. declare module BABYLON {
  41419. /**
  41420. * Interface for any object that can request an animation frame
  41421. */
  41422. export interface ICustomAnimationFrameRequester {
  41423. /**
  41424. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41425. */
  41426. renderFunction?: Function;
  41427. /**
  41428. * Called to request the next frame to render to
  41429. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41430. */
  41431. requestAnimationFrame: Function;
  41432. /**
  41433. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41434. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41435. */
  41436. requestID?: number;
  41437. }
  41438. }
  41439. declare module BABYLON {
  41440. /**
  41441. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41442. */
  41443. export class PerformanceMonitor {
  41444. private _enabled;
  41445. private _rollingFrameTime;
  41446. private _lastFrameTimeMs;
  41447. /**
  41448. * constructor
  41449. * @param frameSampleSize The number of samples required to saturate the sliding window
  41450. */
  41451. constructor(frameSampleSize?: number);
  41452. /**
  41453. * Samples current frame
  41454. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41455. */
  41456. sampleFrame(timeMs?: number): void;
  41457. /**
  41458. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41459. */
  41460. get averageFrameTime(): number;
  41461. /**
  41462. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41463. */
  41464. get averageFrameTimeVariance(): number;
  41465. /**
  41466. * Returns the frame time of the most recent frame
  41467. */
  41468. get instantaneousFrameTime(): number;
  41469. /**
  41470. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41471. */
  41472. get averageFPS(): number;
  41473. /**
  41474. * Returns the average framerate in frames per second using the most recent frame time
  41475. */
  41476. get instantaneousFPS(): number;
  41477. /**
  41478. * Returns true if enough samples have been taken to completely fill the sliding window
  41479. */
  41480. get isSaturated(): boolean;
  41481. /**
  41482. * Enables contributions to the sliding window sample set
  41483. */
  41484. enable(): void;
  41485. /**
  41486. * Disables contributions to the sliding window sample set
  41487. * Samples will not be interpolated over the disabled period
  41488. */
  41489. disable(): void;
  41490. /**
  41491. * Returns true if sampling is enabled
  41492. */
  41493. get isEnabled(): boolean;
  41494. /**
  41495. * Resets performance monitor
  41496. */
  41497. reset(): void;
  41498. }
  41499. /**
  41500. * RollingAverage
  41501. *
  41502. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  41503. */
  41504. export class RollingAverage {
  41505. /**
  41506. * Current average
  41507. */
  41508. average: number;
  41509. /**
  41510. * Current variance
  41511. */
  41512. variance: number;
  41513. protected _samples: Array<number>;
  41514. protected _sampleCount: number;
  41515. protected _pos: number;
  41516. protected _m2: number;
  41517. /**
  41518. * constructor
  41519. * @param length The number of samples required to saturate the sliding window
  41520. */
  41521. constructor(length: number);
  41522. /**
  41523. * Adds a sample to the sample set
  41524. * @param v The sample value
  41525. */
  41526. add(v: number): void;
  41527. /**
  41528. * Returns previously added values or null if outside of history or outside the sliding window domain
  41529. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  41530. * @return Value previously recorded with add() or null if outside of range
  41531. */
  41532. history(i: number): number;
  41533. /**
  41534. * Returns true if enough samples have been taken to completely fill the sliding window
  41535. * @return true if sample-set saturated
  41536. */
  41537. isSaturated(): boolean;
  41538. /**
  41539. * Resets the rolling average (equivalent to 0 samples taken so far)
  41540. */
  41541. reset(): void;
  41542. /**
  41543. * Wraps a value around the sample range boundaries
  41544. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  41545. * @return Wrapped position in sample range
  41546. */
  41547. protected _wrapPosition(i: number): number;
  41548. }
  41549. }
  41550. declare module BABYLON {
  41551. /**
  41552. * This class is used to track a performance counter which is number based.
  41553. * The user has access to many properties which give statistics of different nature.
  41554. *
  41555. * The implementer can track two kinds of Performance Counter: time and count.
  41556. * 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.
  41557. * 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.
  41558. */
  41559. export class PerfCounter {
  41560. /**
  41561. * Gets or sets a global boolean to turn on and off all the counters
  41562. */
  41563. static Enabled: boolean;
  41564. /**
  41565. * Returns the smallest value ever
  41566. */
  41567. get min(): number;
  41568. /**
  41569. * Returns the biggest value ever
  41570. */
  41571. get max(): number;
  41572. /**
  41573. * Returns the average value since the performance counter is running
  41574. */
  41575. get average(): number;
  41576. /**
  41577. * Returns the average value of the last second the counter was monitored
  41578. */
  41579. get lastSecAverage(): number;
  41580. /**
  41581. * Returns the current value
  41582. */
  41583. get current(): number;
  41584. /**
  41585. * Gets the accumulated total
  41586. */
  41587. get total(): number;
  41588. /**
  41589. * Gets the total value count
  41590. */
  41591. get count(): number;
  41592. /**
  41593. * Creates a new counter
  41594. */
  41595. constructor();
  41596. /**
  41597. * Call this method to start monitoring a new frame.
  41598. * 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.
  41599. */
  41600. fetchNewFrame(): void;
  41601. /**
  41602. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  41603. * @param newCount the count value to add to the monitored count
  41604. * @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.
  41605. */
  41606. addCount(newCount: number, fetchResult: boolean): void;
  41607. /**
  41608. * Start monitoring this performance counter
  41609. */
  41610. beginMonitoring(): void;
  41611. /**
  41612. * Compute the time lapsed since the previous beginMonitoring() call.
  41613. * @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
  41614. */
  41615. endMonitoring(newFrame?: boolean): void;
  41616. private _fetchResult;
  41617. private _startMonitoringTime;
  41618. private _min;
  41619. private _max;
  41620. private _average;
  41621. private _current;
  41622. private _totalValueCount;
  41623. private _totalAccumulated;
  41624. private _lastSecAverage;
  41625. private _lastSecAccumulated;
  41626. private _lastSecTime;
  41627. private _lastSecValueCount;
  41628. }
  41629. }
  41630. declare module BABYLON {
  41631. interface ThinEngine {
  41632. /** @hidden */
  41633. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  41634. }
  41635. }
  41636. declare module BABYLON {
  41637. /**
  41638. * Class used to work with sound analyzer using fast fourier transform (FFT)
  41639. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41640. */
  41641. export class Analyser {
  41642. /**
  41643. * Gets or sets the smoothing
  41644. * @ignorenaming
  41645. */
  41646. SMOOTHING: number;
  41647. /**
  41648. * Gets or sets the FFT table size
  41649. * @ignorenaming
  41650. */
  41651. FFT_SIZE: number;
  41652. /**
  41653. * Gets or sets the bar graph amplitude
  41654. * @ignorenaming
  41655. */
  41656. BARGRAPHAMPLITUDE: number;
  41657. /**
  41658. * Gets or sets the position of the debug canvas
  41659. * @ignorenaming
  41660. */
  41661. DEBUGCANVASPOS: {
  41662. x: number;
  41663. y: number;
  41664. };
  41665. /**
  41666. * Gets or sets the debug canvas size
  41667. * @ignorenaming
  41668. */
  41669. DEBUGCANVASSIZE: {
  41670. width: number;
  41671. height: number;
  41672. };
  41673. private _byteFreqs;
  41674. private _byteTime;
  41675. private _floatFreqs;
  41676. private _webAudioAnalyser;
  41677. private _debugCanvas;
  41678. private _debugCanvasContext;
  41679. private _scene;
  41680. private _registerFunc;
  41681. private _audioEngine;
  41682. /**
  41683. * Creates a new analyser
  41684. * @param scene defines hosting scene
  41685. */
  41686. constructor(scene: Scene);
  41687. /**
  41688. * Get the number of data values you will have to play with for the visualization
  41689. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  41690. * @returns a number
  41691. */
  41692. getFrequencyBinCount(): number;
  41693. /**
  41694. * Gets the current frequency data as a byte array
  41695. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41696. * @returns a Uint8Array
  41697. */
  41698. getByteFrequencyData(): Uint8Array;
  41699. /**
  41700. * Gets the current waveform as a byte array
  41701. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  41702. * @returns a Uint8Array
  41703. */
  41704. getByteTimeDomainData(): Uint8Array;
  41705. /**
  41706. * Gets the current frequency data as a float array
  41707. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41708. * @returns a Float32Array
  41709. */
  41710. getFloatFrequencyData(): Float32Array;
  41711. /**
  41712. * Renders the debug canvas
  41713. */
  41714. drawDebugCanvas(): void;
  41715. /**
  41716. * Stops rendering the debug canvas and removes it
  41717. */
  41718. stopDebugCanvas(): void;
  41719. /**
  41720. * Connects two audio nodes
  41721. * @param inputAudioNode defines first node to connect
  41722. * @param outputAudioNode defines second node to connect
  41723. */
  41724. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  41725. /**
  41726. * Releases all associated resources
  41727. */
  41728. dispose(): void;
  41729. }
  41730. }
  41731. declare module BABYLON {
  41732. /**
  41733. * This represents an audio engine and it is responsible
  41734. * to play, synchronize and analyse sounds throughout the application.
  41735. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41736. */
  41737. export interface IAudioEngine extends IDisposable {
  41738. /**
  41739. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41740. */
  41741. readonly canUseWebAudio: boolean;
  41742. /**
  41743. * Gets the current AudioContext if available.
  41744. */
  41745. readonly audioContext: Nullable<AudioContext>;
  41746. /**
  41747. * The master gain node defines the global audio volume of your audio engine.
  41748. */
  41749. readonly masterGain: GainNode;
  41750. /**
  41751. * Gets whether or not mp3 are supported by your browser.
  41752. */
  41753. readonly isMP3supported: boolean;
  41754. /**
  41755. * Gets whether or not ogg are supported by your browser.
  41756. */
  41757. readonly isOGGsupported: boolean;
  41758. /**
  41759. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41760. * @ignoreNaming
  41761. */
  41762. WarnedWebAudioUnsupported: boolean;
  41763. /**
  41764. * Defines if the audio engine relies on a custom unlocked button.
  41765. * In this case, the embedded button will not be displayed.
  41766. */
  41767. useCustomUnlockedButton: boolean;
  41768. /**
  41769. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  41770. */
  41771. readonly unlocked: boolean;
  41772. /**
  41773. * Event raised when audio has been unlocked on the browser.
  41774. */
  41775. onAudioUnlockedObservable: Observable<IAudioEngine>;
  41776. /**
  41777. * Event raised when audio has been locked on the browser.
  41778. */
  41779. onAudioLockedObservable: Observable<IAudioEngine>;
  41780. /**
  41781. * Flags the audio engine in Locked state.
  41782. * This happens due to new browser policies preventing audio to autoplay.
  41783. */
  41784. lock(): void;
  41785. /**
  41786. * Unlocks the audio engine once a user action has been done on the dom.
  41787. * This is helpful to resume play once browser policies have been satisfied.
  41788. */
  41789. unlock(): void;
  41790. /**
  41791. * Gets the global volume sets on the master gain.
  41792. * @returns the global volume if set or -1 otherwise
  41793. */
  41794. getGlobalVolume(): number;
  41795. /**
  41796. * Sets the global volume of your experience (sets on the master gain).
  41797. * @param newVolume Defines the new global volume of the application
  41798. */
  41799. setGlobalVolume(newVolume: number): void;
  41800. /**
  41801. * Connect the audio engine to an audio analyser allowing some amazing
  41802. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41803. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41804. * @param analyser The analyser to connect to the engine
  41805. */
  41806. connectToAnalyser(analyser: Analyser): void;
  41807. }
  41808. }
  41809. declare module BABYLON {
  41810. /**
  41811. * Defines the interface used by display changed events
  41812. */
  41813. export interface IDisplayChangedEventArgs {
  41814. /** Gets the vrDisplay object (if any) */
  41815. vrDisplay: Nullable<any>;
  41816. /** Gets a boolean indicating if webVR is supported */
  41817. vrSupported: boolean;
  41818. }
  41819. /**
  41820. * Defines the interface used by objects containing a viewport (like a camera)
  41821. */
  41822. interface IViewportOwnerLike {
  41823. /**
  41824. * Gets or sets the viewport
  41825. */
  41826. viewport: IViewportLike;
  41827. }
  41828. /**
  41829. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  41830. */
  41831. export class Engine extends ThinEngine {
  41832. /** Defines that alpha blending is disabled */
  41833. static readonly ALPHA_DISABLE: number;
  41834. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  41835. static readonly ALPHA_ADD: number;
  41836. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  41837. static readonly ALPHA_COMBINE: number;
  41838. /** Defines that alpha blending to DEST - SRC * DEST */
  41839. static readonly ALPHA_SUBTRACT: number;
  41840. /** Defines that alpha blending to SRC * DEST */
  41841. static readonly ALPHA_MULTIPLY: number;
  41842. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  41843. static readonly ALPHA_MAXIMIZED: number;
  41844. /** Defines that alpha blending to SRC + DEST */
  41845. static readonly ALPHA_ONEONE: number;
  41846. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  41847. static readonly ALPHA_PREMULTIPLIED: number;
  41848. /**
  41849. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  41850. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  41851. */
  41852. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  41853. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  41854. static readonly ALPHA_INTERPOLATE: number;
  41855. /**
  41856. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  41857. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  41858. */
  41859. static readonly ALPHA_SCREENMODE: number;
  41860. /** Defines that the ressource is not delayed*/
  41861. static readonly DELAYLOADSTATE_NONE: number;
  41862. /** Defines that the ressource was successfully delay loaded */
  41863. static readonly DELAYLOADSTATE_LOADED: number;
  41864. /** Defines that the ressource is currently delay loading */
  41865. static readonly DELAYLOADSTATE_LOADING: number;
  41866. /** Defines that the ressource is delayed and has not started loading */
  41867. static readonly DELAYLOADSTATE_NOTLOADED: number;
  41868. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  41869. static readonly NEVER: number;
  41870. /** 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 */
  41871. static readonly ALWAYS: number;
  41872. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  41873. static readonly LESS: number;
  41874. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  41875. static readonly EQUAL: number;
  41876. /** 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 */
  41877. static readonly LEQUAL: number;
  41878. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  41879. static readonly GREATER: number;
  41880. /** 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 */
  41881. static readonly GEQUAL: number;
  41882. /** 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 */
  41883. static readonly NOTEQUAL: number;
  41884. /** Passed to stencilOperation to specify that stencil value must be kept */
  41885. static readonly KEEP: number;
  41886. /** Passed to stencilOperation to specify that stencil value must be replaced */
  41887. static readonly REPLACE: number;
  41888. /** Passed to stencilOperation to specify that stencil value must be incremented */
  41889. static readonly INCR: number;
  41890. /** Passed to stencilOperation to specify that stencil value must be decremented */
  41891. static readonly DECR: number;
  41892. /** Passed to stencilOperation to specify that stencil value must be inverted */
  41893. static readonly INVERT: number;
  41894. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  41895. static readonly INCR_WRAP: number;
  41896. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  41897. static readonly DECR_WRAP: number;
  41898. /** Texture is not repeating outside of 0..1 UVs */
  41899. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  41900. /** Texture is repeating outside of 0..1 UVs */
  41901. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  41902. /** Texture is repeating and mirrored */
  41903. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  41904. /** ALPHA */
  41905. static readonly TEXTUREFORMAT_ALPHA: number;
  41906. /** LUMINANCE */
  41907. static readonly TEXTUREFORMAT_LUMINANCE: number;
  41908. /** LUMINANCE_ALPHA */
  41909. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  41910. /** RGB */
  41911. static readonly TEXTUREFORMAT_RGB: number;
  41912. /** RGBA */
  41913. static readonly TEXTUREFORMAT_RGBA: number;
  41914. /** RED */
  41915. static readonly TEXTUREFORMAT_RED: number;
  41916. /** RED (2nd reference) */
  41917. static readonly TEXTUREFORMAT_R: number;
  41918. /** RG */
  41919. static readonly TEXTUREFORMAT_RG: number;
  41920. /** RED_INTEGER */
  41921. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  41922. /** RED_INTEGER (2nd reference) */
  41923. static readonly TEXTUREFORMAT_R_INTEGER: number;
  41924. /** RG_INTEGER */
  41925. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  41926. /** RGB_INTEGER */
  41927. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  41928. /** RGBA_INTEGER */
  41929. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  41930. /** UNSIGNED_BYTE */
  41931. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  41932. /** UNSIGNED_BYTE (2nd reference) */
  41933. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  41934. /** FLOAT */
  41935. static readonly TEXTURETYPE_FLOAT: number;
  41936. /** HALF_FLOAT */
  41937. static readonly TEXTURETYPE_HALF_FLOAT: number;
  41938. /** BYTE */
  41939. static readonly TEXTURETYPE_BYTE: number;
  41940. /** SHORT */
  41941. static readonly TEXTURETYPE_SHORT: number;
  41942. /** UNSIGNED_SHORT */
  41943. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  41944. /** INT */
  41945. static readonly TEXTURETYPE_INT: number;
  41946. /** UNSIGNED_INT */
  41947. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  41948. /** UNSIGNED_SHORT_4_4_4_4 */
  41949. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  41950. /** UNSIGNED_SHORT_5_5_5_1 */
  41951. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  41952. /** UNSIGNED_SHORT_5_6_5 */
  41953. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  41954. /** UNSIGNED_INT_2_10_10_10_REV */
  41955. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  41956. /** UNSIGNED_INT_24_8 */
  41957. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  41958. /** UNSIGNED_INT_10F_11F_11F_REV */
  41959. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  41960. /** UNSIGNED_INT_5_9_9_9_REV */
  41961. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  41962. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  41963. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  41964. /** nearest is mag = nearest and min = nearest and mip = none */
  41965. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  41966. /** Bilinear is mag = linear and min = linear and mip = nearest */
  41967. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  41968. /** Trilinear is mag = linear and min = linear and mip = linear */
  41969. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  41970. /** nearest is mag = nearest and min = nearest and mip = linear */
  41971. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  41972. /** Bilinear is mag = linear and min = linear and mip = nearest */
  41973. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  41974. /** Trilinear is mag = linear and min = linear and mip = linear */
  41975. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  41976. /** mag = nearest and min = nearest and mip = nearest */
  41977. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  41978. /** mag = nearest and min = linear and mip = nearest */
  41979. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  41980. /** mag = nearest and min = linear and mip = linear */
  41981. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  41982. /** mag = nearest and min = linear and mip = none */
  41983. static readonly TEXTURE_NEAREST_LINEAR: number;
  41984. /** mag = nearest and min = nearest and mip = none */
  41985. static readonly TEXTURE_NEAREST_NEAREST: number;
  41986. /** mag = linear and min = nearest and mip = nearest */
  41987. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  41988. /** mag = linear and min = nearest and mip = linear */
  41989. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  41990. /** mag = linear and min = linear and mip = none */
  41991. static readonly TEXTURE_LINEAR_LINEAR: number;
  41992. /** mag = linear and min = nearest and mip = none */
  41993. static readonly TEXTURE_LINEAR_NEAREST: number;
  41994. /** Explicit coordinates mode */
  41995. static readonly TEXTURE_EXPLICIT_MODE: number;
  41996. /** Spherical coordinates mode */
  41997. static readonly TEXTURE_SPHERICAL_MODE: number;
  41998. /** Planar coordinates mode */
  41999. static readonly TEXTURE_PLANAR_MODE: number;
  42000. /** Cubic coordinates mode */
  42001. static readonly TEXTURE_CUBIC_MODE: number;
  42002. /** Projection coordinates mode */
  42003. static readonly TEXTURE_PROJECTION_MODE: number;
  42004. /** Skybox coordinates mode */
  42005. static readonly TEXTURE_SKYBOX_MODE: number;
  42006. /** Inverse Cubic coordinates mode */
  42007. static readonly TEXTURE_INVCUBIC_MODE: number;
  42008. /** Equirectangular coordinates mode */
  42009. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42010. /** Equirectangular Fixed coordinates mode */
  42011. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42012. /** Equirectangular Fixed Mirrored coordinates mode */
  42013. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42014. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42015. static readonly SCALEMODE_FLOOR: number;
  42016. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42017. static readonly SCALEMODE_NEAREST: number;
  42018. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42019. static readonly SCALEMODE_CEILING: number;
  42020. /**
  42021. * Returns the current npm package of the sdk
  42022. */
  42023. static get NpmPackage(): string;
  42024. /**
  42025. * Returns the current version of the framework
  42026. */
  42027. static get Version(): string;
  42028. /** Gets the list of created engines */
  42029. static get Instances(): Engine[];
  42030. /**
  42031. * Gets the latest created engine
  42032. */
  42033. static get LastCreatedEngine(): Nullable<Engine>;
  42034. /**
  42035. * Gets the latest created scene
  42036. */
  42037. static get LastCreatedScene(): Nullable<Scene>;
  42038. /**
  42039. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42040. * @param flag defines which part of the materials must be marked as dirty
  42041. * @param predicate defines a predicate used to filter which materials should be affected
  42042. */
  42043. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42044. /**
  42045. * Method called to create the default loading screen.
  42046. * This can be overriden in your own app.
  42047. * @param canvas The rendering canvas element
  42048. * @returns The loading screen
  42049. */
  42050. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42051. /**
  42052. * Method called to create the default rescale post process on each engine.
  42053. */
  42054. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42055. /**
  42056. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42057. **/
  42058. enableOfflineSupport: boolean;
  42059. /**
  42060. * 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)
  42061. **/
  42062. disableManifestCheck: boolean;
  42063. /**
  42064. * Gets the list of created scenes
  42065. */
  42066. scenes: Scene[];
  42067. /**
  42068. * Event raised when a new scene is created
  42069. */
  42070. onNewSceneAddedObservable: Observable<Scene>;
  42071. /**
  42072. * Gets the list of created postprocesses
  42073. */
  42074. postProcesses: PostProcess[];
  42075. /**
  42076. * Gets a boolean indicating if the pointer is currently locked
  42077. */
  42078. isPointerLock: boolean;
  42079. /**
  42080. * Observable event triggered each time the rendering canvas is resized
  42081. */
  42082. onResizeObservable: Observable<Engine>;
  42083. /**
  42084. * Observable event triggered each time the canvas loses focus
  42085. */
  42086. onCanvasBlurObservable: Observable<Engine>;
  42087. /**
  42088. * Observable event triggered each time the canvas gains focus
  42089. */
  42090. onCanvasFocusObservable: Observable<Engine>;
  42091. /**
  42092. * Observable event triggered each time the canvas receives pointerout event
  42093. */
  42094. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42095. /**
  42096. * Observable raised when the engine begins a new frame
  42097. */
  42098. onBeginFrameObservable: Observable<Engine>;
  42099. /**
  42100. * If set, will be used to request the next animation frame for the render loop
  42101. */
  42102. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42103. /**
  42104. * Observable raised when the engine ends the current frame
  42105. */
  42106. onEndFrameObservable: Observable<Engine>;
  42107. /**
  42108. * Observable raised when the engine is about to compile a shader
  42109. */
  42110. onBeforeShaderCompilationObservable: Observable<Engine>;
  42111. /**
  42112. * Observable raised when the engine has jsut compiled a shader
  42113. */
  42114. onAfterShaderCompilationObservable: Observable<Engine>;
  42115. /**
  42116. * Gets the audio engine
  42117. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42118. * @ignorenaming
  42119. */
  42120. static audioEngine: IAudioEngine;
  42121. /**
  42122. * Default AudioEngine factory responsible of creating the Audio Engine.
  42123. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42124. */
  42125. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42126. /**
  42127. * Default offline support factory responsible of creating a tool used to store data locally.
  42128. * By default, this will create a Database object if the workload has been embedded.
  42129. */
  42130. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42131. private _loadingScreen;
  42132. private _pointerLockRequested;
  42133. private _rescalePostProcess;
  42134. protected _deterministicLockstep: boolean;
  42135. protected _lockstepMaxSteps: number;
  42136. protected _timeStep: number;
  42137. protected get _supportsHardwareTextureRescaling(): boolean;
  42138. private _fps;
  42139. private _deltaTime;
  42140. /** @hidden */
  42141. _drawCalls: PerfCounter;
  42142. /** 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 */
  42143. canvasTabIndex: number;
  42144. /**
  42145. * Turn this value on if you want to pause FPS computation when in background
  42146. */
  42147. disablePerformanceMonitorInBackground: boolean;
  42148. private _performanceMonitor;
  42149. /**
  42150. * Gets the performance monitor attached to this engine
  42151. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42152. */
  42153. get performanceMonitor(): PerformanceMonitor;
  42154. private _onFocus;
  42155. private _onBlur;
  42156. private _onCanvasPointerOut;
  42157. private _onCanvasBlur;
  42158. private _onCanvasFocus;
  42159. private _onFullscreenChange;
  42160. private _onPointerLockChange;
  42161. /**
  42162. * Gets the HTML element used to attach event listeners
  42163. * @returns a HTML element
  42164. */
  42165. getInputElement(): Nullable<HTMLElement>;
  42166. /**
  42167. * Creates a new engine
  42168. * @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
  42169. * @param antialias defines enable antialiasing (default: false)
  42170. * @param options defines further options to be sent to the getContext() function
  42171. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42172. */
  42173. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42174. /**
  42175. * Shared initialization across engines types.
  42176. * @param canvas The canvas associated with this instance of the engine.
  42177. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  42178. * @param audioEngine Defines if an audio engine should be created by default
  42179. */
  42180. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  42181. /**
  42182. * Gets current aspect ratio
  42183. * @param viewportOwner defines the camera to use to get the aspect ratio
  42184. * @param useScreen defines if screen size must be used (or the current render target if any)
  42185. * @returns a number defining the aspect ratio
  42186. */
  42187. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42188. /**
  42189. * Gets current screen aspect ratio
  42190. * @returns a number defining the aspect ratio
  42191. */
  42192. getScreenAspectRatio(): number;
  42193. /**
  42194. * Gets the client rect of the HTML canvas attached with the current webGL context
  42195. * @returns a client rectanglee
  42196. */
  42197. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42198. /**
  42199. * Gets the client rect of the HTML element used for events
  42200. * @returns a client rectanglee
  42201. */
  42202. getInputElementClientRect(): Nullable<ClientRect>;
  42203. /**
  42204. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42205. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42206. * @returns true if engine is in deterministic lock step mode
  42207. */
  42208. isDeterministicLockStep(): boolean;
  42209. /**
  42210. * Gets the max steps when engine is running in deterministic lock step
  42211. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42212. * @returns the max steps
  42213. */
  42214. getLockstepMaxSteps(): number;
  42215. /**
  42216. * Returns the time in ms between steps when using deterministic lock step.
  42217. * @returns time step in (ms)
  42218. */
  42219. getTimeStep(): number;
  42220. /**
  42221. * Force the mipmap generation for the given render target texture
  42222. * @param texture defines the render target texture to use
  42223. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42224. */
  42225. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42226. /** States */
  42227. /**
  42228. * Set various states to the webGL context
  42229. * @param culling defines backface culling state
  42230. * @param zOffset defines the value to apply to zOffset (0 by default)
  42231. * @param force defines if states must be applied even if cache is up to date
  42232. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42233. */
  42234. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42235. /**
  42236. * Set the z offset to apply to current rendering
  42237. * @param value defines the offset to apply
  42238. */
  42239. setZOffset(value: number): void;
  42240. /**
  42241. * Gets the current value of the zOffset
  42242. * @returns the current zOffset state
  42243. */
  42244. getZOffset(): number;
  42245. /**
  42246. * Gets a boolean indicating if depth testing is enabled
  42247. * @returns the current state
  42248. */
  42249. getDepthBuffer(): boolean;
  42250. /**
  42251. * Enable or disable depth buffering
  42252. * @param enable defines the state to set
  42253. */
  42254. setDepthBuffer(enable: boolean): void;
  42255. /**
  42256. * Gets a boolean indicating if depth writing is enabled
  42257. * @returns the current depth writing state
  42258. */
  42259. getDepthWrite(): boolean;
  42260. /**
  42261. * Enable or disable depth writing
  42262. * @param enable defines the state to set
  42263. */
  42264. setDepthWrite(enable: boolean): void;
  42265. /**
  42266. * Gets a boolean indicating if stencil buffer is enabled
  42267. * @returns the current stencil buffer state
  42268. */
  42269. getStencilBuffer(): boolean;
  42270. /**
  42271. * Enable or disable the stencil buffer
  42272. * @param enable defines if the stencil buffer must be enabled or disabled
  42273. */
  42274. setStencilBuffer(enable: boolean): void;
  42275. /**
  42276. * Gets the current stencil mask
  42277. * @returns a number defining the new stencil mask to use
  42278. */
  42279. getStencilMask(): number;
  42280. /**
  42281. * Sets the current stencil mask
  42282. * @param mask defines the new stencil mask to use
  42283. */
  42284. setStencilMask(mask: number): void;
  42285. /**
  42286. * Gets the current stencil function
  42287. * @returns a number defining the stencil function to use
  42288. */
  42289. getStencilFunction(): number;
  42290. /**
  42291. * Gets the current stencil reference value
  42292. * @returns a number defining the stencil reference value to use
  42293. */
  42294. getStencilFunctionReference(): number;
  42295. /**
  42296. * Gets the current stencil mask
  42297. * @returns a number defining the stencil mask to use
  42298. */
  42299. getStencilFunctionMask(): number;
  42300. /**
  42301. * Sets the current stencil function
  42302. * @param stencilFunc defines the new stencil function to use
  42303. */
  42304. setStencilFunction(stencilFunc: number): void;
  42305. /**
  42306. * Sets the current stencil reference
  42307. * @param reference defines the new stencil reference to use
  42308. */
  42309. setStencilFunctionReference(reference: number): void;
  42310. /**
  42311. * Sets the current stencil mask
  42312. * @param mask defines the new stencil mask to use
  42313. */
  42314. setStencilFunctionMask(mask: number): void;
  42315. /**
  42316. * Gets the current stencil operation when stencil fails
  42317. * @returns a number defining stencil operation to use when stencil fails
  42318. */
  42319. getStencilOperationFail(): number;
  42320. /**
  42321. * Gets the current stencil operation when depth fails
  42322. * @returns a number defining stencil operation to use when depth fails
  42323. */
  42324. getStencilOperationDepthFail(): number;
  42325. /**
  42326. * Gets the current stencil operation when stencil passes
  42327. * @returns a number defining stencil operation to use when stencil passes
  42328. */
  42329. getStencilOperationPass(): number;
  42330. /**
  42331. * Sets the stencil operation to use when stencil fails
  42332. * @param operation defines the stencil operation to use when stencil fails
  42333. */
  42334. setStencilOperationFail(operation: number): void;
  42335. /**
  42336. * Sets the stencil operation to use when depth fails
  42337. * @param operation defines the stencil operation to use when depth fails
  42338. */
  42339. setStencilOperationDepthFail(operation: number): void;
  42340. /**
  42341. * Sets the stencil operation to use when stencil passes
  42342. * @param operation defines the stencil operation to use when stencil passes
  42343. */
  42344. setStencilOperationPass(operation: number): void;
  42345. /**
  42346. * Sets a boolean indicating if the dithering state is enabled or disabled
  42347. * @param value defines the dithering state
  42348. */
  42349. setDitheringState(value: boolean): void;
  42350. /**
  42351. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42352. * @param value defines the rasterizer state
  42353. */
  42354. setRasterizerState(value: boolean): void;
  42355. /**
  42356. * Gets the current depth function
  42357. * @returns a number defining the depth function
  42358. */
  42359. getDepthFunction(): Nullable<number>;
  42360. /**
  42361. * Sets the current depth function
  42362. * @param depthFunc defines the function to use
  42363. */
  42364. setDepthFunction(depthFunc: number): void;
  42365. /**
  42366. * Sets the current depth function to GREATER
  42367. */
  42368. setDepthFunctionToGreater(): void;
  42369. /**
  42370. * Sets the current depth function to GEQUAL
  42371. */
  42372. setDepthFunctionToGreaterOrEqual(): void;
  42373. /**
  42374. * Sets the current depth function to LESS
  42375. */
  42376. setDepthFunctionToLess(): void;
  42377. /**
  42378. * Sets the current depth function to LEQUAL
  42379. */
  42380. setDepthFunctionToLessOrEqual(): void;
  42381. private _cachedStencilBuffer;
  42382. private _cachedStencilFunction;
  42383. private _cachedStencilMask;
  42384. private _cachedStencilOperationPass;
  42385. private _cachedStencilOperationFail;
  42386. private _cachedStencilOperationDepthFail;
  42387. private _cachedStencilReference;
  42388. /**
  42389. * Caches the the state of the stencil buffer
  42390. */
  42391. cacheStencilState(): void;
  42392. /**
  42393. * Restores the state of the stencil buffer
  42394. */
  42395. restoreStencilState(): void;
  42396. /**
  42397. * Directly set the WebGL Viewport
  42398. * @param x defines the x coordinate of the viewport (in screen space)
  42399. * @param y defines the y coordinate of the viewport (in screen space)
  42400. * @param width defines the width of the viewport (in screen space)
  42401. * @param height defines the height of the viewport (in screen space)
  42402. * @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
  42403. */
  42404. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42405. /**
  42406. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42407. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42408. * @param y defines the y-coordinate of the corner of the clear rectangle
  42409. * @param width defines the width of the clear rectangle
  42410. * @param height defines the height of the clear rectangle
  42411. * @param clearColor defines the clear color
  42412. */
  42413. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42414. /**
  42415. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42416. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42417. * @param y defines the y-coordinate of the corner of the clear rectangle
  42418. * @param width defines the width of the clear rectangle
  42419. * @param height defines the height of the clear rectangle
  42420. */
  42421. enableScissor(x: number, y: number, width: number, height: number): void;
  42422. /**
  42423. * Disable previously set scissor test rectangle
  42424. */
  42425. disableScissor(): void;
  42426. protected _reportDrawCall(): void;
  42427. /**
  42428. * Initializes a webVR display and starts listening to display change events
  42429. * The onVRDisplayChangedObservable will be notified upon these changes
  42430. * @returns The onVRDisplayChangedObservable
  42431. */
  42432. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42433. /** @hidden */
  42434. _prepareVRComponent(): void;
  42435. /** @hidden */
  42436. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42437. /** @hidden */
  42438. _submitVRFrame(): void;
  42439. /**
  42440. * Call this function to leave webVR mode
  42441. * Will do nothing if webVR is not supported or if there is no webVR device
  42442. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42443. */
  42444. disableVR(): void;
  42445. /**
  42446. * Gets a boolean indicating that the system is in VR mode and is presenting
  42447. * @returns true if VR mode is engaged
  42448. */
  42449. isVRPresenting(): boolean;
  42450. /** @hidden */
  42451. _requestVRFrame(): void;
  42452. /** @hidden */
  42453. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42454. /**
  42455. * Gets the source code of the vertex shader associated with a specific webGL program
  42456. * @param program defines the program to use
  42457. * @returns a string containing the source code of the vertex shader associated with the program
  42458. */
  42459. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42460. /**
  42461. * Gets the source code of the fragment shader associated with a specific webGL program
  42462. * @param program defines the program to use
  42463. * @returns a string containing the source code of the fragment shader associated with the program
  42464. */
  42465. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42466. /**
  42467. * Sets a depth stencil texture from a render target to the according uniform.
  42468. * @param channel The texture channel
  42469. * @param uniform The uniform to set
  42470. * @param texture The render target texture containing the depth stencil texture to apply
  42471. * @param name The texture name
  42472. */
  42473. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>, name?: string): void;
  42474. /**
  42475. * Sets a texture to the webGL context from a postprocess
  42476. * @param channel defines the channel to use
  42477. * @param postProcess defines the source postprocess
  42478. * @param name name of the channel
  42479. */
  42480. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  42481. /**
  42482. * Binds the output of the passed in post process to the texture channel specified
  42483. * @param channel The channel the texture should be bound to
  42484. * @param postProcess The post process which's output should be bound
  42485. * @param name name of the channel
  42486. */
  42487. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  42488. protected _rebuildBuffers(): void;
  42489. /** @hidden */
  42490. _renderFrame(): void;
  42491. _renderLoop(): void;
  42492. /** @hidden */
  42493. _renderViews(): boolean;
  42494. /**
  42495. * Toggle full screen mode
  42496. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42497. */
  42498. switchFullscreen(requestPointerLock: boolean): void;
  42499. /**
  42500. * Enters full screen mode
  42501. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42502. */
  42503. enterFullscreen(requestPointerLock: boolean): void;
  42504. /**
  42505. * Exits full screen mode
  42506. */
  42507. exitFullscreen(): void;
  42508. /**
  42509. * Enters Pointerlock mode
  42510. */
  42511. enterPointerlock(): void;
  42512. /**
  42513. * Exits Pointerlock mode
  42514. */
  42515. exitPointerlock(): void;
  42516. /**
  42517. * Begin a new frame
  42518. */
  42519. beginFrame(): void;
  42520. /**
  42521. * End the current frame
  42522. */
  42523. endFrame(): void;
  42524. /**
  42525. * Resize the view according to the canvas' size
  42526. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42527. */
  42528. resize(forceSetSize?: boolean): void;
  42529. /**
  42530. * Force a specific size of the canvas
  42531. * @param width defines the new canvas' width
  42532. * @param height defines the new canvas' height
  42533. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42534. * @returns true if the size was changed
  42535. */
  42536. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  42537. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42538. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42539. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42540. _releaseTexture(texture: InternalTexture): void;
  42541. /**
  42542. * @hidden
  42543. * Rescales a texture
  42544. * @param source input texutre
  42545. * @param destination destination texture
  42546. * @param scene scene to use to render the resize
  42547. * @param internalFormat format to use when resizing
  42548. * @param onComplete callback to be called when resize has completed
  42549. */
  42550. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42551. /**
  42552. * Gets the current framerate
  42553. * @returns a number representing the framerate
  42554. */
  42555. getFps(): number;
  42556. /**
  42557. * Gets the time spent between current and previous frame
  42558. * @returns a number representing the delta time in ms
  42559. */
  42560. getDeltaTime(): number;
  42561. private _measureFps;
  42562. /** @hidden */
  42563. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  42564. /**
  42565. * Updates the sample count of a render target texture
  42566. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42567. * @param texture defines the texture to update
  42568. * @param samples defines the sample count to set
  42569. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42570. */
  42571. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  42572. /**
  42573. * Updates a depth texture Comparison Mode and Function.
  42574. * If the comparison Function is equal to 0, the mode will be set to none.
  42575. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  42576. * @param texture The texture to set the comparison function for
  42577. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  42578. */
  42579. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  42580. /**
  42581. * Creates a webGL buffer to use with instanciation
  42582. * @param capacity defines the size of the buffer
  42583. * @returns the webGL buffer
  42584. */
  42585. createInstancesBuffer(capacity: number): DataBuffer;
  42586. /**
  42587. * Delete a webGL buffer used with instanciation
  42588. * @param buffer defines the webGL buffer to delete
  42589. */
  42590. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  42591. private _clientWaitAsync;
  42592. /** @hidden */
  42593. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;
  42594. dispose(): void;
  42595. private _disableTouchAction;
  42596. /**
  42597. * Display the loading screen
  42598. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42599. */
  42600. displayLoadingUI(): void;
  42601. /**
  42602. * Hide the loading screen
  42603. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42604. */
  42605. hideLoadingUI(): void;
  42606. /**
  42607. * Gets the current loading screen object
  42608. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42609. */
  42610. get loadingScreen(): ILoadingScreen;
  42611. /**
  42612. * Sets the current loading screen object
  42613. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42614. */
  42615. set loadingScreen(loadingScreen: ILoadingScreen);
  42616. /**
  42617. * Sets the current loading screen text
  42618. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42619. */
  42620. set loadingUIText(text: string);
  42621. /**
  42622. * Sets the current loading screen background color
  42623. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42624. */
  42625. set loadingUIBackgroundColor(color: string);
  42626. /** Pointerlock and fullscreen */
  42627. /**
  42628. * Ask the browser to promote the current element to pointerlock mode
  42629. * @param element defines the DOM element to promote
  42630. */
  42631. static _RequestPointerlock(element: HTMLElement): void;
  42632. /**
  42633. * Asks the browser to exit pointerlock mode
  42634. */
  42635. static _ExitPointerlock(): void;
  42636. /**
  42637. * Ask the browser to promote the current element to fullscreen rendering mode
  42638. * @param element defines the DOM element to promote
  42639. */
  42640. static _RequestFullscreen(element: HTMLElement): void;
  42641. /**
  42642. * Asks the browser to exit fullscreen mode
  42643. */
  42644. static _ExitFullscreen(): void;
  42645. }
  42646. }
  42647. declare module BABYLON {
  42648. /**
  42649. * The engine store class is responsible to hold all the instances of Engine and Scene created
  42650. * during the life time of the application.
  42651. */
  42652. export class EngineStore {
  42653. /** Gets the list of created engines */
  42654. static Instances: Engine[];
  42655. /** @hidden */
  42656. static _LastCreatedScene: Nullable<Scene>;
  42657. /**
  42658. * Gets the latest created engine
  42659. */
  42660. static get LastCreatedEngine(): Nullable<Engine>;
  42661. /**
  42662. * Gets the latest created scene
  42663. */
  42664. static get LastCreatedScene(): Nullable<Scene>;
  42665. /**
  42666. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42667. * @ignorenaming
  42668. */
  42669. static UseFallbackTexture: boolean;
  42670. /**
  42671. * Texture content used if a texture cannot loaded
  42672. * @ignorenaming
  42673. */
  42674. static FallbackTexture: string;
  42675. }
  42676. }
  42677. declare module BABYLON {
  42678. /**
  42679. * Helper class that provides a small promise polyfill
  42680. */
  42681. export class PromisePolyfill {
  42682. /**
  42683. * Static function used to check if the polyfill is required
  42684. * If this is the case then the function will inject the polyfill to window.Promise
  42685. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  42686. */
  42687. static Apply(force?: boolean): void;
  42688. }
  42689. }
  42690. declare module BABYLON {
  42691. /**
  42692. * Interface for screenshot methods with describe argument called `size` as object with options
  42693. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  42694. */
  42695. export interface IScreenshotSize {
  42696. /**
  42697. * number in pixels for canvas height
  42698. */
  42699. height?: number;
  42700. /**
  42701. * multiplier allowing render at a higher or lower resolution
  42702. * If value is defined then height and width will be ignored and taken from camera
  42703. */
  42704. precision?: number;
  42705. /**
  42706. * number in pixels for canvas width
  42707. */
  42708. width?: number;
  42709. }
  42710. }
  42711. declare module BABYLON {
  42712. interface IColor4Like {
  42713. r: float;
  42714. g: float;
  42715. b: float;
  42716. a: float;
  42717. }
  42718. /**
  42719. * Class containing a set of static utilities functions
  42720. */
  42721. export class Tools {
  42722. /**
  42723. * Gets or sets the base URL to use to load assets
  42724. */
  42725. static get BaseUrl(): string;
  42726. static set BaseUrl(value: string);
  42727. /**
  42728. * Enable/Disable Custom HTTP Request Headers globally.
  42729. * default = false
  42730. * @see CustomRequestHeaders
  42731. */
  42732. static UseCustomRequestHeaders: boolean;
  42733. /**
  42734. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  42735. * i.e. when loading files, where the server/service expects an Authorization header
  42736. */
  42737. static CustomRequestHeaders: {
  42738. [key: string]: string;
  42739. };
  42740. /**
  42741. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  42742. */
  42743. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  42744. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  42745. /**
  42746. * Default behaviour for cors in the application.
  42747. * It can be a string if the expected behavior is identical in the entire app.
  42748. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  42749. */
  42750. static get CorsBehavior(): string | ((url: string | string[]) => string);
  42751. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  42752. /**
  42753. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42754. * @ignorenaming
  42755. */
  42756. static get UseFallbackTexture(): boolean;
  42757. static set UseFallbackTexture(value: boolean);
  42758. /**
  42759. * Use this object to register external classes like custom textures or material
  42760. * to allow the laoders to instantiate them
  42761. */
  42762. static get RegisteredExternalClasses(): {
  42763. [key: string]: Object;
  42764. };
  42765. static set RegisteredExternalClasses(classes: {
  42766. [key: string]: Object;
  42767. });
  42768. /**
  42769. * Texture content used if a texture cannot loaded
  42770. * @ignorenaming
  42771. */
  42772. static get fallbackTexture(): string;
  42773. static set fallbackTexture(value: string);
  42774. /**
  42775. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  42776. * @param u defines the coordinate on X axis
  42777. * @param v defines the coordinate on Y axis
  42778. * @param width defines the width of the source data
  42779. * @param height defines the height of the source data
  42780. * @param pixels defines the source byte array
  42781. * @param color defines the output color
  42782. */
  42783. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  42784. /**
  42785. * Interpolates between a and b via alpha
  42786. * @param a The lower value (returned when alpha = 0)
  42787. * @param b The upper value (returned when alpha = 1)
  42788. * @param alpha The interpolation-factor
  42789. * @return The mixed value
  42790. */
  42791. static Mix(a: number, b: number, alpha: number): number;
  42792. /**
  42793. * Tries to instantiate a new object from a given class name
  42794. * @param className defines the class name to instantiate
  42795. * @returns the new object or null if the system was not able to do the instantiation
  42796. */
  42797. static Instantiate(className: string): any;
  42798. /**
  42799. * Provides a slice function that will work even on IE
  42800. * @param data defines the array to slice
  42801. * @param start defines the start of the data (optional)
  42802. * @param end defines the end of the data (optional)
  42803. * @returns the new sliced array
  42804. */
  42805. static Slice<T>(data: T, start?: number, end?: number): T;
  42806. /**
  42807. * Provides a slice function that will work even on IE
  42808. * The difference between this and Slice is that this will force-convert to array
  42809. * @param data defines the array to slice
  42810. * @param start defines the start of the data (optional)
  42811. * @param end defines the end of the data (optional)
  42812. * @returns the new sliced array
  42813. */
  42814. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  42815. /**
  42816. * Polyfill for setImmediate
  42817. * @param action defines the action to execute after the current execution block
  42818. */
  42819. static SetImmediate(action: () => void): void;
  42820. /**
  42821. * Function indicating if a number is an exponent of 2
  42822. * @param value defines the value to test
  42823. * @returns true if the value is an exponent of 2
  42824. */
  42825. static IsExponentOfTwo(value: number): boolean;
  42826. private static _tmpFloatArray;
  42827. /**
  42828. * Returns the nearest 32-bit single precision float representation of a Number
  42829. * @param value A Number. If the parameter is of a different type, it will get converted
  42830. * to a number or to NaN if it cannot be converted
  42831. * @returns number
  42832. */
  42833. static FloatRound(value: number): number;
  42834. /**
  42835. * Extracts the filename from a path
  42836. * @param path defines the path to use
  42837. * @returns the filename
  42838. */
  42839. static GetFilename(path: string): string;
  42840. /**
  42841. * Extracts the "folder" part of a path (everything before the filename).
  42842. * @param uri The URI to extract the info from
  42843. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  42844. * @returns The "folder" part of the path
  42845. */
  42846. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  42847. /**
  42848. * Extracts text content from a DOM element hierarchy
  42849. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  42850. */
  42851. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  42852. /**
  42853. * Convert an angle in radians to degrees
  42854. * @param angle defines the angle to convert
  42855. * @returns the angle in degrees
  42856. */
  42857. static ToDegrees(angle: number): number;
  42858. /**
  42859. * Convert an angle in degrees to radians
  42860. * @param angle defines the angle to convert
  42861. * @returns the angle in radians
  42862. */
  42863. static ToRadians(angle: number): number;
  42864. /**
  42865. * Returns an array if obj is not an array
  42866. * @param obj defines the object to evaluate as an array
  42867. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  42868. * @returns either obj directly if obj is an array or a new array containing obj
  42869. */
  42870. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  42871. /**
  42872. * Gets the pointer prefix to use
  42873. * @param engine defines the engine we are finding the prefix for
  42874. * @returns "pointer" if touch is enabled. Else returns "mouse"
  42875. */
  42876. static GetPointerPrefix(engine: Engine): string;
  42877. /**
  42878. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  42879. * @param url define the url we are trying
  42880. * @param element define the dom element where to configure the cors policy
  42881. */
  42882. static SetCorsBehavior(url: string | string[], element: {
  42883. crossOrigin: string | null;
  42884. }): void;
  42885. /**
  42886. * Removes unwanted characters from an url
  42887. * @param url defines the url to clean
  42888. * @returns the cleaned url
  42889. */
  42890. static CleanUrl(url: string): string;
  42891. /**
  42892. * Gets or sets a function used to pre-process url before using them to load assets
  42893. */
  42894. static get PreprocessUrl(): (url: string) => string;
  42895. static set PreprocessUrl(processor: (url: string) => string);
  42896. /**
  42897. * Loads an image as an HTMLImageElement.
  42898. * @param input url string, ArrayBuffer, or Blob to load
  42899. * @param onLoad callback called when the image successfully loads
  42900. * @param onError callback called when the image fails to load
  42901. * @param offlineProvider offline provider for caching
  42902. * @param mimeType optional mime type
  42903. * @returns the HTMLImageElement of the loaded image
  42904. */
  42905. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  42906. /**
  42907. * Loads a file from a url
  42908. * @param url url string, ArrayBuffer, or Blob to load
  42909. * @param onSuccess callback called when the file successfully loads
  42910. * @param onProgress callback called while file is loading (if the server supports this mode)
  42911. * @param offlineProvider defines the offline provider for caching
  42912. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42913. * @param onError callback called when the file fails to load
  42914. * @returns a file request object
  42915. */
  42916. 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;
  42917. /**
  42918. * Loads a file from a url
  42919. * @param url the file url to load
  42920. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42921. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  42922. */
  42923. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  42924. /**
  42925. * Load a script (identified by an url). When the url returns, the
  42926. * content of this file is added into a new script element, attached to the DOM (body element)
  42927. * @param scriptUrl defines the url of the script to laod
  42928. * @param onSuccess defines the callback called when the script is loaded
  42929. * @param onError defines the callback to call if an error occurs
  42930. * @param scriptId defines the id of the script element
  42931. */
  42932. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  42933. /**
  42934. * Load an asynchronous script (identified by an url). When the url returns, the
  42935. * content of this file is added into a new script element, attached to the DOM (body element)
  42936. * @param scriptUrl defines the url of the script to laod
  42937. * @param scriptId defines the id of the script element
  42938. * @returns a promise request object
  42939. */
  42940. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  42941. /**
  42942. * Loads a file from a blob
  42943. * @param fileToLoad defines the blob to use
  42944. * @param callback defines the callback to call when data is loaded
  42945. * @param progressCallback defines the callback to call during loading process
  42946. * @returns a file request object
  42947. */
  42948. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  42949. /**
  42950. * Reads a file from a File object
  42951. * @param file defines the file to load
  42952. * @param onSuccess defines the callback to call when data is loaded
  42953. * @param onProgress defines the callback to call during loading process
  42954. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42955. * @param onError defines the callback to call when an error occurs
  42956. * @returns a file request object
  42957. */
  42958. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42959. /**
  42960. * Creates a data url from a given string content
  42961. * @param content defines the content to convert
  42962. * @returns the new data url link
  42963. */
  42964. static FileAsURL(content: string): string;
  42965. /**
  42966. * Format the given number to a specific decimal format
  42967. * @param value defines the number to format
  42968. * @param decimals defines the number of decimals to use
  42969. * @returns the formatted string
  42970. */
  42971. static Format(value: number, decimals?: number): string;
  42972. /**
  42973. * Tries to copy an object by duplicating every property
  42974. * @param source defines the source object
  42975. * @param destination defines the target object
  42976. * @param doNotCopyList defines a list of properties to avoid
  42977. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  42978. */
  42979. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  42980. /**
  42981. * Gets a boolean indicating if the given object has no own property
  42982. * @param obj defines the object to test
  42983. * @returns true if object has no own property
  42984. */
  42985. static IsEmpty(obj: any): boolean;
  42986. /**
  42987. * Function used to register events at window level
  42988. * @param windowElement defines the Window object to use
  42989. * @param events defines the events to register
  42990. */
  42991. static RegisterTopRootEvents(windowElement: Window, events: {
  42992. name: string;
  42993. handler: Nullable<(e: FocusEvent) => any>;
  42994. }[]): void;
  42995. /**
  42996. * Function used to unregister events from window level
  42997. * @param windowElement defines the Window object to use
  42998. * @param events defines the events to unregister
  42999. */
  43000. static UnregisterTopRootEvents(windowElement: Window, events: {
  43001. name: string;
  43002. handler: Nullable<(e: FocusEvent) => any>;
  43003. }[]): void;
  43004. /**
  43005. * @ignore
  43006. */
  43007. static _ScreenshotCanvas: HTMLCanvasElement;
  43008. /**
  43009. * Dumps the current bound framebuffer
  43010. * @param width defines the rendering width
  43011. * @param height defines the rendering height
  43012. * @param engine defines the hosting engine
  43013. * @param successCallback defines the callback triggered once the data are available
  43014. * @param mimeType defines the mime type of the result
  43015. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43016. * @return a void promise
  43017. */
  43018. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): Promise<void>;
  43019. /**
  43020. * Dumps an array buffer
  43021. * @param width defines the rendering width
  43022. * @param height defines the rendering height
  43023. * @param data the data array
  43024. * @param successCallback defines the callback triggered once the data are available
  43025. * @param mimeType defines the mime type of the result
  43026. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43027. * @param invertY true to invert the picture in the Y dimension
  43028. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43029. */
  43030. static DumpData(width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): void;
  43031. /**
  43032. * Dumps an array buffer
  43033. * @param width defines the rendering width
  43034. * @param height defines the rendering height
  43035. * @param data the data array
  43036. * @param successCallback defines the callback triggered once the data are available
  43037. * @param mimeType defines the mime type of the result
  43038. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43039. * @param invertY true to invert the picture in the Y dimension
  43040. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43041. * @return a promise that resolve to the final data
  43042. */
  43043. static DumpDataAsync(width: number, height: number, data: ArrayBufferView, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  43044. /**
  43045. * Converts the canvas data to blob.
  43046. * This acts as a polyfill for browsers not supporting the to blob function.
  43047. * @param canvas Defines the canvas to extract the data from
  43048. * @param successCallback Defines the callback triggered once the data are available
  43049. * @param mimeType Defines the mime type of the result
  43050. */
  43051. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43052. /**
  43053. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43054. * @param successCallback defines the callback triggered once the data are available
  43055. * @param mimeType defines the mime type of the result
  43056. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43057. * @param canvas canvas to get the data from. If not provided, use the default screenshot canvas
  43058. */
  43059. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string, canvas?: HTMLCanvasElement): void;
  43060. /**
  43061. * Downloads a blob in the browser
  43062. * @param blob defines the blob to download
  43063. * @param fileName defines the name of the downloaded file
  43064. */
  43065. static Download(blob: Blob, fileName: string): void;
  43066. /**
  43067. * Will return the right value of the noPreventDefault variable
  43068. * Needed to keep backwards compatibility to the old API.
  43069. *
  43070. * @param args arguments passed to the attachControl function
  43071. * @returns the correct value for noPreventDefault
  43072. */
  43073. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  43074. /**
  43075. * Captures a screenshot of the current rendering
  43076. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43077. * @param engine defines the rendering engine
  43078. * @param camera defines the source camera
  43079. * @param size This parameter can be set to a single number or to an object with the
  43080. * following (optional) properties: precision, width, height. If a single number is passed,
  43081. * it will be used for both width and height. If an object is passed, the screenshot size
  43082. * will be derived from the parameters. The precision property is a multiplier allowing
  43083. * rendering at a higher or lower resolution
  43084. * @param successCallback defines the callback receives a single parameter which contains the
  43085. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43086. * src parameter of an <img> to display it
  43087. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43088. * Check your browser for supported MIME types
  43089. */
  43090. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43091. /**
  43092. * Captures a screenshot of the current rendering
  43093. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43094. * @param engine defines the rendering engine
  43095. * @param camera defines the source camera
  43096. * @param size This parameter can be set to a single number or to an object with the
  43097. * following (optional) properties: precision, width, height. If a single number is passed,
  43098. * it will be used for both width and height. If an object is passed, the screenshot size
  43099. * will be derived from the parameters. The precision property is a multiplier allowing
  43100. * rendering at a higher or lower resolution
  43101. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43102. * Check your browser for supported MIME types
  43103. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43104. * to the src parameter of an <img> to display it
  43105. */
  43106. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43107. /**
  43108. * Generates an image screenshot from the specified camera.
  43109. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43110. * @param engine The engine to use for rendering
  43111. * @param camera The camera to use for rendering
  43112. * @param size This parameter can be set to a single number or to an object with the
  43113. * following (optional) properties: precision, width, height. If a single number is passed,
  43114. * it will be used for both width and height. If an object is passed, the screenshot size
  43115. * will be derived from the parameters. The precision property is a multiplier allowing
  43116. * rendering at a higher or lower resolution
  43117. * @param successCallback The callback receives a single parameter which contains the
  43118. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43119. * src parameter of an <img> to display it
  43120. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43121. * Check your browser for supported MIME types
  43122. * @param samples Texture samples (default: 1)
  43123. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43124. * @param fileName A name for for the downloaded file.
  43125. */
  43126. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43127. /**
  43128. * Generates an image screenshot from the specified camera.
  43129. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43130. * @param engine The engine to use for rendering
  43131. * @param camera The camera to use for rendering
  43132. * @param size This parameter can be set to a single number or to an object with the
  43133. * following (optional) properties: precision, width, height. If a single number is passed,
  43134. * it will be used for both width and height. If an object is passed, the screenshot size
  43135. * will be derived from the parameters. The precision property is a multiplier allowing
  43136. * rendering at a higher or lower resolution
  43137. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43138. * Check your browser for supported MIME types
  43139. * @param samples Texture samples (default: 1)
  43140. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43141. * @param fileName A name for for the downloaded file.
  43142. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43143. * to the src parameter of an <img> to display it
  43144. */
  43145. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43146. /**
  43147. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43148. * Be aware Math.random() could cause collisions, but:
  43149. * "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"
  43150. * @returns a pseudo random id
  43151. */
  43152. static RandomId(): string;
  43153. /**
  43154. * Test if the given uri is a base64 string
  43155. * @param uri The uri to test
  43156. * @return True if the uri is a base64 string or false otherwise
  43157. */
  43158. static IsBase64(uri: string): boolean;
  43159. /**
  43160. * Decode the given base64 uri.
  43161. * @param uri The uri to decode
  43162. * @return The decoded base64 data.
  43163. */
  43164. static DecodeBase64(uri: string): ArrayBuffer;
  43165. /**
  43166. * Gets the absolute url.
  43167. * @param url the input url
  43168. * @return the absolute url
  43169. */
  43170. static GetAbsoluteUrl(url: string): string;
  43171. /**
  43172. * No log
  43173. */
  43174. static readonly NoneLogLevel: number;
  43175. /**
  43176. * Only message logs
  43177. */
  43178. static readonly MessageLogLevel: number;
  43179. /**
  43180. * Only warning logs
  43181. */
  43182. static readonly WarningLogLevel: number;
  43183. /**
  43184. * Only error logs
  43185. */
  43186. static readonly ErrorLogLevel: number;
  43187. /**
  43188. * All logs
  43189. */
  43190. static readonly AllLogLevel: number;
  43191. /**
  43192. * Gets a value indicating the number of loading errors
  43193. * @ignorenaming
  43194. */
  43195. static get errorsCount(): number;
  43196. /**
  43197. * Callback called when a new log is added
  43198. */
  43199. static OnNewCacheEntry: (entry: string) => void;
  43200. /**
  43201. * Log a message to the console
  43202. * @param message defines the message to log
  43203. */
  43204. static Log(message: string): void;
  43205. /**
  43206. * Write a warning message to the console
  43207. * @param message defines the message to log
  43208. */
  43209. static Warn(message: string): void;
  43210. /**
  43211. * Write an error message to the console
  43212. * @param message defines the message to log
  43213. */
  43214. static Error(message: string): void;
  43215. /**
  43216. * Gets current log cache (list of logs)
  43217. */
  43218. static get LogCache(): string;
  43219. /**
  43220. * Clears the log cache
  43221. */
  43222. static ClearLogCache(): void;
  43223. /**
  43224. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43225. */
  43226. static set LogLevels(level: number);
  43227. /**
  43228. * Checks if the window object exists
  43229. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43230. */
  43231. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43232. /**
  43233. * No performance log
  43234. */
  43235. static readonly PerformanceNoneLogLevel: number;
  43236. /**
  43237. * Use user marks to log performance
  43238. */
  43239. static readonly PerformanceUserMarkLogLevel: number;
  43240. /**
  43241. * Log performance to the console
  43242. */
  43243. static readonly PerformanceConsoleLogLevel: number;
  43244. private static _performance;
  43245. /**
  43246. * Sets the current performance log level
  43247. */
  43248. static set PerformanceLogLevel(level: number);
  43249. private static _StartPerformanceCounterDisabled;
  43250. private static _EndPerformanceCounterDisabled;
  43251. private static _StartUserMark;
  43252. private static _EndUserMark;
  43253. private static _StartPerformanceConsole;
  43254. private static _EndPerformanceConsole;
  43255. /**
  43256. * Starts a performance counter
  43257. */
  43258. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43259. /**
  43260. * Ends a specific performance coutner
  43261. */
  43262. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43263. /**
  43264. * Gets either window.performance.now() if supported or Date.now() else
  43265. */
  43266. static get Now(): number;
  43267. /**
  43268. * This method will return the name of the class used to create the instance of the given object.
  43269. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43270. * @param object the object to get the class name from
  43271. * @param isType defines if the object is actually a type
  43272. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43273. */
  43274. static GetClassName(object: any, isType?: boolean): string;
  43275. /**
  43276. * Gets the first element of an array satisfying a given predicate
  43277. * @param array defines the array to browse
  43278. * @param predicate defines the predicate to use
  43279. * @returns null if not found or the element
  43280. */
  43281. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43282. /**
  43283. * This method will return the name of the full name of the class, including its owning module (if any).
  43284. * 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).
  43285. * @param object the object to get the class name from
  43286. * @param isType defines if the object is actually a type
  43287. * @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.
  43288. * @ignorenaming
  43289. */
  43290. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43291. /**
  43292. * Returns a promise that resolves after the given amount of time.
  43293. * @param delay Number of milliseconds to delay
  43294. * @returns Promise that resolves after the given amount of time
  43295. */
  43296. static DelayAsync(delay: number): Promise<void>;
  43297. /**
  43298. * Utility function to detect if the current user agent is Safari
  43299. * @returns whether or not the current user agent is safari
  43300. */
  43301. static IsSafari(): boolean;
  43302. }
  43303. /**
  43304. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43305. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43306. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43307. * @param name The name of the class, case should be preserved
  43308. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43309. */
  43310. export function className(name: string, module?: string): (target: Object) => void;
  43311. /**
  43312. * An implementation of a loop for asynchronous functions.
  43313. */
  43314. export class AsyncLoop {
  43315. /**
  43316. * Defines the number of iterations for the loop
  43317. */
  43318. iterations: number;
  43319. /**
  43320. * Defines the current index of the loop.
  43321. */
  43322. index: number;
  43323. private _done;
  43324. private _fn;
  43325. private _successCallback;
  43326. /**
  43327. * Constructor.
  43328. * @param iterations the number of iterations.
  43329. * @param func the function to run each iteration
  43330. * @param successCallback the callback that will be called upon succesful execution
  43331. * @param offset starting offset.
  43332. */
  43333. constructor(
  43334. /**
  43335. * Defines the number of iterations for the loop
  43336. */
  43337. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43338. /**
  43339. * Execute the next iteration. Must be called after the last iteration was finished.
  43340. */
  43341. executeNext(): void;
  43342. /**
  43343. * Break the loop and run the success callback.
  43344. */
  43345. breakLoop(): void;
  43346. /**
  43347. * Create and run an async loop.
  43348. * @param iterations the number of iterations.
  43349. * @param fn the function to run each iteration
  43350. * @param successCallback the callback that will be called upon succesful execution
  43351. * @param offset starting offset.
  43352. * @returns the created async loop object
  43353. */
  43354. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43355. /**
  43356. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43357. * @param iterations total number of iterations
  43358. * @param syncedIterations number of synchronous iterations in each async iteration.
  43359. * @param fn the function to call each iteration.
  43360. * @param callback a success call back that will be called when iterating stops.
  43361. * @param breakFunction a break condition (optional)
  43362. * @param timeout timeout settings for the setTimeout function. default - 0.
  43363. * @returns the created async loop object
  43364. */
  43365. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43366. }
  43367. }
  43368. declare module BABYLON {
  43369. /**
  43370. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43371. * The underlying implementation relies on an associative array to ensure the best performances.
  43372. * The value can be anything including 'null' but except 'undefined'
  43373. */
  43374. export class StringDictionary<T> {
  43375. /**
  43376. * This will clear this dictionary and copy the content from the 'source' one.
  43377. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43378. * @param source the dictionary to take the content from and copy to this dictionary
  43379. */
  43380. copyFrom(source: StringDictionary<T>): void;
  43381. /**
  43382. * Get a value based from its key
  43383. * @param key the given key to get the matching value from
  43384. * @return the value if found, otherwise undefined is returned
  43385. */
  43386. get(key: string): T | undefined;
  43387. /**
  43388. * Get a value from its key or add it if it doesn't exist.
  43389. * This method will ensure you that a given key/data will be present in the dictionary.
  43390. * @param key the given key to get the matching value from
  43391. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43392. * The factory will only be invoked if there's no data for the given key.
  43393. * @return the value corresponding to the key.
  43394. */
  43395. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43396. /**
  43397. * Get a value from its key if present in the dictionary otherwise add it
  43398. * @param key the key to get the value from
  43399. * @param val if there's no such key/value pair in the dictionary add it with this value
  43400. * @return the value corresponding to the key
  43401. */
  43402. getOrAdd(key: string, val: T): T;
  43403. /**
  43404. * Check if there's a given key in the dictionary
  43405. * @param key the key to check for
  43406. * @return true if the key is present, false otherwise
  43407. */
  43408. contains(key: string): boolean;
  43409. /**
  43410. * Add a new key and its corresponding value
  43411. * @param key the key to add
  43412. * @param value the value corresponding to the key
  43413. * @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
  43414. */
  43415. add(key: string, value: T): boolean;
  43416. /**
  43417. * Update a specific value associated to a key
  43418. * @param key defines the key to use
  43419. * @param value defines the value to store
  43420. * @returns true if the value was updated (or false if the key was not found)
  43421. */
  43422. set(key: string, value: T): boolean;
  43423. /**
  43424. * Get the element of the given key and remove it from the dictionary
  43425. * @param key defines the key to search
  43426. * @returns the value associated with the key or null if not found
  43427. */
  43428. getAndRemove(key: string): Nullable<T>;
  43429. /**
  43430. * Remove a key/value from the dictionary.
  43431. * @param key the key to remove
  43432. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43433. */
  43434. remove(key: string): boolean;
  43435. /**
  43436. * Clear the whole content of the dictionary
  43437. */
  43438. clear(): void;
  43439. /**
  43440. * Gets the current count
  43441. */
  43442. get count(): number;
  43443. /**
  43444. * Execute a callback on each key/val of the dictionary.
  43445. * Note that you can remove any element in this dictionary in the callback implementation
  43446. * @param callback the callback to execute on a given key/value pair
  43447. */
  43448. forEach(callback: (key: string, val: T) => void): void;
  43449. /**
  43450. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43451. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43452. * Note that you can remove any element in this dictionary in the callback implementation
  43453. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43454. * @returns the first item
  43455. */
  43456. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43457. private _count;
  43458. private _data;
  43459. }
  43460. }
  43461. declare module BABYLON {
  43462. /** @hidden */
  43463. export interface ICollisionCoordinator {
  43464. createCollider(): Collider;
  43465. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43466. init(scene: Scene): void;
  43467. }
  43468. /** @hidden */
  43469. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43470. private _scene;
  43471. private _scaledPosition;
  43472. private _scaledVelocity;
  43473. private _finalPosition;
  43474. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43475. createCollider(): Collider;
  43476. init(scene: Scene): void;
  43477. private _collideWithWorld;
  43478. }
  43479. }
  43480. declare module BABYLON {
  43481. /**
  43482. * Class used to manage all inputs for the scene.
  43483. */
  43484. export class InputManager {
  43485. /** The distance in pixel that you have to move to prevent some events */
  43486. static DragMovementThreshold: number;
  43487. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43488. static LongPressDelay: number;
  43489. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43490. static DoubleClickDelay: number;
  43491. /** If you need to check double click without raising a single click at first click, enable this flag */
  43492. static ExclusiveDoubleClickMode: boolean;
  43493. /** 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. */
  43494. private _alreadyAttached;
  43495. private _alreadyAttachedTo;
  43496. private _wheelEventName;
  43497. private _onPointerMove;
  43498. private _onPointerDown;
  43499. private _onPointerUp;
  43500. private _initClickEvent;
  43501. private _initActionManager;
  43502. private _delayedSimpleClick;
  43503. private _delayedSimpleClickTimeout;
  43504. private _previousDelayedSimpleClickTimeout;
  43505. private _meshPickProceed;
  43506. private _previousButtonPressed;
  43507. private _currentPickResult;
  43508. private _previousPickResult;
  43509. private _totalPointersPressed;
  43510. private _doubleClickOccured;
  43511. private _pointerOverMesh;
  43512. private _pickedDownMesh;
  43513. private _pickedUpMesh;
  43514. private _pointerX;
  43515. private _pointerY;
  43516. private _unTranslatedPointerX;
  43517. private _unTranslatedPointerY;
  43518. private _startingPointerPosition;
  43519. private _previousStartingPointerPosition;
  43520. private _startingPointerTime;
  43521. private _previousStartingPointerTime;
  43522. private _pointerCaptures;
  43523. private _meshUnderPointerId;
  43524. private _onKeyDown;
  43525. private _onKeyUp;
  43526. private _keyboardIsAttached;
  43527. private _onCanvasFocusObserver;
  43528. private _onCanvasBlurObserver;
  43529. private _scene;
  43530. /**
  43531. * Creates a new InputManager
  43532. * @param scene defines the hosting scene
  43533. */
  43534. constructor(scene: Scene);
  43535. /**
  43536. * Gets the mesh that is currently under the pointer
  43537. */
  43538. get meshUnderPointer(): Nullable<AbstractMesh>;
  43539. /**
  43540. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  43541. * @param pointerId the pointer id to use
  43542. * @returns The mesh under this pointer id or null if not found
  43543. */
  43544. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  43545. /**
  43546. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  43547. */
  43548. get unTranslatedPointer(): Vector2;
  43549. /**
  43550. * Gets or sets the current on-screen X position of the pointer
  43551. */
  43552. get pointerX(): number;
  43553. set pointerX(value: number);
  43554. /**
  43555. * Gets or sets the current on-screen Y position of the pointer
  43556. */
  43557. get pointerY(): number;
  43558. set pointerY(value: number);
  43559. private _updatePointerPosition;
  43560. private _processPointerMove;
  43561. private _setRayOnPointerInfo;
  43562. private _checkPrePointerObservable;
  43563. /**
  43564. * Use this method to simulate a pointer move on a mesh
  43565. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43566. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43567. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43568. */
  43569. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43570. /**
  43571. * Use this method to simulate a pointer down on a mesh
  43572. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43573. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43574. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43575. */
  43576. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43577. private _processPointerDown;
  43578. /** @hidden */
  43579. _isPointerSwiping(): boolean;
  43580. /**
  43581. * Use this method to simulate a pointer up on a mesh
  43582. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43583. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43584. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43585. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43586. */
  43587. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  43588. private _processPointerUp;
  43589. /**
  43590. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43591. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43592. * @returns true if the pointer was captured
  43593. */
  43594. isPointerCaptured(pointerId?: number): boolean;
  43595. /**
  43596. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43597. * @param attachUp defines if you want to attach events to pointerup
  43598. * @param attachDown defines if you want to attach events to pointerdown
  43599. * @param attachMove defines if you want to attach events to pointermove
  43600. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  43601. */
  43602. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  43603. /**
  43604. * Detaches all event handlers
  43605. */
  43606. detachControl(): void;
  43607. /**
  43608. * Force the value of meshUnderPointer
  43609. * @param mesh defines the mesh to use
  43610. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  43611. */
  43612. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  43613. /**
  43614. * Gets the mesh under the pointer
  43615. * @returns a Mesh or null if no mesh is under the pointer
  43616. */
  43617. getPointerOverMesh(): Nullable<AbstractMesh>;
  43618. }
  43619. }
  43620. declare module BABYLON {
  43621. /**
  43622. * This class defines the direct association between an animation and a target
  43623. */
  43624. export class TargetedAnimation {
  43625. /**
  43626. * Animation to perform
  43627. */
  43628. animation: Animation;
  43629. /**
  43630. * Target to animate
  43631. */
  43632. target: any;
  43633. /**
  43634. * Returns the string "TargetedAnimation"
  43635. * @returns "TargetedAnimation"
  43636. */
  43637. getClassName(): string;
  43638. /**
  43639. * Serialize the object
  43640. * @returns the JSON object representing the current entity
  43641. */
  43642. serialize(): any;
  43643. }
  43644. /**
  43645. * Use this class to create coordinated animations on multiple targets
  43646. */
  43647. export class AnimationGroup implements IDisposable {
  43648. /** The name of the animation group */
  43649. name: string;
  43650. private _scene;
  43651. private _targetedAnimations;
  43652. private _animatables;
  43653. private _from;
  43654. private _to;
  43655. private _isStarted;
  43656. private _isPaused;
  43657. private _speedRatio;
  43658. private _loopAnimation;
  43659. private _isAdditive;
  43660. /**
  43661. * Gets or sets the unique id of the node
  43662. */
  43663. uniqueId: number;
  43664. /**
  43665. * This observable will notify when one animation have ended
  43666. */
  43667. onAnimationEndObservable: Observable<TargetedAnimation>;
  43668. /**
  43669. * Observer raised when one animation loops
  43670. */
  43671. onAnimationLoopObservable: Observable<TargetedAnimation>;
  43672. /**
  43673. * Observer raised when all animations have looped
  43674. */
  43675. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  43676. /**
  43677. * This observable will notify when all animations have ended.
  43678. */
  43679. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  43680. /**
  43681. * This observable will notify when all animations have paused.
  43682. */
  43683. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  43684. /**
  43685. * This observable will notify when all animations are playing.
  43686. */
  43687. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  43688. /**
  43689. * Gets the first frame
  43690. */
  43691. get from(): number;
  43692. /**
  43693. * Gets the last frame
  43694. */
  43695. get to(): number;
  43696. /**
  43697. * Define if the animations are started
  43698. */
  43699. get isStarted(): boolean;
  43700. /**
  43701. * Gets a value indicating that the current group is playing
  43702. */
  43703. get isPlaying(): boolean;
  43704. /**
  43705. * Gets or sets the speed ratio to use for all animations
  43706. */
  43707. get speedRatio(): number;
  43708. /**
  43709. * Gets or sets the speed ratio to use for all animations
  43710. */
  43711. set speedRatio(value: number);
  43712. /**
  43713. * Gets or sets if all animations should loop or not
  43714. */
  43715. get loopAnimation(): boolean;
  43716. set loopAnimation(value: boolean);
  43717. /**
  43718. * Gets or sets if all animations should be evaluated additively
  43719. */
  43720. get isAdditive(): boolean;
  43721. set isAdditive(value: boolean);
  43722. /**
  43723. * Gets the targeted animations for this animation group
  43724. */
  43725. get targetedAnimations(): Array<TargetedAnimation>;
  43726. /**
  43727. * returning the list of animatables controlled by this animation group.
  43728. */
  43729. get animatables(): Array<Animatable>;
  43730. /**
  43731. * Gets the list of target animations
  43732. */
  43733. get children(): TargetedAnimation[];
  43734. /**
  43735. * Instantiates a new Animation Group.
  43736. * This helps managing several animations at once.
  43737. * @see https://doc.babylonjs.com/how_to/group
  43738. * @param name Defines the name of the group
  43739. * @param scene Defines the scene the group belongs to
  43740. */
  43741. constructor(
  43742. /** The name of the animation group */
  43743. name: string, scene?: Nullable<Scene>);
  43744. /**
  43745. * Add an animation (with its target) in the group
  43746. * @param animation defines the animation we want to add
  43747. * @param target defines the target of the animation
  43748. * @returns the TargetedAnimation object
  43749. */
  43750. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  43751. /**
  43752. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  43753. * It can add constant keys at begin or end
  43754. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  43755. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  43756. * @returns the animation group
  43757. */
  43758. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  43759. private _animationLoopCount;
  43760. private _animationLoopFlags;
  43761. private _processLoop;
  43762. /**
  43763. * Start all animations on given targets
  43764. * @param loop defines if animations must loop
  43765. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  43766. * @param from defines the from key (optional)
  43767. * @param to defines the to key (optional)
  43768. * @param isAdditive defines the additive state for the resulting animatables (optional)
  43769. * @returns the current animation group
  43770. */
  43771. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  43772. /**
  43773. * Pause all animations
  43774. * @returns the animation group
  43775. */
  43776. pause(): AnimationGroup;
  43777. /**
  43778. * Play all animations to initial state
  43779. * This function will start() the animations if they were not started or will restart() them if they were paused
  43780. * @param loop defines if animations must loop
  43781. * @returns the animation group
  43782. */
  43783. play(loop?: boolean): AnimationGroup;
  43784. /**
  43785. * Reset all animations to initial state
  43786. * @returns the animation group
  43787. */
  43788. reset(): AnimationGroup;
  43789. /**
  43790. * Restart animations from key 0
  43791. * @returns the animation group
  43792. */
  43793. restart(): AnimationGroup;
  43794. /**
  43795. * Stop all animations
  43796. * @returns the animation group
  43797. */
  43798. stop(): AnimationGroup;
  43799. /**
  43800. * Set animation weight for all animatables
  43801. * @param weight defines the weight to use
  43802. * @return the animationGroup
  43803. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43804. */
  43805. setWeightForAllAnimatables(weight: number): AnimationGroup;
  43806. /**
  43807. * Synchronize and normalize all animatables with a source animatable
  43808. * @param root defines the root animatable to synchronize with
  43809. * @return the animationGroup
  43810. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43811. */
  43812. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  43813. /**
  43814. * Goes to a specific frame in this animation group
  43815. * @param frame the frame number to go to
  43816. * @return the animationGroup
  43817. */
  43818. goToFrame(frame: number): AnimationGroup;
  43819. /**
  43820. * Dispose all associated resources
  43821. */
  43822. dispose(): void;
  43823. private _checkAnimationGroupEnded;
  43824. /**
  43825. * Clone the current animation group and returns a copy
  43826. * @param newName defines the name of the new group
  43827. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  43828. * @returns the new aniamtion group
  43829. */
  43830. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  43831. /**
  43832. * Serializes the animationGroup to an object
  43833. * @returns Serialized object
  43834. */
  43835. serialize(): any;
  43836. /**
  43837. * Returns a new AnimationGroup object parsed from the source provided.
  43838. * @param parsedAnimationGroup defines the source
  43839. * @param scene defines the scene that will receive the animationGroup
  43840. * @returns a new AnimationGroup
  43841. */
  43842. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  43843. /**
  43844. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  43845. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  43846. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  43847. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  43848. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  43849. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  43850. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  43851. */
  43852. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  43853. /**
  43854. * Returns the string "AnimationGroup"
  43855. * @returns "AnimationGroup"
  43856. */
  43857. getClassName(): string;
  43858. /**
  43859. * Creates a detailled string about the object
  43860. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  43861. * @returns a string representing the object
  43862. */
  43863. toString(fullDetails?: boolean): string;
  43864. }
  43865. }
  43866. declare module BABYLON {
  43867. /**
  43868. * @hidden
  43869. **/
  43870. export class _TimeToken {
  43871. _startTimeQuery: Nullable<WebGLQuery>;
  43872. _endTimeQuery: Nullable<WebGLQuery>;
  43873. _timeElapsedQuery: Nullable<WebGLQuery>;
  43874. _timeElapsedQueryEnded: boolean;
  43875. }
  43876. }
  43877. declare module BABYLON {
  43878. /** @hidden */
  43879. export enum ExtensionName {
  43880. DepthClamping = "depth-clamping",
  43881. Depth24UnormStencil8 = "depth24unorm-stencil8",
  43882. Depth32FloatStencil8 = "depth32float-stencil8",
  43883. PipelineStatisticsQuery = "pipeline-statistics-query",
  43884. TextureCompressionBC = "texture-compression-bc",
  43885. TimestampQuery = "timestamp-query"
  43886. }
  43887. /** @hidden */
  43888. export enum AddressMode {
  43889. ClampToEdge = "clamp-to-edge",
  43890. Repeat = "repeat",
  43891. MirrorRepeat = "mirror-repeat"
  43892. }
  43893. /** @hidden */
  43894. export enum BindingType {
  43895. UniformBuffer = "uniform-buffer",
  43896. StorageBuffer = "storage-buffer",
  43897. ReadonlyStorageBuffer = "readonly-storage-buffer",
  43898. Sampler = "sampler",
  43899. ComparisonSampler = "comparison-sampler",
  43900. SampledTexture = "sampled-texture",
  43901. ReadonlyStorageTexture = "readonly-storage-texture",
  43902. WriteonlyStorageTexture = "writeonly-storage-texture"
  43903. }
  43904. /** @hidden */
  43905. export enum BlendFactor {
  43906. Zero = "zero",
  43907. One = "one",
  43908. SrcColor = "src-color",
  43909. OneMinusSrcColor = "one-minus-src-color",
  43910. SrcAlpha = "src-alpha",
  43911. OneMinusSrcAlpha = "one-minus-src-alpha",
  43912. DstColor = "dst-color",
  43913. OneMinusDstColor = "one-minus-dst-color",
  43914. DstAlpha = "dst-alpha",
  43915. OneMinusDstAlpha = "one-minus-dst-alpha",
  43916. SrcAlphaSaturated = "src-alpha-saturated",
  43917. BlendColor = "blend-color",
  43918. OneMinusBlendColor = "one-minus-blend-color"
  43919. }
  43920. /** @hidden */
  43921. export enum BlendOperation {
  43922. Add = "add",
  43923. Subtract = "subtract",
  43924. ReverseSubtract = "reverse-subtract",
  43925. Min = "min",
  43926. Max = "max"
  43927. }
  43928. /** @hidden */
  43929. export enum CompareFunction {
  43930. Never = "never",
  43931. Less = "less",
  43932. Equal = "equal",
  43933. LessEqual = "less-equal",
  43934. Greater = "greater",
  43935. NotEqual = "not-equal",
  43936. GreaterEqual = "greater-equal",
  43937. Always = "always"
  43938. }
  43939. /** @hidden */
  43940. export enum CullMode {
  43941. None = "none",
  43942. Front = "front",
  43943. Back = "back"
  43944. }
  43945. /** @hidden */
  43946. export enum FilterMode {
  43947. Nearest = "nearest",
  43948. Linear = "linear"
  43949. }
  43950. /** @hidden */
  43951. export enum FrontFace {
  43952. CCW = "ccw",
  43953. CW = "cw"
  43954. }
  43955. /** @hidden */
  43956. export enum IndexFormat {
  43957. Uint16 = "uint16",
  43958. Uint32 = "uint32"
  43959. }
  43960. /** @hidden */
  43961. export enum InputStepMode {
  43962. Vertex = "vertex",
  43963. Instance = "instance"
  43964. }
  43965. /** @hidden */
  43966. export enum LoadOp {
  43967. Load = "load"
  43968. }
  43969. /** @hidden */
  43970. export enum PrimitiveTopology {
  43971. PointList = "point-list",
  43972. LineList = "line-list",
  43973. LineStrip = "line-strip",
  43974. TriangleList = "triangle-list",
  43975. TriangleStrip = "triangle-strip"
  43976. }
  43977. /** @hidden */
  43978. export enum StencilOperation {
  43979. Keep = "keep",
  43980. Zero = "zero",
  43981. Replace = "replace",
  43982. Invert = "invert",
  43983. IncrementClamp = "increment-clamp",
  43984. DecrementClamp = "decrement-clamp",
  43985. IncrementWrap = "increment-wrap",
  43986. DecrementWrap = "decrement-wrap"
  43987. }
  43988. /** @hidden */
  43989. export enum StoreOp {
  43990. Store = "store",
  43991. Clear = "clear"
  43992. }
  43993. /** @hidden */
  43994. export enum TextureDimension {
  43995. E1d = "1d",
  43996. E2d = "2d",
  43997. E3d = "3d"
  43998. }
  43999. /** @hidden */
  44000. export enum TextureFormat {
  44001. R8Unorm = "r8unorm",
  44002. R8Snorm = "r8snorm",
  44003. R8Uint = "r8uint",
  44004. R8Sint = "r8sint",
  44005. R16Uint = "r16uint",
  44006. R16Sint = "r16sint",
  44007. R16Float = "r16float",
  44008. RG8Unorm = "rg8unorm",
  44009. RG8Snorm = "rg8snorm",
  44010. RG8Uint = "rg8uint",
  44011. RG8Sint = "rg8sint",
  44012. R32Uint = "r32uint",
  44013. R32Sint = "r32sint",
  44014. R32Float = "r32float",
  44015. RG16Uint = "rg16uint",
  44016. RG16Sint = "rg16sint",
  44017. RG16Float = "rg16float",
  44018. RGBA8Unorm = "rgba8unorm",
  44019. RGBA8UnormSRGB = "rgba8unorm-srgb",
  44020. RGBA8Snorm = "rgba8snorm",
  44021. RGBA8Uint = "rgba8uint",
  44022. RGBA8Sint = "rgba8sint",
  44023. BGRA8Unorm = "bgra8unorm",
  44024. BGRA8UnormSRGB = "bgra8unorm-srgb",
  44025. RGB9E5UFloat = "rgb9e5ufloat",
  44026. RGB10A2Unorm = "rgb10a2unorm",
  44027. RG11B10UFloat = "rg11b10ufloat",
  44028. RG32Uint = "rg32uint",
  44029. RG32Sint = "rg32sint",
  44030. RG32Float = "rg32float",
  44031. RGBA16Uint = "rgba16uint",
  44032. RGBA16Sint = "rgba16sint",
  44033. RGBA16Float = "rgba16float",
  44034. RGBA32Uint = "rgba32uint",
  44035. RGBA32Sint = "rgba32sint",
  44036. RGBA32Float = "rgba32float",
  44037. Stencil8 = "stencil8",
  44038. Depth16Unorm = "depth16unorm",
  44039. Depth24Plus = "depth24plus",
  44040. Depth24PlusStencil8 = "depth24plus-stencil8",
  44041. Depth32Float = "depth32float",
  44042. BC1RGBAUNorm = "bc1-rgba-unorm",
  44043. BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
  44044. BC2RGBAUnorm = "bc2-rgba-unorm",
  44045. BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
  44046. BC3RGBAUnorm = "bc3-rgba-unorm",
  44047. BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
  44048. BC4RUnorm = "bc4-r-unorm",
  44049. BC4RSnorm = "bc4-r-snorm",
  44050. BC5RGUnorm = "bc5-rg-unorm",
  44051. BC5RGSnorm = "bc5-rg-snorm",
  44052. BC6HRGBUFloat = "bc6h-rgb-ufloat",
  44053. BC6HRGBFloat = "bc6h-rgb-float",
  44054. BC7RGBAUnorm = "bc7-rgba-unorm",
  44055. BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
  44056. Depth24UnormStencil8 = "depth24unorm-stencil8",
  44057. Depth32FloatStencil8 = "depth32float-stencil8"
  44058. }
  44059. /** @hidden */
  44060. export enum TextureComponentType {
  44061. Float = "float",
  44062. Sint = "sint",
  44063. Uint = "uint",
  44064. DepthComparison = "depth-comparison"
  44065. }
  44066. /** @hidden */
  44067. export enum TextureViewDimension {
  44068. E1d = "1d",
  44069. E2d = "2d",
  44070. E2dArray = "2d-array",
  44071. Cube = "cube",
  44072. CubeArray = "cube-array",
  44073. E3d = "3d"
  44074. }
  44075. /** @hidden */
  44076. export enum VertexFormat {
  44077. Uchar2 = "uchar2",
  44078. Uchar4 = "uchar4",
  44079. Char2 = "char2",
  44080. Char4 = "char4",
  44081. Uchar2Norm = "uchar2norm",
  44082. Uchar4Norm = "uchar4norm",
  44083. Char2Norm = "char2norm",
  44084. Char4Norm = "char4norm",
  44085. Ushort2 = "ushort2",
  44086. Ushort4 = "ushort4",
  44087. Short2 = "short2",
  44088. Short4 = "short4",
  44089. Ushort2Norm = "ushort2norm",
  44090. Ushort4Norm = "ushort4norm",
  44091. Short2Norm = "short2norm",
  44092. Short4Norm = "short4norm",
  44093. Half2 = "half2",
  44094. Half4 = "half4",
  44095. Float = "float",
  44096. Float2 = "float2",
  44097. Float3 = "float3",
  44098. Float4 = "float4",
  44099. Uint = "uint",
  44100. Uint2 = "uint2",
  44101. Uint3 = "uint3",
  44102. Uint4 = "uint4",
  44103. Int = "int",
  44104. Int2 = "int2",
  44105. Int3 = "int3",
  44106. Int4 = "int4"
  44107. }
  44108. /** @hidden */
  44109. export enum TextureAspect {
  44110. All = "all",
  44111. StencilOnly = "stencil-only",
  44112. DepthOnly = "depth-only"
  44113. }
  44114. /** @hidden */
  44115. export enum CompilationMessageType {
  44116. Error = "error",
  44117. Warning = "warning",
  44118. Info = "info"
  44119. }
  44120. /** @hidden */
  44121. export enum QueryType {
  44122. Occlusion = "occlusion"
  44123. }
  44124. /** @hidden */
  44125. export enum BufferUsage {
  44126. MapRead = 1,
  44127. MapWrite = 2,
  44128. CopySrc = 4,
  44129. CopyDst = 8,
  44130. Index = 16,
  44131. Vertex = 32,
  44132. Uniform = 64,
  44133. Storage = 128,
  44134. Indirect = 256,
  44135. QueryResolve = 512
  44136. }
  44137. /** @hidden */
  44138. export enum ColorWrite {
  44139. Red = 1,
  44140. Green = 2,
  44141. Blue = 4,
  44142. Alpha = 8,
  44143. All = 15
  44144. }
  44145. /** @hidden */
  44146. export enum ShaderStage {
  44147. Vertex = 1,
  44148. Fragment = 2,
  44149. Compute = 4
  44150. }
  44151. /** @hidden */
  44152. export enum TextureUsage {
  44153. CopySrc = 1,
  44154. CopyDst = 2,
  44155. Sampled = 4,
  44156. Storage = 8,
  44157. OutputAttachment = 16
  44158. }
  44159. /** @hidden */
  44160. export enum MapMode {
  44161. Read = 1,
  44162. Write = 2
  44163. }
  44164. }
  44165. declare module BABYLON {
  44166. /** @hidden */
  44167. export interface WebGPUBindingInfo {
  44168. setIndex: number;
  44169. bindingIndex: number;
  44170. }
  44171. /** @hidden */
  44172. export interface WebGPUTextureSamplerBindingDescription {
  44173. sampler: WebGPUBindingInfo;
  44174. isTextureArray: boolean;
  44175. textures: Array<WebGPUBindingInfo>;
  44176. }
  44177. /** @hidden
  44178. * If the binding is a UBO, isSampler=isTexture=false
  44179. */
  44180. export interface WebGPUBindingDescription {
  44181. name: string;
  44182. usedInVertex: boolean;
  44183. usedInFragment: boolean;
  44184. isSampler: boolean;
  44185. isComparisonSampler?: boolean;
  44186. isTexture: boolean;
  44187. componentType?: GPUTextureComponentType;
  44188. textureDimension?: GPUTextureViewDimension;
  44189. }
  44190. /**
  44191. * @hidden
  44192. */
  44193. export class WebGPUShaderProcessingContext implements ShaderProcessingContext {
  44194. uboNextBindingIndex: number;
  44195. freeSetIndex: number;
  44196. freeBindingIndex: number;
  44197. availableVaryings: {
  44198. [key: string]: number;
  44199. };
  44200. availableAttributes: {
  44201. [key: string]: number;
  44202. };
  44203. availableUBOs: {
  44204. [key: string]: {
  44205. setIndex: number;
  44206. bindingIndex: number;
  44207. };
  44208. };
  44209. availableSamplers: {
  44210. [key: string]: WebGPUTextureSamplerBindingDescription;
  44211. };
  44212. leftOverUniforms: {
  44213. name: string;
  44214. type: string;
  44215. length: number;
  44216. }[];
  44217. orderedAttributes: string[];
  44218. orderedUBOsAndSamplers: WebGPUBindingDescription[][];
  44219. private _attributeNextLocation;
  44220. private _varyingNextLocation;
  44221. constructor();
  44222. getAttributeNextLocation(dataType: string, arrayLength?: number): number;
  44223. getVaryingNextLocation(dataType: string, arrayLength?: number): number;
  44224. getNextFreeUBOBinding(): {
  44225. setIndex: number;
  44226. bindingIndex: number;
  44227. };
  44228. private _getNextFreeBinding;
  44229. }
  44230. }
  44231. declare module BABYLON {
  44232. /** @hidden */
  44233. export interface IWebGPUPipelineContextSamplerCache {
  44234. samplerBinding: number;
  44235. firstTextureName: string;
  44236. }
  44237. /** @hidden */
  44238. export interface IWebGPUPipelineContextTextureCache {
  44239. textureBinding: number;
  44240. texture: InternalTexture;
  44241. }
  44242. /** @hidden */
  44243. export interface IWebGPUPipelineContextVertexInputsCache {
  44244. indexBuffer: Nullable<GPUBuffer>;
  44245. indexOffset: number;
  44246. vertexStartSlot: number;
  44247. vertexBuffers: GPUBuffer[];
  44248. vertexOffsets: number[];
  44249. }
  44250. /** @hidden */
  44251. export interface IWebGPURenderPipelineStageDescriptor {
  44252. vertexStage: GPUProgrammableStageDescriptor;
  44253. fragmentStage?: GPUProgrammableStageDescriptor;
  44254. }
  44255. /** @hidden */
  44256. export class WebGPUPipelineContext implements IPipelineContext {
  44257. engine: WebGPUEngine;
  44258. shaderProcessingContext: WebGPUShaderProcessingContext;
  44259. leftOverUniformsByName: {
  44260. [name: string]: string;
  44261. };
  44262. sources: {
  44263. vertex: string;
  44264. fragment: string;
  44265. rawVertex: string;
  44266. rawFragment: string;
  44267. };
  44268. stages: Nullable<IWebGPURenderPipelineStageDescriptor>;
  44269. samplers: {
  44270. [name: string]: Nullable<IWebGPUPipelineContextSamplerCache>;
  44271. };
  44272. textures: {
  44273. [name: string]: Nullable<IWebGPUPipelineContextTextureCache>;
  44274. };
  44275. bindGroupLayouts: GPUBindGroupLayout[];
  44276. /**
  44277. * Stores the uniform buffer
  44278. */
  44279. uniformBuffer: Nullable<UniformBuffer>;
  44280. onCompiled?: () => void;
  44281. get isAsync(): boolean;
  44282. get isReady(): boolean;
  44283. /** @hidden */
  44284. _name: string;
  44285. constructor(shaderProcessingContext: WebGPUShaderProcessingContext, engine: WebGPUEngine);
  44286. _handlesSpectorRebuildCallback(onCompiled: (program: any) => void): void;
  44287. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  44288. [key: string]: number;
  44289. }, uniformsNames: string[], uniforms: {
  44290. [key: string]: Nullable<WebGLUniformLocation>;
  44291. }, samplerList: string[], samplers: {
  44292. [key: string]: number;
  44293. }, attributesNames: string[], attributes: number[]): void;
  44294. /** @hidden */
  44295. /**
  44296. * Build the uniform buffer used in the material.
  44297. */
  44298. buildUniformLayout(): void;
  44299. /**
  44300. * Release all associated resources.
  44301. **/
  44302. dispose(): void;
  44303. /**
  44304. * Sets an integer value on a uniform variable.
  44305. * @param uniformName Name of the variable.
  44306. * @param value Value to be set.
  44307. */
  44308. setInt(uniformName: string, value: number): void;
  44309. /**
  44310. * Sets an int2 value on a uniform variable.
  44311. * @param uniformName Name of the variable.
  44312. * @param x First int in int2.
  44313. * @param y Second int in int2.
  44314. */
  44315. setInt2(uniformName: string, x: number, y: number): void;
  44316. /**
  44317. * Sets an int3 value on a uniform variable.
  44318. * @param uniformName Name of the variable.
  44319. * @param x First int in int3.
  44320. * @param y Second int in int3.
  44321. * @param z Third int in int3.
  44322. */
  44323. setInt3(uniformName: string, x: number, y: number, z: number): void;
  44324. /**
  44325. * Sets an int4 value on a uniform variable.
  44326. * @param uniformName Name of the variable.
  44327. * @param x First int in int4.
  44328. * @param y Second int in int4.
  44329. * @param z Third int in int4.
  44330. * @param w Fourth int in int4.
  44331. */
  44332. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44333. /**
  44334. * Sets an int array on a uniform variable.
  44335. * @param uniformName Name of the variable.
  44336. * @param array array to be set.
  44337. */
  44338. setIntArray(uniformName: string, array: Int32Array): void;
  44339. /**
  44340. * 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)
  44341. * @param uniformName Name of the variable.
  44342. * @param array array to be set.
  44343. */
  44344. setIntArray2(uniformName: string, array: Int32Array): void;
  44345. /**
  44346. * 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)
  44347. * @param uniformName Name of the variable.
  44348. * @param array array to be set.
  44349. */
  44350. setIntArray3(uniformName: string, array: Int32Array): void;
  44351. /**
  44352. * 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)
  44353. * @param uniformName Name of the variable.
  44354. * @param array array to be set.
  44355. */
  44356. setIntArray4(uniformName: string, array: Int32Array): void;
  44357. /**
  44358. * Sets an array on a uniform variable.
  44359. * @param uniformName Name of the variable.
  44360. * @param array array to be set.
  44361. */
  44362. setArray(uniformName: string, array: number[]): void;
  44363. /**
  44364. * 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)
  44365. * @param uniformName Name of the variable.
  44366. * @param array array to be set.
  44367. */
  44368. setArray2(uniformName: string, array: number[]): void;
  44369. /**
  44370. * 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)
  44371. * @param uniformName Name of the variable.
  44372. * @param array array to be set.
  44373. * @returns this effect.
  44374. */
  44375. setArray3(uniformName: string, array: number[]): void;
  44376. /**
  44377. * 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)
  44378. * @param uniformName Name of the variable.
  44379. * @param array array to be set.
  44380. */
  44381. setArray4(uniformName: string, array: number[]): void;
  44382. /**
  44383. * Sets matrices on a uniform variable.
  44384. * @param uniformName Name of the variable.
  44385. * @param matrices matrices to be set.
  44386. */
  44387. setMatrices(uniformName: string, matrices: Float32Array): void;
  44388. /**
  44389. * Sets matrix on a uniform variable.
  44390. * @param uniformName Name of the variable.
  44391. * @param matrix matrix to be set.
  44392. */
  44393. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  44394. /**
  44395. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  44396. * @param uniformName Name of the variable.
  44397. * @param matrix matrix to be set.
  44398. */
  44399. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  44400. /**
  44401. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  44402. * @param uniformName Name of the variable.
  44403. * @param matrix matrix to be set.
  44404. */
  44405. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  44406. /**
  44407. * Sets a float on a uniform variable.
  44408. * @param uniformName Name of the variable.
  44409. * @param value value to be set.
  44410. * @returns this effect.
  44411. */
  44412. setFloat(uniformName: string, value: number): void;
  44413. /**
  44414. * Sets a Vector2 on a uniform variable.
  44415. * @param uniformName Name of the variable.
  44416. * @param vector2 vector2 to be set.
  44417. */
  44418. setVector2(uniformName: string, vector2: IVector2Like): void;
  44419. /**
  44420. * Sets a float2 on a uniform variable.
  44421. * @param uniformName Name of the variable.
  44422. * @param x First float in float2.
  44423. * @param y Second float in float2.
  44424. */
  44425. setFloat2(uniformName: string, x: number, y: number): void;
  44426. /**
  44427. * Sets a Vector3 on a uniform variable.
  44428. * @param uniformName Name of the variable.
  44429. * @param vector3 Value to be set.
  44430. */
  44431. setVector3(uniformName: string, vector3: IVector3Like): void;
  44432. /**
  44433. * Sets a float3 on a uniform variable.
  44434. * @param uniformName Name of the variable.
  44435. * @param x First float in float3.
  44436. * @param y Second float in float3.
  44437. * @param z Third float in float3.
  44438. */
  44439. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  44440. /**
  44441. * Sets a Vector4 on a uniform variable.
  44442. * @param uniformName Name of the variable.
  44443. * @param vector4 Value to be set.
  44444. */
  44445. setVector4(uniformName: string, vector4: IVector4Like): void;
  44446. /**
  44447. * Sets a float4 on a uniform variable.
  44448. * @param uniformName Name of the variable.
  44449. * @param x First float in float4.
  44450. * @param y Second float in float4.
  44451. * @param z Third float in float4.
  44452. * @param w Fourth float in float4.
  44453. * @returns this effect.
  44454. */
  44455. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44456. /**
  44457. * Sets a Color3 on a uniform variable.
  44458. * @param uniformName Name of the variable.
  44459. * @param color3 Value to be set.
  44460. */
  44461. setColor3(uniformName: string, color3: IColor3Like): void;
  44462. /**
  44463. * Sets a Color4 on a uniform variable.
  44464. * @param uniformName Name of the variable.
  44465. * @param color3 Value to be set.
  44466. * @param alpha Alpha value to be set.
  44467. */
  44468. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  44469. /**
  44470. * Sets a Color4 on a uniform variable
  44471. * @param uniformName defines the name of the variable
  44472. * @param color4 defines the value to be set
  44473. */
  44474. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  44475. _getVertexShaderCode(): string | null;
  44476. _getFragmentShaderCode(): string | null;
  44477. }
  44478. }
  44479. declare module BABYLON {
  44480. /** @hidden */
  44481. export class WebGPUDataBuffer extends DataBuffer {
  44482. private _buffer;
  44483. constructor(resource: GPUBuffer);
  44484. get underlyingResource(): any;
  44485. }
  44486. }
  44487. declare module BABYLON {
  44488. /**
  44489. * Class used to inline functions in shader code
  44490. */
  44491. export class ShaderCodeInliner {
  44492. private static readonly _RegexpFindFunctionNameAndType;
  44493. private _sourceCode;
  44494. private _functionDescr;
  44495. private _numMaxIterations;
  44496. /** Gets or sets the token used to mark the functions to inline */
  44497. inlineToken: string;
  44498. /** Gets or sets the debug mode */
  44499. debug: boolean;
  44500. /** Gets the code after the inlining process */
  44501. get code(): string;
  44502. /**
  44503. * Initializes the inliner
  44504. * @param sourceCode shader code source to inline
  44505. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  44506. */
  44507. constructor(sourceCode: string, numMaxIterations?: number);
  44508. /**
  44509. * Start the processing of the shader code
  44510. */
  44511. processCode(): void;
  44512. private _collectFunctions;
  44513. private _processInlining;
  44514. private _extractBetweenMarkers;
  44515. private _skipWhitespaces;
  44516. private _isIdentifierChar;
  44517. private _removeComments;
  44518. private _replaceFunctionCallsByCode;
  44519. private _findBackward;
  44520. private _escapeRegExp;
  44521. private _replaceNames;
  44522. }
  44523. }
  44524. declare module BABYLON {
  44525. /** @hidden */
  44526. export class WebGPUShaderProcessor implements IShaderProcessor {
  44527. protected _missingVaryings: Array<string>;
  44528. protected _textureArrayProcessing: Array<string>;
  44529. protected _preProcessors: {
  44530. [key: string]: string;
  44531. };
  44532. private _getArraySize;
  44533. initializeShaders(processingContext: Nullable<ShaderProcessingContext>): void;
  44534. varyingProcessor(varying: string, isFragment: boolean, preProcessors: {
  44535. [key: string]: string;
  44536. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44537. attributeProcessor(attribute: string, preProcessors: {
  44538. [key: string]: string;
  44539. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44540. uniformProcessor(uniform: string, isFragment: boolean, preProcessors: {
  44541. [key: string]: string;
  44542. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44543. uniformBufferProcessor(uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44544. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44545. private _applyTextureArrayProcessing;
  44546. finalizeShaders(vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>): {
  44547. vertexCode: string;
  44548. fragmentCode: string;
  44549. };
  44550. }
  44551. }
  44552. declare module BABYLON {
  44553. /** @hidden */
  44554. export class WebGPUBufferManager {
  44555. private _device;
  44556. private _deferredReleaseBuffers;
  44557. private static _IsGPUBuffer;
  44558. constructor(device: GPUDevice);
  44559. createRawBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags, mappedAtCreation?: boolean): GPUBuffer;
  44560. createBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags): DataBuffer;
  44561. setSubData(dataBuffer: WebGPUDataBuffer, dstByteOffset: number, src: ArrayBufferView, srcByteOffset?: number, byteLength?: number): void;
  44562. private _FromHalfFloat;
  44563. private _GetHalfFloatAsFloatRGBAArrayBuffer;
  44564. readDataFromBuffer(gpuBuffer: GPUBuffer, size: number, width: number, height: number, bytesPerRow: number, bytesPerRowAligned: number, floatFormat?: number, offset?: number, buffer?: Nullable<ArrayBufferView>, destroyBuffer?: boolean): Promise<ArrayBufferView>;
  44565. releaseBuffer(buffer: DataBuffer | GPUBuffer): boolean;
  44566. destroyDeferredBuffers(): void;
  44567. }
  44568. }
  44569. declare module BABYLON {
  44570. /** @hidden */
  44571. export class WebGPUHardwareTexture implements HardwareTextureWrapper {
  44572. private _webgpuTexture;
  44573. private _webgpuMSAATexture;
  44574. get underlyingResource(): Nullable<GPUTexture>;
  44575. get msaaTexture(): Nullable<GPUTexture>;
  44576. set msaaTexture(texture: Nullable<GPUTexture>);
  44577. view: Nullable<GPUTextureView>;
  44578. format: GPUTextureFormat;
  44579. textureUsages: number;
  44580. constructor(existingTexture?: Nullable<GPUTexture>);
  44581. set(hardwareTexture: GPUTexture): void;
  44582. setMSAATexture(hardwareTexture: GPUTexture): void;
  44583. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  44584. createView(descriptor?: GPUTextureViewDescriptor): void;
  44585. reset(): void;
  44586. release(): void;
  44587. }
  44588. }
  44589. declare module BABYLON {
  44590. /** @hidden */
  44591. export class WebGPUTextureHelper {
  44592. private _device;
  44593. private _glslang;
  44594. private _bufferManager;
  44595. private _mipmapSampler;
  44596. private _invertYPreMultiplyAlphaSampler;
  44597. private _pipelines;
  44598. private _compiledShaders;
  44599. private _deferredReleaseTextures;
  44600. private _commandEncoderForCreation;
  44601. static ComputeNumMipmapLevels(width: number, height: number): number;
  44602. constructor(device: GPUDevice, glslang: any, bufferManager: WebGPUBufferManager);
  44603. private _getPipeline;
  44604. private static _GetTextureTypeFromFormat;
  44605. private static _GetBlockInformationFromFormat;
  44606. private static _IsHardwareTexture;
  44607. private static _IsInternalTexture;
  44608. static GetCompareFunction(compareFunction: Nullable<number>): GPUCompareFunction;
  44609. static IsImageBitmap(imageBitmap: ImageBitmap | {
  44610. width: number;
  44611. height: number;
  44612. }): imageBitmap is ImageBitmap;
  44613. static IsImageBitmapArray(imageBitmap: ImageBitmap[] | {
  44614. width: number;
  44615. height: number;
  44616. }): imageBitmap is ImageBitmap[];
  44617. setCommandEncoder(encoder: GPUCommandEncoder): void;
  44618. static IsCompressedFormat(format: GPUTextureFormat): boolean;
  44619. static GetWebGPUTextureFormat(type: number, format: number): GPUTextureFormat;
  44620. invertYPreMultiplyAlpha(gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  44621. clear(format: GPUTextureFormat, color: IColor4Like, passEncoder: GPURenderPassEncoder): void;
  44622. createTexture(imageBitmap: ImageBitmap | {
  44623. width: number;
  44624. height: number;
  44625. layers: number;
  44626. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, is3D?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  44627. createCubeTexture(imageBitmaps: ImageBitmap[] | {
  44628. width: number;
  44629. height: number;
  44630. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  44631. generateCubeMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, commandEncoder?: GPUCommandEncoder): void;
  44632. generateMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  44633. createGPUTextureForInternalTexture(texture: InternalTexture, width?: number, height?: number, depth?: number): WebGPUHardwareTexture;
  44634. createMSAATexture(texture: InternalTexture, samples: number): void;
  44635. updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  44636. 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;
  44637. readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>): Promise<ArrayBufferView>;
  44638. releaseTexture(texture: InternalTexture | GPUTexture): void;
  44639. destroyDeferredTextures(): void;
  44640. }
  44641. }
  44642. declare module BABYLON {
  44643. /** @hidden */
  44644. export class WebGPURenderPassWrapper {
  44645. renderPassDescriptor: Nullable<GPURenderPassDescriptor>;
  44646. renderPass: Nullable<GPURenderPassEncoder>;
  44647. colorAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  44648. depthAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  44649. colorAttachmentGPUTextures: WebGPUHardwareTexture[];
  44650. depthTextureFormat: GPUTextureFormat | undefined;
  44651. constructor();
  44652. reset(fullReset?: boolean): void;
  44653. }
  44654. }
  44655. declare module BABYLON {
  44656. /** @hidden */
  44657. export class WebGPUCacheSampler {
  44658. private _samplers;
  44659. private _device;
  44660. constructor(device: GPUDevice);
  44661. private static _GetSamplerHashCode;
  44662. private static _GetSamplerFilterDescriptor;
  44663. private static _GetWrappingMode;
  44664. private static _GetSamplerWrappingDescriptor;
  44665. private static _GetSamplerDescriptor;
  44666. getSampler(internalTexture: InternalTexture, bypassCache?: boolean): GPUSampler;
  44667. }
  44668. }
  44669. declare module BABYLON {
  44670. /** @hidden */
  44671. export class WebGPUShaderManager {
  44672. private _shaders;
  44673. private _device;
  44674. constructor(device: GPUDevice);
  44675. getCompiledShaders(name: string): IWebGPURenderPipelineStageDescriptor;
  44676. }
  44677. }
  44678. declare module BABYLON {
  44679. /** @hidden */
  44680. export var clearQuadVertexShader: {
  44681. name: string;
  44682. shader: string;
  44683. };
  44684. }
  44685. declare module BABYLON {
  44686. /** @hidden */
  44687. export var clearQuadPixelShader: {
  44688. name: string;
  44689. shader: string;
  44690. };
  44691. }
  44692. declare module BABYLON {
  44693. /**
  44694. * Options to load the associated Glslang library
  44695. */
  44696. export interface GlslangOptions {
  44697. /**
  44698. * Defines an existing instance of Glslang (usefull in modules who do not access the global instance).
  44699. */
  44700. glslang?: any;
  44701. /**
  44702. * Defines the URL of the glslang JS File.
  44703. */
  44704. jsPath?: string;
  44705. /**
  44706. * Defines the URL of the glslang WASM File.
  44707. */
  44708. wasmPath?: string;
  44709. }
  44710. /**
  44711. * Options to create the WebGPU engine
  44712. */
  44713. export interface WebGPUEngineOptions extends GPURequestAdapterOptions {
  44714. /**
  44715. * If delta time between frames should be constant
  44716. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44717. */
  44718. deterministicLockstep?: boolean;
  44719. /**
  44720. * Maximum about of steps between frames (Default: 4)
  44721. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44722. */
  44723. lockstepMaxSteps?: number;
  44724. /**
  44725. * Defines the seconds between each deterministic lock step
  44726. */
  44727. timeStep?: number;
  44728. /**
  44729. * Defines that engine should ignore modifying touch action attribute and style
  44730. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  44731. */
  44732. doNotHandleTouchAction?: boolean;
  44733. /**
  44734. * Defines if webaudio should be initialized as well
  44735. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  44736. */
  44737. audioEngine?: boolean;
  44738. /**
  44739. * Defines the category of adapter to use.
  44740. * Is it the discrete or integrated device.
  44741. */
  44742. powerPreference?: GPUPowerPreference;
  44743. /**
  44744. * Defines the device descriptor used to create a device.
  44745. */
  44746. deviceDescriptor?: GPUDeviceDescriptor;
  44747. /**
  44748. * Defines the requested Swap Chain Format.
  44749. */
  44750. swapChainFormat?: GPUTextureFormat;
  44751. /**
  44752. * Defines wether MSAA is enabled on the canvas.
  44753. */
  44754. antialiasing?: boolean;
  44755. /**
  44756. * Defines wether the stencil buffer should be enabled.
  44757. */
  44758. stencil?: boolean;
  44759. /**
  44760. * Defines wether we should generate debug markers in the gpu command lists (can be seen with PIX for eg)
  44761. */
  44762. enableGPUDebugMarkers?: boolean;
  44763. }
  44764. /**
  44765. * The web GPU engine class provides support for WebGPU version of babylon.js.
  44766. */
  44767. export class WebGPUEngine extends Engine {
  44768. private static readonly _glslangDefaultOptions;
  44769. private readonly _uploadEncoderDescriptor;
  44770. private readonly _renderEncoderDescriptor;
  44771. private readonly _renderTargetEncoderDescriptor;
  44772. private readonly _clearDepthValue;
  44773. private readonly _clearReverseDepthValue;
  44774. private readonly _clearStencilValue;
  44775. private readonly _defaultSampleCount;
  44776. private _canvas;
  44777. private _options;
  44778. private _glslang;
  44779. private _adapter;
  44780. private _adapterSupportedExtensions;
  44781. private _device;
  44782. private _deviceEnabledExtensions;
  44783. private _context;
  44784. private _swapChain;
  44785. private _swapChainTexture;
  44786. private _mainPassSampleCount;
  44787. private _textureHelper;
  44788. private _bufferManager;
  44789. private _shaderManager;
  44790. private _cacheSampler;
  44791. private _emptyVertexBuffer;
  44792. private _lastCachedWrapU;
  44793. private _lastCachedWrapV;
  44794. private _lastCachedWrapR;
  44795. private _mrtAttachments;
  44796. private _counters;
  44797. private _mainTexture;
  44798. private _depthTexture;
  44799. private _mainTextureExtends;
  44800. private _depthTextureFormat;
  44801. private _colorFormat;
  44802. private _uploadEncoder;
  44803. private _renderEncoder;
  44804. private _renderTargetEncoder;
  44805. private _commandBuffers;
  44806. private _currentRenderPass;
  44807. private _mainRenderPassWrapper;
  44808. private _rttRenderPassWrapper;
  44809. private _pendingDebugCommands;
  44810. private _currentVertexBuffers;
  44811. private _currentIndexBuffer;
  44812. private __colorWrite;
  44813. private _uniformsBuffers;
  44814. private _forceEnableEffect;
  44815. /** @hidden */
  44816. dbgShowShaderCode: boolean;
  44817. /** @hidden */
  44818. dbgSanityChecks: boolean;
  44819. /** @hidden */
  44820. dbgGenerateLogs: boolean;
  44821. /** @hidden */
  44822. dbgVerboseLogsForFirstFrames: boolean;
  44823. /** @hidden */
  44824. dbgVerboseLogsNumFrames: number;
  44825. /** @hidden */
  44826. dbgShowWarningsNotImplemented: boolean;
  44827. /**
  44828. * Gets a boolean indicating that the engine supports uniform buffers
  44829. */
  44830. get supportsUniformBuffers(): boolean;
  44831. /** Gets the supported extensions by the WebGPU adapter */
  44832. get supportedExtensions(): Immutable<GPUExtensionName[]>;
  44833. /** Gets the currently enabled extensions on the WebGPU device */
  44834. get enabledExtensions(): Immutable<GPUExtensionName[]>;
  44835. /**
  44836. * Returns the name of the engine
  44837. */
  44838. get name(): string;
  44839. /**
  44840. * Returns a string describing the current engine
  44841. */
  44842. get description(): string;
  44843. /**
  44844. * Returns the version of the engine
  44845. */
  44846. get version(): number;
  44847. /**
  44848. * Create a new instance of the gpu engine.
  44849. * @param canvas Defines the canvas to use to display the result
  44850. * @param options Defines the options passed to the engine to create the GPU context dependencies
  44851. */
  44852. constructor(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions);
  44853. /**
  44854. * Initializes the WebGPU context and dependencies.
  44855. * @param glslangOptions Defines the GLSLang compiler options if necessary
  44856. * @returns a promise notifying the readiness of the engine.
  44857. */
  44858. initAsync(glslangOptions?: GlslangOptions): Promise<void>;
  44859. private _initGlslang;
  44860. private _initializeLimits;
  44861. private _initializeContextAndSwapChain;
  44862. private _initializeMainAttachments;
  44863. /**
  44864. * Force a specific size of the canvas
  44865. * @param width defines the new canvas' width
  44866. * @param height defines the new canvas' height
  44867. * @param forceSetSize true to force setting the sizes of the underlying canvas
  44868. * @returns true if the size was changed
  44869. */
  44870. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  44871. /**
  44872. * Gets a shader processor implementation fitting with the current engine type.
  44873. * @returns The shader processor implementation.
  44874. */
  44875. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  44876. /** @hidden */
  44877. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  44878. /**
  44879. * Force the entire cache to be cleared
  44880. * You should not have to use this function unless your engine needs to share the WebGPU context with another engine
  44881. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  44882. */
  44883. wipeCaches(bruteForce?: boolean): void;
  44884. /**
  44885. * Enable or disable color writing
  44886. * @param enable defines the state to set
  44887. */
  44888. setColorWrite(enable: boolean): void;
  44889. /**
  44890. * Gets a boolean indicating if color writing is enabled
  44891. * @returns the current color writing state
  44892. */
  44893. getColorWrite(): boolean;
  44894. private _viewportsCurrent;
  44895. private _resetCurrentViewport;
  44896. private _applyViewport;
  44897. /** @hidden */
  44898. _viewport(x: number, y: number, width: number, height: number): void;
  44899. private _scissorsCurrent;
  44900. protected _scissorCached: {
  44901. x: number;
  44902. y: number;
  44903. z: number;
  44904. w: number;
  44905. };
  44906. private _resetCurrentScissor;
  44907. private _applyScissor;
  44908. private _scissorIsActive;
  44909. enableScissor(x: number, y: number, width: number, height: number): void;
  44910. disableScissor(): void;
  44911. /**
  44912. * Clear the current render buffer or the current render target (if any is set up)
  44913. * @param color defines the color to use
  44914. * @param backBuffer defines if the back buffer must be cleared
  44915. * @param depth defines if the depth buffer must be cleared
  44916. * @param stencil defines if the stencil buffer must be cleared
  44917. */
  44918. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44919. /**
  44920. * Clears a list of attachments
  44921. * @param attachments list of the attachments
  44922. * @param colorMain clear color for the main attachment (the first one)
  44923. * @param colorOthers clear color for the other attachments
  44924. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  44925. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  44926. */
  44927. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  44928. /**
  44929. * Creates a vertex buffer
  44930. * @param data the data for the vertex buffer
  44931. * @returns the new buffer
  44932. */
  44933. createVertexBuffer(data: DataArray): DataBuffer;
  44934. /**
  44935. * Creates a vertex buffer
  44936. * @param data the data for the dynamic vertex buffer
  44937. * @returns the new buffer
  44938. */
  44939. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44940. /**
  44941. * Updates a vertex buffer.
  44942. * @param vertexBuffer the vertex buffer to update
  44943. * @param data the data used to update the vertex buffer
  44944. * @param byteOffset the byte offset of the data
  44945. * @param byteLength the byte length of the data
  44946. */
  44947. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44948. /**
  44949. * Creates a new index buffer
  44950. * @param indices defines the content of the index buffer
  44951. * @param updatable defines if the index buffer must be updatable - not used in WebGPU
  44952. * @returns a new buffer
  44953. */
  44954. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  44955. /**
  44956. * Update an index buffer
  44957. * @param indexBuffer defines the target index buffer
  44958. * @param indices defines the data to update
  44959. * @param offset defines the offset in the target index buffer where update should start
  44960. */
  44961. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44962. /** @hidden */
  44963. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  44964. /** @hidden */
  44965. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  44966. /**
  44967. * Bind a list of vertex buffers with the engine
  44968. * @param vertexBuffers defines the list of vertex buffers to bind
  44969. * @param indexBuffer defines the index buffer to bind
  44970. * @param effect defines the effect associated with the vertex buffers
  44971. */
  44972. bindBuffers(vertexBuffers: {
  44973. [key: string]: Nullable<VertexBuffer>;
  44974. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  44975. /** @hidden */
  44976. _releaseBuffer(buffer: DataBuffer): boolean;
  44977. createUniformBuffer(elements: FloatArray): DataBuffer;
  44978. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  44979. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  44980. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  44981. /**
  44982. * Create a new effect (used to store vertex/fragment shaders)
  44983. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  44984. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  44985. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  44986. * @param samplers defines an array of string used to represent textures
  44987. * @param defines defines the string containing the defines to use to compile the shaders
  44988. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  44989. * @param onCompiled defines a function to call when the effect creation is successful
  44990. * @param onError defines a function to call when the effect creation has failed
  44991. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  44992. * @returns the new Effect
  44993. */
  44994. 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;
  44995. private _compileRawShaderToSpirV;
  44996. private _compileShaderToSpirV;
  44997. private _createPipelineStageDescriptor;
  44998. private _compileRawPipelineStageDescriptor;
  44999. private _compilePipelineStageDescriptor;
  45000. /** @hidden */
  45001. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  45002. /** @hidden */
  45003. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  45004. /**
  45005. * Creates a new pipeline context
  45006. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  45007. * @returns the new pipeline
  45008. */
  45009. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  45010. /** @hidden */
  45011. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  45012. /**
  45013. * Gets the list of active attributes for a given WebGPU program
  45014. * @param pipelineContext defines the pipeline context to use
  45015. * @param attributesNames defines the list of attribute names to get
  45016. * @returns an array of indices indicating the offset of each attribute
  45017. */
  45018. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45019. /**
  45020. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45021. * @param effect defines the effect to activate
  45022. */
  45023. enableEffect(effect: Nullable<Effect>): void;
  45024. /** @hidden */
  45025. _releaseEffect(effect: Effect): void;
  45026. /**
  45027. * 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
  45028. */
  45029. releaseEffects(): void;
  45030. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45031. /**
  45032. * Gets a boolean indicating that only power of 2 textures are supported
  45033. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  45034. */
  45035. get needPOTTextures(): boolean;
  45036. /** @hidden */
  45037. _createHardwareTexture(): HardwareTextureWrapper;
  45038. /** @hidden */
  45039. _releaseTexture(texture: InternalTexture): void;
  45040. /** @hidden */
  45041. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  45042. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  45043. /**
  45044. * Usually called from Texture.ts.
  45045. * Passed information to create a hardware texture
  45046. * @param url defines a value which contains one of the following:
  45047. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45048. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45049. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45050. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45051. * @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)
  45052. * @param scene needed for loading to the correct scene
  45053. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45054. * @param onLoad optional callback to be called upon successful completion
  45055. * @param onError optional callback to be called upon failure
  45056. * @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
  45057. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45058. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45059. * @param forcedExtension defines the extension to use to pick the right loader
  45060. * @param mimeType defines an optional mime type
  45061. * @param loaderOptions options to be passed to the loader
  45062. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45063. */
  45064. 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;
  45065. /** @hidden */
  45066. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  45067. /**
  45068. * Creates a cube texture
  45069. * @param rootUrl defines the url where the files to load is located
  45070. * @param scene defines the current scene
  45071. * @param files defines the list of files to load (1 per face)
  45072. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45073. * @param onLoad defines an optional callback raised when the texture is loaded
  45074. * @param onError defines an optional callback raised if there is an issue to load the texture
  45075. * @param format defines the format of the data
  45076. * @param forcedExtension defines the extension to use to pick the right loader
  45077. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45078. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45079. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45080. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45081. * @param loaderOptions options to be passed to the loader
  45082. * @returns the cube texture as an InternalTexture
  45083. */
  45084. 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;
  45085. /**
  45086. * Creates a raw texture
  45087. * @param data defines the data to store in the texture
  45088. * @param width defines the width of the texture
  45089. * @param height defines the height of the texture
  45090. * @param format defines the format of the data
  45091. * @param generateMipMaps defines if the engine should generate the mip levels
  45092. * @param invertY defines if data must be stored with Y axis inverted
  45093. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  45094. * @param compression defines the compression used (null by default)
  45095. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45096. * @returns the raw texture inside an InternalTexture
  45097. */
  45098. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  45099. /**
  45100. * Creates a new raw cube texture
  45101. * @param data defines the array of data to use to create each face
  45102. * @param size defines the size of the textures
  45103. * @param format defines the format of the data
  45104. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45105. * @param generateMipMaps defines if the engine should generate the mip levels
  45106. * @param invertY defines if data must be stored with Y axis inverted
  45107. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45108. * @param compression defines the compression used (null by default)
  45109. * @returns the cube texture as an InternalTexture
  45110. */
  45111. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  45112. /**
  45113. * Creates a new raw cube texture from a specified url
  45114. * @param url defines the url where the data is located
  45115. * @param scene defines the current scene
  45116. * @param size defines the size of the textures
  45117. * @param format defines the format of the data
  45118. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45119. * @param noMipmap defines if the engine should avoid generating the mip levels
  45120. * @param callback defines a callback used to extract texture data from loaded data
  45121. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  45122. * @param onLoad defines a callback called when texture is loaded
  45123. * @param onError defines a callback called if there is an error
  45124. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45125. * @param invertY defines if data must be stored with Y axis inverted
  45126. * @returns the cube texture as an InternalTexture
  45127. */
  45128. 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;
  45129. /**
  45130. * Creates a new raw 2D array texture
  45131. * @param data defines the data used to create the texture
  45132. * @param width defines the width of the texture
  45133. * @param height defines the height of the texture
  45134. * @param depth defines the number of layers of the texture
  45135. * @param format defines the format of the texture
  45136. * @param generateMipMaps defines if the engine must generate mip levels
  45137. * @param invertY defines if data must be stored with Y axis inverted
  45138. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45139. * @param compression defines the compressed used (can be null)
  45140. * @param textureType defines the compressed used (can be null)
  45141. * @returns a new raw 2D array texture (stored in an InternalTexture)
  45142. */
  45143. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  45144. /**
  45145. * Creates a new raw 3D texture
  45146. * @param data defines the data used to create the texture
  45147. * @param width defines the width of the texture
  45148. * @param height defines the height of the texture
  45149. * @param depth defines the depth of the texture
  45150. * @param format defines the format of the texture
  45151. * @param generateMipMaps defines if the engine must generate mip levels
  45152. * @param invertY defines if data must be stored with Y axis inverted
  45153. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45154. * @param compression defines the compressed used (can be null)
  45155. * @param textureType defines the compressed used (can be null)
  45156. * @returns a new raw 3D texture (stored in an InternalTexture)
  45157. */
  45158. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  45159. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  45160. /**
  45161. * Update the sampling mode of a given texture
  45162. * @param samplingMode defines the required sampling mode
  45163. * @param texture defines the texture to update
  45164. * @param generateMipMaps defines whether to generate mipmaps for the texture
  45165. */
  45166. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  45167. /**
  45168. * Update the sampling mode of a given texture
  45169. * @param texture defines the texture to update
  45170. * @param wrapU defines the texture wrap mode of the u coordinates
  45171. * @param wrapV defines the texture wrap mode of the v coordinates
  45172. * @param wrapR defines the texture wrap mode of the r coordinates
  45173. */
  45174. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  45175. /**
  45176. * Update the dimensions of a texture
  45177. * @param texture texture to update
  45178. * @param width new width of the texture
  45179. * @param height new height of the texture
  45180. * @param depth new depth of the texture
  45181. */
  45182. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  45183. private _setInternalTexture;
  45184. /**
  45185. * Sets a texture to the according uniform.
  45186. * @param channel The texture channel
  45187. * @param unused unused parameter
  45188. * @param texture The texture to apply
  45189. * @param name The name of the uniform in the effect
  45190. */
  45191. setTexture(channel: number, unused: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  45192. /**
  45193. * Sets an array of texture to the WebGPU context
  45194. * @param channel defines the channel where the texture array must be set
  45195. * @param unused unused parameter
  45196. * @param textures defines the array of textures to bind
  45197. * @param name name of the channel
  45198. */
  45199. setTextureArray(channel: number, unused: Nullable<WebGLUniformLocation>, textures: BaseTexture[], name: string): void;
  45200. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string, baseName?: string, textureIndex?: number): boolean;
  45201. /** @hidden */
  45202. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  45203. /** @hidden */
  45204. _bindTexture(channel: number, texture: InternalTexture, name: string): void;
  45205. private _generateMipmaps;
  45206. /**
  45207. * Update the content of a texture
  45208. * @param texture defines the texture to update
  45209. * @param canvas defines the source containing the data
  45210. * @param invertY defines if data must be stored with Y axis inverted
  45211. * @param premulAlpha defines if alpha is stored as premultiplied
  45212. * @param format defines the format of the data
  45213. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45214. */
  45215. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  45216. /**
  45217. * Update a portion of an internal texture
  45218. * @param texture defines the texture to update
  45219. * @param imageData defines the data to store into the texture
  45220. * @param xOffset defines the x coordinates of the update rectangle
  45221. * @param yOffset defines the y coordinates of the update rectangle
  45222. * @param width defines the width of the update rectangle
  45223. * @param height defines the height of the update rectangle
  45224. * @param faceIndex defines the face index if texture is a cube (0 by default)
  45225. * @param lod defines the lod level to update (0 by default)
  45226. */
  45227. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  45228. /**
  45229. * Update a video texture
  45230. * @param texture defines the texture to update
  45231. * @param video defines the video element to use
  45232. * @param invertY defines if data must be stored with Y axis inverted
  45233. */
  45234. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  45235. /** @hidden */
  45236. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45237. /** @hidden */
  45238. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  45239. /** @hidden */
  45240. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45241. /** @hidden */
  45242. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  45243. /**
  45244. * Update a raw texture
  45245. * @param texture defines the texture to update
  45246. * @param bufferView defines the data to store in the texture
  45247. * @param format defines the format of the data
  45248. * @param invertY defines if data must be stored with Y axis inverted
  45249. * @param compression defines the compression used (null by default)
  45250. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45251. */
  45252. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  45253. /**
  45254. * Update a raw cube texture
  45255. * @param texture defines the texture to udpdate
  45256. * @param bufferView defines the data to store
  45257. * @param format defines the data format
  45258. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45259. * @param invertY defines if data must be stored with Y axis inverted
  45260. * @param compression defines the compression used (null by default)
  45261. * @param level defines which level of the texture to update
  45262. */
  45263. updateRawCubeTexture(texture: InternalTexture, bufferView: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  45264. /**
  45265. * Update a raw 2D array texture
  45266. * @param texture defines the texture to update
  45267. * @param bufferView defines the data to store
  45268. * @param format defines the data format
  45269. * @param invertY defines if data must be stored with Y axis inverted
  45270. * @param compression defines the used compression (can be null)
  45271. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45272. */
  45273. updateRawTexture2DArray(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  45274. /**
  45275. * Update a raw 3D texture
  45276. * @param texture defines the texture to update
  45277. * @param bufferView defines the data to store
  45278. * @param format defines the data format
  45279. * @param invertY defines if data must be stored with Y axis inverted
  45280. * @param compression defines the used compression (can be null)
  45281. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45282. */
  45283. updateRawTexture3D(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  45284. /**
  45285. * Reads pixels from the current frame buffer. Please note that this function can be slow
  45286. * @param x defines the x coordinate of the rectangle where pixels must be read
  45287. * @param y defines the y coordinate of the rectangle where pixels must be read
  45288. * @param width defines the width of the rectangle where pixels must be read
  45289. * @param height defines the height of the rectangle where pixels must be read
  45290. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  45291. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  45292. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  45293. */
  45294. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  45295. /** @hidden */
  45296. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  45297. /**
  45298. * Creates a new render target texture
  45299. * @param size defines the size of the texture
  45300. * @param options defines the options used to create the texture
  45301. * @returns a new render target texture stored in an InternalTexture
  45302. */
  45303. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45304. /**
  45305. * Create a multi render target texture
  45306. * @param size defines the size of the texture
  45307. * @param options defines the creation options
  45308. * @returns the cube texture as an InternalTexture
  45309. */
  45310. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45311. /**
  45312. * Creates a new render target cube texture
  45313. * @param size defines the size of the texture
  45314. * @param options defines the options used to create the texture
  45315. * @returns a new render target cube texture stored in an InternalTexture
  45316. */
  45317. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  45318. /** @hidden */
  45319. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  45320. width: number;
  45321. height: number;
  45322. layers?: number;
  45323. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  45324. /** @hidden */
  45325. _createDepthStencilTexture(size: number | {
  45326. width: number;
  45327. height: number;
  45328. layers?: number;
  45329. }, options: DepthTextureCreationOptions): InternalTexture;
  45330. /** @hidden */
  45331. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  45332. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  45333. /**
  45334. * Update the sample count for a given multiple render target texture
  45335. * @param textures defines the textures to update
  45336. * @param samples defines the sample count to set
  45337. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45338. */
  45339. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45340. /**
  45341. * Begin a new frame
  45342. */
  45343. beginFrame(): void;
  45344. /**
  45345. * End the current frame
  45346. */
  45347. endFrame(): void;
  45348. /**
  45349. * Force a WebGPU flush (ie. a flush of all waiting commands)
  45350. */
  45351. flushFramebuffer(): void;
  45352. private _startRenderTargetRenderPass;
  45353. private _endRenderTargetRenderPass;
  45354. private _getCurrentRenderPass;
  45355. private _currentRenderPassIsMRT;
  45356. private _startMainRenderPass;
  45357. private _endMainRenderPass;
  45358. /**
  45359. * Restores the WebGPU state to only draw on the main color attachment
  45360. */
  45361. restoreSingleAttachment(): void;
  45362. /**
  45363. * Creates a layout object to draw/clear on specific textures in a MRT
  45364. * @param textureStatus textureStatus[i] indicates if the i-th is active
  45365. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  45366. */
  45367. buildTextureLayout(textureStatus: boolean[]): number[];
  45368. /**
  45369. * Select a subsets of attachments to draw to.
  45370. * @param attachments index of attachments
  45371. */
  45372. bindAttachments(attachments: number[]): void;
  45373. /**
  45374. * Binds the frame buffer to the specified texture.
  45375. * @param texture The texture to render to or null for the default canvas
  45376. * @param faceIndex The face of the texture to render to in case of cube texture
  45377. * @param requiredWidth The width of the target to render to
  45378. * @param requiredHeight The height of the target to render to
  45379. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45380. * @param lodLevel defines the lod level to bind to the frame buffer
  45381. * @param layer defines the 2d array index to bind to frame buffer to
  45382. */
  45383. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  45384. /**
  45385. * Unbind the current render target texture from the WebGPU context
  45386. * @param texture defines the render target texture to unbind
  45387. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45388. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45389. */
  45390. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45391. /**
  45392. * Unbind a list of render target textures from the WebGPU context
  45393. * @param textures defines the render target textures to unbind
  45394. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45395. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45396. */
  45397. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45398. /**
  45399. * Unbind the current render target and bind the default framebuffer
  45400. */
  45401. restoreDefaultFramebuffer(): void;
  45402. setZOffset(value: number): void;
  45403. private _setColorFormat;
  45404. private _setDepthTextureFormat;
  45405. setDepthBuffer(enable: boolean): void;
  45406. setDepthWrite(enable: boolean): void;
  45407. setStencilBuffer(enable: boolean): void;
  45408. setStencilMask(mask: number): void;
  45409. setStencilFunction(stencilFunc: number): void;
  45410. setStencilFunctionReference(reference: number): void;
  45411. setStencilFunctionMask(mask: number): void;
  45412. setStencilOperationFail(operation: number): void;
  45413. setStencilOperationDepthFail(operation: number): void;
  45414. setStencilOperationPass(operation: number): void;
  45415. setDitheringState(value: boolean): void;
  45416. setRasterizerState(value: boolean): void;
  45417. setDepthFunction(depthFunc: number): void;
  45418. setDepthFunctionToGreater(): void;
  45419. setDepthFunctionToGreaterOrEqual(): void;
  45420. setDepthFunctionToLess(): void;
  45421. setDepthFunctionToLessOrEqual(): void;
  45422. private _indexFormatInRenderPass;
  45423. private _getTopology;
  45424. private _getOpFunction;
  45425. private _getDepthStencilStateDescriptor;
  45426. /**
  45427. * Set various states to the context
  45428. * @param culling defines backface culling state
  45429. * @param zOffset defines the value to apply to zOffset (0 by default)
  45430. * @param force defines if states must be applied even if cache is up to date
  45431. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45432. */
  45433. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45434. private _getFrontFace;
  45435. private _getCullMode;
  45436. private _getRasterizationStateDescriptor;
  45437. private _getWriteMask;
  45438. /**
  45439. * Sets the current alpha mode
  45440. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45441. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45442. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45443. */
  45444. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45445. private _getAphaBlendOperation;
  45446. private _getAphaBlendFactor;
  45447. private _getAphaBlendState;
  45448. private _getColorBlendState;
  45449. private _getColorStateDescriptors;
  45450. private _getStages;
  45451. private _getVertexInputDescriptorFormat;
  45452. private _getVertexInputDescriptor;
  45453. private _getPipelineLayout;
  45454. private _getRenderPipeline;
  45455. private _getVertexInputsToRender;
  45456. private _getBindGroupsToRender;
  45457. private _bindVertexInputs;
  45458. private _setRenderBindGroups;
  45459. private _setRenderPipeline;
  45460. /**
  45461. * Draw a list of indexed primitives
  45462. * @param fillMode defines the primitive to use
  45463. * @param indexStart defines the starting index
  45464. * @param indexCount defines the number of index to draw
  45465. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45466. */
  45467. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45468. /**
  45469. * Draw a list of unindexed primitives
  45470. * @param fillMode defines the primitive to use
  45471. * @param verticesStart defines the index of first vertex to draw
  45472. * @param verticesCount defines the count of vertices to draw
  45473. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45474. */
  45475. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45476. private _bundleEncoder;
  45477. /**
  45478. * Start recording all the gpu calls into a bundle.
  45479. */
  45480. startRecordBundle(): void;
  45481. /**
  45482. * Stops recording the bundle.
  45483. * @returns the recorded bundle
  45484. */
  45485. stopRecordBundle(): GPURenderBundle;
  45486. /**
  45487. * Execute the previously recorded bundle.
  45488. * @param bundles defines the bundle to replay
  45489. */
  45490. executeBundles(bundles: GPURenderBundle[]): void;
  45491. /**
  45492. * Dispose and release all associated resources
  45493. */
  45494. dispose(): void;
  45495. /**
  45496. * Gets the current render width
  45497. * @param useScreen defines if screen size must be used (or the current render target if any)
  45498. * @returns a number defining the current render width
  45499. */
  45500. getRenderWidth(useScreen?: boolean): number;
  45501. /**
  45502. * Gets the current render height
  45503. * @param useScreen defines if screen size must be used (or the current render target if any)
  45504. * @returns a number defining the current render height
  45505. */
  45506. getRenderHeight(useScreen?: boolean): number;
  45507. /**
  45508. * Gets the HTML canvas attached with the current WebGPU context
  45509. * @returns a HTML canvas
  45510. */
  45511. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  45512. /** @hidden */
  45513. _debugPushGroup(groupName: string, targetObject?: number): void;
  45514. /** @hidden */
  45515. _debugPopGroup(targetObject?: number): void;
  45516. /** @hidden */
  45517. _debugInsertMarker(text: string, targetObject?: number): void;
  45518. private _debugFlushPendingCommands;
  45519. /**
  45520. * Get the current error code of the WebGPU context
  45521. * @returns the error code
  45522. */
  45523. getError(): number;
  45524. /** @hidden */
  45525. bindSamplers(effect: Effect): void;
  45526. /** @hidden */
  45527. _bindTextureDirectly(target: number, texture: InternalTexture, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  45528. /** @hidden */
  45529. _releaseFramebufferObjects(texture: InternalTexture): void;
  45530. /** @hidden */
  45531. applyStates(): void;
  45532. /**
  45533. * Gets a boolean indicating if all created effects are ready
  45534. * @returns always true - No parallel shader compilation
  45535. */
  45536. areAllEffectsReady(): boolean;
  45537. /** @hidden */
  45538. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45539. /** @hidden */
  45540. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45541. /** @hidden */
  45542. _getUnpackAlignement(): number;
  45543. /** @hidden */
  45544. _unpackFlipY(value: boolean): void;
  45545. /** @hidden */
  45546. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  45547. min: number;
  45548. mag: number;
  45549. };
  45550. /** @hidden */
  45551. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45552. /** @hidden */
  45553. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45554. /** @hidden */
  45555. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45556. /** @hidden */
  45557. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45558. /** @hidden */
  45559. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45560. /** @hidden */
  45561. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45562. /** @hidden */
  45563. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  45564. /** @hidden */
  45565. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  45566. /** @hidden */
  45567. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  45568. /** @hidden */
  45569. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  45570. /** @hidden */
  45571. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  45572. /** @hidden */
  45573. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  45574. /** @hidden */
  45575. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  45576. /** @hidden */
  45577. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  45578. /** @hidden */
  45579. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  45580. /** @hidden */
  45581. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  45582. /** @hidden */
  45583. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  45584. }
  45585. }
  45586. declare module BABYLON {
  45587. /**
  45588. * Define an interface for all classes that will hold resources
  45589. */
  45590. export interface IDisposable {
  45591. /**
  45592. * Releases all held resources
  45593. */
  45594. dispose(): void;
  45595. }
  45596. /** Interface defining initialization parameters for Scene class */
  45597. export interface SceneOptions {
  45598. /**
  45599. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  45600. * It will improve performance when the number of geometries becomes important.
  45601. */
  45602. useGeometryUniqueIdsMap?: boolean;
  45603. /**
  45604. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  45605. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  45606. */
  45607. useMaterialMeshMap?: boolean;
  45608. /**
  45609. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  45610. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  45611. */
  45612. useClonedMeshMap?: boolean;
  45613. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  45614. virtual?: boolean;
  45615. }
  45616. /**
  45617. * Represents a scene to be rendered by the engine.
  45618. * @see https://doc.babylonjs.com/features/scene
  45619. */
  45620. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  45621. /** The fog is deactivated */
  45622. static readonly FOGMODE_NONE: number;
  45623. /** The fog density is following an exponential function */
  45624. static readonly FOGMODE_EXP: number;
  45625. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  45626. static readonly FOGMODE_EXP2: number;
  45627. /** The fog density is following a linear function. */
  45628. static readonly FOGMODE_LINEAR: number;
  45629. /**
  45630. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  45631. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45632. */
  45633. static MinDeltaTime: number;
  45634. /**
  45635. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  45636. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45637. */
  45638. static MaxDeltaTime: number;
  45639. /**
  45640. * Factory used to create the default material.
  45641. * @param name The name of the material to create
  45642. * @param scene The scene to create the material for
  45643. * @returns The default material
  45644. */
  45645. static DefaultMaterialFactory(scene: Scene): Material;
  45646. /**
  45647. * Factory used to create the a collision coordinator.
  45648. * @returns The collision coordinator
  45649. */
  45650. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  45651. /** @hidden */
  45652. _inputManager: InputManager;
  45653. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  45654. cameraToUseForPointers: Nullable<Camera>;
  45655. /** @hidden */
  45656. readonly _isScene: boolean;
  45657. /** @hidden */
  45658. _blockEntityCollection: boolean;
  45659. /**
  45660. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  45661. */
  45662. autoClear: boolean;
  45663. /**
  45664. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  45665. */
  45666. autoClearDepthAndStencil: boolean;
  45667. /**
  45668. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  45669. */
  45670. clearColor: Color4;
  45671. /**
  45672. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  45673. */
  45674. ambientColor: Color3;
  45675. /**
  45676. * This is use to store the default BRDF lookup for PBR materials in your scene.
  45677. * It should only be one of the following (if not the default embedded one):
  45678. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45679. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  45680. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45681. * The material properties need to be setup according to the type of texture in use.
  45682. */
  45683. environmentBRDFTexture: BaseTexture;
  45684. /**
  45685. * Texture used in all pbr material as the reflection texture.
  45686. * As in the majority of the scene they are the same (exception for multi room and so on),
  45687. * this is easier to reference from here than from all the materials.
  45688. */
  45689. get environmentTexture(): Nullable<BaseTexture>;
  45690. /**
  45691. * Texture used in all pbr material as the reflection texture.
  45692. * As in the majority of the scene they are the same (exception for multi room and so on),
  45693. * this is easier to set here than in all the materials.
  45694. */
  45695. set environmentTexture(value: Nullable<BaseTexture>);
  45696. /** @hidden */
  45697. protected _environmentIntensity: number;
  45698. /**
  45699. * Intensity of the environment in all pbr material.
  45700. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  45701. * As in the majority of the scene they are the same (exception for multi room and so on),
  45702. * this is easier to reference from here than from all the materials.
  45703. */
  45704. get environmentIntensity(): number;
  45705. /**
  45706. * Intensity of the environment in all pbr material.
  45707. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  45708. * As in the majority of the scene they are the same (exception for multi room and so on),
  45709. * this is easier to set here than in all the materials.
  45710. */
  45711. set environmentIntensity(value: number);
  45712. /** @hidden */
  45713. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45714. /**
  45715. * Default image processing configuration used either in the rendering
  45716. * Forward main pass or through the imageProcessingPostProcess if present.
  45717. * As in the majority of the scene they are the same (exception for multi camera),
  45718. * this is easier to reference from here than from all the materials and post process.
  45719. *
  45720. * No setter as we it is a shared configuration, you can set the values instead.
  45721. */
  45722. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45723. private _forceWireframe;
  45724. /**
  45725. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  45726. */
  45727. set forceWireframe(value: boolean);
  45728. get forceWireframe(): boolean;
  45729. private _skipFrustumClipping;
  45730. /**
  45731. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  45732. */
  45733. set skipFrustumClipping(value: boolean);
  45734. get skipFrustumClipping(): boolean;
  45735. private _forcePointsCloud;
  45736. /**
  45737. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  45738. */
  45739. set forcePointsCloud(value: boolean);
  45740. get forcePointsCloud(): boolean;
  45741. /**
  45742. * Gets or sets the active clipplane 1
  45743. */
  45744. clipPlane: Nullable<Plane>;
  45745. /**
  45746. * Gets or sets the active clipplane 2
  45747. */
  45748. clipPlane2: Nullable<Plane>;
  45749. /**
  45750. * Gets or sets the active clipplane 3
  45751. */
  45752. clipPlane3: Nullable<Plane>;
  45753. /**
  45754. * Gets or sets the active clipplane 4
  45755. */
  45756. clipPlane4: Nullable<Plane>;
  45757. /**
  45758. * Gets or sets the active clipplane 5
  45759. */
  45760. clipPlane5: Nullable<Plane>;
  45761. /**
  45762. * Gets or sets the active clipplane 6
  45763. */
  45764. clipPlane6: Nullable<Plane>;
  45765. /**
  45766. * Gets or sets a boolean indicating if animations are enabled
  45767. */
  45768. animationsEnabled: boolean;
  45769. private _animationPropertiesOverride;
  45770. /**
  45771. * Gets or sets the animation properties override
  45772. */
  45773. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  45774. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  45775. /**
  45776. * Gets or sets a boolean indicating if a constant deltatime has to be used
  45777. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  45778. */
  45779. useConstantAnimationDeltaTime: boolean;
  45780. /**
  45781. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  45782. * Please note that it requires to run a ray cast through the scene on every frame
  45783. */
  45784. constantlyUpdateMeshUnderPointer: boolean;
  45785. /**
  45786. * Defines the HTML cursor to use when hovering over interactive elements
  45787. */
  45788. hoverCursor: string;
  45789. /**
  45790. * Defines the HTML default cursor to use (empty by default)
  45791. */
  45792. defaultCursor: string;
  45793. /**
  45794. * Defines whether cursors are handled by the scene.
  45795. */
  45796. doNotHandleCursors: boolean;
  45797. /**
  45798. * This is used to call preventDefault() on pointer down
  45799. * in order to block unwanted artifacts like system double clicks
  45800. */
  45801. preventDefaultOnPointerDown: boolean;
  45802. /**
  45803. * This is used to call preventDefault() on pointer up
  45804. * in order to block unwanted artifacts like system double clicks
  45805. */
  45806. preventDefaultOnPointerUp: boolean;
  45807. /**
  45808. * Gets or sets user defined metadata
  45809. */
  45810. metadata: any;
  45811. /**
  45812. * For internal use only. Please do not use.
  45813. */
  45814. reservedDataStore: any;
  45815. /**
  45816. * Gets the name of the plugin used to load this scene (null by default)
  45817. */
  45818. loadingPluginName: string;
  45819. /**
  45820. * Use this array to add regular expressions used to disable offline support for specific urls
  45821. */
  45822. disableOfflineSupportExceptionRules: RegExp[];
  45823. /**
  45824. * An event triggered when the scene is disposed.
  45825. */
  45826. onDisposeObservable: Observable<Scene>;
  45827. private _onDisposeObserver;
  45828. /** Sets a function to be executed when this scene is disposed. */
  45829. set onDispose(callback: () => void);
  45830. /**
  45831. * An event triggered before rendering the scene (right after animations and physics)
  45832. */
  45833. onBeforeRenderObservable: Observable<Scene>;
  45834. private _onBeforeRenderObserver;
  45835. /** Sets a function to be executed before rendering this scene */
  45836. set beforeRender(callback: Nullable<() => void>);
  45837. /**
  45838. * An event triggered after rendering the scene
  45839. */
  45840. onAfterRenderObservable: Observable<Scene>;
  45841. /**
  45842. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  45843. */
  45844. onAfterRenderCameraObservable: Observable<Camera>;
  45845. private _onAfterRenderObserver;
  45846. /** Sets a function to be executed after rendering this scene */
  45847. set afterRender(callback: Nullable<() => void>);
  45848. /**
  45849. * An event triggered before animating the scene
  45850. */
  45851. onBeforeAnimationsObservable: Observable<Scene>;
  45852. /**
  45853. * An event triggered after animations processing
  45854. */
  45855. onAfterAnimationsObservable: Observable<Scene>;
  45856. /**
  45857. * An event triggered before draw calls are ready to be sent
  45858. */
  45859. onBeforeDrawPhaseObservable: Observable<Scene>;
  45860. /**
  45861. * An event triggered after draw calls have been sent
  45862. */
  45863. onAfterDrawPhaseObservable: Observable<Scene>;
  45864. /**
  45865. * An event triggered when the scene is ready
  45866. */
  45867. onReadyObservable: Observable<Scene>;
  45868. /**
  45869. * An event triggered before rendering a camera
  45870. */
  45871. onBeforeCameraRenderObservable: Observable<Camera>;
  45872. private _onBeforeCameraRenderObserver;
  45873. /** Sets a function to be executed before rendering a camera*/
  45874. set beforeCameraRender(callback: () => void);
  45875. /**
  45876. * An event triggered after rendering a camera
  45877. */
  45878. onAfterCameraRenderObservable: Observable<Camera>;
  45879. private _onAfterCameraRenderObserver;
  45880. /** Sets a function to be executed after rendering a camera*/
  45881. set afterCameraRender(callback: () => void);
  45882. /**
  45883. * An event triggered when active meshes evaluation is about to start
  45884. */
  45885. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  45886. /**
  45887. * An event triggered when active meshes evaluation is done
  45888. */
  45889. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  45890. /**
  45891. * An event triggered when particles rendering is about to start
  45892. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  45893. */
  45894. onBeforeParticlesRenderingObservable: Observable<Scene>;
  45895. /**
  45896. * An event triggered when particles rendering is done
  45897. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  45898. */
  45899. onAfterParticlesRenderingObservable: Observable<Scene>;
  45900. /**
  45901. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  45902. */
  45903. onDataLoadedObservable: Observable<Scene>;
  45904. /**
  45905. * An event triggered when a camera is created
  45906. */
  45907. onNewCameraAddedObservable: Observable<Camera>;
  45908. /**
  45909. * An event triggered when a camera is removed
  45910. */
  45911. onCameraRemovedObservable: Observable<Camera>;
  45912. /**
  45913. * An event triggered when a light is created
  45914. */
  45915. onNewLightAddedObservable: Observable<Light>;
  45916. /**
  45917. * An event triggered when a light is removed
  45918. */
  45919. onLightRemovedObservable: Observable<Light>;
  45920. /**
  45921. * An event triggered when a geometry is created
  45922. */
  45923. onNewGeometryAddedObservable: Observable<Geometry>;
  45924. /**
  45925. * An event triggered when a geometry is removed
  45926. */
  45927. onGeometryRemovedObservable: Observable<Geometry>;
  45928. /**
  45929. * An event triggered when a transform node is created
  45930. */
  45931. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  45932. /**
  45933. * An event triggered when a transform node is removed
  45934. */
  45935. onTransformNodeRemovedObservable: Observable<TransformNode>;
  45936. /**
  45937. * An event triggered when a mesh is created
  45938. */
  45939. onNewMeshAddedObservable: Observable<AbstractMesh>;
  45940. /**
  45941. * An event triggered when a mesh is removed
  45942. */
  45943. onMeshRemovedObservable: Observable<AbstractMesh>;
  45944. /**
  45945. * An event triggered when a skeleton is created
  45946. */
  45947. onNewSkeletonAddedObservable: Observable<Skeleton>;
  45948. /**
  45949. * An event triggered when a skeleton is removed
  45950. */
  45951. onSkeletonRemovedObservable: Observable<Skeleton>;
  45952. /**
  45953. * An event triggered when a material is created
  45954. */
  45955. onNewMaterialAddedObservable: Observable<Material>;
  45956. /**
  45957. * An event triggered when a multi material is created
  45958. */
  45959. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  45960. /**
  45961. * An event triggered when a material is removed
  45962. */
  45963. onMaterialRemovedObservable: Observable<Material>;
  45964. /**
  45965. * An event triggered when a multi material is removed
  45966. */
  45967. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  45968. /**
  45969. * An event triggered when a texture is created
  45970. */
  45971. onNewTextureAddedObservable: Observable<BaseTexture>;
  45972. /**
  45973. * An event triggered when a texture is removed
  45974. */
  45975. onTextureRemovedObservable: Observable<BaseTexture>;
  45976. /**
  45977. * An event triggered when render targets are about to be rendered
  45978. * Can happen multiple times per frame.
  45979. */
  45980. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  45981. /**
  45982. * An event triggered when render targets were rendered.
  45983. * Can happen multiple times per frame.
  45984. */
  45985. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  45986. /**
  45987. * An event triggered before calculating deterministic simulation step
  45988. */
  45989. onBeforeStepObservable: Observable<Scene>;
  45990. /**
  45991. * An event triggered after calculating deterministic simulation step
  45992. */
  45993. onAfterStepObservable: Observable<Scene>;
  45994. /**
  45995. * An event triggered when the activeCamera property is updated
  45996. */
  45997. onActiveCameraChanged: Observable<Scene>;
  45998. /**
  45999. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  46000. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  46001. * 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)
  46002. */
  46003. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  46004. /**
  46005. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  46006. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  46007. * 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)
  46008. */
  46009. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  46010. /**
  46011. * This Observable will when a mesh has been imported into the scene.
  46012. */
  46013. onMeshImportedObservable: Observable<AbstractMesh>;
  46014. /**
  46015. * This Observable will when an animation file has been imported into the scene.
  46016. */
  46017. onAnimationFileImportedObservable: Observable<Scene>;
  46018. /**
  46019. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  46020. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  46021. */
  46022. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  46023. /** @hidden */
  46024. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  46025. /**
  46026. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  46027. */
  46028. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  46029. /**
  46030. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  46031. */
  46032. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  46033. /**
  46034. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  46035. */
  46036. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  46037. /** Callback called when a pointer move is detected */
  46038. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  46039. /** Callback called when a pointer down is detected */
  46040. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  46041. /** Callback called when a pointer up is detected */
  46042. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  46043. /** Callback called when a pointer pick is detected */
  46044. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  46045. /**
  46046. * 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).
  46047. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  46048. */
  46049. onPrePointerObservable: Observable<PointerInfoPre>;
  46050. /**
  46051. * Observable event triggered each time an input event is received from the rendering canvas
  46052. */
  46053. onPointerObservable: Observable<PointerInfo>;
  46054. /**
  46055. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  46056. */
  46057. get unTranslatedPointer(): Vector2;
  46058. /**
  46059. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  46060. */
  46061. static get DragMovementThreshold(): number;
  46062. static set DragMovementThreshold(value: number);
  46063. /**
  46064. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  46065. */
  46066. static get LongPressDelay(): number;
  46067. static set LongPressDelay(value: number);
  46068. /**
  46069. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  46070. */
  46071. static get DoubleClickDelay(): number;
  46072. static set DoubleClickDelay(value: number);
  46073. /** If you need to check double click without raising a single click at first click, enable this flag */
  46074. static get ExclusiveDoubleClickMode(): boolean;
  46075. static set ExclusiveDoubleClickMode(value: boolean);
  46076. /** @hidden */
  46077. _mirroredCameraPosition: Nullable<Vector3>;
  46078. /**
  46079. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  46080. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  46081. */
  46082. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  46083. /**
  46084. * Observable event triggered each time an keyboard event is received from the hosting window
  46085. */
  46086. onKeyboardObservable: Observable<KeyboardInfo>;
  46087. private _useRightHandedSystem;
  46088. /**
  46089. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  46090. */
  46091. set useRightHandedSystem(value: boolean);
  46092. get useRightHandedSystem(): boolean;
  46093. private _timeAccumulator;
  46094. private _currentStepId;
  46095. private _currentInternalStep;
  46096. /**
  46097. * Sets the step Id used by deterministic lock step
  46098. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46099. * @param newStepId defines the step Id
  46100. */
  46101. setStepId(newStepId: number): void;
  46102. /**
  46103. * Gets the step Id used by deterministic lock step
  46104. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46105. * @returns the step Id
  46106. */
  46107. getStepId(): number;
  46108. /**
  46109. * Gets the internal step used by deterministic lock step
  46110. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46111. * @returns the internal step
  46112. */
  46113. getInternalStep(): number;
  46114. private _fogEnabled;
  46115. /**
  46116. * Gets or sets a boolean indicating if fog is enabled on this scene
  46117. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46118. * (Default is true)
  46119. */
  46120. set fogEnabled(value: boolean);
  46121. get fogEnabled(): boolean;
  46122. private _fogMode;
  46123. /**
  46124. * Gets or sets the fog mode to use
  46125. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46126. * | mode | value |
  46127. * | --- | --- |
  46128. * | FOGMODE_NONE | 0 |
  46129. * | FOGMODE_EXP | 1 |
  46130. * | FOGMODE_EXP2 | 2 |
  46131. * | FOGMODE_LINEAR | 3 |
  46132. */
  46133. set fogMode(value: number);
  46134. get fogMode(): number;
  46135. /**
  46136. * Gets or sets the fog color to use
  46137. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46138. * (Default is Color3(0.2, 0.2, 0.3))
  46139. */
  46140. fogColor: Color3;
  46141. /**
  46142. * Gets or sets the fog density to use
  46143. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46144. * (Default is 0.1)
  46145. */
  46146. fogDensity: number;
  46147. /**
  46148. * Gets or sets the fog start distance to use
  46149. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46150. * (Default is 0)
  46151. */
  46152. fogStart: number;
  46153. /**
  46154. * Gets or sets the fog end distance to use
  46155. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46156. * (Default is 1000)
  46157. */
  46158. fogEnd: number;
  46159. /**
  46160. * Flag indicating that the frame buffer binding is handled by another component
  46161. */
  46162. prePass: boolean;
  46163. private _shadowsEnabled;
  46164. /**
  46165. * Gets or sets a boolean indicating if shadows are enabled on this scene
  46166. */
  46167. set shadowsEnabled(value: boolean);
  46168. get shadowsEnabled(): boolean;
  46169. private _lightsEnabled;
  46170. /**
  46171. * Gets or sets a boolean indicating if lights are enabled on this scene
  46172. */
  46173. set lightsEnabled(value: boolean);
  46174. get lightsEnabled(): boolean;
  46175. /** All of the active cameras added to this scene. */
  46176. activeCameras: Nullable<Camera[]>;
  46177. /** @hidden */
  46178. _activeCamera: Nullable<Camera>;
  46179. /** Gets or sets the current active camera */
  46180. get activeCamera(): Nullable<Camera>;
  46181. set activeCamera(value: Nullable<Camera>);
  46182. private _defaultMaterial;
  46183. /** The default material used on meshes when no material is affected */
  46184. get defaultMaterial(): Material;
  46185. /** The default material used on meshes when no material is affected */
  46186. set defaultMaterial(value: Material);
  46187. private _texturesEnabled;
  46188. /**
  46189. * Gets or sets a boolean indicating if textures are enabled on this scene
  46190. */
  46191. set texturesEnabled(value: boolean);
  46192. get texturesEnabled(): boolean;
  46193. /**
  46194. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  46195. */
  46196. physicsEnabled: boolean;
  46197. /**
  46198. * Gets or sets a boolean indicating if particles are enabled on this scene
  46199. */
  46200. particlesEnabled: boolean;
  46201. /**
  46202. * Gets or sets a boolean indicating if sprites are enabled on this scene
  46203. */
  46204. spritesEnabled: boolean;
  46205. private _skeletonsEnabled;
  46206. /**
  46207. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  46208. */
  46209. set skeletonsEnabled(value: boolean);
  46210. get skeletonsEnabled(): boolean;
  46211. /**
  46212. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  46213. */
  46214. lensFlaresEnabled: boolean;
  46215. /**
  46216. * Gets or sets a boolean indicating if collisions are enabled on this scene
  46217. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  46218. */
  46219. collisionsEnabled: boolean;
  46220. private _collisionCoordinator;
  46221. /** @hidden */
  46222. get collisionCoordinator(): ICollisionCoordinator;
  46223. /**
  46224. * Defines the gravity applied to this scene (used only for collisions)
  46225. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  46226. */
  46227. gravity: Vector3;
  46228. /**
  46229. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  46230. */
  46231. postProcessesEnabled: boolean;
  46232. /**
  46233. * Gets the current postprocess manager
  46234. */
  46235. postProcessManager: PostProcessManager;
  46236. /**
  46237. * Gets or sets a boolean indicating if render targets are enabled on this scene
  46238. */
  46239. renderTargetsEnabled: boolean;
  46240. /**
  46241. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  46242. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  46243. */
  46244. dumpNextRenderTargets: boolean;
  46245. /**
  46246. * The list of user defined render targets added to the scene
  46247. */
  46248. customRenderTargets: RenderTargetTexture[];
  46249. /**
  46250. * Defines if texture loading must be delayed
  46251. * If true, textures will only be loaded when they need to be rendered
  46252. */
  46253. useDelayedTextureLoading: boolean;
  46254. /**
  46255. * Gets the list of meshes imported to the scene through SceneLoader
  46256. */
  46257. importedMeshesFiles: String[];
  46258. /**
  46259. * Gets or sets a boolean indicating if probes are enabled on this scene
  46260. */
  46261. probesEnabled: boolean;
  46262. /**
  46263. * Gets or sets the current offline provider to use to store scene data
  46264. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  46265. */
  46266. offlineProvider: IOfflineProvider;
  46267. /**
  46268. * Gets or sets the action manager associated with the scene
  46269. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  46270. */
  46271. actionManager: AbstractActionManager;
  46272. private _meshesForIntersections;
  46273. /**
  46274. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  46275. */
  46276. proceduralTexturesEnabled: boolean;
  46277. private _engine;
  46278. private _totalVertices;
  46279. /** @hidden */
  46280. _activeIndices: PerfCounter;
  46281. /** @hidden */
  46282. _activeParticles: PerfCounter;
  46283. /** @hidden */
  46284. _activeBones: PerfCounter;
  46285. private _animationRatio;
  46286. /** @hidden */
  46287. _animationTimeLast: number;
  46288. /** @hidden */
  46289. _animationTime: number;
  46290. /**
  46291. * Gets or sets a general scale for animation speed
  46292. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  46293. */
  46294. animationTimeScale: number;
  46295. /** @hidden */
  46296. _cachedMaterial: Nullable<Material>;
  46297. /** @hidden */
  46298. _cachedEffect: Nullable<Effect>;
  46299. /** @hidden */
  46300. _cachedVisibility: Nullable<number>;
  46301. private _renderId;
  46302. private _frameId;
  46303. private _executeWhenReadyTimeoutId;
  46304. private _intermediateRendering;
  46305. private _viewUpdateFlag;
  46306. private _projectionUpdateFlag;
  46307. /** @hidden */
  46308. _toBeDisposed: Nullable<IDisposable>[];
  46309. private _activeRequests;
  46310. /** @hidden */
  46311. _pendingData: any[];
  46312. private _isDisposed;
  46313. /**
  46314. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  46315. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  46316. */
  46317. dispatchAllSubMeshesOfActiveMeshes: boolean;
  46318. private _activeMeshes;
  46319. private _processedMaterials;
  46320. private _renderTargets;
  46321. /** @hidden */
  46322. _activeParticleSystems: SmartArray<IParticleSystem>;
  46323. private _activeSkeletons;
  46324. private _softwareSkinnedMeshes;
  46325. private _renderingManager;
  46326. /** @hidden */
  46327. _activeAnimatables: Animatable[];
  46328. private _transformMatrix;
  46329. private _sceneUbo;
  46330. /** @hidden */
  46331. _viewMatrix: Matrix;
  46332. /** @hidden */
  46333. _projectionMatrix: Matrix;
  46334. /** @hidden */
  46335. _forcedViewPosition: Nullable<Vector3>;
  46336. /** @hidden */
  46337. _frustumPlanes: Plane[];
  46338. /**
  46339. * Gets the list of frustum planes (built from the active camera)
  46340. */
  46341. get frustumPlanes(): Plane[];
  46342. /**
  46343. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  46344. * This is useful if there are more lights that the maximum simulteanous authorized
  46345. */
  46346. requireLightSorting: boolean;
  46347. /** @hidden */
  46348. readonly useMaterialMeshMap: boolean;
  46349. /** @hidden */
  46350. readonly useClonedMeshMap: boolean;
  46351. private _externalData;
  46352. private _uid;
  46353. /**
  46354. * @hidden
  46355. * Backing store of defined scene components.
  46356. */
  46357. _components: ISceneComponent[];
  46358. /**
  46359. * @hidden
  46360. * Backing store of defined scene components.
  46361. */
  46362. _serializableComponents: ISceneSerializableComponent[];
  46363. /**
  46364. * List of components to register on the next registration step.
  46365. */
  46366. private _transientComponents;
  46367. /**
  46368. * Registers the transient components if needed.
  46369. */
  46370. private _registerTransientComponents;
  46371. /**
  46372. * @hidden
  46373. * Add a component to the scene.
  46374. * Note that the ccomponent could be registered on th next frame if this is called after
  46375. * the register component stage.
  46376. * @param component Defines the component to add to the scene
  46377. */
  46378. _addComponent(component: ISceneComponent): void;
  46379. /**
  46380. * @hidden
  46381. * Gets a component from the scene.
  46382. * @param name defines the name of the component to retrieve
  46383. * @returns the component or null if not present
  46384. */
  46385. _getComponent(name: string): Nullable<ISceneComponent>;
  46386. /**
  46387. * @hidden
  46388. * Defines the actions happening before camera updates.
  46389. */
  46390. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  46391. /**
  46392. * @hidden
  46393. * Defines the actions happening before clear the canvas.
  46394. */
  46395. _beforeClearStage: Stage<SimpleStageAction>;
  46396. /**
  46397. * @hidden
  46398. * Defines the actions when collecting render targets for the frame.
  46399. */
  46400. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  46401. /**
  46402. * @hidden
  46403. * Defines the actions happening for one camera in the frame.
  46404. */
  46405. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  46406. /**
  46407. * @hidden
  46408. * Defines the actions happening during the per mesh ready checks.
  46409. */
  46410. _isReadyForMeshStage: Stage<MeshStageAction>;
  46411. /**
  46412. * @hidden
  46413. * Defines the actions happening before evaluate active mesh checks.
  46414. */
  46415. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  46416. /**
  46417. * @hidden
  46418. * Defines the actions happening during the evaluate sub mesh checks.
  46419. */
  46420. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  46421. /**
  46422. * @hidden
  46423. * Defines the actions happening during the active mesh stage.
  46424. */
  46425. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  46426. /**
  46427. * @hidden
  46428. * Defines the actions happening during the per camera render target step.
  46429. */
  46430. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  46431. /**
  46432. * @hidden
  46433. * Defines the actions happening just before the active camera is drawing.
  46434. */
  46435. _beforeCameraDrawStage: Stage<CameraStageAction>;
  46436. /**
  46437. * @hidden
  46438. * Defines the actions happening just before a render target is drawing.
  46439. */
  46440. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  46441. /**
  46442. * @hidden
  46443. * Defines the actions happening just before a rendering group is drawing.
  46444. */
  46445. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  46446. /**
  46447. * @hidden
  46448. * Defines the actions happening just before a mesh is drawing.
  46449. */
  46450. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  46451. /**
  46452. * @hidden
  46453. * Defines the actions happening just after a mesh has been drawn.
  46454. */
  46455. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  46456. /**
  46457. * @hidden
  46458. * Defines the actions happening just after a rendering group has been drawn.
  46459. */
  46460. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  46461. /**
  46462. * @hidden
  46463. * Defines the actions happening just after the active camera has been drawn.
  46464. */
  46465. _afterCameraDrawStage: Stage<CameraStageAction>;
  46466. /**
  46467. * @hidden
  46468. * Defines the actions happening just after a render target has been drawn.
  46469. */
  46470. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  46471. /**
  46472. * @hidden
  46473. * Defines the actions happening just after rendering all cameras and computing intersections.
  46474. */
  46475. _afterRenderStage: Stage<SimpleStageAction>;
  46476. /**
  46477. * @hidden
  46478. * Defines the actions happening when a pointer move event happens.
  46479. */
  46480. _pointerMoveStage: Stage<PointerMoveStageAction>;
  46481. /**
  46482. * @hidden
  46483. * Defines the actions happening when a pointer down event happens.
  46484. */
  46485. _pointerDownStage: Stage<PointerUpDownStageAction>;
  46486. /**
  46487. * @hidden
  46488. * Defines the actions happening when a pointer up event happens.
  46489. */
  46490. _pointerUpStage: Stage<PointerUpDownStageAction>;
  46491. /**
  46492. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  46493. */
  46494. private geometriesByUniqueId;
  46495. private _renderBundles;
  46496. /**
  46497. * Creates a new Scene
  46498. * @param engine defines the engine to use to render this scene
  46499. * @param options defines the scene options
  46500. */
  46501. constructor(engine: Engine, options?: SceneOptions);
  46502. /**
  46503. * Gets a string identifying the name of the class
  46504. * @returns "Scene" string
  46505. */
  46506. getClassName(): string;
  46507. private _defaultMeshCandidates;
  46508. /**
  46509. * @hidden
  46510. */
  46511. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46512. private _defaultSubMeshCandidates;
  46513. /**
  46514. * @hidden
  46515. */
  46516. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46517. /**
  46518. * Sets the default candidate providers for the scene.
  46519. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  46520. * and getCollidingSubMeshCandidates to their default function
  46521. */
  46522. setDefaultCandidateProviders(): void;
  46523. /**
  46524. * Gets the mesh that is currently under the pointer
  46525. */
  46526. get meshUnderPointer(): Nullable<AbstractMesh>;
  46527. /**
  46528. * Gets or sets the current on-screen X position of the pointer
  46529. */
  46530. get pointerX(): number;
  46531. set pointerX(value: number);
  46532. /**
  46533. * Gets or sets the current on-screen Y position of the pointer
  46534. */
  46535. get pointerY(): number;
  46536. set pointerY(value: number);
  46537. /**
  46538. * Gets the cached material (ie. the latest rendered one)
  46539. * @returns the cached material
  46540. */
  46541. getCachedMaterial(): Nullable<Material>;
  46542. /**
  46543. * Gets the cached effect (ie. the latest rendered one)
  46544. * @returns the cached effect
  46545. */
  46546. getCachedEffect(): Nullable<Effect>;
  46547. /**
  46548. * Gets the cached visibility state (ie. the latest rendered one)
  46549. * @returns the cached visibility state
  46550. */
  46551. getCachedVisibility(): Nullable<number>;
  46552. /**
  46553. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  46554. * @param material defines the current material
  46555. * @param effect defines the current effect
  46556. * @param visibility defines the current visibility state
  46557. * @returns true if one parameter is not cached
  46558. */
  46559. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  46560. /**
  46561. * Gets the engine associated with the scene
  46562. * @returns an Engine
  46563. */
  46564. getEngine(): Engine;
  46565. /**
  46566. * Gets the total number of vertices rendered per frame
  46567. * @returns the total number of vertices rendered per frame
  46568. */
  46569. getTotalVertices(): number;
  46570. /**
  46571. * Gets the performance counter for total vertices
  46572. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46573. */
  46574. get totalVerticesPerfCounter(): PerfCounter;
  46575. /**
  46576. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  46577. * @returns the total number of active indices rendered per frame
  46578. */
  46579. getActiveIndices(): number;
  46580. /**
  46581. * Gets the performance counter for active indices
  46582. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46583. */
  46584. get totalActiveIndicesPerfCounter(): PerfCounter;
  46585. /**
  46586. * Gets the total number of active particles rendered per frame
  46587. * @returns the total number of active particles rendered per frame
  46588. */
  46589. getActiveParticles(): number;
  46590. /**
  46591. * Gets the performance counter for active particles
  46592. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46593. */
  46594. get activeParticlesPerfCounter(): PerfCounter;
  46595. /**
  46596. * Gets the total number of active bones rendered per frame
  46597. * @returns the total number of active bones rendered per frame
  46598. */
  46599. getActiveBones(): number;
  46600. /**
  46601. * Gets the performance counter for active bones
  46602. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46603. */
  46604. get activeBonesPerfCounter(): PerfCounter;
  46605. /**
  46606. * Gets the array of active meshes
  46607. * @returns an array of AbstractMesh
  46608. */
  46609. getActiveMeshes(): SmartArray<AbstractMesh>;
  46610. /**
  46611. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  46612. * @returns a number
  46613. */
  46614. getAnimationRatio(): number;
  46615. /**
  46616. * Gets an unique Id for the current render phase
  46617. * @returns a number
  46618. */
  46619. getRenderId(): number;
  46620. /**
  46621. * Gets an unique Id for the current frame
  46622. * @returns a number
  46623. */
  46624. getFrameId(): number;
  46625. /** Call this function if you want to manually increment the render Id*/
  46626. incrementRenderId(): void;
  46627. private _createUbo;
  46628. /**
  46629. * Use this method to simulate a pointer move on a mesh
  46630. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  46631. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  46632. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  46633. * @returns the current scene
  46634. */
  46635. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  46636. /**
  46637. * Use this method to simulate a pointer down on a mesh
  46638. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  46639. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  46640. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  46641. * @returns the current scene
  46642. */
  46643. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  46644. /**
  46645. * Use this method to simulate a pointer up on a mesh
  46646. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  46647. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  46648. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  46649. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  46650. * @returns the current scene
  46651. */
  46652. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  46653. /**
  46654. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  46655. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  46656. * @returns true if the pointer was captured
  46657. */
  46658. isPointerCaptured(pointerId?: number): boolean;
  46659. /**
  46660. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  46661. * @param attachUp defines if you want to attach events to pointerup
  46662. * @param attachDown defines if you want to attach events to pointerdown
  46663. * @param attachMove defines if you want to attach events to pointermove
  46664. */
  46665. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  46666. /** Detaches all event handlers*/
  46667. detachControl(): void;
  46668. /**
  46669. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  46670. * Delay loaded resources are not taking in account
  46671. * @return true if all required resources are ready
  46672. */
  46673. isReady(): boolean;
  46674. /** Resets all cached information relative to material (including effect and visibility) */
  46675. resetCachedMaterial(): void;
  46676. /**
  46677. * Registers a function to be called before every frame render
  46678. * @param func defines the function to register
  46679. */
  46680. registerBeforeRender(func: () => void): void;
  46681. /**
  46682. * Unregisters a function called before every frame render
  46683. * @param func defines the function to unregister
  46684. */
  46685. unregisterBeforeRender(func: () => void): void;
  46686. /**
  46687. * Registers a function to be called after every frame render
  46688. * @param func defines the function to register
  46689. */
  46690. registerAfterRender(func: () => void): void;
  46691. /**
  46692. * Unregisters a function called after every frame render
  46693. * @param func defines the function to unregister
  46694. */
  46695. unregisterAfterRender(func: () => void): void;
  46696. private _executeOnceBeforeRender;
  46697. /**
  46698. * The provided function will run before render once and will be disposed afterwards.
  46699. * A timeout delay can be provided so that the function will be executed in N ms.
  46700. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  46701. * @param func The function to be executed.
  46702. * @param timeout optional delay in ms
  46703. */
  46704. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  46705. /** @hidden */
  46706. _addPendingData(data: any): void;
  46707. /** @hidden */
  46708. _removePendingData(data: any): void;
  46709. /**
  46710. * Returns the number of items waiting to be loaded
  46711. * @returns the number of items waiting to be loaded
  46712. */
  46713. getWaitingItemsCount(): number;
  46714. /**
  46715. * Returns a boolean indicating if the scene is still loading data
  46716. */
  46717. get isLoading(): boolean;
  46718. /**
  46719. * Registers a function to be executed when the scene is ready
  46720. * @param {Function} func - the function to be executed
  46721. */
  46722. executeWhenReady(func: () => void): void;
  46723. /**
  46724. * Returns a promise that resolves when the scene is ready
  46725. * @returns A promise that resolves when the scene is ready
  46726. */
  46727. whenReadyAsync(): Promise<void>;
  46728. /** @hidden */
  46729. _checkIsReady(): void;
  46730. /**
  46731. * Gets all animatable attached to the scene
  46732. */
  46733. get animatables(): Animatable[];
  46734. /**
  46735. * Resets the last animation time frame.
  46736. * Useful to override when animations start running when loading a scene for the first time.
  46737. */
  46738. resetLastAnimationTimeFrame(): void;
  46739. /**
  46740. * Gets the current view matrix
  46741. * @returns a Matrix
  46742. */
  46743. getViewMatrix(): Matrix;
  46744. /**
  46745. * Gets the current projection matrix
  46746. * @returns a Matrix
  46747. */
  46748. getProjectionMatrix(): Matrix;
  46749. /**
  46750. * Gets the current transform matrix
  46751. * @returns a Matrix made of View * Projection
  46752. */
  46753. getTransformMatrix(): Matrix;
  46754. /**
  46755. * Sets the current transform matrix
  46756. * @param viewL defines the View matrix to use
  46757. * @param projectionL defines the Projection matrix to use
  46758. * @param viewR defines the right View matrix to use (if provided)
  46759. * @param projectionR defines the right Projection matrix to use (if provided)
  46760. */
  46761. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  46762. /**
  46763. * Gets the uniform buffer used to store scene data
  46764. * @returns a UniformBuffer
  46765. */
  46766. getSceneUniformBuffer(): UniformBuffer;
  46767. /**
  46768. * Gets an unique (relatively to the current scene) Id
  46769. * @returns an unique number for the scene
  46770. */
  46771. getUniqueId(): number;
  46772. /**
  46773. * Add a mesh to the list of scene's meshes
  46774. * @param newMesh defines the mesh to add
  46775. * @param recursive if all child meshes should also be added to the scene
  46776. */
  46777. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  46778. /**
  46779. * Remove a mesh for the list of scene's meshes
  46780. * @param toRemove defines the mesh to remove
  46781. * @param recursive if all child meshes should also be removed from the scene
  46782. * @returns the index where the mesh was in the mesh list
  46783. */
  46784. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  46785. /**
  46786. * Add a transform node to the list of scene's transform nodes
  46787. * @param newTransformNode defines the transform node to add
  46788. */
  46789. addTransformNode(newTransformNode: TransformNode): void;
  46790. /**
  46791. * Remove a transform node for the list of scene's transform nodes
  46792. * @param toRemove defines the transform node to remove
  46793. * @returns the index where the transform node was in the transform node list
  46794. */
  46795. removeTransformNode(toRemove: TransformNode): number;
  46796. /**
  46797. * Remove a skeleton for the list of scene's skeletons
  46798. * @param toRemove defines the skeleton to remove
  46799. * @returns the index where the skeleton was in the skeleton list
  46800. */
  46801. removeSkeleton(toRemove: Skeleton): number;
  46802. /**
  46803. * Remove a morph target for the list of scene's morph targets
  46804. * @param toRemove defines the morph target to remove
  46805. * @returns the index where the morph target was in the morph target list
  46806. */
  46807. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  46808. /**
  46809. * Remove a light for the list of scene's lights
  46810. * @param toRemove defines the light to remove
  46811. * @returns the index where the light was in the light list
  46812. */
  46813. removeLight(toRemove: Light): number;
  46814. /**
  46815. * Remove a camera for the list of scene's cameras
  46816. * @param toRemove defines the camera to remove
  46817. * @returns the index where the camera was in the camera list
  46818. */
  46819. removeCamera(toRemove: Camera): number;
  46820. /**
  46821. * Remove a particle system for the list of scene's particle systems
  46822. * @param toRemove defines the particle system to remove
  46823. * @returns the index where the particle system was in the particle system list
  46824. */
  46825. removeParticleSystem(toRemove: IParticleSystem): number;
  46826. /**
  46827. * Remove a animation for the list of scene's animations
  46828. * @param toRemove defines the animation to remove
  46829. * @returns the index where the animation was in the animation list
  46830. */
  46831. removeAnimation(toRemove: Animation): number;
  46832. /**
  46833. * Will stop the animation of the given target
  46834. * @param target - the target
  46835. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  46836. * @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)
  46837. */
  46838. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  46839. /**
  46840. * Removes the given animation group from this scene.
  46841. * @param toRemove The animation group to remove
  46842. * @returns The index of the removed animation group
  46843. */
  46844. removeAnimationGroup(toRemove: AnimationGroup): number;
  46845. /**
  46846. * Removes the given multi-material from this scene.
  46847. * @param toRemove The multi-material to remove
  46848. * @returns The index of the removed multi-material
  46849. */
  46850. removeMultiMaterial(toRemove: MultiMaterial): number;
  46851. /**
  46852. * Removes the given material from this scene.
  46853. * @param toRemove The material to remove
  46854. * @returns The index of the removed material
  46855. */
  46856. removeMaterial(toRemove: Material): number;
  46857. /**
  46858. * Removes the given action manager from this scene.
  46859. * @param toRemove The action manager to remove
  46860. * @returns The index of the removed action manager
  46861. */
  46862. removeActionManager(toRemove: AbstractActionManager): number;
  46863. /**
  46864. * Removes the given texture from this scene.
  46865. * @param toRemove The texture to remove
  46866. * @returns The index of the removed texture
  46867. */
  46868. removeTexture(toRemove: BaseTexture): number;
  46869. /**
  46870. * Adds the given light to this scene
  46871. * @param newLight The light to add
  46872. */
  46873. addLight(newLight: Light): void;
  46874. /**
  46875. * Sorts the list list based on light priorities
  46876. */
  46877. sortLightsByPriority(): void;
  46878. /**
  46879. * Adds the given camera to this scene
  46880. * @param newCamera The camera to add
  46881. */
  46882. addCamera(newCamera: Camera): void;
  46883. /**
  46884. * Adds the given skeleton to this scene
  46885. * @param newSkeleton The skeleton to add
  46886. */
  46887. addSkeleton(newSkeleton: Skeleton): void;
  46888. /**
  46889. * Adds the given particle system to this scene
  46890. * @param newParticleSystem The particle system to add
  46891. */
  46892. addParticleSystem(newParticleSystem: IParticleSystem): void;
  46893. /**
  46894. * Adds the given animation to this scene
  46895. * @param newAnimation The animation to add
  46896. */
  46897. addAnimation(newAnimation: Animation): void;
  46898. /**
  46899. * Adds the given animation group to this scene.
  46900. * @param newAnimationGroup The animation group to add
  46901. */
  46902. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  46903. /**
  46904. * Adds the given multi-material to this scene
  46905. * @param newMultiMaterial The multi-material to add
  46906. */
  46907. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  46908. /**
  46909. * Adds the given material to this scene
  46910. * @param newMaterial The material to add
  46911. */
  46912. addMaterial(newMaterial: Material): void;
  46913. /**
  46914. * Adds the given morph target to this scene
  46915. * @param newMorphTargetManager The morph target to add
  46916. */
  46917. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  46918. /**
  46919. * Adds the given geometry to this scene
  46920. * @param newGeometry The geometry to add
  46921. */
  46922. addGeometry(newGeometry: Geometry): void;
  46923. /**
  46924. * Adds the given action manager to this scene
  46925. * @param newActionManager The action manager to add
  46926. */
  46927. addActionManager(newActionManager: AbstractActionManager): void;
  46928. /**
  46929. * Adds the given texture to this scene.
  46930. * @param newTexture The texture to add
  46931. */
  46932. addTexture(newTexture: BaseTexture): void;
  46933. /**
  46934. * Switch active camera
  46935. * @param newCamera defines the new active camera
  46936. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  46937. */
  46938. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  46939. /**
  46940. * sets the active camera of the scene using its ID
  46941. * @param id defines the camera's ID
  46942. * @return the new active camera or null if none found.
  46943. */
  46944. setActiveCameraByID(id: string): Nullable<Camera>;
  46945. /**
  46946. * sets the active camera of the scene using its name
  46947. * @param name defines the camera's name
  46948. * @returns the new active camera or null if none found.
  46949. */
  46950. setActiveCameraByName(name: string): Nullable<Camera>;
  46951. /**
  46952. * get an animation group using its name
  46953. * @param name defines the material's name
  46954. * @return the animation group or null if none found.
  46955. */
  46956. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  46957. /**
  46958. * Get a material using its unique id
  46959. * @param uniqueId defines the material's unique id
  46960. * @return the material or null if none found.
  46961. */
  46962. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  46963. /**
  46964. * get a material using its id
  46965. * @param id defines the material's ID
  46966. * @return the material or null if none found.
  46967. */
  46968. getMaterialByID(id: string): Nullable<Material>;
  46969. /**
  46970. * Gets a the last added material using a given id
  46971. * @param id defines the material's ID
  46972. * @return the last material with the given id or null if none found.
  46973. */
  46974. getLastMaterialByID(id: string): Nullable<Material>;
  46975. /**
  46976. * Gets a material using its name
  46977. * @param name defines the material's name
  46978. * @return the material or null if none found.
  46979. */
  46980. getMaterialByName(name: string): Nullable<Material>;
  46981. /**
  46982. * Get a texture using its unique id
  46983. * @param uniqueId defines the texture's unique id
  46984. * @return the texture or null if none found.
  46985. */
  46986. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  46987. /**
  46988. * Gets a camera using its id
  46989. * @param id defines the id to look for
  46990. * @returns the camera or null if not found
  46991. */
  46992. getCameraByID(id: string): Nullable<Camera>;
  46993. /**
  46994. * Gets a camera using its unique id
  46995. * @param uniqueId defines the unique id to look for
  46996. * @returns the camera or null if not found
  46997. */
  46998. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  46999. /**
  47000. * Gets a camera using its name
  47001. * @param name defines the camera's name
  47002. * @return the camera or null if none found.
  47003. */
  47004. getCameraByName(name: string): Nullable<Camera>;
  47005. /**
  47006. * Gets a bone using its id
  47007. * @param id defines the bone's id
  47008. * @return the bone or null if not found
  47009. */
  47010. getBoneByID(id: string): Nullable<Bone>;
  47011. /**
  47012. * Gets a bone using its id
  47013. * @param name defines the bone's name
  47014. * @return the bone or null if not found
  47015. */
  47016. getBoneByName(name: string): Nullable<Bone>;
  47017. /**
  47018. * Gets a light node using its name
  47019. * @param name defines the the light's name
  47020. * @return the light or null if none found.
  47021. */
  47022. getLightByName(name: string): Nullable<Light>;
  47023. /**
  47024. * Gets a light node using its id
  47025. * @param id defines the light's id
  47026. * @return the light or null if none found.
  47027. */
  47028. getLightByID(id: string): Nullable<Light>;
  47029. /**
  47030. * Gets a light node using its scene-generated unique ID
  47031. * @param uniqueId defines the light's unique id
  47032. * @return the light or null if none found.
  47033. */
  47034. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  47035. /**
  47036. * Gets a particle system by id
  47037. * @param id defines the particle system id
  47038. * @return the corresponding system or null if none found
  47039. */
  47040. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  47041. /**
  47042. * Gets a geometry using its ID
  47043. * @param id defines the geometry's id
  47044. * @return the geometry or null if none found.
  47045. */
  47046. getGeometryByID(id: string): Nullable<Geometry>;
  47047. private _getGeometryByUniqueID;
  47048. /**
  47049. * Add a new geometry to this scene
  47050. * @param geometry defines the geometry to be added to the scene.
  47051. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  47052. * @return a boolean defining if the geometry was added or not
  47053. */
  47054. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  47055. /**
  47056. * Removes an existing geometry
  47057. * @param geometry defines the geometry to be removed from the scene
  47058. * @return a boolean defining if the geometry was removed or not
  47059. */
  47060. removeGeometry(geometry: Geometry): boolean;
  47061. /**
  47062. * Gets the list of geometries attached to the scene
  47063. * @returns an array of Geometry
  47064. */
  47065. getGeometries(): Geometry[];
  47066. /**
  47067. * Gets the first added mesh found of a given ID
  47068. * @param id defines the id to search for
  47069. * @return the mesh found or null if not found at all
  47070. */
  47071. getMeshByID(id: string): Nullable<AbstractMesh>;
  47072. /**
  47073. * Gets a list of meshes using their id
  47074. * @param id defines the id to search for
  47075. * @returns a list of meshes
  47076. */
  47077. getMeshesByID(id: string): Array<AbstractMesh>;
  47078. /**
  47079. * Gets the first added transform node found of a given ID
  47080. * @param id defines the id to search for
  47081. * @return the found transform node or null if not found at all.
  47082. */
  47083. getTransformNodeByID(id: string): Nullable<TransformNode>;
  47084. /**
  47085. * Gets a transform node with its auto-generated unique id
  47086. * @param uniqueId efines the unique id to search for
  47087. * @return the found transform node or null if not found at all.
  47088. */
  47089. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  47090. /**
  47091. * Gets a list of transform nodes using their id
  47092. * @param id defines the id to search for
  47093. * @returns a list of transform nodes
  47094. */
  47095. getTransformNodesByID(id: string): Array<TransformNode>;
  47096. /**
  47097. * Gets a mesh with its auto-generated unique id
  47098. * @param uniqueId defines the unique id to search for
  47099. * @return the found mesh or null if not found at all.
  47100. */
  47101. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  47102. /**
  47103. * Gets a the last added mesh using a given id
  47104. * @param id defines the id to search for
  47105. * @return the found mesh or null if not found at all.
  47106. */
  47107. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  47108. /**
  47109. * Gets a the last added node (Mesh, Camera, Light) using a given id
  47110. * @param id defines the id to search for
  47111. * @return the found node or null if not found at all
  47112. */
  47113. getLastEntryByID(id: string): Nullable<Node>;
  47114. /**
  47115. * Gets a node (Mesh, Camera, Light) using a given id
  47116. * @param id defines the id to search for
  47117. * @return the found node or null if not found at all
  47118. */
  47119. getNodeByID(id: string): Nullable<Node>;
  47120. /**
  47121. * Gets a node (Mesh, Camera, Light) using a given name
  47122. * @param name defines the name to search for
  47123. * @return the found node or null if not found at all.
  47124. */
  47125. getNodeByName(name: string): Nullable<Node>;
  47126. /**
  47127. * Gets a mesh using a given name
  47128. * @param name defines the name to search for
  47129. * @return the found mesh or null if not found at all.
  47130. */
  47131. getMeshByName(name: string): Nullable<AbstractMesh>;
  47132. /**
  47133. * Gets a transform node using a given name
  47134. * @param name defines the name to search for
  47135. * @return the found transform node or null if not found at all.
  47136. */
  47137. getTransformNodeByName(name: string): Nullable<TransformNode>;
  47138. /**
  47139. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  47140. * @param id defines the id to search for
  47141. * @return the found skeleton or null if not found at all.
  47142. */
  47143. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  47144. /**
  47145. * Gets a skeleton using a given auto generated unique id
  47146. * @param uniqueId defines the unique id to search for
  47147. * @return the found skeleton or null if not found at all.
  47148. */
  47149. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  47150. /**
  47151. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  47152. * @param id defines the id to search for
  47153. * @return the found skeleton or null if not found at all.
  47154. */
  47155. getSkeletonById(id: string): Nullable<Skeleton>;
  47156. /**
  47157. * Gets a skeleton using a given name
  47158. * @param name defines the name to search for
  47159. * @return the found skeleton or null if not found at all.
  47160. */
  47161. getSkeletonByName(name: string): Nullable<Skeleton>;
  47162. /**
  47163. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  47164. * @param id defines the id to search for
  47165. * @return the found morph target manager or null if not found at all.
  47166. */
  47167. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  47168. /**
  47169. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  47170. * @param id defines the id to search for
  47171. * @return the found morph target or null if not found at all.
  47172. */
  47173. getMorphTargetById(id: string): Nullable<MorphTarget>;
  47174. /**
  47175. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  47176. * @param name defines the name to search for
  47177. * @return the found morph target or null if not found at all.
  47178. */
  47179. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  47180. /**
  47181. * Gets a post process using a given name (if many are found, this function will pick the first one)
  47182. * @param name defines the name to search for
  47183. * @return the found post process or null if not found at all.
  47184. */
  47185. getPostProcessByName(name: string): Nullable<PostProcess>;
  47186. /**
  47187. * Gets a boolean indicating if the given mesh is active
  47188. * @param mesh defines the mesh to look for
  47189. * @returns true if the mesh is in the active list
  47190. */
  47191. isActiveMesh(mesh: AbstractMesh): boolean;
  47192. /**
  47193. * Return a unique id as a string which can serve as an identifier for the scene
  47194. */
  47195. get uid(): string;
  47196. /**
  47197. * Add an externaly attached data from its key.
  47198. * This method call will fail and return false, if such key already exists.
  47199. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  47200. * @param key the unique key that identifies the data
  47201. * @param data the data object to associate to the key for this Engine instance
  47202. * @return true if no such key were already present and the data was added successfully, false otherwise
  47203. */
  47204. addExternalData<T>(key: string, data: T): boolean;
  47205. /**
  47206. * Get an externaly attached data from its key
  47207. * @param key the unique key that identifies the data
  47208. * @return the associated data, if present (can be null), or undefined if not present
  47209. */
  47210. getExternalData<T>(key: string): Nullable<T>;
  47211. /**
  47212. * Get an externaly attached data from its key, create it using a factory if it's not already present
  47213. * @param key the unique key that identifies the data
  47214. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  47215. * @return the associated data, can be null if the factory returned null.
  47216. */
  47217. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  47218. /**
  47219. * Remove an externaly attached data from the Engine instance
  47220. * @param key the unique key that identifies the data
  47221. * @return true if the data was successfully removed, false if it doesn't exist
  47222. */
  47223. removeExternalData(key: string): boolean;
  47224. private _evaluateSubMesh;
  47225. /**
  47226. * Clear the processed materials smart array preventing retention point in material dispose.
  47227. */
  47228. freeProcessedMaterials(): void;
  47229. private _preventFreeActiveMeshesAndRenderingGroups;
  47230. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  47231. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  47232. * when disposing several meshes in a row or a hierarchy of meshes.
  47233. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  47234. */
  47235. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  47236. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  47237. /**
  47238. * Clear the active meshes smart array preventing retention point in mesh dispose.
  47239. */
  47240. freeActiveMeshes(): void;
  47241. /**
  47242. * Clear the info related to rendering groups preventing retention points during dispose.
  47243. */
  47244. freeRenderingGroups(): void;
  47245. /** @hidden */
  47246. _isInIntermediateRendering(): boolean;
  47247. /**
  47248. * Lambda returning the list of potentially active meshes.
  47249. */
  47250. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  47251. /**
  47252. * Lambda returning the list of potentially active sub meshes.
  47253. */
  47254. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  47255. /**
  47256. * Lambda returning the list of potentially intersecting sub meshes.
  47257. */
  47258. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  47259. /**
  47260. * Lambda returning the list of potentially colliding sub meshes.
  47261. */
  47262. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  47263. /** @hidden */
  47264. _activeMeshesFrozen: boolean;
  47265. private _skipEvaluateActiveMeshesCompletely;
  47266. /**
  47267. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  47268. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  47269. * @param onSuccess optional success callback
  47270. * @param onError optional error callback
  47271. * @returns the current scene
  47272. */
  47273. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  47274. /**
  47275. * Use this function to restart evaluating active meshes on every frame
  47276. * @returns the current scene
  47277. */
  47278. unfreezeActiveMeshes(): Scene;
  47279. private _evaluateActiveMeshes;
  47280. private _activeMesh;
  47281. /**
  47282. * Update the transform matrix to update from the current active camera
  47283. * @param force defines a boolean used to force the update even if cache is up to date
  47284. */
  47285. updateTransformMatrix(force?: boolean): void;
  47286. private _bindFrameBuffer;
  47287. /** @hidden */
  47288. _allowPostProcessClearColor: boolean;
  47289. /** @hidden */
  47290. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  47291. private _processSubCameras;
  47292. private _checkIntersections;
  47293. /** @hidden */
  47294. _advancePhysicsEngineStep(step: number): void;
  47295. /**
  47296. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  47297. */
  47298. getDeterministicFrameTime: () => number;
  47299. /** @hidden */
  47300. _animate(): void;
  47301. /** Execute all animations (for a frame) */
  47302. animate(): void;
  47303. /**
  47304. * Render the scene
  47305. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  47306. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  47307. */
  47308. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  47309. /**
  47310. * Freeze all materials
  47311. * A frozen material will not be updatable but should be faster to render
  47312. */
  47313. freezeMaterials(): void;
  47314. /**
  47315. * Unfreeze all materials
  47316. * A frozen material will not be updatable but should be faster to render
  47317. */
  47318. unfreezeMaterials(): void;
  47319. /**
  47320. * Releases all held ressources
  47321. */
  47322. dispose(): void;
  47323. /**
  47324. * Gets if the scene is already disposed
  47325. */
  47326. get isDisposed(): boolean;
  47327. /**
  47328. * Call this function to reduce memory footprint of the scene.
  47329. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  47330. */
  47331. clearCachedVertexData(): void;
  47332. /**
  47333. * This function will remove the local cached buffer data from texture.
  47334. * It will save memory but will prevent the texture from being rebuilt
  47335. */
  47336. cleanCachedTextureBuffer(): void;
  47337. /**
  47338. * Get the world extend vectors with an optional filter
  47339. *
  47340. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  47341. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  47342. */
  47343. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  47344. min: Vector3;
  47345. max: Vector3;
  47346. };
  47347. /**
  47348. * Creates a ray that can be used to pick in the scene
  47349. * @param x defines the x coordinate of the origin (on-screen)
  47350. * @param y defines the y coordinate of the origin (on-screen)
  47351. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  47352. * @param camera defines the camera to use for the picking
  47353. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  47354. * @returns a Ray
  47355. */
  47356. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  47357. /**
  47358. * Creates a ray that can be used to pick in the scene
  47359. * @param x defines the x coordinate of the origin (on-screen)
  47360. * @param y defines the y coordinate of the origin (on-screen)
  47361. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  47362. * @param result defines the ray where to store the picking ray
  47363. * @param camera defines the camera to use for the picking
  47364. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  47365. * @returns the current scene
  47366. */
  47367. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  47368. /**
  47369. * Creates a ray that can be used to pick in the scene
  47370. * @param x defines the x coordinate of the origin (on-screen)
  47371. * @param y defines the y coordinate of the origin (on-screen)
  47372. * @param camera defines the camera to use for the picking
  47373. * @returns a Ray
  47374. */
  47375. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  47376. /**
  47377. * Creates a ray that can be used to pick in the scene
  47378. * @param x defines the x coordinate of the origin (on-screen)
  47379. * @param y defines the y coordinate of the origin (on-screen)
  47380. * @param result defines the ray where to store the picking ray
  47381. * @param camera defines the camera to use for the picking
  47382. * @returns the current scene
  47383. */
  47384. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  47385. /** Launch a ray to try to pick a mesh in the scene
  47386. * @param x position on screen
  47387. * @param y position on screen
  47388. * @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
  47389. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47390. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47391. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47392. * @returns a PickingInfo
  47393. */
  47394. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  47395. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  47396. * @param x position on screen
  47397. * @param y position on screen
  47398. * @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
  47399. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47400. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47401. * @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)
  47402. */
  47403. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  47404. /** Use the given ray to pick a mesh in the scene
  47405. * @param ray The ray to use to pick meshes
  47406. * @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
  47407. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47408. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47409. * @returns a PickingInfo
  47410. */
  47411. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  47412. /**
  47413. * Launch a ray to try to pick a mesh in the scene
  47414. * @param x X position on screen
  47415. * @param y Y position on screen
  47416. * @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
  47417. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47418. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47419. * @returns an array of PickingInfo
  47420. */
  47421. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  47422. /**
  47423. * Launch a ray to try to pick a mesh in the scene
  47424. * @param ray Ray to use
  47425. * @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
  47426. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47427. * @returns an array of PickingInfo
  47428. */
  47429. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  47430. /**
  47431. * Force the value of meshUnderPointer
  47432. * @param mesh defines the mesh to use
  47433. * @param pointerId optional pointer id when using more than one pointer
  47434. */
  47435. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  47436. /**
  47437. * Gets the mesh under the pointer
  47438. * @returns a Mesh or null if no mesh is under the pointer
  47439. */
  47440. getPointerOverMesh(): Nullable<AbstractMesh>;
  47441. /** @hidden */
  47442. _rebuildGeometries(): void;
  47443. /** @hidden */
  47444. _rebuildTextures(): void;
  47445. private _getByTags;
  47446. /**
  47447. * Get a list of meshes by tags
  47448. * @param tagsQuery defines the tags query to use
  47449. * @param forEach defines a predicate used to filter results
  47450. * @returns an array of Mesh
  47451. */
  47452. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  47453. /**
  47454. * Get a list of cameras by tags
  47455. * @param tagsQuery defines the tags query to use
  47456. * @param forEach defines a predicate used to filter results
  47457. * @returns an array of Camera
  47458. */
  47459. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  47460. /**
  47461. * Get a list of lights by tags
  47462. * @param tagsQuery defines the tags query to use
  47463. * @param forEach defines a predicate used to filter results
  47464. * @returns an array of Light
  47465. */
  47466. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  47467. /**
  47468. * Get a list of materials by tags
  47469. * @param tagsQuery defines the tags query to use
  47470. * @param forEach defines a predicate used to filter results
  47471. * @returns an array of Material
  47472. */
  47473. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  47474. /**
  47475. * Get a list of transform nodes by tags
  47476. * @param tagsQuery defines the tags query to use
  47477. * @param forEach defines a predicate used to filter results
  47478. * @returns an array of TransformNode
  47479. */
  47480. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  47481. /**
  47482. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  47483. * This allowed control for front to back rendering or reversly depending of the special needs.
  47484. *
  47485. * @param renderingGroupId The rendering group id corresponding to its index
  47486. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  47487. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  47488. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  47489. */
  47490. 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;
  47491. /**
  47492. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  47493. *
  47494. * @param renderingGroupId The rendering group id corresponding to its index
  47495. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47496. * @param depth Automatically clears depth between groups if true and autoClear is true.
  47497. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  47498. */
  47499. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  47500. /**
  47501. * Gets the current auto clear configuration for one rendering group of the rendering
  47502. * manager.
  47503. * @param index the rendering group index to get the information for
  47504. * @returns The auto clear setup for the requested rendering group
  47505. */
  47506. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  47507. private _blockMaterialDirtyMechanism;
  47508. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  47509. get blockMaterialDirtyMechanism(): boolean;
  47510. set blockMaterialDirtyMechanism(value: boolean);
  47511. /**
  47512. * Will flag all materials as dirty to trigger new shader compilation
  47513. * @param flag defines the flag used to specify which material part must be marked as dirty
  47514. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  47515. */
  47516. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  47517. /** @hidden */
  47518. _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;
  47519. /** @hidden */
  47520. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  47521. /** @hidden */
  47522. _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;
  47523. /** @hidden */
  47524. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  47525. /** @hidden */
  47526. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  47527. /** @hidden */
  47528. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  47529. }
  47530. }
  47531. declare module BABYLON {
  47532. /**
  47533. * Set of assets to keep when moving a scene into an asset container.
  47534. */
  47535. export class KeepAssets extends AbstractScene {
  47536. }
  47537. /**
  47538. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  47539. */
  47540. export class InstantiatedEntries {
  47541. /**
  47542. * List of new root nodes (eg. nodes with no parent)
  47543. */
  47544. rootNodes: TransformNode[];
  47545. /**
  47546. * List of new skeletons
  47547. */
  47548. skeletons: Skeleton[];
  47549. /**
  47550. * List of new animation groups
  47551. */
  47552. animationGroups: AnimationGroup[];
  47553. }
  47554. /**
  47555. * Container with a set of assets that can be added or removed from a scene.
  47556. */
  47557. export class AssetContainer extends AbstractScene {
  47558. private _wasAddedToScene;
  47559. /**
  47560. * The scene the AssetContainer belongs to.
  47561. */
  47562. scene: Scene;
  47563. /**
  47564. * Instantiates an AssetContainer.
  47565. * @param scene The scene the AssetContainer belongs to.
  47566. */
  47567. constructor(scene: Scene);
  47568. /**
  47569. * Instantiate or clone all meshes and add the new ones to the scene.
  47570. * Skeletons and animation groups will all be cloned
  47571. * @param nameFunction defines an optional function used to get new names for clones
  47572. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  47573. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  47574. */
  47575. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  47576. /**
  47577. * Adds all the assets from the container to the scene.
  47578. */
  47579. addAllToScene(): void;
  47580. /**
  47581. * Removes all the assets in the container from the scene
  47582. */
  47583. removeAllFromScene(): void;
  47584. /**
  47585. * Disposes all the assets in the container
  47586. */
  47587. dispose(): void;
  47588. private _moveAssets;
  47589. /**
  47590. * Removes all the assets contained in the scene and adds them to the container.
  47591. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  47592. */
  47593. moveAllFromScene(keepAssets?: KeepAssets): void;
  47594. /**
  47595. * 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.
  47596. * @returns the root mesh
  47597. */
  47598. createRootMesh(): Mesh;
  47599. /**
  47600. * Merge animations (direct and animation groups) from this asset container into a scene
  47601. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47602. * @param animatables set of animatables to retarget to a node from the scene
  47603. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  47604. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  47605. */
  47606. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  47607. }
  47608. }
  47609. declare module BABYLON {
  47610. /**
  47611. * Defines how the parser contract is defined.
  47612. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  47613. */
  47614. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  47615. /**
  47616. * Defines how the individual parser contract is defined.
  47617. * These parser can parse an individual asset
  47618. */
  47619. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  47620. /**
  47621. * Base class of the scene acting as a container for the different elements composing a scene.
  47622. * This class is dynamically extended by the different components of the scene increasing
  47623. * flexibility and reducing coupling
  47624. */
  47625. export abstract class AbstractScene {
  47626. /**
  47627. * Stores the list of available parsers in the application.
  47628. */
  47629. private static _BabylonFileParsers;
  47630. /**
  47631. * Stores the list of available individual parsers in the application.
  47632. */
  47633. private static _IndividualBabylonFileParsers;
  47634. /**
  47635. * Adds a parser in the list of available ones
  47636. * @param name Defines the name of the parser
  47637. * @param parser Defines the parser to add
  47638. */
  47639. static AddParser(name: string, parser: BabylonFileParser): void;
  47640. /**
  47641. * Gets a general parser from the list of avaialble ones
  47642. * @param name Defines the name of the parser
  47643. * @returns the requested parser or null
  47644. */
  47645. static GetParser(name: string): Nullable<BabylonFileParser>;
  47646. /**
  47647. * Adds n individual parser in the list of available ones
  47648. * @param name Defines the name of the parser
  47649. * @param parser Defines the parser to add
  47650. */
  47651. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47652. /**
  47653. * Gets an individual parser from the list of avaialble ones
  47654. * @param name Defines the name of the parser
  47655. * @returns the requested parser or null
  47656. */
  47657. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  47658. /**
  47659. * Parser json data and populate both a scene and its associated container object
  47660. * @param jsonData Defines the data to parse
  47661. * @param scene Defines the scene to parse the data for
  47662. * @param container Defines the container attached to the parsing sequence
  47663. * @param rootUrl Defines the root url of the data
  47664. */
  47665. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  47666. /**
  47667. * Gets the list of root nodes (ie. nodes with no parent)
  47668. */
  47669. rootNodes: Node[];
  47670. /** All of the cameras added to this scene
  47671. * @see https://doc.babylonjs.com/babylon101/cameras
  47672. */
  47673. cameras: Camera[];
  47674. /**
  47675. * All of the lights added to this scene
  47676. * @see https://doc.babylonjs.com/babylon101/lights
  47677. */
  47678. lights: Light[];
  47679. /**
  47680. * All of the (abstract) meshes added to this scene
  47681. */
  47682. meshes: AbstractMesh[];
  47683. /**
  47684. * The list of skeletons added to the scene
  47685. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  47686. */
  47687. skeletons: Skeleton[];
  47688. /**
  47689. * All of the particle systems added to this scene
  47690. * @see https://doc.babylonjs.com/babylon101/particles
  47691. */
  47692. particleSystems: IParticleSystem[];
  47693. /**
  47694. * Gets a list of Animations associated with the scene
  47695. */
  47696. animations: Animation[];
  47697. /**
  47698. * All of the animation groups added to this scene
  47699. * @see https://doc.babylonjs.com/how_to/group
  47700. */
  47701. animationGroups: AnimationGroup[];
  47702. /**
  47703. * All of the multi-materials added to this scene
  47704. * @see https://doc.babylonjs.com/how_to/multi_materials
  47705. */
  47706. multiMaterials: MultiMaterial[];
  47707. /**
  47708. * All of the materials added to this scene
  47709. * In the context of a Scene, it is not supposed to be modified manually.
  47710. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  47711. * Note also that the order of the Material within the array is not significant and might change.
  47712. * @see https://doc.babylonjs.com/babylon101/materials
  47713. */
  47714. materials: Material[];
  47715. /**
  47716. * The list of morph target managers added to the scene
  47717. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  47718. */
  47719. morphTargetManagers: MorphTargetManager[];
  47720. /**
  47721. * The list of geometries used in the scene.
  47722. */
  47723. geometries: Geometry[];
  47724. /**
  47725. * All of the tranform nodes added to this scene
  47726. * In the context of a Scene, it is not supposed to be modified manually.
  47727. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  47728. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  47729. * @see https://doc.babylonjs.com/how_to/transformnode
  47730. */
  47731. transformNodes: TransformNode[];
  47732. /**
  47733. * ActionManagers available on the scene.
  47734. */
  47735. actionManagers: AbstractActionManager[];
  47736. /**
  47737. * Textures to keep.
  47738. */
  47739. textures: BaseTexture[];
  47740. /** @hidden */
  47741. protected _environmentTexture: Nullable<BaseTexture>;
  47742. /**
  47743. * Texture used in all pbr material as the reflection texture.
  47744. * As in the majority of the scene they are the same (exception for multi room and so on),
  47745. * this is easier to reference from here than from all the materials.
  47746. */
  47747. get environmentTexture(): Nullable<BaseTexture>;
  47748. set environmentTexture(value: Nullable<BaseTexture>);
  47749. /**
  47750. * The list of postprocesses added to the scene
  47751. */
  47752. postProcesses: PostProcess[];
  47753. /**
  47754. * @returns all meshes, lights, cameras, transformNodes and bones
  47755. */
  47756. getNodes(): Array<Node>;
  47757. }
  47758. }
  47759. declare module BABYLON {
  47760. /**
  47761. * Interface used to define options for Sound class
  47762. */
  47763. export interface ISoundOptions {
  47764. /**
  47765. * Does the sound autoplay once loaded.
  47766. */
  47767. autoplay?: boolean;
  47768. /**
  47769. * Does the sound loop after it finishes playing once.
  47770. */
  47771. loop?: boolean;
  47772. /**
  47773. * Sound's volume
  47774. */
  47775. volume?: number;
  47776. /**
  47777. * Is it a spatial sound?
  47778. */
  47779. spatialSound?: boolean;
  47780. /**
  47781. * Maximum distance to hear that sound
  47782. */
  47783. maxDistance?: number;
  47784. /**
  47785. * Uses user defined attenuation function
  47786. */
  47787. useCustomAttenuation?: boolean;
  47788. /**
  47789. * Define the roll off factor of spatial sounds.
  47790. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47791. */
  47792. rolloffFactor?: number;
  47793. /**
  47794. * Define the reference distance the sound should be heard perfectly.
  47795. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47796. */
  47797. refDistance?: number;
  47798. /**
  47799. * Define the distance attenuation model the sound will follow.
  47800. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47801. */
  47802. distanceModel?: string;
  47803. /**
  47804. * Defines the playback speed (1 by default)
  47805. */
  47806. playbackRate?: number;
  47807. /**
  47808. * Defines if the sound is from a streaming source
  47809. */
  47810. streaming?: boolean;
  47811. /**
  47812. * Defines an optional length (in seconds) inside the sound file
  47813. */
  47814. length?: number;
  47815. /**
  47816. * Defines an optional offset (in seconds) inside the sound file
  47817. */
  47818. offset?: number;
  47819. /**
  47820. * If true, URLs will not be required to state the audio file codec to use.
  47821. */
  47822. skipCodecCheck?: boolean;
  47823. }
  47824. }
  47825. declare module BABYLON {
  47826. /**
  47827. * Defines a sound that can be played in the application.
  47828. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  47829. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47830. */
  47831. export class Sound {
  47832. /**
  47833. * The name of the sound in the scene.
  47834. */
  47835. name: string;
  47836. /**
  47837. * Does the sound autoplay once loaded.
  47838. */
  47839. autoplay: boolean;
  47840. private _loop;
  47841. /**
  47842. * Does the sound loop after it finishes playing once.
  47843. */
  47844. get loop(): boolean;
  47845. set loop(value: boolean);
  47846. /**
  47847. * Does the sound use a custom attenuation curve to simulate the falloff
  47848. * happening when the source gets further away from the camera.
  47849. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  47850. */
  47851. useCustomAttenuation: boolean;
  47852. /**
  47853. * The sound track id this sound belongs to.
  47854. */
  47855. soundTrackId: number;
  47856. /**
  47857. * Is this sound currently played.
  47858. */
  47859. isPlaying: boolean;
  47860. /**
  47861. * Is this sound currently paused.
  47862. */
  47863. isPaused: boolean;
  47864. /**
  47865. * Does this sound enables spatial sound.
  47866. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47867. */
  47868. spatialSound: boolean;
  47869. /**
  47870. * Define the reference distance the sound should be heard perfectly.
  47871. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47872. */
  47873. refDistance: number;
  47874. /**
  47875. * Define the roll off factor of spatial sounds.
  47876. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47877. */
  47878. rolloffFactor: number;
  47879. /**
  47880. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  47881. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47882. */
  47883. maxDistance: number;
  47884. /**
  47885. * Define the distance attenuation model the sound will follow.
  47886. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47887. */
  47888. distanceModel: string;
  47889. /**
  47890. * @hidden
  47891. * Back Compat
  47892. **/
  47893. onended: () => any;
  47894. /**
  47895. * Gets or sets an object used to store user defined information for the sound.
  47896. */
  47897. metadata: any;
  47898. /**
  47899. * Observable event when the current playing sound finishes.
  47900. */
  47901. onEndedObservable: Observable<Sound>;
  47902. /**
  47903. * Gets the current time for the sound.
  47904. */
  47905. get currentTime(): number;
  47906. private _panningModel;
  47907. private _playbackRate;
  47908. private _streaming;
  47909. private _startTime;
  47910. private _startOffset;
  47911. private _position;
  47912. /** @hidden */
  47913. _positionInEmitterSpace: boolean;
  47914. private _localDirection;
  47915. private _volume;
  47916. private _isReadyToPlay;
  47917. private _isDirectional;
  47918. private _readyToPlayCallback;
  47919. private _audioBuffer;
  47920. private _soundSource;
  47921. private _streamingSource;
  47922. private _soundPanner;
  47923. private _soundGain;
  47924. private _inputAudioNode;
  47925. private _outputAudioNode;
  47926. private _coneInnerAngle;
  47927. private _coneOuterAngle;
  47928. private _coneOuterGain;
  47929. private _scene;
  47930. private _connectedTransformNode;
  47931. private _customAttenuationFunction;
  47932. private _registerFunc;
  47933. private _isOutputConnected;
  47934. private _htmlAudioElement;
  47935. private _urlType;
  47936. private _length?;
  47937. private _offset?;
  47938. /** @hidden */
  47939. static _SceneComponentInitialization: (scene: Scene) => void;
  47940. /**
  47941. * Create a sound and attach it to a scene
  47942. * @param name Name of your sound
  47943. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  47944. * @param scene defines the scene the sound belongs to
  47945. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  47946. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  47947. */
  47948. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  47949. /**
  47950. * Release the sound and its associated resources
  47951. */
  47952. dispose(): void;
  47953. /**
  47954. * Gets if the sounds is ready to be played or not.
  47955. * @returns true if ready, otherwise false
  47956. */
  47957. isReady(): boolean;
  47958. /**
  47959. * Get the current class name.
  47960. * @returns current class name
  47961. */
  47962. getClassName(): string;
  47963. private _soundLoaded;
  47964. /**
  47965. * Sets the data of the sound from an audiobuffer
  47966. * @param audioBuffer The audioBuffer containing the data
  47967. */
  47968. setAudioBuffer(audioBuffer: AudioBuffer): void;
  47969. /**
  47970. * Updates the current sounds options such as maxdistance, loop...
  47971. * @param options A JSON object containing values named as the object properties
  47972. */
  47973. updateOptions(options: ISoundOptions): void;
  47974. private _createSpatialParameters;
  47975. private _updateSpatialParameters;
  47976. /**
  47977. * Switch the panning model to HRTF:
  47978. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  47979. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47980. */
  47981. switchPanningModelToHRTF(): void;
  47982. /**
  47983. * Switch the panning model to Equal Power:
  47984. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  47985. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47986. */
  47987. switchPanningModelToEqualPower(): void;
  47988. private _switchPanningModel;
  47989. /**
  47990. * Connect this sound to a sound track audio node like gain...
  47991. * @param soundTrackAudioNode the sound track audio node to connect to
  47992. */
  47993. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  47994. /**
  47995. * Transform this sound into a directional source
  47996. * @param coneInnerAngle Size of the inner cone in degree
  47997. * @param coneOuterAngle Size of the outer cone in degree
  47998. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  47999. */
  48000. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  48001. /**
  48002. * Gets or sets the inner angle for the directional cone.
  48003. */
  48004. get directionalConeInnerAngle(): number;
  48005. /**
  48006. * Gets or sets the inner angle for the directional cone.
  48007. */
  48008. set directionalConeInnerAngle(value: number);
  48009. /**
  48010. * Gets or sets the outer angle for the directional cone.
  48011. */
  48012. get directionalConeOuterAngle(): number;
  48013. /**
  48014. * Gets or sets the outer angle for the directional cone.
  48015. */
  48016. set directionalConeOuterAngle(value: number);
  48017. /**
  48018. * Sets the position of the emitter if spatial sound is enabled
  48019. * @param newPosition Defines the new posisiton
  48020. */
  48021. setPosition(newPosition: Vector3): void;
  48022. /**
  48023. * Sets the local direction of the emitter if spatial sound is enabled
  48024. * @param newLocalDirection Defines the new local direction
  48025. */
  48026. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  48027. private _updateDirection;
  48028. /** @hidden */
  48029. updateDistanceFromListener(): void;
  48030. /**
  48031. * Sets a new custom attenuation function for the sound.
  48032. * @param callback Defines the function used for the attenuation
  48033. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  48034. */
  48035. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  48036. /**
  48037. * Play the sound
  48038. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  48039. * @param offset (optional) Start the sound at a specific time in seconds
  48040. * @param length (optional) Sound duration (in seconds)
  48041. */
  48042. play(time?: number, offset?: number, length?: number): void;
  48043. private _onended;
  48044. /**
  48045. * Stop the sound
  48046. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  48047. */
  48048. stop(time?: number): void;
  48049. /**
  48050. * Put the sound in pause
  48051. */
  48052. pause(): void;
  48053. /**
  48054. * Sets a dedicated volume for this sounds
  48055. * @param newVolume Define the new volume of the sound
  48056. * @param time Define time for gradual change to new volume
  48057. */
  48058. setVolume(newVolume: number, time?: number): void;
  48059. /**
  48060. * Set the sound play back rate
  48061. * @param newPlaybackRate Define the playback rate the sound should be played at
  48062. */
  48063. setPlaybackRate(newPlaybackRate: number): void;
  48064. /**
  48065. * Gets the volume of the sound.
  48066. * @returns the volume of the sound
  48067. */
  48068. getVolume(): number;
  48069. /**
  48070. * Attach the sound to a dedicated mesh
  48071. * @param transformNode The transform node to connect the sound with
  48072. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  48073. */
  48074. attachToMesh(transformNode: TransformNode): void;
  48075. /**
  48076. * Detach the sound from the previously attached mesh
  48077. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  48078. */
  48079. detachFromMesh(): void;
  48080. private _onRegisterAfterWorldMatrixUpdate;
  48081. /**
  48082. * Clone the current sound in the scene.
  48083. * @returns the new sound clone
  48084. */
  48085. clone(): Nullable<Sound>;
  48086. /**
  48087. * Gets the current underlying audio buffer containing the data
  48088. * @returns the audio buffer
  48089. */
  48090. getAudioBuffer(): Nullable<AudioBuffer>;
  48091. /**
  48092. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  48093. * @returns the source node
  48094. */
  48095. getSoundSource(): Nullable<AudioBufferSourceNode>;
  48096. /**
  48097. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  48098. * @returns the gain node
  48099. */
  48100. getSoundGain(): Nullable<GainNode>;
  48101. /**
  48102. * Serializes the Sound in a JSON representation
  48103. * @returns the JSON representation of the sound
  48104. */
  48105. serialize(): any;
  48106. /**
  48107. * Parse a JSON representation of a sound to innstantiate in a given scene
  48108. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  48109. * @param scene Define the scene the new parsed sound should be created in
  48110. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  48111. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  48112. * @returns the newly parsed sound
  48113. */
  48114. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  48115. }
  48116. }
  48117. declare module BABYLON {
  48118. /**
  48119. * This defines an action helpful to play a defined sound on a triggered action.
  48120. */
  48121. export class PlaySoundAction extends Action {
  48122. private _sound;
  48123. /**
  48124. * Instantiate the action
  48125. * @param triggerOptions defines the trigger options
  48126. * @param sound defines the sound to play
  48127. * @param condition defines the trigger related conditions
  48128. */
  48129. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  48130. /** @hidden */
  48131. _prepare(): void;
  48132. /**
  48133. * Execute the action and play the sound.
  48134. */
  48135. execute(): void;
  48136. /**
  48137. * Serializes the actions and its related information.
  48138. * @param parent defines the object to serialize in
  48139. * @returns the serialized object
  48140. */
  48141. serialize(parent: any): any;
  48142. }
  48143. /**
  48144. * This defines an action helpful to stop a defined sound on a triggered action.
  48145. */
  48146. export class StopSoundAction extends Action {
  48147. private _sound;
  48148. /**
  48149. * Instantiate the action
  48150. * @param triggerOptions defines the trigger options
  48151. * @param sound defines the sound to stop
  48152. * @param condition defines the trigger related conditions
  48153. */
  48154. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  48155. /** @hidden */
  48156. _prepare(): void;
  48157. /**
  48158. * Execute the action and stop the sound.
  48159. */
  48160. execute(): void;
  48161. /**
  48162. * Serializes the actions and its related information.
  48163. * @param parent defines the object to serialize in
  48164. * @returns the serialized object
  48165. */
  48166. serialize(parent: any): any;
  48167. }
  48168. }
  48169. declare module BABYLON {
  48170. /**
  48171. * This defines an action responsible to change the value of a property
  48172. * by interpolating between its current value and the newly set one once triggered.
  48173. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  48174. */
  48175. export class InterpolateValueAction extends Action {
  48176. /**
  48177. * Defines the path of the property where the value should be interpolated
  48178. */
  48179. propertyPath: string;
  48180. /**
  48181. * Defines the target value at the end of the interpolation.
  48182. */
  48183. value: any;
  48184. /**
  48185. * Defines the time it will take for the property to interpolate to the value.
  48186. */
  48187. duration: number;
  48188. /**
  48189. * Defines if the other scene animations should be stopped when the action has been triggered
  48190. */
  48191. stopOtherAnimations?: boolean;
  48192. /**
  48193. * Defines a callback raised once the interpolation animation has been done.
  48194. */
  48195. onInterpolationDone?: () => void;
  48196. /**
  48197. * Observable triggered once the interpolation animation has been done.
  48198. */
  48199. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  48200. private _target;
  48201. private _effectiveTarget;
  48202. private _property;
  48203. /**
  48204. * Instantiate the action
  48205. * @param triggerOptions defines the trigger options
  48206. * @param target defines the object containing the value to interpolate
  48207. * @param propertyPath defines the path to the property in the target object
  48208. * @param value defines the target value at the end of the interpolation
  48209. * @param duration deines the time it will take for the property to interpolate to the value.
  48210. * @param condition defines the trigger related conditions
  48211. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  48212. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  48213. */
  48214. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  48215. /** @hidden */
  48216. _prepare(): void;
  48217. /**
  48218. * Execute the action starts the value interpolation.
  48219. */
  48220. execute(): void;
  48221. /**
  48222. * Serializes the actions and its related information.
  48223. * @param parent defines the object to serialize in
  48224. * @returns the serialized object
  48225. */
  48226. serialize(parent: any): any;
  48227. }
  48228. }
  48229. declare module BABYLON {
  48230. /**
  48231. * This represents the default audio engine used in babylon.
  48232. * It is responsible to play, synchronize and analyse sounds throughout the application.
  48233. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48234. */
  48235. export class AudioEngine implements IAudioEngine {
  48236. private _audioContext;
  48237. private _audioContextInitialized;
  48238. private _muteButton;
  48239. private _hostElement;
  48240. /**
  48241. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  48242. */
  48243. canUseWebAudio: boolean;
  48244. /**
  48245. * The master gain node defines the global audio volume of your audio engine.
  48246. */
  48247. masterGain: GainNode;
  48248. /**
  48249. * Defines if Babylon should emit a warning if WebAudio is not supported.
  48250. * @ignoreNaming
  48251. */
  48252. WarnedWebAudioUnsupported: boolean;
  48253. /**
  48254. * Gets whether or not mp3 are supported by your browser.
  48255. */
  48256. isMP3supported: boolean;
  48257. /**
  48258. * Gets whether or not ogg are supported by your browser.
  48259. */
  48260. isOGGsupported: boolean;
  48261. /**
  48262. * Gets whether audio has been unlocked on the device.
  48263. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  48264. * a user interaction has happened.
  48265. */
  48266. unlocked: boolean;
  48267. /**
  48268. * Defines if the audio engine relies on a custom unlocked button.
  48269. * In this case, the embedded button will not be displayed.
  48270. */
  48271. useCustomUnlockedButton: boolean;
  48272. /**
  48273. * Event raised when audio has been unlocked on the browser.
  48274. */
  48275. onAudioUnlockedObservable: Observable<IAudioEngine>;
  48276. /**
  48277. * Event raised when audio has been locked on the browser.
  48278. */
  48279. onAudioLockedObservable: Observable<IAudioEngine>;
  48280. /**
  48281. * Gets the current AudioContext if available.
  48282. */
  48283. get audioContext(): Nullable<AudioContext>;
  48284. private _connectedAnalyser;
  48285. /**
  48286. * Instantiates a new audio engine.
  48287. *
  48288. * There should be only one per page as some browsers restrict the number
  48289. * of audio contexts you can create.
  48290. * @param hostElement defines the host element where to display the mute icon if necessary
  48291. */
  48292. constructor(hostElement?: Nullable<HTMLElement>);
  48293. /**
  48294. * Flags the audio engine in Locked state.
  48295. * This happens due to new browser policies preventing audio to autoplay.
  48296. */
  48297. lock(): void;
  48298. /**
  48299. * Unlocks the audio engine once a user action has been done on the dom.
  48300. * This is helpful to resume play once browser policies have been satisfied.
  48301. */
  48302. unlock(): void;
  48303. private _resumeAudioContext;
  48304. private _initializeAudioContext;
  48305. private _tryToRun;
  48306. private _triggerRunningState;
  48307. private _triggerSuspendedState;
  48308. private _displayMuteButton;
  48309. private _moveButtonToTopLeft;
  48310. private _onResize;
  48311. private _hideMuteButton;
  48312. /**
  48313. * Destroy and release the resources associated with the audio ccontext.
  48314. */
  48315. dispose(): void;
  48316. /**
  48317. * Gets the global volume sets on the master gain.
  48318. * @returns the global volume if set or -1 otherwise
  48319. */
  48320. getGlobalVolume(): number;
  48321. /**
  48322. * Sets the global volume of your experience (sets on the master gain).
  48323. * @param newVolume Defines the new global volume of the application
  48324. */
  48325. setGlobalVolume(newVolume: number): void;
  48326. /**
  48327. * Connect the audio engine to an audio analyser allowing some amazing
  48328. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  48329. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  48330. * @param analyser The analyser to connect to the engine
  48331. */
  48332. connectToAnalyser(analyser: Analyser): void;
  48333. }
  48334. }
  48335. declare module BABYLON {
  48336. /**
  48337. * Options allowed during the creation of a sound track.
  48338. */
  48339. export interface ISoundTrackOptions {
  48340. /**
  48341. * The volume the sound track should take during creation
  48342. */
  48343. volume?: number;
  48344. /**
  48345. * Define if the sound track is the main sound track of the scene
  48346. */
  48347. mainTrack?: boolean;
  48348. }
  48349. /**
  48350. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  48351. * It will be also used in a future release to apply effects on a specific track.
  48352. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  48353. */
  48354. export class SoundTrack {
  48355. /**
  48356. * The unique identifier of the sound track in the scene.
  48357. */
  48358. id: number;
  48359. /**
  48360. * The list of sounds included in the sound track.
  48361. */
  48362. soundCollection: Array<Sound>;
  48363. private _outputAudioNode;
  48364. private _scene;
  48365. private _connectedAnalyser;
  48366. private _options;
  48367. private _isInitialized;
  48368. /**
  48369. * Creates a new sound track.
  48370. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  48371. * @param scene Define the scene the sound track belongs to
  48372. * @param options
  48373. */
  48374. constructor(scene: Scene, options?: ISoundTrackOptions);
  48375. private _initializeSoundTrackAudioGraph;
  48376. /**
  48377. * Release the sound track and its associated resources
  48378. */
  48379. dispose(): void;
  48380. /**
  48381. * Adds a sound to this sound track
  48382. * @param sound define the cound to add
  48383. * @ignoreNaming
  48384. */
  48385. addSound(sound: Sound): void;
  48386. /**
  48387. * Removes a sound to this sound track
  48388. * @param sound define the cound to remove
  48389. * @ignoreNaming
  48390. */
  48391. removeSound(sound: Sound): void;
  48392. /**
  48393. * Set a global volume for the full sound track.
  48394. * @param newVolume Define the new volume of the sound track
  48395. */
  48396. setVolume(newVolume: number): void;
  48397. /**
  48398. * Switch the panning model to HRTF:
  48399. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  48400. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48401. */
  48402. switchPanningModelToHRTF(): void;
  48403. /**
  48404. * Switch the panning model to Equal Power:
  48405. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  48406. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48407. */
  48408. switchPanningModelToEqualPower(): void;
  48409. /**
  48410. * Connect the sound track to an audio analyser allowing some amazing
  48411. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  48412. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  48413. * @param analyser The analyser to connect to the engine
  48414. */
  48415. connectToAnalyser(analyser: Analyser): void;
  48416. }
  48417. }
  48418. declare module BABYLON {
  48419. interface AbstractScene {
  48420. /**
  48421. * The list of sounds used in the scene.
  48422. */
  48423. sounds: Nullable<Array<Sound>>;
  48424. }
  48425. interface Scene {
  48426. /**
  48427. * @hidden
  48428. * Backing field
  48429. */
  48430. _mainSoundTrack: SoundTrack;
  48431. /**
  48432. * The main sound track played by the scene.
  48433. * It cotains your primary collection of sounds.
  48434. */
  48435. mainSoundTrack: SoundTrack;
  48436. /**
  48437. * The list of sound tracks added to the scene
  48438. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48439. */
  48440. soundTracks: Nullable<Array<SoundTrack>>;
  48441. /**
  48442. * Gets a sound using a given name
  48443. * @param name defines the name to search for
  48444. * @return the found sound or null if not found at all.
  48445. */
  48446. getSoundByName(name: string): Nullable<Sound>;
  48447. /**
  48448. * Gets or sets if audio support is enabled
  48449. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48450. */
  48451. audioEnabled: boolean;
  48452. /**
  48453. * Gets or sets if audio will be output to headphones
  48454. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48455. */
  48456. headphone: boolean;
  48457. /**
  48458. * Gets or sets custom audio listener position provider
  48459. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48460. */
  48461. audioListenerPositionProvider: Nullable<() => Vector3>;
  48462. /**
  48463. * Gets or sets a refresh rate when using 3D audio positioning
  48464. */
  48465. audioPositioningRefreshRate: number;
  48466. }
  48467. /**
  48468. * Defines the sound scene component responsible to manage any sounds
  48469. * in a given scene.
  48470. */
  48471. export class AudioSceneComponent implements ISceneSerializableComponent {
  48472. private static _CameraDirectionLH;
  48473. private static _CameraDirectionRH;
  48474. /**
  48475. * The component name helpfull to identify the component in the list of scene components.
  48476. */
  48477. readonly name: string;
  48478. /**
  48479. * The scene the component belongs to.
  48480. */
  48481. scene: Scene;
  48482. private _audioEnabled;
  48483. /**
  48484. * Gets whether audio is enabled or not.
  48485. * Please use related enable/disable method to switch state.
  48486. */
  48487. get audioEnabled(): boolean;
  48488. private _headphone;
  48489. /**
  48490. * Gets whether audio is outputing to headphone or not.
  48491. * Please use the according Switch methods to change output.
  48492. */
  48493. get headphone(): boolean;
  48494. /**
  48495. * Gets or sets a refresh rate when using 3D audio positioning
  48496. */
  48497. audioPositioningRefreshRate: number;
  48498. private _audioListenerPositionProvider;
  48499. /**
  48500. * Gets the current audio listener position provider
  48501. */
  48502. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  48503. /**
  48504. * Sets a custom listener position for all sounds in the scene
  48505. * By default, this is the position of the first active camera
  48506. */
  48507. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  48508. /**
  48509. * Creates a new instance of the component for the given scene
  48510. * @param scene Defines the scene to register the component in
  48511. */
  48512. constructor(scene: Scene);
  48513. /**
  48514. * Registers the component in a given scene
  48515. */
  48516. register(): void;
  48517. /**
  48518. * Rebuilds the elements related to this component in case of
  48519. * context lost for instance.
  48520. */
  48521. rebuild(): void;
  48522. /**
  48523. * Serializes the component data to the specified json object
  48524. * @param serializationObject The object to serialize to
  48525. */
  48526. serialize(serializationObject: any): void;
  48527. /**
  48528. * Adds all the elements from the container to the scene
  48529. * @param container the container holding the elements
  48530. */
  48531. addFromContainer(container: AbstractScene): void;
  48532. /**
  48533. * Removes all the elements in the container from the scene
  48534. * @param container contains the elements to remove
  48535. * @param dispose if the removed element should be disposed (default: false)
  48536. */
  48537. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48538. /**
  48539. * Disposes the component and the associated ressources.
  48540. */
  48541. dispose(): void;
  48542. /**
  48543. * Disables audio in the associated scene.
  48544. */
  48545. disableAudio(): void;
  48546. /**
  48547. * Enables audio in the associated scene.
  48548. */
  48549. enableAudio(): void;
  48550. /**
  48551. * Switch audio to headphone output.
  48552. */
  48553. switchAudioModeForHeadphones(): void;
  48554. /**
  48555. * Switch audio to normal speakers.
  48556. */
  48557. switchAudioModeForNormalSpeakers(): void;
  48558. private _cachedCameraDirection;
  48559. private _cachedCameraPosition;
  48560. private _lastCheck;
  48561. private _afterRender;
  48562. }
  48563. }
  48564. declare module BABYLON {
  48565. /**
  48566. * Wraps one or more Sound objects and selects one with random weight for playback.
  48567. */
  48568. export class WeightedSound {
  48569. /** When true a Sound will be selected and played when the current playing Sound completes. */
  48570. loop: boolean;
  48571. private _coneInnerAngle;
  48572. private _coneOuterAngle;
  48573. private _volume;
  48574. /** A Sound is currently playing. */
  48575. isPlaying: boolean;
  48576. /** A Sound is currently paused. */
  48577. isPaused: boolean;
  48578. private _sounds;
  48579. private _weights;
  48580. private _currentIndex?;
  48581. /**
  48582. * Creates a new WeightedSound from the list of sounds given.
  48583. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  48584. * @param sounds Array of Sounds that will be selected from.
  48585. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  48586. */
  48587. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  48588. /**
  48589. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  48590. */
  48591. get directionalConeInnerAngle(): number;
  48592. /**
  48593. * The size of cone in degress for a directional sound in which there will be no attenuation.
  48594. */
  48595. set directionalConeInnerAngle(value: number);
  48596. /**
  48597. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  48598. * Listener angles between innerAngle and outerAngle will falloff linearly.
  48599. */
  48600. get directionalConeOuterAngle(): number;
  48601. /**
  48602. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  48603. * Listener angles between innerAngle and outerAngle will falloff linearly.
  48604. */
  48605. set directionalConeOuterAngle(value: number);
  48606. /**
  48607. * Playback volume.
  48608. */
  48609. get volume(): number;
  48610. /**
  48611. * Playback volume.
  48612. */
  48613. set volume(value: number);
  48614. private _onended;
  48615. /**
  48616. * Suspend playback
  48617. */
  48618. pause(): void;
  48619. /**
  48620. * Stop playback
  48621. */
  48622. stop(): void;
  48623. /**
  48624. * Start playback.
  48625. * @param startOffset Position the clip head at a specific time in seconds.
  48626. */
  48627. play(startOffset?: number): void;
  48628. }
  48629. }
  48630. declare module BABYLON {
  48631. /**
  48632. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  48633. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  48634. */
  48635. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  48636. /**
  48637. * Gets the name of the behavior.
  48638. */
  48639. get name(): string;
  48640. /**
  48641. * The easing function used by animations
  48642. */
  48643. static EasingFunction: BackEase;
  48644. /**
  48645. * The easing mode used by animations
  48646. */
  48647. static EasingMode: number;
  48648. /**
  48649. * The duration of the animation, in milliseconds
  48650. */
  48651. transitionDuration: number;
  48652. /**
  48653. * Length of the distance animated by the transition when lower radius is reached
  48654. */
  48655. lowerRadiusTransitionRange: number;
  48656. /**
  48657. * Length of the distance animated by the transition when upper radius is reached
  48658. */
  48659. upperRadiusTransitionRange: number;
  48660. private _autoTransitionRange;
  48661. /**
  48662. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  48663. */
  48664. get autoTransitionRange(): boolean;
  48665. /**
  48666. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  48667. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  48668. */
  48669. set autoTransitionRange(value: boolean);
  48670. private _attachedCamera;
  48671. private _onAfterCheckInputsObserver;
  48672. private _onMeshTargetChangedObserver;
  48673. /**
  48674. * Initializes the behavior.
  48675. */
  48676. init(): void;
  48677. /**
  48678. * Attaches the behavior to its arc rotate camera.
  48679. * @param camera Defines the camera to attach the behavior to
  48680. */
  48681. attach(camera: ArcRotateCamera): void;
  48682. /**
  48683. * Detaches the behavior from its current arc rotate camera.
  48684. */
  48685. detach(): void;
  48686. private _radiusIsAnimating;
  48687. private _radiusBounceTransition;
  48688. private _animatables;
  48689. private _cachedWheelPrecision;
  48690. /**
  48691. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  48692. * @param radiusLimit The limit to check against.
  48693. * @return Bool to indicate if at limit.
  48694. */
  48695. private _isRadiusAtLimit;
  48696. /**
  48697. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  48698. * @param radiusDelta The delta by which to animate to. Can be negative.
  48699. */
  48700. private _applyBoundRadiusAnimation;
  48701. /**
  48702. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  48703. */
  48704. protected _clearAnimationLocks(): void;
  48705. /**
  48706. * Stops and removes all animations that have been applied to the camera
  48707. */
  48708. stopAllAnimations(): void;
  48709. }
  48710. }
  48711. declare module BABYLON {
  48712. /**
  48713. * 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.
  48714. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  48715. */
  48716. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  48717. /**
  48718. * Gets the name of the behavior.
  48719. */
  48720. get name(): string;
  48721. private _mode;
  48722. private _radiusScale;
  48723. private _positionScale;
  48724. private _defaultElevation;
  48725. private _elevationReturnTime;
  48726. private _elevationReturnWaitTime;
  48727. private _zoomStopsAnimation;
  48728. private _framingTime;
  48729. /**
  48730. * The easing function used by animations
  48731. */
  48732. static EasingFunction: ExponentialEase;
  48733. /**
  48734. * The easing mode used by animations
  48735. */
  48736. static EasingMode: number;
  48737. /**
  48738. * Sets the current mode used by the behavior
  48739. */
  48740. set mode(mode: number);
  48741. /**
  48742. * Gets current mode used by the behavior.
  48743. */
  48744. get mode(): number;
  48745. /**
  48746. * Sets the scale applied to the radius (1 by default)
  48747. */
  48748. set radiusScale(radius: number);
  48749. /**
  48750. * Gets the scale applied to the radius
  48751. */
  48752. get radiusScale(): number;
  48753. /**
  48754. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  48755. */
  48756. set positionScale(scale: number);
  48757. /**
  48758. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  48759. */
  48760. get positionScale(): number;
  48761. /**
  48762. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  48763. * behaviour is triggered, in radians.
  48764. */
  48765. set defaultElevation(elevation: number);
  48766. /**
  48767. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  48768. * behaviour is triggered, in radians.
  48769. */
  48770. get defaultElevation(): number;
  48771. /**
  48772. * Sets the time (in milliseconds) taken to return to the default beta position.
  48773. * Negative value indicates camera should not return to default.
  48774. */
  48775. set elevationReturnTime(speed: number);
  48776. /**
  48777. * Gets the time (in milliseconds) taken to return to the default beta position.
  48778. * Negative value indicates camera should not return to default.
  48779. */
  48780. get elevationReturnTime(): number;
  48781. /**
  48782. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  48783. */
  48784. set elevationReturnWaitTime(time: number);
  48785. /**
  48786. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  48787. */
  48788. get elevationReturnWaitTime(): number;
  48789. /**
  48790. * Sets the flag that indicates if user zooming should stop animation.
  48791. */
  48792. set zoomStopsAnimation(flag: boolean);
  48793. /**
  48794. * Gets the flag that indicates if user zooming should stop animation.
  48795. */
  48796. get zoomStopsAnimation(): boolean;
  48797. /**
  48798. * Sets the transition time when framing the mesh, in milliseconds
  48799. */
  48800. set framingTime(time: number);
  48801. /**
  48802. * Gets the transition time when framing the mesh, in milliseconds
  48803. */
  48804. get framingTime(): number;
  48805. /**
  48806. * Define if the behavior should automatically change the configured
  48807. * camera limits and sensibilities.
  48808. */
  48809. autoCorrectCameraLimitsAndSensibility: boolean;
  48810. private _onPrePointerObservableObserver;
  48811. private _onAfterCheckInputsObserver;
  48812. private _onMeshTargetChangedObserver;
  48813. private _attachedCamera;
  48814. private _isPointerDown;
  48815. private _lastInteractionTime;
  48816. /**
  48817. * Initializes the behavior.
  48818. */
  48819. init(): void;
  48820. /**
  48821. * Attaches the behavior to its arc rotate camera.
  48822. * @param camera Defines the camera to attach the behavior to
  48823. */
  48824. attach(camera: ArcRotateCamera): void;
  48825. /**
  48826. * Detaches the behavior from its current arc rotate camera.
  48827. */
  48828. detach(): void;
  48829. private _animatables;
  48830. private _betaIsAnimating;
  48831. private _betaTransition;
  48832. private _radiusTransition;
  48833. private _vectorTransition;
  48834. /**
  48835. * Targets the given mesh and updates zoom level accordingly.
  48836. * @param mesh The mesh to target.
  48837. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  48838. * @param onAnimationEnd Callback triggered at the end of the framing animation
  48839. */
  48840. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  48841. /**
  48842. * Targets the given mesh with its children and updates zoom level accordingly.
  48843. * @param mesh The mesh to target.
  48844. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  48845. * @param onAnimationEnd Callback triggered at the end of the framing animation
  48846. */
  48847. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  48848. /**
  48849. * Targets the given meshes with their children and updates zoom level accordingly.
  48850. * @param meshes The mesh to target.
  48851. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  48852. * @param onAnimationEnd Callback triggered at the end of the framing animation
  48853. */
  48854. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  48855. /**
  48856. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  48857. * @param minimumWorld Determines the smaller position of the bounding box extend
  48858. * @param maximumWorld Determines the bigger position of the bounding box extend
  48859. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  48860. * @param onAnimationEnd Callback triggered at the end of the framing animation
  48861. */
  48862. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  48863. /**
  48864. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  48865. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  48866. * frustum width.
  48867. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  48868. * to fully enclose the mesh in the viewing frustum.
  48869. */
  48870. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  48871. /**
  48872. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  48873. * is automatically returned to its default position (expected to be above ground plane).
  48874. */
  48875. private _maintainCameraAboveGround;
  48876. /**
  48877. * Returns the frustum slope based on the canvas ratio and camera FOV
  48878. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  48879. */
  48880. private _getFrustumSlope;
  48881. /**
  48882. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  48883. */
  48884. private _clearAnimationLocks;
  48885. /**
  48886. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  48887. */
  48888. private _applyUserInteraction;
  48889. /**
  48890. * Stops and removes all animations that have been applied to the camera
  48891. */
  48892. stopAllAnimations(): void;
  48893. /**
  48894. * Gets a value indicating if the user is moving the camera
  48895. */
  48896. get isUserIsMoving(): boolean;
  48897. /**
  48898. * The camera can move all the way towards the mesh.
  48899. */
  48900. static IgnoreBoundsSizeMode: number;
  48901. /**
  48902. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  48903. */
  48904. static FitFrustumSidesMode: number;
  48905. }
  48906. }
  48907. declare module BABYLON {
  48908. /**
  48909. * Base class for Camera Pointer Inputs.
  48910. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  48911. * for example usage.
  48912. */
  48913. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  48914. /**
  48915. * Defines the camera the input is attached to.
  48916. */
  48917. abstract camera: Camera;
  48918. /**
  48919. * Whether keyboard modifier keys are pressed at time of last mouse event.
  48920. */
  48921. protected _altKey: boolean;
  48922. protected _ctrlKey: boolean;
  48923. protected _metaKey: boolean;
  48924. protected _shiftKey: boolean;
  48925. /**
  48926. * Which mouse buttons were pressed at time of last mouse event.
  48927. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  48928. */
  48929. protected _buttonsPressed: number;
  48930. /**
  48931. * Defines the buttons associated with the input to handle camera move.
  48932. */
  48933. buttons: number[];
  48934. /**
  48935. * Attach the input controls to a specific dom element to get the input from.
  48936. * @param element Defines the element the controls should be listened from
  48937. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48938. */
  48939. attachControl(noPreventDefault?: boolean): void;
  48940. /**
  48941. * Detach the current controls from the specified dom element.
  48942. */
  48943. detachControl(): void;
  48944. /**
  48945. * Gets the class name of the current input.
  48946. * @returns the class name
  48947. */
  48948. getClassName(): string;
  48949. /**
  48950. * Get the friendly name associated with the input class.
  48951. * @returns the input friendly name
  48952. */
  48953. getSimpleName(): string;
  48954. /**
  48955. * Called on pointer POINTERDOUBLETAP event.
  48956. * Override this method to provide functionality on POINTERDOUBLETAP event.
  48957. */
  48958. protected onDoubleTap(type: string): void;
  48959. /**
  48960. * Called on pointer POINTERMOVE event if only a single touch is active.
  48961. * Override this method to provide functionality.
  48962. */
  48963. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  48964. /**
  48965. * Called on pointer POINTERMOVE event if multiple touches are active.
  48966. * Override this method to provide functionality.
  48967. */
  48968. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  48969. /**
  48970. * Called on JS contextmenu event.
  48971. * Override this method to provide functionality.
  48972. */
  48973. protected onContextMenu(evt: PointerEvent): void;
  48974. /**
  48975. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  48976. * press.
  48977. * Override this method to provide functionality.
  48978. */
  48979. protected onButtonDown(evt: PointerEvent): void;
  48980. /**
  48981. * Called each time a new POINTERUP event occurs. Ie, for each button
  48982. * release.
  48983. * Override this method to provide functionality.
  48984. */
  48985. protected onButtonUp(evt: PointerEvent): void;
  48986. /**
  48987. * Called when window becomes inactive.
  48988. * Override this method to provide functionality.
  48989. */
  48990. protected onLostFocus(): void;
  48991. private _pointerInput;
  48992. private _observer;
  48993. private _onLostFocus;
  48994. private pointA;
  48995. private pointB;
  48996. }
  48997. }
  48998. declare module BABYLON {
  48999. /**
  49000. * Manage the pointers inputs to control an arc rotate camera.
  49001. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49002. */
  49003. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  49004. /**
  49005. * Defines the camera the input is attached to.
  49006. */
  49007. camera: ArcRotateCamera;
  49008. /**
  49009. * Gets the class name of the current input.
  49010. * @returns the class name
  49011. */
  49012. getClassName(): string;
  49013. /**
  49014. * Defines the buttons associated with the input to handle camera move.
  49015. */
  49016. buttons: number[];
  49017. /**
  49018. * Defines the pointer angular sensibility along the X axis or how fast is
  49019. * the camera rotating.
  49020. */
  49021. angularSensibilityX: number;
  49022. /**
  49023. * Defines the pointer angular sensibility along the Y axis or how fast is
  49024. * the camera rotating.
  49025. */
  49026. angularSensibilityY: number;
  49027. /**
  49028. * Defines the pointer pinch precision or how fast is the camera zooming.
  49029. */
  49030. pinchPrecision: number;
  49031. /**
  49032. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49033. * from 0.
  49034. * It defines the percentage of current camera.radius to use as delta when
  49035. * pinch zoom is used.
  49036. */
  49037. pinchDeltaPercentage: number;
  49038. /**
  49039. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  49040. * that any object in the plane at the camera's target point will scale
  49041. * perfectly with finger motion.
  49042. * Overrides pinchDeltaPercentage and pinchPrecision.
  49043. */
  49044. useNaturalPinchZoom: boolean;
  49045. /**
  49046. * Defines the pointer panning sensibility or how fast is the camera moving.
  49047. */
  49048. panningSensibility: number;
  49049. /**
  49050. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  49051. */
  49052. multiTouchPanning: boolean;
  49053. /**
  49054. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  49055. * zoom (pinch) through multitouch.
  49056. */
  49057. multiTouchPanAndZoom: boolean;
  49058. /**
  49059. * Revers pinch action direction.
  49060. */
  49061. pinchInwards: boolean;
  49062. private _isPanClick;
  49063. private _twoFingerActivityCount;
  49064. private _isPinching;
  49065. /**
  49066. * Called on pointer POINTERMOVE event if only a single touch is active.
  49067. */
  49068. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49069. /**
  49070. * Called on pointer POINTERDOUBLETAP event.
  49071. */
  49072. protected onDoubleTap(type: string): void;
  49073. /**
  49074. * Called on pointer POINTERMOVE event if multiple touches are active.
  49075. */
  49076. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49077. /**
  49078. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  49079. * press.
  49080. */
  49081. protected onButtonDown(evt: PointerEvent): void;
  49082. /**
  49083. * Called each time a new POINTERUP event occurs. Ie, for each button
  49084. * release.
  49085. */
  49086. protected onButtonUp(evt: PointerEvent): void;
  49087. /**
  49088. * Called when window becomes inactive.
  49089. */
  49090. protected onLostFocus(): void;
  49091. }
  49092. }
  49093. declare module BABYLON {
  49094. /**
  49095. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  49096. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49097. */
  49098. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  49099. /**
  49100. * Defines the camera the input is attached to.
  49101. */
  49102. camera: ArcRotateCamera;
  49103. /**
  49104. * Defines the list of key codes associated with the up action (increase alpha)
  49105. */
  49106. keysUp: number[];
  49107. /**
  49108. * Defines the list of key codes associated with the down action (decrease alpha)
  49109. */
  49110. keysDown: number[];
  49111. /**
  49112. * Defines the list of key codes associated with the left action (increase beta)
  49113. */
  49114. keysLeft: number[];
  49115. /**
  49116. * Defines the list of key codes associated with the right action (decrease beta)
  49117. */
  49118. keysRight: number[];
  49119. /**
  49120. * Defines the list of key codes associated with the reset action.
  49121. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  49122. */
  49123. keysReset: number[];
  49124. /**
  49125. * Defines the panning sensibility of the inputs.
  49126. * (How fast is the camera panning)
  49127. */
  49128. panningSensibility: number;
  49129. /**
  49130. * Defines the zooming sensibility of the inputs.
  49131. * (How fast is the camera zooming)
  49132. */
  49133. zoomingSensibility: number;
  49134. /**
  49135. * Defines whether maintaining the alt key down switch the movement mode from
  49136. * orientation to zoom.
  49137. */
  49138. useAltToZoom: boolean;
  49139. /**
  49140. * Rotation speed of the camera
  49141. */
  49142. angularSpeed: number;
  49143. private _keys;
  49144. private _ctrlPressed;
  49145. private _altPressed;
  49146. private _onCanvasBlurObserver;
  49147. private _onKeyboardObserver;
  49148. private _engine;
  49149. private _scene;
  49150. /**
  49151. * Attach the input controls to a specific dom element to get the input from.
  49152. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49153. */
  49154. attachControl(noPreventDefault?: boolean): void;
  49155. /**
  49156. * Detach the current controls from the specified dom element.
  49157. */
  49158. detachControl(): void;
  49159. /**
  49160. * Update the current camera state depending on the inputs that have been used this frame.
  49161. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49162. */
  49163. checkInputs(): void;
  49164. /**
  49165. * Gets the class name of the current intput.
  49166. * @returns the class name
  49167. */
  49168. getClassName(): string;
  49169. /**
  49170. * Get the friendly name associated with the input class.
  49171. * @returns the input friendly name
  49172. */
  49173. getSimpleName(): string;
  49174. }
  49175. }
  49176. declare module BABYLON {
  49177. /**
  49178. * Manage the mouse wheel inputs to control an arc rotate camera.
  49179. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49180. */
  49181. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  49182. /**
  49183. * Defines the camera the input is attached to.
  49184. */
  49185. camera: ArcRotateCamera;
  49186. /**
  49187. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  49188. */
  49189. wheelPrecision: number;
  49190. /**
  49191. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49192. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49193. */
  49194. wheelDeltaPercentage: number;
  49195. private _wheel;
  49196. private _observer;
  49197. private computeDeltaFromMouseWheelLegacyEvent;
  49198. /**
  49199. * Attach the input controls to a specific dom element to get the input from.
  49200. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49201. */
  49202. attachControl(noPreventDefault?: boolean): void;
  49203. /**
  49204. * Detach the current controls from the specified dom element.
  49205. */
  49206. detachControl(): void;
  49207. /**
  49208. * Gets the class name of the current intput.
  49209. * @returns the class name
  49210. */
  49211. getClassName(): string;
  49212. /**
  49213. * Get the friendly name associated with the input class.
  49214. * @returns the input friendly name
  49215. */
  49216. getSimpleName(): string;
  49217. }
  49218. }
  49219. declare module BABYLON {
  49220. /**
  49221. * Default Inputs manager for the ArcRotateCamera.
  49222. * It groups all the default supported inputs for ease of use.
  49223. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49224. */
  49225. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  49226. /**
  49227. * Instantiates a new ArcRotateCameraInputsManager.
  49228. * @param camera Defines the camera the inputs belong to
  49229. */
  49230. constructor(camera: ArcRotateCamera);
  49231. /**
  49232. * Add mouse wheel input support to the input manager.
  49233. * @returns the current input manager
  49234. */
  49235. addMouseWheel(): ArcRotateCameraInputsManager;
  49236. /**
  49237. * Add pointers input support to the input manager.
  49238. * @returns the current input manager
  49239. */
  49240. addPointers(): ArcRotateCameraInputsManager;
  49241. /**
  49242. * Add keyboard input support to the input manager.
  49243. * @returns the current input manager
  49244. */
  49245. addKeyboard(): ArcRotateCameraInputsManager;
  49246. }
  49247. }
  49248. declare module BABYLON {
  49249. /**
  49250. * This represents an orbital type of camera.
  49251. *
  49252. * 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.
  49253. * 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.
  49254. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  49255. */
  49256. export class ArcRotateCamera extends TargetCamera {
  49257. /**
  49258. * Defines the rotation angle of the camera along the longitudinal axis.
  49259. */
  49260. alpha: number;
  49261. /**
  49262. * Defines the rotation angle of the camera along the latitudinal axis.
  49263. */
  49264. beta: number;
  49265. /**
  49266. * Defines the radius of the camera from it s target point.
  49267. */
  49268. radius: number;
  49269. protected _target: Vector3;
  49270. protected _targetHost: Nullable<AbstractMesh>;
  49271. /**
  49272. * Defines the target point of the camera.
  49273. * The camera looks towards it form the radius distance.
  49274. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  49275. */
  49276. get target(): Vector3;
  49277. set target(value: Vector3);
  49278. /**
  49279. * Define the current local position of the camera in the scene
  49280. */
  49281. get position(): Vector3;
  49282. set position(newPosition: Vector3);
  49283. protected _upToYMatrix: Matrix;
  49284. protected _YToUpMatrix: Matrix;
  49285. /**
  49286. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  49287. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  49288. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  49289. */
  49290. set upVector(vec: Vector3);
  49291. get upVector(): Vector3;
  49292. /**
  49293. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  49294. */
  49295. setMatUp(): void;
  49296. /**
  49297. * Current inertia value on the longitudinal axis.
  49298. * The bigger this number the longer it will take for the camera to stop.
  49299. */
  49300. inertialAlphaOffset: number;
  49301. /**
  49302. * Current inertia value on the latitudinal axis.
  49303. * The bigger this number the longer it will take for the camera to stop.
  49304. */
  49305. inertialBetaOffset: number;
  49306. /**
  49307. * Current inertia value on the radius axis.
  49308. * The bigger this number the longer it will take for the camera to stop.
  49309. */
  49310. inertialRadiusOffset: number;
  49311. /**
  49312. * Minimum allowed angle on the longitudinal axis.
  49313. * This can help limiting how the Camera is able to move in the scene.
  49314. */
  49315. lowerAlphaLimit: Nullable<number>;
  49316. /**
  49317. * Maximum allowed angle on the longitudinal axis.
  49318. * This can help limiting how the Camera is able to move in the scene.
  49319. */
  49320. upperAlphaLimit: Nullable<number>;
  49321. /**
  49322. * Minimum allowed angle on the latitudinal axis.
  49323. * This can help limiting how the Camera is able to move in the scene.
  49324. */
  49325. lowerBetaLimit: number;
  49326. /**
  49327. * Maximum allowed angle on the latitudinal axis.
  49328. * This can help limiting how the Camera is able to move in the scene.
  49329. */
  49330. upperBetaLimit: number;
  49331. /**
  49332. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  49333. * This can help limiting how the Camera is able to move in the scene.
  49334. */
  49335. lowerRadiusLimit: Nullable<number>;
  49336. /**
  49337. * Maximum allowed distance of the camera to the target (The camera can not get further).
  49338. * This can help limiting how the Camera is able to move in the scene.
  49339. */
  49340. upperRadiusLimit: Nullable<number>;
  49341. /**
  49342. * Defines the current inertia value used during panning of the camera along the X axis.
  49343. */
  49344. inertialPanningX: number;
  49345. /**
  49346. * Defines the current inertia value used during panning of the camera along the Y axis.
  49347. */
  49348. inertialPanningY: number;
  49349. /**
  49350. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  49351. * Basically if your fingers moves away from more than this distance you will be considered
  49352. * in pinch mode.
  49353. */
  49354. pinchToPanMaxDistance: number;
  49355. /**
  49356. * Defines the maximum distance the camera can pan.
  49357. * This could help keeping the cammera always in your scene.
  49358. */
  49359. panningDistanceLimit: Nullable<number>;
  49360. /**
  49361. * Defines the target of the camera before paning.
  49362. */
  49363. panningOriginTarget: Vector3;
  49364. /**
  49365. * Defines the value of the inertia used during panning.
  49366. * 0 would mean stop inertia and one would mean no decelleration at all.
  49367. */
  49368. panningInertia: number;
  49369. /**
  49370. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  49371. */
  49372. get angularSensibilityX(): number;
  49373. set angularSensibilityX(value: number);
  49374. /**
  49375. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  49376. */
  49377. get angularSensibilityY(): number;
  49378. set angularSensibilityY(value: number);
  49379. /**
  49380. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  49381. */
  49382. get pinchPrecision(): number;
  49383. set pinchPrecision(value: number);
  49384. /**
  49385. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  49386. * It will be used instead of pinchDeltaPrecision if different from 0.
  49387. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  49388. */
  49389. get pinchDeltaPercentage(): number;
  49390. set pinchDeltaPercentage(value: number);
  49391. /**
  49392. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  49393. * and pinch delta percentage.
  49394. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  49395. * that any object in the plane at the camera's target point will scale
  49396. * perfectly with finger motion.
  49397. */
  49398. get useNaturalPinchZoom(): boolean;
  49399. set useNaturalPinchZoom(value: boolean);
  49400. /**
  49401. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  49402. */
  49403. get panningSensibility(): number;
  49404. set panningSensibility(value: number);
  49405. /**
  49406. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  49407. */
  49408. get keysUp(): number[];
  49409. set keysUp(value: number[]);
  49410. /**
  49411. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  49412. */
  49413. get keysDown(): number[];
  49414. set keysDown(value: number[]);
  49415. /**
  49416. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  49417. */
  49418. get keysLeft(): number[];
  49419. set keysLeft(value: number[]);
  49420. /**
  49421. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  49422. */
  49423. get keysRight(): number[];
  49424. set keysRight(value: number[]);
  49425. /**
  49426. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  49427. */
  49428. get wheelPrecision(): number;
  49429. set wheelPrecision(value: number);
  49430. /**
  49431. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  49432. * It will be used instead of pinchDeltaPrecision if different from 0.
  49433. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  49434. */
  49435. get wheelDeltaPercentage(): number;
  49436. set wheelDeltaPercentage(value: number);
  49437. /**
  49438. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  49439. */
  49440. zoomOnFactor: number;
  49441. /**
  49442. * Defines a screen offset for the camera position.
  49443. */
  49444. targetScreenOffset: Vector2;
  49445. /**
  49446. * Allows the camera to be completely reversed.
  49447. * If false the camera can not arrive upside down.
  49448. */
  49449. allowUpsideDown: boolean;
  49450. /**
  49451. * Define if double tap/click is used to restore the previously saved state of the camera.
  49452. */
  49453. useInputToRestoreState: boolean;
  49454. /** @hidden */
  49455. _viewMatrix: Matrix;
  49456. /** @hidden */
  49457. _useCtrlForPanning: boolean;
  49458. /** @hidden */
  49459. _panningMouseButton: number;
  49460. /**
  49461. * Defines the input associated to the camera.
  49462. */
  49463. inputs: ArcRotateCameraInputsManager;
  49464. /** @hidden */
  49465. _reset: () => void;
  49466. /**
  49467. * Defines the allowed panning axis.
  49468. */
  49469. panningAxis: Vector3;
  49470. protected _transformedDirection: Vector3;
  49471. private _bouncingBehavior;
  49472. /**
  49473. * Gets the bouncing behavior of the camera if it has been enabled.
  49474. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49475. */
  49476. get bouncingBehavior(): Nullable<BouncingBehavior>;
  49477. /**
  49478. * Defines if the bouncing behavior of the camera is enabled on the camera.
  49479. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49480. */
  49481. get useBouncingBehavior(): boolean;
  49482. set useBouncingBehavior(value: boolean);
  49483. private _framingBehavior;
  49484. /**
  49485. * Gets the framing behavior of the camera if it has been enabled.
  49486. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  49487. */
  49488. get framingBehavior(): Nullable<FramingBehavior>;
  49489. /**
  49490. * Defines if the framing behavior of the camera is enabled on the camera.
  49491. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  49492. */
  49493. get useFramingBehavior(): boolean;
  49494. set useFramingBehavior(value: boolean);
  49495. private _autoRotationBehavior;
  49496. /**
  49497. * Gets the auto rotation behavior of the camera if it has been enabled.
  49498. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49499. */
  49500. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  49501. /**
  49502. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  49503. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49504. */
  49505. get useAutoRotationBehavior(): boolean;
  49506. set useAutoRotationBehavior(value: boolean);
  49507. /**
  49508. * Observable triggered when the mesh target has been changed on the camera.
  49509. */
  49510. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  49511. /**
  49512. * Event raised when the camera is colliding with a mesh.
  49513. */
  49514. onCollide: (collidedMesh: AbstractMesh) => void;
  49515. /**
  49516. * Defines whether the camera should check collision with the objects oh the scene.
  49517. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  49518. */
  49519. checkCollisions: boolean;
  49520. /**
  49521. * Defines the collision radius of the camera.
  49522. * This simulates a sphere around the camera.
  49523. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  49524. */
  49525. collisionRadius: Vector3;
  49526. protected _collider: Collider;
  49527. protected _previousPosition: Vector3;
  49528. protected _collisionVelocity: Vector3;
  49529. protected _newPosition: Vector3;
  49530. protected _previousAlpha: number;
  49531. protected _previousBeta: number;
  49532. protected _previousRadius: number;
  49533. protected _collisionTriggered: boolean;
  49534. protected _targetBoundingCenter: Nullable<Vector3>;
  49535. private _computationVector;
  49536. /**
  49537. * Instantiates a new ArcRotateCamera in a given scene
  49538. * @param name Defines the name of the camera
  49539. * @param alpha Defines the camera rotation along the logitudinal axis
  49540. * @param beta Defines the camera rotation along the latitudinal axis
  49541. * @param radius Defines the camera distance from its target
  49542. * @param target Defines the camera target
  49543. * @param scene Defines the scene the camera belongs to
  49544. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  49545. */
  49546. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  49547. /** @hidden */
  49548. _initCache(): void;
  49549. /** @hidden */
  49550. _updateCache(ignoreParentClass?: boolean): void;
  49551. protected _getTargetPosition(): Vector3;
  49552. private _storedAlpha;
  49553. private _storedBeta;
  49554. private _storedRadius;
  49555. private _storedTarget;
  49556. private _storedTargetScreenOffset;
  49557. /**
  49558. * Stores the current state of the camera (alpha, beta, radius and target)
  49559. * @returns the camera itself
  49560. */
  49561. storeState(): Camera;
  49562. /**
  49563. * @hidden
  49564. * Restored camera state. You must call storeState() first
  49565. */
  49566. _restoreStateValues(): boolean;
  49567. /** @hidden */
  49568. _isSynchronizedViewMatrix(): boolean;
  49569. /**
  49570. * Attach the input controls to a specific dom element to get the input from.
  49571. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49572. */
  49573. attachControl(noPreventDefault?: boolean): void;
  49574. /**
  49575. * Attach the input controls to a specific dom element to get the input from.
  49576. * @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
  49577. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49578. */
  49579. attachControl(ignored: any, noPreventDefault?: boolean): void;
  49580. /**
  49581. * Attached controls to the current camera.
  49582. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49583. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  49584. */
  49585. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  49586. /**
  49587. * Attached controls to the current camera.
  49588. * @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
  49589. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49590. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  49591. */
  49592. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  49593. /**
  49594. * Attached controls to the current camera.
  49595. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49596. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  49597. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  49598. */
  49599. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  49600. /**
  49601. * Detach the current controls from the specified dom element.
  49602. */
  49603. detachControl(): void;
  49604. /**
  49605. * Detach the current controls from the specified dom element.
  49606. * @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
  49607. */
  49608. detachControl(ignored: any): void;
  49609. /** @hidden */
  49610. _checkInputs(): void;
  49611. protected _checkLimits(): void;
  49612. /**
  49613. * Rebuilds angles (alpha, beta) and radius from the give position and target
  49614. */
  49615. rebuildAnglesAndRadius(): void;
  49616. /**
  49617. * Use a position to define the current camera related information like alpha, beta and radius
  49618. * @param position Defines the position to set the camera at
  49619. */
  49620. setPosition(position: Vector3): void;
  49621. /**
  49622. * Defines the target the camera should look at.
  49623. * This will automatically adapt alpha beta and radius to fit within the new target.
  49624. * @param target Defines the new target as a Vector or a mesh
  49625. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  49626. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  49627. */
  49628. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  49629. /** @hidden */
  49630. _getViewMatrix(): Matrix;
  49631. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  49632. /**
  49633. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  49634. * @param meshes Defines the mesh to zoom on
  49635. * @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)
  49636. */
  49637. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  49638. /**
  49639. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  49640. * The target will be changed but the radius
  49641. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  49642. * @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)
  49643. */
  49644. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  49645. min: Vector3;
  49646. max: Vector3;
  49647. distance: number;
  49648. }, doNotUpdateMaxZ?: boolean): void;
  49649. /**
  49650. * @override
  49651. * Override Camera.createRigCamera
  49652. */
  49653. createRigCamera(name: string, cameraIndex: number): Camera;
  49654. /**
  49655. * @hidden
  49656. * @override
  49657. * Override Camera._updateRigCameras
  49658. */
  49659. _updateRigCameras(): void;
  49660. /**
  49661. * Destroy the camera and release the current resources hold by it.
  49662. */
  49663. dispose(): void;
  49664. /**
  49665. * Gets the current object class name.
  49666. * @return the class name
  49667. */
  49668. getClassName(): string;
  49669. }
  49670. }
  49671. declare module BABYLON {
  49672. /**
  49673. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  49674. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49675. */
  49676. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  49677. /**
  49678. * Gets the name of the behavior.
  49679. */
  49680. get name(): string;
  49681. private _zoomStopsAnimation;
  49682. private _idleRotationSpeed;
  49683. private _idleRotationWaitTime;
  49684. private _idleRotationSpinupTime;
  49685. /**
  49686. * Sets the flag that indicates if user zooming should stop animation.
  49687. */
  49688. set zoomStopsAnimation(flag: boolean);
  49689. /**
  49690. * Gets the flag that indicates if user zooming should stop animation.
  49691. */
  49692. get zoomStopsAnimation(): boolean;
  49693. /**
  49694. * Sets the default speed at which the camera rotates around the model.
  49695. */
  49696. set idleRotationSpeed(speed: number);
  49697. /**
  49698. * Gets the default speed at which the camera rotates around the model.
  49699. */
  49700. get idleRotationSpeed(): number;
  49701. /**
  49702. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  49703. */
  49704. set idleRotationWaitTime(time: number);
  49705. /**
  49706. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  49707. */
  49708. get idleRotationWaitTime(): number;
  49709. /**
  49710. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  49711. */
  49712. set idleRotationSpinupTime(time: number);
  49713. /**
  49714. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  49715. */
  49716. get idleRotationSpinupTime(): number;
  49717. /**
  49718. * Gets a value indicating if the camera is currently rotating because of this behavior
  49719. */
  49720. get rotationInProgress(): boolean;
  49721. private _onPrePointerObservableObserver;
  49722. private _onAfterCheckInputsObserver;
  49723. private _attachedCamera;
  49724. private _isPointerDown;
  49725. private _lastFrameTime;
  49726. private _lastInteractionTime;
  49727. private _cameraRotationSpeed;
  49728. /**
  49729. * Initializes the behavior.
  49730. */
  49731. init(): void;
  49732. /**
  49733. * Attaches the behavior to its arc rotate camera.
  49734. * @param camera Defines the camera to attach the behavior to
  49735. */
  49736. attach(camera: ArcRotateCamera): void;
  49737. /**
  49738. * Detaches the behavior from its current arc rotate camera.
  49739. */
  49740. detach(): void;
  49741. /**
  49742. * Returns true if user is scrolling.
  49743. * @return true if user is scrolling.
  49744. */
  49745. private _userIsZooming;
  49746. private _lastFrameRadius;
  49747. private _shouldAnimationStopForInteraction;
  49748. /**
  49749. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  49750. */
  49751. private _applyUserInteraction;
  49752. private _userIsMoving;
  49753. }
  49754. }
  49755. declare module BABYLON {
  49756. /**
  49757. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  49758. */
  49759. export class AttachToBoxBehavior implements Behavior<Mesh> {
  49760. private ui;
  49761. /**
  49762. * The name of the behavior
  49763. */
  49764. name: string;
  49765. /**
  49766. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  49767. */
  49768. distanceAwayFromFace: number;
  49769. /**
  49770. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  49771. */
  49772. distanceAwayFromBottomOfFace: number;
  49773. private _faceVectors;
  49774. private _target;
  49775. private _scene;
  49776. private _onRenderObserver;
  49777. private _tmpMatrix;
  49778. private _tmpVector;
  49779. /**
  49780. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  49781. * @param ui The transform node that should be attched to the mesh
  49782. */
  49783. constructor(ui: TransformNode);
  49784. /**
  49785. * Initializes the behavior
  49786. */
  49787. init(): void;
  49788. private _closestFace;
  49789. private _zeroVector;
  49790. private _lookAtTmpMatrix;
  49791. private _lookAtToRef;
  49792. /**
  49793. * Attaches the AttachToBoxBehavior to the passed in mesh
  49794. * @param target The mesh that the specified node will be attached to
  49795. */
  49796. attach(target: Mesh): void;
  49797. /**
  49798. * Detaches the behavior from the mesh
  49799. */
  49800. detach(): void;
  49801. }
  49802. }
  49803. declare module BABYLON {
  49804. /**
  49805. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  49806. */
  49807. export class FadeInOutBehavior implements Behavior<Mesh> {
  49808. /**
  49809. * Time in milliseconds to delay before fading in (Default: 0)
  49810. */
  49811. delay: number;
  49812. /**
  49813. * Time in milliseconds for the mesh to fade in (Default: 300)
  49814. */
  49815. fadeInTime: number;
  49816. private _millisecondsPerFrame;
  49817. private _hovered;
  49818. private _hoverValue;
  49819. private _ownerNode;
  49820. /**
  49821. * Instatiates the FadeInOutBehavior
  49822. */
  49823. constructor();
  49824. /**
  49825. * The name of the behavior
  49826. */
  49827. get name(): string;
  49828. /**
  49829. * Initializes the behavior
  49830. */
  49831. init(): void;
  49832. /**
  49833. * Attaches the fade behavior on the passed in mesh
  49834. * @param ownerNode The mesh that will be faded in/out once attached
  49835. */
  49836. attach(ownerNode: Mesh): void;
  49837. /**
  49838. * Detaches the behavior from the mesh
  49839. */
  49840. detach(): void;
  49841. /**
  49842. * Triggers the mesh to begin fading in or out
  49843. * @param value if the object should fade in or out (true to fade in)
  49844. */
  49845. fadeIn(value: boolean): void;
  49846. private _update;
  49847. private _setAllVisibility;
  49848. }
  49849. }
  49850. declare module BABYLON {
  49851. /**
  49852. * Class containing a set of static utilities functions for managing Pivots
  49853. * @hidden
  49854. */
  49855. export class PivotTools {
  49856. private static _PivotCached;
  49857. private static _OldPivotPoint;
  49858. private static _PivotTranslation;
  49859. private static _PivotTmpVector;
  49860. private static _PivotPostMultiplyPivotMatrix;
  49861. /** @hidden */
  49862. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  49863. /** @hidden */
  49864. static _RestorePivotPoint(mesh: AbstractMesh): void;
  49865. }
  49866. }
  49867. declare module BABYLON {
  49868. /**
  49869. * Class containing static functions to help procedurally build meshes
  49870. */
  49871. export class PlaneBuilder {
  49872. /**
  49873. * Creates a plane mesh
  49874. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  49875. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  49876. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  49877. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49878. * * 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
  49879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49880. * @param name defines the name of the mesh
  49881. * @param options defines the options used to create the mesh
  49882. * @param scene defines the hosting scene
  49883. * @returns the plane mesh
  49884. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  49885. */
  49886. static CreatePlane(name: string, options: {
  49887. size?: number;
  49888. width?: number;
  49889. height?: number;
  49890. sideOrientation?: number;
  49891. frontUVs?: Vector4;
  49892. backUVs?: Vector4;
  49893. updatable?: boolean;
  49894. sourcePlane?: Plane;
  49895. }, scene?: Nullable<Scene>): Mesh;
  49896. }
  49897. }
  49898. declare module BABYLON {
  49899. /**
  49900. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  49901. */
  49902. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  49903. private static _AnyMouseID;
  49904. /**
  49905. * Abstract mesh the behavior is set on
  49906. */
  49907. attachedNode: AbstractMesh;
  49908. private _dragPlane;
  49909. private _scene;
  49910. private _pointerObserver;
  49911. private _beforeRenderObserver;
  49912. private static _planeScene;
  49913. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  49914. /**
  49915. * 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)
  49916. */
  49917. maxDragAngle: number;
  49918. /**
  49919. * @hidden
  49920. */
  49921. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  49922. /**
  49923. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  49924. */
  49925. currentDraggingPointerID: number;
  49926. /**
  49927. * The last position where the pointer hit the drag plane in world space
  49928. */
  49929. lastDragPosition: Vector3;
  49930. /**
  49931. * If the behavior is currently in a dragging state
  49932. */
  49933. dragging: boolean;
  49934. /**
  49935. * 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)
  49936. */
  49937. dragDeltaRatio: number;
  49938. /**
  49939. * If the drag plane orientation should be updated during the dragging (Default: true)
  49940. */
  49941. updateDragPlane: boolean;
  49942. private _debugMode;
  49943. private _moving;
  49944. /**
  49945. * Fires each time the attached mesh is dragged with the pointer
  49946. * * delta between last drag position and current drag position in world space
  49947. * * dragDistance along the drag axis
  49948. * * dragPlaneNormal normal of the current drag plane used during the drag
  49949. * * dragPlanePoint in world space where the drag intersects the drag plane
  49950. */
  49951. onDragObservable: Observable<{
  49952. delta: Vector3;
  49953. dragPlanePoint: Vector3;
  49954. dragPlaneNormal: Vector3;
  49955. dragDistance: number;
  49956. pointerId: number;
  49957. }>;
  49958. /**
  49959. * Fires each time a drag begins (eg. mouse down on mesh)
  49960. */
  49961. onDragStartObservable: Observable<{
  49962. dragPlanePoint: Vector3;
  49963. pointerId: number;
  49964. }>;
  49965. /**
  49966. * Fires each time a drag ends (eg. mouse release after drag)
  49967. */
  49968. onDragEndObservable: Observable<{
  49969. dragPlanePoint: Vector3;
  49970. pointerId: number;
  49971. }>;
  49972. /**
  49973. * If the attached mesh should be moved when dragged
  49974. */
  49975. moveAttached: boolean;
  49976. /**
  49977. * If the drag behavior will react to drag events (Default: true)
  49978. */
  49979. enabled: boolean;
  49980. /**
  49981. * If pointer events should start and release the drag (Default: true)
  49982. */
  49983. startAndReleaseDragOnPointerEvents: boolean;
  49984. /**
  49985. * If camera controls should be detached during the drag
  49986. */
  49987. detachCameraControls: boolean;
  49988. /**
  49989. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  49990. */
  49991. useObjectOrientationForDragging: boolean;
  49992. private _options;
  49993. /**
  49994. * Gets the options used by the behavior
  49995. */
  49996. get options(): {
  49997. dragAxis?: Vector3;
  49998. dragPlaneNormal?: Vector3;
  49999. };
  50000. /**
  50001. * Sets the options used by the behavior
  50002. */
  50003. set options(options: {
  50004. dragAxis?: Vector3;
  50005. dragPlaneNormal?: Vector3;
  50006. });
  50007. /**
  50008. * Creates a pointer drag behavior that can be attached to a mesh
  50009. * @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)
  50010. */
  50011. constructor(options?: {
  50012. dragAxis?: Vector3;
  50013. dragPlaneNormal?: Vector3;
  50014. });
  50015. /**
  50016. * Predicate to determine if it is valid to move the object to a new position when it is moved
  50017. */
  50018. validateDrag: (targetPosition: Vector3) => boolean;
  50019. /**
  50020. * The name of the behavior
  50021. */
  50022. get name(): string;
  50023. /**
  50024. * Initializes the behavior
  50025. */
  50026. init(): void;
  50027. private _tmpVector;
  50028. private _alternatePickedPoint;
  50029. private _worldDragAxis;
  50030. private _targetPosition;
  50031. private _attachedToElement;
  50032. /**
  50033. * Attaches the drag behavior the passed in mesh
  50034. * @param ownerNode The mesh that will be dragged around once attached
  50035. * @param predicate Predicate to use for pick filtering
  50036. */
  50037. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  50038. /**
  50039. * Force relase the drag action by code.
  50040. */
  50041. releaseDrag(): void;
  50042. private _startDragRay;
  50043. private _lastPointerRay;
  50044. /**
  50045. * Simulates the start of a pointer drag event on the behavior
  50046. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  50047. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  50048. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  50049. */
  50050. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  50051. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  50052. private _dragDelta;
  50053. protected _moveDrag(ray: Ray): void;
  50054. private _pickWithRayOnDragPlane;
  50055. private _pointA;
  50056. private _pointC;
  50057. private _localAxis;
  50058. private _lookAt;
  50059. private _updateDragPlanePosition;
  50060. /**
  50061. * Detaches the behavior from the mesh
  50062. */
  50063. detach(): void;
  50064. }
  50065. }
  50066. declare module BABYLON {
  50067. /**
  50068. * A behavior that when attached to a mesh will allow the mesh to be scaled
  50069. */
  50070. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  50071. private _dragBehaviorA;
  50072. private _dragBehaviorB;
  50073. private _startDistance;
  50074. private _initialScale;
  50075. private _targetScale;
  50076. private _ownerNode;
  50077. private _sceneRenderObserver;
  50078. /**
  50079. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  50080. */
  50081. constructor();
  50082. /**
  50083. * The name of the behavior
  50084. */
  50085. get name(): string;
  50086. /**
  50087. * Initializes the behavior
  50088. */
  50089. init(): void;
  50090. private _getCurrentDistance;
  50091. /**
  50092. * Attaches the scale behavior the passed in mesh
  50093. * @param ownerNode The mesh that will be scaled around once attached
  50094. */
  50095. attach(ownerNode: Mesh): void;
  50096. /**
  50097. * Detaches the behavior from the mesh
  50098. */
  50099. detach(): void;
  50100. }
  50101. }
  50102. declare module BABYLON {
  50103. /**
  50104. * 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
  50105. */
  50106. export class SixDofDragBehavior implements Behavior<Mesh> {
  50107. private static _virtualScene;
  50108. private _ownerNode;
  50109. private _sceneRenderObserver;
  50110. private _scene;
  50111. private _targetPosition;
  50112. private _virtualOriginMesh;
  50113. private _virtualDragMesh;
  50114. private _pointerObserver;
  50115. private _moving;
  50116. private _startingOrientation;
  50117. private _attachedToElement;
  50118. /**
  50119. * 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)
  50120. */
  50121. private zDragFactor;
  50122. /**
  50123. * If the object should rotate to face the drag origin
  50124. */
  50125. rotateDraggedObject: boolean;
  50126. /**
  50127. * If the behavior is currently in a dragging state
  50128. */
  50129. dragging: boolean;
  50130. /**
  50131. * 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)
  50132. */
  50133. dragDeltaRatio: number;
  50134. /**
  50135. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  50136. */
  50137. currentDraggingPointerID: number;
  50138. /**
  50139. * If camera controls should be detached during the drag
  50140. */
  50141. detachCameraControls: boolean;
  50142. /**
  50143. * Fires each time a drag starts
  50144. */
  50145. onDragStartObservable: Observable<{}>;
  50146. /**
  50147. * Fires each time a drag happens
  50148. */
  50149. onDragObservable: Observable<void>;
  50150. /**
  50151. * Fires each time a drag ends (eg. mouse release after drag)
  50152. */
  50153. onDragEndObservable: Observable<{}>;
  50154. /**
  50155. * 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
  50156. */
  50157. constructor();
  50158. /**
  50159. * The name of the behavior
  50160. */
  50161. get name(): string;
  50162. /**
  50163. * Initializes the behavior
  50164. */
  50165. init(): void;
  50166. /**
  50167. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  50168. */
  50169. private get _pointerCamera();
  50170. /**
  50171. * Attaches the scale behavior the passed in mesh
  50172. * @param ownerNode The mesh that will be scaled around once attached
  50173. */
  50174. attach(ownerNode: Mesh): void;
  50175. /**
  50176. * Detaches the behavior from the mesh
  50177. */
  50178. detach(): void;
  50179. }
  50180. }
  50181. declare module BABYLON {
  50182. /**
  50183. * Class used to apply inverse kinematics to bones
  50184. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  50185. */
  50186. export class BoneIKController {
  50187. private static _tmpVecs;
  50188. private static _tmpQuat;
  50189. private static _tmpMats;
  50190. /**
  50191. * Gets or sets the target mesh
  50192. */
  50193. targetMesh: AbstractMesh;
  50194. /** Gets or sets the mesh used as pole */
  50195. poleTargetMesh: AbstractMesh;
  50196. /**
  50197. * Gets or sets the bone used as pole
  50198. */
  50199. poleTargetBone: Nullable<Bone>;
  50200. /**
  50201. * Gets or sets the target position
  50202. */
  50203. targetPosition: Vector3;
  50204. /**
  50205. * Gets or sets the pole target position
  50206. */
  50207. poleTargetPosition: Vector3;
  50208. /**
  50209. * Gets or sets the pole target local offset
  50210. */
  50211. poleTargetLocalOffset: Vector3;
  50212. /**
  50213. * Gets or sets the pole angle
  50214. */
  50215. poleAngle: number;
  50216. /**
  50217. * Gets or sets the mesh associated with the controller
  50218. */
  50219. mesh: AbstractMesh;
  50220. /**
  50221. * 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)
  50222. */
  50223. slerpAmount: number;
  50224. private _bone1Quat;
  50225. private _bone1Mat;
  50226. private _bone2Ang;
  50227. private _bone1;
  50228. private _bone2;
  50229. private _bone1Length;
  50230. private _bone2Length;
  50231. private _maxAngle;
  50232. private _maxReach;
  50233. private _rightHandedSystem;
  50234. private _bendAxis;
  50235. private _slerping;
  50236. private _adjustRoll;
  50237. /**
  50238. * Gets or sets maximum allowed angle
  50239. */
  50240. get maxAngle(): number;
  50241. set maxAngle(value: number);
  50242. /**
  50243. * Creates a new BoneIKController
  50244. * @param mesh defines the mesh to control
  50245. * @param bone defines the bone to control
  50246. * @param options defines options to set up the controller
  50247. */
  50248. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  50249. targetMesh?: AbstractMesh;
  50250. poleTargetMesh?: AbstractMesh;
  50251. poleTargetBone?: Bone;
  50252. poleTargetLocalOffset?: Vector3;
  50253. poleAngle?: number;
  50254. bendAxis?: Vector3;
  50255. maxAngle?: number;
  50256. slerpAmount?: number;
  50257. });
  50258. private _setMaxAngle;
  50259. /**
  50260. * Force the controller to update the bones
  50261. */
  50262. update(): void;
  50263. }
  50264. }
  50265. declare module BABYLON {
  50266. /**
  50267. * Class used to make a bone look toward a point in space
  50268. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  50269. */
  50270. export class BoneLookController {
  50271. private static _tmpVecs;
  50272. private static _tmpQuat;
  50273. private static _tmpMats;
  50274. /**
  50275. * The target Vector3 that the bone will look at
  50276. */
  50277. target: Vector3;
  50278. /**
  50279. * The mesh that the bone is attached to
  50280. */
  50281. mesh: AbstractMesh;
  50282. /**
  50283. * The bone that will be looking to the target
  50284. */
  50285. bone: Bone;
  50286. /**
  50287. * The up axis of the coordinate system that is used when the bone is rotated
  50288. */
  50289. upAxis: Vector3;
  50290. /**
  50291. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  50292. */
  50293. upAxisSpace: Space;
  50294. /**
  50295. * Used to make an adjustment to the yaw of the bone
  50296. */
  50297. adjustYaw: number;
  50298. /**
  50299. * Used to make an adjustment to the pitch of the bone
  50300. */
  50301. adjustPitch: number;
  50302. /**
  50303. * Used to make an adjustment to the roll of the bone
  50304. */
  50305. adjustRoll: number;
  50306. /**
  50307. * 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)
  50308. */
  50309. slerpAmount: number;
  50310. private _minYaw;
  50311. private _maxYaw;
  50312. private _minPitch;
  50313. private _maxPitch;
  50314. private _minYawSin;
  50315. private _minYawCos;
  50316. private _maxYawSin;
  50317. private _maxYawCos;
  50318. private _midYawConstraint;
  50319. private _minPitchTan;
  50320. private _maxPitchTan;
  50321. private _boneQuat;
  50322. private _slerping;
  50323. private _transformYawPitch;
  50324. private _transformYawPitchInv;
  50325. private _firstFrameSkipped;
  50326. private _yawRange;
  50327. private _fowardAxis;
  50328. /**
  50329. * Gets or sets the minimum yaw angle that the bone can look to
  50330. */
  50331. get minYaw(): number;
  50332. set minYaw(value: number);
  50333. /**
  50334. * Gets or sets the maximum yaw angle that the bone can look to
  50335. */
  50336. get maxYaw(): number;
  50337. set maxYaw(value: number);
  50338. /**
  50339. * Gets or sets the minimum pitch angle that the bone can look to
  50340. */
  50341. get minPitch(): number;
  50342. set minPitch(value: number);
  50343. /**
  50344. * Gets or sets the maximum pitch angle that the bone can look to
  50345. */
  50346. get maxPitch(): number;
  50347. set maxPitch(value: number);
  50348. /**
  50349. * Create a BoneLookController
  50350. * @param mesh the mesh that the bone belongs to
  50351. * @param bone the bone that will be looking to the target
  50352. * @param target the target Vector3 to look at
  50353. * @param options optional settings:
  50354. * * maxYaw: the maximum angle the bone will yaw to
  50355. * * minYaw: the minimum angle the bone will yaw to
  50356. * * maxPitch: the maximum angle the bone will pitch to
  50357. * * minPitch: the minimum angle the bone will yaw to
  50358. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  50359. * * upAxis: the up axis of the coordinate system
  50360. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  50361. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  50362. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  50363. * * adjustYaw: used to make an adjustment to the yaw of the bone
  50364. * * adjustPitch: used to make an adjustment to the pitch of the bone
  50365. * * adjustRoll: used to make an adjustment to the roll of the bone
  50366. **/
  50367. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  50368. maxYaw?: number;
  50369. minYaw?: number;
  50370. maxPitch?: number;
  50371. minPitch?: number;
  50372. slerpAmount?: number;
  50373. upAxis?: Vector3;
  50374. upAxisSpace?: Space;
  50375. yawAxis?: Vector3;
  50376. pitchAxis?: Vector3;
  50377. adjustYaw?: number;
  50378. adjustPitch?: number;
  50379. adjustRoll?: number;
  50380. });
  50381. /**
  50382. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  50383. */
  50384. update(): void;
  50385. private _getAngleDiff;
  50386. private _getAngleBetween;
  50387. private _isAngleBetween;
  50388. }
  50389. }
  50390. declare module BABYLON {
  50391. /**
  50392. * Manage the gamepad inputs to control an arc rotate camera.
  50393. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50394. */
  50395. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  50396. /**
  50397. * Defines the camera the input is attached to.
  50398. */
  50399. camera: ArcRotateCamera;
  50400. /**
  50401. * Defines the gamepad the input is gathering event from.
  50402. */
  50403. gamepad: Nullable<Gamepad>;
  50404. /**
  50405. * Defines the gamepad rotation sensiblity.
  50406. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50407. */
  50408. gamepadRotationSensibility: number;
  50409. /**
  50410. * Defines the gamepad move sensiblity.
  50411. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50412. */
  50413. gamepadMoveSensibility: number;
  50414. private _yAxisScale;
  50415. /**
  50416. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  50417. */
  50418. get invertYAxis(): boolean;
  50419. set invertYAxis(value: boolean);
  50420. private _onGamepadConnectedObserver;
  50421. private _onGamepadDisconnectedObserver;
  50422. /**
  50423. * Attach the input controls to a specific dom element to get the input from.
  50424. */
  50425. attachControl(): void;
  50426. /**
  50427. * Detach the current controls from the specified dom element.
  50428. */
  50429. detachControl(): void;
  50430. /**
  50431. * Update the current camera state depending on the inputs that have been used this frame.
  50432. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50433. */
  50434. checkInputs(): void;
  50435. /**
  50436. * Gets the class name of the current intput.
  50437. * @returns the class name
  50438. */
  50439. getClassName(): string;
  50440. /**
  50441. * Get the friendly name associated with the input class.
  50442. * @returns the input friendly name
  50443. */
  50444. getSimpleName(): string;
  50445. }
  50446. }
  50447. declare module BABYLON {
  50448. interface ArcRotateCameraInputsManager {
  50449. /**
  50450. * Add orientation input support to the input manager.
  50451. * @returns the current input manager
  50452. */
  50453. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  50454. }
  50455. /**
  50456. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  50457. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50458. */
  50459. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  50460. /**
  50461. * Defines the camera the input is attached to.
  50462. */
  50463. camera: ArcRotateCamera;
  50464. /**
  50465. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  50466. */
  50467. alphaCorrection: number;
  50468. /**
  50469. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  50470. */
  50471. gammaCorrection: number;
  50472. private _alpha;
  50473. private _gamma;
  50474. private _dirty;
  50475. private _deviceOrientationHandler;
  50476. /**
  50477. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  50478. */
  50479. constructor();
  50480. /**
  50481. * Attach the input controls to a specific dom element to get the input from.
  50482. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50483. */
  50484. attachControl(noPreventDefault?: boolean): void;
  50485. /** @hidden */
  50486. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  50487. /**
  50488. * Update the current camera state depending on the inputs that have been used this frame.
  50489. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50490. */
  50491. checkInputs(): void;
  50492. /**
  50493. * Detach the current controls from the specified dom element.
  50494. */
  50495. detachControl(): void;
  50496. /**
  50497. * Gets the class name of the current intput.
  50498. * @returns the class name
  50499. */
  50500. getClassName(): string;
  50501. /**
  50502. * Get the friendly name associated with the input class.
  50503. * @returns the input friendly name
  50504. */
  50505. getSimpleName(): string;
  50506. }
  50507. }
  50508. declare module BABYLON {
  50509. /**
  50510. * Listen to mouse events to control the camera.
  50511. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50512. */
  50513. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  50514. /**
  50515. * Defines the camera the input is attached to.
  50516. */
  50517. camera: FlyCamera;
  50518. /**
  50519. * Defines if touch is enabled. (Default is true.)
  50520. */
  50521. touchEnabled: boolean;
  50522. /**
  50523. * Defines the buttons associated with the input to handle camera rotation.
  50524. */
  50525. buttons: number[];
  50526. /**
  50527. * Assign buttons for Yaw control.
  50528. */
  50529. buttonsYaw: number[];
  50530. /**
  50531. * Assign buttons for Pitch control.
  50532. */
  50533. buttonsPitch: number[];
  50534. /**
  50535. * Assign buttons for Roll control.
  50536. */
  50537. buttonsRoll: number[];
  50538. /**
  50539. * Detect if any button is being pressed while mouse is moved.
  50540. * -1 = Mouse locked.
  50541. * 0 = Left button.
  50542. * 1 = Middle Button.
  50543. * 2 = Right Button.
  50544. */
  50545. activeButton: number;
  50546. /**
  50547. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  50548. * Higher values reduce its sensitivity.
  50549. */
  50550. angularSensibility: number;
  50551. private _observer;
  50552. private _rollObserver;
  50553. private previousPosition;
  50554. private noPreventDefault;
  50555. private element;
  50556. /**
  50557. * Listen to mouse events to control the camera.
  50558. * @param touchEnabled Define if touch is enabled. (Default is true.)
  50559. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50560. */
  50561. constructor(touchEnabled?: boolean);
  50562. /**
  50563. * Attach the mouse control to the HTML DOM element.
  50564. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  50565. */
  50566. attachControl(noPreventDefault?: boolean): void;
  50567. /**
  50568. * Detach the current controls from the specified dom element.
  50569. */
  50570. detachControl(): void;
  50571. /**
  50572. * Gets the class name of the current input.
  50573. * @returns the class name.
  50574. */
  50575. getClassName(): string;
  50576. /**
  50577. * Get the friendly name associated with the input class.
  50578. * @returns the input's friendly name.
  50579. */
  50580. getSimpleName(): string;
  50581. private _pointerInput;
  50582. private _onMouseMove;
  50583. /**
  50584. * Rotate camera by mouse offset.
  50585. */
  50586. private rotateCamera;
  50587. }
  50588. }
  50589. declare module BABYLON {
  50590. /**
  50591. * Default Inputs manager for the FlyCamera.
  50592. * It groups all the default supported inputs for ease of use.
  50593. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50594. */
  50595. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  50596. /**
  50597. * Instantiates a new FlyCameraInputsManager.
  50598. * @param camera Defines the camera the inputs belong to.
  50599. */
  50600. constructor(camera: FlyCamera);
  50601. /**
  50602. * Add keyboard input support to the input manager.
  50603. * @returns the new FlyCameraKeyboardMoveInput().
  50604. */
  50605. addKeyboard(): FlyCameraInputsManager;
  50606. /**
  50607. * Add mouse input support to the input manager.
  50608. * @param touchEnabled Enable touch screen support.
  50609. * @returns the new FlyCameraMouseInput().
  50610. */
  50611. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  50612. }
  50613. }
  50614. declare module BABYLON {
  50615. /**
  50616. * This is a flying camera, designed for 3D movement and rotation in all directions,
  50617. * such as in a 3D Space Shooter or a Flight Simulator.
  50618. */
  50619. export class FlyCamera extends TargetCamera {
  50620. /**
  50621. * Define the collision ellipsoid of the camera.
  50622. * This is helpful for simulating a camera body, like a player's body.
  50623. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  50624. */
  50625. ellipsoid: Vector3;
  50626. /**
  50627. * Define an offset for the position of the ellipsoid around the camera.
  50628. * This can be helpful if the camera is attached away from the player's body center,
  50629. * such as at its head.
  50630. */
  50631. ellipsoidOffset: Vector3;
  50632. /**
  50633. * Enable or disable collisions of the camera with the rest of the scene objects.
  50634. */
  50635. checkCollisions: boolean;
  50636. /**
  50637. * Enable or disable gravity on the camera.
  50638. */
  50639. applyGravity: boolean;
  50640. /**
  50641. * Define the current direction the camera is moving to.
  50642. */
  50643. cameraDirection: Vector3;
  50644. /**
  50645. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  50646. * This overrides and empties cameraRotation.
  50647. */
  50648. rotationQuaternion: Quaternion;
  50649. /**
  50650. * Track Roll to maintain the wanted Rolling when looking around.
  50651. */
  50652. _trackRoll: number;
  50653. /**
  50654. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  50655. */
  50656. rollCorrect: number;
  50657. /**
  50658. * Mimic a banked turn, Rolling the camera when Yawing.
  50659. * It's recommended to use rollCorrect = 10 for faster banking correction.
  50660. */
  50661. bankedTurn: boolean;
  50662. /**
  50663. * Limit in radians for how much Roll banking will add. (Default: 90°)
  50664. */
  50665. bankedTurnLimit: number;
  50666. /**
  50667. * Value of 0 disables the banked Roll.
  50668. * Value of 1 is equal to the Yaw angle in radians.
  50669. */
  50670. bankedTurnMultiplier: number;
  50671. /**
  50672. * The inputs manager loads all the input sources, such as keyboard and mouse.
  50673. */
  50674. inputs: FlyCameraInputsManager;
  50675. /**
  50676. * Gets the input sensibility for mouse input.
  50677. * Higher values reduce sensitivity.
  50678. */
  50679. get angularSensibility(): number;
  50680. /**
  50681. * Sets the input sensibility for a mouse input.
  50682. * Higher values reduce sensitivity.
  50683. */
  50684. set angularSensibility(value: number);
  50685. /**
  50686. * Get the keys for camera movement forward.
  50687. */
  50688. get keysForward(): number[];
  50689. /**
  50690. * Set the keys for camera movement forward.
  50691. */
  50692. set keysForward(value: number[]);
  50693. /**
  50694. * Get the keys for camera movement backward.
  50695. */
  50696. get keysBackward(): number[];
  50697. set keysBackward(value: number[]);
  50698. /**
  50699. * Get the keys for camera movement up.
  50700. */
  50701. get keysUp(): number[];
  50702. /**
  50703. * Set the keys for camera movement up.
  50704. */
  50705. set keysUp(value: number[]);
  50706. /**
  50707. * Get the keys for camera movement down.
  50708. */
  50709. get keysDown(): number[];
  50710. /**
  50711. * Set the keys for camera movement down.
  50712. */
  50713. set keysDown(value: number[]);
  50714. /**
  50715. * Get the keys for camera movement left.
  50716. */
  50717. get keysLeft(): number[];
  50718. /**
  50719. * Set the keys for camera movement left.
  50720. */
  50721. set keysLeft(value: number[]);
  50722. /**
  50723. * Set the keys for camera movement right.
  50724. */
  50725. get keysRight(): number[];
  50726. /**
  50727. * Set the keys for camera movement right.
  50728. */
  50729. set keysRight(value: number[]);
  50730. /**
  50731. * Event raised when the camera collides with a mesh in the scene.
  50732. */
  50733. onCollide: (collidedMesh: AbstractMesh) => void;
  50734. private _collider;
  50735. private _needMoveForGravity;
  50736. private _oldPosition;
  50737. private _diffPosition;
  50738. private _newPosition;
  50739. /** @hidden */
  50740. _localDirection: Vector3;
  50741. /** @hidden */
  50742. _transformedDirection: Vector3;
  50743. /**
  50744. * Instantiates a FlyCamera.
  50745. * This is a flying camera, designed for 3D movement and rotation in all directions,
  50746. * such as in a 3D Space Shooter or a Flight Simulator.
  50747. * @param name Define the name of the camera in the scene.
  50748. * @param position Define the starting position of the camera in the scene.
  50749. * @param scene Define the scene the camera belongs to.
  50750. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  50751. */
  50752. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  50753. /**
  50754. * Attach the input controls to a specific dom element to get the input from.
  50755. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50756. */
  50757. attachControl(noPreventDefault?: boolean): void;
  50758. /**
  50759. * Detach a control from the HTML DOM element.
  50760. * The camera will stop reacting to that input.
  50761. */
  50762. detachControl(): void;
  50763. private _collisionMask;
  50764. /**
  50765. * Get the mask that the camera ignores in collision events.
  50766. */
  50767. get collisionMask(): number;
  50768. /**
  50769. * Set the mask that the camera ignores in collision events.
  50770. */
  50771. set collisionMask(mask: number);
  50772. /** @hidden */
  50773. _collideWithWorld(displacement: Vector3): void;
  50774. /** @hidden */
  50775. private _onCollisionPositionChange;
  50776. /** @hidden */
  50777. _checkInputs(): void;
  50778. /** @hidden */
  50779. _decideIfNeedsToMove(): boolean;
  50780. /** @hidden */
  50781. _updatePosition(): void;
  50782. /**
  50783. * Restore the Roll to its target value at the rate specified.
  50784. * @param rate - Higher means slower restoring.
  50785. * @hidden
  50786. */
  50787. restoreRoll(rate: number): void;
  50788. /**
  50789. * Destroy the camera and release the current resources held by it.
  50790. */
  50791. dispose(): void;
  50792. /**
  50793. * Get the current object class name.
  50794. * @returns the class name.
  50795. */
  50796. getClassName(): string;
  50797. }
  50798. }
  50799. declare module BABYLON {
  50800. /**
  50801. * Listen to keyboard events to control the camera.
  50802. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50803. */
  50804. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  50805. /**
  50806. * Defines the camera the input is attached to.
  50807. */
  50808. camera: FlyCamera;
  50809. /**
  50810. * The list of keyboard keys used to control the forward move of the camera.
  50811. */
  50812. keysForward: number[];
  50813. /**
  50814. * The list of keyboard keys used to control the backward move of the camera.
  50815. */
  50816. keysBackward: number[];
  50817. /**
  50818. * The list of keyboard keys used to control the forward move of the camera.
  50819. */
  50820. keysUp: number[];
  50821. /**
  50822. * The list of keyboard keys used to control the backward move of the camera.
  50823. */
  50824. keysDown: number[];
  50825. /**
  50826. * The list of keyboard keys used to control the right strafe move of the camera.
  50827. */
  50828. keysRight: number[];
  50829. /**
  50830. * The list of keyboard keys used to control the left strafe move of the camera.
  50831. */
  50832. keysLeft: number[];
  50833. private _keys;
  50834. private _onCanvasBlurObserver;
  50835. private _onKeyboardObserver;
  50836. private _engine;
  50837. private _scene;
  50838. /**
  50839. * Attach the input controls to a specific dom element to get the input from.
  50840. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50841. */
  50842. attachControl(noPreventDefault?: boolean): void;
  50843. /**
  50844. * Detach the current controls from the specified dom element.
  50845. */
  50846. detachControl(): void;
  50847. /**
  50848. * Gets the class name of the current intput.
  50849. * @returns the class name
  50850. */
  50851. getClassName(): string;
  50852. /** @hidden */
  50853. _onLostFocus(e: FocusEvent): void;
  50854. /**
  50855. * Get the friendly name associated with the input class.
  50856. * @returns the input friendly name
  50857. */
  50858. getSimpleName(): string;
  50859. /**
  50860. * Update the current camera state depending on the inputs that have been used this frame.
  50861. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50862. */
  50863. checkInputs(): void;
  50864. }
  50865. }
  50866. declare module BABYLON {
  50867. /**
  50868. * Manage the mouse wheel inputs to control a follow camera.
  50869. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50870. */
  50871. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  50872. /**
  50873. * Defines the camera the input is attached to.
  50874. */
  50875. camera: FollowCamera;
  50876. /**
  50877. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  50878. */
  50879. axisControlRadius: boolean;
  50880. /**
  50881. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  50882. */
  50883. axisControlHeight: boolean;
  50884. /**
  50885. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  50886. */
  50887. axisControlRotation: boolean;
  50888. /**
  50889. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  50890. * relation to mouseWheel events.
  50891. */
  50892. wheelPrecision: number;
  50893. /**
  50894. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  50895. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  50896. */
  50897. wheelDeltaPercentage: number;
  50898. private _wheel;
  50899. private _observer;
  50900. /**
  50901. * Attach the input controls to a specific dom element to get the input from.
  50902. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50903. */
  50904. attachControl(noPreventDefault?: boolean): void;
  50905. /**
  50906. * Detach the current controls from the specified dom element.
  50907. */
  50908. detachControl(): void;
  50909. /**
  50910. * Gets the class name of the current intput.
  50911. * @returns the class name
  50912. */
  50913. getClassName(): string;
  50914. /**
  50915. * Get the friendly name associated with the input class.
  50916. * @returns the input friendly name
  50917. */
  50918. getSimpleName(): string;
  50919. }
  50920. }
  50921. declare module BABYLON {
  50922. /**
  50923. * Manage the pointers inputs to control an follow camera.
  50924. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50925. */
  50926. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  50927. /**
  50928. * Defines the camera the input is attached to.
  50929. */
  50930. camera: FollowCamera;
  50931. /**
  50932. * Gets the class name of the current input.
  50933. * @returns the class name
  50934. */
  50935. getClassName(): string;
  50936. /**
  50937. * Defines the pointer angular sensibility along the X axis or how fast is
  50938. * the camera rotating.
  50939. * A negative number will reverse the axis direction.
  50940. */
  50941. angularSensibilityX: number;
  50942. /**
  50943. * Defines the pointer angular sensibility along the Y axis or how fast is
  50944. * the camera rotating.
  50945. * A negative number will reverse the axis direction.
  50946. */
  50947. angularSensibilityY: number;
  50948. /**
  50949. * Defines the pointer pinch precision or how fast is the camera zooming.
  50950. * A negative number will reverse the axis direction.
  50951. */
  50952. pinchPrecision: number;
  50953. /**
  50954. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  50955. * from 0.
  50956. * It defines the percentage of current camera.radius to use as delta when
  50957. * pinch zoom is used.
  50958. */
  50959. pinchDeltaPercentage: number;
  50960. /**
  50961. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  50962. */
  50963. axisXControlRadius: boolean;
  50964. /**
  50965. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  50966. */
  50967. axisXControlHeight: boolean;
  50968. /**
  50969. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  50970. */
  50971. axisXControlRotation: boolean;
  50972. /**
  50973. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  50974. */
  50975. axisYControlRadius: boolean;
  50976. /**
  50977. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  50978. */
  50979. axisYControlHeight: boolean;
  50980. /**
  50981. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  50982. */
  50983. axisYControlRotation: boolean;
  50984. /**
  50985. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  50986. */
  50987. axisPinchControlRadius: boolean;
  50988. /**
  50989. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  50990. */
  50991. axisPinchControlHeight: boolean;
  50992. /**
  50993. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  50994. */
  50995. axisPinchControlRotation: boolean;
  50996. /**
  50997. * Log error messages if basic misconfiguration has occurred.
  50998. */
  50999. warningEnable: boolean;
  51000. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  51001. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  51002. private _warningCounter;
  51003. private _warning;
  51004. }
  51005. }
  51006. declare module BABYLON {
  51007. /**
  51008. * Default Inputs manager for the FollowCamera.
  51009. * It groups all the default supported inputs for ease of use.
  51010. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51011. */
  51012. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  51013. /**
  51014. * Instantiates a new FollowCameraInputsManager.
  51015. * @param camera Defines the camera the inputs belong to
  51016. */
  51017. constructor(camera: FollowCamera);
  51018. /**
  51019. * Add keyboard input support to the input manager.
  51020. * @returns the current input manager
  51021. */
  51022. addKeyboard(): FollowCameraInputsManager;
  51023. /**
  51024. * Add mouse wheel input support to the input manager.
  51025. * @returns the current input manager
  51026. */
  51027. addMouseWheel(): FollowCameraInputsManager;
  51028. /**
  51029. * Add pointers input support to the input manager.
  51030. * @returns the current input manager
  51031. */
  51032. addPointers(): FollowCameraInputsManager;
  51033. /**
  51034. * Add orientation input support to the input manager.
  51035. * @returns the current input manager
  51036. */
  51037. addVRDeviceOrientation(): FollowCameraInputsManager;
  51038. }
  51039. }
  51040. declare module BABYLON {
  51041. /**
  51042. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  51043. * an arc rotate version arcFollowCamera are available.
  51044. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51045. */
  51046. export class FollowCamera extends TargetCamera {
  51047. /**
  51048. * Distance the follow camera should follow an object at
  51049. */
  51050. radius: number;
  51051. /**
  51052. * Minimum allowed distance of the camera to the axis of rotation
  51053. * (The camera can not get closer).
  51054. * This can help limiting how the Camera is able to move in the scene.
  51055. */
  51056. lowerRadiusLimit: Nullable<number>;
  51057. /**
  51058. * Maximum allowed distance of the camera to the axis of rotation
  51059. * (The camera can not get further).
  51060. * This can help limiting how the Camera is able to move in the scene.
  51061. */
  51062. upperRadiusLimit: Nullable<number>;
  51063. /**
  51064. * Define a rotation offset between the camera and the object it follows
  51065. */
  51066. rotationOffset: number;
  51067. /**
  51068. * Minimum allowed angle to camera position relative to target object.
  51069. * This can help limiting how the Camera is able to move in the scene.
  51070. */
  51071. lowerRotationOffsetLimit: Nullable<number>;
  51072. /**
  51073. * Maximum allowed angle to camera position relative to target object.
  51074. * This can help limiting how the Camera is able to move in the scene.
  51075. */
  51076. upperRotationOffsetLimit: Nullable<number>;
  51077. /**
  51078. * Define a height offset between the camera and the object it follows.
  51079. * It can help following an object from the top (like a car chaing a plane)
  51080. */
  51081. heightOffset: number;
  51082. /**
  51083. * Minimum allowed height of camera position relative to target object.
  51084. * This can help limiting how the Camera is able to move in the scene.
  51085. */
  51086. lowerHeightOffsetLimit: Nullable<number>;
  51087. /**
  51088. * Maximum allowed height of camera position relative to target object.
  51089. * This can help limiting how the Camera is able to move in the scene.
  51090. */
  51091. upperHeightOffsetLimit: Nullable<number>;
  51092. /**
  51093. * Define how fast the camera can accelerate to follow it s target.
  51094. */
  51095. cameraAcceleration: number;
  51096. /**
  51097. * Define the speed limit of the camera following an object.
  51098. */
  51099. maxCameraSpeed: number;
  51100. /**
  51101. * Define the target of the camera.
  51102. */
  51103. lockedTarget: Nullable<AbstractMesh>;
  51104. /**
  51105. * Defines the input associated with the camera.
  51106. */
  51107. inputs: FollowCameraInputsManager;
  51108. /**
  51109. * Instantiates the follow camera.
  51110. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51111. * @param name Define the name of the camera in the scene
  51112. * @param position Define the position of the camera
  51113. * @param scene Define the scene the camera belong to
  51114. * @param lockedTarget Define the target of the camera
  51115. */
  51116. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  51117. private _follow;
  51118. /**
  51119. * Attach the input controls to a specific dom element to get the input from.
  51120. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51121. */
  51122. attachControl(noPreventDefault?: boolean): void;
  51123. /**
  51124. * Detach the current controls from the specified dom element.
  51125. */
  51126. detachControl(): void;
  51127. /** @hidden */
  51128. _checkInputs(): void;
  51129. private _checkLimits;
  51130. /**
  51131. * Gets the camera class name.
  51132. * @returns the class name
  51133. */
  51134. getClassName(): string;
  51135. }
  51136. /**
  51137. * Arc Rotate version of the follow camera.
  51138. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  51139. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51140. */
  51141. export class ArcFollowCamera extends TargetCamera {
  51142. /** The longitudinal angle of the camera */
  51143. alpha: number;
  51144. /** The latitudinal angle of the camera */
  51145. beta: number;
  51146. /** The radius of the camera from its target */
  51147. radius: number;
  51148. private _cartesianCoordinates;
  51149. /** Define the camera target (the mesh it should follow) */
  51150. private _meshTarget;
  51151. /**
  51152. * Instantiates a new ArcFollowCamera
  51153. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51154. * @param name Define the name of the camera
  51155. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  51156. * @param beta Define the rotation angle of the camera around the elevation axis
  51157. * @param radius Define the radius of the camera from its target point
  51158. * @param target Define the target of the camera
  51159. * @param scene Define the scene the camera belongs to
  51160. */
  51161. constructor(name: string,
  51162. /** The longitudinal angle of the camera */
  51163. alpha: number,
  51164. /** The latitudinal angle of the camera */
  51165. beta: number,
  51166. /** The radius of the camera from its target */
  51167. radius: number,
  51168. /** Define the camera target (the mesh it should follow) */
  51169. target: Nullable<AbstractMesh>, scene: Scene);
  51170. private _follow;
  51171. /** @hidden */
  51172. _checkInputs(): void;
  51173. /**
  51174. * Returns the class name of the object.
  51175. * It is mostly used internally for serialization purposes.
  51176. */
  51177. getClassName(): string;
  51178. }
  51179. }
  51180. declare module BABYLON {
  51181. /**
  51182. * Manage the keyboard inputs to control the movement of a follow camera.
  51183. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51184. */
  51185. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  51186. /**
  51187. * Defines the camera the input is attached to.
  51188. */
  51189. camera: FollowCamera;
  51190. /**
  51191. * Defines the list of key codes associated with the up action (increase heightOffset)
  51192. */
  51193. keysHeightOffsetIncr: number[];
  51194. /**
  51195. * Defines the list of key codes associated with the down action (decrease heightOffset)
  51196. */
  51197. keysHeightOffsetDecr: number[];
  51198. /**
  51199. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  51200. */
  51201. keysHeightOffsetModifierAlt: boolean;
  51202. /**
  51203. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  51204. */
  51205. keysHeightOffsetModifierCtrl: boolean;
  51206. /**
  51207. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  51208. */
  51209. keysHeightOffsetModifierShift: boolean;
  51210. /**
  51211. * Defines the list of key codes associated with the left action (increase rotationOffset)
  51212. */
  51213. keysRotationOffsetIncr: number[];
  51214. /**
  51215. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  51216. */
  51217. keysRotationOffsetDecr: number[];
  51218. /**
  51219. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  51220. */
  51221. keysRotationOffsetModifierAlt: boolean;
  51222. /**
  51223. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  51224. */
  51225. keysRotationOffsetModifierCtrl: boolean;
  51226. /**
  51227. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  51228. */
  51229. keysRotationOffsetModifierShift: boolean;
  51230. /**
  51231. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  51232. */
  51233. keysRadiusIncr: number[];
  51234. /**
  51235. * Defines the list of key codes associated with the zoom-out action (increase radius)
  51236. */
  51237. keysRadiusDecr: number[];
  51238. /**
  51239. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  51240. */
  51241. keysRadiusModifierAlt: boolean;
  51242. /**
  51243. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  51244. */
  51245. keysRadiusModifierCtrl: boolean;
  51246. /**
  51247. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  51248. */
  51249. keysRadiusModifierShift: boolean;
  51250. /**
  51251. * Defines the rate of change of heightOffset.
  51252. */
  51253. heightSensibility: number;
  51254. /**
  51255. * Defines the rate of change of rotationOffset.
  51256. */
  51257. rotationSensibility: number;
  51258. /**
  51259. * Defines the rate of change of radius.
  51260. */
  51261. radiusSensibility: number;
  51262. private _keys;
  51263. private _ctrlPressed;
  51264. private _altPressed;
  51265. private _shiftPressed;
  51266. private _onCanvasBlurObserver;
  51267. private _onKeyboardObserver;
  51268. private _engine;
  51269. private _scene;
  51270. /**
  51271. * Attach the input controls to a specific dom element to get the input from.
  51272. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51273. */
  51274. attachControl(noPreventDefault?: boolean): void;
  51275. /**
  51276. * Detach the current controls from the specified dom element.
  51277. */
  51278. detachControl(): void;
  51279. /**
  51280. * Update the current camera state depending on the inputs that have been used this frame.
  51281. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51282. */
  51283. checkInputs(): void;
  51284. /**
  51285. * Gets the class name of the current input.
  51286. * @returns the class name
  51287. */
  51288. getClassName(): string;
  51289. /**
  51290. * Get the friendly name associated with the input class.
  51291. * @returns the input friendly name
  51292. */
  51293. getSimpleName(): string;
  51294. /**
  51295. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51296. * allow modification of the heightOffset value.
  51297. */
  51298. private _modifierHeightOffset;
  51299. /**
  51300. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51301. * allow modification of the rotationOffset value.
  51302. */
  51303. private _modifierRotationOffset;
  51304. /**
  51305. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51306. * allow modification of the radius value.
  51307. */
  51308. private _modifierRadius;
  51309. }
  51310. }
  51311. declare module BABYLON {
  51312. interface FreeCameraInputsManager {
  51313. /**
  51314. * @hidden
  51315. */
  51316. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  51317. /**
  51318. * Add orientation input support to the input manager.
  51319. * @returns the current input manager
  51320. */
  51321. addDeviceOrientation(): FreeCameraInputsManager;
  51322. }
  51323. /**
  51324. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  51325. * Screen rotation is taken into account.
  51326. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51327. */
  51328. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  51329. private _camera;
  51330. private _screenOrientationAngle;
  51331. private _constantTranform;
  51332. private _screenQuaternion;
  51333. private _alpha;
  51334. private _beta;
  51335. private _gamma;
  51336. /**
  51337. * Can be used to detect if a device orientation sensor is available on a device
  51338. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  51339. * @returns a promise that will resolve on orientation change
  51340. */
  51341. static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
  51342. /**
  51343. * @hidden
  51344. */
  51345. _onDeviceOrientationChangedObservable: Observable<void>;
  51346. /**
  51347. * Instantiates a new input
  51348. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51349. */
  51350. constructor();
  51351. /**
  51352. * Define the camera controlled by the input.
  51353. */
  51354. get camera(): FreeCamera;
  51355. set camera(camera: FreeCamera);
  51356. /**
  51357. * Attach the input controls to a specific dom element to get the input from.
  51358. */
  51359. attachControl(): void;
  51360. private _orientationChanged;
  51361. private _deviceOrientation;
  51362. /**
  51363. * Detach the current controls from the specified dom element.
  51364. */
  51365. detachControl(): void;
  51366. /**
  51367. * Update the current camera state depending on the inputs that have been used this frame.
  51368. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51369. */
  51370. checkInputs(): void;
  51371. /**
  51372. * Gets the class name of the current intput.
  51373. * @returns the class name
  51374. */
  51375. getClassName(): string;
  51376. /**
  51377. * Get the friendly name associated with the input class.
  51378. * @returns the input friendly name
  51379. */
  51380. getSimpleName(): string;
  51381. }
  51382. }
  51383. declare module BABYLON {
  51384. /**
  51385. * Manage the gamepad inputs to control a free camera.
  51386. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51387. */
  51388. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  51389. /**
  51390. * Define the camera the input is attached to.
  51391. */
  51392. camera: FreeCamera;
  51393. /**
  51394. * Define the Gamepad controlling the input
  51395. */
  51396. gamepad: Nullable<Gamepad>;
  51397. /**
  51398. * Defines the gamepad rotation sensiblity.
  51399. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  51400. */
  51401. gamepadAngularSensibility: number;
  51402. /**
  51403. * Defines the gamepad move sensiblity.
  51404. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  51405. */
  51406. gamepadMoveSensibility: number;
  51407. private _yAxisScale;
  51408. /**
  51409. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  51410. */
  51411. get invertYAxis(): boolean;
  51412. set invertYAxis(value: boolean);
  51413. private _onGamepadConnectedObserver;
  51414. private _onGamepadDisconnectedObserver;
  51415. private _cameraTransform;
  51416. private _deltaTransform;
  51417. private _vector3;
  51418. private _vector2;
  51419. /**
  51420. * Attach the input controls to a specific dom element to get the input from.
  51421. */
  51422. attachControl(): void;
  51423. /**
  51424. * Detach the current controls from the specified dom element.
  51425. */
  51426. detachControl(): void;
  51427. /**
  51428. * Update the current camera state depending on the inputs that have been used this frame.
  51429. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51430. */
  51431. checkInputs(): void;
  51432. /**
  51433. * Gets the class name of the current intput.
  51434. * @returns the class name
  51435. */
  51436. getClassName(): string;
  51437. /**
  51438. * Get the friendly name associated with the input class.
  51439. * @returns the input friendly name
  51440. */
  51441. getSimpleName(): string;
  51442. }
  51443. }
  51444. declare module BABYLON {
  51445. /**
  51446. * Defines the potential axis of a Joystick
  51447. */
  51448. export enum JoystickAxis {
  51449. /** X axis */
  51450. X = 0,
  51451. /** Y axis */
  51452. Y = 1,
  51453. /** Z axis */
  51454. Z = 2
  51455. }
  51456. /**
  51457. * Represents the different customization options available
  51458. * for VirtualJoystick
  51459. */
  51460. interface VirtualJoystickCustomizations {
  51461. /**
  51462. * Size of the joystick's puck
  51463. */
  51464. puckSize: number;
  51465. /**
  51466. * Size of the joystick's container
  51467. */
  51468. containerSize: number;
  51469. /**
  51470. * Color of the joystick && puck
  51471. */
  51472. color: string;
  51473. /**
  51474. * Image URL for the joystick's puck
  51475. */
  51476. puckImage?: string;
  51477. /**
  51478. * Image URL for the joystick's container
  51479. */
  51480. containerImage?: string;
  51481. /**
  51482. * Defines the unmoving position of the joystick container
  51483. */
  51484. position?: {
  51485. x: number;
  51486. y: number;
  51487. };
  51488. /**
  51489. * Defines whether or not the joystick container is always visible
  51490. */
  51491. alwaysVisible: boolean;
  51492. /**
  51493. * Defines whether or not to limit the movement of the puck to the joystick's container
  51494. */
  51495. limitToContainer: boolean;
  51496. }
  51497. /**
  51498. * Class used to define virtual joystick (used in touch mode)
  51499. */
  51500. export class VirtualJoystick {
  51501. /**
  51502. * Gets or sets a boolean indicating that left and right values must be inverted
  51503. */
  51504. reverseLeftRight: boolean;
  51505. /**
  51506. * Gets or sets a boolean indicating that up and down values must be inverted
  51507. */
  51508. reverseUpDown: boolean;
  51509. /**
  51510. * Gets the offset value for the position (ie. the change of the position value)
  51511. */
  51512. deltaPosition: Vector3;
  51513. /**
  51514. * Gets a boolean indicating if the virtual joystick was pressed
  51515. */
  51516. pressed: boolean;
  51517. /**
  51518. * Canvas the virtual joystick will render onto, default z-index of this is 5
  51519. */
  51520. static Canvas: Nullable<HTMLCanvasElement>;
  51521. /**
  51522. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  51523. */
  51524. limitToContainer: boolean;
  51525. private static _globalJoystickIndex;
  51526. private static _alwaysVisibleSticks;
  51527. private static vjCanvasContext;
  51528. private static vjCanvasWidth;
  51529. private static vjCanvasHeight;
  51530. private static halfWidth;
  51531. private static _GetDefaultOptions;
  51532. private _action;
  51533. private _axisTargetedByLeftAndRight;
  51534. private _axisTargetedByUpAndDown;
  51535. private _joystickSensibility;
  51536. private _inversedSensibility;
  51537. private _joystickPointerID;
  51538. private _joystickColor;
  51539. private _joystickPointerPos;
  51540. private _joystickPreviousPointerPos;
  51541. private _joystickPointerStartPos;
  51542. private _deltaJoystickVector;
  51543. private _leftJoystick;
  51544. private _touches;
  51545. private _joystickPosition;
  51546. private _alwaysVisible;
  51547. private _puckImage;
  51548. private _containerImage;
  51549. private _joystickPuckSize;
  51550. private _joystickContainerSize;
  51551. private _clearPuckSize;
  51552. private _clearContainerSize;
  51553. private _clearPuckSizeOffset;
  51554. private _clearContainerSizeOffset;
  51555. private _onPointerDownHandlerRef;
  51556. private _onPointerMoveHandlerRef;
  51557. private _onPointerUpHandlerRef;
  51558. private _onResize;
  51559. /**
  51560. * Creates a new virtual joystick
  51561. * @param leftJoystick defines that the joystick is for left hand (false by default)
  51562. * @param customizations Defines the options we want to customize the VirtualJoystick
  51563. */
  51564. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  51565. /**
  51566. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  51567. * @param newJoystickSensibility defines the new sensibility
  51568. */
  51569. setJoystickSensibility(newJoystickSensibility: number): void;
  51570. private _onPointerDown;
  51571. private _onPointerMove;
  51572. private _onPointerUp;
  51573. /**
  51574. * Change the color of the virtual joystick
  51575. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  51576. */
  51577. setJoystickColor(newColor: string): void;
  51578. /**
  51579. * Size of the joystick's container
  51580. */
  51581. set containerSize(newSize: number);
  51582. get containerSize(): number;
  51583. /**
  51584. * Size of the joystick's puck
  51585. */
  51586. set puckSize(newSize: number);
  51587. get puckSize(): number;
  51588. /**
  51589. * Clears the set position of the joystick
  51590. */
  51591. clearPosition(): void;
  51592. /**
  51593. * Defines whether or not the joystick container is always visible
  51594. */
  51595. set alwaysVisible(value: boolean);
  51596. get alwaysVisible(): boolean;
  51597. /**
  51598. * Sets the constant position of the Joystick container
  51599. * @param x X axis coordinate
  51600. * @param y Y axis coordinate
  51601. */
  51602. setPosition(x: number, y: number): void;
  51603. /**
  51604. * Defines a callback to call when the joystick is touched
  51605. * @param action defines the callback
  51606. */
  51607. setActionOnTouch(action: () => any): void;
  51608. /**
  51609. * Defines which axis you'd like to control for left & right
  51610. * @param axis defines the axis to use
  51611. */
  51612. setAxisForLeftRight(axis: JoystickAxis): void;
  51613. /**
  51614. * Defines which axis you'd like to control for up & down
  51615. * @param axis defines the axis to use
  51616. */
  51617. setAxisForUpDown(axis: JoystickAxis): void;
  51618. /**
  51619. * Clears the canvas from the previous puck / container draw
  51620. */
  51621. private _clearPreviousDraw;
  51622. /**
  51623. * Loads `urlPath` to be used for the container's image
  51624. * @param urlPath defines the urlPath of an image to use
  51625. */
  51626. setContainerImage(urlPath: string): void;
  51627. /**
  51628. * Loads `urlPath` to be used for the puck's image
  51629. * @param urlPath defines the urlPath of an image to use
  51630. */
  51631. setPuckImage(urlPath: string): void;
  51632. /**
  51633. * Draws the Virtual Joystick's container
  51634. */
  51635. private _drawContainer;
  51636. /**
  51637. * Draws the Virtual Joystick's puck
  51638. */
  51639. private _drawPuck;
  51640. private _drawVirtualJoystick;
  51641. /**
  51642. * Release internal HTML canvas
  51643. */
  51644. releaseCanvas(): void;
  51645. }
  51646. }
  51647. declare module BABYLON {
  51648. interface FreeCameraInputsManager {
  51649. /**
  51650. * Add virtual joystick input support to the input manager.
  51651. * @returns the current input manager
  51652. */
  51653. addVirtualJoystick(): FreeCameraInputsManager;
  51654. }
  51655. /**
  51656. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  51657. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51658. */
  51659. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  51660. /**
  51661. * Defines the camera the input is attached to.
  51662. */
  51663. camera: FreeCamera;
  51664. private _leftjoystick;
  51665. private _rightjoystick;
  51666. /**
  51667. * Gets the left stick of the virtual joystick.
  51668. * @returns The virtual Joystick
  51669. */
  51670. getLeftJoystick(): VirtualJoystick;
  51671. /**
  51672. * Gets the right stick of the virtual joystick.
  51673. * @returns The virtual Joystick
  51674. */
  51675. getRightJoystick(): VirtualJoystick;
  51676. /**
  51677. * Update the current camera state depending on the inputs that have been used this frame.
  51678. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51679. */
  51680. checkInputs(): void;
  51681. /**
  51682. * Attach the input controls to a specific dom element to get the input from.
  51683. */
  51684. attachControl(): void;
  51685. /**
  51686. * Detach the current controls from the specified dom element.
  51687. */
  51688. detachControl(): void;
  51689. /**
  51690. * Gets the class name of the current intput.
  51691. * @returns the class name
  51692. */
  51693. getClassName(): string;
  51694. /**
  51695. * Get the friendly name associated with the input class.
  51696. * @returns the input friendly name
  51697. */
  51698. getSimpleName(): string;
  51699. }
  51700. }
  51701. declare module BABYLON {
  51702. /**
  51703. * This represents a FPS type of camera controlled by touch.
  51704. * This is like a universal camera minus the Gamepad controls.
  51705. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51706. */
  51707. export class TouchCamera extends FreeCamera {
  51708. /**
  51709. * Defines the touch sensibility for rotation.
  51710. * The higher the faster.
  51711. */
  51712. get touchAngularSensibility(): number;
  51713. set touchAngularSensibility(value: number);
  51714. /**
  51715. * Defines the touch sensibility for move.
  51716. * The higher the faster.
  51717. */
  51718. get touchMoveSensibility(): number;
  51719. set touchMoveSensibility(value: number);
  51720. /**
  51721. * Instantiates a new touch camera.
  51722. * This represents a FPS type of camera controlled by touch.
  51723. * This is like a universal camera minus the Gamepad controls.
  51724. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51725. * @param name Define the name of the camera in the scene
  51726. * @param position Define the start position of the camera in the scene
  51727. * @param scene Define the scene the camera belongs to
  51728. */
  51729. constructor(name: string, position: Vector3, scene: Scene);
  51730. /**
  51731. * Gets the current object class name.
  51732. * @return the class name
  51733. */
  51734. getClassName(): string;
  51735. /** @hidden */
  51736. _setupInputs(): void;
  51737. }
  51738. }
  51739. declare module BABYLON {
  51740. /**
  51741. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  51742. * being tilted forward or back and left or right.
  51743. */
  51744. export class DeviceOrientationCamera extends FreeCamera {
  51745. private _initialQuaternion;
  51746. private _quaternionCache;
  51747. private _tmpDragQuaternion;
  51748. private _disablePointerInputWhenUsingDeviceOrientation;
  51749. /**
  51750. * Creates a new device orientation camera
  51751. * @param name The name of the camera
  51752. * @param position The start position camera
  51753. * @param scene The scene the camera belongs to
  51754. */
  51755. constructor(name: string, position: Vector3, scene: Scene);
  51756. /**
  51757. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  51758. */
  51759. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  51760. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  51761. private _dragFactor;
  51762. /**
  51763. * Enabled turning on the y axis when the orientation sensor is active
  51764. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  51765. */
  51766. enableHorizontalDragging(dragFactor?: number): void;
  51767. /**
  51768. * Gets the current instance class name ("DeviceOrientationCamera").
  51769. * This helps avoiding instanceof at run time.
  51770. * @returns the class name
  51771. */
  51772. getClassName(): string;
  51773. /**
  51774. * @hidden
  51775. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  51776. */
  51777. _checkInputs(): void;
  51778. /**
  51779. * Reset the camera to its default orientation on the specified axis only.
  51780. * @param axis The axis to reset
  51781. */
  51782. resetToCurrentRotation(axis?: Axis): void;
  51783. }
  51784. }
  51785. declare module BABYLON {
  51786. /**
  51787. * Defines supported buttons for XBox360 compatible gamepads
  51788. */
  51789. export enum Xbox360Button {
  51790. /** A */
  51791. A = 0,
  51792. /** B */
  51793. B = 1,
  51794. /** X */
  51795. X = 2,
  51796. /** Y */
  51797. Y = 3,
  51798. /** Left button */
  51799. LB = 4,
  51800. /** Right button */
  51801. RB = 5,
  51802. /** Back */
  51803. Back = 8,
  51804. /** Start */
  51805. Start = 9,
  51806. /** Left stick */
  51807. LeftStick = 10,
  51808. /** Right stick */
  51809. RightStick = 11
  51810. }
  51811. /** Defines values for XBox360 DPad */
  51812. export enum Xbox360Dpad {
  51813. /** Up */
  51814. Up = 12,
  51815. /** Down */
  51816. Down = 13,
  51817. /** Left */
  51818. Left = 14,
  51819. /** Right */
  51820. Right = 15
  51821. }
  51822. /**
  51823. * Defines a XBox360 gamepad
  51824. */
  51825. export class Xbox360Pad extends Gamepad {
  51826. private _leftTrigger;
  51827. private _rightTrigger;
  51828. private _onlefttriggerchanged;
  51829. private _onrighttriggerchanged;
  51830. private _onbuttondown;
  51831. private _onbuttonup;
  51832. private _ondpaddown;
  51833. private _ondpadup;
  51834. /** Observable raised when a button is pressed */
  51835. onButtonDownObservable: Observable<Xbox360Button>;
  51836. /** Observable raised when a button is released */
  51837. onButtonUpObservable: Observable<Xbox360Button>;
  51838. /** Observable raised when a pad is pressed */
  51839. onPadDownObservable: Observable<Xbox360Dpad>;
  51840. /** Observable raised when a pad is released */
  51841. onPadUpObservable: Observable<Xbox360Dpad>;
  51842. private _buttonA;
  51843. private _buttonB;
  51844. private _buttonX;
  51845. private _buttonY;
  51846. private _buttonBack;
  51847. private _buttonStart;
  51848. private _buttonLB;
  51849. private _buttonRB;
  51850. private _buttonLeftStick;
  51851. private _buttonRightStick;
  51852. private _dPadUp;
  51853. private _dPadDown;
  51854. private _dPadLeft;
  51855. private _dPadRight;
  51856. private _isXboxOnePad;
  51857. /**
  51858. * Creates a new XBox360 gamepad object
  51859. * @param id defines the id of this gamepad
  51860. * @param index defines its index
  51861. * @param gamepad defines the internal HTML gamepad object
  51862. * @param xboxOne defines if it is a XBox One gamepad
  51863. */
  51864. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  51865. /**
  51866. * Defines the callback to call when left trigger is pressed
  51867. * @param callback defines the callback to use
  51868. */
  51869. onlefttriggerchanged(callback: (value: number) => void): void;
  51870. /**
  51871. * Defines the callback to call when right trigger is pressed
  51872. * @param callback defines the callback to use
  51873. */
  51874. onrighttriggerchanged(callback: (value: number) => void): void;
  51875. /**
  51876. * Gets the left trigger value
  51877. */
  51878. get leftTrigger(): number;
  51879. /**
  51880. * Sets the left trigger value
  51881. */
  51882. set leftTrigger(newValue: number);
  51883. /**
  51884. * Gets the right trigger value
  51885. */
  51886. get rightTrigger(): number;
  51887. /**
  51888. * Sets the right trigger value
  51889. */
  51890. set rightTrigger(newValue: number);
  51891. /**
  51892. * Defines the callback to call when a button is pressed
  51893. * @param callback defines the callback to use
  51894. */
  51895. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  51896. /**
  51897. * Defines the callback to call when a button is released
  51898. * @param callback defines the callback to use
  51899. */
  51900. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  51901. /**
  51902. * Defines the callback to call when a pad is pressed
  51903. * @param callback defines the callback to use
  51904. */
  51905. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  51906. /**
  51907. * Defines the callback to call when a pad is released
  51908. * @param callback defines the callback to use
  51909. */
  51910. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  51911. private _setButtonValue;
  51912. private _setDPadValue;
  51913. /**
  51914. * Gets the value of the `A` button
  51915. */
  51916. get buttonA(): number;
  51917. /**
  51918. * Sets the value of the `A` button
  51919. */
  51920. set buttonA(value: number);
  51921. /**
  51922. * Gets the value of the `B` button
  51923. */
  51924. get buttonB(): number;
  51925. /**
  51926. * Sets the value of the `B` button
  51927. */
  51928. set buttonB(value: number);
  51929. /**
  51930. * Gets the value of the `X` button
  51931. */
  51932. get buttonX(): number;
  51933. /**
  51934. * Sets the value of the `X` button
  51935. */
  51936. set buttonX(value: number);
  51937. /**
  51938. * Gets the value of the `Y` button
  51939. */
  51940. get buttonY(): number;
  51941. /**
  51942. * Sets the value of the `Y` button
  51943. */
  51944. set buttonY(value: number);
  51945. /**
  51946. * Gets the value of the `Start` button
  51947. */
  51948. get buttonStart(): number;
  51949. /**
  51950. * Sets the value of the `Start` button
  51951. */
  51952. set buttonStart(value: number);
  51953. /**
  51954. * Gets the value of the `Back` button
  51955. */
  51956. get buttonBack(): number;
  51957. /**
  51958. * Sets the value of the `Back` button
  51959. */
  51960. set buttonBack(value: number);
  51961. /**
  51962. * Gets the value of the `Left` button
  51963. */
  51964. get buttonLB(): number;
  51965. /**
  51966. * Sets the value of the `Left` button
  51967. */
  51968. set buttonLB(value: number);
  51969. /**
  51970. * Gets the value of the `Right` button
  51971. */
  51972. get buttonRB(): number;
  51973. /**
  51974. * Sets the value of the `Right` button
  51975. */
  51976. set buttonRB(value: number);
  51977. /**
  51978. * Gets the value of the Left joystick
  51979. */
  51980. get buttonLeftStick(): number;
  51981. /**
  51982. * Sets the value of the Left joystick
  51983. */
  51984. set buttonLeftStick(value: number);
  51985. /**
  51986. * Gets the value of the Right joystick
  51987. */
  51988. get buttonRightStick(): number;
  51989. /**
  51990. * Sets the value of the Right joystick
  51991. */
  51992. set buttonRightStick(value: number);
  51993. /**
  51994. * Gets the value of D-pad up
  51995. */
  51996. get dPadUp(): number;
  51997. /**
  51998. * Sets the value of D-pad up
  51999. */
  52000. set dPadUp(value: number);
  52001. /**
  52002. * Gets the value of D-pad down
  52003. */
  52004. get dPadDown(): number;
  52005. /**
  52006. * Sets the value of D-pad down
  52007. */
  52008. set dPadDown(value: number);
  52009. /**
  52010. * Gets the value of D-pad left
  52011. */
  52012. get dPadLeft(): number;
  52013. /**
  52014. * Sets the value of D-pad left
  52015. */
  52016. set dPadLeft(value: number);
  52017. /**
  52018. * Gets the value of D-pad right
  52019. */
  52020. get dPadRight(): number;
  52021. /**
  52022. * Sets the value of D-pad right
  52023. */
  52024. set dPadRight(value: number);
  52025. /**
  52026. * Force the gamepad to synchronize with device values
  52027. */
  52028. update(): void;
  52029. /**
  52030. * Disposes the gamepad
  52031. */
  52032. dispose(): void;
  52033. }
  52034. }
  52035. declare module BABYLON {
  52036. /**
  52037. * Defines supported buttons for DualShock compatible gamepads
  52038. */
  52039. export enum DualShockButton {
  52040. /** Cross */
  52041. Cross = 0,
  52042. /** Circle */
  52043. Circle = 1,
  52044. /** Square */
  52045. Square = 2,
  52046. /** Triangle */
  52047. Triangle = 3,
  52048. /** L1 */
  52049. L1 = 4,
  52050. /** R1 */
  52051. R1 = 5,
  52052. /** Share */
  52053. Share = 8,
  52054. /** Options */
  52055. Options = 9,
  52056. /** Left stick */
  52057. LeftStick = 10,
  52058. /** Right stick */
  52059. RightStick = 11
  52060. }
  52061. /** Defines values for DualShock DPad */
  52062. export enum DualShockDpad {
  52063. /** Up */
  52064. Up = 12,
  52065. /** Down */
  52066. Down = 13,
  52067. /** Left */
  52068. Left = 14,
  52069. /** Right */
  52070. Right = 15
  52071. }
  52072. /**
  52073. * Defines a DualShock gamepad
  52074. */
  52075. export class DualShockPad extends Gamepad {
  52076. private _leftTrigger;
  52077. private _rightTrigger;
  52078. private _onlefttriggerchanged;
  52079. private _onrighttriggerchanged;
  52080. private _onbuttondown;
  52081. private _onbuttonup;
  52082. private _ondpaddown;
  52083. private _ondpadup;
  52084. /** Observable raised when a button is pressed */
  52085. onButtonDownObservable: Observable<DualShockButton>;
  52086. /** Observable raised when a button is released */
  52087. onButtonUpObservable: Observable<DualShockButton>;
  52088. /** Observable raised when a pad is pressed */
  52089. onPadDownObservable: Observable<DualShockDpad>;
  52090. /** Observable raised when a pad is released */
  52091. onPadUpObservable: Observable<DualShockDpad>;
  52092. private _buttonCross;
  52093. private _buttonCircle;
  52094. private _buttonSquare;
  52095. private _buttonTriangle;
  52096. private _buttonShare;
  52097. private _buttonOptions;
  52098. private _buttonL1;
  52099. private _buttonR1;
  52100. private _buttonLeftStick;
  52101. private _buttonRightStick;
  52102. private _dPadUp;
  52103. private _dPadDown;
  52104. private _dPadLeft;
  52105. private _dPadRight;
  52106. /**
  52107. * Creates a new DualShock gamepad object
  52108. * @param id defines the id of this gamepad
  52109. * @param index defines its index
  52110. * @param gamepad defines the internal HTML gamepad object
  52111. */
  52112. constructor(id: string, index: number, gamepad: any);
  52113. /**
  52114. * Defines the callback to call when left trigger is pressed
  52115. * @param callback defines the callback to use
  52116. */
  52117. onlefttriggerchanged(callback: (value: number) => void): void;
  52118. /**
  52119. * Defines the callback to call when right trigger is pressed
  52120. * @param callback defines the callback to use
  52121. */
  52122. onrighttriggerchanged(callback: (value: number) => void): void;
  52123. /**
  52124. * Gets the left trigger value
  52125. */
  52126. get leftTrigger(): number;
  52127. /**
  52128. * Sets the left trigger value
  52129. */
  52130. set leftTrigger(newValue: number);
  52131. /**
  52132. * Gets the right trigger value
  52133. */
  52134. get rightTrigger(): number;
  52135. /**
  52136. * Sets the right trigger value
  52137. */
  52138. set rightTrigger(newValue: number);
  52139. /**
  52140. * Defines the callback to call when a button is pressed
  52141. * @param callback defines the callback to use
  52142. */
  52143. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  52144. /**
  52145. * Defines the callback to call when a button is released
  52146. * @param callback defines the callback to use
  52147. */
  52148. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  52149. /**
  52150. * Defines the callback to call when a pad is pressed
  52151. * @param callback defines the callback to use
  52152. */
  52153. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  52154. /**
  52155. * Defines the callback to call when a pad is released
  52156. * @param callback defines the callback to use
  52157. */
  52158. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  52159. private _setButtonValue;
  52160. private _setDPadValue;
  52161. /**
  52162. * Gets the value of the `Cross` button
  52163. */
  52164. get buttonCross(): number;
  52165. /**
  52166. * Sets the value of the `Cross` button
  52167. */
  52168. set buttonCross(value: number);
  52169. /**
  52170. * Gets the value of the `Circle` button
  52171. */
  52172. get buttonCircle(): number;
  52173. /**
  52174. * Sets the value of the `Circle` button
  52175. */
  52176. set buttonCircle(value: number);
  52177. /**
  52178. * Gets the value of the `Square` button
  52179. */
  52180. get buttonSquare(): number;
  52181. /**
  52182. * Sets the value of the `Square` button
  52183. */
  52184. set buttonSquare(value: number);
  52185. /**
  52186. * Gets the value of the `Triangle` button
  52187. */
  52188. get buttonTriangle(): number;
  52189. /**
  52190. * Sets the value of the `Triangle` button
  52191. */
  52192. set buttonTriangle(value: number);
  52193. /**
  52194. * Gets the value of the `Options` button
  52195. */
  52196. get buttonOptions(): number;
  52197. /**
  52198. * Sets the value of the `Options` button
  52199. */
  52200. set buttonOptions(value: number);
  52201. /**
  52202. * Gets the value of the `Share` button
  52203. */
  52204. get buttonShare(): number;
  52205. /**
  52206. * Sets the value of the `Share` button
  52207. */
  52208. set buttonShare(value: number);
  52209. /**
  52210. * Gets the value of the `L1` button
  52211. */
  52212. get buttonL1(): number;
  52213. /**
  52214. * Sets the value of the `L1` button
  52215. */
  52216. set buttonL1(value: number);
  52217. /**
  52218. * Gets the value of the `R1` button
  52219. */
  52220. get buttonR1(): number;
  52221. /**
  52222. * Sets the value of the `R1` button
  52223. */
  52224. set buttonR1(value: number);
  52225. /**
  52226. * Gets the value of the Left joystick
  52227. */
  52228. get buttonLeftStick(): number;
  52229. /**
  52230. * Sets the value of the Left joystick
  52231. */
  52232. set buttonLeftStick(value: number);
  52233. /**
  52234. * Gets the value of the Right joystick
  52235. */
  52236. get buttonRightStick(): number;
  52237. /**
  52238. * Sets the value of the Right joystick
  52239. */
  52240. set buttonRightStick(value: number);
  52241. /**
  52242. * Gets the value of D-pad up
  52243. */
  52244. get dPadUp(): number;
  52245. /**
  52246. * Sets the value of D-pad up
  52247. */
  52248. set dPadUp(value: number);
  52249. /**
  52250. * Gets the value of D-pad down
  52251. */
  52252. get dPadDown(): number;
  52253. /**
  52254. * Sets the value of D-pad down
  52255. */
  52256. set dPadDown(value: number);
  52257. /**
  52258. * Gets the value of D-pad left
  52259. */
  52260. get dPadLeft(): number;
  52261. /**
  52262. * Sets the value of D-pad left
  52263. */
  52264. set dPadLeft(value: number);
  52265. /**
  52266. * Gets the value of D-pad right
  52267. */
  52268. get dPadRight(): number;
  52269. /**
  52270. * Sets the value of D-pad right
  52271. */
  52272. set dPadRight(value: number);
  52273. /**
  52274. * Force the gamepad to synchronize with device values
  52275. */
  52276. update(): void;
  52277. /**
  52278. * Disposes the gamepad
  52279. */
  52280. dispose(): void;
  52281. }
  52282. }
  52283. declare module BABYLON {
  52284. /**
  52285. * Manager for handling gamepads
  52286. */
  52287. export class GamepadManager {
  52288. private _scene?;
  52289. private _babylonGamepads;
  52290. private _oneGamepadConnected;
  52291. /** @hidden */
  52292. _isMonitoring: boolean;
  52293. private _gamepadEventSupported;
  52294. private _gamepadSupport?;
  52295. /**
  52296. * observable to be triggered when the gamepad controller has been connected
  52297. */
  52298. onGamepadConnectedObservable: Observable<Gamepad>;
  52299. /**
  52300. * observable to be triggered when the gamepad controller has been disconnected
  52301. */
  52302. onGamepadDisconnectedObservable: Observable<Gamepad>;
  52303. private _onGamepadConnectedEvent;
  52304. private _onGamepadDisconnectedEvent;
  52305. /**
  52306. * Initializes the gamepad manager
  52307. * @param _scene BabylonJS scene
  52308. */
  52309. constructor(_scene?: Scene | undefined);
  52310. /**
  52311. * The gamepads in the game pad manager
  52312. */
  52313. get gamepads(): Gamepad[];
  52314. /**
  52315. * Get the gamepad controllers based on type
  52316. * @param type The type of gamepad controller
  52317. * @returns Nullable gamepad
  52318. */
  52319. getGamepadByType(type?: number): Nullable<Gamepad>;
  52320. /**
  52321. * Disposes the gamepad manager
  52322. */
  52323. dispose(): void;
  52324. private _addNewGamepad;
  52325. private _startMonitoringGamepads;
  52326. private _stopMonitoringGamepads;
  52327. /** @hidden */
  52328. _checkGamepadsStatus(): void;
  52329. private _updateGamepadObjects;
  52330. }
  52331. }
  52332. declare module BABYLON {
  52333. interface Scene {
  52334. /** @hidden */
  52335. _gamepadManager: Nullable<GamepadManager>;
  52336. /**
  52337. * Gets the gamepad manager associated with the scene
  52338. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  52339. */
  52340. gamepadManager: GamepadManager;
  52341. }
  52342. /**
  52343. * Interface representing a free camera inputs manager
  52344. */
  52345. interface FreeCameraInputsManager {
  52346. /**
  52347. * Adds gamepad input support to the FreeCameraInputsManager.
  52348. * @returns the FreeCameraInputsManager
  52349. */
  52350. addGamepad(): FreeCameraInputsManager;
  52351. }
  52352. /**
  52353. * Interface representing an arc rotate camera inputs manager
  52354. */
  52355. interface ArcRotateCameraInputsManager {
  52356. /**
  52357. * Adds gamepad input support to the ArcRotateCamera InputManager.
  52358. * @returns the camera inputs manager
  52359. */
  52360. addGamepad(): ArcRotateCameraInputsManager;
  52361. }
  52362. /**
  52363. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  52364. */
  52365. export class GamepadSystemSceneComponent implements ISceneComponent {
  52366. /**
  52367. * The component name helpfull to identify the component in the list of scene components.
  52368. */
  52369. readonly name: string;
  52370. /**
  52371. * The scene the component belongs to.
  52372. */
  52373. scene: Scene;
  52374. /**
  52375. * Creates a new instance of the component for the given scene
  52376. * @param scene Defines the scene to register the component in
  52377. */
  52378. constructor(scene: Scene);
  52379. /**
  52380. * Registers the component in a given scene
  52381. */
  52382. register(): void;
  52383. /**
  52384. * Rebuilds the elements related to this component in case of
  52385. * context lost for instance.
  52386. */
  52387. rebuild(): void;
  52388. /**
  52389. * Disposes the component and the associated ressources
  52390. */
  52391. dispose(): void;
  52392. private _beforeCameraUpdate;
  52393. }
  52394. }
  52395. declare module BABYLON {
  52396. /**
  52397. * 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,
  52398. * which still works and will still be found in many Playgrounds.
  52399. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52400. */
  52401. export class UniversalCamera extends TouchCamera {
  52402. /**
  52403. * Defines the gamepad rotation sensiblity.
  52404. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  52405. */
  52406. get gamepadAngularSensibility(): number;
  52407. set gamepadAngularSensibility(value: number);
  52408. /**
  52409. * Defines the gamepad move sensiblity.
  52410. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  52411. */
  52412. get gamepadMoveSensibility(): number;
  52413. set gamepadMoveSensibility(value: number);
  52414. /**
  52415. * 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,
  52416. * which still works and will still be found in many Playgrounds.
  52417. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52418. * @param name Define the name of the camera in the scene
  52419. * @param position Define the start position of the camera in the scene
  52420. * @param scene Define the scene the camera belongs to
  52421. */
  52422. constructor(name: string, position: Vector3, scene: Scene);
  52423. /**
  52424. * Gets the current object class name.
  52425. * @return the class name
  52426. */
  52427. getClassName(): string;
  52428. }
  52429. }
  52430. declare module BABYLON {
  52431. /**
  52432. * This represents a FPS type of camera. This is only here for back compat purpose.
  52433. * Please use the UniversalCamera instead as both are identical.
  52434. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52435. */
  52436. export class GamepadCamera extends UniversalCamera {
  52437. /**
  52438. * Instantiates a new Gamepad Camera
  52439. * This represents a FPS type of camera. This is only here for back compat purpose.
  52440. * Please use the UniversalCamera instead as both are identical.
  52441. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52442. * @param name Define the name of the camera in the scene
  52443. * @param position Define the start position of the camera in the scene
  52444. * @param scene Define the scene the camera belongs to
  52445. */
  52446. constructor(name: string, position: Vector3, scene: Scene);
  52447. /**
  52448. * Gets the current object class name.
  52449. * @return the class name
  52450. */
  52451. getClassName(): string;
  52452. }
  52453. }
  52454. declare module BABYLON {
  52455. /** @hidden */
  52456. export var anaglyphPixelShader: {
  52457. name: string;
  52458. shader: string;
  52459. };
  52460. }
  52461. declare module BABYLON {
  52462. /**
  52463. * Postprocess used to generate anaglyphic rendering
  52464. */
  52465. export class AnaglyphPostProcess extends PostProcess {
  52466. private _passedProcess;
  52467. /**
  52468. * Gets a string identifying the name of the class
  52469. * @returns "AnaglyphPostProcess" string
  52470. */
  52471. getClassName(): string;
  52472. /**
  52473. * Creates a new AnaglyphPostProcess
  52474. * @param name defines postprocess name
  52475. * @param options defines creation options or target ratio scale
  52476. * @param rigCameras defines cameras using this postprocess
  52477. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  52478. * @param engine defines hosting engine
  52479. * @param reusable defines if the postprocess will be reused multiple times per frame
  52480. */
  52481. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  52482. }
  52483. }
  52484. declare module BABYLON {
  52485. /**
  52486. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  52487. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52488. */
  52489. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  52490. /**
  52491. * Creates a new AnaglyphArcRotateCamera
  52492. * @param name defines camera name
  52493. * @param alpha defines alpha angle (in radians)
  52494. * @param beta defines beta angle (in radians)
  52495. * @param radius defines radius
  52496. * @param target defines camera target
  52497. * @param interaxialDistance defines distance between each color axis
  52498. * @param scene defines the hosting scene
  52499. */
  52500. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  52501. /**
  52502. * Gets camera class name
  52503. * @returns AnaglyphArcRotateCamera
  52504. */
  52505. getClassName(): string;
  52506. }
  52507. }
  52508. declare module BABYLON {
  52509. /**
  52510. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  52511. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52512. */
  52513. export class AnaglyphFreeCamera extends FreeCamera {
  52514. /**
  52515. * Creates a new AnaglyphFreeCamera
  52516. * @param name defines camera name
  52517. * @param position defines initial position
  52518. * @param interaxialDistance defines distance between each color axis
  52519. * @param scene defines the hosting scene
  52520. */
  52521. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  52522. /**
  52523. * Gets camera class name
  52524. * @returns AnaglyphFreeCamera
  52525. */
  52526. getClassName(): string;
  52527. }
  52528. }
  52529. declare module BABYLON {
  52530. /**
  52531. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  52532. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52533. */
  52534. export class AnaglyphGamepadCamera extends GamepadCamera {
  52535. /**
  52536. * Creates a new AnaglyphGamepadCamera
  52537. * @param name defines camera name
  52538. * @param position defines initial position
  52539. * @param interaxialDistance defines distance between each color axis
  52540. * @param scene defines the hosting scene
  52541. */
  52542. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  52543. /**
  52544. * Gets camera class name
  52545. * @returns AnaglyphGamepadCamera
  52546. */
  52547. getClassName(): string;
  52548. }
  52549. }
  52550. declare module BABYLON {
  52551. /**
  52552. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  52553. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52554. */
  52555. export class AnaglyphUniversalCamera extends UniversalCamera {
  52556. /**
  52557. * Creates a new AnaglyphUniversalCamera
  52558. * @param name defines camera name
  52559. * @param position defines initial position
  52560. * @param interaxialDistance defines distance between each color axis
  52561. * @param scene defines the hosting scene
  52562. */
  52563. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  52564. /**
  52565. * Gets camera class name
  52566. * @returns AnaglyphUniversalCamera
  52567. */
  52568. getClassName(): string;
  52569. }
  52570. }
  52571. declare module BABYLON {
  52572. /**
  52573. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  52574. * @see https://doc.babylonjs.com/features/cameras
  52575. */
  52576. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  52577. /**
  52578. * Creates a new StereoscopicArcRotateCamera
  52579. * @param name defines camera name
  52580. * @param alpha defines alpha angle (in radians)
  52581. * @param beta defines beta angle (in radians)
  52582. * @param radius defines radius
  52583. * @param target defines camera target
  52584. * @param interaxialDistance defines distance between each color axis
  52585. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52586. * @param scene defines the hosting scene
  52587. */
  52588. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52589. /**
  52590. * Gets camera class name
  52591. * @returns StereoscopicArcRotateCamera
  52592. */
  52593. getClassName(): string;
  52594. }
  52595. }
  52596. declare module BABYLON {
  52597. /**
  52598. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  52599. * @see https://doc.babylonjs.com/features/cameras
  52600. */
  52601. export class StereoscopicFreeCamera extends FreeCamera {
  52602. /**
  52603. * Creates a new StereoscopicFreeCamera
  52604. * @param name defines camera name
  52605. * @param position defines initial position
  52606. * @param interaxialDistance defines distance between each color axis
  52607. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52608. * @param scene defines the hosting scene
  52609. */
  52610. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52611. /**
  52612. * Gets camera class name
  52613. * @returns StereoscopicFreeCamera
  52614. */
  52615. getClassName(): string;
  52616. }
  52617. }
  52618. declare module BABYLON {
  52619. /**
  52620. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  52621. * @see https://doc.babylonjs.com/features/cameras
  52622. */
  52623. export class StereoscopicGamepadCamera extends GamepadCamera {
  52624. /**
  52625. * Creates a new StereoscopicGamepadCamera
  52626. * @param name defines camera name
  52627. * @param position defines initial position
  52628. * @param interaxialDistance defines distance between each color axis
  52629. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52630. * @param scene defines the hosting scene
  52631. */
  52632. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52633. /**
  52634. * Gets camera class name
  52635. * @returns StereoscopicGamepadCamera
  52636. */
  52637. getClassName(): string;
  52638. }
  52639. }
  52640. declare module BABYLON {
  52641. /**
  52642. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  52643. * @see https://doc.babylonjs.com/features/cameras
  52644. */
  52645. export class StereoscopicUniversalCamera extends UniversalCamera {
  52646. /**
  52647. * Creates a new StereoscopicUniversalCamera
  52648. * @param name defines camera name
  52649. * @param position defines initial position
  52650. * @param interaxialDistance defines distance between each color axis
  52651. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52652. * @param scene defines the hosting scene
  52653. */
  52654. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52655. /**
  52656. * Gets camera class name
  52657. * @returns StereoscopicUniversalCamera
  52658. */
  52659. getClassName(): string;
  52660. }
  52661. }
  52662. declare module BABYLON {
  52663. /**
  52664. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  52665. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  52666. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  52667. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  52668. */
  52669. export class VirtualJoysticksCamera extends FreeCamera {
  52670. /**
  52671. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  52672. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  52673. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  52674. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  52675. * @param name Define the name of the camera in the scene
  52676. * @param position Define the start position of the camera in the scene
  52677. * @param scene Define the scene the camera belongs to
  52678. */
  52679. constructor(name: string, position: Vector3, scene: Scene);
  52680. /**
  52681. * Gets the current object class name.
  52682. * @return the class name
  52683. */
  52684. getClassName(): string;
  52685. }
  52686. }
  52687. declare module BABYLON {
  52688. /**
  52689. * This represents all the required metrics to create a VR camera.
  52690. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  52691. */
  52692. export class VRCameraMetrics {
  52693. /**
  52694. * Define the horizontal resolution off the screen.
  52695. */
  52696. hResolution: number;
  52697. /**
  52698. * Define the vertical resolution off the screen.
  52699. */
  52700. vResolution: number;
  52701. /**
  52702. * Define the horizontal screen size.
  52703. */
  52704. hScreenSize: number;
  52705. /**
  52706. * Define the vertical screen size.
  52707. */
  52708. vScreenSize: number;
  52709. /**
  52710. * Define the vertical screen center position.
  52711. */
  52712. vScreenCenter: number;
  52713. /**
  52714. * Define the distance of the eyes to the screen.
  52715. */
  52716. eyeToScreenDistance: number;
  52717. /**
  52718. * Define the distance between both lenses
  52719. */
  52720. lensSeparationDistance: number;
  52721. /**
  52722. * Define the distance between both viewer's eyes.
  52723. */
  52724. interpupillaryDistance: number;
  52725. /**
  52726. * Define the distortion factor of the VR postprocess.
  52727. * Please, touch with care.
  52728. */
  52729. distortionK: number[];
  52730. /**
  52731. * Define the chromatic aberration correction factors for the VR post process.
  52732. */
  52733. chromaAbCorrection: number[];
  52734. /**
  52735. * Define the scale factor of the post process.
  52736. * The smaller the better but the slower.
  52737. */
  52738. postProcessScaleFactor: number;
  52739. /**
  52740. * Define an offset for the lens center.
  52741. */
  52742. lensCenterOffset: number;
  52743. /**
  52744. * Define if the current vr camera should compensate the distortion of the lense or not.
  52745. */
  52746. compensateDistortion: boolean;
  52747. /**
  52748. * Defines if multiview should be enabled when rendering (Default: false)
  52749. */
  52750. multiviewEnabled: boolean;
  52751. /**
  52752. * Gets the rendering aspect ratio based on the provided resolutions.
  52753. */
  52754. get aspectRatio(): number;
  52755. /**
  52756. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  52757. */
  52758. get aspectRatioFov(): number;
  52759. /**
  52760. * @hidden
  52761. */
  52762. get leftHMatrix(): Matrix;
  52763. /**
  52764. * @hidden
  52765. */
  52766. get rightHMatrix(): Matrix;
  52767. /**
  52768. * @hidden
  52769. */
  52770. get leftPreViewMatrix(): Matrix;
  52771. /**
  52772. * @hidden
  52773. */
  52774. get rightPreViewMatrix(): Matrix;
  52775. /**
  52776. * Get the default VRMetrics based on the most generic setup.
  52777. * @returns the default vr metrics
  52778. */
  52779. static GetDefault(): VRCameraMetrics;
  52780. }
  52781. }
  52782. declare module BABYLON {
  52783. /** @hidden */
  52784. export var vrDistortionCorrectionPixelShader: {
  52785. name: string;
  52786. shader: string;
  52787. };
  52788. }
  52789. declare module BABYLON {
  52790. /**
  52791. * VRDistortionCorrectionPostProcess used for mobile VR
  52792. */
  52793. export class VRDistortionCorrectionPostProcess extends PostProcess {
  52794. private _isRightEye;
  52795. private _distortionFactors;
  52796. private _postProcessScaleFactor;
  52797. private _lensCenterOffset;
  52798. private _scaleIn;
  52799. private _scaleFactor;
  52800. private _lensCenter;
  52801. /**
  52802. * Gets a string identifying the name of the class
  52803. * @returns "VRDistortionCorrectionPostProcess" string
  52804. */
  52805. getClassName(): string;
  52806. /**
  52807. * Initializes the VRDistortionCorrectionPostProcess
  52808. * @param name The name of the effect.
  52809. * @param camera The camera to apply the render pass to.
  52810. * @param isRightEye If this is for the right eye distortion
  52811. * @param vrMetrics All the required metrics for the VR camera
  52812. */
  52813. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  52814. }
  52815. }
  52816. declare module BABYLON {
  52817. /**
  52818. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  52819. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  52820. */
  52821. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  52822. /**
  52823. * Creates a new VRDeviceOrientationArcRotateCamera
  52824. * @param name defines camera name
  52825. * @param alpha defines the camera rotation along the logitudinal axis
  52826. * @param beta defines the camera rotation along the latitudinal axis
  52827. * @param radius defines the camera distance from its target
  52828. * @param target defines the camera target
  52829. * @param scene defines the scene the camera belongs to
  52830. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  52831. * @param vrCameraMetrics defines the vr metrics associated to the camera
  52832. */
  52833. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  52834. /**
  52835. * Gets camera class name
  52836. * @returns VRDeviceOrientationArcRotateCamera
  52837. */
  52838. getClassName(): string;
  52839. }
  52840. }
  52841. declare module BABYLON {
  52842. /**
  52843. * Camera used to simulate VR rendering (based on FreeCamera)
  52844. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  52845. */
  52846. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  52847. /**
  52848. * Creates a new VRDeviceOrientationFreeCamera
  52849. * @param name defines camera name
  52850. * @param position defines the start position of the camera
  52851. * @param scene defines the scene the camera belongs to
  52852. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  52853. * @param vrCameraMetrics defines the vr metrics associated to the camera
  52854. */
  52855. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  52856. /**
  52857. * Gets camera class name
  52858. * @returns VRDeviceOrientationFreeCamera
  52859. */
  52860. getClassName(): string;
  52861. }
  52862. }
  52863. declare module BABYLON {
  52864. /**
  52865. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  52866. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  52867. */
  52868. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  52869. /**
  52870. * Creates a new VRDeviceOrientationGamepadCamera
  52871. * @param name defines camera name
  52872. * @param position defines the start position of the camera
  52873. * @param scene defines the scene the camera belongs to
  52874. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  52875. * @param vrCameraMetrics defines the vr metrics associated to the camera
  52876. */
  52877. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  52878. /**
  52879. * Gets camera class name
  52880. * @returns VRDeviceOrientationGamepadCamera
  52881. */
  52882. getClassName(): string;
  52883. }
  52884. }
  52885. declare module BABYLON {
  52886. /**
  52887. * A class extending Texture allowing drawing on a texture
  52888. * @see https://doc.babylonjs.com/how_to/dynamictexture
  52889. */
  52890. export class DynamicTexture extends Texture {
  52891. private _generateMipMaps;
  52892. private _canvas;
  52893. private _context;
  52894. /**
  52895. * Creates a DynamicTexture
  52896. * @param name defines the name of the texture
  52897. * @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
  52898. * @param scene defines the scene where you want the texture
  52899. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  52900. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  52901. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  52902. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  52903. */
  52904. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  52905. /**
  52906. * Get the current class name of the texture useful for serialization or dynamic coding.
  52907. * @returns "DynamicTexture"
  52908. */
  52909. getClassName(): string;
  52910. /**
  52911. * Gets the current state of canRescale
  52912. */
  52913. get canRescale(): boolean;
  52914. private _recreate;
  52915. /**
  52916. * Scales the texture
  52917. * @param ratio the scale factor to apply to both width and height
  52918. */
  52919. scale(ratio: number): void;
  52920. /**
  52921. * Resizes the texture
  52922. * @param width the new width
  52923. * @param height the new height
  52924. */
  52925. scaleTo(width: number, height: number): void;
  52926. /**
  52927. * Gets the context of the canvas used by the texture
  52928. * @returns the canvas context of the dynamic texture
  52929. */
  52930. getContext(): CanvasRenderingContext2D;
  52931. /**
  52932. * Clears the texture
  52933. */
  52934. clear(): void;
  52935. /**
  52936. * Updates the texture
  52937. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  52938. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  52939. */
  52940. update(invertY?: boolean, premulAlpha?: boolean): void;
  52941. /**
  52942. * Draws text onto the texture
  52943. * @param text defines the text to be drawn
  52944. * @param x defines the placement of the text from the left
  52945. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  52946. * @param font defines the font to be used with font-style, font-size, font-name
  52947. * @param color defines the color used for the text
  52948. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  52949. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  52950. * @param update defines whether texture is immediately update (default is true)
  52951. */
  52952. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  52953. /**
  52954. * Clones the texture
  52955. * @returns the clone of the texture.
  52956. */
  52957. clone(): DynamicTexture;
  52958. /**
  52959. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  52960. * @returns a serialized dynamic texture object
  52961. */
  52962. serialize(): any;
  52963. private _IsCanvasElement;
  52964. /** @hidden */
  52965. _rebuild(): void;
  52966. }
  52967. }
  52968. declare module BABYLON {
  52969. /**
  52970. * Class containing static functions to help procedurally build meshes
  52971. */
  52972. export class GroundBuilder {
  52973. /**
  52974. * Creates a ground mesh
  52975. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  52976. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  52977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52978. * @param name defines the name of the mesh
  52979. * @param options defines the options used to create the mesh
  52980. * @param scene defines the hosting scene
  52981. * @returns the ground mesh
  52982. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  52983. */
  52984. static CreateGround(name: string, options: {
  52985. width?: number;
  52986. height?: number;
  52987. subdivisions?: number;
  52988. subdivisionsX?: number;
  52989. subdivisionsY?: number;
  52990. updatable?: boolean;
  52991. }, scene: any): Mesh;
  52992. /**
  52993. * Creates a tiled ground mesh
  52994. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  52995. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  52996. * * 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
  52997. * * 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
  52998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52999. * @param name defines the name of the mesh
  53000. * @param options defines the options used to create the mesh
  53001. * @param scene defines the hosting scene
  53002. * @returns the tiled ground mesh
  53003. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53004. */
  53005. static CreateTiledGround(name: string, options: {
  53006. xmin: number;
  53007. zmin: number;
  53008. xmax: number;
  53009. zmax: number;
  53010. subdivisions?: {
  53011. w: number;
  53012. h: number;
  53013. };
  53014. precision?: {
  53015. w: number;
  53016. h: number;
  53017. };
  53018. updatable?: boolean;
  53019. }, scene?: Nullable<Scene>): Mesh;
  53020. /**
  53021. * Creates a ground mesh from a height map
  53022. * * The parameter `url` sets the URL of the height map image resource.
  53023. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53024. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53025. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53026. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53027. * * 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.
  53028. * * 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).
  53029. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53031. * @param name defines the name of the mesh
  53032. * @param url defines the url to the height map
  53033. * @param options defines the options used to create the mesh
  53034. * @param scene defines the hosting scene
  53035. * @returns the ground mesh
  53036. * @see https://doc.babylonjs.com/babylon101/height_map
  53037. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53038. */
  53039. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53040. width?: number;
  53041. height?: number;
  53042. subdivisions?: number;
  53043. minHeight?: number;
  53044. maxHeight?: number;
  53045. colorFilter?: Color3;
  53046. alphaFilter?: number;
  53047. updatable?: boolean;
  53048. onReady?: (mesh: GroundMesh) => void;
  53049. }, scene?: Nullable<Scene>): GroundMesh;
  53050. }
  53051. }
  53052. declare module BABYLON {
  53053. /**
  53054. * Class containing static functions to help procedurally build meshes
  53055. */
  53056. export class TorusBuilder {
  53057. /**
  53058. * Creates a torus mesh
  53059. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  53060. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  53061. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  53062. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53063. * * 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
  53064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53065. * @param name defines the name of the mesh
  53066. * @param options defines the options used to create the mesh
  53067. * @param scene defines the hosting scene
  53068. * @returns the torus mesh
  53069. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  53070. */
  53071. static CreateTorus(name: string, options: {
  53072. diameter?: number;
  53073. thickness?: number;
  53074. tessellation?: number;
  53075. updatable?: boolean;
  53076. sideOrientation?: number;
  53077. frontUVs?: Vector4;
  53078. backUVs?: Vector4;
  53079. }, scene: any): Mesh;
  53080. }
  53081. }
  53082. declare module BABYLON {
  53083. /**
  53084. * Class containing static functions to help procedurally build meshes
  53085. */
  53086. export class CylinderBuilder {
  53087. /**
  53088. * Creates a cylinder or a cone mesh
  53089. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  53090. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  53091. * * 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.
  53092. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  53093. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  53094. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  53095. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  53096. * * 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).
  53097. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  53098. * * 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).
  53099. * * 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
  53100. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  53101. * * 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
  53102. * * 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.
  53103. * * If `enclose` is false, a ring surface is one element.
  53104. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  53105. * * 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
  53106. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53107. * * 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
  53108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53109. * @param name defines the name of the mesh
  53110. * @param options defines the options used to create the mesh
  53111. * @param scene defines the hosting scene
  53112. * @returns the cylinder mesh
  53113. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  53114. */
  53115. static CreateCylinder(name: string, options: {
  53116. height?: number;
  53117. diameterTop?: number;
  53118. diameterBottom?: number;
  53119. diameter?: number;
  53120. tessellation?: number;
  53121. subdivisions?: number;
  53122. arc?: number;
  53123. faceColors?: Color4[];
  53124. faceUV?: Vector4[];
  53125. updatable?: boolean;
  53126. hasRings?: boolean;
  53127. enclose?: boolean;
  53128. cap?: number;
  53129. sideOrientation?: number;
  53130. frontUVs?: Vector4;
  53131. backUVs?: Vector4;
  53132. }, scene: any): Mesh;
  53133. }
  53134. }
  53135. declare module BABYLON {
  53136. /**
  53137. * States of the webXR experience
  53138. */
  53139. export enum WebXRState {
  53140. /**
  53141. * Transitioning to being in XR mode
  53142. */
  53143. ENTERING_XR = 0,
  53144. /**
  53145. * Transitioning to non XR mode
  53146. */
  53147. EXITING_XR = 1,
  53148. /**
  53149. * In XR mode and presenting
  53150. */
  53151. IN_XR = 2,
  53152. /**
  53153. * Not entered XR mode
  53154. */
  53155. NOT_IN_XR = 3
  53156. }
  53157. /**
  53158. * The state of the XR camera's tracking
  53159. */
  53160. export enum WebXRTrackingState {
  53161. /**
  53162. * No transformation received, device is not being tracked
  53163. */
  53164. NOT_TRACKING = 0,
  53165. /**
  53166. * Tracking lost - using emulated position
  53167. */
  53168. TRACKING_LOST = 1,
  53169. /**
  53170. * Transformation tracking works normally
  53171. */
  53172. TRACKING = 2
  53173. }
  53174. /**
  53175. * Abstraction of the XR render target
  53176. */
  53177. export interface WebXRRenderTarget extends IDisposable {
  53178. /**
  53179. * xrpresent context of the canvas which can be used to display/mirror xr content
  53180. */
  53181. canvasContext: WebGLRenderingContext;
  53182. /**
  53183. * xr layer for the canvas
  53184. */
  53185. xrLayer: Nullable<XRWebGLLayer>;
  53186. /**
  53187. * Initializes the xr layer for the session
  53188. * @param xrSession xr session
  53189. * @returns a promise that will resolve once the XR Layer has been created
  53190. */
  53191. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  53192. }
  53193. }
  53194. declare module BABYLON {
  53195. /**
  53196. * COnfiguration object for WebXR output canvas
  53197. */
  53198. export class WebXRManagedOutputCanvasOptions {
  53199. /**
  53200. * An optional canvas in case you wish to create it yourself and provide it here.
  53201. * If not provided, a new canvas will be created
  53202. */
  53203. canvasElement?: HTMLCanvasElement;
  53204. /**
  53205. * Options for this XR Layer output
  53206. */
  53207. canvasOptions?: XRWebGLLayerInit;
  53208. /**
  53209. * CSS styling for a newly created canvas (if not provided)
  53210. */
  53211. newCanvasCssStyle?: string;
  53212. /**
  53213. * Get the default values of the configuration object
  53214. * @param engine defines the engine to use (can be null)
  53215. * @returns default values of this configuration object
  53216. */
  53217. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  53218. }
  53219. /**
  53220. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  53221. */
  53222. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  53223. private _options;
  53224. private _canvas;
  53225. private _engine;
  53226. private _originalCanvasSize;
  53227. /**
  53228. * Rendering context of the canvas which can be used to display/mirror xr content
  53229. */
  53230. canvasContext: WebGLRenderingContext;
  53231. /**
  53232. * xr layer for the canvas
  53233. */
  53234. xrLayer: Nullable<XRWebGLLayer>;
  53235. /**
  53236. * Obseervers registered here will be triggered when the xr layer was initialized
  53237. */
  53238. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  53239. /**
  53240. * Initializes the canvas to be added/removed upon entering/exiting xr
  53241. * @param _xrSessionManager The XR Session manager
  53242. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  53243. */
  53244. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  53245. /**
  53246. * Disposes of the object
  53247. */
  53248. dispose(): void;
  53249. /**
  53250. * Initializes the xr layer for the session
  53251. * @param xrSession xr session
  53252. * @returns a promise that will resolve once the XR Layer has been created
  53253. */
  53254. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  53255. private _addCanvas;
  53256. private _removeCanvas;
  53257. private _setCanvasSize;
  53258. private _setManagedOutputCanvas;
  53259. }
  53260. }
  53261. declare module BABYLON {
  53262. /**
  53263. * Manages an XRSession to work with Babylon's engine
  53264. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  53265. */
  53266. export class WebXRSessionManager implements IDisposable {
  53267. /** The scene which the session should be created for */
  53268. scene: Scene;
  53269. private _referenceSpace;
  53270. private _rttProvider;
  53271. private _sessionEnded;
  53272. private _xrNavigator;
  53273. private baseLayer;
  53274. /**
  53275. * The base reference space from which the session started. good if you want to reset your
  53276. * reference space
  53277. */
  53278. baseReferenceSpace: XRReferenceSpace;
  53279. /**
  53280. * Current XR frame
  53281. */
  53282. currentFrame: Nullable<XRFrame>;
  53283. /** WebXR timestamp updated every frame */
  53284. currentTimestamp: number;
  53285. /**
  53286. * Used just in case of a failure to initialize an immersive session.
  53287. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  53288. */
  53289. defaultHeightCompensation: number;
  53290. /**
  53291. * Fires every time a new xrFrame arrives which can be used to update the camera
  53292. */
  53293. onXRFrameObservable: Observable<XRFrame>;
  53294. /**
  53295. * Fires when the reference space changed
  53296. */
  53297. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  53298. /**
  53299. * Fires when the xr session is ended either by the device or manually done
  53300. */
  53301. onXRSessionEnded: Observable<any>;
  53302. /**
  53303. * Fires when the xr session is ended either by the device or manually done
  53304. */
  53305. onXRSessionInit: Observable<XRSession>;
  53306. /**
  53307. * Underlying xr session
  53308. */
  53309. session: XRSession;
  53310. /**
  53311. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  53312. * or get the offset the player is currently at.
  53313. */
  53314. viewerReferenceSpace: XRReferenceSpace;
  53315. /**
  53316. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  53317. * @param scene The scene which the session should be created for
  53318. */
  53319. constructor(
  53320. /** The scene which the session should be created for */
  53321. scene: Scene);
  53322. /**
  53323. * The current reference space used in this session. This reference space can constantly change!
  53324. * It is mainly used to offset the camera's position.
  53325. */
  53326. get referenceSpace(): XRReferenceSpace;
  53327. /**
  53328. * Set a new reference space and triggers the observable
  53329. */
  53330. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  53331. /**
  53332. * Disposes of the session manager
  53333. */
  53334. dispose(): void;
  53335. /**
  53336. * Stops the xrSession and restores the render loop
  53337. * @returns Promise which resolves after it exits XR
  53338. */
  53339. exitXRAsync(): Promise<void>;
  53340. /**
  53341. * Gets the correct render target texture to be rendered this frame for this eye
  53342. * @param eye the eye for which to get the render target
  53343. * @returns the render target for the specified eye
  53344. */
  53345. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  53346. /**
  53347. * Creates a WebXRRenderTarget object for the XR session
  53348. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  53349. * @param options optional options to provide when creating a new render target
  53350. * @returns a WebXR render target to which the session can render
  53351. */
  53352. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  53353. /**
  53354. * Initializes the manager
  53355. * After initialization enterXR can be called to start an XR session
  53356. * @returns Promise which resolves after it is initialized
  53357. */
  53358. initializeAsync(): Promise<void>;
  53359. /**
  53360. * Initializes an xr session
  53361. * @param xrSessionMode mode to initialize
  53362. * @param xrSessionInit defines optional and required values to pass to the session builder
  53363. * @returns a promise which will resolve once the session has been initialized
  53364. */
  53365. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  53366. /**
  53367. * Checks if a session would be supported for the creation options specified
  53368. * @param sessionMode session mode to check if supported eg. immersive-vr
  53369. * @returns A Promise that resolves to true if supported and false if not
  53370. */
  53371. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  53372. /**
  53373. * Resets the reference space to the one started the session
  53374. */
  53375. resetReferenceSpace(): void;
  53376. /**
  53377. * Starts rendering to the xr layer
  53378. */
  53379. runXRRenderLoop(): void;
  53380. /**
  53381. * Sets the reference space on the xr session
  53382. * @param referenceSpaceType space to set
  53383. * @returns a promise that will resolve once the reference space has been set
  53384. */
  53385. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  53386. /**
  53387. * Updates the render state of the session
  53388. * @param state state to set
  53389. * @returns a promise that resolves once the render state has been updated
  53390. */
  53391. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  53392. /**
  53393. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  53394. * @param sessionMode defines the session to test
  53395. * @returns a promise with boolean as final value
  53396. */
  53397. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  53398. /**
  53399. * Returns true if Babylon.js is using the BabylonNative backend, otherwise false
  53400. */
  53401. get isNative(): boolean;
  53402. private _createRenderTargetTexture;
  53403. }
  53404. }
  53405. declare module BABYLON {
  53406. /**
  53407. * WebXR Camera which holds the views for the xrSession
  53408. * @see https://doc.babylonjs.com/how_to/webxr_camera
  53409. */
  53410. export class WebXRCamera extends FreeCamera {
  53411. private _xrSessionManager;
  53412. private _firstFrame;
  53413. private _referenceQuaternion;
  53414. private _referencedPosition;
  53415. private _xrInvPositionCache;
  53416. private _xrInvQuaternionCache;
  53417. private _trackingState;
  53418. /**
  53419. * Observable raised before camera teleportation
  53420. */
  53421. onBeforeCameraTeleport: Observable<Vector3>;
  53422. /**
  53423. * Observable raised after camera teleportation
  53424. */
  53425. onAfterCameraTeleport: Observable<Vector3>;
  53426. /**
  53427. * Notifies when the camera's tracking state has changed.
  53428. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  53429. */
  53430. onTrackingStateChanged: Observable<WebXRTrackingState>;
  53431. /**
  53432. * Should position compensation execute on first frame.
  53433. * This is used when copying the position from a native (non XR) camera
  53434. */
  53435. compensateOnFirstFrame: boolean;
  53436. /**
  53437. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  53438. * @param name the name of the camera
  53439. * @param scene the scene to add the camera to
  53440. * @param _xrSessionManager a constructed xr session manager
  53441. */
  53442. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  53443. /**
  53444. * Get the current XR tracking state of the camera
  53445. */
  53446. get trackingState(): WebXRTrackingState;
  53447. private _setTrackingState;
  53448. /**
  53449. * Return the user's height, unrelated to the current ground.
  53450. * This will be the y position of this camera, when ground level is 0.
  53451. */
  53452. get realWorldHeight(): number;
  53453. /** @hidden */
  53454. _updateForDualEyeDebugging(): void;
  53455. /**
  53456. * Sets this camera's transformation based on a non-vr camera
  53457. * @param otherCamera the non-vr camera to copy the transformation from
  53458. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  53459. */
  53460. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  53461. /**
  53462. * Gets the current instance class name ("WebXRCamera").
  53463. * @returns the class name
  53464. */
  53465. getClassName(): string;
  53466. private _rotate180;
  53467. private _updateFromXRSession;
  53468. private _updateNumberOfRigCameras;
  53469. private _updateReferenceSpace;
  53470. private _updateReferenceSpaceOffset;
  53471. }
  53472. }
  53473. declare module BABYLON {
  53474. /**
  53475. * Defining the interface required for a (webxr) feature
  53476. */
  53477. export interface IWebXRFeature extends IDisposable {
  53478. /**
  53479. * Is this feature attached
  53480. */
  53481. attached: boolean;
  53482. /**
  53483. * Should auto-attach be disabled?
  53484. */
  53485. disableAutoAttach: boolean;
  53486. /**
  53487. * Attach the feature to the session
  53488. * Will usually be called by the features manager
  53489. *
  53490. * @param force should attachment be forced (even when already attached)
  53491. * @returns true if successful.
  53492. */
  53493. attach(force?: boolean): boolean;
  53494. /**
  53495. * Detach the feature from the session
  53496. * Will usually be called by the features manager
  53497. *
  53498. * @returns true if successful.
  53499. */
  53500. detach(): boolean;
  53501. /**
  53502. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  53503. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  53504. *
  53505. * @returns whether or not the feature is compatible in this environment
  53506. */
  53507. isCompatible(): boolean;
  53508. /**
  53509. * Was this feature disposed;
  53510. */
  53511. isDisposed: boolean;
  53512. /**
  53513. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  53514. */
  53515. xrNativeFeatureName?: string;
  53516. /**
  53517. * A list of (Babylon WebXR) features this feature depends on
  53518. */
  53519. dependsOn?: string[];
  53520. }
  53521. /**
  53522. * A list of the currently available features without referencing them
  53523. */
  53524. export class WebXRFeatureName {
  53525. /**
  53526. * The name of the anchor system feature
  53527. */
  53528. static readonly ANCHOR_SYSTEM: string;
  53529. /**
  53530. * The name of the background remover feature
  53531. */
  53532. static readonly BACKGROUND_REMOVER: string;
  53533. /**
  53534. * The name of the hit test feature
  53535. */
  53536. static readonly HIT_TEST: string;
  53537. /**
  53538. * The name of the mesh detection feature
  53539. */
  53540. static readonly MESH_DETECTION: string;
  53541. /**
  53542. * physics impostors for xr controllers feature
  53543. */
  53544. static readonly PHYSICS_CONTROLLERS: string;
  53545. /**
  53546. * The name of the plane detection feature
  53547. */
  53548. static readonly PLANE_DETECTION: string;
  53549. /**
  53550. * The name of the pointer selection feature
  53551. */
  53552. static readonly POINTER_SELECTION: string;
  53553. /**
  53554. * The name of the teleportation feature
  53555. */
  53556. static readonly TELEPORTATION: string;
  53557. /**
  53558. * The name of the feature points feature.
  53559. */
  53560. static readonly FEATURE_POINTS: string;
  53561. /**
  53562. * The name of the hand tracking feature.
  53563. */
  53564. static readonly HAND_TRACKING: string;
  53565. }
  53566. /**
  53567. * Defining the constructor of a feature. Used to register the modules.
  53568. */
  53569. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  53570. /**
  53571. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  53572. * It is mainly used in AR sessions.
  53573. *
  53574. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  53575. */
  53576. export class WebXRFeaturesManager implements IDisposable {
  53577. private _xrSessionManager;
  53578. private static readonly _AvailableFeatures;
  53579. private _features;
  53580. /**
  53581. * constructs a new features manages.
  53582. *
  53583. * @param _xrSessionManager an instance of WebXRSessionManager
  53584. */
  53585. constructor(_xrSessionManager: WebXRSessionManager);
  53586. /**
  53587. * Used to register a module. After calling this function a developer can use this feature in the scene.
  53588. * Mainly used internally.
  53589. *
  53590. * @param featureName the name of the feature to register
  53591. * @param constructorFunction the function used to construct the module
  53592. * @param version the (babylon) version of the module
  53593. * @param stable is that a stable version of this module
  53594. */
  53595. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  53596. /**
  53597. * Returns a constructor of a specific feature.
  53598. *
  53599. * @param featureName the name of the feature to construct
  53600. * @param version the version of the feature to load
  53601. * @param xrSessionManager the xrSessionManager. Used to construct the module
  53602. * @param options optional options provided to the module.
  53603. * @returns a function that, when called, will return a new instance of this feature
  53604. */
  53605. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  53606. /**
  53607. * Can be used to return the list of features currently registered
  53608. *
  53609. * @returns an Array of available features
  53610. */
  53611. static GetAvailableFeatures(): string[];
  53612. /**
  53613. * Gets the versions available for a specific feature
  53614. * @param featureName the name of the feature
  53615. * @returns an array with the available versions
  53616. */
  53617. static GetAvailableVersions(featureName: string): string[];
  53618. /**
  53619. * Return the latest unstable version of this feature
  53620. * @param featureName the name of the feature to search
  53621. * @returns the version number. if not found will return -1
  53622. */
  53623. static GetLatestVersionOfFeature(featureName: string): number;
  53624. /**
  53625. * Return the latest stable version of this feature
  53626. * @param featureName the name of the feature to search
  53627. * @returns the version number. if not found will return -1
  53628. */
  53629. static GetStableVersionOfFeature(featureName: string): number;
  53630. /**
  53631. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  53632. * Can be used during a session to start a feature
  53633. * @param featureName the name of feature to attach
  53634. */
  53635. attachFeature(featureName: string): void;
  53636. /**
  53637. * Can be used inside a session or when the session ends to detach a specific feature
  53638. * @param featureName the name of the feature to detach
  53639. */
  53640. detachFeature(featureName: string): void;
  53641. /**
  53642. * Used to disable an already-enabled feature
  53643. * The feature will be disposed and will be recreated once enabled.
  53644. * @param featureName the feature to disable
  53645. * @returns true if disable was successful
  53646. */
  53647. disableFeature(featureName: string | {
  53648. Name: string;
  53649. }): boolean;
  53650. /**
  53651. * dispose this features manager
  53652. */
  53653. dispose(): void;
  53654. /**
  53655. * 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.
  53656. * 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.
  53657. *
  53658. * @param featureName the name of the feature to load or the class of the feature
  53659. * @param version optional version to load. if not provided the latest version will be enabled
  53660. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  53661. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  53662. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  53663. * @returns a new constructed feature or throws an error if feature not found.
  53664. */
  53665. enableFeature(featureName: string | {
  53666. Name: string;
  53667. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  53668. /**
  53669. * get the implementation of an enabled feature.
  53670. * @param featureName the name of the feature to load
  53671. * @returns the feature class, if found
  53672. */
  53673. getEnabledFeature(featureName: string): IWebXRFeature;
  53674. /**
  53675. * Get the list of enabled features
  53676. * @returns an array of enabled features
  53677. */
  53678. getEnabledFeatures(): string[];
  53679. /**
  53680. * This function will exten the session creation configuration object with enabled features.
  53681. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  53682. * according to the defined "required" variable, provided during enableFeature call
  53683. * @param xrSessionInit the xr Session init object to extend
  53684. *
  53685. * @returns an extended XRSessionInit object
  53686. */
  53687. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  53688. }
  53689. }
  53690. declare module BABYLON {
  53691. /**
  53692. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  53693. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  53694. */
  53695. export class WebXRExperienceHelper implements IDisposable {
  53696. private scene;
  53697. private _nonVRCamera;
  53698. private _originalSceneAutoClear;
  53699. private _supported;
  53700. /**
  53701. * Camera used to render xr content
  53702. */
  53703. camera: WebXRCamera;
  53704. /** A features manager for this xr session */
  53705. featuresManager: WebXRFeaturesManager;
  53706. /**
  53707. * Observers registered here will be triggered after the camera's initial transformation is set
  53708. * This can be used to set a different ground level or an extra rotation.
  53709. *
  53710. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  53711. * to the position set after this observable is done executing.
  53712. */
  53713. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  53714. /**
  53715. * Fires when the state of the experience helper has changed
  53716. */
  53717. onStateChangedObservable: Observable<WebXRState>;
  53718. /** Session manager used to keep track of xr session */
  53719. sessionManager: WebXRSessionManager;
  53720. /**
  53721. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  53722. */
  53723. state: WebXRState;
  53724. /**
  53725. * Creates a WebXRExperienceHelper
  53726. * @param scene The scene the helper should be created in
  53727. */
  53728. private constructor();
  53729. /**
  53730. * Creates the experience helper
  53731. * @param scene the scene to attach the experience helper to
  53732. * @returns a promise for the experience helper
  53733. */
  53734. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  53735. /**
  53736. * Disposes of the experience helper
  53737. */
  53738. dispose(): void;
  53739. /**
  53740. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  53741. * @param sessionMode options for the XR session
  53742. * @param referenceSpaceType frame of reference of the XR session
  53743. * @param renderTarget the output canvas that will be used to enter XR mode
  53744. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  53745. * @returns promise that resolves after xr mode has entered
  53746. */
  53747. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  53748. /**
  53749. * Exits XR mode and returns the scene to its original state
  53750. * @returns promise that resolves after xr mode has exited
  53751. */
  53752. exitXRAsync(): Promise<void>;
  53753. private _nonXRToXRCamera;
  53754. private _setState;
  53755. }
  53756. }
  53757. declare module BABYLON {
  53758. /**
  53759. * X-Y values for axes in WebXR
  53760. */
  53761. export interface IWebXRMotionControllerAxesValue {
  53762. /**
  53763. * The value of the x axis
  53764. */
  53765. x: number;
  53766. /**
  53767. * The value of the y-axis
  53768. */
  53769. y: number;
  53770. }
  53771. /**
  53772. * changed / previous values for the values of this component
  53773. */
  53774. export interface IWebXRMotionControllerComponentChangesValues<T> {
  53775. /**
  53776. * current (this frame) value
  53777. */
  53778. current: T;
  53779. /**
  53780. * previous (last change) value
  53781. */
  53782. previous: T;
  53783. }
  53784. /**
  53785. * Represents changes in the component between current frame and last values recorded
  53786. */
  53787. export interface IWebXRMotionControllerComponentChanges {
  53788. /**
  53789. * will be populated with previous and current values if axes changed
  53790. */
  53791. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  53792. /**
  53793. * will be populated with previous and current values if pressed changed
  53794. */
  53795. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  53796. /**
  53797. * will be populated with previous and current values if touched changed
  53798. */
  53799. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  53800. /**
  53801. * will be populated with previous and current values if value changed
  53802. */
  53803. value?: IWebXRMotionControllerComponentChangesValues<number>;
  53804. }
  53805. /**
  53806. * This class represents a single component (for example button or thumbstick) of a motion controller
  53807. */
  53808. export class WebXRControllerComponent implements IDisposable {
  53809. /**
  53810. * the id of this component
  53811. */
  53812. id: string;
  53813. /**
  53814. * the type of the component
  53815. */
  53816. type: MotionControllerComponentType;
  53817. private _buttonIndex;
  53818. private _axesIndices;
  53819. private _axes;
  53820. private _changes;
  53821. private _currentValue;
  53822. private _hasChanges;
  53823. private _pressed;
  53824. private _touched;
  53825. /**
  53826. * button component type
  53827. */
  53828. static BUTTON_TYPE: MotionControllerComponentType;
  53829. /**
  53830. * squeeze component type
  53831. */
  53832. static SQUEEZE_TYPE: MotionControllerComponentType;
  53833. /**
  53834. * Thumbstick component type
  53835. */
  53836. static THUMBSTICK_TYPE: MotionControllerComponentType;
  53837. /**
  53838. * Touchpad component type
  53839. */
  53840. static TOUCHPAD_TYPE: MotionControllerComponentType;
  53841. /**
  53842. * trigger component type
  53843. */
  53844. static TRIGGER_TYPE: MotionControllerComponentType;
  53845. /**
  53846. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  53847. * the axes data changes
  53848. */
  53849. onAxisValueChangedObservable: Observable<{
  53850. x: number;
  53851. y: number;
  53852. }>;
  53853. /**
  53854. * Observers registered here will be triggered when the state of a button changes
  53855. * State change is either pressed / touched / value
  53856. */
  53857. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  53858. /**
  53859. * Creates a new component for a motion controller.
  53860. * It is created by the motion controller itself
  53861. *
  53862. * @param id the id of this component
  53863. * @param type the type of the component
  53864. * @param _buttonIndex index in the buttons array of the gamepad
  53865. * @param _axesIndices indices of the values in the axes array of the gamepad
  53866. */
  53867. constructor(
  53868. /**
  53869. * the id of this component
  53870. */
  53871. id: string,
  53872. /**
  53873. * the type of the component
  53874. */
  53875. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  53876. /**
  53877. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  53878. */
  53879. get axes(): IWebXRMotionControllerAxesValue;
  53880. /**
  53881. * Get the changes. Elements will be populated only if they changed with their previous and current value
  53882. */
  53883. get changes(): IWebXRMotionControllerComponentChanges;
  53884. /**
  53885. * Return whether or not the component changed the last frame
  53886. */
  53887. get hasChanges(): boolean;
  53888. /**
  53889. * is the button currently pressed
  53890. */
  53891. get pressed(): boolean;
  53892. /**
  53893. * is the button currently touched
  53894. */
  53895. get touched(): boolean;
  53896. /**
  53897. * Get the current value of this component
  53898. */
  53899. get value(): number;
  53900. /**
  53901. * Dispose this component
  53902. */
  53903. dispose(): void;
  53904. /**
  53905. * Are there axes correlating to this component
  53906. * @return true is axes data is available
  53907. */
  53908. isAxes(): boolean;
  53909. /**
  53910. * Is this component a button (hence - pressable)
  53911. * @returns true if can be pressed
  53912. */
  53913. isButton(): boolean;
  53914. /**
  53915. * update this component using the gamepad object it is in. Called on every frame
  53916. * @param nativeController the native gamepad controller object
  53917. */
  53918. update(nativeController: IMinimalMotionControllerObject): void;
  53919. }
  53920. }
  53921. declare module BABYLON {
  53922. /**
  53923. * Type used for the success callback of ImportMesh
  53924. */
  53925. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  53926. /**
  53927. * Interface used for the result of ImportMeshAsync
  53928. */
  53929. export interface ISceneLoaderAsyncResult {
  53930. /**
  53931. * The array of loaded meshes
  53932. */
  53933. readonly meshes: AbstractMesh[];
  53934. /**
  53935. * The array of loaded particle systems
  53936. */
  53937. readonly particleSystems: IParticleSystem[];
  53938. /**
  53939. * The array of loaded skeletons
  53940. */
  53941. readonly skeletons: Skeleton[];
  53942. /**
  53943. * The array of loaded animation groups
  53944. */
  53945. readonly animationGroups: AnimationGroup[];
  53946. /**
  53947. * The array of loaded transform nodes
  53948. */
  53949. readonly transformNodes: TransformNode[];
  53950. /**
  53951. * The array of loaded geometries
  53952. */
  53953. readonly geometries: Geometry[];
  53954. /**
  53955. * The array of loaded lights
  53956. */
  53957. readonly lights: Light[];
  53958. }
  53959. /**
  53960. * Interface used to represent data loading progression
  53961. */
  53962. export interface ISceneLoaderProgressEvent {
  53963. /**
  53964. * Defines if data length to load can be evaluated
  53965. */
  53966. readonly lengthComputable: boolean;
  53967. /**
  53968. * Defines the loaded data length
  53969. */
  53970. readonly loaded: number;
  53971. /**
  53972. * Defines the data length to load
  53973. */
  53974. readonly total: number;
  53975. }
  53976. /**
  53977. * Interface used by SceneLoader plugins to define supported file extensions
  53978. */
  53979. export interface ISceneLoaderPluginExtensions {
  53980. /**
  53981. * Defines the list of supported extensions
  53982. */
  53983. [extension: string]: {
  53984. isBinary: boolean;
  53985. };
  53986. }
  53987. /**
  53988. * Interface used by SceneLoader plugin factory
  53989. */
  53990. export interface ISceneLoaderPluginFactory {
  53991. /**
  53992. * Defines the name of the factory
  53993. */
  53994. name: string;
  53995. /**
  53996. * Function called to create a new plugin
  53997. * @return the new plugin
  53998. */
  53999. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  54000. /**
  54001. * The callback that returns true if the data can be directly loaded.
  54002. * @param data string containing the file data
  54003. * @returns if the data can be loaded directly
  54004. */
  54005. canDirectLoad?(data: string): boolean;
  54006. }
  54007. /**
  54008. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  54009. */
  54010. export interface ISceneLoaderPluginBase {
  54011. /**
  54012. * The friendly name of this plugin.
  54013. */
  54014. name: string;
  54015. /**
  54016. * The file extensions supported by this plugin.
  54017. */
  54018. extensions: string | ISceneLoaderPluginExtensions;
  54019. /**
  54020. * The callback called when loading from a url.
  54021. * @param scene scene loading this url
  54022. * @param url url to load
  54023. * @param onSuccess callback called when the file successfully loads
  54024. * @param onProgress callback called while file is loading (if the server supports this mode)
  54025. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  54026. * @param onError callback called when the file fails to load
  54027. * @returns a file request object
  54028. */
  54029. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  54030. /**
  54031. * The callback called when loading from a file object.
  54032. * @param scene scene loading this file
  54033. * @param file defines the file to load
  54034. * @param onSuccess defines the callback to call when data is loaded
  54035. * @param onProgress defines the callback to call during loading process
  54036. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  54037. * @param onError defines the callback to call when an error occurs
  54038. * @returns a file request object
  54039. */
  54040. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  54041. /**
  54042. * The callback that returns true if the data can be directly loaded.
  54043. * @param data string containing the file data
  54044. * @returns if the data can be loaded directly
  54045. */
  54046. canDirectLoad?(data: string): boolean;
  54047. /**
  54048. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  54049. * @param scene scene loading this data
  54050. * @param data string containing the data
  54051. * @returns data to pass to the plugin
  54052. */
  54053. directLoad?(scene: Scene, data: string): any;
  54054. /**
  54055. * The callback that allows custom handling of the root url based on the response url.
  54056. * @param rootUrl the original root url
  54057. * @param responseURL the response url if available
  54058. * @returns the new root url
  54059. */
  54060. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  54061. }
  54062. /**
  54063. * Interface used to define a SceneLoader plugin
  54064. */
  54065. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  54066. /**
  54067. * Import meshes into a scene.
  54068. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54069. * @param scene The scene to import into
  54070. * @param data The data to import
  54071. * @param rootUrl The root url for scene and resources
  54072. * @param meshes The meshes array to import into
  54073. * @param particleSystems The particle systems array to import into
  54074. * @param skeletons The skeletons array to import into
  54075. * @param onError The callback when import fails
  54076. * @returns True if successful or false otherwise
  54077. */
  54078. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  54079. /**
  54080. * Load into a scene.
  54081. * @param scene The scene to load into
  54082. * @param data The data to import
  54083. * @param rootUrl The root url for scene and resources
  54084. * @param onError The callback when import fails
  54085. * @returns True if successful or false otherwise
  54086. */
  54087. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  54088. /**
  54089. * Load into an asset container.
  54090. * @param scene The scene to load into
  54091. * @param data The data to import
  54092. * @param rootUrl The root url for scene and resources
  54093. * @param onError The callback when import fails
  54094. * @returns The loaded asset container
  54095. */
  54096. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  54097. }
  54098. /**
  54099. * Interface used to define an async SceneLoader plugin
  54100. */
  54101. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  54102. /**
  54103. * Import meshes into a scene.
  54104. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54105. * @param scene The scene to import into
  54106. * @param data The data to import
  54107. * @param rootUrl The root url for scene and resources
  54108. * @param onProgress The callback when the load progresses
  54109. * @param fileName Defines the name of the file to load
  54110. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  54111. */
  54112. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  54113. /**
  54114. * Load into a scene.
  54115. * @param scene The scene to load into
  54116. * @param data The data to import
  54117. * @param rootUrl The root url for scene and resources
  54118. * @param onProgress The callback when the load progresses
  54119. * @param fileName Defines the name of the file to load
  54120. * @returns Nothing
  54121. */
  54122. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  54123. /**
  54124. * Load into an asset container.
  54125. * @param scene The scene to load into
  54126. * @param data The data to import
  54127. * @param rootUrl The root url for scene and resources
  54128. * @param onProgress The callback when the load progresses
  54129. * @param fileName Defines the name of the file to load
  54130. * @returns The loaded asset container
  54131. */
  54132. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  54133. }
  54134. /**
  54135. * Mode that determines how to handle old animation groups before loading new ones.
  54136. */
  54137. export enum SceneLoaderAnimationGroupLoadingMode {
  54138. /**
  54139. * Reset all old animations to initial state then dispose them.
  54140. */
  54141. Clean = 0,
  54142. /**
  54143. * Stop all old animations.
  54144. */
  54145. Stop = 1,
  54146. /**
  54147. * Restart old animations from first frame.
  54148. */
  54149. Sync = 2,
  54150. /**
  54151. * Old animations remains untouched.
  54152. */
  54153. NoSync = 3
  54154. }
  54155. /**
  54156. * Defines a plugin registered by the SceneLoader
  54157. */
  54158. interface IRegisteredPlugin {
  54159. /**
  54160. * Defines the plugin to use
  54161. */
  54162. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  54163. /**
  54164. * Defines if the plugin supports binary data
  54165. */
  54166. isBinary: boolean;
  54167. }
  54168. /**
  54169. * Class used to load scene from various file formats using registered plugins
  54170. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  54171. */
  54172. export class SceneLoader {
  54173. /**
  54174. * No logging while loading
  54175. */
  54176. static readonly NO_LOGGING: number;
  54177. /**
  54178. * Minimal logging while loading
  54179. */
  54180. static readonly MINIMAL_LOGGING: number;
  54181. /**
  54182. * Summary logging while loading
  54183. */
  54184. static readonly SUMMARY_LOGGING: number;
  54185. /**
  54186. * Detailled logging while loading
  54187. */
  54188. static readonly DETAILED_LOGGING: number;
  54189. /**
  54190. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  54191. */
  54192. static get ForceFullSceneLoadingForIncremental(): boolean;
  54193. static set ForceFullSceneLoadingForIncremental(value: boolean);
  54194. /**
  54195. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  54196. */
  54197. static get ShowLoadingScreen(): boolean;
  54198. static set ShowLoadingScreen(value: boolean);
  54199. /**
  54200. * Defines the current logging level (while loading the scene)
  54201. * @ignorenaming
  54202. */
  54203. static get loggingLevel(): number;
  54204. static set loggingLevel(value: number);
  54205. /**
  54206. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  54207. */
  54208. static get CleanBoneMatrixWeights(): boolean;
  54209. static set CleanBoneMatrixWeights(value: boolean);
  54210. /**
  54211. * Event raised when a plugin is used to load a scene
  54212. */
  54213. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  54214. private static _registeredPlugins;
  54215. private static _showingLoadingScreen;
  54216. /**
  54217. * Gets the default plugin (used to load Babylon files)
  54218. * @returns the .babylon plugin
  54219. */
  54220. static GetDefaultPlugin(): IRegisteredPlugin;
  54221. private static _GetPluginForExtension;
  54222. private static _GetPluginForDirectLoad;
  54223. private static _GetPluginForFilename;
  54224. private static _GetDirectLoad;
  54225. private static _LoadData;
  54226. private static _GetFileInfo;
  54227. /**
  54228. * Gets a plugin that can load the given extension
  54229. * @param extension defines the extension to load
  54230. * @returns a plugin or null if none works
  54231. */
  54232. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  54233. /**
  54234. * Gets a boolean indicating that the given extension can be loaded
  54235. * @param extension defines the extension to load
  54236. * @returns true if the extension is supported
  54237. */
  54238. static IsPluginForExtensionAvailable(extension: string): boolean;
  54239. /**
  54240. * Adds a new plugin to the list of registered plugins
  54241. * @param plugin defines the plugin to add
  54242. */
  54243. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  54244. /**
  54245. * Import meshes into a scene
  54246. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54247. * @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)
  54248. * @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)
  54249. * @param scene the instance of BABYLON.Scene to append to
  54250. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  54251. * @param onProgress a callback with a progress event for each file being loaded
  54252. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54253. * @param pluginExtension the extension used to determine the plugin
  54254. * @returns The loaded plugin
  54255. */
  54256. 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>;
  54257. /**
  54258. * Import meshes into a scene
  54259. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54260. * @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)
  54261. * @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)
  54262. * @param scene the instance of BABYLON.Scene to append to
  54263. * @param onProgress a callback with a progress event for each file being loaded
  54264. * @param pluginExtension the extension used to determine the plugin
  54265. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  54266. */
  54267. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  54268. /**
  54269. * Load a scene
  54270. * @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)
  54271. * @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)
  54272. * @param engine is the instance of BABYLON.Engine to use to create the scene
  54273. * @param onSuccess a callback with the scene when import succeeds
  54274. * @param onProgress a callback with a progress event for each file being loaded
  54275. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54276. * @param pluginExtension the extension used to determine the plugin
  54277. * @returns The loaded plugin
  54278. */
  54279. 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>;
  54280. /**
  54281. * Load a scene
  54282. * @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)
  54283. * @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)
  54284. * @param engine is the instance of BABYLON.Engine to use to create the scene
  54285. * @param onProgress a callback with a progress event for each file being loaded
  54286. * @param pluginExtension the extension used to determine the plugin
  54287. * @returns The loaded scene
  54288. */
  54289. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  54290. /**
  54291. * Append a scene
  54292. * @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)
  54293. * @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)
  54294. * @param scene is the instance of BABYLON.Scene to append to
  54295. * @param onSuccess a callback with the scene when import succeeds
  54296. * @param onProgress a callback with a progress event for each file being loaded
  54297. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54298. * @param pluginExtension the extension used to determine the plugin
  54299. * @returns The loaded plugin
  54300. */
  54301. 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>;
  54302. /**
  54303. * Append a scene
  54304. * @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)
  54305. * @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)
  54306. * @param scene is the instance of BABYLON.Scene to append to
  54307. * @param onProgress a callback with a progress event for each file being loaded
  54308. * @param pluginExtension the extension used to determine the plugin
  54309. * @returns The given scene
  54310. */
  54311. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  54312. /**
  54313. * Load a scene into an asset container
  54314. * @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)
  54315. * @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)
  54316. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54317. * @param onSuccess a callback with the scene when import succeeds
  54318. * @param onProgress a callback with a progress event for each file being loaded
  54319. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54320. * @param pluginExtension the extension used to determine the plugin
  54321. * @returns The loaded plugin
  54322. */
  54323. 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>;
  54324. /**
  54325. * Load a scene into an asset container
  54326. * @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)
  54327. * @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)
  54328. * @param scene is the instance of Scene to append to
  54329. * @param onProgress a callback with a progress event for each file being loaded
  54330. * @param pluginExtension the extension used to determine the plugin
  54331. * @returns The loaded asset container
  54332. */
  54333. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  54334. /**
  54335. * Import animations from a file into a scene
  54336. * @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)
  54337. * @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)
  54338. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54339. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  54340. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  54341. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  54342. * @param onSuccess a callback with the scene when import succeeds
  54343. * @param onProgress a callback with a progress event for each file being loaded
  54344. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54345. * @param pluginExtension the extension used to determine the plugin
  54346. */
  54347. 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;
  54348. /**
  54349. * Import animations from a file into a scene
  54350. * @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)
  54351. * @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)
  54352. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54353. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  54354. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  54355. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  54356. * @param onSuccess a callback with the scene when import succeeds
  54357. * @param onProgress a callback with a progress event for each file being loaded
  54358. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54359. * @param pluginExtension the extension used to determine the plugin
  54360. * @returns the updated scene with imported animations
  54361. */
  54362. 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>;
  54363. }
  54364. }
  54365. declare module BABYLON {
  54366. /**
  54367. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  54368. */
  54369. export type MotionControllerHandedness = "none" | "left" | "right";
  54370. /**
  54371. * The type of components available in motion controllers.
  54372. * This is not the name of the component.
  54373. */
  54374. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  54375. /**
  54376. * The state of a controller component
  54377. */
  54378. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  54379. /**
  54380. * The schema of motion controller layout.
  54381. * No object will be initialized using this interface
  54382. * This is used just to define the profile.
  54383. */
  54384. export interface IMotionControllerLayout {
  54385. /**
  54386. * Path to load the assets. Usually relative to the base path
  54387. */
  54388. assetPath: string;
  54389. /**
  54390. * Available components (unsorted)
  54391. */
  54392. components: {
  54393. /**
  54394. * A map of component Ids
  54395. */
  54396. [componentId: string]: {
  54397. /**
  54398. * The type of input the component outputs
  54399. */
  54400. type: MotionControllerComponentType;
  54401. /**
  54402. * The indices of this component in the gamepad object
  54403. */
  54404. gamepadIndices: {
  54405. /**
  54406. * Index of button
  54407. */
  54408. button?: number;
  54409. /**
  54410. * If available, index of x-axis
  54411. */
  54412. xAxis?: number;
  54413. /**
  54414. * If available, index of y-axis
  54415. */
  54416. yAxis?: number;
  54417. };
  54418. /**
  54419. * The mesh's root node name
  54420. */
  54421. rootNodeName: string;
  54422. /**
  54423. * Animation definitions for this model
  54424. */
  54425. visualResponses: {
  54426. [stateKey: string]: {
  54427. /**
  54428. * What property will be animated
  54429. */
  54430. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  54431. /**
  54432. * What states influence this visual response
  54433. */
  54434. states: MotionControllerComponentStateType[];
  54435. /**
  54436. * Type of animation - movement or visibility
  54437. */
  54438. valueNodeProperty: "transform" | "visibility";
  54439. /**
  54440. * Base node name to move. Its position will be calculated according to the min and max nodes
  54441. */
  54442. valueNodeName?: string;
  54443. /**
  54444. * Minimum movement node
  54445. */
  54446. minNodeName?: string;
  54447. /**
  54448. * Max movement node
  54449. */
  54450. maxNodeName?: string;
  54451. };
  54452. };
  54453. /**
  54454. * If touch enabled, what is the name of node to display user feedback
  54455. */
  54456. touchPointNodeName?: string;
  54457. };
  54458. };
  54459. /**
  54460. * Is it xr standard mapping or not
  54461. */
  54462. gamepadMapping: "" | "xr-standard";
  54463. /**
  54464. * Base root node of this entire model
  54465. */
  54466. rootNodeName: string;
  54467. /**
  54468. * Defines the main button component id
  54469. */
  54470. selectComponentId: string;
  54471. }
  54472. /**
  54473. * A definition for the layout map in the input profile
  54474. */
  54475. export interface IMotionControllerLayoutMap {
  54476. /**
  54477. * Layouts with handedness type as a key
  54478. */
  54479. [handedness: string]: IMotionControllerLayout;
  54480. }
  54481. /**
  54482. * The XR Input profile schema
  54483. * Profiles can be found here:
  54484. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  54485. */
  54486. export interface IMotionControllerProfile {
  54487. /**
  54488. * fallback profiles for this profileId
  54489. */
  54490. fallbackProfileIds: string[];
  54491. /**
  54492. * The layout map, with handedness as key
  54493. */
  54494. layouts: IMotionControllerLayoutMap;
  54495. /**
  54496. * The id of this profile
  54497. * correlates to the profile(s) in the xrInput.profiles array
  54498. */
  54499. profileId: string;
  54500. }
  54501. /**
  54502. * A helper-interface for the 3 meshes needed for controller button animation
  54503. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  54504. */
  54505. export interface IMotionControllerButtonMeshMap {
  54506. /**
  54507. * the mesh that defines the pressed value mesh position.
  54508. * This is used to find the max-position of this button
  54509. */
  54510. pressedMesh: AbstractMesh;
  54511. /**
  54512. * the mesh that defines the unpressed value mesh position.
  54513. * This is used to find the min (or initial) position of this button
  54514. */
  54515. unpressedMesh: AbstractMesh;
  54516. /**
  54517. * The mesh that will be changed when value changes
  54518. */
  54519. valueMesh: AbstractMesh;
  54520. }
  54521. /**
  54522. * A helper-interface for the 3 meshes needed for controller axis animation.
  54523. * This will be expanded when touchpad animations are fully supported
  54524. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  54525. */
  54526. export interface IMotionControllerMeshMap {
  54527. /**
  54528. * the mesh that defines the maximum value mesh position.
  54529. */
  54530. maxMesh?: AbstractMesh;
  54531. /**
  54532. * the mesh that defines the minimum value mesh position.
  54533. */
  54534. minMesh?: AbstractMesh;
  54535. /**
  54536. * The mesh that will be changed when axis value changes
  54537. */
  54538. valueMesh?: AbstractMesh;
  54539. }
  54540. /**
  54541. * The elements needed for change-detection of the gamepad objects in motion controllers
  54542. */
  54543. export interface IMinimalMotionControllerObject {
  54544. /**
  54545. * Available axes of this controller
  54546. */
  54547. axes: number[];
  54548. /**
  54549. * An array of available buttons
  54550. */
  54551. buttons: Array<{
  54552. /**
  54553. * Value of the button/trigger
  54554. */
  54555. value: number;
  54556. /**
  54557. * If the button/trigger is currently touched
  54558. */
  54559. touched: boolean;
  54560. /**
  54561. * If the button/trigger is currently pressed
  54562. */
  54563. pressed: boolean;
  54564. }>;
  54565. /**
  54566. * EXPERIMENTAL haptic support.
  54567. */
  54568. hapticActuators?: Array<{
  54569. pulse: (value: number, duration: number) => Promise<boolean>;
  54570. }>;
  54571. }
  54572. /**
  54573. * An Abstract Motion controller
  54574. * This class receives an xrInput and a profile layout and uses those to initialize the components
  54575. * Each component has an observable to check for changes in value and state
  54576. */
  54577. export abstract class WebXRAbstractMotionController implements IDisposable {
  54578. protected scene: Scene;
  54579. protected layout: IMotionControllerLayout;
  54580. /**
  54581. * The gamepad object correlating to this controller
  54582. */
  54583. gamepadObject: IMinimalMotionControllerObject;
  54584. /**
  54585. * handedness (left/right/none) of this controller
  54586. */
  54587. handedness: MotionControllerHandedness;
  54588. private _initComponent;
  54589. private _modelReady;
  54590. /**
  54591. * A map of components (WebXRControllerComponent) in this motion controller
  54592. * Components have a ComponentType and can also have both button and axis definitions
  54593. */
  54594. readonly components: {
  54595. [id: string]: WebXRControllerComponent;
  54596. };
  54597. /**
  54598. * Disable the model's animation. Can be set at any time.
  54599. */
  54600. disableAnimation: boolean;
  54601. /**
  54602. * Observers registered here will be triggered when the model of this controller is done loading
  54603. */
  54604. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  54605. /**
  54606. * The profile id of this motion controller
  54607. */
  54608. abstract profileId: string;
  54609. /**
  54610. * The root mesh of the model. It is null if the model was not yet initialized
  54611. */
  54612. rootMesh: Nullable<AbstractMesh>;
  54613. /**
  54614. * constructs a new abstract motion controller
  54615. * @param scene the scene to which the model of the controller will be added
  54616. * @param layout The profile layout to load
  54617. * @param gamepadObject The gamepad object correlating to this controller
  54618. * @param handedness handedness (left/right/none) of this controller
  54619. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  54620. */
  54621. constructor(scene: Scene, layout: IMotionControllerLayout,
  54622. /**
  54623. * The gamepad object correlating to this controller
  54624. */
  54625. gamepadObject: IMinimalMotionControllerObject,
  54626. /**
  54627. * handedness (left/right/none) of this controller
  54628. */
  54629. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  54630. /**
  54631. * Dispose this controller, the model mesh and all its components
  54632. */
  54633. dispose(): void;
  54634. /**
  54635. * Returns all components of specific type
  54636. * @param type the type to search for
  54637. * @return an array of components with this type
  54638. */
  54639. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  54640. /**
  54641. * get a component based an its component id as defined in layout.components
  54642. * @param id the id of the component
  54643. * @returns the component correlates to the id or undefined if not found
  54644. */
  54645. getComponent(id: string): WebXRControllerComponent;
  54646. /**
  54647. * Get the list of components available in this motion controller
  54648. * @returns an array of strings correlating to available components
  54649. */
  54650. getComponentIds(): string[];
  54651. /**
  54652. * Get the first component of specific type
  54653. * @param type type of component to find
  54654. * @return a controller component or null if not found
  54655. */
  54656. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  54657. /**
  54658. * Get the main (Select) component of this controller as defined in the layout
  54659. * @returns the main component of this controller
  54660. */
  54661. getMainComponent(): WebXRControllerComponent;
  54662. /**
  54663. * Loads the model correlating to this controller
  54664. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  54665. * @returns A promise fulfilled with the result of the model loading
  54666. */
  54667. loadModel(): Promise<boolean>;
  54668. /**
  54669. * Update this model using the current XRFrame
  54670. * @param xrFrame the current xr frame to use and update the model
  54671. */
  54672. updateFromXRFrame(xrFrame: XRFrame): void;
  54673. /**
  54674. * Backwards compatibility due to a deeply-integrated typo
  54675. */
  54676. get handness(): XREye;
  54677. /**
  54678. * Pulse (vibrate) this controller
  54679. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  54680. * Consecutive calls to this function will cancel the last pulse call
  54681. *
  54682. * @param value the strength of the pulse in 0.0...1.0 range
  54683. * @param duration Duration of the pulse in milliseconds
  54684. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  54685. * @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
  54686. */
  54687. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  54688. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  54689. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  54690. /**
  54691. * Moves the axis on the controller mesh based on its current state
  54692. * @param axis the index of the axis
  54693. * @param axisValue the value of the axis which determines the meshes new position
  54694. * @hidden
  54695. */
  54696. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  54697. /**
  54698. * Update the model itself with the current frame data
  54699. * @param xrFrame the frame to use for updating the model mesh
  54700. */
  54701. protected updateModel(xrFrame: XRFrame): void;
  54702. /**
  54703. * Get the filename and path for this controller's model
  54704. * @returns a map of filename and path
  54705. */
  54706. protected abstract _getFilenameAndPath(): {
  54707. filename: string;
  54708. path: string;
  54709. };
  54710. /**
  54711. * This function is called before the mesh is loaded. It checks for loading constraints.
  54712. * For example, this function can check if the GLB loader is available
  54713. * If this function returns false, the generic controller will be loaded instead
  54714. * @returns Is the client ready to load the mesh
  54715. */
  54716. protected abstract _getModelLoadingConstraints(): boolean;
  54717. /**
  54718. * This function will be called after the model was successfully loaded and can be used
  54719. * for mesh transformations before it is available for the user
  54720. * @param meshes the loaded meshes
  54721. */
  54722. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  54723. /**
  54724. * Set the root mesh for this controller. Important for the WebXR controller class
  54725. * @param meshes the loaded meshes
  54726. */
  54727. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  54728. /**
  54729. * A function executed each frame that updates the mesh (if needed)
  54730. * @param xrFrame the current xrFrame
  54731. */
  54732. protected abstract _updateModel(xrFrame: XRFrame): void;
  54733. private _getGenericFilenameAndPath;
  54734. private _getGenericParentMesh;
  54735. }
  54736. }
  54737. declare module BABYLON {
  54738. /**
  54739. * A generic trigger-only motion controller for WebXR
  54740. */
  54741. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  54742. /**
  54743. * Static version of the profile id of this controller
  54744. */
  54745. static ProfileId: string;
  54746. profileId: string;
  54747. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  54748. protected _getFilenameAndPath(): {
  54749. filename: string;
  54750. path: string;
  54751. };
  54752. protected _getModelLoadingConstraints(): boolean;
  54753. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  54754. protected _setRootMesh(meshes: AbstractMesh[]): void;
  54755. protected _updateModel(): void;
  54756. }
  54757. }
  54758. declare module BABYLON {
  54759. /**
  54760. * Class containing static functions to help procedurally build meshes
  54761. */
  54762. export class SphereBuilder {
  54763. /**
  54764. * Creates a sphere mesh
  54765. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  54766. * * 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`)
  54767. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  54768. * * 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
  54769. * * 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)
  54770. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54771. * * 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
  54772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54773. * @param name defines the name of the mesh
  54774. * @param options defines the options used to create the mesh
  54775. * @param scene defines the hosting scene
  54776. * @returns the sphere mesh
  54777. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  54778. */
  54779. static CreateSphere(name: string, options: {
  54780. segments?: number;
  54781. diameter?: number;
  54782. diameterX?: number;
  54783. diameterY?: number;
  54784. diameterZ?: number;
  54785. arc?: number;
  54786. slice?: number;
  54787. sideOrientation?: number;
  54788. frontUVs?: Vector4;
  54789. backUVs?: Vector4;
  54790. updatable?: boolean;
  54791. }, scene?: Nullable<Scene>): Mesh;
  54792. }
  54793. }
  54794. declare module BABYLON {
  54795. /**
  54796. * A profiled motion controller has its profile loaded from an online repository.
  54797. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  54798. */
  54799. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  54800. private _repositoryUrl;
  54801. private _buttonMeshMapping;
  54802. private _touchDots;
  54803. /**
  54804. * The profile ID of this controller. Will be populated when the controller initializes.
  54805. */
  54806. profileId: string;
  54807. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  54808. dispose(): void;
  54809. protected _getFilenameAndPath(): {
  54810. filename: string;
  54811. path: string;
  54812. };
  54813. protected _getModelLoadingConstraints(): boolean;
  54814. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  54815. protected _setRootMesh(meshes: AbstractMesh[]): void;
  54816. protected _updateModel(_xrFrame: XRFrame): void;
  54817. }
  54818. }
  54819. declare module BABYLON {
  54820. /**
  54821. * A construction function type to create a new controller based on an xrInput object
  54822. */
  54823. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  54824. /**
  54825. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  54826. *
  54827. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  54828. * it should be replaced with auto-loaded controllers.
  54829. *
  54830. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  54831. */
  54832. export class WebXRMotionControllerManager {
  54833. private static _AvailableControllers;
  54834. private static _Fallbacks;
  54835. private static _ProfileLoadingPromises;
  54836. private static _ProfilesList;
  54837. /**
  54838. * The base URL of the online controller repository. Can be changed at any time.
  54839. */
  54840. static BaseRepositoryUrl: string;
  54841. /**
  54842. * Which repository gets priority - local or online
  54843. */
  54844. static PrioritizeOnlineRepository: boolean;
  54845. /**
  54846. * Use the online repository, or use only locally-defined controllers
  54847. */
  54848. static UseOnlineRepository: boolean;
  54849. /**
  54850. * Clear the cache used for profile loading and reload when requested again
  54851. */
  54852. static ClearProfilesCache(): void;
  54853. /**
  54854. * Register the default fallbacks.
  54855. * This function is called automatically when this file is imported.
  54856. */
  54857. static DefaultFallbacks(): void;
  54858. /**
  54859. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  54860. * @param profileId the profile to which a fallback needs to be found
  54861. * @return an array with corresponding fallback profiles
  54862. */
  54863. static FindFallbackWithProfileId(profileId: string): string[];
  54864. /**
  54865. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  54866. * The order of search:
  54867. *
  54868. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  54869. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  54870. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  54871. * 4) return the generic trigger controller if none were found
  54872. *
  54873. * @param xrInput the xrInput to which a new controller is initialized
  54874. * @param scene the scene to which the model will be added
  54875. * @param forceProfile force a certain profile for this controller
  54876. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  54877. */
  54878. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  54879. /**
  54880. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  54881. *
  54882. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  54883. *
  54884. * @param type the profile type to register
  54885. * @param constructFunction the function to be called when loading this profile
  54886. */
  54887. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  54888. /**
  54889. * Register a fallback to a specific profile.
  54890. * @param profileId the profileId that will receive the fallbacks
  54891. * @param fallbacks A list of fallback profiles
  54892. */
  54893. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  54894. /**
  54895. * Will update the list of profiles available in the repository
  54896. * @return a promise that resolves to a map of profiles available online
  54897. */
  54898. static UpdateProfilesList(): Promise<{
  54899. [profile: string]: string;
  54900. }>;
  54901. private static _LoadProfileFromRepository;
  54902. private static _LoadProfilesFromAvailableControllers;
  54903. }
  54904. }
  54905. declare module BABYLON {
  54906. /**
  54907. * Configuration options for the WebXR controller creation
  54908. */
  54909. export interface IWebXRControllerOptions {
  54910. /**
  54911. * Should the controller mesh be animated when a user interacts with it
  54912. * The pressed buttons / thumbstick and touchpad animations will be disabled
  54913. */
  54914. disableMotionControllerAnimation?: boolean;
  54915. /**
  54916. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  54917. */
  54918. doNotLoadControllerMesh?: boolean;
  54919. /**
  54920. * Force a specific controller type for this controller.
  54921. * This can be used when creating your own profile or when testing different controllers
  54922. */
  54923. forceControllerProfile?: string;
  54924. /**
  54925. * Defines a rendering group ID for meshes that will be loaded.
  54926. * This is for the default controllers only.
  54927. */
  54928. renderingGroupId?: number;
  54929. }
  54930. /**
  54931. * Represents an XR controller
  54932. */
  54933. export class WebXRInputSource {
  54934. private _scene;
  54935. /** The underlying input source for the controller */
  54936. inputSource: XRInputSource;
  54937. private _options;
  54938. private _tmpVector;
  54939. private _uniqueId;
  54940. private _disposed;
  54941. /**
  54942. * Represents the part of the controller that is held. This may not exist if the controller is the head mounted display itself, if thats the case only the pointer from the head will be availible
  54943. */
  54944. grip?: AbstractMesh;
  54945. /**
  54946. * If available, this is the gamepad object related to this controller.
  54947. * Using this object it is possible to get click events and trackpad changes of the
  54948. * webxr controller that is currently being used.
  54949. */
  54950. motionController?: WebXRAbstractMotionController;
  54951. /**
  54952. * Event that fires when the controller is removed/disposed.
  54953. * The object provided as event data is this controller, after associated assets were disposed.
  54954. * uniqueId is still available.
  54955. */
  54956. onDisposeObservable: Observable<WebXRInputSource>;
  54957. /**
  54958. * Will be triggered when the mesh associated with the motion controller is done loading.
  54959. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  54960. * A shortened version of controller -> motion controller -> on mesh loaded.
  54961. */
  54962. onMeshLoadedObservable: Observable<AbstractMesh>;
  54963. /**
  54964. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  54965. */
  54966. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  54967. /**
  54968. * Pointer which can be used to select objects or attach a visible laser to
  54969. */
  54970. pointer: AbstractMesh;
  54971. /**
  54972. * Creates the input source object
  54973. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  54974. * @param _scene the scene which the controller should be associated to
  54975. * @param inputSource the underlying input source for the controller
  54976. * @param _options options for this controller creation
  54977. */
  54978. constructor(_scene: Scene,
  54979. /** The underlying input source for the controller */
  54980. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  54981. /**
  54982. * Get this controllers unique id
  54983. */
  54984. get uniqueId(): string;
  54985. /**
  54986. * Disposes of the object
  54987. */
  54988. dispose(): void;
  54989. /**
  54990. * Gets a world space ray coming from the pointer or grip
  54991. * @param result the resulting ray
  54992. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  54993. */
  54994. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  54995. /**
  54996. * Updates the controller pose based on the given XRFrame
  54997. * @param xrFrame xr frame to update the pose with
  54998. * @param referenceSpace reference space to use
  54999. */
  55000. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  55001. }
  55002. }
  55003. declare module BABYLON {
  55004. /**
  55005. * The schema for initialization options of the XR Input class
  55006. */
  55007. export interface IWebXRInputOptions {
  55008. /**
  55009. * If set to true no model will be automatically loaded
  55010. */
  55011. doNotLoadControllerMeshes?: boolean;
  55012. /**
  55013. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  55014. * If not found, the xr input profile data will be used.
  55015. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  55016. */
  55017. forceInputProfile?: string;
  55018. /**
  55019. * Do not send a request to the controller repository to load the profile.
  55020. *
  55021. * Instead, use the controllers available in babylon itself.
  55022. */
  55023. disableOnlineControllerRepository?: boolean;
  55024. /**
  55025. * A custom URL for the controllers repository
  55026. */
  55027. customControllersRepositoryURL?: string;
  55028. /**
  55029. * Should the controller model's components not move according to the user input
  55030. */
  55031. disableControllerAnimation?: boolean;
  55032. /**
  55033. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  55034. */
  55035. controllerOptions?: IWebXRControllerOptions;
  55036. }
  55037. /**
  55038. * XR input used to track XR inputs such as controllers/rays
  55039. */
  55040. export class WebXRInput implements IDisposable {
  55041. /**
  55042. * the xr session manager for this session
  55043. */
  55044. xrSessionManager: WebXRSessionManager;
  55045. /**
  55046. * the WebXR camera for this session. Mainly used for teleportation
  55047. */
  55048. xrCamera: WebXRCamera;
  55049. private readonly options;
  55050. /**
  55051. * XR controllers being tracked
  55052. */
  55053. controllers: Array<WebXRInputSource>;
  55054. private _frameObserver;
  55055. private _sessionEndedObserver;
  55056. private _sessionInitObserver;
  55057. /**
  55058. * Event when a controller has been connected/added
  55059. */
  55060. onControllerAddedObservable: Observable<WebXRInputSource>;
  55061. /**
  55062. * Event when a controller has been removed/disconnected
  55063. */
  55064. onControllerRemovedObservable: Observable<WebXRInputSource>;
  55065. /**
  55066. * Initializes the WebXRInput
  55067. * @param xrSessionManager the xr session manager for this session
  55068. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  55069. * @param options = initialization options for this xr input
  55070. */
  55071. constructor(
  55072. /**
  55073. * the xr session manager for this session
  55074. */
  55075. xrSessionManager: WebXRSessionManager,
  55076. /**
  55077. * the WebXR camera for this session. Mainly used for teleportation
  55078. */
  55079. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  55080. private _onInputSourcesChange;
  55081. private _addAndRemoveControllers;
  55082. /**
  55083. * Disposes of the object
  55084. */
  55085. dispose(): void;
  55086. }
  55087. }
  55088. declare module BABYLON {
  55089. /**
  55090. * This is the base class for all WebXR features.
  55091. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  55092. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  55093. */
  55094. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  55095. protected _xrSessionManager: WebXRSessionManager;
  55096. private _attached;
  55097. private _removeOnDetach;
  55098. /**
  55099. * Is this feature disposed?
  55100. */
  55101. isDisposed: boolean;
  55102. /**
  55103. * Should auto-attach be disabled?
  55104. */
  55105. disableAutoAttach: boolean;
  55106. /**
  55107. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  55108. */
  55109. xrNativeFeatureName: string;
  55110. /**
  55111. * Construct a new (abstract) WebXR feature
  55112. * @param _xrSessionManager the xr session manager for this feature
  55113. */
  55114. constructor(_xrSessionManager: WebXRSessionManager);
  55115. /**
  55116. * Is this feature attached
  55117. */
  55118. get attached(): boolean;
  55119. /**
  55120. * attach this feature
  55121. *
  55122. * @param force should attachment be forced (even when already attached)
  55123. * @returns true if successful, false is failed or already attached
  55124. */
  55125. attach(force?: boolean): boolean;
  55126. /**
  55127. * detach this feature.
  55128. *
  55129. * @returns true if successful, false if failed or already detached
  55130. */
  55131. detach(): boolean;
  55132. /**
  55133. * Dispose this feature and all of the resources attached
  55134. */
  55135. dispose(): void;
  55136. /**
  55137. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  55138. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  55139. *
  55140. * @returns whether or not the feature is compatible in this environment
  55141. */
  55142. isCompatible(): boolean;
  55143. /**
  55144. * This is used to register callbacks that will automatically be removed when detach is called.
  55145. * @param observable the observable to which the observer will be attached
  55146. * @param callback the callback to register
  55147. */
  55148. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  55149. /**
  55150. * Code in this function will be executed on each xrFrame received from the browser.
  55151. * This function will not execute after the feature is detached.
  55152. * @param _xrFrame the current frame
  55153. */
  55154. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  55155. }
  55156. }
  55157. declare module BABYLON {
  55158. /**
  55159. * Renders a layer on top of an existing scene
  55160. */
  55161. export class UtilityLayerRenderer implements IDisposable {
  55162. /** the original scene that will be rendered on top of */
  55163. originalScene: Scene;
  55164. private _pointerCaptures;
  55165. private _lastPointerEvents;
  55166. private static _DefaultUtilityLayer;
  55167. private static _DefaultKeepDepthUtilityLayer;
  55168. private _sharedGizmoLight;
  55169. private _renderCamera;
  55170. /**
  55171. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  55172. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  55173. * @returns the camera that is used when rendering the utility layer
  55174. */
  55175. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  55176. /**
  55177. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  55178. * @param cam the camera that should be used when rendering the utility layer
  55179. */
  55180. setRenderCamera(cam: Nullable<Camera>): void;
  55181. /**
  55182. * @hidden
  55183. * Light which used by gizmos to get light shading
  55184. */
  55185. _getSharedGizmoLight(): HemisphericLight;
  55186. /**
  55187. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  55188. */
  55189. pickUtilitySceneFirst: boolean;
  55190. /**
  55191. * 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)
  55192. */
  55193. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  55194. /**
  55195. * 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)
  55196. */
  55197. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  55198. /**
  55199. * The scene that is rendered on top of the original scene
  55200. */
  55201. utilityLayerScene: Scene;
  55202. /**
  55203. * If the utility layer should automatically be rendered on top of existing scene
  55204. */
  55205. shouldRender: boolean;
  55206. /**
  55207. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  55208. */
  55209. onlyCheckPointerDownEvents: boolean;
  55210. /**
  55211. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  55212. */
  55213. processAllEvents: boolean;
  55214. /**
  55215. * Observable raised when the pointer move from the utility layer scene to the main scene
  55216. */
  55217. onPointerOutObservable: Observable<number>;
  55218. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  55219. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  55220. private _afterRenderObserver;
  55221. private _sceneDisposeObserver;
  55222. private _originalPointerObserver;
  55223. /**
  55224. * Instantiates a UtilityLayerRenderer
  55225. * @param originalScene the original scene that will be rendered on top of
  55226. * @param handleEvents boolean indicating if the utility layer should handle events
  55227. */
  55228. constructor(
  55229. /** the original scene that will be rendered on top of */
  55230. originalScene: Scene, handleEvents?: boolean);
  55231. private _notifyObservers;
  55232. /**
  55233. * Renders the utility layers scene on top of the original scene
  55234. */
  55235. render(): void;
  55236. /**
  55237. * Disposes of the renderer
  55238. */
  55239. dispose(): void;
  55240. private _updateCamera;
  55241. }
  55242. }
  55243. declare module BABYLON {
  55244. /**
  55245. * Options interface for the pointer selection module
  55246. */
  55247. export interface IWebXRControllerPointerSelectionOptions {
  55248. /**
  55249. * if provided, this scene will be used to render meshes.
  55250. */
  55251. customUtilityLayerScene?: Scene;
  55252. /**
  55253. * 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)
  55254. * If not disabled, the last picked point will be used to execute a pointer up event
  55255. * If disabled, pointer up event will be triggered right after the pointer down event.
  55256. * Used in screen and gaze target ray mode only
  55257. */
  55258. disablePointerUpOnTouchOut: boolean;
  55259. /**
  55260. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  55261. */
  55262. forceGazeMode: boolean;
  55263. /**
  55264. * 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
  55265. * to start a new countdown to the pointer down event.
  55266. * Defaults to 1.
  55267. */
  55268. gazeModePointerMovedFactor?: number;
  55269. /**
  55270. * Different button type to use instead of the main component
  55271. */
  55272. overrideButtonId?: string;
  55273. /**
  55274. * use this rendering group id for the meshes (optional)
  55275. */
  55276. renderingGroupId?: number;
  55277. /**
  55278. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  55279. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  55280. * 3000 means 3 seconds between pointing at something and selecting it
  55281. */
  55282. timeToSelect?: number;
  55283. /**
  55284. * Should meshes created here be added to a utility layer or the main scene
  55285. */
  55286. useUtilityLayer?: boolean;
  55287. /**
  55288. * Optional WebXR camera to be used for gaze selection
  55289. */
  55290. gazeCamera?: WebXRCamera;
  55291. /**
  55292. * the xr input to use with this pointer selection
  55293. */
  55294. xrInput: WebXRInput;
  55295. /**
  55296. * Should the scene pointerX and pointerY update be disabled
  55297. * This is required for fullscreen AR GUI, but might slow down other experiences.
  55298. * Disable in VR, if not needed.
  55299. * The first rig camera (left eye) will be used to calculate the projection
  55300. */
  55301. disableScenePointerVectorUpdate: boolean;
  55302. /**
  55303. * Enable pointer selection on all controllers instead of switching between them
  55304. */
  55305. enablePointerSelectionOnAllControllers?: boolean;
  55306. /**
  55307. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  55308. * If switch is enabled, it will still allow the user to switch between the different controllers
  55309. */
  55310. preferredHandedness?: XRHandedness;
  55311. /**
  55312. * Disable switching the pointer selection from one controller to the other.
  55313. * 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
  55314. */
  55315. disableSwitchOnClick?: boolean;
  55316. /**
  55317. * The maximum distance of the pointer selection feature. Defaults to 100.
  55318. */
  55319. maxPointerDistance?: number;
  55320. }
  55321. /**
  55322. * A module that will enable pointer selection for motion controllers of XR Input Sources
  55323. */
  55324. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  55325. private readonly _options;
  55326. private static _idCounter;
  55327. private _attachController;
  55328. private _controllers;
  55329. private _scene;
  55330. private _tmpVectorForPickCompare;
  55331. private _attachedController;
  55332. /**
  55333. * The module's name
  55334. */
  55335. static readonly Name: string;
  55336. /**
  55337. * The (Babylon) version of this module.
  55338. * This is an integer representing the implementation version.
  55339. * This number does not correspond to the WebXR specs version
  55340. */
  55341. static readonly Version: number;
  55342. /**
  55343. * Disable lighting on the laser pointer (so it will always be visible)
  55344. */
  55345. disablePointerLighting: boolean;
  55346. /**
  55347. * Disable lighting on the selection mesh (so it will always be visible)
  55348. */
  55349. disableSelectionMeshLighting: boolean;
  55350. /**
  55351. * Should the laser pointer be displayed
  55352. */
  55353. displayLaserPointer: boolean;
  55354. /**
  55355. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  55356. */
  55357. displaySelectionMesh: boolean;
  55358. /**
  55359. * This color will be set to the laser pointer when selection is triggered
  55360. */
  55361. laserPointerPickedColor: Color3;
  55362. /**
  55363. * Default color of the laser pointer
  55364. */
  55365. laserPointerDefaultColor: Color3;
  55366. /**
  55367. * default color of the selection ring
  55368. */
  55369. selectionMeshDefaultColor: Color3;
  55370. /**
  55371. * This color will be applied to the selection ring when selection is triggered
  55372. */
  55373. selectionMeshPickedColor: Color3;
  55374. /**
  55375. * Optional filter to be used for ray selection. This predicate shares behavior with
  55376. * scene.pointerMovePredicate which takes priority if it is also assigned.
  55377. */
  55378. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  55379. /**
  55380. * constructs a new background remover module
  55381. * @param _xrSessionManager the session manager for this module
  55382. * @param _options read-only options to be used in this module
  55383. */
  55384. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  55385. /**
  55386. * attach this feature
  55387. * Will usually be called by the features manager
  55388. *
  55389. * @returns true if successful.
  55390. */
  55391. attach(): boolean;
  55392. /**
  55393. * detach this feature.
  55394. * Will usually be called by the features manager
  55395. *
  55396. * @returns true if successful.
  55397. */
  55398. detach(): boolean;
  55399. /**
  55400. * Will get the mesh under a specific pointer.
  55401. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  55402. * @param controllerId the controllerId to check
  55403. * @returns The mesh under pointer or null if no mesh is under the pointer
  55404. */
  55405. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  55406. /**
  55407. * Get the xr controller that correlates to the pointer id in the pointer event
  55408. *
  55409. * @param id the pointer id to search for
  55410. * @returns the controller that correlates to this id or null if not found
  55411. */
  55412. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  55413. private _identityMatrix;
  55414. private _screenCoordinatesRef;
  55415. private _viewportRef;
  55416. protected _onXRFrame(_xrFrame: XRFrame): void;
  55417. private _attachGazeMode;
  55418. private _attachScreenRayMode;
  55419. private _attachTrackedPointerRayMode;
  55420. private _convertNormalToDirectionOfRay;
  55421. private _detachController;
  55422. private _generateNewMeshPair;
  55423. private _pickingMoved;
  55424. private _updatePointerDistance;
  55425. /** @hidden */
  55426. get lasterPointerDefaultColor(): Color3;
  55427. }
  55428. }
  55429. declare module BABYLON {
  55430. /**
  55431. * Button which can be used to enter a different mode of XR
  55432. */
  55433. export class WebXREnterExitUIButton {
  55434. /** button element */
  55435. element: HTMLElement;
  55436. /** XR initialization options for the button */
  55437. sessionMode: XRSessionMode;
  55438. /** Reference space type */
  55439. referenceSpaceType: XRReferenceSpaceType;
  55440. /**
  55441. * Creates a WebXREnterExitUIButton
  55442. * @param element button element
  55443. * @param sessionMode XR initialization session mode
  55444. * @param referenceSpaceType the type of reference space to be used
  55445. */
  55446. constructor(
  55447. /** button element */
  55448. element: HTMLElement,
  55449. /** XR initialization options for the button */
  55450. sessionMode: XRSessionMode,
  55451. /** Reference space type */
  55452. referenceSpaceType: XRReferenceSpaceType);
  55453. /**
  55454. * Extendable function which can be used to update the button's visuals when the state changes
  55455. * @param activeButton the current active button in the UI
  55456. */
  55457. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  55458. }
  55459. /**
  55460. * Options to create the webXR UI
  55461. */
  55462. export class WebXREnterExitUIOptions {
  55463. /**
  55464. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  55465. */
  55466. customButtons?: Array<WebXREnterExitUIButton>;
  55467. /**
  55468. * A reference space type to use when creating the default button.
  55469. * Default is local-floor
  55470. */
  55471. referenceSpaceType?: XRReferenceSpaceType;
  55472. /**
  55473. * Context to enter xr with
  55474. */
  55475. renderTarget?: Nullable<WebXRRenderTarget>;
  55476. /**
  55477. * A session mode to use when creating the default button.
  55478. * Default is immersive-vr
  55479. */
  55480. sessionMode?: XRSessionMode;
  55481. /**
  55482. * A list of optional features to init the session with
  55483. */
  55484. optionalFeatures?: string[];
  55485. /**
  55486. * A list of optional features to init the session with
  55487. */
  55488. requiredFeatures?: string[];
  55489. /**
  55490. * If defined, this function will be executed if the UI encounters an error when entering XR
  55491. */
  55492. onError?: (error: any) => void;
  55493. }
  55494. /**
  55495. * UI to allow the user to enter/exit XR mode
  55496. */
  55497. export class WebXREnterExitUI implements IDisposable {
  55498. private scene;
  55499. /** version of the options passed to this UI */
  55500. options: WebXREnterExitUIOptions;
  55501. private _activeButton;
  55502. private _buttons;
  55503. /**
  55504. * The HTML Div Element to which buttons are added.
  55505. */
  55506. readonly overlay: HTMLDivElement;
  55507. /**
  55508. * Fired every time the active button is changed.
  55509. *
  55510. * When xr is entered via a button that launches xr that button will be the callback parameter
  55511. *
  55512. * When exiting xr the callback parameter will be null)
  55513. */
  55514. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  55515. /**
  55516. *
  55517. * @param scene babylon scene object to use
  55518. * @param options (read-only) version of the options passed to this UI
  55519. */
  55520. private constructor();
  55521. /**
  55522. * Creates UI to allow the user to enter/exit XR mode
  55523. * @param scene the scene to add the ui to
  55524. * @param helper the xr experience helper to enter/exit xr with
  55525. * @param options options to configure the UI
  55526. * @returns the created ui
  55527. */
  55528. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  55529. /**
  55530. * Disposes of the XR UI component
  55531. */
  55532. dispose(): void;
  55533. private _updateButtons;
  55534. }
  55535. }
  55536. declare module BABYLON {
  55537. /**
  55538. * Class containing static functions to help procedurally build meshes
  55539. */
  55540. export class LinesBuilder {
  55541. /**
  55542. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55543. * * 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
  55544. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55545. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55546. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55547. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55548. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55549. * * 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
  55550. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55552. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55553. * @param name defines the name of the new line system
  55554. * @param options defines the options used to create the line system
  55555. * @param scene defines the hosting scene
  55556. * @returns a new line system mesh
  55557. */
  55558. static CreateLineSystem(name: string, options: {
  55559. lines: Vector3[][];
  55560. updatable?: boolean;
  55561. instance?: Nullable<LinesMesh>;
  55562. colors?: Nullable<Color4[][]>;
  55563. useVertexAlpha?: boolean;
  55564. }, scene: Nullable<Scene>): LinesMesh;
  55565. /**
  55566. * Creates a line mesh
  55567. * 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
  55568. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55569. * * The parameter `points` is an array successive Vector3
  55570. * * 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
  55571. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55572. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55573. * * When updating an instance, remember that only point positions can change, not the number of points
  55574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55575. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55576. * @param name defines the name of the new line system
  55577. * @param options defines the options used to create the line system
  55578. * @param scene defines the hosting scene
  55579. * @returns a new line mesh
  55580. */
  55581. static CreateLines(name: string, options: {
  55582. points: Vector3[];
  55583. updatable?: boolean;
  55584. instance?: Nullable<LinesMesh>;
  55585. colors?: Color4[];
  55586. useVertexAlpha?: boolean;
  55587. }, scene?: Nullable<Scene>): LinesMesh;
  55588. /**
  55589. * Creates a dashed line mesh
  55590. * * 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
  55591. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55592. * * The parameter `points` is an array successive Vector3
  55593. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55594. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55595. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55596. * * 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
  55597. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55598. * * When updating an instance, remember that only point positions can change, not the number of points
  55599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55600. * @param name defines the name of the mesh
  55601. * @param options defines the options used to create the mesh
  55602. * @param scene defines the hosting scene
  55603. * @returns the dashed line mesh
  55604. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55605. */
  55606. static CreateDashedLines(name: string, options: {
  55607. points: Vector3[];
  55608. dashSize?: number;
  55609. gapSize?: number;
  55610. dashNb?: number;
  55611. updatable?: boolean;
  55612. instance?: LinesMesh;
  55613. useVertexAlpha?: boolean;
  55614. }, scene?: Nullable<Scene>): LinesMesh;
  55615. }
  55616. }
  55617. declare module BABYLON {
  55618. /**
  55619. * Construction options for a timer
  55620. */
  55621. export interface ITimerOptions<T> {
  55622. /**
  55623. * Time-to-end
  55624. */
  55625. timeout: number;
  55626. /**
  55627. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  55628. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  55629. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  55630. */
  55631. contextObservable: Observable<T>;
  55632. /**
  55633. * Optional parameters when adding an observer to the observable
  55634. */
  55635. observableParameters?: {
  55636. mask?: number;
  55637. insertFirst?: boolean;
  55638. scope?: any;
  55639. };
  55640. /**
  55641. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  55642. */
  55643. breakCondition?: (data?: ITimerData<T>) => boolean;
  55644. /**
  55645. * Will be triggered when the time condition has met
  55646. */
  55647. onEnded?: (data: ITimerData<any>) => void;
  55648. /**
  55649. * Will be triggered when the break condition has met (prematurely ended)
  55650. */
  55651. onAborted?: (data: ITimerData<any>) => void;
  55652. /**
  55653. * Optional function to execute on each tick (or count)
  55654. */
  55655. onTick?: (data: ITimerData<any>) => void;
  55656. }
  55657. /**
  55658. * An interface defining the data sent by the timer
  55659. */
  55660. export interface ITimerData<T> {
  55661. /**
  55662. * When did it start
  55663. */
  55664. startTime: number;
  55665. /**
  55666. * Time now
  55667. */
  55668. currentTime: number;
  55669. /**
  55670. * Time passed since started
  55671. */
  55672. deltaTime: number;
  55673. /**
  55674. * How much is completed, in [0.0...1.0].
  55675. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  55676. */
  55677. completeRate: number;
  55678. /**
  55679. * What the registered observable sent in the last count
  55680. */
  55681. payload: T;
  55682. }
  55683. /**
  55684. * The current state of the timer
  55685. */
  55686. export enum TimerState {
  55687. /**
  55688. * Timer initialized, not yet started
  55689. */
  55690. INIT = 0,
  55691. /**
  55692. * Timer started and counting
  55693. */
  55694. STARTED = 1,
  55695. /**
  55696. * Timer ended (whether aborted or time reached)
  55697. */
  55698. ENDED = 2
  55699. }
  55700. /**
  55701. * A simple version of the timer. Will take options and start the timer immediately after calling it
  55702. *
  55703. * @param options options with which to initialize this timer
  55704. */
  55705. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  55706. /**
  55707. * An advanced implementation of a timer class
  55708. */
  55709. export class AdvancedTimer<T = any> implements IDisposable {
  55710. /**
  55711. * Will notify each time the timer calculates the remaining time
  55712. */
  55713. onEachCountObservable: Observable<ITimerData<T>>;
  55714. /**
  55715. * Will trigger when the timer was aborted due to the break condition
  55716. */
  55717. onTimerAbortedObservable: Observable<ITimerData<T>>;
  55718. /**
  55719. * Will trigger when the timer ended successfully
  55720. */
  55721. onTimerEndedObservable: Observable<ITimerData<T>>;
  55722. /**
  55723. * Will trigger when the timer state has changed
  55724. */
  55725. onStateChangedObservable: Observable<TimerState>;
  55726. private _observer;
  55727. private _contextObservable;
  55728. private _observableParameters;
  55729. private _startTime;
  55730. private _timer;
  55731. private _state;
  55732. private _breakCondition;
  55733. private _timeToEnd;
  55734. private _breakOnNextTick;
  55735. /**
  55736. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  55737. * @param options construction options for this advanced timer
  55738. */
  55739. constructor(options: ITimerOptions<T>);
  55740. /**
  55741. * set a breaking condition for this timer. Default is to never break during count
  55742. * @param predicate the new break condition. Returns true to break, false otherwise
  55743. */
  55744. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  55745. /**
  55746. * Reset ALL associated observables in this advanced timer
  55747. */
  55748. clearObservables(): void;
  55749. /**
  55750. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  55751. *
  55752. * @param timeToEnd how much time to measure until timer ended
  55753. */
  55754. start(timeToEnd?: number): void;
  55755. /**
  55756. * Will force a stop on the next tick.
  55757. */
  55758. stop(): void;
  55759. /**
  55760. * Dispose this timer, clearing all resources
  55761. */
  55762. dispose(): void;
  55763. private _setState;
  55764. private _tick;
  55765. private _stop;
  55766. }
  55767. }
  55768. declare module BABYLON {
  55769. /**
  55770. * The options container for the teleportation module
  55771. */
  55772. export interface IWebXRTeleportationOptions {
  55773. /**
  55774. * if provided, this scene will be used to render meshes.
  55775. */
  55776. customUtilityLayerScene?: Scene;
  55777. /**
  55778. * Values to configure the default target mesh
  55779. */
  55780. defaultTargetMeshOptions?: {
  55781. /**
  55782. * Fill color of the teleportation area
  55783. */
  55784. teleportationFillColor?: string;
  55785. /**
  55786. * Border color for the teleportation area
  55787. */
  55788. teleportationBorderColor?: string;
  55789. /**
  55790. * Disable the mesh's animation sequence
  55791. */
  55792. disableAnimation?: boolean;
  55793. /**
  55794. * Disable lighting on the material or the ring and arrow
  55795. */
  55796. disableLighting?: boolean;
  55797. /**
  55798. * Override the default material of the torus and arrow
  55799. */
  55800. torusArrowMaterial?: Material;
  55801. };
  55802. /**
  55803. * A list of meshes to use as floor meshes.
  55804. * Meshes can be added and removed after initializing the feature using the
  55805. * addFloorMesh and removeFloorMesh functions
  55806. * If empty, rotation will still work
  55807. */
  55808. floorMeshes?: AbstractMesh[];
  55809. /**
  55810. * use this rendering group id for the meshes (optional)
  55811. */
  55812. renderingGroupId?: number;
  55813. /**
  55814. * Should teleportation move only to snap points
  55815. */
  55816. snapPointsOnly?: boolean;
  55817. /**
  55818. * An array of points to which the teleportation will snap to.
  55819. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  55820. */
  55821. snapPositions?: Vector3[];
  55822. /**
  55823. * How close should the teleportation ray be in order to snap to position.
  55824. * Default to 0.8 units (meters)
  55825. */
  55826. snapToPositionRadius?: number;
  55827. /**
  55828. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  55829. * If you want to support rotation, make sure your mesh has a direction indicator.
  55830. *
  55831. * When left untouched, the default mesh will be initialized.
  55832. */
  55833. teleportationTargetMesh?: AbstractMesh;
  55834. /**
  55835. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  55836. */
  55837. timeToTeleport?: number;
  55838. /**
  55839. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  55840. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  55841. */
  55842. useMainComponentOnly?: boolean;
  55843. /**
  55844. * Should meshes created here be added to a utility layer or the main scene
  55845. */
  55846. useUtilityLayer?: boolean;
  55847. /**
  55848. * Babylon XR Input class for controller
  55849. */
  55850. xrInput: WebXRInput;
  55851. /**
  55852. * Meshes that the teleportation ray cannot go through
  55853. */
  55854. pickBlockerMeshes?: AbstractMesh[];
  55855. /**
  55856. * Should teleport work only on a specific hand?
  55857. */
  55858. forceHandedness?: XRHandedness;
  55859. /**
  55860. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  55861. */
  55862. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  55863. }
  55864. /**
  55865. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  55866. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  55867. * the input of the attached controllers.
  55868. */
  55869. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  55870. private _options;
  55871. private _controllers;
  55872. private _currentTeleportationControllerId;
  55873. private _floorMeshes;
  55874. private _quadraticBezierCurve;
  55875. private _selectionFeature;
  55876. private _snapToPositions;
  55877. private _snappedToPoint;
  55878. private _teleportationRingMaterial?;
  55879. private _tmpRay;
  55880. private _tmpVector;
  55881. private _tmpQuaternion;
  55882. /**
  55883. * The module's name
  55884. */
  55885. static readonly Name: string;
  55886. /**
  55887. * The (Babylon) version of this module.
  55888. * This is an integer representing the implementation version.
  55889. * This number does not correspond to the webxr specs version
  55890. */
  55891. static readonly Version: number;
  55892. /**
  55893. * Is movement backwards enabled
  55894. */
  55895. backwardsMovementEnabled: boolean;
  55896. /**
  55897. * Distance to travel when moving backwards
  55898. */
  55899. backwardsTeleportationDistance: number;
  55900. /**
  55901. * The distance from the user to the inspection point in the direction of the controller
  55902. * A higher number will allow the user to move further
  55903. * defaults to 5 (meters, in xr units)
  55904. */
  55905. parabolicCheckRadius: number;
  55906. /**
  55907. * Should the module support parabolic ray on top of direct ray
  55908. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  55909. * Very helpful when moving between floors / different heights
  55910. */
  55911. parabolicRayEnabled: boolean;
  55912. /**
  55913. * The second type of ray - straight line.
  55914. * Should it be enabled or should the parabolic line be the only one.
  55915. */
  55916. straightRayEnabled: boolean;
  55917. /**
  55918. * How much rotation should be applied when rotating right and left
  55919. */
  55920. rotationAngle: number;
  55921. private _rotationEnabled;
  55922. /**
  55923. * Is rotation enabled when moving forward?
  55924. * Disabling this feature will prevent the user from deciding the direction when teleporting
  55925. */
  55926. get rotationEnabled(): boolean;
  55927. /**
  55928. * Sets wether rotation is enabled or not
  55929. * @param enabled is rotation enabled when teleportation is shown
  55930. */
  55931. set rotationEnabled(enabled: boolean);
  55932. /**
  55933. * Exposes the currently set teleportation target mesh.
  55934. */
  55935. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  55936. /**
  55937. * constructs a new anchor system
  55938. * @param _xrSessionManager an instance of WebXRSessionManager
  55939. * @param _options configuration object for this feature
  55940. */
  55941. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  55942. /**
  55943. * Get the snapPointsOnly flag
  55944. */
  55945. get snapPointsOnly(): boolean;
  55946. /**
  55947. * Sets the snapPointsOnly flag
  55948. * @param snapToPoints should teleportation be exclusively to snap points
  55949. */
  55950. set snapPointsOnly(snapToPoints: boolean);
  55951. /**
  55952. * Add a new mesh to the floor meshes array
  55953. * @param mesh the mesh to use as floor mesh
  55954. */
  55955. addFloorMesh(mesh: AbstractMesh): void;
  55956. /**
  55957. * Add a new snap-to point to fix teleportation to this position
  55958. * @param newSnapPoint The new Snap-To point
  55959. */
  55960. addSnapPoint(newSnapPoint: Vector3): void;
  55961. attach(): boolean;
  55962. detach(): boolean;
  55963. dispose(): void;
  55964. /**
  55965. * Remove a mesh from the floor meshes array
  55966. * @param mesh the mesh to remove
  55967. */
  55968. removeFloorMesh(mesh: AbstractMesh): void;
  55969. /**
  55970. * Remove a mesh from the floor meshes array using its name
  55971. * @param name the mesh name to remove
  55972. */
  55973. removeFloorMeshByName(name: string): void;
  55974. /**
  55975. * 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
  55976. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  55977. * @returns was the point found and removed or not
  55978. */
  55979. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  55980. /**
  55981. * This function sets a selection feature that will be disabled when
  55982. * the forward ray is shown and will be reattached when hidden.
  55983. * This is used to remove the selection rays when moving.
  55984. * @param selectionFeature the feature to disable when forward movement is enabled
  55985. */
  55986. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  55987. protected _onXRFrame(_xrFrame: XRFrame): void;
  55988. private _attachController;
  55989. private _createDefaultTargetMesh;
  55990. private _detachController;
  55991. private _findClosestSnapPointWithRadius;
  55992. private _setTargetMeshPosition;
  55993. private _setTargetMeshVisibility;
  55994. private _showParabolicPath;
  55995. private _teleportForward;
  55996. }
  55997. }
  55998. declare module BABYLON {
  55999. /**
  56000. * Options for the default xr helper
  56001. */
  56002. export class WebXRDefaultExperienceOptions {
  56003. /**
  56004. * Enable or disable default UI to enter XR
  56005. */
  56006. disableDefaultUI?: boolean;
  56007. /**
  56008. * Should teleportation not initialize. defaults to false.
  56009. */
  56010. disableTeleportation?: boolean;
  56011. /**
  56012. * Floor meshes that will be used for teleport
  56013. */
  56014. floorMeshes?: Array<AbstractMesh>;
  56015. /**
  56016. * If set to true, the first frame will not be used to reset position
  56017. * The first frame is mainly used when copying transformation from the old camera
  56018. * Mainly used in AR
  56019. */
  56020. ignoreNativeCameraTransformation?: boolean;
  56021. /**
  56022. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  56023. */
  56024. inputOptions?: IWebXRInputOptions;
  56025. /**
  56026. * optional configuration for the output canvas
  56027. */
  56028. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  56029. /**
  56030. * optional UI options. This can be used among other to change session mode and reference space type
  56031. */
  56032. uiOptions?: WebXREnterExitUIOptions;
  56033. /**
  56034. * When loading teleportation and pointer select, use stable versions instead of latest.
  56035. */
  56036. useStablePlugins?: boolean;
  56037. /**
  56038. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  56039. */
  56040. renderingGroupId?: number;
  56041. /**
  56042. * A list of optional features to init the session with
  56043. * If set to true, all features we support will be added
  56044. */
  56045. optionalFeatures?: boolean | string[];
  56046. }
  56047. /**
  56048. * Default experience which provides a similar setup to the previous webVRExperience
  56049. */
  56050. export class WebXRDefaultExperience {
  56051. /**
  56052. * Base experience
  56053. */
  56054. baseExperience: WebXRExperienceHelper;
  56055. /**
  56056. * Enables ui for entering/exiting xr
  56057. */
  56058. enterExitUI: WebXREnterExitUI;
  56059. /**
  56060. * Input experience extension
  56061. */
  56062. input: WebXRInput;
  56063. /**
  56064. * Enables laser pointer and selection
  56065. */
  56066. pointerSelection: WebXRControllerPointerSelection;
  56067. /**
  56068. * Default target xr should render to
  56069. */
  56070. renderTarget: WebXRRenderTarget;
  56071. /**
  56072. * Enables teleportation
  56073. */
  56074. teleportation: WebXRMotionControllerTeleportation;
  56075. private constructor();
  56076. /**
  56077. * Creates the default xr experience
  56078. * @param scene scene
  56079. * @param options options for basic configuration
  56080. * @returns resulting WebXRDefaultExperience
  56081. */
  56082. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56083. /**
  56084. * DIsposes of the experience helper
  56085. */
  56086. dispose(): void;
  56087. }
  56088. }
  56089. declare module BABYLON {
  56090. /**
  56091. * Options to modify the vr teleportation behavior.
  56092. */
  56093. export interface VRTeleportationOptions {
  56094. /**
  56095. * The name of the mesh which should be used as the teleportation floor. (default: null)
  56096. */
  56097. floorMeshName?: string;
  56098. /**
  56099. * A list of meshes to be used as the teleportation floor. (default: empty)
  56100. */
  56101. floorMeshes?: Mesh[];
  56102. /**
  56103. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  56104. */
  56105. teleportationMode?: number;
  56106. /**
  56107. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  56108. */
  56109. teleportationTime?: number;
  56110. /**
  56111. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  56112. */
  56113. teleportationSpeed?: number;
  56114. /**
  56115. * The easing function used in the animation or null for Linear. (default CircleEase)
  56116. */
  56117. easingFunction?: EasingFunction;
  56118. }
  56119. /**
  56120. * Options to modify the vr experience helper's behavior.
  56121. */
  56122. export interface VRExperienceHelperOptions extends WebVROptions {
  56123. /**
  56124. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  56125. */
  56126. createDeviceOrientationCamera?: boolean;
  56127. /**
  56128. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  56129. */
  56130. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  56131. /**
  56132. * Uses the main button on the controller to toggle the laser casted. (default: true)
  56133. */
  56134. laserToggle?: boolean;
  56135. /**
  56136. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  56137. */
  56138. floorMeshes?: Mesh[];
  56139. /**
  56140. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  56141. */
  56142. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  56143. /**
  56144. * Defines if WebXR should be used instead of WebVR (if available)
  56145. */
  56146. useXR?: boolean;
  56147. }
  56148. /**
  56149. * Event containing information after VR has been entered
  56150. */
  56151. export class OnAfterEnteringVRObservableEvent {
  56152. /**
  56153. * If entering vr was successful
  56154. */
  56155. success: boolean;
  56156. }
  56157. /**
  56158. * Helps to quickly add VR support to an existing scene.
  56159. * See https://doc.babylonjs.com/how_to/webvr_helper
  56160. */
  56161. export class VRExperienceHelper {
  56162. /** Options to modify the vr experience helper's behavior. */
  56163. webVROptions: VRExperienceHelperOptions;
  56164. private _scene;
  56165. private _position;
  56166. private _btnVR;
  56167. private _btnVRDisplayed;
  56168. private _webVRsupported;
  56169. private _webVRready;
  56170. private _webVRrequesting;
  56171. private _webVRpresenting;
  56172. private _hasEnteredVR;
  56173. private _fullscreenVRpresenting;
  56174. private _inputElement;
  56175. private _webVRCamera;
  56176. private _vrDeviceOrientationCamera;
  56177. private _deviceOrientationCamera;
  56178. private _existingCamera;
  56179. private _onKeyDown;
  56180. private _onVrDisplayPresentChange;
  56181. private _onVRDisplayChanged;
  56182. private _onVRRequestPresentStart;
  56183. private _onVRRequestPresentComplete;
  56184. /**
  56185. * 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)
  56186. */
  56187. enableGazeEvenWhenNoPointerLock: boolean;
  56188. /**
  56189. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  56190. */
  56191. exitVROnDoubleTap: boolean;
  56192. /**
  56193. * Observable raised right before entering VR.
  56194. */
  56195. onEnteringVRObservable: Observable<VRExperienceHelper>;
  56196. /**
  56197. * Observable raised when entering VR has completed.
  56198. */
  56199. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  56200. /**
  56201. * Observable raised when exiting VR.
  56202. */
  56203. onExitingVRObservable: Observable<VRExperienceHelper>;
  56204. /**
  56205. * Observable raised when controller mesh is loaded.
  56206. */
  56207. onControllerMeshLoadedObservable: Observable<WebVRController>;
  56208. /** Return this.onEnteringVRObservable
  56209. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  56210. */
  56211. get onEnteringVR(): Observable<VRExperienceHelper>;
  56212. /** Return this.onExitingVRObservable
  56213. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  56214. */
  56215. get onExitingVR(): Observable<VRExperienceHelper>;
  56216. /** Return this.onControllerMeshLoadedObservable
  56217. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  56218. */
  56219. get onControllerMeshLoaded(): Observable<WebVRController>;
  56220. private _rayLength;
  56221. private _useCustomVRButton;
  56222. private _teleportationRequested;
  56223. private _teleportActive;
  56224. private _floorMeshName;
  56225. private _floorMeshesCollection;
  56226. private _teleportationMode;
  56227. private _teleportationTime;
  56228. private _teleportationSpeed;
  56229. private _teleportationEasing;
  56230. private _rotationAllowed;
  56231. private _teleportBackwardsVector;
  56232. private _teleportationTarget;
  56233. private _isDefaultTeleportationTarget;
  56234. private _postProcessMove;
  56235. private _teleportationFillColor;
  56236. private _teleportationBorderColor;
  56237. private _rotationAngle;
  56238. private _haloCenter;
  56239. private _cameraGazer;
  56240. private _padSensibilityUp;
  56241. private _padSensibilityDown;
  56242. private _leftController;
  56243. private _rightController;
  56244. private _gazeColor;
  56245. private _laserColor;
  56246. private _pickedLaserColor;
  56247. private _pickedGazeColor;
  56248. /**
  56249. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  56250. */
  56251. onNewMeshSelected: Observable<AbstractMesh>;
  56252. /**
  56253. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  56254. * This observable will provide the mesh and the controller used to select the mesh
  56255. */
  56256. onMeshSelectedWithController: Observable<{
  56257. mesh: AbstractMesh;
  56258. controller: WebVRController;
  56259. }>;
  56260. /**
  56261. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  56262. */
  56263. onNewMeshPicked: Observable<PickingInfo>;
  56264. private _circleEase;
  56265. /**
  56266. * Observable raised before camera teleportation
  56267. */
  56268. onBeforeCameraTeleport: Observable<Vector3>;
  56269. /**
  56270. * Observable raised after camera teleportation
  56271. */
  56272. onAfterCameraTeleport: Observable<Vector3>;
  56273. /**
  56274. * Observable raised when current selected mesh gets unselected
  56275. */
  56276. onSelectedMeshUnselected: Observable<AbstractMesh>;
  56277. private _raySelectionPredicate;
  56278. /**
  56279. * To be optionaly changed by user to define custom ray selection
  56280. */
  56281. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  56282. /**
  56283. * To be optionaly changed by user to define custom selection logic (after ray selection)
  56284. */
  56285. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56286. /**
  56287. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  56288. */
  56289. teleportationEnabled: boolean;
  56290. private _defaultHeight;
  56291. private _teleportationInitialized;
  56292. private _interactionsEnabled;
  56293. private _interactionsRequested;
  56294. private _displayGaze;
  56295. private _displayLaserPointer;
  56296. /**
  56297. * The mesh used to display where the user is going to teleport.
  56298. */
  56299. get teleportationTarget(): Mesh;
  56300. /**
  56301. * Sets the mesh to be used to display where the user is going to teleport.
  56302. */
  56303. set teleportationTarget(value: Mesh);
  56304. /**
  56305. * 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
  56306. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  56307. * See https://doc.babylonjs.com/resources/baking_transformations
  56308. */
  56309. get gazeTrackerMesh(): Mesh;
  56310. set gazeTrackerMesh(value: Mesh);
  56311. /**
  56312. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  56313. */
  56314. updateGazeTrackerScale: boolean;
  56315. /**
  56316. * If the gaze trackers color should be updated when selecting meshes
  56317. */
  56318. updateGazeTrackerColor: boolean;
  56319. /**
  56320. * If the controller laser color should be updated when selecting meshes
  56321. */
  56322. updateControllerLaserColor: boolean;
  56323. /**
  56324. * The gaze tracking mesh corresponding to the left controller
  56325. */
  56326. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  56327. /**
  56328. * The gaze tracking mesh corresponding to the right controller
  56329. */
  56330. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  56331. /**
  56332. * If the ray of the gaze should be displayed.
  56333. */
  56334. get displayGaze(): boolean;
  56335. /**
  56336. * Sets if the ray of the gaze should be displayed.
  56337. */
  56338. set displayGaze(value: boolean);
  56339. /**
  56340. * If the ray of the LaserPointer should be displayed.
  56341. */
  56342. get displayLaserPointer(): boolean;
  56343. /**
  56344. * Sets if the ray of the LaserPointer should be displayed.
  56345. */
  56346. set displayLaserPointer(value: boolean);
  56347. /**
  56348. * The deviceOrientationCamera used as the camera when not in VR.
  56349. */
  56350. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  56351. /**
  56352. * Based on the current WebVR support, returns the current VR camera used.
  56353. */
  56354. get currentVRCamera(): Nullable<Camera>;
  56355. /**
  56356. * The webVRCamera which is used when in VR.
  56357. */
  56358. get webVRCamera(): WebVRFreeCamera;
  56359. /**
  56360. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  56361. */
  56362. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  56363. /**
  56364. * The html button that is used to trigger entering into VR.
  56365. */
  56366. get vrButton(): Nullable<HTMLButtonElement>;
  56367. private get _teleportationRequestInitiated();
  56368. /**
  56369. * Defines whether or not Pointer lock should be requested when switching to
  56370. * full screen.
  56371. */
  56372. requestPointerLockOnFullScreen: boolean;
  56373. /**
  56374. * If asking to force XR, this will be populated with the default xr experience
  56375. */
  56376. xr: WebXRDefaultExperience;
  56377. /**
  56378. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  56379. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  56380. */
  56381. xrTestDone: boolean;
  56382. /**
  56383. * Instantiates a VRExperienceHelper.
  56384. * Helps to quickly add VR support to an existing scene.
  56385. * @param scene The scene the VRExperienceHelper belongs to.
  56386. * @param webVROptions Options to modify the vr experience helper's behavior.
  56387. */
  56388. constructor(scene: Scene,
  56389. /** Options to modify the vr experience helper's behavior. */
  56390. webVROptions?: VRExperienceHelperOptions);
  56391. private completeVRInit;
  56392. private _onDefaultMeshLoaded;
  56393. private _onResize;
  56394. private _onFullscreenChange;
  56395. /**
  56396. * Gets a value indicating if we are currently in VR mode.
  56397. */
  56398. get isInVRMode(): boolean;
  56399. private onVrDisplayPresentChange;
  56400. private onVRDisplayChanged;
  56401. private moveButtonToBottomRight;
  56402. private displayVRButton;
  56403. private updateButtonVisibility;
  56404. private _cachedAngularSensibility;
  56405. /**
  56406. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  56407. * Otherwise, will use the fullscreen API.
  56408. */
  56409. enterVR(): void;
  56410. /**
  56411. * Attempt to exit VR, or fullscreen.
  56412. */
  56413. exitVR(): void;
  56414. /**
  56415. * The position of the vr experience helper.
  56416. */
  56417. get position(): Vector3;
  56418. /**
  56419. * Sets the position of the vr experience helper.
  56420. */
  56421. set position(value: Vector3);
  56422. /**
  56423. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  56424. */
  56425. enableInteractions(): void;
  56426. private get _noControllerIsActive();
  56427. private beforeRender;
  56428. private _isTeleportationFloor;
  56429. /**
  56430. * Adds a floor mesh to be used for teleportation.
  56431. * @param floorMesh the mesh to be used for teleportation.
  56432. */
  56433. addFloorMesh(floorMesh: Mesh): void;
  56434. /**
  56435. * Removes a floor mesh from being used for teleportation.
  56436. * @param floorMesh the mesh to be removed.
  56437. */
  56438. removeFloorMesh(floorMesh: Mesh): void;
  56439. /**
  56440. * Enables interactions and teleportation using the VR controllers and gaze.
  56441. * @param vrTeleportationOptions options to modify teleportation behavior.
  56442. */
  56443. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  56444. private _onNewGamepadConnected;
  56445. private _tryEnableInteractionOnController;
  56446. private _onNewGamepadDisconnected;
  56447. private _enableInteractionOnController;
  56448. private _checkTeleportWithRay;
  56449. private _checkRotate;
  56450. private _checkTeleportBackwards;
  56451. private _enableTeleportationOnController;
  56452. private _createTeleportationCircles;
  56453. private _displayTeleportationTarget;
  56454. private _hideTeleportationTarget;
  56455. private _rotateCamera;
  56456. private _moveTeleportationSelectorTo;
  56457. private _workingVector;
  56458. private _workingQuaternion;
  56459. private _workingMatrix;
  56460. /**
  56461. * Time Constant Teleportation Mode
  56462. */
  56463. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  56464. /**
  56465. * Speed Constant Teleportation Mode
  56466. */
  56467. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  56468. /**
  56469. * Teleports the users feet to the desired location
  56470. * @param location The location where the user's feet should be placed
  56471. */
  56472. teleportCamera(location: Vector3): void;
  56473. private _convertNormalToDirectionOfRay;
  56474. private _castRayAndSelectObject;
  56475. private _notifySelectedMeshUnselected;
  56476. /**
  56477. * Permanently set new colors for the laser pointer
  56478. * @param color the new laser color
  56479. * @param pickedColor the new laser color when picked mesh detected
  56480. */
  56481. setLaserColor(color: Color3, pickedColor?: Color3): void;
  56482. /**
  56483. * Set lighting enabled / disabled on the laser pointer of both controllers
  56484. * @param enabled should the lighting be enabled on the laser pointer
  56485. */
  56486. setLaserLightingState(enabled?: boolean): void;
  56487. /**
  56488. * Permanently set new colors for the gaze pointer
  56489. * @param color the new gaze color
  56490. * @param pickedColor the new gaze color when picked mesh detected
  56491. */
  56492. setGazeColor(color: Color3, pickedColor?: Color3): void;
  56493. /**
  56494. * Sets the color of the laser ray from the vr controllers.
  56495. * @param color new color for the ray.
  56496. */
  56497. changeLaserColor(color: Color3): void;
  56498. /**
  56499. * Sets the color of the ray from the vr headsets gaze.
  56500. * @param color new color for the ray.
  56501. */
  56502. changeGazeColor(color: Color3): void;
  56503. /**
  56504. * Exits VR and disposes of the vr experience helper
  56505. */
  56506. dispose(): void;
  56507. /**
  56508. * Gets the name of the VRExperienceHelper class
  56509. * @returns "VRExperienceHelper"
  56510. */
  56511. getClassName(): string;
  56512. }
  56513. }
  56514. declare module BABYLON {
  56515. /**
  56516. * Contains an array of blocks representing the octree
  56517. */
  56518. export interface IOctreeContainer<T> {
  56519. /**
  56520. * Blocks within the octree
  56521. */
  56522. blocks: Array<OctreeBlock<T>>;
  56523. }
  56524. /**
  56525. * Class used to store a cell in an octree
  56526. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56527. */
  56528. export class OctreeBlock<T> {
  56529. /**
  56530. * Gets the content of the current block
  56531. */
  56532. entries: T[];
  56533. /**
  56534. * Gets the list of block children
  56535. */
  56536. blocks: Array<OctreeBlock<T>>;
  56537. private _depth;
  56538. private _maxDepth;
  56539. private _capacity;
  56540. private _minPoint;
  56541. private _maxPoint;
  56542. private _boundingVectors;
  56543. private _creationFunc;
  56544. /**
  56545. * Creates a new block
  56546. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  56547. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  56548. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  56549. * @param depth defines the current depth of this block in the octree
  56550. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  56551. * @param creationFunc defines a callback to call when an element is added to the block
  56552. */
  56553. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  56554. /**
  56555. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  56556. */
  56557. get capacity(): number;
  56558. /**
  56559. * Gets the minimum vector (in world space) of the block's bounding box
  56560. */
  56561. get minPoint(): Vector3;
  56562. /**
  56563. * Gets the maximum vector (in world space) of the block's bounding box
  56564. */
  56565. get maxPoint(): Vector3;
  56566. /**
  56567. * Add a new element to this block
  56568. * @param entry defines the element to add
  56569. */
  56570. addEntry(entry: T): void;
  56571. /**
  56572. * Remove an element from this block
  56573. * @param entry defines the element to remove
  56574. */
  56575. removeEntry(entry: T): void;
  56576. /**
  56577. * Add an array of elements to this block
  56578. * @param entries defines the array of elements to add
  56579. */
  56580. addEntries(entries: T[]): void;
  56581. /**
  56582. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  56583. * @param frustumPlanes defines the frustum planes to test
  56584. * @param selection defines the array to store current content if selection is positive
  56585. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56586. */
  56587. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  56588. /**
  56589. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  56590. * @param sphereCenter defines the bounding sphere center
  56591. * @param sphereRadius defines the bounding sphere radius
  56592. * @param selection defines the array to store current content if selection is positive
  56593. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56594. */
  56595. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  56596. /**
  56597. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  56598. * @param ray defines the ray to test with
  56599. * @param selection defines the array to store current content if selection is positive
  56600. */
  56601. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  56602. /**
  56603. * Subdivide the content into child blocks (this block will then be empty)
  56604. */
  56605. createInnerBlocks(): void;
  56606. /**
  56607. * @hidden
  56608. */
  56609. 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;
  56610. }
  56611. }
  56612. declare module BABYLON {
  56613. /**
  56614. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  56615. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56616. */
  56617. export class Octree<T> {
  56618. /** 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.) */
  56619. maxDepth: number;
  56620. /**
  56621. * Blocks within the octree containing objects
  56622. */
  56623. blocks: Array<OctreeBlock<T>>;
  56624. /**
  56625. * Content stored in the octree
  56626. */
  56627. dynamicContent: T[];
  56628. private _maxBlockCapacity;
  56629. private _selectionContent;
  56630. private _creationFunc;
  56631. /**
  56632. * Creates a octree
  56633. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56634. * @param creationFunc function to be used to instatiate the octree
  56635. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  56636. * @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.)
  56637. */
  56638. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  56639. /** 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.) */
  56640. maxDepth?: number);
  56641. /**
  56642. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  56643. * @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);
  56644. * @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);
  56645. * @param entries meshes to be added to the octree blocks
  56646. */
  56647. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  56648. /**
  56649. * Adds a mesh to the octree
  56650. * @param entry Mesh to add to the octree
  56651. */
  56652. addMesh(entry: T): void;
  56653. /**
  56654. * Remove an element from the octree
  56655. * @param entry defines the element to remove
  56656. */
  56657. removeMesh(entry: T): void;
  56658. /**
  56659. * Selects an array of meshes within the frustum
  56660. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  56661. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  56662. * @returns array of meshes within the frustum
  56663. */
  56664. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  56665. /**
  56666. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  56667. * @param sphereCenter defines the bounding sphere center
  56668. * @param sphereRadius defines the bounding sphere radius
  56669. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56670. * @returns an array of objects that intersect the sphere
  56671. */
  56672. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  56673. /**
  56674. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  56675. * @param ray defines the ray to test with
  56676. * @returns array of intersected objects
  56677. */
  56678. intersectsRay(ray: Ray): SmartArray<T>;
  56679. /**
  56680. * Adds a mesh into the octree block if it intersects the block
  56681. */
  56682. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  56683. /**
  56684. * Adds a submesh into the octree block if it intersects the block
  56685. */
  56686. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  56687. }
  56688. }
  56689. declare module BABYLON {
  56690. interface Scene {
  56691. /**
  56692. * @hidden
  56693. * Backing Filed
  56694. */
  56695. _selectionOctree: Octree<AbstractMesh>;
  56696. /**
  56697. * Gets the octree used to boost mesh selection (picking)
  56698. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56699. */
  56700. selectionOctree: Octree<AbstractMesh>;
  56701. /**
  56702. * Creates or updates the octree used to boost selection (picking)
  56703. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56704. * @param maxCapacity defines the maximum capacity per leaf
  56705. * @param maxDepth defines the maximum depth of the octree
  56706. * @returns an octree of AbstractMesh
  56707. */
  56708. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  56709. }
  56710. interface AbstractMesh {
  56711. /**
  56712. * @hidden
  56713. * Backing Field
  56714. */
  56715. _submeshesOctree: Octree<SubMesh>;
  56716. /**
  56717. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  56718. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  56719. * @param maxCapacity defines the maximum size of each block (64 by default)
  56720. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  56721. * @returns the new octree
  56722. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  56723. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56724. */
  56725. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  56726. }
  56727. /**
  56728. * Defines the octree scene component responsible to manage any octrees
  56729. * in a given scene.
  56730. */
  56731. export class OctreeSceneComponent {
  56732. /**
  56733. * The component name help to identify the component in the list of scene components.
  56734. */
  56735. readonly name: string;
  56736. /**
  56737. * The scene the component belongs to.
  56738. */
  56739. scene: Scene;
  56740. /**
  56741. * Indicates if the meshes have been checked to make sure they are isEnabled()
  56742. */
  56743. readonly checksIsEnabled: boolean;
  56744. /**
  56745. * Creates a new instance of the component for the given scene
  56746. * @param scene Defines the scene to register the component in
  56747. */
  56748. constructor(scene: Scene);
  56749. /**
  56750. * Registers the component in a given scene
  56751. */
  56752. register(): void;
  56753. /**
  56754. * Return the list of active meshes
  56755. * @returns the list of active meshes
  56756. */
  56757. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  56758. /**
  56759. * Return the list of active sub meshes
  56760. * @param mesh The mesh to get the candidates sub meshes from
  56761. * @returns the list of active sub meshes
  56762. */
  56763. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  56764. private _tempRay;
  56765. /**
  56766. * Return the list of sub meshes intersecting with a given local ray
  56767. * @param mesh defines the mesh to find the submesh for
  56768. * @param localRay defines the ray in local space
  56769. * @returns the list of intersecting sub meshes
  56770. */
  56771. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  56772. /**
  56773. * Return the list of sub meshes colliding with a collider
  56774. * @param mesh defines the mesh to find the submesh for
  56775. * @param collider defines the collider to evaluate the collision against
  56776. * @returns the list of colliding sub meshes
  56777. */
  56778. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  56779. /**
  56780. * Rebuilds the elements related to this component in case of
  56781. * context lost for instance.
  56782. */
  56783. rebuild(): void;
  56784. /**
  56785. * Disposes the component and the associated ressources.
  56786. */
  56787. dispose(): void;
  56788. }
  56789. }
  56790. declare module BABYLON {
  56791. /**
  56792. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  56793. */
  56794. export interface GizmoAxisCache {
  56795. /** Mesh used to runder the Gizmo */
  56796. gizmoMeshes: Mesh[];
  56797. /** Mesh used to detect user interaction with Gizmo */
  56798. colliderMeshes: Mesh[];
  56799. /** Material used to inicate color of gizmo mesh */
  56800. material: StandardMaterial;
  56801. /** Material used to inicate hover state of the Gizmo */
  56802. hoverMaterial: StandardMaterial;
  56803. /** Material used to inicate disabled state of the Gizmo */
  56804. disableMaterial: StandardMaterial;
  56805. /** Used to indicate Active state of the Gizmo */
  56806. active: boolean;
  56807. }
  56808. /**
  56809. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  56810. */
  56811. export class Gizmo implements IDisposable {
  56812. /** The utility layer the gizmo will be added to */
  56813. gizmoLayer: UtilityLayerRenderer;
  56814. /**
  56815. * The root mesh of the gizmo
  56816. */
  56817. _rootMesh: Mesh;
  56818. private _attachedMesh;
  56819. private _attachedNode;
  56820. /**
  56821. * Ratio for the scale of the gizmo (Default: 1)
  56822. */
  56823. protected _scaleRatio: number;
  56824. /**
  56825. * boolean updated by pointermove when a gizmo mesh is hovered
  56826. */
  56827. protected _isHovered: boolean;
  56828. /**
  56829. * Ratio for the scale of the gizmo (Default: 1)
  56830. */
  56831. set scaleRatio(value: number);
  56832. get scaleRatio(): number;
  56833. /**
  56834. * True when the mouse pointer is hovered a gizmo mesh
  56835. */
  56836. get isHovered(): boolean;
  56837. /**
  56838. * If a custom mesh has been set (Default: false)
  56839. */
  56840. protected _customMeshSet: boolean;
  56841. /**
  56842. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  56843. * * When set, interactions will be enabled
  56844. */
  56845. get attachedMesh(): Nullable<AbstractMesh>;
  56846. set attachedMesh(value: Nullable<AbstractMesh>);
  56847. /**
  56848. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  56849. * * When set, interactions will be enabled
  56850. */
  56851. get attachedNode(): Nullable<Node>;
  56852. set attachedNode(value: Nullable<Node>);
  56853. /**
  56854. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56855. * @param mesh The mesh to replace the default mesh of the gizmo
  56856. */
  56857. setCustomMesh(mesh: Mesh): void;
  56858. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  56859. /**
  56860. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  56861. */
  56862. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56863. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56864. /**
  56865. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  56866. */
  56867. updateGizmoPositionToMatchAttachedMesh: boolean;
  56868. /**
  56869. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  56870. */
  56871. updateScale: boolean;
  56872. protected _interactionsEnabled: boolean;
  56873. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56874. private _beforeRenderObserver;
  56875. private _tempQuaternion;
  56876. private _tempVector;
  56877. private _tempVector2;
  56878. private _tempMatrix1;
  56879. private _tempMatrix2;
  56880. private _rightHandtoLeftHandMatrix;
  56881. /**
  56882. * Creates a gizmo
  56883. * @param gizmoLayer The utility layer the gizmo will be added to
  56884. */
  56885. constructor(
  56886. /** The utility layer the gizmo will be added to */
  56887. gizmoLayer?: UtilityLayerRenderer);
  56888. /**
  56889. * Updates the gizmo to match the attached mesh's position/rotation
  56890. */
  56891. protected _update(): void;
  56892. /**
  56893. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  56894. * @param value Node, TransformNode or mesh
  56895. */
  56896. protected _matrixChanged(): void;
  56897. /**
  56898. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  56899. * @param gizmoLayer The utility layer the gizmo will be added to
  56900. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  56901. * @returns {Observer<PointerInfo>} pointerObserver
  56902. */
  56903. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  56904. /**
  56905. * Disposes of the gizmo
  56906. */
  56907. dispose(): void;
  56908. }
  56909. }
  56910. declare module BABYLON {
  56911. /**
  56912. * Single plane drag gizmo
  56913. */
  56914. export class PlaneDragGizmo extends Gizmo {
  56915. /**
  56916. * Drag behavior responsible for the gizmos dragging interactions
  56917. */
  56918. dragBehavior: PointerDragBehavior;
  56919. private _pointerObserver;
  56920. /**
  56921. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56922. */
  56923. snapDistance: number;
  56924. /**
  56925. * Event that fires each time the gizmo snaps to a new location.
  56926. * * snapDistance is the the change in distance
  56927. */
  56928. onSnapObservable: Observable<{
  56929. snapDistance: number;
  56930. }>;
  56931. private _gizmoMesh;
  56932. private _coloredMaterial;
  56933. private _hoverMaterial;
  56934. private _disableMaterial;
  56935. private _isEnabled;
  56936. private _parent;
  56937. private _dragging;
  56938. /** @hidden */
  56939. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  56940. /**
  56941. * Creates a PlaneDragGizmo
  56942. * @param gizmoLayer The utility layer the gizmo will be added to
  56943. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  56944. * @param color The color of the gizmo
  56945. */
  56946. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  56947. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56948. /**
  56949. * If the gizmo is enabled
  56950. */
  56951. set isEnabled(value: boolean);
  56952. get isEnabled(): boolean;
  56953. /**
  56954. * Disposes of the gizmo
  56955. */
  56956. dispose(): void;
  56957. }
  56958. }
  56959. declare module BABYLON {
  56960. /**
  56961. * Single plane rotation gizmo
  56962. */
  56963. export class PlaneRotationGizmo extends Gizmo {
  56964. /**
  56965. * Drag behavior responsible for the gizmos dragging interactions
  56966. */
  56967. dragBehavior: PointerDragBehavior;
  56968. private _pointerObserver;
  56969. /**
  56970. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56971. */
  56972. snapDistance: number;
  56973. /**
  56974. * Event that fires each time the gizmo snaps to a new location.
  56975. * * snapDistance is the the change in distance
  56976. */
  56977. onSnapObservable: Observable<{
  56978. snapDistance: number;
  56979. }>;
  56980. private _isEnabled;
  56981. private _parent;
  56982. private _coloredMaterial;
  56983. private _hoverMaterial;
  56984. private _disableMaterial;
  56985. private _gizmoMesh;
  56986. private _rotationCircle;
  56987. private _dragging;
  56988. private static _CircleConstants;
  56989. /**
  56990. * Creates a PlaneRotationGizmo
  56991. * @param gizmoLayer The utility layer the gizmo will be added to
  56992. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  56993. * @param color The color of the gizmo
  56994. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56995. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56996. * @param thickness display gizmo axis thickness
  56997. */
  56998. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  56999. /** Create Geometry for Gizmo */
  57000. private _createGizmoMesh;
  57001. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57002. private setupRotationCircle;
  57003. private updateRotationPath;
  57004. private updateRotationCircle;
  57005. /**
  57006. * If the gizmo is enabled
  57007. */
  57008. set isEnabled(value: boolean);
  57009. get isEnabled(): boolean;
  57010. /**
  57011. * Disposes of the gizmo
  57012. */
  57013. dispose(): void;
  57014. }
  57015. }
  57016. declare module BABYLON {
  57017. /**
  57018. * Gizmo that enables rotating a mesh along 3 axis
  57019. */
  57020. export class RotationGizmo extends Gizmo {
  57021. /**
  57022. * Internal gizmo used for interactions on the x axis
  57023. */
  57024. xGizmo: PlaneRotationGizmo;
  57025. /**
  57026. * Internal gizmo used for interactions on the y axis
  57027. */
  57028. yGizmo: PlaneRotationGizmo;
  57029. /**
  57030. * Internal gizmo used for interactions on the z axis
  57031. */
  57032. zGizmo: PlaneRotationGizmo;
  57033. /** Fires an event when any of it's sub gizmos are dragged */
  57034. onDragStartObservable: Observable<unknown>;
  57035. /** Fires an event when any of it's sub gizmos are released from dragging */
  57036. onDragEndObservable: Observable<unknown>;
  57037. private _meshAttached;
  57038. private _nodeAttached;
  57039. private _observables;
  57040. /** Node Caching for quick lookup */
  57041. private _gizmoAxisCache;
  57042. get attachedMesh(): Nullable<AbstractMesh>;
  57043. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57044. get attachedNode(): Nullable<Node>;
  57045. set attachedNode(node: Nullable<Node>);
  57046. protected _checkBillboardTransform(): void;
  57047. /**
  57048. * True when the mouse pointer is hovering a gizmo mesh
  57049. */
  57050. get isHovered(): boolean;
  57051. /**
  57052. * Creates a RotationGizmo
  57053. * @param gizmoLayer The utility layer the gizmo will be added to
  57054. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57055. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57056. * @param thickness display gizmo axis thickness
  57057. */
  57058. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  57059. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57060. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57061. /**
  57062. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57063. */
  57064. set snapDistance(value: number);
  57065. get snapDistance(): number;
  57066. /**
  57067. * Ratio for the scale of the gizmo (Default: 1)
  57068. */
  57069. set scaleRatio(value: number);
  57070. get scaleRatio(): number;
  57071. /**
  57072. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57073. * @param mesh Axis gizmo mesh
  57074. * @param cache Gizmo axis definition used for reactive gizmo UI
  57075. */
  57076. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57077. /**
  57078. * Disposes of the gizmo
  57079. */
  57080. dispose(): void;
  57081. /**
  57082. * CustomMeshes are not supported by this gizmo
  57083. * @param mesh The mesh to replace the default mesh of the gizmo
  57084. */
  57085. setCustomMesh(mesh: Mesh): void;
  57086. }
  57087. }
  57088. declare module BABYLON {
  57089. /**
  57090. * Class containing static functions to help procedurally build meshes
  57091. */
  57092. export class PolyhedronBuilder {
  57093. /**
  57094. * Creates a polyhedron mesh
  57095. * * 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
  57096. * * The parameter `size` (positive float, default 1) sets the polygon size
  57097. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57098. * * 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`
  57099. * * 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
  57100. * * 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)`)
  57101. * * 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
  57102. * * 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
  57103. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57104. * * 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
  57105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57106. * @param name defines the name of the mesh
  57107. * @param options defines the options used to create the mesh
  57108. * @param scene defines the hosting scene
  57109. * @returns the polyhedron mesh
  57110. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57111. */
  57112. static CreatePolyhedron(name: string, options: {
  57113. type?: number;
  57114. size?: number;
  57115. sizeX?: number;
  57116. sizeY?: number;
  57117. sizeZ?: number;
  57118. custom?: any;
  57119. faceUV?: Vector4[];
  57120. faceColors?: Color4[];
  57121. flat?: boolean;
  57122. updatable?: boolean;
  57123. sideOrientation?: number;
  57124. frontUVs?: Vector4;
  57125. backUVs?: Vector4;
  57126. }, scene?: Nullable<Scene>): Mesh;
  57127. }
  57128. }
  57129. declare module BABYLON {
  57130. /**
  57131. * Class containing static functions to help procedurally build meshes
  57132. */
  57133. export class BoxBuilder {
  57134. /**
  57135. * Creates a box mesh
  57136. * * The parameter `size` sets the size (float) of each box side (default 1)
  57137. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  57138. * * 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)
  57139. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57140. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57141. * * 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
  57142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57143. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57144. * @param name defines the name of the mesh
  57145. * @param options defines the options used to create the mesh
  57146. * @param scene defines the hosting scene
  57147. * @returns the box mesh
  57148. */
  57149. static CreateBox(name: string, options: {
  57150. size?: number;
  57151. width?: number;
  57152. height?: number;
  57153. depth?: number;
  57154. faceUV?: Vector4[];
  57155. faceColors?: Color4[];
  57156. sideOrientation?: number;
  57157. frontUVs?: Vector4;
  57158. backUVs?: Vector4;
  57159. wrap?: boolean;
  57160. topBaseAt?: number;
  57161. bottomBaseAt?: number;
  57162. updatable?: boolean;
  57163. }, scene?: Nullable<Scene>): Mesh;
  57164. }
  57165. }
  57166. declare module BABYLON {
  57167. /**
  57168. * Single axis scale gizmo
  57169. */
  57170. export class AxisScaleGizmo extends Gizmo {
  57171. /**
  57172. * Drag behavior responsible for the gizmos dragging interactions
  57173. */
  57174. dragBehavior: PointerDragBehavior;
  57175. private _pointerObserver;
  57176. /**
  57177. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57178. */
  57179. snapDistance: number;
  57180. /**
  57181. * Event that fires each time the gizmo snaps to a new location.
  57182. * * snapDistance is the the change in distance
  57183. */
  57184. onSnapObservable: Observable<{
  57185. snapDistance: number;
  57186. }>;
  57187. /**
  57188. * If the scaling operation should be done on all axis (default: false)
  57189. */
  57190. uniformScaling: boolean;
  57191. /**
  57192. * Custom sensitivity value for the drag strength
  57193. */
  57194. sensitivity: number;
  57195. private _isEnabled;
  57196. private _parent;
  57197. private _gizmoMesh;
  57198. private _coloredMaterial;
  57199. private _hoverMaterial;
  57200. private _disableMaterial;
  57201. private _dragging;
  57202. private _tmpVector;
  57203. private _tmpMatrix;
  57204. private _tmpMatrix2;
  57205. /**
  57206. * Creates an AxisScaleGizmo
  57207. * @param gizmoLayer The utility layer the gizmo will be added to
  57208. * @param dragAxis The axis which the gizmo will be able to scale on
  57209. * @param color The color of the gizmo
  57210. * @param thickness display gizmo axis thickness
  57211. */
  57212. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  57213. /** Create Geometry for Gizmo */
  57214. private _createGizmoMesh;
  57215. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57216. /**
  57217. * If the gizmo is enabled
  57218. */
  57219. set isEnabled(value: boolean);
  57220. get isEnabled(): boolean;
  57221. /**
  57222. * Disposes of the gizmo
  57223. */
  57224. dispose(): void;
  57225. /**
  57226. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  57227. * @param mesh The mesh to replace the default mesh of the gizmo
  57228. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  57229. */
  57230. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  57231. }
  57232. }
  57233. declare module BABYLON {
  57234. /**
  57235. * Gizmo that enables scaling a mesh along 3 axis
  57236. */
  57237. export class ScaleGizmo extends Gizmo {
  57238. /**
  57239. * Internal gizmo used for interactions on the x axis
  57240. */
  57241. xGizmo: AxisScaleGizmo;
  57242. /**
  57243. * Internal gizmo used for interactions on the y axis
  57244. */
  57245. yGizmo: AxisScaleGizmo;
  57246. /**
  57247. * Internal gizmo used for interactions on the z axis
  57248. */
  57249. zGizmo: AxisScaleGizmo;
  57250. /**
  57251. * Internal gizmo used to scale all axis equally
  57252. */
  57253. uniformScaleGizmo: AxisScaleGizmo;
  57254. private _meshAttached;
  57255. private _nodeAttached;
  57256. private _snapDistance;
  57257. private _uniformScalingMesh;
  57258. private _octahedron;
  57259. private _sensitivity;
  57260. private _coloredMaterial;
  57261. private _hoverMaterial;
  57262. private _disableMaterial;
  57263. private _observables;
  57264. /** Node Caching for quick lookup */
  57265. private _gizmoAxisCache;
  57266. /** Fires an event when any of it's sub gizmos are dragged */
  57267. onDragStartObservable: Observable<unknown>;
  57268. /** Fires an event when any of it's sub gizmos are released from dragging */
  57269. onDragEndObservable: Observable<unknown>;
  57270. get attachedMesh(): Nullable<AbstractMesh>;
  57271. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57272. get attachedNode(): Nullable<Node>;
  57273. set attachedNode(node: Nullable<Node>);
  57274. /**
  57275. * True when the mouse pointer is hovering a gizmo mesh
  57276. */
  57277. get isHovered(): boolean;
  57278. /**
  57279. * Creates a ScaleGizmo
  57280. * @param gizmoLayer The utility layer the gizmo will be added to
  57281. * @param thickness display gizmo axis thickness
  57282. */
  57283. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  57284. /** Create Geometry for Gizmo */
  57285. private _createUniformScaleMesh;
  57286. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57287. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57288. /**
  57289. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57290. */
  57291. set snapDistance(value: number);
  57292. get snapDistance(): number;
  57293. /**
  57294. * Ratio for the scale of the gizmo (Default: 1)
  57295. */
  57296. set scaleRatio(value: number);
  57297. get scaleRatio(): number;
  57298. /**
  57299. * Sensitivity factor for dragging (Default: 1)
  57300. */
  57301. set sensitivity(value: number);
  57302. get sensitivity(): number;
  57303. /**
  57304. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57305. * @param mesh Axis gizmo mesh
  57306. * @param cache Gizmo axis definition used for reactive gizmo UI
  57307. */
  57308. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57309. /**
  57310. * Disposes of the gizmo
  57311. */
  57312. dispose(): void;
  57313. }
  57314. }
  57315. declare module BABYLON {
  57316. /**
  57317. * Bounding box gizmo
  57318. */
  57319. export class BoundingBoxGizmo extends Gizmo {
  57320. private _lineBoundingBox;
  57321. private _rotateSpheresParent;
  57322. private _scaleBoxesParent;
  57323. private _boundingDimensions;
  57324. private _renderObserver;
  57325. private _pointerObserver;
  57326. private _scaleDragSpeed;
  57327. private _tmpQuaternion;
  57328. private _tmpVector;
  57329. private _tmpRotationMatrix;
  57330. /**
  57331. * If child meshes should be ignored when calculating the boudning box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)
  57332. */
  57333. ignoreChildren: boolean;
  57334. /**
  57335. * 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)
  57336. */
  57337. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  57338. /**
  57339. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  57340. */
  57341. rotationSphereSize: number;
  57342. /**
  57343. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  57344. */
  57345. scaleBoxSize: number;
  57346. /**
  57347. * 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)
  57348. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  57349. */
  57350. fixedDragMeshScreenSize: boolean;
  57351. /**
  57352. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  57353. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  57354. */
  57355. fixedDragMeshBoundsSize: boolean;
  57356. /**
  57357. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  57358. */
  57359. fixedDragMeshScreenSizeDistanceFactor: number;
  57360. /**
  57361. * Fired when a rotation sphere or scale box is dragged
  57362. */
  57363. onDragStartObservable: Observable<{}>;
  57364. /**
  57365. * Fired when a scale box is dragged
  57366. */
  57367. onScaleBoxDragObservable: Observable<{}>;
  57368. /**
  57369. * Fired when a scale box drag is ended
  57370. */
  57371. onScaleBoxDragEndObservable: Observable<{}>;
  57372. /**
  57373. * Fired when a rotation sphere is dragged
  57374. */
  57375. onRotationSphereDragObservable: Observable<{}>;
  57376. /**
  57377. * Fired when a rotation sphere drag is ended
  57378. */
  57379. onRotationSphereDragEndObservable: Observable<{}>;
  57380. /**
  57381. * 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)
  57382. */
  57383. scalePivot: Nullable<Vector3>;
  57384. /**
  57385. * Mesh used as a pivot to rotate the attached node
  57386. */
  57387. private _anchorMesh;
  57388. private _existingMeshScale;
  57389. private _dragMesh;
  57390. private pointerDragBehavior;
  57391. private coloredMaterial;
  57392. private hoverColoredMaterial;
  57393. /**
  57394. * Sets the color of the bounding box gizmo
  57395. * @param color the color to set
  57396. */
  57397. setColor(color: Color3): void;
  57398. /**
  57399. * Creates an BoundingBoxGizmo
  57400. * @param gizmoLayer The utility layer the gizmo will be added to
  57401. * @param color The color of the gizmo
  57402. */
  57403. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  57404. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  57405. private _selectNode;
  57406. /**
  57407. * Updates the bounding box information for the Gizmo
  57408. */
  57409. updateBoundingBox(): void;
  57410. private _updateRotationSpheres;
  57411. private _updateScaleBoxes;
  57412. /**
  57413. * Enables rotation on the specified axis and disables rotation on the others
  57414. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  57415. */
  57416. setEnabledRotationAxis(axis: string): void;
  57417. /**
  57418. * Enables/disables scaling
  57419. * @param enable if scaling should be enabled
  57420. * @param homogeneousScaling defines if scaling should only be homogeneous
  57421. */
  57422. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  57423. private _updateDummy;
  57424. /**
  57425. * Enables a pointer drag behavior on the bounding box of the gizmo
  57426. */
  57427. enableDragBehavior(): void;
  57428. /**
  57429. * Disposes of the gizmo
  57430. */
  57431. dispose(): void;
  57432. /**
  57433. * 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)
  57434. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  57435. * @returns the bounding box mesh with the passed in mesh as a child
  57436. */
  57437. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  57438. /**
  57439. * CustomMeshes are not supported by this gizmo
  57440. * @param mesh The mesh to replace the default mesh of the gizmo
  57441. */
  57442. setCustomMesh(mesh: Mesh): void;
  57443. }
  57444. }
  57445. declare module BABYLON {
  57446. /**
  57447. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  57448. */
  57449. export class GizmoManager implements IDisposable {
  57450. private scene;
  57451. /**
  57452. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  57453. */
  57454. gizmos: {
  57455. positionGizmo: Nullable<PositionGizmo>;
  57456. rotationGizmo: Nullable<RotationGizmo>;
  57457. scaleGizmo: Nullable<ScaleGizmo>;
  57458. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  57459. };
  57460. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  57461. clearGizmoOnEmptyPointerEvent: boolean;
  57462. /** Fires an event when the manager is attached to a mesh */
  57463. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  57464. /** Fires an event when the manager is attached to a node */
  57465. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  57466. private _gizmosEnabled;
  57467. private _pointerObservers;
  57468. private _attachedMesh;
  57469. private _attachedNode;
  57470. private _boundingBoxColor;
  57471. private _defaultUtilityLayer;
  57472. private _defaultKeepDepthUtilityLayer;
  57473. private _thickness;
  57474. /** Node Caching for quick lookup */
  57475. private _gizmoAxisCache;
  57476. /**
  57477. * When bounding box gizmo is enabled, this can be used to track drag/end events
  57478. */
  57479. boundingBoxDragBehavior: SixDofDragBehavior;
  57480. /**
  57481. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  57482. */
  57483. attachableMeshes: Nullable<Array<AbstractMesh>>;
  57484. /**
  57485. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  57486. */
  57487. attachableNodes: Nullable<Array<Node>>;
  57488. /**
  57489. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  57490. */
  57491. usePointerToAttachGizmos: boolean;
  57492. /**
  57493. * Utility layer that the bounding box gizmo belongs to
  57494. */
  57495. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  57496. /**
  57497. * Utility layer that all gizmos besides bounding box belong to
  57498. */
  57499. get utilityLayer(): UtilityLayerRenderer;
  57500. /**
  57501. * True when the mouse pointer is hovering a gizmo mesh
  57502. */
  57503. get isHovered(): boolean;
  57504. /**
  57505. * Instatiates a gizmo manager
  57506. * @param scene the scene to overlay the gizmos on top of
  57507. * @param thickness display gizmo axis thickness
  57508. * @param utilityLayer the layer where gizmos are rendered
  57509. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  57510. */
  57511. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  57512. /**
  57513. * Subscribes to pointer down events, for attaching and detaching mesh
  57514. * @param scene The sceme layer the observer will be added to
  57515. */
  57516. private _attachToMeshPointerObserver;
  57517. /**
  57518. * Attaches a set of gizmos to the specified mesh
  57519. * @param mesh The mesh the gizmo's should be attached to
  57520. */
  57521. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57522. /**
  57523. * Attaches a set of gizmos to the specified node
  57524. * @param node The node the gizmo's should be attached to
  57525. */
  57526. attachToNode(node: Nullable<Node>): void;
  57527. /**
  57528. * If the position gizmo is enabled
  57529. */
  57530. set positionGizmoEnabled(value: boolean);
  57531. get positionGizmoEnabled(): boolean;
  57532. /**
  57533. * If the rotation gizmo is enabled
  57534. */
  57535. set rotationGizmoEnabled(value: boolean);
  57536. get rotationGizmoEnabled(): boolean;
  57537. /**
  57538. * If the scale gizmo is enabled
  57539. */
  57540. set scaleGizmoEnabled(value: boolean);
  57541. get scaleGizmoEnabled(): boolean;
  57542. /**
  57543. * If the boundingBox gizmo is enabled
  57544. */
  57545. set boundingBoxGizmoEnabled(value: boolean);
  57546. get boundingBoxGizmoEnabled(): boolean;
  57547. /**
  57548. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57549. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  57550. */
  57551. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  57552. /**
  57553. * Disposes of the gizmo manager
  57554. */
  57555. dispose(): void;
  57556. }
  57557. }
  57558. declare module BABYLON {
  57559. /**
  57560. * Gizmo that enables dragging a mesh along 3 axis
  57561. */
  57562. export class PositionGizmo extends Gizmo {
  57563. /**
  57564. * Internal gizmo used for interactions on the x axis
  57565. */
  57566. xGizmo: AxisDragGizmo;
  57567. /**
  57568. * Internal gizmo used for interactions on the y axis
  57569. */
  57570. yGizmo: AxisDragGizmo;
  57571. /**
  57572. * Internal gizmo used for interactions on the z axis
  57573. */
  57574. zGizmo: AxisDragGizmo;
  57575. /**
  57576. * Internal gizmo used for interactions on the yz plane
  57577. */
  57578. xPlaneGizmo: PlaneDragGizmo;
  57579. /**
  57580. * Internal gizmo used for interactions on the xz plane
  57581. */
  57582. yPlaneGizmo: PlaneDragGizmo;
  57583. /**
  57584. * Internal gizmo used for interactions on the xy plane
  57585. */
  57586. zPlaneGizmo: PlaneDragGizmo;
  57587. /**
  57588. * private variables
  57589. */
  57590. private _meshAttached;
  57591. private _nodeAttached;
  57592. private _snapDistance;
  57593. private _observables;
  57594. /** Node Caching for quick lookup */
  57595. private _gizmoAxisCache;
  57596. /** Fires an event when any of it's sub gizmos are dragged */
  57597. onDragStartObservable: Observable<unknown>;
  57598. /** Fires an event when any of it's sub gizmos are released from dragging */
  57599. onDragEndObservable: Observable<unknown>;
  57600. /**
  57601. * If set to true, planar drag is enabled
  57602. */
  57603. private _planarGizmoEnabled;
  57604. get attachedMesh(): Nullable<AbstractMesh>;
  57605. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57606. get attachedNode(): Nullable<Node>;
  57607. set attachedNode(node: Nullable<Node>);
  57608. /**
  57609. * True when the mouse pointer is hovering a gizmo mesh
  57610. */
  57611. get isHovered(): boolean;
  57612. /**
  57613. * Creates a PositionGizmo
  57614. * @param gizmoLayer The utility layer the gizmo will be added to
  57615. @param thickness display gizmo axis thickness
  57616. */
  57617. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  57618. /**
  57619. * If the planar drag gizmo is enabled
  57620. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  57621. */
  57622. set planarGizmoEnabled(value: boolean);
  57623. get planarGizmoEnabled(): boolean;
  57624. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57625. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57626. /**
  57627. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57628. */
  57629. set snapDistance(value: number);
  57630. get snapDistance(): number;
  57631. /**
  57632. * Ratio for the scale of the gizmo (Default: 1)
  57633. */
  57634. set scaleRatio(value: number);
  57635. get scaleRatio(): number;
  57636. /**
  57637. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57638. * @param mesh Axis gizmo mesh
  57639. * @param cache Gizmo axis definition used for reactive gizmo UI
  57640. */
  57641. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57642. /**
  57643. * Disposes of the gizmo
  57644. */
  57645. dispose(): void;
  57646. /**
  57647. * CustomMeshes are not supported by this gizmo
  57648. * @param mesh The mesh to replace the default mesh of the gizmo
  57649. */
  57650. setCustomMesh(mesh: Mesh): void;
  57651. }
  57652. }
  57653. declare module BABYLON {
  57654. /**
  57655. * Single axis drag gizmo
  57656. */
  57657. export class AxisDragGizmo extends Gizmo {
  57658. /**
  57659. * Drag behavior responsible for the gizmos dragging interactions
  57660. */
  57661. dragBehavior: PointerDragBehavior;
  57662. private _pointerObserver;
  57663. /**
  57664. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57665. */
  57666. snapDistance: number;
  57667. /**
  57668. * Event that fires each time the gizmo snaps to a new location.
  57669. * * snapDistance is the the change in distance
  57670. */
  57671. onSnapObservable: Observable<{
  57672. snapDistance: number;
  57673. }>;
  57674. private _isEnabled;
  57675. private _parent;
  57676. private _gizmoMesh;
  57677. private _coloredMaterial;
  57678. private _hoverMaterial;
  57679. private _disableMaterial;
  57680. private _dragging;
  57681. /** @hidden */
  57682. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  57683. /** @hidden */
  57684. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  57685. /**
  57686. * Creates an AxisDragGizmo
  57687. * @param gizmoLayer The utility layer the gizmo will be added to
  57688. * @param dragAxis The axis which the gizmo will be able to drag on
  57689. * @param color The color of the gizmo
  57690. * @param thickness display gizmo axis thickness
  57691. */
  57692. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  57693. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57694. /**
  57695. * If the gizmo is enabled
  57696. */
  57697. set isEnabled(value: boolean);
  57698. get isEnabled(): boolean;
  57699. /**
  57700. * Disposes of the gizmo
  57701. */
  57702. dispose(): void;
  57703. }
  57704. }
  57705. declare module BABYLON.Debug {
  57706. /**
  57707. * The Axes viewer will show 3 axes in a specific point in space
  57708. */
  57709. export class AxesViewer {
  57710. private _xAxis;
  57711. private _yAxis;
  57712. private _zAxis;
  57713. private _scaleLinesFactor;
  57714. private _instanced;
  57715. /**
  57716. * Gets the hosting scene
  57717. */
  57718. scene: Nullable<Scene>;
  57719. /**
  57720. * Gets or sets a number used to scale line length
  57721. */
  57722. scaleLines: number;
  57723. /** Gets the node hierarchy used to render x-axis */
  57724. get xAxis(): TransformNode;
  57725. /** Gets the node hierarchy used to render y-axis */
  57726. get yAxis(): TransformNode;
  57727. /** Gets the node hierarchy used to render z-axis */
  57728. get zAxis(): TransformNode;
  57729. /**
  57730. * Creates a new AxesViewer
  57731. * @param scene defines the hosting scene
  57732. * @param scaleLines defines a number used to scale line length (1 by default)
  57733. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  57734. * @param xAxis defines the node hierarchy used to render the x-axis
  57735. * @param yAxis defines the node hierarchy used to render the y-axis
  57736. * @param zAxis defines the node hierarchy used to render the z-axis
  57737. */
  57738. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  57739. /**
  57740. * Force the viewer to update
  57741. * @param position defines the position of the viewer
  57742. * @param xaxis defines the x axis of the viewer
  57743. * @param yaxis defines the y axis of the viewer
  57744. * @param zaxis defines the z axis of the viewer
  57745. */
  57746. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  57747. /**
  57748. * Creates an instance of this axes viewer.
  57749. * @returns a new axes viewer with instanced meshes
  57750. */
  57751. createInstance(): AxesViewer;
  57752. /** Releases resources */
  57753. dispose(): void;
  57754. private static _SetRenderingGroupId;
  57755. }
  57756. }
  57757. declare module BABYLON.Debug {
  57758. /**
  57759. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  57760. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  57761. */
  57762. export class BoneAxesViewer extends AxesViewer {
  57763. /**
  57764. * Gets or sets the target mesh where to display the axes viewer
  57765. */
  57766. mesh: Nullable<Mesh>;
  57767. /**
  57768. * Gets or sets the target bone where to display the axes viewer
  57769. */
  57770. bone: Nullable<Bone>;
  57771. /** Gets current position */
  57772. pos: Vector3;
  57773. /** Gets direction of X axis */
  57774. xaxis: Vector3;
  57775. /** Gets direction of Y axis */
  57776. yaxis: Vector3;
  57777. /** Gets direction of Z axis */
  57778. zaxis: Vector3;
  57779. /**
  57780. * Creates a new BoneAxesViewer
  57781. * @param scene defines the hosting scene
  57782. * @param bone defines the target bone
  57783. * @param mesh defines the target mesh
  57784. * @param scaleLines defines a scaling factor for line length (1 by default)
  57785. */
  57786. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  57787. /**
  57788. * Force the viewer to update
  57789. */
  57790. update(): void;
  57791. /** Releases resources */
  57792. dispose(): void;
  57793. }
  57794. }
  57795. declare module BABYLON {
  57796. /**
  57797. * Interface used to define scene explorer extensibility option
  57798. */
  57799. export interface IExplorerExtensibilityOption {
  57800. /**
  57801. * Define the option label
  57802. */
  57803. label: string;
  57804. /**
  57805. * Defines the action to execute on click
  57806. */
  57807. action: (entity: any) => void;
  57808. }
  57809. /**
  57810. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  57811. */
  57812. export interface IExplorerExtensibilityGroup {
  57813. /**
  57814. * Defines a predicate to test if a given type mut be extended
  57815. */
  57816. predicate: (entity: any) => boolean;
  57817. /**
  57818. * Gets the list of options added to a type
  57819. */
  57820. entries: IExplorerExtensibilityOption[];
  57821. }
  57822. /**
  57823. * Interface used to define the options to use to create the Inspector
  57824. */
  57825. export interface IInspectorOptions {
  57826. /**
  57827. * Display in overlay mode (default: false)
  57828. */
  57829. overlay?: boolean;
  57830. /**
  57831. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  57832. */
  57833. globalRoot?: HTMLElement;
  57834. /**
  57835. * Display the Scene explorer
  57836. */
  57837. showExplorer?: boolean;
  57838. /**
  57839. * Display the property inspector
  57840. */
  57841. showInspector?: boolean;
  57842. /**
  57843. * Display in embed mode (both panes on the right)
  57844. */
  57845. embedMode?: boolean;
  57846. /**
  57847. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  57848. */
  57849. handleResize?: boolean;
  57850. /**
  57851. * Allow the panes to popup (default: true)
  57852. */
  57853. enablePopup?: boolean;
  57854. /**
  57855. * Allow the panes to be closed by users (default: true)
  57856. */
  57857. enableClose?: boolean;
  57858. /**
  57859. * Optional list of extensibility entries
  57860. */
  57861. explorerExtensibility?: IExplorerExtensibilityGroup[];
  57862. /**
  57863. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  57864. */
  57865. inspectorURL?: string;
  57866. /**
  57867. * Optional initial tab (default to DebugLayerTab.Properties)
  57868. */
  57869. initialTab?: DebugLayerTab;
  57870. }
  57871. interface Scene {
  57872. /**
  57873. * @hidden
  57874. * Backing field
  57875. */
  57876. _debugLayer: DebugLayer;
  57877. /**
  57878. * Gets the debug layer (aka Inspector) associated with the scene
  57879. * @see https://doc.babylonjs.com/features/playground_debuglayer
  57880. */
  57881. debugLayer: DebugLayer;
  57882. }
  57883. /**
  57884. * Enum of inspector action tab
  57885. */
  57886. export enum DebugLayerTab {
  57887. /**
  57888. * Properties tag (default)
  57889. */
  57890. Properties = 0,
  57891. /**
  57892. * Debug tab
  57893. */
  57894. Debug = 1,
  57895. /**
  57896. * Statistics tab
  57897. */
  57898. Statistics = 2,
  57899. /**
  57900. * Tools tab
  57901. */
  57902. Tools = 3,
  57903. /**
  57904. * Settings tab
  57905. */
  57906. Settings = 4
  57907. }
  57908. /**
  57909. * The debug layer (aka Inspector) is the go to tool in order to better understand
  57910. * what is happening in your scene
  57911. * @see https://doc.babylonjs.com/features/playground_debuglayer
  57912. */
  57913. export class DebugLayer {
  57914. /**
  57915. * Define the url to get the inspector script from.
  57916. * By default it uses the babylonjs CDN.
  57917. * @ignoreNaming
  57918. */
  57919. static InspectorURL: string;
  57920. private _scene;
  57921. private BJSINSPECTOR;
  57922. private _onPropertyChangedObservable?;
  57923. /**
  57924. * Observable triggered when a property is changed through the inspector.
  57925. */
  57926. get onPropertyChangedObservable(): any;
  57927. /**
  57928. * Instantiates a new debug layer.
  57929. * The debug layer (aka Inspector) is the go to tool in order to better understand
  57930. * what is happening in your scene
  57931. * @see https://doc.babylonjs.com/features/playground_debuglayer
  57932. * @param scene Defines the scene to inspect
  57933. */
  57934. constructor(scene: Scene);
  57935. /** Creates the inspector window. */
  57936. private _createInspector;
  57937. /**
  57938. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  57939. * @param entity defines the entity to select
  57940. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  57941. */
  57942. select(entity: any, lineContainerTitles?: string | string[]): void;
  57943. /** Get the inspector from bundle or global */
  57944. private _getGlobalInspector;
  57945. /**
  57946. * Get if the inspector is visible or not.
  57947. * @returns true if visible otherwise, false
  57948. */
  57949. isVisible(): boolean;
  57950. /**
  57951. * Hide the inspector and close its window.
  57952. */
  57953. hide(): void;
  57954. /**
  57955. * Update the scene in the inspector
  57956. */
  57957. setAsActiveScene(): void;
  57958. /**
  57959. * Launch the debugLayer.
  57960. * @param config Define the configuration of the inspector
  57961. * @return a promise fulfilled when the debug layer is visible
  57962. */
  57963. show(config?: IInspectorOptions): Promise<DebugLayer>;
  57964. }
  57965. }
  57966. declare module BABYLON.Debug {
  57967. /**
  57968. * Used to show the physics impostor around the specific mesh
  57969. */
  57970. export class PhysicsViewer {
  57971. /** @hidden */
  57972. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  57973. /** @hidden */
  57974. protected _meshes: Array<Nullable<AbstractMesh>>;
  57975. /** @hidden */
  57976. protected _scene: Nullable<Scene>;
  57977. /** @hidden */
  57978. protected _numMeshes: number;
  57979. /** @hidden */
  57980. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  57981. private _renderFunction;
  57982. private _utilityLayer;
  57983. private _debugBoxMesh;
  57984. private _debugSphereMesh;
  57985. private _debugCylinderMesh;
  57986. private _debugMaterial;
  57987. private _debugMeshMeshes;
  57988. /**
  57989. * Creates a new PhysicsViewer
  57990. * @param scene defines the hosting scene
  57991. */
  57992. constructor(scene: Scene);
  57993. /** @hidden */
  57994. protected _updateDebugMeshes(): void;
  57995. /**
  57996. * Renders a specified physic impostor
  57997. * @param impostor defines the impostor to render
  57998. * @param targetMesh defines the mesh represented by the impostor
  57999. * @returns the new debug mesh used to render the impostor
  58000. */
  58001. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  58002. /**
  58003. * Hides a specified physic impostor
  58004. * @param impostor defines the impostor to hide
  58005. */
  58006. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  58007. private _getDebugMaterial;
  58008. private _getDebugBoxMesh;
  58009. private _getDebugSphereMesh;
  58010. private _getDebugCylinderMesh;
  58011. private _getDebugMeshMesh;
  58012. private _getDebugMesh;
  58013. /** Releases all resources */
  58014. dispose(): void;
  58015. }
  58016. }
  58017. declare module BABYLON {
  58018. /**
  58019. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  58020. * in order to better appreciate the issue one might have.
  58021. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  58022. */
  58023. export class RayHelper {
  58024. /**
  58025. * Defines the ray we are currently tryin to visualize.
  58026. */
  58027. ray: Nullable<Ray>;
  58028. private _renderPoints;
  58029. private _renderLine;
  58030. private _renderFunction;
  58031. private _scene;
  58032. private _onAfterRenderObserver;
  58033. private _onAfterStepObserver;
  58034. private _attachedToMesh;
  58035. private _meshSpaceDirection;
  58036. private _meshSpaceOrigin;
  58037. /**
  58038. * Helper function to create a colored helper in a scene in one line.
  58039. * @param ray Defines the ray we are currently tryin to visualize
  58040. * @param scene Defines the scene the ray is used in
  58041. * @param color Defines the color we want to see the ray in
  58042. * @returns The newly created ray helper.
  58043. */
  58044. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  58045. /**
  58046. * Instantiate a new ray helper.
  58047. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  58048. * in order to better appreciate the issue one might have.
  58049. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  58050. * @param ray Defines the ray we are currently tryin to visualize
  58051. */
  58052. constructor(ray: Ray);
  58053. /**
  58054. * Shows the ray we are willing to debug.
  58055. * @param scene Defines the scene the ray needs to be rendered in
  58056. * @param color Defines the color the ray needs to be rendered in
  58057. */
  58058. show(scene: Scene, color?: Color3): void;
  58059. /**
  58060. * Hides the ray we are debugging.
  58061. */
  58062. hide(): void;
  58063. private _render;
  58064. /**
  58065. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  58066. * @param mesh Defines the mesh we want the helper attached to
  58067. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  58068. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  58069. * @param length Defines the length of the ray
  58070. */
  58071. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  58072. /**
  58073. * Detach the ray helper from the mesh it has previously been attached to.
  58074. */
  58075. detachFromMesh(): void;
  58076. private _updateToMesh;
  58077. /**
  58078. * Dispose the helper and release its associated resources.
  58079. */
  58080. dispose(): void;
  58081. }
  58082. }
  58083. declare module BABYLON {
  58084. /**
  58085. * Defines the options associated with the creation of a SkeletonViewer.
  58086. */
  58087. export interface ISkeletonViewerOptions {
  58088. /** Should the system pause animations before building the Viewer? */
  58089. pauseAnimations: boolean;
  58090. /** Should the system return the skeleton to rest before building? */
  58091. returnToRest: boolean;
  58092. /** public Display Mode of the Viewer */
  58093. displayMode: number;
  58094. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  58095. displayOptions: ISkeletonViewerDisplayOptions;
  58096. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  58097. computeBonesUsingShaders: boolean;
  58098. /** Flag ignore non weighted bones */
  58099. useAllBones: boolean;
  58100. }
  58101. /**
  58102. * Defines how to display the various bone meshes for the viewer.
  58103. */
  58104. export interface ISkeletonViewerDisplayOptions {
  58105. /** How far down to start tapering the bone spurs */
  58106. midStep?: number;
  58107. /** How big is the midStep? */
  58108. midStepFactor?: number;
  58109. /** Base for the Sphere Size */
  58110. sphereBaseSize?: number;
  58111. /** The ratio of the sphere to the longest bone in units */
  58112. sphereScaleUnit?: number;
  58113. /** Ratio for the Sphere Size */
  58114. sphereFactor?: number;
  58115. /** Whether a spur should attach its far end to the child bone position */
  58116. spurFollowsChild?: boolean;
  58117. /** Whether to show local axes or not */
  58118. showLocalAxes?: boolean;
  58119. /** Length of each local axis */
  58120. localAxesSize?: number;
  58121. }
  58122. /**
  58123. * Defines the constructor options for the BoneWeight Shader.
  58124. */
  58125. export interface IBoneWeightShaderOptions {
  58126. /** Skeleton to Map */
  58127. skeleton: Skeleton;
  58128. /** Colors for Uninfluenced bones */
  58129. colorBase?: Color3;
  58130. /** Colors for 0.0-0.25 Weight bones */
  58131. colorZero?: Color3;
  58132. /** Color for 0.25-0.5 Weight Influence */
  58133. colorQuarter?: Color3;
  58134. /** Color for 0.5-0.75 Weight Influence */
  58135. colorHalf?: Color3;
  58136. /** Color for 0.75-1 Weight Influence */
  58137. colorFull?: Color3;
  58138. /** Color for Zero Weight Influence */
  58139. targetBoneIndex?: number;
  58140. }
  58141. /**
  58142. * Simple structure of the gradient steps for the Color Map.
  58143. */
  58144. export interface ISkeletonMapShaderColorMapKnot {
  58145. /** Color of the Knot */
  58146. color: Color3;
  58147. /** Location of the Knot */
  58148. location: number;
  58149. }
  58150. /**
  58151. * Defines the constructor options for the SkeletonMap Shader.
  58152. */
  58153. export interface ISkeletonMapShaderOptions {
  58154. /** Skeleton to Map */
  58155. skeleton: Skeleton;
  58156. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  58157. colorMap?: ISkeletonMapShaderColorMapKnot[];
  58158. }
  58159. }
  58160. declare module BABYLON {
  58161. /**
  58162. * Class containing static functions to help procedurally build meshes
  58163. */
  58164. export class RibbonBuilder {
  58165. /**
  58166. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58167. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58168. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58169. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58170. * * 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
  58171. * * 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
  58172. * * 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
  58173. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58174. * * 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
  58175. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58176. * * 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
  58177. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58178. * * 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
  58179. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58181. * @param name defines the name of the mesh
  58182. * @param options defines the options used to create the mesh
  58183. * @param scene defines the hosting scene
  58184. * @returns the ribbon mesh
  58185. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58186. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58187. */
  58188. static CreateRibbon(name: string, options: {
  58189. pathArray: Vector3[][];
  58190. closeArray?: boolean;
  58191. closePath?: boolean;
  58192. offset?: number;
  58193. updatable?: boolean;
  58194. sideOrientation?: number;
  58195. frontUVs?: Vector4;
  58196. backUVs?: Vector4;
  58197. instance?: Mesh;
  58198. invertUV?: boolean;
  58199. uvs?: Vector2[];
  58200. colors?: Color4[];
  58201. }, scene?: Nullable<Scene>): Mesh;
  58202. }
  58203. }
  58204. declare module BABYLON {
  58205. /**
  58206. * Class containing static functions to help procedurally build meshes
  58207. */
  58208. export class ShapeBuilder {
  58209. /**
  58210. * 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.
  58211. * * 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.
  58212. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58213. * * 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.
  58214. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58215. * * 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
  58216. * * 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
  58217. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58219. * * 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
  58220. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58222. * @param name defines the name of the mesh
  58223. * @param options defines the options used to create the mesh
  58224. * @param scene defines the hosting scene
  58225. * @returns the extruded shape mesh
  58226. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58227. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58228. */
  58229. static ExtrudeShape(name: string, options: {
  58230. shape: Vector3[];
  58231. path: Vector3[];
  58232. scale?: number;
  58233. rotation?: number;
  58234. cap?: number;
  58235. updatable?: boolean;
  58236. sideOrientation?: number;
  58237. frontUVs?: Vector4;
  58238. backUVs?: Vector4;
  58239. instance?: Mesh;
  58240. invertUV?: boolean;
  58241. }, scene?: Nullable<Scene>): Mesh;
  58242. /**
  58243. * Creates an custom extruded shape mesh.
  58244. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58245. * * 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.
  58246. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58247. * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  58248. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58249. * * 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
  58250. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58251. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58252. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58253. * * 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
  58254. * * 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
  58255. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58256. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58257. * * 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
  58258. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58260. * @param name defines the name of the mesh
  58261. * @param options defines the options used to create the mesh
  58262. * @param scene defines the hosting scene
  58263. * @returns the custom extruded shape mesh
  58264. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58265. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58266. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58267. */
  58268. static ExtrudeShapeCustom(name: string, options: {
  58269. shape: Vector3[];
  58270. path: Vector3[];
  58271. scaleFunction?: any;
  58272. rotationFunction?: any;
  58273. ribbonCloseArray?: boolean;
  58274. ribbonClosePath?: boolean;
  58275. cap?: number;
  58276. updatable?: boolean;
  58277. sideOrientation?: number;
  58278. frontUVs?: Vector4;
  58279. backUVs?: Vector4;
  58280. instance?: Mesh;
  58281. invertUV?: boolean;
  58282. }, scene?: Nullable<Scene>): Mesh;
  58283. private static _ExtrudeShapeGeneric;
  58284. }
  58285. }
  58286. declare module BABYLON.Debug {
  58287. /**
  58288. * Class used to render a debug view of a given skeleton
  58289. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  58290. */
  58291. export class SkeletonViewer {
  58292. /** defines the skeleton to render */
  58293. skeleton: Skeleton;
  58294. /** defines the mesh attached to the skeleton */
  58295. mesh: AbstractMesh;
  58296. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  58297. autoUpdateBonesMatrices: boolean;
  58298. /** defines the rendering group id to use with the viewer */
  58299. renderingGroupId: number;
  58300. /** is the options for the viewer */
  58301. options: Partial<ISkeletonViewerOptions>;
  58302. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  58303. static readonly DISPLAY_LINES: number;
  58304. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  58305. static readonly DISPLAY_SPHERES: number;
  58306. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  58307. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  58308. /** public static method to create a BoneWeight Shader
  58309. * @param options The constructor options
  58310. * @param scene The scene that the shader is scoped to
  58311. * @returns The created ShaderMaterial
  58312. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  58313. */
  58314. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  58315. /** public static method to create a BoneWeight Shader
  58316. * @param options The constructor options
  58317. * @param scene The scene that the shader is scoped to
  58318. * @returns The created ShaderMaterial
  58319. */
  58320. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  58321. /** private static method to create a BoneWeight Shader
  58322. * @param size The size of the buffer to create (usually the bone count)
  58323. * @param colorMap The gradient data to generate
  58324. * @param scene The scene that the shader is scoped to
  58325. * @returns an Array of floats from the color gradient values
  58326. */
  58327. private static _CreateBoneMapColorBuffer;
  58328. /** If SkeletonViewer scene scope. */
  58329. private _scene;
  58330. /** Gets or sets the color used to render the skeleton */
  58331. color: Color3;
  58332. /** Array of the points of the skeleton fo the line view. */
  58333. private _debugLines;
  58334. /** The SkeletonViewers Mesh. */
  58335. private _debugMesh;
  58336. /** The local axes Meshes. */
  58337. private _localAxes;
  58338. /** If SkeletonViewer is enabled. */
  58339. private _isEnabled;
  58340. /** If SkeletonViewer is ready. */
  58341. private _ready;
  58342. /** SkeletonViewer render observable. */
  58343. private _obs;
  58344. /** The Utility Layer to render the gizmos in. */
  58345. private _utilityLayer;
  58346. private _boneIndices;
  58347. /** Gets the Scene. */
  58348. get scene(): Scene;
  58349. /** Gets the utilityLayer. */
  58350. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  58351. /** Checks Ready Status. */
  58352. get isReady(): Boolean;
  58353. /** Sets Ready Status. */
  58354. set ready(value: boolean);
  58355. /** Gets the debugMesh */
  58356. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  58357. /** Sets the debugMesh */
  58358. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  58359. /** Gets the displayMode */
  58360. get displayMode(): number;
  58361. /** Sets the displayMode */
  58362. set displayMode(value: number);
  58363. /**
  58364. * Creates a new SkeletonViewer
  58365. * @param skeleton defines the skeleton to render
  58366. * @param mesh defines the mesh attached to the skeleton
  58367. * @param scene defines the hosting scene
  58368. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  58369. * @param renderingGroupId defines the rendering group id to use with the viewer
  58370. * @param options All of the extra constructor options for the SkeletonViewer
  58371. */
  58372. constructor(
  58373. /** defines the skeleton to render */
  58374. skeleton: Skeleton,
  58375. /** defines the mesh attached to the skeleton */
  58376. mesh: AbstractMesh,
  58377. /** The Scene scope*/
  58378. scene: Scene,
  58379. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  58380. autoUpdateBonesMatrices?: boolean,
  58381. /** defines the rendering group id to use with the viewer */
  58382. renderingGroupId?: number,
  58383. /** is the options for the viewer */
  58384. options?: Partial<ISkeletonViewerOptions>);
  58385. /** The Dynamic bindings for the update functions */
  58386. private _bindObs;
  58387. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  58388. update(): void;
  58389. /** Gets or sets a boolean indicating if the viewer is enabled */
  58390. set isEnabled(value: boolean);
  58391. get isEnabled(): boolean;
  58392. private _getBonePosition;
  58393. private _getLinesForBonesWithLength;
  58394. private _getLinesForBonesNoLength;
  58395. /** function to revert the mesh and scene back to the initial state. */
  58396. private _revert;
  58397. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  58398. private _getAbsoluteBindPoseToRef;
  58399. /** function to build and bind sphere joint points and spur bone representations. */
  58400. private _buildSpheresAndSpurs;
  58401. private _buildLocalAxes;
  58402. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  58403. private _displayLinesUpdate;
  58404. /** Changes the displayMode of the skeleton viewer
  58405. * @param mode The displayMode numerical value
  58406. */
  58407. changeDisplayMode(mode: number): void;
  58408. /** Sets a display option of the skeleton viewer
  58409. *
  58410. * | Option | Type | Default | Description |
  58411. * | ---------------- | ------- | ------- | ----------- |
  58412. * | 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`. |
  58413. * | 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`. |
  58414. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  58415. * | 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`. |
  58416. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  58417. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  58418. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  58419. *
  58420. * @param option String of the option name
  58421. * @param value The numerical option value
  58422. */
  58423. changeDisplayOptions(option: string, value: number): void;
  58424. /** Release associated resources */
  58425. dispose(): void;
  58426. }
  58427. }
  58428. declare module BABYLON {
  58429. /**
  58430. * Enum for Device Types
  58431. */
  58432. export enum DeviceType {
  58433. /** Generic */
  58434. Generic = 0,
  58435. /** Keyboard */
  58436. Keyboard = 1,
  58437. /** Mouse */
  58438. Mouse = 2,
  58439. /** Touch Pointers */
  58440. Touch = 3,
  58441. /** PS4 Dual Shock */
  58442. DualShock = 4,
  58443. /** Xbox */
  58444. Xbox = 5,
  58445. /** Switch Controller */
  58446. Switch = 6
  58447. }
  58448. /**
  58449. * Enum for All Pointers (Touch/Mouse)
  58450. */
  58451. export enum PointerInput {
  58452. /** Horizontal Axis */
  58453. Horizontal = 0,
  58454. /** Vertical Axis */
  58455. Vertical = 1,
  58456. /** Left Click or Touch */
  58457. LeftClick = 2,
  58458. /** Middle Click */
  58459. MiddleClick = 3,
  58460. /** Right Click */
  58461. RightClick = 4,
  58462. /** Browser Back */
  58463. BrowserBack = 5,
  58464. /** Browser Forward */
  58465. BrowserForward = 6
  58466. }
  58467. /**
  58468. * Enum for Dual Shock Gamepad
  58469. */
  58470. export enum DualShockInput {
  58471. /** Cross */
  58472. Cross = 0,
  58473. /** Circle */
  58474. Circle = 1,
  58475. /** Square */
  58476. Square = 2,
  58477. /** Triangle */
  58478. Triangle = 3,
  58479. /** L1 */
  58480. L1 = 4,
  58481. /** R1 */
  58482. R1 = 5,
  58483. /** L2 */
  58484. L2 = 6,
  58485. /** R2 */
  58486. R2 = 7,
  58487. /** Share */
  58488. Share = 8,
  58489. /** Options */
  58490. Options = 9,
  58491. /** L3 */
  58492. L3 = 10,
  58493. /** R3 */
  58494. R3 = 11,
  58495. /** DPadUp */
  58496. DPadUp = 12,
  58497. /** DPadDown */
  58498. DPadDown = 13,
  58499. /** DPadLeft */
  58500. DPadLeft = 14,
  58501. /** DRight */
  58502. DPadRight = 15,
  58503. /** Home */
  58504. Home = 16,
  58505. /** TouchPad */
  58506. TouchPad = 17,
  58507. /** LStickXAxis */
  58508. LStickXAxis = 18,
  58509. /** LStickYAxis */
  58510. LStickYAxis = 19,
  58511. /** RStickXAxis */
  58512. RStickXAxis = 20,
  58513. /** RStickYAxis */
  58514. RStickYAxis = 21
  58515. }
  58516. /**
  58517. * Enum for Xbox Gamepad
  58518. */
  58519. export enum XboxInput {
  58520. /** A */
  58521. A = 0,
  58522. /** B */
  58523. B = 1,
  58524. /** X */
  58525. X = 2,
  58526. /** Y */
  58527. Y = 3,
  58528. /** LB */
  58529. LB = 4,
  58530. /** RB */
  58531. RB = 5,
  58532. /** LT */
  58533. LT = 6,
  58534. /** RT */
  58535. RT = 7,
  58536. /** Back */
  58537. Back = 8,
  58538. /** Start */
  58539. Start = 9,
  58540. /** LS */
  58541. LS = 10,
  58542. /** RS */
  58543. RS = 11,
  58544. /** DPadUp */
  58545. DPadUp = 12,
  58546. /** DPadDown */
  58547. DPadDown = 13,
  58548. /** DPadLeft */
  58549. DPadLeft = 14,
  58550. /** DRight */
  58551. DPadRight = 15,
  58552. /** Home */
  58553. Home = 16,
  58554. /** LStickXAxis */
  58555. LStickXAxis = 17,
  58556. /** LStickYAxis */
  58557. LStickYAxis = 18,
  58558. /** RStickXAxis */
  58559. RStickXAxis = 19,
  58560. /** RStickYAxis */
  58561. RStickYAxis = 20
  58562. }
  58563. /**
  58564. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  58565. */
  58566. export enum SwitchInput {
  58567. /** B */
  58568. B = 0,
  58569. /** A */
  58570. A = 1,
  58571. /** Y */
  58572. Y = 2,
  58573. /** X */
  58574. X = 3,
  58575. /** L */
  58576. L = 4,
  58577. /** R */
  58578. R = 5,
  58579. /** ZL */
  58580. ZL = 6,
  58581. /** ZR */
  58582. ZR = 7,
  58583. /** Minus */
  58584. Minus = 8,
  58585. /** Plus */
  58586. Plus = 9,
  58587. /** LS */
  58588. LS = 10,
  58589. /** RS */
  58590. RS = 11,
  58591. /** DPadUp */
  58592. DPadUp = 12,
  58593. /** DPadDown */
  58594. DPadDown = 13,
  58595. /** DPadLeft */
  58596. DPadLeft = 14,
  58597. /** DRight */
  58598. DPadRight = 15,
  58599. /** Home */
  58600. Home = 16,
  58601. /** Capture */
  58602. Capture = 17,
  58603. /** LStickXAxis */
  58604. LStickXAxis = 18,
  58605. /** LStickYAxis */
  58606. LStickYAxis = 19,
  58607. /** RStickXAxis */
  58608. RStickXAxis = 20,
  58609. /** RStickYAxis */
  58610. RStickYAxis = 21
  58611. }
  58612. }
  58613. declare module BABYLON {
  58614. /**
  58615. * This class will take all inputs from Keyboard, Pointer, and
  58616. * any Gamepads and provide a polling system that all devices
  58617. * will use. This class assumes that there will only be one
  58618. * pointer device and one keyboard.
  58619. */
  58620. export class DeviceInputSystem implements IDisposable {
  58621. /**
  58622. * Returns onDeviceConnected callback property
  58623. * @returns Callback with function to execute when a device is connected
  58624. */
  58625. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  58626. /**
  58627. * Sets callback function when a device is connected and executes against all connected devices
  58628. * @param callback Function to execute when a device is connected
  58629. */
  58630. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  58631. /**
  58632. * Callback to be triggered when a device is disconnected
  58633. */
  58634. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  58635. /**
  58636. * Callback to be triggered when event driven input is updated
  58637. */
  58638. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  58639. private _inputs;
  58640. private _gamepads;
  58641. private _keyboardActive;
  58642. private _pointerActive;
  58643. private _elementToAttachTo;
  58644. private _keyboardDownEvent;
  58645. private _keyboardUpEvent;
  58646. private _pointerMoveEvent;
  58647. private _pointerDownEvent;
  58648. private _pointerUpEvent;
  58649. private _gamepadConnectedEvent;
  58650. private _gamepadDisconnectedEvent;
  58651. private _onDeviceConnected;
  58652. private static _MAX_KEYCODES;
  58653. private static _MAX_POINTER_INPUTS;
  58654. private constructor();
  58655. /**
  58656. * Creates a new DeviceInputSystem instance
  58657. * @param engine Engine to pull input element from
  58658. * @returns The new instance
  58659. */
  58660. static Create(engine: Engine): DeviceInputSystem;
  58661. /**
  58662. * Checks for current device input value, given an id and input index
  58663. * @param deviceName Id of connected device
  58664. * @param inputIndex Index of device input
  58665. * @returns Current value of input
  58666. */
  58667. /**
  58668. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  58669. * @param deviceType Enum specifiying device type
  58670. * @param deviceSlot "Slot" or index that device is referenced in
  58671. * @param inputIndex Id of input to be checked
  58672. * @returns Current value of input
  58673. */
  58674. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  58675. /**
  58676. * Dispose of all the eventlisteners
  58677. */
  58678. dispose(): void;
  58679. /**
  58680. * Checks for existing connections to devices and register them, if necessary
  58681. * Currently handles gamepads and mouse
  58682. */
  58683. private _checkForConnectedDevices;
  58684. /**
  58685. * Add a gamepad to the DeviceInputSystem
  58686. * @param gamepad A single DOM Gamepad object
  58687. */
  58688. private _addGamePad;
  58689. /**
  58690. * Add pointer device to DeviceInputSystem
  58691. * @param deviceType Type of Pointer to add
  58692. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  58693. * @param currentX Current X at point of adding
  58694. * @param currentY Current Y at point of adding
  58695. */
  58696. private _addPointerDevice;
  58697. /**
  58698. * Add device and inputs to device array
  58699. * @param deviceType Enum specifiying device type
  58700. * @param deviceSlot "Slot" or index that device is referenced in
  58701. * @param numberOfInputs Number of input entries to create for given device
  58702. */
  58703. private _registerDevice;
  58704. /**
  58705. * Given a specific device name, remove that device from the device map
  58706. * @param deviceType Enum specifiying device type
  58707. * @param deviceSlot "Slot" or index that device is referenced in
  58708. */
  58709. private _unregisterDevice;
  58710. /**
  58711. * Handle all actions that come from keyboard interaction
  58712. */
  58713. private _handleKeyActions;
  58714. /**
  58715. * Handle all actions that come from pointer interaction
  58716. */
  58717. private _handlePointerActions;
  58718. /**
  58719. * Handle all actions that come from gamepad interaction
  58720. */
  58721. private _handleGamepadActions;
  58722. /**
  58723. * Update all non-event based devices with each frame
  58724. * @param deviceType Enum specifiying device type
  58725. * @param deviceSlot "Slot" or index that device is referenced in
  58726. * @param inputIndex Id of input to be checked
  58727. */
  58728. private _updateDevice;
  58729. /**
  58730. * Gets DeviceType from the device name
  58731. * @param deviceName Name of Device from DeviceInputSystem
  58732. * @returns DeviceType enum value
  58733. */
  58734. private _getGamepadDeviceType;
  58735. }
  58736. }
  58737. declare module BABYLON {
  58738. /**
  58739. * Type to handle enforcement of inputs
  58740. */
  58741. 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;
  58742. }
  58743. declare module BABYLON {
  58744. /**
  58745. * Class that handles all input for a specific device
  58746. */
  58747. export class DeviceSource<T extends DeviceType> {
  58748. /** Type of device */
  58749. readonly deviceType: DeviceType;
  58750. /** "Slot" or index that device is referenced in */
  58751. readonly deviceSlot: number;
  58752. /**
  58753. * Observable to handle device input changes per device
  58754. */
  58755. readonly onInputChangedObservable: Observable<{
  58756. inputIndex: DeviceInput<T>;
  58757. previousState: Nullable<number>;
  58758. currentState: Nullable<number>;
  58759. }>;
  58760. private readonly _deviceInputSystem;
  58761. /**
  58762. * Default Constructor
  58763. * @param deviceInputSystem Reference to DeviceInputSystem
  58764. * @param deviceType Type of device
  58765. * @param deviceSlot "Slot" or index that device is referenced in
  58766. */
  58767. constructor(deviceInputSystem: DeviceInputSystem,
  58768. /** Type of device */
  58769. deviceType: DeviceType,
  58770. /** "Slot" or index that device is referenced in */
  58771. deviceSlot?: number);
  58772. /**
  58773. * Get input for specific input
  58774. * @param inputIndex index of specific input on device
  58775. * @returns Input value from DeviceInputSystem
  58776. */
  58777. getInput(inputIndex: DeviceInput<T>): number;
  58778. }
  58779. /**
  58780. * Class to keep track of devices
  58781. */
  58782. export class DeviceSourceManager implements IDisposable {
  58783. /**
  58784. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  58785. */
  58786. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  58787. /**
  58788. * Observable to be triggered when after a device is disconnected
  58789. */
  58790. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  58791. private readonly _devices;
  58792. private readonly _firstDevice;
  58793. private readonly _deviceInputSystem;
  58794. /**
  58795. * Default Constructor
  58796. * @param engine engine to pull input element from
  58797. */
  58798. constructor(engine: Engine);
  58799. /**
  58800. * Gets a DeviceSource, given a type and slot
  58801. * @param deviceType Enum specifying device type
  58802. * @param deviceSlot "Slot" or index that device is referenced in
  58803. * @returns DeviceSource object
  58804. */
  58805. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  58806. /**
  58807. * Gets an array of DeviceSource objects for a given device type
  58808. * @param deviceType Enum specifying device type
  58809. * @returns Array of DeviceSource objects
  58810. */
  58811. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  58812. /**
  58813. * Returns a read-only list of all available devices
  58814. * @returns Read-only array with active devices
  58815. */
  58816. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  58817. /**
  58818. * Dispose of DeviceInputSystem and other parts
  58819. */
  58820. dispose(): void;
  58821. /**
  58822. * Function to add device name to device list
  58823. * @param deviceType Enum specifying device type
  58824. * @param deviceSlot "Slot" or index that device is referenced in
  58825. */
  58826. private _addDevice;
  58827. /**
  58828. * Function to remove device name to device list
  58829. * @param deviceType Enum specifying device type
  58830. * @param deviceSlot "Slot" or index that device is referenced in
  58831. */
  58832. private _removeDevice;
  58833. /**
  58834. * Updates array storing first connected device of each type
  58835. * @param type Type of Device
  58836. */
  58837. private _updateFirstDevices;
  58838. }
  58839. }
  58840. declare module BABYLON {
  58841. /**
  58842. * Options to create the null engine
  58843. */
  58844. export class NullEngineOptions {
  58845. /**
  58846. * Render width (Default: 512)
  58847. */
  58848. renderWidth: number;
  58849. /**
  58850. * Render height (Default: 256)
  58851. */
  58852. renderHeight: number;
  58853. /**
  58854. * Texture size (Default: 512)
  58855. */
  58856. textureSize: number;
  58857. /**
  58858. * If delta time between frames should be constant
  58859. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58860. */
  58861. deterministicLockstep: boolean;
  58862. /**
  58863. * Maximum about of steps between frames (Default: 4)
  58864. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58865. */
  58866. lockstepMaxSteps: number;
  58867. /**
  58868. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  58869. */
  58870. useHighPrecisionMatrix?: boolean;
  58871. }
  58872. /**
  58873. * The null engine class provides support for headless version of babylon.js.
  58874. * This can be used in server side scenario or for testing purposes
  58875. */
  58876. export class NullEngine extends Engine {
  58877. private _options;
  58878. /**
  58879. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  58880. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58881. * @returns true if engine is in deterministic lock step mode
  58882. */
  58883. isDeterministicLockStep(): boolean;
  58884. /**
  58885. * Gets the max steps when engine is running in deterministic lock step
  58886. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58887. * @returns the max steps
  58888. */
  58889. getLockstepMaxSteps(): number;
  58890. /**
  58891. * Gets the current hardware scaling level.
  58892. * By default the hardware scaling level is computed from the window device ratio.
  58893. * 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.
  58894. * @returns a number indicating the current hardware scaling level
  58895. */
  58896. getHardwareScalingLevel(): number;
  58897. constructor(options?: NullEngineOptions);
  58898. /**
  58899. * Creates a vertex buffer
  58900. * @param vertices the data for the vertex buffer
  58901. * @returns the new WebGL static buffer
  58902. */
  58903. createVertexBuffer(vertices: FloatArray): DataBuffer;
  58904. /**
  58905. * Creates a new index buffer
  58906. * @param indices defines the content of the index buffer
  58907. * @param updatable defines if the index buffer must be updatable
  58908. * @returns a new webGL buffer
  58909. */
  58910. createIndexBuffer(indices: IndicesArray): DataBuffer;
  58911. /**
  58912. * Clear the current render buffer or the current render target (if any is set up)
  58913. * @param color defines the color to use
  58914. * @param backBuffer defines if the back buffer must be cleared
  58915. * @param depth defines if the depth buffer must be cleared
  58916. * @param stencil defines if the stencil buffer must be cleared
  58917. */
  58918. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  58919. /**
  58920. * Gets the current render width
  58921. * @param useScreen defines if screen size must be used (or the current render target if any)
  58922. * @returns a number defining the current render width
  58923. */
  58924. getRenderWidth(useScreen?: boolean): number;
  58925. /**
  58926. * Gets the current render height
  58927. * @param useScreen defines if screen size must be used (or the current render target if any)
  58928. * @returns a number defining the current render height
  58929. */
  58930. getRenderHeight(useScreen?: boolean): number;
  58931. /**
  58932. * Set the WebGL's viewport
  58933. * @param viewport defines the viewport element to be used
  58934. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  58935. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  58936. */
  58937. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  58938. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  58939. /**
  58940. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  58941. * @param pipelineContext defines the pipeline context to use
  58942. * @param uniformsNames defines the list of uniform names
  58943. * @returns an array of webGL uniform locations
  58944. */
  58945. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  58946. /**
  58947. * Gets the lsit of active attributes for a given webGL program
  58948. * @param pipelineContext defines the pipeline context to use
  58949. * @param attributesNames defines the list of attribute names to get
  58950. * @returns an array of indices indicating the offset of each attribute
  58951. */
  58952. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  58953. /**
  58954. * Binds an effect to the webGL context
  58955. * @param effect defines the effect to bind
  58956. */
  58957. bindSamplers(effect: Effect): void;
  58958. /**
  58959. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  58960. * @param effect defines the effect to activate
  58961. */
  58962. enableEffect(effect: Effect): void;
  58963. /**
  58964. * Set various states to the webGL context
  58965. * @param culling defines backface culling state
  58966. * @param zOffset defines the value to apply to zOffset (0 by default)
  58967. * @param force defines if states must be applied even if cache is up to date
  58968. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  58969. */
  58970. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  58971. /**
  58972. * Set the value of an uniform to an array of int32
  58973. * @param uniform defines the webGL uniform location where to store the value
  58974. * @param array defines the array of int32 to store
  58975. * @returns true if value was set
  58976. */
  58977. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58978. /**
  58979. * Set the value of an uniform to an array of int32 (stored as vec2)
  58980. * @param uniform defines the webGL uniform location where to store the value
  58981. * @param array defines the array of int32 to store
  58982. * @returns true if value was set
  58983. */
  58984. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58985. /**
  58986. * Set the value of an uniform to an array of int32 (stored as vec3)
  58987. * @param uniform defines the webGL uniform location where to store the value
  58988. * @param array defines the array of int32 to store
  58989. * @returns true if value was set
  58990. */
  58991. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58992. /**
  58993. * Set the value of an uniform to an array of int32 (stored as vec4)
  58994. * @param uniform defines the webGL uniform location where to store the value
  58995. * @param array defines the array of int32 to store
  58996. * @returns true if value was set
  58997. */
  58998. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58999. /**
  59000. * Set the value of an uniform to an array of float32
  59001. * @param uniform defines the webGL uniform location where to store the value
  59002. * @param array defines the array of float32 to store
  59003. * @returns true if value was set
  59004. */
  59005. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59006. /**
  59007. * Set the value of an uniform to an array of float32 (stored as vec2)
  59008. * @param uniform defines the webGL uniform location where to store the value
  59009. * @param array defines the array of float32 to store
  59010. * @returns true if value was set
  59011. */
  59012. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59013. /**
  59014. * Set the value of an uniform to an array of float32 (stored as vec3)
  59015. * @param uniform defines the webGL uniform location where to store the value
  59016. * @param array defines the array of float32 to store
  59017. * @returns true if value was set
  59018. */
  59019. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59020. /**
  59021. * Set the value of an uniform to an array of float32 (stored as vec4)
  59022. * @param uniform defines the webGL uniform location where to store the value
  59023. * @param array defines the array of float32 to store
  59024. * @returns true if value was set
  59025. */
  59026. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59027. /**
  59028. * Set the value of an uniform to an array of number
  59029. * @param uniform defines the webGL uniform location where to store the value
  59030. * @param array defines the array of number to store
  59031. * @returns true if value was set
  59032. */
  59033. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  59034. /**
  59035. * Set the value of an uniform to an array of number (stored as vec2)
  59036. * @param uniform defines the webGL uniform location where to store the value
  59037. * @param array defines the array of number to store
  59038. * @returns true if value was set
  59039. */
  59040. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  59041. /**
  59042. * Set the value of an uniform to an array of number (stored as vec3)
  59043. * @param uniform defines the webGL uniform location where to store the value
  59044. * @param array defines the array of number to store
  59045. * @returns true if value was set
  59046. */
  59047. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  59048. /**
  59049. * Set the value of an uniform to an array of number (stored as vec4)
  59050. * @param uniform defines the webGL uniform location where to store the value
  59051. * @param array defines the array of number to store
  59052. * @returns true if value was set
  59053. */
  59054. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  59055. /**
  59056. * Set the value of an uniform to an array of float32 (stored as matrices)
  59057. * @param uniform defines the webGL uniform location where to store the value
  59058. * @param matrices defines the array of float32 to store
  59059. * @returns true if value was set
  59060. */
  59061. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  59062. /**
  59063. * Set the value of an uniform to a matrix (3x3)
  59064. * @param uniform defines the webGL uniform location where to store the value
  59065. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  59066. * @returns true if value was set
  59067. */
  59068. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59069. /**
  59070. * Set the value of an uniform to a matrix (2x2)
  59071. * @param uniform defines the webGL uniform location where to store the value
  59072. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  59073. * @returns true if value was set
  59074. */
  59075. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59076. /**
  59077. * Set the value of an uniform to a number (float)
  59078. * @param uniform defines the webGL uniform location where to store the value
  59079. * @param value defines the float number to store
  59080. * @returns true if value was set
  59081. */
  59082. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  59083. /**
  59084. * Set the value of an uniform to a vec2
  59085. * @param uniform defines the webGL uniform location where to store the value
  59086. * @param x defines the 1st component of the value
  59087. * @param y defines the 2nd component of the value
  59088. * @returns true if value was set
  59089. */
  59090. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  59091. /**
  59092. * Set the value of an uniform to a vec3
  59093. * @param uniform defines the webGL uniform location where to store the value
  59094. * @param x defines the 1st component of the value
  59095. * @param y defines the 2nd component of the value
  59096. * @param z defines the 3rd component of the value
  59097. * @returns true if value was set
  59098. */
  59099. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  59100. /**
  59101. * Set the value of an uniform to a boolean
  59102. * @param uniform defines the webGL uniform location where to store the value
  59103. * @param bool defines the boolean to store
  59104. * @returns true if value was set
  59105. */
  59106. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  59107. /**
  59108. * Set the value of an uniform to a vec4
  59109. * @param uniform defines the webGL uniform location where to store the value
  59110. * @param x defines the 1st component of the value
  59111. * @param y defines the 2nd component of the value
  59112. * @param z defines the 3rd component of the value
  59113. * @param w defines the 4th component of the value
  59114. * @returns true if value was set
  59115. */
  59116. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  59117. /**
  59118. * Sets the current alpha mode
  59119. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  59120. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  59121. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59122. */
  59123. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  59124. /**
  59125. * Bind webGl buffers directly to the webGL context
  59126. * @param vertexBuffers defines the vertex buffer to bind
  59127. * @param indexBuffer defines the index buffer to bind
  59128. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  59129. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  59130. * @param effect defines the effect associated with the vertex buffer
  59131. */
  59132. bindBuffers(vertexBuffers: {
  59133. [key: string]: VertexBuffer;
  59134. }, indexBuffer: DataBuffer, effect: Effect): void;
  59135. /**
  59136. * Force the entire cache to be cleared
  59137. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  59138. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  59139. */
  59140. wipeCaches(bruteForce?: boolean): void;
  59141. /**
  59142. * Send a draw order
  59143. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  59144. * @param indexStart defines the starting index
  59145. * @param indexCount defines the number of index to draw
  59146. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59147. */
  59148. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  59149. /**
  59150. * Draw a list of indexed primitives
  59151. * @param fillMode defines the primitive to use
  59152. * @param indexStart defines the starting index
  59153. * @param indexCount defines the number of index to draw
  59154. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59155. */
  59156. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  59157. /**
  59158. * Draw a list of unindexed primitives
  59159. * @param fillMode defines the primitive to use
  59160. * @param verticesStart defines the index of first vertex to draw
  59161. * @param verticesCount defines the count of vertices to draw
  59162. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59163. */
  59164. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  59165. /** @hidden */
  59166. protected _createTexture(): WebGLTexture;
  59167. /** @hidden */
  59168. _releaseTexture(texture: InternalTexture): void;
  59169. /**
  59170. * Usually called from Texture.ts.
  59171. * Passed information to create a WebGLTexture
  59172. * @param urlArg defines a value which contains one of the following:
  59173. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  59174. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  59175. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  59176. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  59177. * @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)
  59178. * @param scene needed for loading to the correct scene
  59179. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  59180. * @param onLoad optional callback to be called upon successful completion
  59181. * @param onError optional callback to be called upon failure
  59182. * @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
  59183. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  59184. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  59185. * @param forcedExtension defines the extension to use to pick the right loader
  59186. * @param mimeType defines an optional mime type
  59187. * @returns a InternalTexture for assignment back into BABYLON.Texture
  59188. */
  59189. 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;
  59190. /**
  59191. * Creates a new render target texture
  59192. * @param size defines the size of the texture
  59193. * @param options defines the options used to create the texture
  59194. * @returns a new render target texture stored in an InternalTexture
  59195. */
  59196. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  59197. /**
  59198. * Update the sampling mode of a given texture
  59199. * @param samplingMode defines the required sampling mode
  59200. * @param texture defines the texture to update
  59201. */
  59202. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  59203. /**
  59204. * Binds the frame buffer to the specified texture.
  59205. * @param texture The texture to render to or null for the default canvas
  59206. * @param faceIndex The face of the texture to render to in case of cube texture
  59207. * @param requiredWidth The width of the target to render to
  59208. * @param requiredHeight The height of the target to render to
  59209. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  59210. * @param lodLevel defines le lod level to bind to the frame buffer
  59211. */
  59212. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  59213. /**
  59214. * Unbind the current render target texture from the webGL context
  59215. * @param texture defines the render target texture to unbind
  59216. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  59217. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  59218. */
  59219. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  59220. /**
  59221. * Creates a dynamic vertex buffer
  59222. * @param vertices the data for the dynamic vertex buffer
  59223. * @returns the new WebGL dynamic buffer
  59224. */
  59225. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  59226. /**
  59227. * Update the content of a dynamic texture
  59228. * @param texture defines the texture to update
  59229. * @param canvas defines the canvas containing the source
  59230. * @param invertY defines if data must be stored with Y axis inverted
  59231. * @param premulAlpha defines if alpha is stored as premultiplied
  59232. * @param format defines the format of the data
  59233. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  59234. */
  59235. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  59236. /**
  59237. * Gets a boolean indicating if all created effects are ready
  59238. * @returns true if all effects are ready
  59239. */
  59240. areAllEffectsReady(): boolean;
  59241. /**
  59242. * @hidden
  59243. * Get the current error code of the webGL context
  59244. * @returns the error code
  59245. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  59246. */
  59247. getError(): number;
  59248. /** @hidden */
  59249. _getUnpackAlignement(): number;
  59250. /** @hidden */
  59251. _unpackFlipY(value: boolean): void;
  59252. /**
  59253. * Update a dynamic index buffer
  59254. * @param indexBuffer defines the target index buffer
  59255. * @param indices defines the data to update
  59256. * @param offset defines the offset in the target index buffer where update should start
  59257. */
  59258. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  59259. /**
  59260. * Updates a dynamic vertex buffer.
  59261. * @param vertexBuffer the vertex buffer to update
  59262. * @param vertices the data used to update the vertex buffer
  59263. * @param byteOffset the byte offset of the data (optional)
  59264. * @param byteLength the byte length of the data (optional)
  59265. */
  59266. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  59267. /** @hidden */
  59268. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  59269. /** @hidden */
  59270. _bindTexture(channel: number, texture: InternalTexture): void;
  59271. protected _deleteBuffer(buffer: WebGLBuffer): void;
  59272. /**
  59273. * 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
  59274. */
  59275. releaseEffects(): void;
  59276. displayLoadingUI(): void;
  59277. hideLoadingUI(): void;
  59278. /** @hidden */
  59279. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59280. /** @hidden */
  59281. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59282. /** @hidden */
  59283. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59284. /** @hidden */
  59285. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  59286. }
  59287. }
  59288. declare module BABYLON {
  59289. /** @hidden */
  59290. export class _OcclusionDataStorage {
  59291. /** @hidden */
  59292. occlusionInternalRetryCounter: number;
  59293. /** @hidden */
  59294. isOcclusionQueryInProgress: boolean;
  59295. /** @hidden */
  59296. isOccluded: boolean;
  59297. /** @hidden */
  59298. occlusionRetryCount: number;
  59299. /** @hidden */
  59300. occlusionType: number;
  59301. /** @hidden */
  59302. occlusionQueryAlgorithmType: number;
  59303. }
  59304. interface Engine {
  59305. /**
  59306. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  59307. * @return the new query
  59308. */
  59309. createQuery(): WebGLQuery;
  59310. /**
  59311. * Delete and release a webGL query
  59312. * @param query defines the query to delete
  59313. * @return the current engine
  59314. */
  59315. deleteQuery(query: WebGLQuery): Engine;
  59316. /**
  59317. * Check if a given query has resolved and got its value
  59318. * @param query defines the query to check
  59319. * @returns true if the query got its value
  59320. */
  59321. isQueryResultAvailable(query: WebGLQuery): boolean;
  59322. /**
  59323. * Gets the value of a given query
  59324. * @param query defines the query to check
  59325. * @returns the value of the query
  59326. */
  59327. getQueryResult(query: WebGLQuery): number;
  59328. /**
  59329. * Initiates an occlusion query
  59330. * @param algorithmType defines the algorithm to use
  59331. * @param query defines the query to use
  59332. * @returns the current engine
  59333. * @see https://doc.babylonjs.com/features/occlusionquery
  59334. */
  59335. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  59336. /**
  59337. * Ends an occlusion query
  59338. * @see https://doc.babylonjs.com/features/occlusionquery
  59339. * @param algorithmType defines the algorithm to use
  59340. * @returns the current engine
  59341. */
  59342. endOcclusionQuery(algorithmType: number): Engine;
  59343. /**
  59344. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  59345. * Please note that only one query can be issued at a time
  59346. * @returns a time token used to track the time span
  59347. */
  59348. startTimeQuery(): Nullable<_TimeToken>;
  59349. /**
  59350. * Ends a time query
  59351. * @param token defines the token used to measure the time span
  59352. * @returns the time spent (in ns)
  59353. */
  59354. endTimeQuery(token: _TimeToken): int;
  59355. /** @hidden */
  59356. _currentNonTimestampToken: Nullable<_TimeToken>;
  59357. /** @hidden */
  59358. _createTimeQuery(): WebGLQuery;
  59359. /** @hidden */
  59360. _deleteTimeQuery(query: WebGLQuery): void;
  59361. /** @hidden */
  59362. _getGlAlgorithmType(algorithmType: number): number;
  59363. /** @hidden */
  59364. _getTimeQueryResult(query: WebGLQuery): any;
  59365. /** @hidden */
  59366. _getTimeQueryAvailability(query: WebGLQuery): any;
  59367. }
  59368. interface AbstractMesh {
  59369. /**
  59370. * Backing filed
  59371. * @hidden
  59372. */
  59373. __occlusionDataStorage: _OcclusionDataStorage;
  59374. /**
  59375. * Access property
  59376. * @hidden
  59377. */
  59378. _occlusionDataStorage: _OcclusionDataStorage;
  59379. /**
  59380. * This number indicates the number of allowed retries before stop the occlusion query, this is useful if the occlusion query is taking long time before to the query result is retireved, the query result indicates if the object is visible within the scene or not and based on that Babylon.Js engine decideds to show or hide the object.
  59381. * The default value is -1 which means don't break the query and wait till the result
  59382. * @see https://doc.babylonjs.com/features/occlusionquery
  59383. */
  59384. occlusionRetryCount: number;
  59385. /**
  59386. * 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:
  59387. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  59388. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  59389. * * 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.
  59390. * @see https://doc.babylonjs.com/features/occlusionquery
  59391. */
  59392. occlusionType: number;
  59393. /**
  59394. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  59395. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  59396. * * 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.
  59397. * @see https://doc.babylonjs.com/features/occlusionquery
  59398. */
  59399. occlusionQueryAlgorithmType: number;
  59400. /**
  59401. * Gets or sets whether the mesh is occluded or not, it is used also to set the intial state of the mesh to be occluded or not
  59402. * @see https://doc.babylonjs.com/features/occlusionquery
  59403. */
  59404. isOccluded: boolean;
  59405. /**
  59406. * Flag to check the progress status of the query
  59407. * @see https://doc.babylonjs.com/features/occlusionquery
  59408. */
  59409. isOcclusionQueryInProgress: boolean;
  59410. }
  59411. }
  59412. declare module BABYLON {
  59413. /** @hidden */
  59414. export var _forceTransformFeedbackToBundle: boolean;
  59415. interface Engine {
  59416. /**
  59417. * Creates a webGL transform feedback object
  59418. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  59419. * @returns the webGL transform feedback object
  59420. */
  59421. createTransformFeedback(): WebGLTransformFeedback;
  59422. /**
  59423. * Delete a webGL transform feedback object
  59424. * @param value defines the webGL transform feedback object to delete
  59425. */
  59426. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  59427. /**
  59428. * Bind a webGL transform feedback object to the webgl context
  59429. * @param value defines the webGL transform feedback object to bind
  59430. */
  59431. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  59432. /**
  59433. * Begins a transform feedback operation
  59434. * @param usePoints defines if points or triangles must be used
  59435. */
  59436. beginTransformFeedback(usePoints: boolean): void;
  59437. /**
  59438. * Ends a transform feedback operation
  59439. */
  59440. endTransformFeedback(): void;
  59441. /**
  59442. * Specify the varyings to use with transform feedback
  59443. * @param program defines the associated webGL program
  59444. * @param value defines the list of strings representing the varying names
  59445. */
  59446. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  59447. /**
  59448. * Bind a webGL buffer for a transform feedback operation
  59449. * @param value defines the webGL buffer to bind
  59450. */
  59451. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  59452. }
  59453. }
  59454. declare module BABYLON {
  59455. /**
  59456. * Class used to define an additional view for the engine
  59457. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59458. */
  59459. export class EngineView {
  59460. /** Defines the canvas where to render the view */
  59461. target: HTMLCanvasElement;
  59462. /** Defines an optional camera used to render the view (will use active camera else) */
  59463. camera?: Camera;
  59464. }
  59465. interface Engine {
  59466. /**
  59467. * Gets or sets the HTML element to use for attaching events
  59468. */
  59469. inputElement: Nullable<HTMLElement>;
  59470. /**
  59471. * Gets the current engine view
  59472. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59473. */
  59474. activeView: Nullable<EngineView>;
  59475. /** Gets or sets the list of views */
  59476. views: EngineView[];
  59477. /**
  59478. * Register a new child canvas
  59479. * @param canvas defines the canvas to register
  59480. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  59481. * @returns the associated view
  59482. */
  59483. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  59484. /**
  59485. * Remove a registered child canvas
  59486. * @param canvas defines the canvas to remove
  59487. * @returns the current engine
  59488. */
  59489. unRegisterView(canvas: HTMLCanvasElement): Engine;
  59490. }
  59491. }
  59492. declare module BABYLON {
  59493. interface Engine {
  59494. /** @hidden */
  59495. _excludedCompressedTextures: string[];
  59496. /** @hidden */
  59497. _textureFormatInUse: string;
  59498. /**
  59499. * Gets the list of texture formats supported
  59500. */
  59501. readonly texturesSupported: Array<string>;
  59502. /**
  59503. * Gets the texture format in use
  59504. */
  59505. readonly textureFormatInUse: Nullable<string>;
  59506. /**
  59507. * Set the compressed texture extensions or file names to skip.
  59508. *
  59509. * @param skippedFiles defines the list of those texture files you want to skip
  59510. * Example: [".dds", ".env", "myfile.png"]
  59511. */
  59512. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  59513. /**
  59514. * Set the compressed texture format to use, based on the formats you have, and the formats
  59515. * supported by the hardware / browser.
  59516. *
  59517. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  59518. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  59519. * to API arguments needed to compressed textures. This puts the burden on the container
  59520. * generator to house the arcane code for determining these for current & future formats.
  59521. *
  59522. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59523. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59524. *
  59525. * Note: The result of this call is not taken into account when a texture is base64.
  59526. *
  59527. * @param formatsAvailable defines the list of those format families you have created
  59528. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  59529. *
  59530. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  59531. * @returns The extension selected.
  59532. */
  59533. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  59534. }
  59535. }
  59536. declare module BABYLON {
  59537. /** @hidden */
  59538. export var rgbdEncodePixelShader: {
  59539. name: string;
  59540. shader: string;
  59541. };
  59542. }
  59543. declare module BABYLON {
  59544. /**
  59545. * Raw texture data and descriptor sufficient for WebGL texture upload
  59546. */
  59547. export interface EnvironmentTextureInfo {
  59548. /**
  59549. * Version of the environment map
  59550. */
  59551. version: number;
  59552. /**
  59553. * Width of image
  59554. */
  59555. width: number;
  59556. /**
  59557. * Irradiance information stored in the file.
  59558. */
  59559. irradiance: any;
  59560. /**
  59561. * Specular information stored in the file.
  59562. */
  59563. specular: any;
  59564. }
  59565. /**
  59566. * Defines One Image in the file. It requires only the position in the file
  59567. * as well as the length.
  59568. */
  59569. interface BufferImageData {
  59570. /**
  59571. * Length of the image data.
  59572. */
  59573. length: number;
  59574. /**
  59575. * Position of the data from the null terminator delimiting the end of the JSON.
  59576. */
  59577. position: number;
  59578. }
  59579. /**
  59580. * Defines the specular data enclosed in the file.
  59581. * This corresponds to the version 1 of the data.
  59582. */
  59583. export interface EnvironmentTextureSpecularInfoV1 {
  59584. /**
  59585. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  59586. */
  59587. specularDataPosition?: number;
  59588. /**
  59589. * This contains all the images data needed to reconstruct the cubemap.
  59590. */
  59591. mipmaps: Array<BufferImageData>;
  59592. /**
  59593. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  59594. */
  59595. lodGenerationScale: number;
  59596. }
  59597. /**
  59598. * Sets of helpers addressing the serialization and deserialization of environment texture
  59599. * stored in a BabylonJS env file.
  59600. * Those files are usually stored as .env files.
  59601. */
  59602. export class EnvironmentTextureTools {
  59603. /**
  59604. * Magic number identifying the env file.
  59605. */
  59606. private static _MagicBytes;
  59607. /**
  59608. * Gets the environment info from an env file.
  59609. * @param data The array buffer containing the .env bytes.
  59610. * @returns the environment file info (the json header) if successfully parsed.
  59611. */
  59612. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  59613. /**
  59614. * Creates an environment texture from a loaded cube texture.
  59615. * @param texture defines the cube texture to convert in env file
  59616. * @return a promise containing the environment data if succesfull.
  59617. */
  59618. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  59619. /**
  59620. * Creates a JSON representation of the spherical data.
  59621. * @param texture defines the texture containing the polynomials
  59622. * @return the JSON representation of the spherical info
  59623. */
  59624. private static _CreateEnvTextureIrradiance;
  59625. /**
  59626. * Creates the ArrayBufferViews used for initializing environment texture image data.
  59627. * @param data the image data
  59628. * @param info parameters that determine what views will be created for accessing the underlying buffer
  59629. * @return the views described by info providing access to the underlying buffer
  59630. */
  59631. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  59632. /**
  59633. * Uploads the texture info contained in the env file to the GPU.
  59634. * @param texture defines the internal texture to upload to
  59635. * @param data defines the data to load
  59636. * @param info defines the texture info retrieved through the GetEnvInfo method
  59637. * @returns a promise
  59638. */
  59639. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  59640. private static _OnImageReadyAsync;
  59641. /**
  59642. * Uploads the levels of image data to the GPU.
  59643. * @param texture defines the internal texture to upload to
  59644. * @param imageData defines the array buffer views of image data [mipmap][face]
  59645. * @returns a promise
  59646. */
  59647. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  59648. /**
  59649. * Uploads spherical polynomials information to the texture.
  59650. * @param texture defines the texture we are trying to upload the information to
  59651. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  59652. */
  59653. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  59654. /** @hidden */
  59655. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59656. }
  59657. }
  59658. declare module BABYLON {
  59659. /**
  59660. * Container for accessors for natively-stored mesh data buffers.
  59661. */
  59662. class NativeDataBuffer extends DataBuffer {
  59663. /**
  59664. * Accessor value used to identify/retrieve a natively-stored index buffer.
  59665. */
  59666. nativeIndexBuffer?: any;
  59667. /**
  59668. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  59669. */
  59670. nativeVertexBuffer?: any;
  59671. }
  59672. /** @hidden */
  59673. class NativeTexture extends InternalTexture {
  59674. getInternalTexture(): InternalTexture;
  59675. getViewCount(): number;
  59676. }
  59677. /** @hidden */
  59678. export class NativeEngine extends Engine {
  59679. private readonly _native;
  59680. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  59681. private readonly INVALID_HANDLE;
  59682. private _boundBuffersVertexArray;
  59683. private _currentDepthTest;
  59684. getHardwareScalingLevel(): number;
  59685. constructor();
  59686. dispose(): void;
  59687. /**
  59688. * Can be used to override the current requestAnimationFrame requester.
  59689. * @hidden
  59690. */
  59691. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  59692. /**
  59693. * Override default engine behavior.
  59694. * @param color
  59695. * @param backBuffer
  59696. * @param depth
  59697. * @param stencil
  59698. */
  59699. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  59700. /**
  59701. * Gets host document
  59702. * @returns the host document object
  59703. */
  59704. getHostDocument(): Nullable<Document>;
  59705. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  59706. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  59707. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  59708. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  59709. [key: string]: VertexBuffer;
  59710. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  59711. bindBuffers(vertexBuffers: {
  59712. [key: string]: VertexBuffer;
  59713. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  59714. recordVertexArrayObject(vertexBuffers: {
  59715. [key: string]: VertexBuffer;
  59716. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  59717. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  59718. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  59719. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  59720. /**
  59721. * Draw a list of indexed primitives
  59722. * @param fillMode defines the primitive to use
  59723. * @param indexStart defines the starting index
  59724. * @param indexCount defines the number of index to draw
  59725. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59726. */
  59727. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  59728. /**
  59729. * Draw a list of unindexed primitives
  59730. * @param fillMode defines the primitive to use
  59731. * @param verticesStart defines the index of first vertex to draw
  59732. * @param verticesCount defines the count of vertices to draw
  59733. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59734. */
  59735. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  59736. createPipelineContext(): IPipelineContext;
  59737. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  59738. /** @hidden */
  59739. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  59740. /** @hidden */
  59741. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  59742. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  59743. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  59744. protected _setProgram(program: WebGLProgram): void;
  59745. _releaseEffect(effect: Effect): void;
  59746. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  59747. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  59748. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  59749. bindSamplers(effect: Effect): void;
  59750. setMatrix(uniform: WebGLUniformLocation, matrix: IMatrixLike): void;
  59751. getRenderWidth(useScreen?: boolean): number;
  59752. getRenderHeight(useScreen?: boolean): number;
  59753. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  59754. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  59755. /**
  59756. * Set the z offset to apply to current rendering
  59757. * @param value defines the offset to apply
  59758. */
  59759. setZOffset(value: number): void;
  59760. /**
  59761. * Gets the current value of the zOffset
  59762. * @returns the current zOffset state
  59763. */
  59764. getZOffset(): number;
  59765. /**
  59766. * Enable or disable depth buffering
  59767. * @param enable defines the state to set
  59768. */
  59769. setDepthBuffer(enable: boolean): void;
  59770. /**
  59771. * Gets a boolean indicating if depth writing is enabled
  59772. * @returns the current depth writing state
  59773. */
  59774. getDepthWrite(): boolean;
  59775. setDepthFunctionToGreater(): void;
  59776. setDepthFunctionToGreaterOrEqual(): void;
  59777. setDepthFunctionToLess(): void;
  59778. setDepthFunctionToLessOrEqual(): void;
  59779. /**
  59780. * Enable or disable depth writing
  59781. * @param enable defines the state to set
  59782. */
  59783. setDepthWrite(enable: boolean): void;
  59784. /**
  59785. * Enable or disable color writing
  59786. * @param enable defines the state to set
  59787. */
  59788. setColorWrite(enable: boolean): void;
  59789. /**
  59790. * Gets a boolean indicating if color writing is enabled
  59791. * @returns the current color writing state
  59792. */
  59793. getColorWrite(): boolean;
  59794. /**
  59795. * Sets alpha constants used by some alpha blending modes
  59796. * @param r defines the red component
  59797. * @param g defines the green component
  59798. * @param b defines the blue component
  59799. * @param a defines the alpha component
  59800. */
  59801. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  59802. /**
  59803. * Sets the current alpha mode
  59804. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  59805. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  59806. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59807. */
  59808. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  59809. /**
  59810. * Gets the current alpha mode
  59811. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59812. * @returns the current alpha mode
  59813. */
  59814. getAlphaMode(): number;
  59815. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  59816. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59817. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59818. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59819. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59820. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59821. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59822. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59823. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59824. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  59825. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  59826. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  59827. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  59828. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  59829. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59830. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59831. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  59832. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  59833. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  59834. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  59835. setColor3(uniform: WebGLUniformLocation, color3: IColor3Like): boolean;
  59836. setColor4(uniform: WebGLUniformLocation, color3: IColor3Like, alpha: number): boolean;
  59837. wipeCaches(bruteForce?: boolean): void;
  59838. protected _createTexture(): WebGLTexture;
  59839. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  59840. /**
  59841. * Update the content of a dynamic texture
  59842. * @param texture defines the texture to update
  59843. * @param canvas defines the canvas containing the source
  59844. * @param invertY defines if data must be stored with Y axis inverted
  59845. * @param premulAlpha defines if alpha is stored as premultiplied
  59846. * @param format defines the format of the data
  59847. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  59848. */
  59849. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  59850. /**
  59851. * Usually called from Texture.ts.
  59852. * Passed information to create a WebGLTexture
  59853. * @param url defines a value which contains one of the following:
  59854. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  59855. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  59856. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  59857. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  59858. * @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)
  59859. * @param scene needed for loading to the correct scene
  59860. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  59861. * @param onLoad optional callback to be called upon successful completion
  59862. * @param onError optional callback to be called upon failure
  59863. * @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
  59864. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  59865. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  59866. * @param forcedExtension defines the extension to use to pick the right loader
  59867. * @param mimeType defines an optional mime type
  59868. * @param loaderOptions options to be passed to the loader
  59869. * @returns a InternalTexture for assignment back into BABYLON.Texture
  59870. */
  59871. 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;
  59872. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  59873. _releaseFramebufferObjects(texture: InternalTexture): void;
  59874. /**
  59875. * Creates a cube texture
  59876. * @param rootUrl defines the url where the files to load is located
  59877. * @param scene defines the current scene
  59878. * @param files defines the list of files to load (1 per face)
  59879. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  59880. * @param onLoad defines an optional callback raised when the texture is loaded
  59881. * @param onError defines an optional callback raised if there is an issue to load the texture
  59882. * @param format defines the format of the data
  59883. * @param forcedExtension defines the extension to use to pick the right loader
  59884. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  59885. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59886. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59887. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  59888. * @returns the cube texture as an InternalTexture
  59889. */
  59890. 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;
  59891. createRenderTargetTexture(size: number | {
  59892. width: number;
  59893. height: number;
  59894. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  59895. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  59896. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  59897. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  59898. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  59899. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  59900. /**
  59901. * Updates a dynamic vertex buffer.
  59902. * @param vertexBuffer the vertex buffer to update
  59903. * @param data the data used to update the vertex buffer
  59904. * @param byteOffset the byte offset of the data (optional)
  59905. * @param byteLength the byte length of the data (optional)
  59906. */
  59907. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  59908. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  59909. private _updateAnisotropicLevel;
  59910. private _getAddressMode;
  59911. /** @hidden */
  59912. _bindTexture(channel: number, texture: InternalTexture): void;
  59913. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  59914. releaseEffects(): void;
  59915. /** @hidden */
  59916. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59917. /** @hidden */
  59918. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59919. /** @hidden */
  59920. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59921. /** @hidden */
  59922. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  59923. private _getNativeSamplingMode;
  59924. private _getNativeTextureFormat;
  59925. private _getNativeAlphaMode;
  59926. private _getNativeAttribType;
  59927. }
  59928. }
  59929. declare module BABYLON {
  59930. /**
  59931. * Gather the list of clipboard event types as constants.
  59932. */
  59933. export class ClipboardEventTypes {
  59934. /**
  59935. * The clipboard event is fired when a copy command is active (pressed).
  59936. */
  59937. static readonly COPY: number;
  59938. /**
  59939. * The clipboard event is fired when a cut command is active (pressed).
  59940. */
  59941. static readonly CUT: number;
  59942. /**
  59943. * The clipboard event is fired when a paste command is active (pressed).
  59944. */
  59945. static readonly PASTE: number;
  59946. }
  59947. /**
  59948. * This class is used to store clipboard related info for the onClipboardObservable event.
  59949. */
  59950. export class ClipboardInfo {
  59951. /**
  59952. * Defines the type of event (BABYLON.ClipboardEventTypes)
  59953. */
  59954. type: number;
  59955. /**
  59956. * Defines the related dom event
  59957. */
  59958. event: ClipboardEvent;
  59959. /**
  59960. *Creates an instance of ClipboardInfo.
  59961. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  59962. * @param event Defines the related dom event
  59963. */
  59964. constructor(
  59965. /**
  59966. * Defines the type of event (BABYLON.ClipboardEventTypes)
  59967. */
  59968. type: number,
  59969. /**
  59970. * Defines the related dom event
  59971. */
  59972. event: ClipboardEvent);
  59973. /**
  59974. * Get the clipboard event's type from the keycode.
  59975. * @param keyCode Defines the keyCode for the current keyboard event.
  59976. * @return {number}
  59977. */
  59978. static GetTypeFromCharacter(keyCode: number): number;
  59979. }
  59980. }
  59981. declare module BABYLON {
  59982. /**
  59983. * Google Daydream controller
  59984. */
  59985. export class DaydreamController extends WebVRController {
  59986. /**
  59987. * Base Url for the controller model.
  59988. */
  59989. static MODEL_BASE_URL: string;
  59990. /**
  59991. * File name for the controller model.
  59992. */
  59993. static MODEL_FILENAME: string;
  59994. /**
  59995. * Gamepad Id prefix used to identify Daydream Controller.
  59996. */
  59997. static readonly GAMEPAD_ID_PREFIX: string;
  59998. /**
  59999. * Creates a new DaydreamController from a gamepad
  60000. * @param vrGamepad the gamepad that the controller should be created from
  60001. */
  60002. constructor(vrGamepad: any);
  60003. /**
  60004. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60005. * @param scene scene in which to add meshes
  60006. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60007. */
  60008. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60009. /**
  60010. * Called once for each button that changed state since the last frame
  60011. * @param buttonIdx Which button index changed
  60012. * @param state New state of the button
  60013. * @param changes Which properties on the state changed since last frame
  60014. */
  60015. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60016. }
  60017. }
  60018. declare module BABYLON {
  60019. /**
  60020. * Gear VR Controller
  60021. */
  60022. export class GearVRController extends WebVRController {
  60023. /**
  60024. * Base Url for the controller model.
  60025. */
  60026. static MODEL_BASE_URL: string;
  60027. /**
  60028. * File name for the controller model.
  60029. */
  60030. static MODEL_FILENAME: string;
  60031. /**
  60032. * Gamepad Id prefix used to identify this controller.
  60033. */
  60034. static readonly GAMEPAD_ID_PREFIX: string;
  60035. private readonly _buttonIndexToObservableNameMap;
  60036. /**
  60037. * Creates a new GearVRController from a gamepad
  60038. * @param vrGamepad the gamepad that the controller should be created from
  60039. */
  60040. constructor(vrGamepad: any);
  60041. /**
  60042. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60043. * @param scene scene in which to add meshes
  60044. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60045. */
  60046. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60047. /**
  60048. * Called once for each button that changed state since the last frame
  60049. * @param buttonIdx Which button index changed
  60050. * @param state New state of the button
  60051. * @param changes Which properties on the state changed since last frame
  60052. */
  60053. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60054. }
  60055. }
  60056. declare module BABYLON {
  60057. /**
  60058. * Generic Controller
  60059. */
  60060. export class GenericController extends WebVRController {
  60061. /**
  60062. * Base Url for the controller model.
  60063. */
  60064. static readonly MODEL_BASE_URL: string;
  60065. /**
  60066. * File name for the controller model.
  60067. */
  60068. static readonly MODEL_FILENAME: string;
  60069. /**
  60070. * Creates a new GenericController from a gamepad
  60071. * @param vrGamepad the gamepad that the controller should be created from
  60072. */
  60073. constructor(vrGamepad: any);
  60074. /**
  60075. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60076. * @param scene scene in which to add meshes
  60077. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60078. */
  60079. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60080. /**
  60081. * Called once for each button that changed state since the last frame
  60082. * @param buttonIdx Which button index changed
  60083. * @param state New state of the button
  60084. * @param changes Which properties on the state changed since last frame
  60085. */
  60086. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60087. }
  60088. }
  60089. declare module BABYLON {
  60090. /**
  60091. * Oculus Touch Controller
  60092. */
  60093. export class OculusTouchController extends WebVRController {
  60094. /**
  60095. * Base Url for the controller model.
  60096. */
  60097. static MODEL_BASE_URL: string;
  60098. /**
  60099. * File name for the left controller model.
  60100. */
  60101. static MODEL_LEFT_FILENAME: string;
  60102. /**
  60103. * File name for the right controller model.
  60104. */
  60105. static MODEL_RIGHT_FILENAME: string;
  60106. /**
  60107. * Base Url for the Quest controller model.
  60108. */
  60109. static QUEST_MODEL_BASE_URL: string;
  60110. /**
  60111. * @hidden
  60112. * If the controllers are running on a device that needs the updated Quest controller models
  60113. */
  60114. static _IsQuest: boolean;
  60115. /**
  60116. * Fired when the secondary trigger on this controller is modified
  60117. */
  60118. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  60119. /**
  60120. * Fired when the thumb rest on this controller is modified
  60121. */
  60122. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  60123. /**
  60124. * Creates a new OculusTouchController from a gamepad
  60125. * @param vrGamepad the gamepad that the controller should be created from
  60126. */
  60127. constructor(vrGamepad: any);
  60128. /**
  60129. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60130. * @param scene scene in which to add meshes
  60131. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60132. */
  60133. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60134. /**
  60135. * Fired when the A button on this controller is modified
  60136. */
  60137. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60138. /**
  60139. * Fired when the B button on this controller is modified
  60140. */
  60141. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60142. /**
  60143. * Fired when the X button on this controller is modified
  60144. */
  60145. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60146. /**
  60147. * Fired when the Y button on this controller is modified
  60148. */
  60149. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60150. /**
  60151. * Called once for each button that changed state since the last frame
  60152. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  60153. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  60154. * 2) secondary trigger (same)
  60155. * 3) A (right) X (left), touch, pressed = value
  60156. * 4) B / Y
  60157. * 5) thumb rest
  60158. * @param buttonIdx Which button index changed
  60159. * @param state New state of the button
  60160. * @param changes Which properties on the state changed since last frame
  60161. */
  60162. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60163. }
  60164. }
  60165. declare module BABYLON {
  60166. /**
  60167. * Vive Controller
  60168. */
  60169. export class ViveController extends WebVRController {
  60170. /**
  60171. * Base Url for the controller model.
  60172. */
  60173. static MODEL_BASE_URL: string;
  60174. /**
  60175. * File name for the controller model.
  60176. */
  60177. static MODEL_FILENAME: string;
  60178. /**
  60179. * Creates a new ViveController from a gamepad
  60180. * @param vrGamepad the gamepad that the controller should be created from
  60181. */
  60182. constructor(vrGamepad: any);
  60183. /**
  60184. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60185. * @param scene scene in which to add meshes
  60186. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60187. */
  60188. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60189. /**
  60190. * Fired when the left button on this controller is modified
  60191. */
  60192. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60193. /**
  60194. * Fired when the right button on this controller is modified
  60195. */
  60196. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60197. /**
  60198. * Fired when the menu button on this controller is modified
  60199. */
  60200. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60201. /**
  60202. * Called once for each button that changed state since the last frame
  60203. * Vive mapping:
  60204. * 0: touchpad
  60205. * 1: trigger
  60206. * 2: left AND right buttons
  60207. * 3: menu button
  60208. * @param buttonIdx Which button index changed
  60209. * @param state New state of the button
  60210. * @param changes Which properties on the state changed since last frame
  60211. */
  60212. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60213. }
  60214. }
  60215. declare module BABYLON {
  60216. /**
  60217. * Defines the WindowsMotionController object that the state of the windows motion controller
  60218. */
  60219. export class WindowsMotionController extends WebVRController {
  60220. /**
  60221. * The base url used to load the left and right controller models
  60222. */
  60223. static MODEL_BASE_URL: string;
  60224. /**
  60225. * The name of the left controller model file
  60226. */
  60227. static MODEL_LEFT_FILENAME: string;
  60228. /**
  60229. * The name of the right controller model file
  60230. */
  60231. static MODEL_RIGHT_FILENAME: string;
  60232. /**
  60233. * The controller name prefix for this controller type
  60234. */
  60235. static readonly GAMEPAD_ID_PREFIX: string;
  60236. /**
  60237. * The controller id pattern for this controller type
  60238. */
  60239. private static readonly GAMEPAD_ID_PATTERN;
  60240. private _loadedMeshInfo;
  60241. protected readonly _mapping: {
  60242. buttons: string[];
  60243. buttonMeshNames: {
  60244. trigger: string;
  60245. menu: string;
  60246. grip: string;
  60247. thumbstick: string;
  60248. trackpad: string;
  60249. };
  60250. buttonObservableNames: {
  60251. trigger: string;
  60252. menu: string;
  60253. grip: string;
  60254. thumbstick: string;
  60255. trackpad: string;
  60256. };
  60257. axisMeshNames: string[];
  60258. pointingPoseMeshName: string;
  60259. };
  60260. /**
  60261. * Fired when the trackpad on this controller is clicked
  60262. */
  60263. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60264. /**
  60265. * Fired when the trackpad on this controller is modified
  60266. */
  60267. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60268. /**
  60269. * The current x and y values of this controller's trackpad
  60270. */
  60271. trackpad: StickValues;
  60272. /**
  60273. * Creates a new WindowsMotionController from a gamepad
  60274. * @param vrGamepad the gamepad that the controller should be created from
  60275. */
  60276. constructor(vrGamepad: any);
  60277. /**
  60278. * Fired when the trigger on this controller is modified
  60279. */
  60280. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60281. /**
  60282. * Fired when the menu button on this controller is modified
  60283. */
  60284. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60285. /**
  60286. * Fired when the grip button on this controller is modified
  60287. */
  60288. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60289. /**
  60290. * Fired when the thumbstick button on this controller is modified
  60291. */
  60292. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60293. /**
  60294. * Fired when the touchpad button on this controller is modified
  60295. */
  60296. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60297. /**
  60298. * Fired when the touchpad values on this controller are modified
  60299. */
  60300. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  60301. protected _updateTrackpad(): void;
  60302. /**
  60303. * Called once per frame by the engine.
  60304. */
  60305. update(): void;
  60306. /**
  60307. * Called once for each button that changed state since the last frame
  60308. * @param buttonIdx Which button index changed
  60309. * @param state New state of the button
  60310. * @param changes Which properties on the state changed since last frame
  60311. */
  60312. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60313. /**
  60314. * Moves the buttons on the controller mesh based on their current state
  60315. * @param buttonName the name of the button to move
  60316. * @param buttonValue the value of the button which determines the buttons new position
  60317. */
  60318. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  60319. /**
  60320. * Moves the axis on the controller mesh based on its current state
  60321. * @param axis the index of the axis
  60322. * @param axisValue the value of the axis which determines the meshes new position
  60323. * @hidden
  60324. */
  60325. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  60326. /**
  60327. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60328. * @param scene scene in which to add meshes
  60329. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60330. */
  60331. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  60332. /**
  60333. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  60334. * can be transformed by button presses and axes values, based on this._mapping.
  60335. *
  60336. * @param scene scene in which the meshes exist
  60337. * @param meshes list of meshes that make up the controller model to process
  60338. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  60339. */
  60340. private processModel;
  60341. private createMeshInfo;
  60342. /**
  60343. * Gets the ray of the controller in the direction the controller is pointing
  60344. * @param length the length the resulting ray should be
  60345. * @returns a ray in the direction the controller is pointing
  60346. */
  60347. getForwardRay(length?: number): Ray;
  60348. /**
  60349. * Disposes of the controller
  60350. */
  60351. dispose(): void;
  60352. }
  60353. /**
  60354. * This class represents a new windows motion controller in XR.
  60355. */
  60356. export class XRWindowsMotionController extends WindowsMotionController {
  60357. /**
  60358. * Changing the original WIndowsMotionController mapping to fir the new mapping
  60359. */
  60360. protected readonly _mapping: {
  60361. buttons: string[];
  60362. buttonMeshNames: {
  60363. trigger: string;
  60364. menu: string;
  60365. grip: string;
  60366. thumbstick: string;
  60367. trackpad: string;
  60368. };
  60369. buttonObservableNames: {
  60370. trigger: string;
  60371. menu: string;
  60372. grip: string;
  60373. thumbstick: string;
  60374. trackpad: string;
  60375. };
  60376. axisMeshNames: string[];
  60377. pointingPoseMeshName: string;
  60378. };
  60379. /**
  60380. * Construct a new XR-Based windows motion controller
  60381. *
  60382. * @param gamepadInfo the gamepad object from the browser
  60383. */
  60384. constructor(gamepadInfo: any);
  60385. /**
  60386. * holds the thumbstick values (X,Y)
  60387. */
  60388. thumbstickValues: StickValues;
  60389. /**
  60390. * Fired when the thumbstick on this controller is clicked
  60391. */
  60392. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  60393. /**
  60394. * Fired when the thumbstick on this controller is modified
  60395. */
  60396. onThumbstickValuesChangedObservable: Observable<StickValues>;
  60397. /**
  60398. * Fired when the touchpad button on this controller is modified
  60399. */
  60400. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60401. /**
  60402. * Fired when the touchpad values on this controller are modified
  60403. */
  60404. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60405. /**
  60406. * Fired when the thumbstick button on this controller is modified
  60407. * here to prevent breaking changes
  60408. */
  60409. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60410. /**
  60411. * updating the thumbstick(!) and not the trackpad.
  60412. * This is named this way due to the difference between WebVR and XR and to avoid
  60413. * changing the parent class.
  60414. */
  60415. protected _updateTrackpad(): void;
  60416. /**
  60417. * Disposes the class with joy
  60418. */
  60419. dispose(): void;
  60420. }
  60421. }
  60422. declare module BABYLON {
  60423. /**
  60424. * A directional light is defined by a direction (what a surprise!).
  60425. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  60426. * 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.
  60427. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60428. */
  60429. export class DirectionalLight extends ShadowLight {
  60430. private _shadowFrustumSize;
  60431. /**
  60432. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  60433. */
  60434. get shadowFrustumSize(): number;
  60435. /**
  60436. * Specifies a fix frustum size for the shadow generation.
  60437. */
  60438. set shadowFrustumSize(value: number);
  60439. private _shadowOrthoScale;
  60440. /**
  60441. * Gets the shadow projection scale against the optimal computed one.
  60442. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60443. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60444. */
  60445. get shadowOrthoScale(): number;
  60446. /**
  60447. * Sets the shadow projection scale against the optimal computed one.
  60448. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60449. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60450. */
  60451. set shadowOrthoScale(value: number);
  60452. /**
  60453. * Automatically compute the projection matrix to best fit (including all the casters)
  60454. * on each frame.
  60455. */
  60456. autoUpdateExtends: boolean;
  60457. /**
  60458. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  60459. * on each frame. autoUpdateExtends must be set to true for this to work
  60460. */
  60461. autoCalcShadowZBounds: boolean;
  60462. private _orthoLeft;
  60463. private _orthoRight;
  60464. private _orthoTop;
  60465. private _orthoBottom;
  60466. /**
  60467. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  60468. * The directional light is emitted from everywhere in the given direction.
  60469. * It can cast shadows.
  60470. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60471. * @param name The friendly name of the light
  60472. * @param direction The direction of the light
  60473. * @param scene The scene the light belongs to
  60474. */
  60475. constructor(name: string, direction: Vector3, scene: Scene);
  60476. /**
  60477. * Returns the string "DirectionalLight".
  60478. * @return The class name
  60479. */
  60480. getClassName(): string;
  60481. /**
  60482. * Returns the integer 1.
  60483. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60484. */
  60485. getTypeID(): number;
  60486. /**
  60487. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  60488. * Returns the DirectionalLight Shadow projection matrix.
  60489. */
  60490. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60491. /**
  60492. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  60493. * Returns the DirectionalLight Shadow projection matrix.
  60494. */
  60495. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  60496. /**
  60497. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  60498. * Returns the DirectionalLight Shadow projection matrix.
  60499. */
  60500. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60501. protected _buildUniformLayout(): void;
  60502. /**
  60503. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  60504. * @param effect The effect to update
  60505. * @param lightIndex The index of the light in the effect to update
  60506. * @returns The directional light
  60507. */
  60508. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  60509. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  60510. /**
  60511. * Gets the minZ used for shadow according to both the scene and the light.
  60512. *
  60513. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  60514. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  60515. * @param activeCamera The camera we are returning the min for
  60516. * @returns the depth min z
  60517. */
  60518. getDepthMinZ(activeCamera: Camera): number;
  60519. /**
  60520. * Gets the maxZ used for shadow according to both the scene and the light.
  60521. *
  60522. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  60523. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  60524. * @param activeCamera The camera we are returning the max for
  60525. * @returns the depth max z
  60526. */
  60527. getDepthMaxZ(activeCamera: Camera): number;
  60528. /**
  60529. * Prepares the list of defines specific to the light type.
  60530. * @param defines the list of defines
  60531. * @param lightIndex defines the index of the light for the effect
  60532. */
  60533. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60534. }
  60535. }
  60536. declare module BABYLON {
  60537. /**
  60538. * Class containing static functions to help procedurally build meshes
  60539. */
  60540. export class HemisphereBuilder {
  60541. /**
  60542. * Creates a hemisphere mesh
  60543. * @param name defines the name of the mesh
  60544. * @param options defines the options used to create the mesh
  60545. * @param scene defines the hosting scene
  60546. * @returns the hemisphere mesh
  60547. */
  60548. static CreateHemisphere(name: string, options: {
  60549. segments?: number;
  60550. diameter?: number;
  60551. sideOrientation?: number;
  60552. }, scene: any): Mesh;
  60553. }
  60554. }
  60555. declare module BABYLON {
  60556. /**
  60557. * A spot light is defined by a position, a direction, an angle, and an exponent.
  60558. * These values define a cone of light starting from the position, emitting toward the direction.
  60559. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  60560. * and the exponent defines the speed of the decay of the light with distance (reach).
  60561. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60562. */
  60563. export class SpotLight extends ShadowLight {
  60564. private _angle;
  60565. private _innerAngle;
  60566. private _cosHalfAngle;
  60567. private _lightAngleScale;
  60568. private _lightAngleOffset;
  60569. /**
  60570. * Gets the cone angle of the spot light in Radians.
  60571. */
  60572. get angle(): number;
  60573. /**
  60574. * Sets the cone angle of the spot light in Radians.
  60575. */
  60576. set angle(value: number);
  60577. /**
  60578. * Only used in gltf falloff mode, this defines the angle where
  60579. * the directional falloff will start before cutting at angle which could be seen
  60580. * as outer angle.
  60581. */
  60582. get innerAngle(): number;
  60583. /**
  60584. * Only used in gltf falloff mode, this defines the angle where
  60585. * the directional falloff will start before cutting at angle which could be seen
  60586. * as outer angle.
  60587. */
  60588. set innerAngle(value: number);
  60589. private _shadowAngleScale;
  60590. /**
  60591. * Allows scaling the angle of the light for shadow generation only.
  60592. */
  60593. get shadowAngleScale(): number;
  60594. /**
  60595. * Allows scaling the angle of the light for shadow generation only.
  60596. */
  60597. set shadowAngleScale(value: number);
  60598. /**
  60599. * The light decay speed with the distance from the emission spot.
  60600. */
  60601. exponent: number;
  60602. private _projectionTextureMatrix;
  60603. /**
  60604. * Allows reading the projecton texture
  60605. */
  60606. get projectionTextureMatrix(): Matrix;
  60607. protected _projectionTextureLightNear: number;
  60608. /**
  60609. * Gets the near clip of the Spotlight for texture projection.
  60610. */
  60611. get projectionTextureLightNear(): number;
  60612. /**
  60613. * Sets the near clip of the Spotlight for texture projection.
  60614. */
  60615. set projectionTextureLightNear(value: number);
  60616. protected _projectionTextureLightFar: number;
  60617. /**
  60618. * Gets the far clip of the Spotlight for texture projection.
  60619. */
  60620. get projectionTextureLightFar(): number;
  60621. /**
  60622. * Sets the far clip of the Spotlight for texture projection.
  60623. */
  60624. set projectionTextureLightFar(value: number);
  60625. protected _projectionTextureUpDirection: Vector3;
  60626. /**
  60627. * Gets the Up vector of the Spotlight for texture projection.
  60628. */
  60629. get projectionTextureUpDirection(): Vector3;
  60630. /**
  60631. * Sets the Up vector of the Spotlight for texture projection.
  60632. */
  60633. set projectionTextureUpDirection(value: Vector3);
  60634. private _projectionTexture;
  60635. /**
  60636. * Gets the projection texture of the light.
  60637. */
  60638. get projectionTexture(): Nullable<BaseTexture>;
  60639. /**
  60640. * Sets the projection texture of the light.
  60641. */
  60642. set projectionTexture(value: Nullable<BaseTexture>);
  60643. private static _IsProceduralTexture;
  60644. private static _IsTexture;
  60645. private _projectionTextureViewLightDirty;
  60646. private _projectionTextureProjectionLightDirty;
  60647. private _projectionTextureDirty;
  60648. private _projectionTextureViewTargetVector;
  60649. private _projectionTextureViewLightMatrix;
  60650. private _projectionTextureProjectionLightMatrix;
  60651. private _projectionTextureScalingMatrix;
  60652. /**
  60653. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  60654. * It can cast shadows.
  60655. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60656. * @param name The light friendly name
  60657. * @param position The position of the spot light in the scene
  60658. * @param direction The direction of the light in the scene
  60659. * @param angle The cone angle of the light in Radians
  60660. * @param exponent The light decay speed with the distance from the emission spot
  60661. * @param scene The scene the lights belongs to
  60662. */
  60663. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  60664. /**
  60665. * Returns the string "SpotLight".
  60666. * @returns the class name
  60667. */
  60668. getClassName(): string;
  60669. /**
  60670. * Returns the integer 2.
  60671. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60672. */
  60673. getTypeID(): number;
  60674. /**
  60675. * Overrides the direction setter to recompute the projection texture view light Matrix.
  60676. */
  60677. protected _setDirection(value: Vector3): void;
  60678. /**
  60679. * Overrides the position setter to recompute the projection texture view light Matrix.
  60680. */
  60681. protected _setPosition(value: Vector3): void;
  60682. /**
  60683. * 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.
  60684. * Returns the SpotLight.
  60685. */
  60686. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60687. protected _computeProjectionTextureViewLightMatrix(): void;
  60688. protected _computeProjectionTextureProjectionLightMatrix(): void;
  60689. /**
  60690. * Main function for light texture projection matrix computing.
  60691. */
  60692. protected _computeProjectionTextureMatrix(): void;
  60693. protected _buildUniformLayout(): void;
  60694. private _computeAngleValues;
  60695. /**
  60696. * Sets the passed Effect "effect" with the Light textures.
  60697. * @param effect The effect to update
  60698. * @param lightIndex The index of the light in the effect to update
  60699. * @returns The light
  60700. */
  60701. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  60702. /**
  60703. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  60704. * @param effect The effect to update
  60705. * @param lightIndex The index of the light in the effect to update
  60706. * @returns The spot light
  60707. */
  60708. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  60709. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60710. /**
  60711. * Disposes the light and the associated resources.
  60712. */
  60713. dispose(): void;
  60714. /**
  60715. * Prepares the list of defines specific to the light type.
  60716. * @param defines the list of defines
  60717. * @param lightIndex defines the index of the light for the effect
  60718. */
  60719. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60720. }
  60721. }
  60722. declare module BABYLON {
  60723. /**
  60724. * Gizmo that enables viewing a light
  60725. */
  60726. export class LightGizmo extends Gizmo {
  60727. private _lightMesh;
  60728. private _material;
  60729. private _cachedPosition;
  60730. private _cachedForward;
  60731. private _attachedMeshParent;
  60732. private _pointerObserver;
  60733. /**
  60734. * Event that fires each time the gizmo is clicked
  60735. */
  60736. onClickedObservable: Observable<Light>;
  60737. /**
  60738. * Creates a LightGizmo
  60739. * @param gizmoLayer The utility layer the gizmo will be added to
  60740. */
  60741. constructor(gizmoLayer?: UtilityLayerRenderer);
  60742. private _light;
  60743. /**
  60744. * The light that the gizmo is attached to
  60745. */
  60746. set light(light: Nullable<Light>);
  60747. get light(): Nullable<Light>;
  60748. /**
  60749. * Gets the material used to render the light gizmo
  60750. */
  60751. get material(): StandardMaterial;
  60752. /**
  60753. * @hidden
  60754. * Updates the gizmo to match the attached mesh's position/rotation
  60755. */
  60756. protected _update(): void;
  60757. private static _Scale;
  60758. /**
  60759. * Creates the lines for a light mesh
  60760. */
  60761. private static _CreateLightLines;
  60762. /**
  60763. * Disposes of the light gizmo
  60764. */
  60765. dispose(): void;
  60766. private static _CreateHemisphericLightMesh;
  60767. private static _CreatePointLightMesh;
  60768. private static _CreateSpotLightMesh;
  60769. private static _CreateDirectionalLightMesh;
  60770. }
  60771. }
  60772. declare module BABYLON {
  60773. /**
  60774. * Gizmo that enables viewing a camera
  60775. */
  60776. export class CameraGizmo extends Gizmo {
  60777. private _cameraMesh;
  60778. private _cameraLinesMesh;
  60779. private _material;
  60780. private _pointerObserver;
  60781. /**
  60782. * Event that fires each time the gizmo is clicked
  60783. */
  60784. onClickedObservable: Observable<Camera>;
  60785. /**
  60786. * Creates a CameraGizmo
  60787. * @param gizmoLayer The utility layer the gizmo will be added to
  60788. */
  60789. constructor(gizmoLayer?: UtilityLayerRenderer);
  60790. private _camera;
  60791. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  60792. get displayFrustum(): boolean;
  60793. set displayFrustum(value: boolean);
  60794. /**
  60795. * The camera that the gizmo is attached to
  60796. */
  60797. set camera(camera: Nullable<Camera>);
  60798. get camera(): Nullable<Camera>;
  60799. /**
  60800. * Gets the material used to render the camera gizmo
  60801. */
  60802. get material(): StandardMaterial;
  60803. /**
  60804. * @hidden
  60805. * Updates the gizmo to match the attached mesh's position/rotation
  60806. */
  60807. protected _update(): void;
  60808. private static _Scale;
  60809. private _invProjection;
  60810. /**
  60811. * Disposes of the camera gizmo
  60812. */
  60813. dispose(): void;
  60814. private static _CreateCameraMesh;
  60815. private static _CreateCameraFrustum;
  60816. }
  60817. }
  60818. declare module BABYLON {
  60819. /** @hidden */
  60820. export var backgroundFragmentDeclaration: {
  60821. name: string;
  60822. shader: string;
  60823. };
  60824. }
  60825. declare module BABYLON {
  60826. /** @hidden */
  60827. export var backgroundUboDeclaration: {
  60828. name: string;
  60829. shader: string;
  60830. };
  60831. }
  60832. declare module BABYLON {
  60833. /** @hidden */
  60834. export var backgroundPixelShader: {
  60835. name: string;
  60836. shader: string;
  60837. };
  60838. }
  60839. declare module BABYLON {
  60840. /** @hidden */
  60841. export var backgroundVertexDeclaration: {
  60842. name: string;
  60843. shader: string;
  60844. };
  60845. }
  60846. declare module BABYLON {
  60847. /** @hidden */
  60848. export var backgroundVertexShader: {
  60849. name: string;
  60850. shader: string;
  60851. };
  60852. }
  60853. declare module BABYLON {
  60854. /**
  60855. * Background material used to create an efficient environement around your scene.
  60856. */
  60857. export class BackgroundMaterial extends PushMaterial {
  60858. /**
  60859. * Standard reflectance value at parallel view angle.
  60860. */
  60861. static StandardReflectance0: number;
  60862. /**
  60863. * Standard reflectance value at grazing angle.
  60864. */
  60865. static StandardReflectance90: number;
  60866. protected _primaryColor: Color3;
  60867. /**
  60868. * Key light Color (multiply against the environement texture)
  60869. */
  60870. primaryColor: Color3;
  60871. protected __perceptualColor: Nullable<Color3>;
  60872. /**
  60873. * Experimental Internal Use Only.
  60874. *
  60875. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  60876. * This acts as a helper to set the primary color to a more "human friendly" value.
  60877. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  60878. * output color as close as possible from the chosen value.
  60879. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  60880. * part of lighting setup.)
  60881. */
  60882. get _perceptualColor(): Nullable<Color3>;
  60883. set _perceptualColor(value: Nullable<Color3>);
  60884. protected _primaryColorShadowLevel: float;
  60885. /**
  60886. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  60887. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  60888. */
  60889. get primaryColorShadowLevel(): float;
  60890. set primaryColorShadowLevel(value: float);
  60891. protected _primaryColorHighlightLevel: float;
  60892. /**
  60893. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  60894. * The primary color is used at the level chosen to define what the white area would look.
  60895. */
  60896. get primaryColorHighlightLevel(): float;
  60897. set primaryColorHighlightLevel(value: float);
  60898. protected _reflectionTexture: Nullable<BaseTexture>;
  60899. /**
  60900. * Reflection Texture used in the material.
  60901. * Should be author in a specific way for the best result (refer to the documentation).
  60902. */
  60903. reflectionTexture: Nullable<BaseTexture>;
  60904. protected _reflectionBlur: float;
  60905. /**
  60906. * Reflection Texture level of blur.
  60907. *
  60908. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  60909. * texture twice.
  60910. */
  60911. reflectionBlur: float;
  60912. protected _diffuseTexture: Nullable<BaseTexture>;
  60913. /**
  60914. * Diffuse Texture used in the material.
  60915. * Should be author in a specific way for the best result (refer to the documentation).
  60916. */
  60917. diffuseTexture: Nullable<BaseTexture>;
  60918. protected _shadowLights: Nullable<IShadowLight[]>;
  60919. /**
  60920. * Specify the list of lights casting shadow on the material.
  60921. * All scene shadow lights will be included if null.
  60922. */
  60923. shadowLights: Nullable<IShadowLight[]>;
  60924. protected _shadowLevel: float;
  60925. /**
  60926. * Helps adjusting the shadow to a softer level if required.
  60927. * 0 means black shadows and 1 means no shadows.
  60928. */
  60929. shadowLevel: float;
  60930. protected _sceneCenter: Vector3;
  60931. /**
  60932. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  60933. * It is usually zero but might be interesting to modify according to your setup.
  60934. */
  60935. sceneCenter: Vector3;
  60936. protected _opacityFresnel: boolean;
  60937. /**
  60938. * This helps specifying that the material is falling off to the sky box at grazing angle.
  60939. * This helps ensuring a nice transition when the camera goes under the ground.
  60940. */
  60941. opacityFresnel: boolean;
  60942. protected _reflectionFresnel: boolean;
  60943. /**
  60944. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  60945. * This helps adding a mirror texture on the ground.
  60946. */
  60947. reflectionFresnel: boolean;
  60948. protected _reflectionFalloffDistance: number;
  60949. /**
  60950. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  60951. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  60952. */
  60953. reflectionFalloffDistance: number;
  60954. protected _reflectionAmount: number;
  60955. /**
  60956. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  60957. */
  60958. reflectionAmount: number;
  60959. protected _reflectionReflectance0: number;
  60960. /**
  60961. * This specifies the weight of the reflection at grazing angle.
  60962. */
  60963. reflectionReflectance0: number;
  60964. protected _reflectionReflectance90: number;
  60965. /**
  60966. * This specifies the weight of the reflection at a perpendicular point of view.
  60967. */
  60968. reflectionReflectance90: number;
  60969. /**
  60970. * Sets the reflection reflectance fresnel values according to the default standard
  60971. * empirically know to work well :-)
  60972. */
  60973. set reflectionStandardFresnelWeight(value: number);
  60974. protected _useRGBColor: boolean;
  60975. /**
  60976. * Helps to directly use the maps channels instead of their level.
  60977. */
  60978. useRGBColor: boolean;
  60979. protected _enableNoise: boolean;
  60980. /**
  60981. * This helps reducing the banding effect that could occur on the background.
  60982. */
  60983. enableNoise: boolean;
  60984. /**
  60985. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60986. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  60987. * Recommended to be keep at 1.0 except for special cases.
  60988. */
  60989. get fovMultiplier(): number;
  60990. set fovMultiplier(value: number);
  60991. private _fovMultiplier;
  60992. /**
  60993. * Enable the FOV adjustment feature controlled by fovMultiplier.
  60994. */
  60995. useEquirectangularFOV: boolean;
  60996. private _maxSimultaneousLights;
  60997. /**
  60998. * Number of Simultaneous lights allowed on the material.
  60999. */
  61000. maxSimultaneousLights: int;
  61001. private _shadowOnly;
  61002. /**
  61003. * Make the material only render shadows
  61004. */
  61005. shadowOnly: boolean;
  61006. /**
  61007. * Default configuration related to image processing available in the Background Material.
  61008. */
  61009. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  61010. /**
  61011. * Keep track of the image processing observer to allow dispose and replace.
  61012. */
  61013. private _imageProcessingObserver;
  61014. /**
  61015. * Attaches a new image processing configuration to the PBR Material.
  61016. * @param configuration (if null the scene configuration will be use)
  61017. */
  61018. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  61019. /**
  61020. * Gets the image processing configuration used either in this material.
  61021. */
  61022. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  61023. /**
  61024. * Sets the Default image processing configuration used either in the this material.
  61025. *
  61026. * If sets to null, the scene one is in use.
  61027. */
  61028. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  61029. /**
  61030. * Gets wether the color curves effect is enabled.
  61031. */
  61032. get cameraColorCurvesEnabled(): boolean;
  61033. /**
  61034. * Sets wether the color curves effect is enabled.
  61035. */
  61036. set cameraColorCurvesEnabled(value: boolean);
  61037. /**
  61038. * Gets wether the color grading effect is enabled.
  61039. */
  61040. get cameraColorGradingEnabled(): boolean;
  61041. /**
  61042. * Gets wether the color grading effect is enabled.
  61043. */
  61044. set cameraColorGradingEnabled(value: boolean);
  61045. /**
  61046. * Gets wether tonemapping is enabled or not.
  61047. */
  61048. get cameraToneMappingEnabled(): boolean;
  61049. /**
  61050. * Sets wether tonemapping is enabled or not
  61051. */
  61052. set cameraToneMappingEnabled(value: boolean);
  61053. /**
  61054. * The camera exposure used on this material.
  61055. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61056. * This corresponds to a photographic exposure.
  61057. */
  61058. get cameraExposure(): float;
  61059. /**
  61060. * The camera exposure used on this material.
  61061. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61062. * This corresponds to a photographic exposure.
  61063. */
  61064. set cameraExposure(value: float);
  61065. /**
  61066. * Gets The camera contrast used on this material.
  61067. */
  61068. get cameraContrast(): float;
  61069. /**
  61070. * Sets The camera contrast used on this material.
  61071. */
  61072. set cameraContrast(value: float);
  61073. /**
  61074. * Gets the Color Grading 2D Lookup Texture.
  61075. */
  61076. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  61077. /**
  61078. * Sets the Color Grading 2D Lookup Texture.
  61079. */
  61080. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  61081. /**
  61082. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  61083. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61084. * 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;
  61085. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61086. */
  61087. get cameraColorCurves(): Nullable<ColorCurves>;
  61088. /**
  61089. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  61090. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61091. * 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;
  61092. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61093. */
  61094. set cameraColorCurves(value: Nullable<ColorCurves>);
  61095. /**
  61096. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  61097. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  61098. */
  61099. switchToBGR: boolean;
  61100. private _renderTargets;
  61101. private _reflectionControls;
  61102. private _white;
  61103. private _primaryShadowColor;
  61104. private _primaryHighlightColor;
  61105. /**
  61106. * Instantiates a Background Material in the given scene
  61107. * @param name The friendly name of the material
  61108. * @param scene The scene to add the material to
  61109. */
  61110. constructor(name: string, scene: Scene);
  61111. /**
  61112. * Gets a boolean indicating that current material needs to register RTT
  61113. */
  61114. get hasRenderTargetTextures(): boolean;
  61115. /**
  61116. * The entire material has been created in order to prevent overdraw.
  61117. * @returns false
  61118. */
  61119. needAlphaTesting(): boolean;
  61120. /**
  61121. * The entire material has been created in order to prevent overdraw.
  61122. * @returns true if blending is enable
  61123. */
  61124. needAlphaBlending(): boolean;
  61125. /**
  61126. * Checks wether the material is ready to be rendered for a given mesh.
  61127. * @param mesh The mesh to render
  61128. * @param subMesh The submesh to check against
  61129. * @param useInstances Specify wether or not the material is used with instances
  61130. * @returns true if all the dependencies are ready (Textures, Effects...)
  61131. */
  61132. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  61133. /**
  61134. * Compute the primary color according to the chosen perceptual color.
  61135. */
  61136. private _computePrimaryColorFromPerceptualColor;
  61137. /**
  61138. * Compute the highlights and shadow colors according to their chosen levels.
  61139. */
  61140. private _computePrimaryColors;
  61141. /**
  61142. * Build the uniform buffer used in the material.
  61143. */
  61144. buildUniformLayout(): void;
  61145. /**
  61146. * Unbind the material.
  61147. */
  61148. unbind(): void;
  61149. /**
  61150. * Bind only the world matrix to the material.
  61151. * @param world The world matrix to bind.
  61152. */
  61153. bindOnlyWorldMatrix(world: Matrix): void;
  61154. /**
  61155. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  61156. * @param world The world matrix to bind.
  61157. * @param subMesh The submesh to bind for.
  61158. */
  61159. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  61160. /**
  61161. * Checks to see if a texture is used in the material.
  61162. * @param texture - Base texture to use.
  61163. * @returns - Boolean specifying if a texture is used in the material.
  61164. */
  61165. hasTexture(texture: BaseTexture): boolean;
  61166. /**
  61167. * Dispose the material.
  61168. * @param forceDisposeEffect Force disposal of the associated effect.
  61169. * @param forceDisposeTextures Force disposal of the associated textures.
  61170. */
  61171. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  61172. /**
  61173. * Clones the material.
  61174. * @param name The cloned name.
  61175. * @returns The cloned material.
  61176. */
  61177. clone(name: string): BackgroundMaterial;
  61178. /**
  61179. * Serializes the current material to its JSON representation.
  61180. * @returns The JSON representation.
  61181. */
  61182. serialize(): any;
  61183. /**
  61184. * Gets the class name of the material
  61185. * @returns "BackgroundMaterial"
  61186. */
  61187. getClassName(): string;
  61188. /**
  61189. * Parse a JSON input to create back a background material.
  61190. * @param source The JSON data to parse
  61191. * @param scene The scene to create the parsed material in
  61192. * @param rootUrl The root url of the assets the material depends upon
  61193. * @returns the instantiated BackgroundMaterial.
  61194. */
  61195. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  61196. }
  61197. }
  61198. declare module BABYLON {
  61199. /**
  61200. * Represents the different options available during the creation of
  61201. * a Environment helper.
  61202. *
  61203. * This can control the default ground, skybox and image processing setup of your scene.
  61204. */
  61205. export interface IEnvironmentHelperOptions {
  61206. /**
  61207. * Specifies whether or not to create a ground.
  61208. * True by default.
  61209. */
  61210. createGround: boolean;
  61211. /**
  61212. * Specifies the ground size.
  61213. * 15 by default.
  61214. */
  61215. groundSize: number;
  61216. /**
  61217. * The texture used on the ground for the main color.
  61218. * Comes from the BabylonJS CDN by default.
  61219. *
  61220. * Remarks: Can be either a texture or a url.
  61221. */
  61222. groundTexture: string | BaseTexture;
  61223. /**
  61224. * The color mixed in the ground texture by default.
  61225. * BabylonJS clearColor by default.
  61226. */
  61227. groundColor: Color3;
  61228. /**
  61229. * Specifies the ground opacity.
  61230. * 1 by default.
  61231. */
  61232. groundOpacity: number;
  61233. /**
  61234. * Enables the ground to receive shadows.
  61235. * True by default.
  61236. */
  61237. enableGroundShadow: boolean;
  61238. /**
  61239. * Helps preventing the shadow to be fully black on the ground.
  61240. * 0.5 by default.
  61241. */
  61242. groundShadowLevel: number;
  61243. /**
  61244. * Creates a mirror texture attach to the ground.
  61245. * false by default.
  61246. */
  61247. enableGroundMirror: boolean;
  61248. /**
  61249. * Specifies the ground mirror size ratio.
  61250. * 0.3 by default as the default kernel is 64.
  61251. */
  61252. groundMirrorSizeRatio: number;
  61253. /**
  61254. * Specifies the ground mirror blur kernel size.
  61255. * 64 by default.
  61256. */
  61257. groundMirrorBlurKernel: number;
  61258. /**
  61259. * Specifies the ground mirror visibility amount.
  61260. * 1 by default
  61261. */
  61262. groundMirrorAmount: number;
  61263. /**
  61264. * Specifies the ground mirror reflectance weight.
  61265. * This uses the standard weight of the background material to setup the fresnel effect
  61266. * of the mirror.
  61267. * 1 by default.
  61268. */
  61269. groundMirrorFresnelWeight: number;
  61270. /**
  61271. * Specifies the ground mirror Falloff distance.
  61272. * This can helps reducing the size of the reflection.
  61273. * 0 by Default.
  61274. */
  61275. groundMirrorFallOffDistance: number;
  61276. /**
  61277. * Specifies the ground mirror texture type.
  61278. * Unsigned Int by Default.
  61279. */
  61280. groundMirrorTextureType: number;
  61281. /**
  61282. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  61283. * the shown objects.
  61284. */
  61285. groundYBias: number;
  61286. /**
  61287. * Specifies whether or not to create a skybox.
  61288. * True by default.
  61289. */
  61290. createSkybox: boolean;
  61291. /**
  61292. * Specifies the skybox size.
  61293. * 20 by default.
  61294. */
  61295. skyboxSize: number;
  61296. /**
  61297. * The texture used on the skybox for the main color.
  61298. * Comes from the BabylonJS CDN by default.
  61299. *
  61300. * Remarks: Can be either a texture or a url.
  61301. */
  61302. skyboxTexture: string | BaseTexture;
  61303. /**
  61304. * The color mixed in the skybox texture by default.
  61305. * BabylonJS clearColor by default.
  61306. */
  61307. skyboxColor: Color3;
  61308. /**
  61309. * The background rotation around the Y axis of the scene.
  61310. * This helps aligning the key lights of your scene with the background.
  61311. * 0 by default.
  61312. */
  61313. backgroundYRotation: number;
  61314. /**
  61315. * Compute automatically the size of the elements to best fit with the scene.
  61316. */
  61317. sizeAuto: boolean;
  61318. /**
  61319. * Default position of the rootMesh if autoSize is not true.
  61320. */
  61321. rootPosition: Vector3;
  61322. /**
  61323. * Sets up the image processing in the scene.
  61324. * true by default.
  61325. */
  61326. setupImageProcessing: boolean;
  61327. /**
  61328. * The texture used as your environment texture in the scene.
  61329. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  61330. *
  61331. * Remarks: Can be either a texture or a url.
  61332. */
  61333. environmentTexture: string | BaseTexture;
  61334. /**
  61335. * The value of the exposure to apply to the scene.
  61336. * 0.6 by default if setupImageProcessing is true.
  61337. */
  61338. cameraExposure: number;
  61339. /**
  61340. * The value of the contrast to apply to the scene.
  61341. * 1.6 by default if setupImageProcessing is true.
  61342. */
  61343. cameraContrast: number;
  61344. /**
  61345. * Specifies whether or not tonemapping should be enabled in the scene.
  61346. * true by default if setupImageProcessing is true.
  61347. */
  61348. toneMappingEnabled: boolean;
  61349. }
  61350. /**
  61351. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  61352. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  61353. * It also helps with the default setup of your imageProcessing configuration.
  61354. */
  61355. export class EnvironmentHelper {
  61356. /**
  61357. * Default ground texture URL.
  61358. */
  61359. private static _groundTextureCDNUrl;
  61360. /**
  61361. * Default skybox texture URL.
  61362. */
  61363. private static _skyboxTextureCDNUrl;
  61364. /**
  61365. * Default environment texture URL.
  61366. */
  61367. private static _environmentTextureCDNUrl;
  61368. /**
  61369. * Creates the default options for the helper.
  61370. */
  61371. private static _getDefaultOptions;
  61372. private _rootMesh;
  61373. /**
  61374. * Gets the root mesh created by the helper.
  61375. */
  61376. get rootMesh(): Mesh;
  61377. private _skybox;
  61378. /**
  61379. * Gets the skybox created by the helper.
  61380. */
  61381. get skybox(): Nullable<Mesh>;
  61382. private _skyboxTexture;
  61383. /**
  61384. * Gets the skybox texture created by the helper.
  61385. */
  61386. get skyboxTexture(): Nullable<BaseTexture>;
  61387. private _skyboxMaterial;
  61388. /**
  61389. * Gets the skybox material created by the helper.
  61390. */
  61391. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  61392. private _ground;
  61393. /**
  61394. * Gets the ground mesh created by the helper.
  61395. */
  61396. get ground(): Nullable<Mesh>;
  61397. private _groundTexture;
  61398. /**
  61399. * Gets the ground texture created by the helper.
  61400. */
  61401. get groundTexture(): Nullable<BaseTexture>;
  61402. private _groundMirror;
  61403. /**
  61404. * Gets the ground mirror created by the helper.
  61405. */
  61406. get groundMirror(): Nullable<MirrorTexture>;
  61407. /**
  61408. * Gets the ground mirror render list to helps pushing the meshes
  61409. * you wish in the ground reflection.
  61410. */
  61411. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  61412. private _groundMaterial;
  61413. /**
  61414. * Gets the ground material created by the helper.
  61415. */
  61416. get groundMaterial(): Nullable<BackgroundMaterial>;
  61417. /**
  61418. * Stores the creation options.
  61419. */
  61420. private readonly _scene;
  61421. private _options;
  61422. /**
  61423. * This observable will be notified with any error during the creation of the environment,
  61424. * mainly texture creation errors.
  61425. */
  61426. onErrorObservable: Observable<{
  61427. message?: string;
  61428. exception?: any;
  61429. }>;
  61430. /**
  61431. * constructor
  61432. * @param options Defines the options we want to customize the helper
  61433. * @param scene The scene to add the material to
  61434. */
  61435. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  61436. /**
  61437. * Updates the background according to the new options
  61438. * @param options
  61439. */
  61440. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  61441. /**
  61442. * Sets the primary color of all the available elements.
  61443. * @param color the main color to affect to the ground and the background
  61444. */
  61445. setMainColor(color: Color3): void;
  61446. /**
  61447. * Setup the image processing according to the specified options.
  61448. */
  61449. private _setupImageProcessing;
  61450. /**
  61451. * Setup the environment texture according to the specified options.
  61452. */
  61453. private _setupEnvironmentTexture;
  61454. /**
  61455. * Setup the background according to the specified options.
  61456. */
  61457. private _setupBackground;
  61458. /**
  61459. * Get the scene sizes according to the setup.
  61460. */
  61461. private _getSceneSize;
  61462. /**
  61463. * Setup the ground according to the specified options.
  61464. */
  61465. private _setupGround;
  61466. /**
  61467. * Setup the ground material according to the specified options.
  61468. */
  61469. private _setupGroundMaterial;
  61470. /**
  61471. * Setup the ground diffuse texture according to the specified options.
  61472. */
  61473. private _setupGroundDiffuseTexture;
  61474. /**
  61475. * Setup the ground mirror texture according to the specified options.
  61476. */
  61477. private _setupGroundMirrorTexture;
  61478. /**
  61479. * Setup the ground to receive the mirror texture.
  61480. */
  61481. private _setupMirrorInGroundMaterial;
  61482. /**
  61483. * Setup the skybox according to the specified options.
  61484. */
  61485. private _setupSkybox;
  61486. /**
  61487. * Setup the skybox material according to the specified options.
  61488. */
  61489. private _setupSkyboxMaterial;
  61490. /**
  61491. * Setup the skybox reflection texture according to the specified options.
  61492. */
  61493. private _setupSkyboxReflectionTexture;
  61494. private _errorHandler;
  61495. /**
  61496. * Dispose all the elements created by the Helper.
  61497. */
  61498. dispose(): void;
  61499. }
  61500. }
  61501. declare module BABYLON {
  61502. /**
  61503. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  61504. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  61505. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61506. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61507. */
  61508. export abstract class TextureDome<T extends Texture> extends TransformNode {
  61509. protected onError: Nullable<(message?: string, exception?: any) => void>;
  61510. /**
  61511. * Define the source as a Monoscopic panoramic 360/180.
  61512. */
  61513. static readonly MODE_MONOSCOPIC: number;
  61514. /**
  61515. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  61516. */
  61517. static readonly MODE_TOPBOTTOM: number;
  61518. /**
  61519. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  61520. */
  61521. static readonly MODE_SIDEBYSIDE: number;
  61522. private _halfDome;
  61523. private _crossEye;
  61524. protected _useDirectMapping: boolean;
  61525. /**
  61526. * The texture being displayed on the sphere
  61527. */
  61528. protected _texture: T;
  61529. /**
  61530. * Gets the texture being displayed on the sphere
  61531. */
  61532. get texture(): T;
  61533. /**
  61534. * Sets the texture being displayed on the sphere
  61535. */
  61536. set texture(newTexture: T);
  61537. /**
  61538. * The skybox material
  61539. */
  61540. protected _material: BackgroundMaterial;
  61541. /**
  61542. * The surface used for the dome
  61543. */
  61544. protected _mesh: Mesh;
  61545. /**
  61546. * Gets the mesh used for the dome.
  61547. */
  61548. get mesh(): Mesh;
  61549. /**
  61550. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  61551. */
  61552. private _halfDomeMask;
  61553. /**
  61554. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61555. * Also see the options.resolution property.
  61556. */
  61557. get fovMultiplier(): number;
  61558. set fovMultiplier(value: number);
  61559. protected _textureMode: number;
  61560. /**
  61561. * Gets or set the current texture mode for the texture. It can be:
  61562. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61563. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61564. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61565. */
  61566. get textureMode(): number;
  61567. /**
  61568. * Sets the current texture mode for the texture. It can be:
  61569. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61570. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61571. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61572. */
  61573. set textureMode(value: number);
  61574. /**
  61575. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  61576. */
  61577. get halfDome(): boolean;
  61578. /**
  61579. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  61580. */
  61581. set halfDome(enabled: boolean);
  61582. /**
  61583. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  61584. */
  61585. set crossEye(enabled: boolean);
  61586. /**
  61587. * Is it a cross-eye texture?
  61588. */
  61589. get crossEye(): boolean;
  61590. /**
  61591. * The background material of this dome.
  61592. */
  61593. get material(): BackgroundMaterial;
  61594. /**
  61595. * Oberserver used in Stereoscopic VR Mode.
  61596. */
  61597. private _onBeforeCameraRenderObserver;
  61598. /**
  61599. * Observable raised when an error occured while loading the 360 image
  61600. */
  61601. onLoadErrorObservable: Observable<string>;
  61602. /**
  61603. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  61604. * @param name Element's name, child elements will append suffixes for their own names.
  61605. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  61606. * @param options An object containing optional or exposed sub element properties
  61607. */
  61608. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  61609. resolution?: number;
  61610. clickToPlay?: boolean;
  61611. autoPlay?: boolean;
  61612. loop?: boolean;
  61613. size?: number;
  61614. poster?: string;
  61615. faceForward?: boolean;
  61616. useDirectMapping?: boolean;
  61617. halfDomeMode?: boolean;
  61618. crossEyeMode?: boolean;
  61619. generateMipMaps?: boolean;
  61620. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  61621. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  61622. protected _changeTextureMode(value: number): void;
  61623. /**
  61624. * Releases resources associated with this node.
  61625. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  61626. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  61627. */
  61628. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  61629. }
  61630. }
  61631. declare module BABYLON {
  61632. /**
  61633. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  61634. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  61635. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61636. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61637. */
  61638. export class PhotoDome extends TextureDome<Texture> {
  61639. /**
  61640. * Define the image as a Monoscopic panoramic 360 image.
  61641. */
  61642. static readonly MODE_MONOSCOPIC: number;
  61643. /**
  61644. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  61645. */
  61646. static readonly MODE_TOPBOTTOM: number;
  61647. /**
  61648. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  61649. */
  61650. static readonly MODE_SIDEBYSIDE: number;
  61651. /**
  61652. * Gets or sets the texture being displayed on the sphere
  61653. */
  61654. get photoTexture(): Texture;
  61655. /**
  61656. * sets the texture being displayed on the sphere
  61657. */
  61658. set photoTexture(value: Texture);
  61659. /**
  61660. * Gets the current video mode for the video. It can be:
  61661. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61662. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61663. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61664. */
  61665. get imageMode(): number;
  61666. /**
  61667. * Sets the current video mode for the video. It can be:
  61668. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61669. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61670. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61671. */
  61672. set imageMode(value: number);
  61673. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  61674. }
  61675. }
  61676. declare module BABYLON {
  61677. /**
  61678. * Direct draw surface info
  61679. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  61680. */
  61681. export interface DDSInfo {
  61682. /**
  61683. * Width of the texture
  61684. */
  61685. width: number;
  61686. /**
  61687. * Width of the texture
  61688. */
  61689. height: number;
  61690. /**
  61691. * Number of Mipmaps for the texture
  61692. * @see https://en.wikipedia.org/wiki/Mipmap
  61693. */
  61694. mipmapCount: number;
  61695. /**
  61696. * If the textures format is a known fourCC format
  61697. * @see https://www.fourcc.org/
  61698. */
  61699. isFourCC: boolean;
  61700. /**
  61701. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  61702. */
  61703. isRGB: boolean;
  61704. /**
  61705. * If the texture is a lumincance format
  61706. */
  61707. isLuminance: boolean;
  61708. /**
  61709. * If this is a cube texture
  61710. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  61711. */
  61712. isCube: boolean;
  61713. /**
  61714. * If the texture is a compressed format eg. FOURCC_DXT1
  61715. */
  61716. isCompressed: boolean;
  61717. /**
  61718. * The dxgiFormat of the texture
  61719. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  61720. */
  61721. dxgiFormat: number;
  61722. /**
  61723. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  61724. */
  61725. textureType: number;
  61726. /**
  61727. * Sphericle polynomial created for the dds texture
  61728. */
  61729. sphericalPolynomial?: SphericalPolynomial;
  61730. }
  61731. /**
  61732. * Class used to provide DDS decompression tools
  61733. */
  61734. export class DDSTools {
  61735. /**
  61736. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  61737. */
  61738. static StoreLODInAlphaChannel: boolean;
  61739. /**
  61740. * Gets DDS information from an array buffer
  61741. * @param data defines the array buffer view to read data from
  61742. * @returns the DDS information
  61743. */
  61744. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  61745. private static _FloatView;
  61746. private static _Int32View;
  61747. private static _ToHalfFloat;
  61748. private static _FromHalfFloat;
  61749. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  61750. private static _GetHalfFloatRGBAArrayBuffer;
  61751. private static _GetFloatRGBAArrayBuffer;
  61752. private static _GetFloatAsUIntRGBAArrayBuffer;
  61753. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  61754. private static _GetRGBAArrayBuffer;
  61755. private static _ExtractLongWordOrder;
  61756. private static _GetRGBArrayBuffer;
  61757. private static _GetLuminanceArrayBuffer;
  61758. /**
  61759. * Uploads DDS Levels to a Babylon Texture
  61760. * @hidden
  61761. */
  61762. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  61763. }
  61764. interface ThinEngine {
  61765. /**
  61766. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  61767. * @param rootUrl defines the url where the file to load is located
  61768. * @param scene defines the current scene
  61769. * @param lodScale defines scale to apply to the mip map selection
  61770. * @param lodOffset defines offset to apply to the mip map selection
  61771. * @param onLoad defines an optional callback raised when the texture is loaded
  61772. * @param onError defines an optional callback raised if there is an issue to load the texture
  61773. * @param format defines the format of the data
  61774. * @param forcedExtension defines the extension to use to pick the right loader
  61775. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  61776. * @returns the cube texture as an InternalTexture
  61777. */
  61778. 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;
  61779. }
  61780. }
  61781. declare module BABYLON {
  61782. /**
  61783. * Implementation of the DDS Texture Loader.
  61784. * @hidden
  61785. */
  61786. export class _DDSTextureLoader implements IInternalTextureLoader {
  61787. /**
  61788. * Defines wether the loader supports cascade loading the different faces.
  61789. */
  61790. readonly supportCascades: boolean;
  61791. /**
  61792. * This returns if the loader support the current file information.
  61793. * @param extension defines the file extension of the file being loaded
  61794. * @returns true if the loader can load the specified file
  61795. */
  61796. canLoad(extension: string): boolean;
  61797. /**
  61798. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61799. * @param data contains the texture data
  61800. * @param texture defines the BabylonJS internal texture
  61801. * @param createPolynomials will be true if polynomials have been requested
  61802. * @param onLoad defines the callback to trigger once the texture is ready
  61803. * @param onError defines the callback to trigger in case of error
  61804. */
  61805. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61806. /**
  61807. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61808. * @param data contains the texture data
  61809. * @param texture defines the BabylonJS internal texture
  61810. * @param callback defines the method to call once ready to upload
  61811. */
  61812. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61813. }
  61814. }
  61815. declare module BABYLON {
  61816. /**
  61817. * Implementation of the ENV Texture Loader.
  61818. * @hidden
  61819. */
  61820. export class _ENVTextureLoader implements IInternalTextureLoader {
  61821. /**
  61822. * Defines wether the loader supports cascade loading the different faces.
  61823. */
  61824. readonly supportCascades: boolean;
  61825. /**
  61826. * This returns if the loader support the current file information.
  61827. * @param extension defines the file extension of the file being loaded
  61828. * @returns true if the loader can load the specified file
  61829. */
  61830. canLoad(extension: string): boolean;
  61831. /**
  61832. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61833. * @param data contains the texture data
  61834. * @param texture defines the BabylonJS internal texture
  61835. * @param createPolynomials will be true if polynomials have been requested
  61836. * @param onLoad defines the callback to trigger once the texture is ready
  61837. * @param onError defines the callback to trigger in case of error
  61838. */
  61839. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61840. /**
  61841. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61842. * @param data contains the texture data
  61843. * @param texture defines the BabylonJS internal texture
  61844. * @param callback defines the method to call once ready to upload
  61845. */
  61846. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61847. }
  61848. }
  61849. declare module BABYLON {
  61850. /**
  61851. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  61852. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  61853. */
  61854. export class KhronosTextureContainer {
  61855. /** contents of the KTX container file */
  61856. data: ArrayBufferView;
  61857. private static HEADER_LEN;
  61858. private static COMPRESSED_2D;
  61859. private static COMPRESSED_3D;
  61860. private static TEX_2D;
  61861. private static TEX_3D;
  61862. /**
  61863. * Gets the openGL type
  61864. */
  61865. glType: number;
  61866. /**
  61867. * Gets the openGL type size
  61868. */
  61869. glTypeSize: number;
  61870. /**
  61871. * Gets the openGL format
  61872. */
  61873. glFormat: number;
  61874. /**
  61875. * Gets the openGL internal format
  61876. */
  61877. glInternalFormat: number;
  61878. /**
  61879. * Gets the base internal format
  61880. */
  61881. glBaseInternalFormat: number;
  61882. /**
  61883. * Gets image width in pixel
  61884. */
  61885. pixelWidth: number;
  61886. /**
  61887. * Gets image height in pixel
  61888. */
  61889. pixelHeight: number;
  61890. /**
  61891. * Gets image depth in pixels
  61892. */
  61893. pixelDepth: number;
  61894. /**
  61895. * Gets the number of array elements
  61896. */
  61897. numberOfArrayElements: number;
  61898. /**
  61899. * Gets the number of faces
  61900. */
  61901. numberOfFaces: number;
  61902. /**
  61903. * Gets the number of mipmap levels
  61904. */
  61905. numberOfMipmapLevels: number;
  61906. /**
  61907. * Gets the bytes of key value data
  61908. */
  61909. bytesOfKeyValueData: number;
  61910. /**
  61911. * Gets the load type
  61912. */
  61913. loadType: number;
  61914. /**
  61915. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  61916. */
  61917. isInvalid: boolean;
  61918. /**
  61919. * Creates a new KhronosTextureContainer
  61920. * @param data contents of the KTX container file
  61921. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  61922. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  61923. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  61924. */
  61925. constructor(
  61926. /** contents of the KTX container file */
  61927. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  61928. /**
  61929. * Uploads KTX content to a Babylon Texture.
  61930. * It is assumed that the texture has already been created & is currently bound
  61931. * @hidden
  61932. */
  61933. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  61934. private _upload2DCompressedLevels;
  61935. /**
  61936. * Checks if the given data starts with a KTX file identifier.
  61937. * @param data the data to check
  61938. * @returns true if the data is a KTX file or false otherwise
  61939. */
  61940. static IsValid(data: ArrayBufferView): boolean;
  61941. }
  61942. }
  61943. declare module BABYLON {
  61944. /**
  61945. * Helper class to push actions to a pool of workers.
  61946. */
  61947. export class WorkerPool implements IDisposable {
  61948. private _workerInfos;
  61949. private _pendingActions;
  61950. /**
  61951. * Constructor
  61952. * @param workers Array of workers to use for actions
  61953. */
  61954. constructor(workers: Array<Worker>);
  61955. /**
  61956. * Terminates all workers and clears any pending actions.
  61957. */
  61958. dispose(): void;
  61959. /**
  61960. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61961. * pended until a worker has completed its action.
  61962. * @param action The action to perform. Call onComplete when the action is complete.
  61963. */
  61964. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61965. private _execute;
  61966. }
  61967. }
  61968. declare module BABYLON {
  61969. /**
  61970. * Class for loading KTX2 files
  61971. */
  61972. export class KhronosTextureContainer2 {
  61973. private static _WorkerPoolPromise?;
  61974. private static _Initialized;
  61975. private static _Ktx2Decoder;
  61976. /**
  61977. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  61978. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  61979. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  61980. * Urls you can change:
  61981. * URLConfig.jsDecoderModule
  61982. * URLConfig.wasmUASTCToASTC
  61983. * URLConfig.wasmUASTCToBC7
  61984. * URLConfig.wasmUASTCToRGBA_UNORM
  61985. * URLConfig.wasmUASTCToRGBA_SRGB
  61986. * URLConfig.jsMSCTranscoder
  61987. * URLConfig.wasmMSCTranscoder
  61988. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#22
  61989. */
  61990. static URLConfig: {
  61991. jsDecoderModule: string;
  61992. wasmUASTCToASTC: null;
  61993. wasmUASTCToBC7: null;
  61994. wasmUASTCToRGBA_UNORM: null;
  61995. wasmUASTCToRGBA_SRGB: null;
  61996. jsMSCTranscoder: null;
  61997. wasmMSCTranscoder: null;
  61998. };
  61999. /**
  62000. * Default number of workers used to handle data decoding
  62001. */
  62002. static DefaultNumWorkers: number;
  62003. private static GetDefaultNumWorkers;
  62004. private _engine;
  62005. private static _CreateWorkerPool;
  62006. /**
  62007. * Constructor
  62008. * @param engine The engine to use
  62009. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  62010. */
  62011. constructor(engine: ThinEngine, numWorkers?: number);
  62012. /** @hidden */
  62013. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  62014. /**
  62015. * Stop all async operations and release resources.
  62016. */
  62017. dispose(): void;
  62018. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  62019. /**
  62020. * Checks if the given data starts with a KTX2 file identifier.
  62021. * @param data the data to check
  62022. * @returns true if the data is a KTX2 file or false otherwise
  62023. */
  62024. static IsValid(data: ArrayBufferView): boolean;
  62025. }
  62026. }
  62027. declare module BABYLON {
  62028. /**
  62029. * Implementation of the KTX Texture Loader.
  62030. * @hidden
  62031. */
  62032. export class _KTXTextureLoader implements IInternalTextureLoader {
  62033. /**
  62034. * Defines wether the loader supports cascade loading the different faces.
  62035. */
  62036. readonly supportCascades: boolean;
  62037. /**
  62038. * This returns if the loader support the current file information.
  62039. * @param extension defines the file extension of the file being loaded
  62040. * @param mimeType defines the optional mime type of the file being loaded
  62041. * @returns true if the loader can load the specified file
  62042. */
  62043. canLoad(extension: string, mimeType?: string): boolean;
  62044. /**
  62045. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62046. * @param data contains the texture data
  62047. * @param texture defines the BabylonJS internal texture
  62048. * @param createPolynomials will be true if polynomials have been requested
  62049. * @param onLoad defines the callback to trigger once the texture is ready
  62050. * @param onError defines the callback to trigger in case of error
  62051. */
  62052. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62053. /**
  62054. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62055. * @param data contains the texture data
  62056. * @param texture defines the BabylonJS internal texture
  62057. * @param callback defines the method to call once ready to upload
  62058. */
  62059. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  62060. }
  62061. }
  62062. declare module BABYLON {
  62063. /** @hidden */
  62064. export var _forceSceneHelpersToBundle: boolean;
  62065. interface Scene {
  62066. /**
  62067. * Creates a default light for the scene.
  62068. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  62069. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  62070. */
  62071. createDefaultLight(replace?: boolean): void;
  62072. /**
  62073. * Creates a default camera for the scene.
  62074. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  62075. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62076. * @param replace has default false, when true replaces the active camera in the scene
  62077. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  62078. */
  62079. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62080. /**
  62081. * Creates a default camera and a default light.
  62082. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  62083. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62084. * @param replace has the default false, when true replaces the active camera/light in the scene
  62085. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  62086. */
  62087. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62088. /**
  62089. * Creates a new sky box
  62090. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  62091. * @param environmentTexture defines the texture to use as environment texture
  62092. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  62093. * @param scale defines the overall scale of the skybox
  62094. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  62095. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  62096. * @returns a new mesh holding the sky box
  62097. */
  62098. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  62099. /**
  62100. * Creates a new environment
  62101. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  62102. * @param options defines the options you can use to configure the environment
  62103. * @returns the new EnvironmentHelper
  62104. */
  62105. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  62106. /**
  62107. * Creates a new VREXperienceHelper
  62108. * @see https://doc.babylonjs.com/how_to/webvr_helper
  62109. * @param webVROptions defines the options used to create the new VREXperienceHelper
  62110. * @returns a new VREXperienceHelper
  62111. */
  62112. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  62113. /**
  62114. * Creates a new WebXRDefaultExperience
  62115. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  62116. * @param options experience options
  62117. * @returns a promise for a new WebXRDefaultExperience
  62118. */
  62119. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  62120. }
  62121. }
  62122. declare module BABYLON {
  62123. /**
  62124. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  62125. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  62126. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  62127. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62128. */
  62129. export class VideoDome extends TextureDome<VideoTexture> {
  62130. /**
  62131. * Define the video source as a Monoscopic panoramic 360 video.
  62132. */
  62133. static readonly MODE_MONOSCOPIC: number;
  62134. /**
  62135. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  62136. */
  62137. static readonly MODE_TOPBOTTOM: number;
  62138. /**
  62139. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  62140. */
  62141. static readonly MODE_SIDEBYSIDE: number;
  62142. /**
  62143. * Get the video texture associated with this video dome
  62144. */
  62145. get videoTexture(): VideoTexture;
  62146. /**
  62147. * Get the video mode of this dome
  62148. */
  62149. get videoMode(): number;
  62150. /**
  62151. * Set the video mode of this dome.
  62152. * @see textureMode
  62153. */
  62154. set videoMode(value: number);
  62155. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  62156. }
  62157. }
  62158. declare module BABYLON {
  62159. /**
  62160. * This class can be used to get instrumentation data from a Babylon engine
  62161. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62162. */
  62163. export class EngineInstrumentation implements IDisposable {
  62164. /**
  62165. * Define the instrumented engine.
  62166. */
  62167. engine: Engine;
  62168. private _captureGPUFrameTime;
  62169. private _gpuFrameTimeToken;
  62170. private _gpuFrameTime;
  62171. private _captureShaderCompilationTime;
  62172. private _shaderCompilationTime;
  62173. private _onBeginFrameObserver;
  62174. private _onEndFrameObserver;
  62175. private _onBeforeShaderCompilationObserver;
  62176. private _onAfterShaderCompilationObserver;
  62177. /**
  62178. * Gets the perf counter used for GPU frame time
  62179. */
  62180. get gpuFrameTimeCounter(): PerfCounter;
  62181. /**
  62182. * Gets the GPU frame time capture status
  62183. */
  62184. get captureGPUFrameTime(): boolean;
  62185. /**
  62186. * Enable or disable the GPU frame time capture
  62187. */
  62188. set captureGPUFrameTime(value: boolean);
  62189. /**
  62190. * Gets the perf counter used for shader compilation time
  62191. */
  62192. get shaderCompilationTimeCounter(): PerfCounter;
  62193. /**
  62194. * Gets the shader compilation time capture status
  62195. */
  62196. get captureShaderCompilationTime(): boolean;
  62197. /**
  62198. * Enable or disable the shader compilation time capture
  62199. */
  62200. set captureShaderCompilationTime(value: boolean);
  62201. /**
  62202. * Instantiates a new engine instrumentation.
  62203. * This class can be used to get instrumentation data from a Babylon engine
  62204. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62205. * @param engine Defines the engine to instrument
  62206. */
  62207. constructor(
  62208. /**
  62209. * Define the instrumented engine.
  62210. */
  62211. engine: Engine);
  62212. /**
  62213. * Dispose and release associated resources.
  62214. */
  62215. dispose(): void;
  62216. }
  62217. }
  62218. declare module BABYLON {
  62219. /**
  62220. * This class can be used to get instrumentation data from a Babylon engine
  62221. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62222. */
  62223. export class SceneInstrumentation implements IDisposable {
  62224. /**
  62225. * Defines the scene to instrument
  62226. */
  62227. scene: Scene;
  62228. private _captureActiveMeshesEvaluationTime;
  62229. private _activeMeshesEvaluationTime;
  62230. private _captureRenderTargetsRenderTime;
  62231. private _renderTargetsRenderTime;
  62232. private _captureFrameTime;
  62233. private _frameTime;
  62234. private _captureRenderTime;
  62235. private _renderTime;
  62236. private _captureInterFrameTime;
  62237. private _interFrameTime;
  62238. private _captureParticlesRenderTime;
  62239. private _particlesRenderTime;
  62240. private _captureSpritesRenderTime;
  62241. private _spritesRenderTime;
  62242. private _capturePhysicsTime;
  62243. private _physicsTime;
  62244. private _captureAnimationsTime;
  62245. private _animationsTime;
  62246. private _captureCameraRenderTime;
  62247. private _cameraRenderTime;
  62248. private _onBeforeActiveMeshesEvaluationObserver;
  62249. private _onAfterActiveMeshesEvaluationObserver;
  62250. private _onBeforeRenderTargetsRenderObserver;
  62251. private _onAfterRenderTargetsRenderObserver;
  62252. private _onAfterRenderObserver;
  62253. private _onBeforeDrawPhaseObserver;
  62254. private _onAfterDrawPhaseObserver;
  62255. private _onBeforeAnimationsObserver;
  62256. private _onBeforeParticlesRenderingObserver;
  62257. private _onAfterParticlesRenderingObserver;
  62258. private _onBeforeSpritesRenderingObserver;
  62259. private _onAfterSpritesRenderingObserver;
  62260. private _onBeforePhysicsObserver;
  62261. private _onAfterPhysicsObserver;
  62262. private _onAfterAnimationsObserver;
  62263. private _onBeforeCameraRenderObserver;
  62264. private _onAfterCameraRenderObserver;
  62265. /**
  62266. * Gets the perf counter used for active meshes evaluation time
  62267. */
  62268. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  62269. /**
  62270. * Gets the active meshes evaluation time capture status
  62271. */
  62272. get captureActiveMeshesEvaluationTime(): boolean;
  62273. /**
  62274. * Enable or disable the active meshes evaluation time capture
  62275. */
  62276. set captureActiveMeshesEvaluationTime(value: boolean);
  62277. /**
  62278. * Gets the perf counter used for render targets render time
  62279. */
  62280. get renderTargetsRenderTimeCounter(): PerfCounter;
  62281. /**
  62282. * Gets the render targets render time capture status
  62283. */
  62284. get captureRenderTargetsRenderTime(): boolean;
  62285. /**
  62286. * Enable or disable the render targets render time capture
  62287. */
  62288. set captureRenderTargetsRenderTime(value: boolean);
  62289. /**
  62290. * Gets the perf counter used for particles render time
  62291. */
  62292. get particlesRenderTimeCounter(): PerfCounter;
  62293. /**
  62294. * Gets the particles render time capture status
  62295. */
  62296. get captureParticlesRenderTime(): boolean;
  62297. /**
  62298. * Enable or disable the particles render time capture
  62299. */
  62300. set captureParticlesRenderTime(value: boolean);
  62301. /**
  62302. * Gets the perf counter used for sprites render time
  62303. */
  62304. get spritesRenderTimeCounter(): PerfCounter;
  62305. /**
  62306. * Gets the sprites render time capture status
  62307. */
  62308. get captureSpritesRenderTime(): boolean;
  62309. /**
  62310. * Enable or disable the sprites render time capture
  62311. */
  62312. set captureSpritesRenderTime(value: boolean);
  62313. /**
  62314. * Gets the perf counter used for physics time
  62315. */
  62316. get physicsTimeCounter(): PerfCounter;
  62317. /**
  62318. * Gets the physics time capture status
  62319. */
  62320. get capturePhysicsTime(): boolean;
  62321. /**
  62322. * Enable or disable the physics time capture
  62323. */
  62324. set capturePhysicsTime(value: boolean);
  62325. /**
  62326. * Gets the perf counter used for animations time
  62327. */
  62328. get animationsTimeCounter(): PerfCounter;
  62329. /**
  62330. * Gets the animations time capture status
  62331. */
  62332. get captureAnimationsTime(): boolean;
  62333. /**
  62334. * Enable or disable the animations time capture
  62335. */
  62336. set captureAnimationsTime(value: boolean);
  62337. /**
  62338. * Gets the perf counter used for frame time capture
  62339. */
  62340. get frameTimeCounter(): PerfCounter;
  62341. /**
  62342. * Gets the frame time capture status
  62343. */
  62344. get captureFrameTime(): boolean;
  62345. /**
  62346. * Enable or disable the frame time capture
  62347. */
  62348. set captureFrameTime(value: boolean);
  62349. /**
  62350. * Gets the perf counter used for inter-frames time capture
  62351. */
  62352. get interFrameTimeCounter(): PerfCounter;
  62353. /**
  62354. * Gets the inter-frames time capture status
  62355. */
  62356. get captureInterFrameTime(): boolean;
  62357. /**
  62358. * Enable or disable the inter-frames time capture
  62359. */
  62360. set captureInterFrameTime(value: boolean);
  62361. /**
  62362. * Gets the perf counter used for render time capture
  62363. */
  62364. get renderTimeCounter(): PerfCounter;
  62365. /**
  62366. * Gets the render time capture status
  62367. */
  62368. get captureRenderTime(): boolean;
  62369. /**
  62370. * Enable or disable the render time capture
  62371. */
  62372. set captureRenderTime(value: boolean);
  62373. /**
  62374. * Gets the perf counter used for camera render time capture
  62375. */
  62376. get cameraRenderTimeCounter(): PerfCounter;
  62377. /**
  62378. * Gets the camera render time capture status
  62379. */
  62380. get captureCameraRenderTime(): boolean;
  62381. /**
  62382. * Enable or disable the camera render time capture
  62383. */
  62384. set captureCameraRenderTime(value: boolean);
  62385. /**
  62386. * Gets the perf counter used for draw calls
  62387. */
  62388. get drawCallsCounter(): PerfCounter;
  62389. /**
  62390. * Instantiates a new scene instrumentation.
  62391. * This class can be used to get instrumentation data from a Babylon engine
  62392. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62393. * @param scene Defines the scene to instrument
  62394. */
  62395. constructor(
  62396. /**
  62397. * Defines the scene to instrument
  62398. */
  62399. scene: Scene);
  62400. /**
  62401. * Dispose and release associated resources.
  62402. */
  62403. dispose(): void;
  62404. }
  62405. }
  62406. declare module BABYLON {
  62407. /** @hidden */
  62408. export var glowMapGenerationPixelShader: {
  62409. name: string;
  62410. shader: string;
  62411. };
  62412. }
  62413. declare module BABYLON {
  62414. /** @hidden */
  62415. export var glowMapGenerationVertexShader: {
  62416. name: string;
  62417. shader: string;
  62418. };
  62419. }
  62420. declare module BABYLON {
  62421. /**
  62422. * Effect layer options. This helps customizing the behaviour
  62423. * of the effect layer.
  62424. */
  62425. export interface IEffectLayerOptions {
  62426. /**
  62427. * Multiplication factor apply to the canvas size to compute the render target size
  62428. * used to generated the objects (the smaller the faster).
  62429. */
  62430. mainTextureRatio: number;
  62431. /**
  62432. * Enforces a fixed size texture to ensure effect stability across devices.
  62433. */
  62434. mainTextureFixedSize?: number;
  62435. /**
  62436. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  62437. */
  62438. alphaBlendingMode: number;
  62439. /**
  62440. * The camera attached to the layer.
  62441. */
  62442. camera: Nullable<Camera>;
  62443. /**
  62444. * The rendering group to draw the layer in.
  62445. */
  62446. renderingGroupId: number;
  62447. }
  62448. /**
  62449. * The effect layer Helps adding post process effect blended with the main pass.
  62450. *
  62451. * This can be for instance use to generate glow or higlight effects on the scene.
  62452. *
  62453. * The effect layer class can not be used directly and is intented to inherited from to be
  62454. * customized per effects.
  62455. */
  62456. export abstract class EffectLayer {
  62457. private _vertexBuffers;
  62458. private _indexBuffer;
  62459. private _cachedDefines;
  62460. private _effectLayerMapGenerationEffect;
  62461. private _effectLayerOptions;
  62462. private _mergeEffect;
  62463. protected _scene: Scene;
  62464. protected _engine: Engine;
  62465. protected _maxSize: number;
  62466. protected _mainTextureDesiredSize: ISize;
  62467. protected _mainTexture: RenderTargetTexture;
  62468. protected _shouldRender: boolean;
  62469. protected _postProcesses: PostProcess[];
  62470. protected _textures: BaseTexture[];
  62471. protected _emissiveTextureAndColor: {
  62472. texture: Nullable<BaseTexture>;
  62473. color: Color4;
  62474. };
  62475. /**
  62476. * The name of the layer
  62477. */
  62478. name: string;
  62479. /**
  62480. * The clear color of the texture used to generate the glow map.
  62481. */
  62482. neutralColor: Color4;
  62483. /**
  62484. * Specifies whether the highlight layer is enabled or not.
  62485. */
  62486. isEnabled: boolean;
  62487. /**
  62488. * Gets the camera attached to the layer.
  62489. */
  62490. get camera(): Nullable<Camera>;
  62491. /**
  62492. * Gets the rendering group id the layer should render in.
  62493. */
  62494. get renderingGroupId(): number;
  62495. set renderingGroupId(renderingGroupId: number);
  62496. /**
  62497. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  62498. */
  62499. disableBoundingBoxesFromEffectLayer: boolean;
  62500. /**
  62501. * An event triggered when the effect layer has been disposed.
  62502. */
  62503. onDisposeObservable: Observable<EffectLayer>;
  62504. /**
  62505. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  62506. */
  62507. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  62508. /**
  62509. * An event triggered when the generated texture is being merged in the scene.
  62510. */
  62511. onBeforeComposeObservable: Observable<EffectLayer>;
  62512. /**
  62513. * An event triggered when the mesh is rendered into the effect render target.
  62514. */
  62515. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  62516. /**
  62517. * An event triggered after the mesh has been rendered into the effect render target.
  62518. */
  62519. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  62520. /**
  62521. * An event triggered when the generated texture has been merged in the scene.
  62522. */
  62523. onAfterComposeObservable: Observable<EffectLayer>;
  62524. /**
  62525. * An event triggered when the efffect layer changes its size.
  62526. */
  62527. onSizeChangedObservable: Observable<EffectLayer>;
  62528. /** @hidden */
  62529. static _SceneComponentInitialization: (scene: Scene) => void;
  62530. /**
  62531. * Instantiates a new effect Layer and references it in the scene.
  62532. * @param name The name of the layer
  62533. * @param scene The scene to use the layer in
  62534. */
  62535. constructor(
  62536. /** The Friendly of the effect in the scene */
  62537. name: string, scene: Scene);
  62538. /**
  62539. * Get the effect name of the layer.
  62540. * @return The effect name
  62541. */
  62542. abstract getEffectName(): string;
  62543. /**
  62544. * Checks for the readiness of the element composing the layer.
  62545. * @param subMesh the mesh to check for
  62546. * @param useInstances specify whether or not to use instances to render the mesh
  62547. * @return true if ready otherwise, false
  62548. */
  62549. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62550. /**
  62551. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62552. * @returns true if the effect requires stencil during the main canvas render pass.
  62553. */
  62554. abstract needStencil(): boolean;
  62555. /**
  62556. * Create the merge effect. This is the shader use to blit the information back
  62557. * to the main canvas at the end of the scene rendering.
  62558. * @returns The effect containing the shader used to merge the effect on the main canvas
  62559. */
  62560. protected abstract _createMergeEffect(): Effect;
  62561. /**
  62562. * Creates the render target textures and post processes used in the effect layer.
  62563. */
  62564. protected abstract _createTextureAndPostProcesses(): void;
  62565. /**
  62566. * Implementation specific of rendering the generating effect on the main canvas.
  62567. * @param effect The effect used to render through
  62568. */
  62569. protected abstract _internalRender(effect: Effect): void;
  62570. /**
  62571. * Sets the required values for both the emissive texture and and the main color.
  62572. */
  62573. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62574. /**
  62575. * Free any resources and references associated to a mesh.
  62576. * Internal use
  62577. * @param mesh The mesh to free.
  62578. */
  62579. abstract _disposeMesh(mesh: Mesh): void;
  62580. /**
  62581. * Serializes this layer (Glow or Highlight for example)
  62582. * @returns a serialized layer object
  62583. */
  62584. abstract serialize?(): any;
  62585. /**
  62586. * Initializes the effect layer with the required options.
  62587. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  62588. */
  62589. protected _init(options: Partial<IEffectLayerOptions>): void;
  62590. /**
  62591. * Generates the index buffer of the full screen quad blending to the main canvas.
  62592. */
  62593. private _generateIndexBuffer;
  62594. /**
  62595. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  62596. */
  62597. private _generateVertexBuffer;
  62598. /**
  62599. * Sets the main texture desired size which is the closest power of two
  62600. * of the engine canvas size.
  62601. */
  62602. private _setMainTextureSize;
  62603. /**
  62604. * Creates the main texture for the effect layer.
  62605. */
  62606. protected _createMainTexture(): void;
  62607. /**
  62608. * Adds specific effects defines.
  62609. * @param defines The defines to add specifics to.
  62610. */
  62611. protected _addCustomEffectDefines(defines: string[]): void;
  62612. /**
  62613. * Checks for the readiness of the element composing the layer.
  62614. * @param subMesh the mesh to check for
  62615. * @param useInstances specify whether or not to use instances to render the mesh
  62616. * @param emissiveTexture the associated emissive texture used to generate the glow
  62617. * @return true if ready otherwise, false
  62618. */
  62619. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  62620. /**
  62621. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  62622. */
  62623. render(): void;
  62624. /**
  62625. * Determine if a given mesh will be used in the current effect.
  62626. * @param mesh mesh to test
  62627. * @returns true if the mesh will be used
  62628. */
  62629. hasMesh(mesh: AbstractMesh): boolean;
  62630. /**
  62631. * Returns true if the layer contains information to display, otherwise false.
  62632. * @returns true if the glow layer should be rendered
  62633. */
  62634. shouldRender(): boolean;
  62635. /**
  62636. * Returns true if the mesh should render, otherwise false.
  62637. * @param mesh The mesh to render
  62638. * @returns true if it should render otherwise false
  62639. */
  62640. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  62641. /**
  62642. * Returns true if the mesh can be rendered, otherwise false.
  62643. * @param mesh The mesh to render
  62644. * @param material The material used on the mesh
  62645. * @returns true if it can be rendered otherwise false
  62646. */
  62647. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62648. /**
  62649. * Returns true if the mesh should render, otherwise false.
  62650. * @param mesh The mesh to render
  62651. * @returns true if it should render otherwise false
  62652. */
  62653. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  62654. /**
  62655. * Renders the submesh passed in parameter to the generation map.
  62656. */
  62657. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  62658. /**
  62659. * Defines whether the current material of the mesh should be use to render the effect.
  62660. * @param mesh defines the current mesh to render
  62661. */
  62662. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62663. /**
  62664. * Rebuild the required buffers.
  62665. * @hidden Internal use only.
  62666. */
  62667. _rebuild(): void;
  62668. /**
  62669. * Dispose only the render target textures and post process.
  62670. */
  62671. private _disposeTextureAndPostProcesses;
  62672. /**
  62673. * Dispose the highlight layer and free resources.
  62674. */
  62675. dispose(): void;
  62676. /**
  62677. * Gets the class name of the effect layer
  62678. * @returns the string with the class name of the effect layer
  62679. */
  62680. getClassName(): string;
  62681. /**
  62682. * Creates an effect layer from parsed effect layer data
  62683. * @param parsedEffectLayer defines effect layer data
  62684. * @param scene defines the current scene
  62685. * @param rootUrl defines the root URL containing the effect layer information
  62686. * @returns a parsed effect Layer
  62687. */
  62688. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  62689. }
  62690. }
  62691. declare module BABYLON {
  62692. interface AbstractScene {
  62693. /**
  62694. * The list of effect layers (highlights/glow) added to the scene
  62695. * @see https://doc.babylonjs.com/how_to/highlight_layer
  62696. * @see https://doc.babylonjs.com/how_to/glow_layer
  62697. */
  62698. effectLayers: Array<EffectLayer>;
  62699. /**
  62700. * Removes the given effect layer from this scene.
  62701. * @param toRemove defines the effect layer to remove
  62702. * @returns the index of the removed effect layer
  62703. */
  62704. removeEffectLayer(toRemove: EffectLayer): number;
  62705. /**
  62706. * Adds the given effect layer to this scene
  62707. * @param newEffectLayer defines the effect layer to add
  62708. */
  62709. addEffectLayer(newEffectLayer: EffectLayer): void;
  62710. }
  62711. /**
  62712. * Defines the layer scene component responsible to manage any effect layers
  62713. * in a given scene.
  62714. */
  62715. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  62716. /**
  62717. * The component name helpfull to identify the component in the list of scene components.
  62718. */
  62719. readonly name: string;
  62720. /**
  62721. * The scene the component belongs to.
  62722. */
  62723. scene: Scene;
  62724. private _engine;
  62725. private _renderEffects;
  62726. private _needStencil;
  62727. private _previousStencilState;
  62728. /**
  62729. * Creates a new instance of the component for the given scene
  62730. * @param scene Defines the scene to register the component in
  62731. */
  62732. constructor(scene: Scene);
  62733. /**
  62734. * Registers the component in a given scene
  62735. */
  62736. register(): void;
  62737. /**
  62738. * Rebuilds the elements related to this component in case of
  62739. * context lost for instance.
  62740. */
  62741. rebuild(): void;
  62742. /**
  62743. * Serializes the component data to the specified json object
  62744. * @param serializationObject The object to serialize to
  62745. */
  62746. serialize(serializationObject: any): void;
  62747. /**
  62748. * Adds all the elements from the container to the scene
  62749. * @param container the container holding the elements
  62750. */
  62751. addFromContainer(container: AbstractScene): void;
  62752. /**
  62753. * Removes all the elements in the container from the scene
  62754. * @param container contains the elements to remove
  62755. * @param dispose if the removed element should be disposed (default: false)
  62756. */
  62757. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62758. /**
  62759. * Disposes the component and the associated ressources.
  62760. */
  62761. dispose(): void;
  62762. private _isReadyForMesh;
  62763. private _renderMainTexture;
  62764. private _setStencil;
  62765. private _setStencilBack;
  62766. private _draw;
  62767. private _drawCamera;
  62768. private _drawRenderingGroup;
  62769. }
  62770. }
  62771. declare module BABYLON {
  62772. /** @hidden */
  62773. export var glowMapMergePixelShader: {
  62774. name: string;
  62775. shader: string;
  62776. };
  62777. }
  62778. declare module BABYLON {
  62779. /** @hidden */
  62780. export var glowMapMergeVertexShader: {
  62781. name: string;
  62782. shader: string;
  62783. };
  62784. }
  62785. declare module BABYLON {
  62786. interface AbstractScene {
  62787. /**
  62788. * Return a the first highlight layer of the scene with a given name.
  62789. * @param name The name of the highlight layer to look for.
  62790. * @return The highlight layer if found otherwise null.
  62791. */
  62792. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  62793. }
  62794. /**
  62795. * Glow layer options. This helps customizing the behaviour
  62796. * of the glow layer.
  62797. */
  62798. export interface IGlowLayerOptions {
  62799. /**
  62800. * Multiplication factor apply to the canvas size to compute the render target size
  62801. * used to generated the glowing objects (the smaller the faster).
  62802. */
  62803. mainTextureRatio: number;
  62804. /**
  62805. * Enforces a fixed size texture to ensure resize independant blur.
  62806. */
  62807. mainTextureFixedSize?: number;
  62808. /**
  62809. * How big is the kernel of the blur texture.
  62810. */
  62811. blurKernelSize: number;
  62812. /**
  62813. * The camera attached to the layer.
  62814. */
  62815. camera: Nullable<Camera>;
  62816. /**
  62817. * Enable MSAA by chosing the number of samples.
  62818. */
  62819. mainTextureSamples?: number;
  62820. /**
  62821. * The rendering group to draw the layer in.
  62822. */
  62823. renderingGroupId: number;
  62824. }
  62825. /**
  62826. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  62827. *
  62828. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  62829. *
  62830. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  62831. */
  62832. export class GlowLayer extends EffectLayer {
  62833. /**
  62834. * Effect Name of the layer.
  62835. */
  62836. static readonly EffectName: string;
  62837. /**
  62838. * The default blur kernel size used for the glow.
  62839. */
  62840. static DefaultBlurKernelSize: number;
  62841. /**
  62842. * The default texture size ratio used for the glow.
  62843. */
  62844. static DefaultTextureRatio: number;
  62845. /**
  62846. * Sets the kernel size of the blur.
  62847. */
  62848. set blurKernelSize(value: number);
  62849. /**
  62850. * Gets the kernel size of the blur.
  62851. */
  62852. get blurKernelSize(): number;
  62853. /**
  62854. * Sets the glow intensity.
  62855. */
  62856. set intensity(value: number);
  62857. /**
  62858. * Gets the glow intensity.
  62859. */
  62860. get intensity(): number;
  62861. private _options;
  62862. private _intensity;
  62863. private _horizontalBlurPostprocess1;
  62864. private _verticalBlurPostprocess1;
  62865. private _horizontalBlurPostprocess2;
  62866. private _verticalBlurPostprocess2;
  62867. private _blurTexture1;
  62868. private _blurTexture2;
  62869. private _postProcesses1;
  62870. private _postProcesses2;
  62871. private _includedOnlyMeshes;
  62872. private _excludedMeshes;
  62873. private _meshesUsingTheirOwnMaterials;
  62874. /**
  62875. * Callback used to let the user override the color selection on a per mesh basis
  62876. */
  62877. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  62878. /**
  62879. * Callback used to let the user override the texture selection on a per mesh basis
  62880. */
  62881. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  62882. /**
  62883. * Instantiates a new glow Layer and references it to the scene.
  62884. * @param name The name of the layer
  62885. * @param scene The scene to use the layer in
  62886. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  62887. */
  62888. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  62889. /**
  62890. * Get the effect name of the layer.
  62891. * @return The effect name
  62892. */
  62893. getEffectName(): string;
  62894. /**
  62895. * Create the merge effect. This is the shader use to blit the information back
  62896. * to the main canvas at the end of the scene rendering.
  62897. */
  62898. protected _createMergeEffect(): Effect;
  62899. /**
  62900. * Creates the render target textures and post processes used in the glow layer.
  62901. */
  62902. protected _createTextureAndPostProcesses(): void;
  62903. /**
  62904. * Checks for the readiness of the element composing the layer.
  62905. * @param subMesh the mesh to check for
  62906. * @param useInstances specify wether or not to use instances to render the mesh
  62907. * @param emissiveTexture the associated emissive texture used to generate the glow
  62908. * @return true if ready otherwise, false
  62909. */
  62910. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62911. /**
  62912. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62913. */
  62914. needStencil(): boolean;
  62915. /**
  62916. * Returns true if the mesh can be rendered, otherwise false.
  62917. * @param mesh The mesh to render
  62918. * @param material The material used on the mesh
  62919. * @returns true if it can be rendered otherwise false
  62920. */
  62921. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62922. /**
  62923. * Implementation specific of rendering the generating effect on the main canvas.
  62924. * @param effect The effect used to render through
  62925. */
  62926. protected _internalRender(effect: Effect): void;
  62927. /**
  62928. * Sets the required values for both the emissive texture and and the main color.
  62929. */
  62930. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62931. /**
  62932. * Returns true if the mesh should render, otherwise false.
  62933. * @param mesh The mesh to render
  62934. * @returns true if it should render otherwise false
  62935. */
  62936. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62937. /**
  62938. * Adds specific effects defines.
  62939. * @param defines The defines to add specifics to.
  62940. */
  62941. protected _addCustomEffectDefines(defines: string[]): void;
  62942. /**
  62943. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  62944. * @param mesh The mesh to exclude from the glow layer
  62945. */
  62946. addExcludedMesh(mesh: Mesh): void;
  62947. /**
  62948. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  62949. * @param mesh The mesh to remove
  62950. */
  62951. removeExcludedMesh(mesh: Mesh): void;
  62952. /**
  62953. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  62954. * @param mesh The mesh to include in the glow layer
  62955. */
  62956. addIncludedOnlyMesh(mesh: Mesh): void;
  62957. /**
  62958. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  62959. * @param mesh The mesh to remove
  62960. */
  62961. removeIncludedOnlyMesh(mesh: Mesh): void;
  62962. /**
  62963. * Determine if a given mesh will be used in the glow layer
  62964. * @param mesh The mesh to test
  62965. * @returns true if the mesh will be highlighted by the current glow layer
  62966. */
  62967. hasMesh(mesh: AbstractMesh): boolean;
  62968. /**
  62969. * Defines whether the current material of the mesh should be use to render the effect.
  62970. * @param mesh defines the current mesh to render
  62971. */
  62972. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62973. /**
  62974. * Add a mesh to be rendered through its own material and not with emissive only.
  62975. * @param mesh The mesh for which we need to use its material
  62976. */
  62977. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  62978. /**
  62979. * Remove a mesh from being rendered through its own material and not with emissive only.
  62980. * @param mesh The mesh for which we need to not use its material
  62981. */
  62982. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  62983. /**
  62984. * Free any resources and references associated to a mesh.
  62985. * Internal use
  62986. * @param mesh The mesh to free.
  62987. * @hidden
  62988. */
  62989. _disposeMesh(mesh: Mesh): void;
  62990. /**
  62991. * Gets the class name of the effect layer
  62992. * @returns the string with the class name of the effect layer
  62993. */
  62994. getClassName(): string;
  62995. /**
  62996. * Serializes this glow layer
  62997. * @returns a serialized glow layer object
  62998. */
  62999. serialize(): any;
  63000. /**
  63001. * Creates a Glow Layer from parsed glow layer data
  63002. * @param parsedGlowLayer defines glow layer data
  63003. * @param scene defines the current scene
  63004. * @param rootUrl defines the root URL containing the glow layer information
  63005. * @returns a parsed Glow Layer
  63006. */
  63007. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  63008. }
  63009. }
  63010. declare module BABYLON {
  63011. /** @hidden */
  63012. export var glowBlurPostProcessPixelShader: {
  63013. name: string;
  63014. shader: string;
  63015. };
  63016. }
  63017. declare module BABYLON {
  63018. interface AbstractScene {
  63019. /**
  63020. * Return a the first highlight layer of the scene with a given name.
  63021. * @param name The name of the highlight layer to look for.
  63022. * @return The highlight layer if found otherwise null.
  63023. */
  63024. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  63025. }
  63026. /**
  63027. * Highlight layer options. This helps customizing the behaviour
  63028. * of the highlight layer.
  63029. */
  63030. export interface IHighlightLayerOptions {
  63031. /**
  63032. * Multiplication factor apply to the canvas size to compute the render target size
  63033. * used to generated the glowing objects (the smaller the faster).
  63034. */
  63035. mainTextureRatio: number;
  63036. /**
  63037. * Enforces a fixed size texture to ensure resize independant blur.
  63038. */
  63039. mainTextureFixedSize?: number;
  63040. /**
  63041. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  63042. * of the picture to blur (the smaller the faster).
  63043. */
  63044. blurTextureSizeRatio: number;
  63045. /**
  63046. * How big in texel of the blur texture is the vertical blur.
  63047. */
  63048. blurVerticalSize: number;
  63049. /**
  63050. * How big in texel of the blur texture is the horizontal blur.
  63051. */
  63052. blurHorizontalSize: number;
  63053. /**
  63054. * Alpha blending mode used to apply the blur. Default is combine.
  63055. */
  63056. alphaBlendingMode: number;
  63057. /**
  63058. * The camera attached to the layer.
  63059. */
  63060. camera: Nullable<Camera>;
  63061. /**
  63062. * Should we display highlight as a solid stroke?
  63063. */
  63064. isStroke?: boolean;
  63065. /**
  63066. * The rendering group to draw the layer in.
  63067. */
  63068. renderingGroupId: number;
  63069. }
  63070. /**
  63071. * The highlight layer Helps adding a glow effect around a mesh.
  63072. *
  63073. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  63074. * glowy meshes to your scene.
  63075. *
  63076. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  63077. */
  63078. export class HighlightLayer extends EffectLayer {
  63079. name: string;
  63080. /**
  63081. * Effect Name of the highlight layer.
  63082. */
  63083. static readonly EffectName: string;
  63084. /**
  63085. * The neutral color used during the preparation of the glow effect.
  63086. * This is black by default as the blend operation is a blend operation.
  63087. */
  63088. static NeutralColor: Color4;
  63089. /**
  63090. * Stencil value used for glowing meshes.
  63091. */
  63092. static GlowingMeshStencilReference: number;
  63093. /**
  63094. * Stencil value used for the other meshes in the scene.
  63095. */
  63096. static NormalMeshStencilReference: number;
  63097. /**
  63098. * Specifies whether or not the inner glow is ACTIVE in the layer.
  63099. */
  63100. innerGlow: boolean;
  63101. /**
  63102. * Specifies whether or not the outer glow is ACTIVE in the layer.
  63103. */
  63104. outerGlow: boolean;
  63105. /**
  63106. * Specifies the horizontal size of the blur.
  63107. */
  63108. set blurHorizontalSize(value: number);
  63109. /**
  63110. * Specifies the vertical size of the blur.
  63111. */
  63112. set blurVerticalSize(value: number);
  63113. /**
  63114. * Gets the horizontal size of the blur.
  63115. */
  63116. get blurHorizontalSize(): number;
  63117. /**
  63118. * Gets the vertical size of the blur.
  63119. */
  63120. get blurVerticalSize(): number;
  63121. /**
  63122. * An event triggered when the highlight layer is being blurred.
  63123. */
  63124. onBeforeBlurObservable: Observable<HighlightLayer>;
  63125. /**
  63126. * An event triggered when the highlight layer has been blurred.
  63127. */
  63128. onAfterBlurObservable: Observable<HighlightLayer>;
  63129. private _instanceGlowingMeshStencilReference;
  63130. private _options;
  63131. private _downSamplePostprocess;
  63132. private _horizontalBlurPostprocess;
  63133. private _verticalBlurPostprocess;
  63134. private _blurTexture;
  63135. private _meshes;
  63136. private _excludedMeshes;
  63137. /**
  63138. * Instantiates a new highlight Layer and references it to the scene..
  63139. * @param name The name of the layer
  63140. * @param scene The scene to use the layer in
  63141. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  63142. */
  63143. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  63144. /**
  63145. * Get the effect name of the layer.
  63146. * @return The effect name
  63147. */
  63148. getEffectName(): string;
  63149. /**
  63150. * Create the merge effect. This is the shader use to blit the information back
  63151. * to the main canvas at the end of the scene rendering.
  63152. */
  63153. protected _createMergeEffect(): Effect;
  63154. /**
  63155. * Creates the render target textures and post processes used in the highlight layer.
  63156. */
  63157. protected _createTextureAndPostProcesses(): void;
  63158. /**
  63159. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  63160. */
  63161. needStencil(): boolean;
  63162. /**
  63163. * Checks for the readiness of the element composing the layer.
  63164. * @param subMesh the mesh to check for
  63165. * @param useInstances specify wether or not to use instances to render the mesh
  63166. * @param emissiveTexture the associated emissive texture used to generate the glow
  63167. * @return true if ready otherwise, false
  63168. */
  63169. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63170. /**
  63171. * Implementation specific of rendering the generating effect on the main canvas.
  63172. * @param effect The effect used to render through
  63173. */
  63174. protected _internalRender(effect: Effect): void;
  63175. /**
  63176. * Returns true if the layer contains information to display, otherwise false.
  63177. */
  63178. shouldRender(): boolean;
  63179. /**
  63180. * Returns true if the mesh should render, otherwise false.
  63181. * @param mesh The mesh to render
  63182. * @returns true if it should render otherwise false
  63183. */
  63184. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63185. /**
  63186. * Returns true if the mesh can be rendered, otherwise false.
  63187. * @param mesh The mesh to render
  63188. * @param material The material used on the mesh
  63189. * @returns true if it can be rendered otherwise false
  63190. */
  63191. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63192. /**
  63193. * Adds specific effects defines.
  63194. * @param defines The defines to add specifics to.
  63195. */
  63196. protected _addCustomEffectDefines(defines: string[]): void;
  63197. /**
  63198. * Sets the required values for both the emissive texture and and the main color.
  63199. */
  63200. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63201. /**
  63202. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  63203. * @param mesh The mesh to exclude from the highlight layer
  63204. */
  63205. addExcludedMesh(mesh: Mesh): void;
  63206. /**
  63207. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  63208. * @param mesh The mesh to highlight
  63209. */
  63210. removeExcludedMesh(mesh: Mesh): void;
  63211. /**
  63212. * Determine if a given mesh will be highlighted by the current HighlightLayer
  63213. * @param mesh mesh to test
  63214. * @returns true if the mesh will be highlighted by the current HighlightLayer
  63215. */
  63216. hasMesh(mesh: AbstractMesh): boolean;
  63217. /**
  63218. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  63219. * @param mesh The mesh to highlight
  63220. * @param color The color of the highlight
  63221. * @param glowEmissiveOnly Extract the glow from the emissive texture
  63222. */
  63223. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  63224. /**
  63225. * Remove a mesh from the highlight layer in order to make it stop glowing.
  63226. * @param mesh The mesh to highlight
  63227. */
  63228. removeMesh(mesh: Mesh): void;
  63229. /**
  63230. * Remove all the meshes currently referenced in the highlight layer
  63231. */
  63232. removeAllMeshes(): void;
  63233. /**
  63234. * Force the stencil to the normal expected value for none glowing parts
  63235. */
  63236. private _defaultStencilReference;
  63237. /**
  63238. * Free any resources and references associated to a mesh.
  63239. * Internal use
  63240. * @param mesh The mesh to free.
  63241. * @hidden
  63242. */
  63243. _disposeMesh(mesh: Mesh): void;
  63244. /**
  63245. * Dispose the highlight layer and free resources.
  63246. */
  63247. dispose(): void;
  63248. /**
  63249. * Gets the class name of the effect layer
  63250. * @returns the string with the class name of the effect layer
  63251. */
  63252. getClassName(): string;
  63253. /**
  63254. * Serializes this Highlight layer
  63255. * @returns a serialized Highlight layer object
  63256. */
  63257. serialize(): any;
  63258. /**
  63259. * Creates a Highlight layer from parsed Highlight layer data
  63260. * @param parsedHightlightLayer defines the Highlight layer data
  63261. * @param scene defines the current scene
  63262. * @param rootUrl defines the root URL containing the Highlight layer information
  63263. * @returns a parsed Highlight layer
  63264. */
  63265. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  63266. }
  63267. }
  63268. declare module BABYLON {
  63269. interface AbstractScene {
  63270. /**
  63271. * The list of layers (background and foreground) of the scene
  63272. */
  63273. layers: Array<Layer>;
  63274. }
  63275. /**
  63276. * Defines the layer scene component responsible to manage any layers
  63277. * in a given scene.
  63278. */
  63279. export class LayerSceneComponent implements ISceneComponent {
  63280. /**
  63281. * The component name helpfull to identify the component in the list of scene components.
  63282. */
  63283. readonly name: string;
  63284. /**
  63285. * The scene the component belongs to.
  63286. */
  63287. scene: Scene;
  63288. private _engine;
  63289. /**
  63290. * Creates a new instance of the component for the given scene
  63291. * @param scene Defines the scene to register the component in
  63292. */
  63293. constructor(scene: Scene);
  63294. /**
  63295. * Registers the component in a given scene
  63296. */
  63297. register(): void;
  63298. /**
  63299. * Rebuilds the elements related to this component in case of
  63300. * context lost for instance.
  63301. */
  63302. rebuild(): void;
  63303. /**
  63304. * Disposes the component and the associated ressources.
  63305. */
  63306. dispose(): void;
  63307. private _draw;
  63308. private _drawCameraPredicate;
  63309. private _drawCameraBackground;
  63310. private _drawCameraForeground;
  63311. private _drawRenderTargetPredicate;
  63312. private _drawRenderTargetBackground;
  63313. private _drawRenderTargetForeground;
  63314. /**
  63315. * Adds all the elements from the container to the scene
  63316. * @param container the container holding the elements
  63317. */
  63318. addFromContainer(container: AbstractScene): void;
  63319. /**
  63320. * Removes all the elements in the container from the scene
  63321. * @param container contains the elements to remove
  63322. * @param dispose if the removed element should be disposed (default: false)
  63323. */
  63324. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63325. }
  63326. }
  63327. declare module BABYLON {
  63328. /** @hidden */
  63329. export var layerPixelShader: {
  63330. name: string;
  63331. shader: string;
  63332. };
  63333. }
  63334. declare module BABYLON {
  63335. /** @hidden */
  63336. export var layerVertexShader: {
  63337. name: string;
  63338. shader: string;
  63339. };
  63340. }
  63341. declare module BABYLON {
  63342. /**
  63343. * This represents a full screen 2d layer.
  63344. * This can be useful to display a picture in the background of your scene for instance.
  63345. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63346. */
  63347. export class Layer {
  63348. /**
  63349. * Define the name of the layer.
  63350. */
  63351. name: string;
  63352. /**
  63353. * Define the texture the layer should display.
  63354. */
  63355. texture: Nullable<Texture>;
  63356. /**
  63357. * Is the layer in background or foreground.
  63358. */
  63359. isBackground: boolean;
  63360. /**
  63361. * Define the color of the layer (instead of texture).
  63362. */
  63363. color: Color4;
  63364. /**
  63365. * Define the scale of the layer in order to zoom in out of the texture.
  63366. */
  63367. scale: Vector2;
  63368. /**
  63369. * Define an offset for the layer in order to shift the texture.
  63370. */
  63371. offset: Vector2;
  63372. /**
  63373. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  63374. */
  63375. alphaBlendingMode: number;
  63376. /**
  63377. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  63378. * Alpha test will not mix with the background color in case of transparency.
  63379. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  63380. */
  63381. alphaTest: boolean;
  63382. /**
  63383. * Define a mask to restrict the layer to only some of the scene cameras.
  63384. */
  63385. layerMask: number;
  63386. /**
  63387. * Define the list of render target the layer is visible into.
  63388. */
  63389. renderTargetTextures: RenderTargetTexture[];
  63390. /**
  63391. * Define if the layer is only used in renderTarget or if it also
  63392. * renders in the main frame buffer of the canvas.
  63393. */
  63394. renderOnlyInRenderTargetTextures: boolean;
  63395. private _scene;
  63396. private _vertexBuffers;
  63397. private _indexBuffer;
  63398. private _effect;
  63399. private _previousDefines;
  63400. /**
  63401. * An event triggered when the layer is disposed.
  63402. */
  63403. onDisposeObservable: Observable<Layer>;
  63404. private _onDisposeObserver;
  63405. /**
  63406. * Back compatibility with callback before the onDisposeObservable existed.
  63407. * The set callback will be triggered when the layer has been disposed.
  63408. */
  63409. set onDispose(callback: () => void);
  63410. /**
  63411. * An event triggered before rendering the scene
  63412. */
  63413. onBeforeRenderObservable: Observable<Layer>;
  63414. private _onBeforeRenderObserver;
  63415. /**
  63416. * Back compatibility with callback before the onBeforeRenderObservable existed.
  63417. * The set callback will be triggered just before rendering the layer.
  63418. */
  63419. set onBeforeRender(callback: () => void);
  63420. /**
  63421. * An event triggered after rendering the scene
  63422. */
  63423. onAfterRenderObservable: Observable<Layer>;
  63424. private _onAfterRenderObserver;
  63425. /**
  63426. * Back compatibility with callback before the onAfterRenderObservable existed.
  63427. * The set callback will be triggered just after rendering the layer.
  63428. */
  63429. set onAfterRender(callback: () => void);
  63430. /**
  63431. * Instantiates a new layer.
  63432. * This represents a full screen 2d layer.
  63433. * This can be useful to display a picture in the background of your scene for instance.
  63434. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63435. * @param name Define the name of the layer in the scene
  63436. * @param imgUrl Define the url of the texture to display in the layer
  63437. * @param scene Define the scene the layer belongs to
  63438. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  63439. * @param color Defines a color for the layer
  63440. */
  63441. constructor(
  63442. /**
  63443. * Define the name of the layer.
  63444. */
  63445. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  63446. private _createIndexBuffer;
  63447. /** @hidden */
  63448. _rebuild(): void;
  63449. /**
  63450. * Renders the layer in the scene.
  63451. */
  63452. render(): void;
  63453. /**
  63454. * Disposes and releases the associated ressources.
  63455. */
  63456. dispose(): void;
  63457. }
  63458. }
  63459. declare module BABYLON {
  63460. /** @hidden */
  63461. export var lensFlarePixelShader: {
  63462. name: string;
  63463. shader: string;
  63464. };
  63465. }
  63466. declare module BABYLON {
  63467. /** @hidden */
  63468. export var lensFlareVertexShader: {
  63469. name: string;
  63470. shader: string;
  63471. };
  63472. }
  63473. declare module BABYLON {
  63474. /**
  63475. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63476. * It is usually composed of several `lensFlare`.
  63477. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63478. */
  63479. export class LensFlareSystem {
  63480. /**
  63481. * Define the name of the lens flare system
  63482. */
  63483. name: string;
  63484. /**
  63485. * List of lens flares used in this system.
  63486. */
  63487. lensFlares: LensFlare[];
  63488. /**
  63489. * Define a limit from the border the lens flare can be visible.
  63490. */
  63491. borderLimit: number;
  63492. /**
  63493. * Define a viewport border we do not want to see the lens flare in.
  63494. */
  63495. viewportBorder: number;
  63496. /**
  63497. * Define a predicate which could limit the list of meshes able to occlude the effect.
  63498. */
  63499. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  63500. /**
  63501. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  63502. */
  63503. layerMask: number;
  63504. /**
  63505. * Define the id of the lens flare system in the scene.
  63506. * (equal to name by default)
  63507. */
  63508. id: string;
  63509. private _scene;
  63510. private _emitter;
  63511. private _vertexBuffers;
  63512. private _indexBuffer;
  63513. private _effect;
  63514. private _positionX;
  63515. private _positionY;
  63516. private _isEnabled;
  63517. /** @hidden */
  63518. static _SceneComponentInitialization: (scene: Scene) => void;
  63519. /**
  63520. * Instantiates a lens flare system.
  63521. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63522. * It is usually composed of several `lensFlare`.
  63523. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63524. * @param name Define the name of the lens flare system in the scene
  63525. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  63526. * @param scene Define the scene the lens flare system belongs to
  63527. */
  63528. constructor(
  63529. /**
  63530. * Define the name of the lens flare system
  63531. */
  63532. name: string, emitter: any, scene: Scene);
  63533. /**
  63534. * Define if the lens flare system is enabled.
  63535. */
  63536. get isEnabled(): boolean;
  63537. set isEnabled(value: boolean);
  63538. /**
  63539. * Get the scene the effects belongs to.
  63540. * @returns the scene holding the lens flare system
  63541. */
  63542. getScene(): Scene;
  63543. /**
  63544. * Get the emitter of the lens flare system.
  63545. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63546. * @returns the emitter of the lens flare system
  63547. */
  63548. getEmitter(): any;
  63549. /**
  63550. * Set the emitter of the lens flare system.
  63551. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63552. * @param newEmitter Define the new emitter of the system
  63553. */
  63554. setEmitter(newEmitter: any): void;
  63555. /**
  63556. * Get the lens flare system emitter position.
  63557. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  63558. * @returns the position
  63559. */
  63560. getEmitterPosition(): Vector3;
  63561. /**
  63562. * @hidden
  63563. */
  63564. computeEffectivePosition(globalViewport: Viewport): boolean;
  63565. /** @hidden */
  63566. _isVisible(): boolean;
  63567. /**
  63568. * @hidden
  63569. */
  63570. render(): boolean;
  63571. /**
  63572. * Dispose and release the lens flare with its associated resources.
  63573. */
  63574. dispose(): void;
  63575. /**
  63576. * Parse a lens flare system from a JSON repressentation
  63577. * @param parsedLensFlareSystem Define the JSON to parse
  63578. * @param scene Define the scene the parsed system should be instantiated in
  63579. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  63580. * @returns the parsed system
  63581. */
  63582. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  63583. /**
  63584. * Serialize the current Lens Flare System into a JSON representation.
  63585. * @returns the serialized JSON
  63586. */
  63587. serialize(): any;
  63588. }
  63589. }
  63590. declare module BABYLON {
  63591. /**
  63592. * This represents one of the lens effect in a `lensFlareSystem`.
  63593. * It controls one of the indiviual texture used in the effect.
  63594. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63595. */
  63596. export class LensFlare {
  63597. /**
  63598. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63599. */
  63600. size: number;
  63601. /**
  63602. * 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.
  63603. */
  63604. position: number;
  63605. /**
  63606. * Define the lens color.
  63607. */
  63608. color: Color3;
  63609. /**
  63610. * Define the lens texture.
  63611. */
  63612. texture: Nullable<Texture>;
  63613. /**
  63614. * Define the alpha mode to render this particular lens.
  63615. */
  63616. alphaMode: number;
  63617. private _system;
  63618. /**
  63619. * Creates a new Lens Flare.
  63620. * This represents one of the lens effect in a `lensFlareSystem`.
  63621. * It controls one of the indiviual texture used in the effect.
  63622. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63623. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  63624. * @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.
  63625. * @param color Define the lens color
  63626. * @param imgUrl Define the lens texture url
  63627. * @param system Define the `lensFlareSystem` this flare is part of
  63628. * @returns The newly created Lens Flare
  63629. */
  63630. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  63631. /**
  63632. * Instantiates a new Lens Flare.
  63633. * This represents one of the lens effect in a `lensFlareSystem`.
  63634. * It controls one of the indiviual texture used in the effect.
  63635. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63636. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  63637. * @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.
  63638. * @param color Define the lens color
  63639. * @param imgUrl Define the lens texture url
  63640. * @param system Define the `lensFlareSystem` this flare is part of
  63641. */
  63642. constructor(
  63643. /**
  63644. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63645. */
  63646. size: number,
  63647. /**
  63648. * 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.
  63649. */
  63650. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  63651. /**
  63652. * Dispose and release the lens flare with its associated resources.
  63653. */
  63654. dispose(): void;
  63655. }
  63656. }
  63657. declare module BABYLON {
  63658. interface AbstractScene {
  63659. /**
  63660. * The list of lens flare system added to the scene
  63661. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63662. */
  63663. lensFlareSystems: Array<LensFlareSystem>;
  63664. /**
  63665. * Removes the given lens flare system from this scene.
  63666. * @param toRemove The lens flare system to remove
  63667. * @returns The index of the removed lens flare system
  63668. */
  63669. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  63670. /**
  63671. * Adds the given lens flare system to this scene
  63672. * @param newLensFlareSystem The lens flare system to add
  63673. */
  63674. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  63675. /**
  63676. * Gets a lens flare system using its name
  63677. * @param name defines the name to look for
  63678. * @returns the lens flare system or null if not found
  63679. */
  63680. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  63681. /**
  63682. * Gets a lens flare system using its id
  63683. * @param id defines the id to look for
  63684. * @returns the lens flare system or null if not found
  63685. */
  63686. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  63687. }
  63688. /**
  63689. * Defines the lens flare scene component responsible to manage any lens flares
  63690. * in a given scene.
  63691. */
  63692. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  63693. /**
  63694. * The component name helpfull to identify the component in the list of scene components.
  63695. */
  63696. readonly name: string;
  63697. /**
  63698. * The scene the component belongs to.
  63699. */
  63700. scene: Scene;
  63701. /**
  63702. * Creates a new instance of the component for the given scene
  63703. * @param scene Defines the scene to register the component in
  63704. */
  63705. constructor(scene: Scene);
  63706. /**
  63707. * Registers the component in a given scene
  63708. */
  63709. register(): void;
  63710. /**
  63711. * Rebuilds the elements related to this component in case of
  63712. * context lost for instance.
  63713. */
  63714. rebuild(): void;
  63715. /**
  63716. * Adds all the elements from the container to the scene
  63717. * @param container the container holding the elements
  63718. */
  63719. addFromContainer(container: AbstractScene): void;
  63720. /**
  63721. * Removes all the elements in the container from the scene
  63722. * @param container contains the elements to remove
  63723. * @param dispose if the removed element should be disposed (default: false)
  63724. */
  63725. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63726. /**
  63727. * Serializes the component data to the specified json object
  63728. * @param serializationObject The object to serialize to
  63729. */
  63730. serialize(serializationObject: any): void;
  63731. /**
  63732. * Disposes the component and the associated ressources.
  63733. */
  63734. dispose(): void;
  63735. private _draw;
  63736. }
  63737. }
  63738. declare module BABYLON {
  63739. /** @hidden */
  63740. export var depthPixelShader: {
  63741. name: string;
  63742. shader: string;
  63743. };
  63744. }
  63745. declare module BABYLON {
  63746. /** @hidden */
  63747. export var depthVertexShader: {
  63748. name: string;
  63749. shader: string;
  63750. };
  63751. }
  63752. declare module BABYLON {
  63753. /**
  63754. * This represents a depth renderer in Babylon.
  63755. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63756. */
  63757. export class DepthRenderer {
  63758. private _scene;
  63759. private _depthMap;
  63760. private _effect;
  63761. private readonly _storeNonLinearDepth;
  63762. private readonly _clearColor;
  63763. /** Get if the depth renderer is using packed depth or not */
  63764. readonly isPacked: boolean;
  63765. private _cachedDefines;
  63766. private _camera;
  63767. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  63768. enabled: boolean;
  63769. /**
  63770. * Specifiess that the depth renderer will only be used within
  63771. * the camera it is created for.
  63772. * This can help forcing its rendering during the camera processing.
  63773. */
  63774. useOnlyInActiveCamera: boolean;
  63775. /** @hidden */
  63776. static _SceneComponentInitialization: (scene: Scene) => void;
  63777. /**
  63778. * Instantiates a depth renderer
  63779. * @param scene The scene the renderer belongs to
  63780. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63781. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63782. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63783. */
  63784. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63785. /**
  63786. * Creates the depth rendering effect and checks if the effect is ready.
  63787. * @param subMesh The submesh to be used to render the depth map of
  63788. * @param useInstances If multiple world instances should be used
  63789. * @returns if the depth renderer is ready to render the depth map
  63790. */
  63791. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63792. /**
  63793. * Gets the texture which the depth map will be written to.
  63794. * @returns The depth map texture
  63795. */
  63796. getDepthMap(): RenderTargetTexture;
  63797. /**
  63798. * Disposes of the depth renderer.
  63799. */
  63800. dispose(): void;
  63801. }
  63802. }
  63803. declare module BABYLON {
  63804. /** @hidden */
  63805. export var minmaxReduxPixelShader: {
  63806. name: string;
  63807. shader: string;
  63808. };
  63809. }
  63810. declare module BABYLON {
  63811. /**
  63812. * This class computes a min/max reduction from a texture: it means it computes the minimum
  63813. * and maximum values from all values of the texture.
  63814. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  63815. * The source values are read from the red channel of the texture.
  63816. */
  63817. export class MinMaxReducer {
  63818. /**
  63819. * Observable triggered when the computation has been performed
  63820. */
  63821. onAfterReductionPerformed: Observable<{
  63822. min: number;
  63823. max: number;
  63824. }>;
  63825. protected _camera: Camera;
  63826. protected _sourceTexture: Nullable<RenderTargetTexture>;
  63827. protected _reductionSteps: Nullable<Array<PostProcess>>;
  63828. protected _postProcessManager: PostProcessManager;
  63829. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  63830. protected _forceFullscreenViewport: boolean;
  63831. /**
  63832. * Creates a min/max reducer
  63833. * @param camera The camera to use for the post processes
  63834. */
  63835. constructor(camera: Camera);
  63836. /**
  63837. * Gets the texture used to read the values from.
  63838. */
  63839. get sourceTexture(): Nullable<RenderTargetTexture>;
  63840. /**
  63841. * Sets the source texture to read the values from.
  63842. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  63843. * because in such textures '1' value must not be taken into account to compute the maximum
  63844. * as this value is used to clear the texture.
  63845. * Note that the computation is not activated by calling this function, you must call activate() for that!
  63846. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  63847. * @param depthRedux Indicates if the texture is a depth texture or not
  63848. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  63849. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63850. */
  63851. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63852. /**
  63853. * Defines the refresh rate of the computation.
  63854. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63855. */
  63856. get refreshRate(): number;
  63857. set refreshRate(value: number);
  63858. protected _activated: boolean;
  63859. /**
  63860. * Gets the activation status of the reducer
  63861. */
  63862. get activated(): boolean;
  63863. /**
  63864. * Activates the reduction computation.
  63865. * When activated, the observers registered in onAfterReductionPerformed are
  63866. * called after the compuation is performed
  63867. */
  63868. activate(): void;
  63869. /**
  63870. * Deactivates the reduction computation.
  63871. */
  63872. deactivate(): void;
  63873. /**
  63874. * Disposes the min/max reducer
  63875. * @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.
  63876. */
  63877. dispose(disposeAll?: boolean): void;
  63878. }
  63879. }
  63880. declare module BABYLON {
  63881. /**
  63882. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  63883. */
  63884. export class DepthReducer extends MinMaxReducer {
  63885. private _depthRenderer;
  63886. private _depthRendererId;
  63887. /**
  63888. * Gets the depth renderer used for the computation.
  63889. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  63890. */
  63891. get depthRenderer(): Nullable<DepthRenderer>;
  63892. /**
  63893. * Creates a depth reducer
  63894. * @param camera The camera used to render the depth texture
  63895. */
  63896. constructor(camera: Camera);
  63897. /**
  63898. * Sets the depth renderer to use to generate the depth map
  63899. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  63900. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  63901. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63902. */
  63903. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  63904. /** @hidden */
  63905. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63906. /**
  63907. * Activates the reduction computation.
  63908. * When activated, the observers registered in onAfterReductionPerformed are
  63909. * called after the compuation is performed
  63910. */
  63911. activate(): void;
  63912. /**
  63913. * Deactivates the reduction computation.
  63914. */
  63915. deactivate(): void;
  63916. /**
  63917. * Disposes the depth reducer
  63918. * @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.
  63919. */
  63920. dispose(disposeAll?: boolean): void;
  63921. }
  63922. }
  63923. declare module BABYLON {
  63924. /**
  63925. * A CSM implementation allowing casting shadows on large scenes.
  63926. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63927. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  63928. */
  63929. export class CascadedShadowGenerator extends ShadowGenerator {
  63930. private static readonly frustumCornersNDCSpace;
  63931. /**
  63932. * Name of the CSM class
  63933. */
  63934. static CLASSNAME: string;
  63935. /**
  63936. * Defines the default number of cascades used by the CSM.
  63937. */
  63938. static readonly DEFAULT_CASCADES_COUNT: number;
  63939. /**
  63940. * Defines the minimum number of cascades used by the CSM.
  63941. */
  63942. static readonly MIN_CASCADES_COUNT: number;
  63943. /**
  63944. * Defines the maximum number of cascades used by the CSM.
  63945. */
  63946. static readonly MAX_CASCADES_COUNT: number;
  63947. protected _validateFilter(filter: number): number;
  63948. /**
  63949. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  63950. */
  63951. penumbraDarkness: number;
  63952. private _numCascades;
  63953. /**
  63954. * Gets or set the number of cascades used by the CSM.
  63955. */
  63956. get numCascades(): number;
  63957. set numCascades(value: number);
  63958. /**
  63959. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  63960. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  63961. */
  63962. stabilizeCascades: boolean;
  63963. private _freezeShadowCastersBoundingInfo;
  63964. private _freezeShadowCastersBoundingInfoObservable;
  63965. /**
  63966. * Enables or disables the shadow casters bounding info computation.
  63967. * If your shadow casters don't move, you can disable this feature.
  63968. * If it is enabled, the bounding box computation is done every frame.
  63969. */
  63970. get freezeShadowCastersBoundingInfo(): boolean;
  63971. set freezeShadowCastersBoundingInfo(freeze: boolean);
  63972. private _scbiMin;
  63973. private _scbiMax;
  63974. protected _computeShadowCastersBoundingInfo(): void;
  63975. protected _shadowCastersBoundingInfo: BoundingInfo;
  63976. /**
  63977. * Gets or sets the shadow casters bounding info.
  63978. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  63979. * so that the system won't overwrite the bounds you provide
  63980. */
  63981. get shadowCastersBoundingInfo(): BoundingInfo;
  63982. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  63983. protected _breaksAreDirty: boolean;
  63984. protected _minDistance: number;
  63985. protected _maxDistance: number;
  63986. /**
  63987. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  63988. *
  63989. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  63990. * If you don't know these values, simply leave them to their defaults and don't call this function.
  63991. * @param min minimal distance for the breaks (default to 0.)
  63992. * @param max maximal distance for the breaks (default to 1.)
  63993. */
  63994. setMinMaxDistance(min: number, max: number): void;
  63995. /** Gets the minimal distance used in the cascade break computation */
  63996. get minDistance(): number;
  63997. /** Gets the maximal distance used in the cascade break computation */
  63998. get maxDistance(): number;
  63999. /**
  64000. * Gets the class name of that object
  64001. * @returns "CascadedShadowGenerator"
  64002. */
  64003. getClassName(): string;
  64004. private _cascadeMinExtents;
  64005. private _cascadeMaxExtents;
  64006. /**
  64007. * Gets a cascade minimum extents
  64008. * @param cascadeIndex index of the cascade
  64009. * @returns the minimum cascade extents
  64010. */
  64011. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  64012. /**
  64013. * Gets a cascade maximum extents
  64014. * @param cascadeIndex index of the cascade
  64015. * @returns the maximum cascade extents
  64016. */
  64017. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  64018. private _cascades;
  64019. private _currentLayer;
  64020. private _viewSpaceFrustumsZ;
  64021. private _viewMatrices;
  64022. private _projectionMatrices;
  64023. private _transformMatrices;
  64024. private _transformMatricesAsArray;
  64025. private _frustumLengths;
  64026. private _lightSizeUVCorrection;
  64027. private _depthCorrection;
  64028. private _frustumCornersWorldSpace;
  64029. private _frustumCenter;
  64030. private _shadowCameraPos;
  64031. private _shadowMaxZ;
  64032. /**
  64033. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  64034. * It defaults to camera.maxZ
  64035. */
  64036. get shadowMaxZ(): number;
  64037. /**
  64038. * Sets the shadow max z distance.
  64039. */
  64040. set shadowMaxZ(value: number);
  64041. protected _debug: boolean;
  64042. /**
  64043. * Gets or sets the debug flag.
  64044. * When enabled, the cascades are materialized by different colors on the screen.
  64045. */
  64046. get debug(): boolean;
  64047. set debug(dbg: boolean);
  64048. private _depthClamp;
  64049. /**
  64050. * Gets or sets the depth clamping value.
  64051. *
  64052. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  64053. * to account for the shadow casters far away.
  64054. *
  64055. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  64056. */
  64057. get depthClamp(): boolean;
  64058. set depthClamp(value: boolean);
  64059. private _cascadeBlendPercentage;
  64060. /**
  64061. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  64062. * It defaults to 0.1 (10% blending).
  64063. */
  64064. get cascadeBlendPercentage(): number;
  64065. set cascadeBlendPercentage(value: number);
  64066. private _lambda;
  64067. /**
  64068. * Gets or set the lambda parameter.
  64069. * This parameter is used to split the camera frustum and create the cascades.
  64070. * 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.
  64071. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  64072. */
  64073. get lambda(): number;
  64074. set lambda(value: number);
  64075. /**
  64076. * Gets the view matrix corresponding to a given cascade
  64077. * @param cascadeNum cascade to retrieve the view matrix from
  64078. * @returns the cascade view matrix
  64079. */
  64080. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  64081. /**
  64082. * Gets the projection matrix corresponding to a given cascade
  64083. * @param cascadeNum cascade to retrieve the projection matrix from
  64084. * @returns the cascade projection matrix
  64085. */
  64086. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  64087. /**
  64088. * Gets the transformation matrix corresponding to a given cascade
  64089. * @param cascadeNum cascade to retrieve the transformation matrix from
  64090. * @returns the cascade transformation matrix
  64091. */
  64092. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  64093. private _depthRenderer;
  64094. /**
  64095. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  64096. *
  64097. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  64098. *
  64099. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  64100. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  64101. * @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
  64102. */
  64103. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  64104. private _depthReducer;
  64105. private _autoCalcDepthBounds;
  64106. /**
  64107. * Gets or sets the autoCalcDepthBounds property.
  64108. *
  64109. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  64110. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  64111. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  64112. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  64113. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  64114. */
  64115. get autoCalcDepthBounds(): boolean;
  64116. set autoCalcDepthBounds(value: boolean);
  64117. /**
  64118. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  64119. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64120. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  64121. * for setting the refresh rate on the renderer yourself!
  64122. */
  64123. get autoCalcDepthBoundsRefreshRate(): number;
  64124. set autoCalcDepthBoundsRefreshRate(value: number);
  64125. /**
  64126. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  64127. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  64128. * you change the camera near/far planes!
  64129. */
  64130. splitFrustum(): void;
  64131. private _splitFrustum;
  64132. private _computeMatrices;
  64133. private _computeFrustumInWorldSpace;
  64134. private _computeCascadeFrustum;
  64135. /**
  64136. * Support test.
  64137. */
  64138. static get IsSupported(): boolean;
  64139. /** @hidden */
  64140. static _SceneComponentInitialization: (scene: Scene) => void;
  64141. /**
  64142. * Creates a Cascaded Shadow Generator object.
  64143. * A ShadowGenerator is the required tool to use the shadows.
  64144. * Each directional light casting shadows needs to use its own ShadowGenerator.
  64145. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64146. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  64147. * @param light The directional light object generating the shadows.
  64148. * @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.
  64149. */
  64150. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  64151. protected _initializeGenerator(): void;
  64152. protected _createTargetRenderTexture(): void;
  64153. protected _initializeShadowMap(): void;
  64154. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  64155. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  64156. /**
  64157. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  64158. * @param defines Defines of the material we want to update
  64159. * @param lightIndex Index of the light in the enabled light list of the material
  64160. */
  64161. prepareDefines(defines: any, lightIndex: number): void;
  64162. /**
  64163. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  64164. * defined in the generator but impacting the effect).
  64165. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  64166. * @param effect The effect we are binfing the information for
  64167. */
  64168. bindShadowLight(lightIndex: string, effect: Effect): void;
  64169. /**
  64170. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  64171. * (eq to view projection * shadow projection matrices)
  64172. * @returns The transform matrix used to create the shadow map
  64173. */
  64174. getTransformMatrix(): Matrix;
  64175. /**
  64176. * Disposes the ShadowGenerator.
  64177. * Returns nothing.
  64178. */
  64179. dispose(): void;
  64180. /**
  64181. * Serializes the shadow generator setup to a json object.
  64182. * @returns The serialized JSON object
  64183. */
  64184. serialize(): any;
  64185. /**
  64186. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  64187. * @param parsedShadowGenerator The JSON object to parse
  64188. * @param scene The scene to create the shadow map for
  64189. * @returns The parsed shadow generator
  64190. */
  64191. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  64192. }
  64193. }
  64194. declare module BABYLON {
  64195. /**
  64196. * Defines the shadow generator component responsible to manage any shadow generators
  64197. * in a given scene.
  64198. */
  64199. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  64200. /**
  64201. * The component name helpfull to identify the component in the list of scene components.
  64202. */
  64203. readonly name: string;
  64204. /**
  64205. * The scene the component belongs to.
  64206. */
  64207. scene: Scene;
  64208. /**
  64209. * Creates a new instance of the component for the given scene
  64210. * @param scene Defines the scene to register the component in
  64211. */
  64212. constructor(scene: Scene);
  64213. /**
  64214. * Registers the component in a given scene
  64215. */
  64216. register(): void;
  64217. /**
  64218. * Rebuilds the elements related to this component in case of
  64219. * context lost for instance.
  64220. */
  64221. rebuild(): void;
  64222. /**
  64223. * Serializes the component data to the specified json object
  64224. * @param serializationObject The object to serialize to
  64225. */
  64226. serialize(serializationObject: any): void;
  64227. /**
  64228. * Adds all the elements from the container to the scene
  64229. * @param container the container holding the elements
  64230. */
  64231. addFromContainer(container: AbstractScene): void;
  64232. /**
  64233. * Removes all the elements in the container from the scene
  64234. * @param container contains the elements to remove
  64235. * @param dispose if the removed element should be disposed (default: false)
  64236. */
  64237. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64238. /**
  64239. * Rebuilds the elements related to this component in case of
  64240. * context lost for instance.
  64241. */
  64242. dispose(): void;
  64243. private _gatherRenderTargets;
  64244. }
  64245. }
  64246. declare module BABYLON {
  64247. /**
  64248. * A point light is a light defined by an unique point in world space.
  64249. * The light is emitted in every direction from this point.
  64250. * A good example of a point light is a standard light bulb.
  64251. * Documentation: https://doc.babylonjs.com/babylon101/lights
  64252. */
  64253. export class PointLight extends ShadowLight {
  64254. private _shadowAngle;
  64255. /**
  64256. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64257. * This specifies what angle the shadow will use to be created.
  64258. *
  64259. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64260. */
  64261. get shadowAngle(): number;
  64262. /**
  64263. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64264. * This specifies what angle the shadow will use to be created.
  64265. *
  64266. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64267. */
  64268. set shadowAngle(value: number);
  64269. /**
  64270. * Gets the direction if it has been set.
  64271. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64272. */
  64273. get direction(): Vector3;
  64274. /**
  64275. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64276. */
  64277. set direction(value: Vector3);
  64278. /**
  64279. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  64280. * A PointLight emits the light in every direction.
  64281. * It can cast shadows.
  64282. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  64283. * ```javascript
  64284. * var pointLight = new PointLight("pl", camera.position, scene);
  64285. * ```
  64286. * Documentation : https://doc.babylonjs.com/babylon101/lights
  64287. * @param name The light friendly name
  64288. * @param position The position of the point light in the scene
  64289. * @param scene The scene the lights belongs to
  64290. */
  64291. constructor(name: string, position: Vector3, scene: Scene);
  64292. /**
  64293. * Returns the string "PointLight"
  64294. * @returns the class name
  64295. */
  64296. getClassName(): string;
  64297. /**
  64298. * Returns the integer 0.
  64299. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  64300. */
  64301. getTypeID(): number;
  64302. /**
  64303. * Specifies wether or not the shadowmap should be a cube texture.
  64304. * @returns true if the shadowmap needs to be a cube texture.
  64305. */
  64306. needCube(): boolean;
  64307. /**
  64308. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  64309. * @param faceIndex The index of the face we are computed the direction to generate shadow
  64310. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  64311. */
  64312. getShadowDirection(faceIndex?: number): Vector3;
  64313. /**
  64314. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  64315. * - fov = PI / 2
  64316. * - aspect ratio : 1.0
  64317. * - z-near and far equal to the active camera minZ and maxZ.
  64318. * Returns the PointLight.
  64319. */
  64320. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  64321. protected _buildUniformLayout(): void;
  64322. /**
  64323. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  64324. * @param effect The effect to update
  64325. * @param lightIndex The index of the light in the effect to update
  64326. * @returns The point light
  64327. */
  64328. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  64329. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  64330. /**
  64331. * Prepares the list of defines specific to the light type.
  64332. * @param defines the list of defines
  64333. * @param lightIndex defines the index of the light for the effect
  64334. */
  64335. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  64336. }
  64337. }
  64338. declare module BABYLON {
  64339. /**
  64340. * Header information of HDR texture files.
  64341. */
  64342. export interface HDRInfo {
  64343. /**
  64344. * The height of the texture in pixels.
  64345. */
  64346. height: number;
  64347. /**
  64348. * The width of the texture in pixels.
  64349. */
  64350. width: number;
  64351. /**
  64352. * The index of the beginning of the data in the binary file.
  64353. */
  64354. dataPosition: number;
  64355. }
  64356. /**
  64357. * This groups tools to convert HDR texture to native colors array.
  64358. */
  64359. export class HDRTools {
  64360. private static Ldexp;
  64361. private static Rgbe2float;
  64362. private static readStringLine;
  64363. /**
  64364. * Reads header information from an RGBE texture stored in a native array.
  64365. * More information on this format are available here:
  64366. * https://en.wikipedia.org/wiki/RGBE_image_format
  64367. *
  64368. * @param uint8array The binary file stored in native array.
  64369. * @return The header information.
  64370. */
  64371. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  64372. /**
  64373. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  64374. * This RGBE texture needs to store the information as a panorama.
  64375. *
  64376. * More information on this format are available here:
  64377. * https://en.wikipedia.org/wiki/RGBE_image_format
  64378. *
  64379. * @param buffer The binary file stored in an array buffer.
  64380. * @param size The expected size of the extracted cubemap.
  64381. * @return The Cube Map information.
  64382. */
  64383. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  64384. /**
  64385. * Returns the pixels data extracted from an RGBE texture.
  64386. * This pixels will be stored left to right up to down in the R G B order in one array.
  64387. *
  64388. * More information on this format are available here:
  64389. * https://en.wikipedia.org/wiki/RGBE_image_format
  64390. *
  64391. * @param uint8array The binary file stored in an array buffer.
  64392. * @param hdrInfo The header information of the file.
  64393. * @return The pixels data in RGB right to left up to down order.
  64394. */
  64395. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  64396. private static RGBE_ReadPixels_RLE;
  64397. private static RGBE_ReadPixels_NOT_RLE;
  64398. }
  64399. }
  64400. declare module BABYLON {
  64401. /**
  64402. * Effect Render Options
  64403. */
  64404. export interface IEffectRendererOptions {
  64405. /**
  64406. * Defines the vertices positions.
  64407. */
  64408. positions?: number[];
  64409. /**
  64410. * Defines the indices.
  64411. */
  64412. indices?: number[];
  64413. }
  64414. /**
  64415. * Helper class to render one or more effects.
  64416. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  64417. */
  64418. export class EffectRenderer {
  64419. private engine;
  64420. private static _DefaultOptions;
  64421. private _vertexBuffers;
  64422. private _indexBuffer;
  64423. private _fullscreenViewport;
  64424. /**
  64425. * Creates an effect renderer
  64426. * @param engine the engine to use for rendering
  64427. * @param options defines the options of the effect renderer
  64428. */
  64429. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  64430. /**
  64431. * Sets the current viewport in normalized coordinates 0-1
  64432. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  64433. */
  64434. setViewport(viewport?: Viewport): void;
  64435. /**
  64436. * Binds the embedded attributes buffer to the effect.
  64437. * @param effect Defines the effect to bind the attributes for
  64438. */
  64439. bindBuffers(effect: Effect): void;
  64440. /**
  64441. * Sets the current effect wrapper to use during draw.
  64442. * The effect needs to be ready before calling this api.
  64443. * This also sets the default full screen position attribute.
  64444. * @param effectWrapper Defines the effect to draw with
  64445. */
  64446. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  64447. /**
  64448. * Restores engine states
  64449. */
  64450. restoreStates(): void;
  64451. /**
  64452. * Draws a full screen quad.
  64453. */
  64454. draw(): void;
  64455. private isRenderTargetTexture;
  64456. /**
  64457. * renders one or more effects to a specified texture
  64458. * @param effectWrapper the effect to renderer
  64459. * @param outputTexture texture to draw to, if null it will render to the screen.
  64460. */
  64461. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  64462. /**
  64463. * Disposes of the effect renderer
  64464. */
  64465. dispose(): void;
  64466. }
  64467. /**
  64468. * Options to create an EffectWrapper
  64469. */
  64470. interface EffectWrapperCreationOptions {
  64471. /**
  64472. * Engine to use to create the effect
  64473. */
  64474. engine: ThinEngine;
  64475. /**
  64476. * Fragment shader for the effect
  64477. */
  64478. fragmentShader: string;
  64479. /**
  64480. * Use the shader store instead of direct source code
  64481. */
  64482. useShaderStore?: boolean;
  64483. /**
  64484. * Vertex shader for the effect
  64485. */
  64486. vertexShader?: string;
  64487. /**
  64488. * Attributes to use in the shader
  64489. */
  64490. attributeNames?: Array<string>;
  64491. /**
  64492. * Uniforms to use in the shader
  64493. */
  64494. uniformNames?: Array<string>;
  64495. /**
  64496. * Texture sampler names to use in the shader
  64497. */
  64498. samplerNames?: Array<string>;
  64499. /**
  64500. * Defines to use in the shader
  64501. */
  64502. defines?: Array<string>;
  64503. /**
  64504. * Callback when effect is compiled
  64505. */
  64506. onCompiled?: Nullable<(effect: Effect) => void>;
  64507. /**
  64508. * The friendly name of the effect displayed in Spector.
  64509. */
  64510. name?: string;
  64511. }
  64512. /**
  64513. * Wraps an effect to be used for rendering
  64514. */
  64515. export class EffectWrapper {
  64516. /**
  64517. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  64518. */
  64519. onApplyObservable: Observable<{}>;
  64520. /**
  64521. * The underlying effect
  64522. */
  64523. effect: Effect;
  64524. /**
  64525. * Creates an effect to be renderer
  64526. * @param creationOptions options to create the effect
  64527. */
  64528. constructor(creationOptions: EffectWrapperCreationOptions);
  64529. /**
  64530. * Disposes of the effect wrapper
  64531. */
  64532. dispose(): void;
  64533. }
  64534. }
  64535. declare module BABYLON {
  64536. /** @hidden */
  64537. export var hdrFilteringVertexShader: {
  64538. name: string;
  64539. shader: string;
  64540. };
  64541. }
  64542. declare module BABYLON {
  64543. /** @hidden */
  64544. export var hdrFilteringPixelShader: {
  64545. name: string;
  64546. shader: string;
  64547. };
  64548. }
  64549. declare module BABYLON {
  64550. /**
  64551. * Options for texture filtering
  64552. */
  64553. interface IHDRFilteringOptions {
  64554. /**
  64555. * Scales pixel intensity for the input HDR map.
  64556. */
  64557. hdrScale?: number;
  64558. /**
  64559. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  64560. */
  64561. quality?: number;
  64562. }
  64563. /**
  64564. * Filters HDR maps to get correct renderings of PBR reflections
  64565. */
  64566. export class HDRFiltering {
  64567. private _engine;
  64568. private _effectRenderer;
  64569. private _effectWrapper;
  64570. private _lodGenerationOffset;
  64571. private _lodGenerationScale;
  64572. /**
  64573. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  64574. * you care about baking speed.
  64575. */
  64576. quality: number;
  64577. /**
  64578. * Scales pixel intensity for the input HDR map.
  64579. */
  64580. hdrScale: number;
  64581. /**
  64582. * Instantiates HDR filter for reflection maps
  64583. *
  64584. * @param engine Thin engine
  64585. * @param options Options
  64586. */
  64587. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  64588. private _createRenderTarget;
  64589. private _prefilterInternal;
  64590. private _createEffect;
  64591. /**
  64592. * Get a value indicating if the filter is ready to be used
  64593. * @param texture Texture to filter
  64594. * @returns true if the filter is ready
  64595. */
  64596. isReady(texture: BaseTexture): boolean;
  64597. /**
  64598. * Prefilters a cube texture to have mipmap levels representing roughness values.
  64599. * Prefiltering will be invoked at the end of next rendering pass.
  64600. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  64601. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  64602. * @param texture Texture to filter
  64603. * @param onFinished Callback when filtering is done
  64604. * @return Promise called when prefiltering is done
  64605. */
  64606. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
  64607. }
  64608. }
  64609. declare module BABYLON {
  64610. /**
  64611. * This represents a texture coming from an HDR input.
  64612. *
  64613. * The only supported format is currently panorama picture stored in RGBE format.
  64614. * Example of such files can be found on HDRLib: http://hdrlib.com/
  64615. */
  64616. export class HDRCubeTexture extends BaseTexture {
  64617. private static _facesMapping;
  64618. private _generateHarmonics;
  64619. private _noMipmap;
  64620. private _prefilterOnLoad;
  64621. private _textureMatrix;
  64622. private _size;
  64623. private _onLoad;
  64624. private _onError;
  64625. /**
  64626. * The texture URL.
  64627. */
  64628. url: string;
  64629. protected _isBlocking: boolean;
  64630. /**
  64631. * Sets wether or not the texture is blocking during loading.
  64632. */
  64633. set isBlocking(value: boolean);
  64634. /**
  64635. * Gets wether or not the texture is blocking during loading.
  64636. */
  64637. get isBlocking(): boolean;
  64638. protected _rotationY: number;
  64639. /**
  64640. * Sets texture matrix rotation angle around Y axis in radians.
  64641. */
  64642. set rotationY(value: number);
  64643. /**
  64644. * Gets texture matrix rotation angle around Y axis radians.
  64645. */
  64646. get rotationY(): number;
  64647. /**
  64648. * Gets or sets the center of the bounding box associated with the cube texture
  64649. * It must define where the camera used to render the texture was set
  64650. */
  64651. boundingBoxPosition: Vector3;
  64652. private _boundingBoxSize;
  64653. /**
  64654. * Gets or sets the size of the bounding box associated with the cube texture
  64655. * When defined, the cubemap will switch to local mode
  64656. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  64657. * @example https://www.babylonjs-playground.com/#RNASML
  64658. */
  64659. set boundingBoxSize(value: Vector3);
  64660. get boundingBoxSize(): Vector3;
  64661. /**
  64662. * Instantiates an HDRTexture from the following parameters.
  64663. *
  64664. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  64665. * @param sceneOrEngine The scene or engine the texture will be used in
  64666. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64667. * @param noMipmap Forces to not generate the mipmap if true
  64668. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  64669. * @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)
  64670. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  64671. */
  64672. 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>);
  64673. /**
  64674. * Get the current class name of the texture useful for serialization or dynamic coding.
  64675. * @returns "HDRCubeTexture"
  64676. */
  64677. getClassName(): string;
  64678. /**
  64679. * Occurs when the file is raw .hdr file.
  64680. */
  64681. private loadTexture;
  64682. clone(): HDRCubeTexture;
  64683. delayLoad(): void;
  64684. /**
  64685. * Get the texture reflection matrix used to rotate/transform the reflection.
  64686. * @returns the reflection matrix
  64687. */
  64688. getReflectionTextureMatrix(): Matrix;
  64689. /**
  64690. * Set the texture reflection matrix used to rotate/transform the reflection.
  64691. * @param value Define the reflection matrix to set
  64692. */
  64693. setReflectionTextureMatrix(value: Matrix): void;
  64694. /**
  64695. * Parses a JSON representation of an HDR Texture in order to create the texture
  64696. * @param parsedTexture Define the JSON representation
  64697. * @param scene Define the scene the texture should be created in
  64698. * @param rootUrl Define the root url in case we need to load relative dependencies
  64699. * @returns the newly created texture after parsing
  64700. */
  64701. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  64702. serialize(): any;
  64703. }
  64704. }
  64705. declare module BABYLON {
  64706. /**
  64707. * Class used to control physics engine
  64708. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64709. */
  64710. export class PhysicsEngine implements IPhysicsEngine {
  64711. private _physicsPlugin;
  64712. /**
  64713. * Global value used to control the smallest number supported by the simulation
  64714. */
  64715. static Epsilon: number;
  64716. private _impostors;
  64717. private _joints;
  64718. private _subTimeStep;
  64719. /**
  64720. * Gets the gravity vector used by the simulation
  64721. */
  64722. gravity: Vector3;
  64723. /**
  64724. * Factory used to create the default physics plugin.
  64725. * @returns The default physics plugin
  64726. */
  64727. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  64728. /**
  64729. * Creates a new Physics Engine
  64730. * @param gravity defines the gravity vector used by the simulation
  64731. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  64732. */
  64733. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  64734. /**
  64735. * Sets the gravity vector used by the simulation
  64736. * @param gravity defines the gravity vector to use
  64737. */
  64738. setGravity(gravity: Vector3): void;
  64739. /**
  64740. * Set the time step of the physics engine.
  64741. * Default is 1/60.
  64742. * To slow it down, enter 1/600 for example.
  64743. * To speed it up, 1/30
  64744. * @param newTimeStep defines the new timestep to apply to this world.
  64745. */
  64746. setTimeStep(newTimeStep?: number): void;
  64747. /**
  64748. * Get the time step of the physics engine.
  64749. * @returns the current time step
  64750. */
  64751. getTimeStep(): number;
  64752. /**
  64753. * Set the sub time step of the physics engine.
  64754. * Default is 0 meaning there is no sub steps
  64755. * To increase physics resolution precision, set a small value (like 1 ms)
  64756. * @param subTimeStep defines the new sub timestep used for physics resolution.
  64757. */
  64758. setSubTimeStep(subTimeStep?: number): void;
  64759. /**
  64760. * Get the sub time step of the physics engine.
  64761. * @returns the current sub time step
  64762. */
  64763. getSubTimeStep(): number;
  64764. /**
  64765. * Release all resources
  64766. */
  64767. dispose(): void;
  64768. /**
  64769. * Gets the name of the current physics plugin
  64770. * @returns the name of the plugin
  64771. */
  64772. getPhysicsPluginName(): string;
  64773. /**
  64774. * Adding a new impostor for the impostor tracking.
  64775. * This will be done by the impostor itself.
  64776. * @param impostor the impostor to add
  64777. */
  64778. addImpostor(impostor: PhysicsImpostor): void;
  64779. /**
  64780. * Remove an impostor from the engine.
  64781. * This impostor and its mesh will not longer be updated by the physics engine.
  64782. * @param impostor the impostor to remove
  64783. */
  64784. removeImpostor(impostor: PhysicsImpostor): void;
  64785. /**
  64786. * Add a joint to the physics engine
  64787. * @param mainImpostor defines the main impostor to which the joint is added.
  64788. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  64789. * @param joint defines the joint that will connect both impostors.
  64790. */
  64791. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64792. /**
  64793. * Removes a joint from the simulation
  64794. * @param mainImpostor defines the impostor used with the joint
  64795. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  64796. * @param joint defines the joint to remove
  64797. */
  64798. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64799. /**
  64800. * Called by the scene. No need to call it.
  64801. * @param delta defines the timespam between frames
  64802. */
  64803. _step(delta: number): void;
  64804. /**
  64805. * Gets the current plugin used to run the simulation
  64806. * @returns current plugin
  64807. */
  64808. getPhysicsPlugin(): IPhysicsEnginePlugin;
  64809. /**
  64810. * Gets the list of physic impostors
  64811. * @returns an array of PhysicsImpostor
  64812. */
  64813. getImpostors(): Array<PhysicsImpostor>;
  64814. /**
  64815. * Gets the impostor for a physics enabled object
  64816. * @param object defines the object impersonated by the impostor
  64817. * @returns the PhysicsImpostor or null if not found
  64818. */
  64819. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  64820. /**
  64821. * Gets the impostor for a physics body object
  64822. * @param body defines physics body used by the impostor
  64823. * @returns the PhysicsImpostor or null if not found
  64824. */
  64825. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  64826. /**
  64827. * Does a raycast in the physics world
  64828. * @param from when should the ray start?
  64829. * @param to when should the ray end?
  64830. * @returns PhysicsRaycastResult
  64831. */
  64832. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64833. }
  64834. }
  64835. declare module BABYLON {
  64836. /** @hidden */
  64837. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  64838. private _useDeltaForWorldStep;
  64839. world: any;
  64840. name: string;
  64841. private _physicsMaterials;
  64842. private _fixedTimeStep;
  64843. private _cannonRaycastResult;
  64844. private _raycastResult;
  64845. private _physicsBodysToRemoveAfterStep;
  64846. private _firstFrame;
  64847. BJSCANNON: any;
  64848. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  64849. setGravity(gravity: Vector3): void;
  64850. setTimeStep(timeStep: number): void;
  64851. getTimeStep(): number;
  64852. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64853. private _removeMarkedPhysicsBodiesFromWorld;
  64854. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64855. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64856. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64857. private _processChildMeshes;
  64858. removePhysicsBody(impostor: PhysicsImpostor): void;
  64859. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64860. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64861. private _addMaterial;
  64862. private _checkWithEpsilon;
  64863. private _createShape;
  64864. private _createHeightmap;
  64865. private _minus90X;
  64866. private _plus90X;
  64867. private _tmpPosition;
  64868. private _tmpDeltaPosition;
  64869. private _tmpUnityRotation;
  64870. private _updatePhysicsBodyTransformation;
  64871. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64872. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64873. isSupported(): boolean;
  64874. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64875. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64876. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64877. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64878. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64879. getBodyMass(impostor: PhysicsImpostor): number;
  64880. getBodyFriction(impostor: PhysicsImpostor): number;
  64881. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64882. getBodyRestitution(impostor: PhysicsImpostor): number;
  64883. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64884. sleepBody(impostor: PhysicsImpostor): void;
  64885. wakeUpBody(impostor: PhysicsImpostor): void;
  64886. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  64887. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64888. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64889. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64890. getRadius(impostor: PhysicsImpostor): number;
  64891. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64892. dispose(): void;
  64893. private _extendNamespace;
  64894. /**
  64895. * Does a raycast in the physics world
  64896. * @param from when should the ray start?
  64897. * @param to when should the ray end?
  64898. * @returns PhysicsRaycastResult
  64899. */
  64900. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64901. }
  64902. }
  64903. declare module BABYLON {
  64904. /** @hidden */
  64905. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  64906. private _useDeltaForWorldStep;
  64907. world: any;
  64908. name: string;
  64909. BJSOIMO: any;
  64910. private _raycastResult;
  64911. private _fixedTimeStep;
  64912. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  64913. setGravity(gravity: Vector3): void;
  64914. setTimeStep(timeStep: number): void;
  64915. getTimeStep(): number;
  64916. private _tmpImpostorsArray;
  64917. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64918. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64919. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64920. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64921. private _tmpPositionVector;
  64922. removePhysicsBody(impostor: PhysicsImpostor): void;
  64923. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64924. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64925. isSupported(): boolean;
  64926. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64927. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64928. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64929. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64930. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64931. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64932. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64933. getBodyMass(impostor: PhysicsImpostor): number;
  64934. getBodyFriction(impostor: PhysicsImpostor): number;
  64935. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64936. getBodyRestitution(impostor: PhysicsImpostor): number;
  64937. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64938. sleepBody(impostor: PhysicsImpostor): void;
  64939. wakeUpBody(impostor: PhysicsImpostor): void;
  64940. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64941. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  64942. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  64943. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64944. getRadius(impostor: PhysicsImpostor): number;
  64945. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64946. dispose(): void;
  64947. /**
  64948. * Does a raycast in the physics world
  64949. * @param from when should the ray start?
  64950. * @param to when should the ray end?
  64951. * @returns PhysicsRaycastResult
  64952. */
  64953. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64954. }
  64955. }
  64956. declare module BABYLON {
  64957. /**
  64958. * AmmoJS Physics plugin
  64959. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64960. * @see https://github.com/kripken/ammo.js/
  64961. */
  64962. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  64963. private _useDeltaForWorldStep;
  64964. /**
  64965. * Reference to the Ammo library
  64966. */
  64967. bjsAMMO: any;
  64968. /**
  64969. * Created ammoJS world which physics bodies are added to
  64970. */
  64971. world: any;
  64972. /**
  64973. * Name of the plugin
  64974. */
  64975. name: string;
  64976. private _timeStep;
  64977. private _fixedTimeStep;
  64978. private _maxSteps;
  64979. private _tmpQuaternion;
  64980. private _tmpAmmoTransform;
  64981. private _tmpAmmoQuaternion;
  64982. private _tmpAmmoConcreteContactResultCallback;
  64983. private _collisionConfiguration;
  64984. private _dispatcher;
  64985. private _overlappingPairCache;
  64986. private _solver;
  64987. private _softBodySolver;
  64988. private _tmpAmmoVectorA;
  64989. private _tmpAmmoVectorB;
  64990. private _tmpAmmoVectorC;
  64991. private _tmpAmmoVectorD;
  64992. private _tmpContactCallbackResult;
  64993. private _tmpAmmoVectorRCA;
  64994. private _tmpAmmoVectorRCB;
  64995. private _raycastResult;
  64996. private _tmpContactPoint;
  64997. private static readonly DISABLE_COLLISION_FLAG;
  64998. private static readonly KINEMATIC_FLAG;
  64999. private static readonly DISABLE_DEACTIVATION_FLAG;
  65000. /**
  65001. * Initializes the ammoJS plugin
  65002. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  65003. * @param ammoInjection can be used to inject your own ammo reference
  65004. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  65005. */
  65006. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  65007. /**
  65008. * Sets the gravity of the physics world (m/(s^2))
  65009. * @param gravity Gravity to set
  65010. */
  65011. setGravity(gravity: Vector3): void;
  65012. /**
  65013. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  65014. * @param timeStep timestep to use in seconds
  65015. */
  65016. setTimeStep(timeStep: number): void;
  65017. /**
  65018. * 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)
  65019. * @param fixedTimeStep fixedTimeStep to use in seconds
  65020. */
  65021. setFixedTimeStep(fixedTimeStep: number): void;
  65022. /**
  65023. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  65024. * @param maxSteps the maximum number of steps by the physics engine per frame
  65025. */
  65026. setMaxSteps(maxSteps: number): void;
  65027. /**
  65028. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  65029. * @returns the current timestep in seconds
  65030. */
  65031. getTimeStep(): number;
  65032. /**
  65033. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  65034. */
  65035. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  65036. private _isImpostorInContact;
  65037. private _isImpostorPairInContact;
  65038. private _stepSimulation;
  65039. /**
  65040. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  65041. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  65042. * After the step the babylon meshes are set to the position of the physics imposters
  65043. * @param delta amount of time to step forward
  65044. * @param impostors array of imposters to update before/after the step
  65045. */
  65046. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65047. /**
  65048. * Update babylon mesh to match physics world object
  65049. * @param impostor imposter to match
  65050. */
  65051. private _afterSoftStep;
  65052. /**
  65053. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65054. * @param impostor imposter to match
  65055. */
  65056. private _ropeStep;
  65057. /**
  65058. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65059. * @param impostor imposter to match
  65060. */
  65061. private _softbodyOrClothStep;
  65062. private _tmpMatrix;
  65063. /**
  65064. * Applies an impulse on the imposter
  65065. * @param impostor imposter to apply impulse to
  65066. * @param force amount of force to be applied to the imposter
  65067. * @param contactPoint the location to apply the impulse on the imposter
  65068. */
  65069. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65070. /**
  65071. * Applies a force on the imposter
  65072. * @param impostor imposter to apply force
  65073. * @param force amount of force to be applied to the imposter
  65074. * @param contactPoint the location to apply the force on the imposter
  65075. */
  65076. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65077. /**
  65078. * Creates a physics body using the plugin
  65079. * @param impostor the imposter to create the physics body on
  65080. */
  65081. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65082. /**
  65083. * Removes the physics body from the imposter and disposes of the body's memory
  65084. * @param impostor imposter to remove the physics body from
  65085. */
  65086. removePhysicsBody(impostor: PhysicsImpostor): void;
  65087. /**
  65088. * Generates a joint
  65089. * @param impostorJoint the imposter joint to create the joint with
  65090. */
  65091. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65092. /**
  65093. * Removes a joint
  65094. * @param impostorJoint the imposter joint to remove the joint from
  65095. */
  65096. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65097. private _addMeshVerts;
  65098. /**
  65099. * Initialise the soft body vertices to match its object's (mesh) vertices
  65100. * Softbody vertices (nodes) are in world space and to match this
  65101. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  65102. * @param impostor to create the softbody for
  65103. */
  65104. private _softVertexData;
  65105. /**
  65106. * Create an impostor's soft body
  65107. * @param impostor to create the softbody for
  65108. */
  65109. private _createSoftbody;
  65110. /**
  65111. * Create cloth for an impostor
  65112. * @param impostor to create the softbody for
  65113. */
  65114. private _createCloth;
  65115. /**
  65116. * Create rope for an impostor
  65117. * @param impostor to create the softbody for
  65118. */
  65119. private _createRope;
  65120. /**
  65121. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  65122. * @param impostor to create the custom physics shape for
  65123. */
  65124. private _createCustom;
  65125. private _addHullVerts;
  65126. private _createShape;
  65127. /**
  65128. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  65129. * @param impostor imposter containing the physics body and babylon object
  65130. */
  65131. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65132. /**
  65133. * Sets the babylon object's position/rotation from the physics body's position/rotation
  65134. * @param impostor imposter containing the physics body and babylon object
  65135. * @param newPosition new position
  65136. * @param newRotation new rotation
  65137. */
  65138. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65139. /**
  65140. * If this plugin is supported
  65141. * @returns true if its supported
  65142. */
  65143. isSupported(): boolean;
  65144. /**
  65145. * Sets the linear velocity of the physics body
  65146. * @param impostor imposter to set the velocity on
  65147. * @param velocity velocity to set
  65148. */
  65149. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65150. /**
  65151. * Sets the angular velocity of the physics body
  65152. * @param impostor imposter to set the velocity on
  65153. * @param velocity velocity to set
  65154. */
  65155. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65156. /**
  65157. * gets the linear velocity
  65158. * @param impostor imposter to get linear velocity from
  65159. * @returns linear velocity
  65160. */
  65161. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65162. /**
  65163. * gets the angular velocity
  65164. * @param impostor imposter to get angular velocity from
  65165. * @returns angular velocity
  65166. */
  65167. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65168. /**
  65169. * Sets the mass of physics body
  65170. * @param impostor imposter to set the mass on
  65171. * @param mass mass to set
  65172. */
  65173. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65174. /**
  65175. * Gets the mass of the physics body
  65176. * @param impostor imposter to get the mass from
  65177. * @returns mass
  65178. */
  65179. getBodyMass(impostor: PhysicsImpostor): number;
  65180. /**
  65181. * Gets friction of the impostor
  65182. * @param impostor impostor to get friction from
  65183. * @returns friction value
  65184. */
  65185. getBodyFriction(impostor: PhysicsImpostor): number;
  65186. /**
  65187. * Sets friction of the impostor
  65188. * @param impostor impostor to set friction on
  65189. * @param friction friction value
  65190. */
  65191. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65192. /**
  65193. * Gets restitution of the impostor
  65194. * @param impostor impostor to get restitution from
  65195. * @returns restitution value
  65196. */
  65197. getBodyRestitution(impostor: PhysicsImpostor): number;
  65198. /**
  65199. * Sets resitution of the impostor
  65200. * @param impostor impostor to set resitution on
  65201. * @param restitution resitution value
  65202. */
  65203. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65204. /**
  65205. * Gets pressure inside the impostor
  65206. * @param impostor impostor to get pressure from
  65207. * @returns pressure value
  65208. */
  65209. getBodyPressure(impostor: PhysicsImpostor): number;
  65210. /**
  65211. * Sets pressure inside a soft body impostor
  65212. * Cloth and rope must remain 0 pressure
  65213. * @param impostor impostor to set pressure on
  65214. * @param pressure pressure value
  65215. */
  65216. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  65217. /**
  65218. * Gets stiffness of the impostor
  65219. * @param impostor impostor to get stiffness from
  65220. * @returns pressure value
  65221. */
  65222. getBodyStiffness(impostor: PhysicsImpostor): number;
  65223. /**
  65224. * Sets stiffness of the impostor
  65225. * @param impostor impostor to set stiffness on
  65226. * @param stiffness stiffness value from 0 to 1
  65227. */
  65228. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  65229. /**
  65230. * Gets velocityIterations of the impostor
  65231. * @param impostor impostor to get velocity iterations from
  65232. * @returns velocityIterations value
  65233. */
  65234. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  65235. /**
  65236. * Sets velocityIterations of the impostor
  65237. * @param impostor impostor to set velocity iterations on
  65238. * @param velocityIterations velocityIterations value
  65239. */
  65240. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  65241. /**
  65242. * Gets positionIterations of the impostor
  65243. * @param impostor impostor to get position iterations from
  65244. * @returns positionIterations value
  65245. */
  65246. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  65247. /**
  65248. * Sets positionIterations of the impostor
  65249. * @param impostor impostor to set position on
  65250. * @param positionIterations positionIterations value
  65251. */
  65252. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  65253. /**
  65254. * Append an anchor to a cloth object
  65255. * @param impostor is the cloth impostor to add anchor to
  65256. * @param otherImpostor is the rigid impostor to anchor to
  65257. * @param width ratio across width from 0 to 1
  65258. * @param height ratio up height from 0 to 1
  65259. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  65260. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65261. */
  65262. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65263. /**
  65264. * Append an hook to a rope object
  65265. * @param impostor is the rope impostor to add hook to
  65266. * @param otherImpostor is the rigid impostor to hook to
  65267. * @param length ratio along the rope from 0 to 1
  65268. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  65269. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65270. */
  65271. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65272. /**
  65273. * Sleeps the physics body and stops it from being active
  65274. * @param impostor impostor to sleep
  65275. */
  65276. sleepBody(impostor: PhysicsImpostor): void;
  65277. /**
  65278. * Activates the physics body
  65279. * @param impostor impostor to activate
  65280. */
  65281. wakeUpBody(impostor: PhysicsImpostor): void;
  65282. /**
  65283. * Updates the distance parameters of the joint
  65284. * @param joint joint to update
  65285. * @param maxDistance maximum distance of the joint
  65286. * @param minDistance minimum distance of the joint
  65287. */
  65288. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65289. /**
  65290. * Sets a motor on the joint
  65291. * @param joint joint to set motor on
  65292. * @param speed speed of the motor
  65293. * @param maxForce maximum force of the motor
  65294. * @param motorIndex index of the motor
  65295. */
  65296. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65297. /**
  65298. * Sets the motors limit
  65299. * @param joint joint to set limit on
  65300. * @param upperLimit upper limit
  65301. * @param lowerLimit lower limit
  65302. */
  65303. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65304. /**
  65305. * Syncs the position and rotation of a mesh with the impostor
  65306. * @param mesh mesh to sync
  65307. * @param impostor impostor to update the mesh with
  65308. */
  65309. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65310. /**
  65311. * Gets the radius of the impostor
  65312. * @param impostor impostor to get radius from
  65313. * @returns the radius
  65314. */
  65315. getRadius(impostor: PhysicsImpostor): number;
  65316. /**
  65317. * Gets the box size of the impostor
  65318. * @param impostor impostor to get box size from
  65319. * @param result the resulting box size
  65320. */
  65321. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65322. /**
  65323. * Disposes of the impostor
  65324. */
  65325. dispose(): void;
  65326. /**
  65327. * Does a raycast in the physics world
  65328. * @param from when should the ray start?
  65329. * @param to when should the ray end?
  65330. * @returns PhysicsRaycastResult
  65331. */
  65332. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65333. }
  65334. }
  65335. declare module BABYLON {
  65336. interface AbstractScene {
  65337. /**
  65338. * The list of reflection probes added to the scene
  65339. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65340. */
  65341. reflectionProbes: Array<ReflectionProbe>;
  65342. /**
  65343. * Removes the given reflection probe from this scene.
  65344. * @param toRemove The reflection probe to remove
  65345. * @returns The index of the removed reflection probe
  65346. */
  65347. removeReflectionProbe(toRemove: ReflectionProbe): number;
  65348. /**
  65349. * Adds the given reflection probe to this scene.
  65350. * @param newReflectionProbe The reflection probe to add
  65351. */
  65352. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  65353. }
  65354. /**
  65355. * Class used to generate realtime reflection / refraction cube textures
  65356. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65357. */
  65358. export class ReflectionProbe {
  65359. /** defines the name of the probe */
  65360. name: string;
  65361. private _scene;
  65362. private _renderTargetTexture;
  65363. private _projectionMatrix;
  65364. private _viewMatrix;
  65365. private _target;
  65366. private _add;
  65367. private _attachedMesh;
  65368. private _invertYAxis;
  65369. /** Gets or sets probe position (center of the cube map) */
  65370. position: Vector3;
  65371. /**
  65372. * Creates a new reflection probe
  65373. * @param name defines the name of the probe
  65374. * @param size defines the texture resolution (for each face)
  65375. * @param scene defines the hosting scene
  65376. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  65377. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  65378. */
  65379. constructor(
  65380. /** defines the name of the probe */
  65381. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  65382. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  65383. get samples(): number;
  65384. set samples(value: number);
  65385. /** Gets or sets the refresh rate to use (on every frame by default) */
  65386. get refreshRate(): number;
  65387. set refreshRate(value: number);
  65388. /**
  65389. * Gets the hosting scene
  65390. * @returns a Scene
  65391. */
  65392. getScene(): Scene;
  65393. /** Gets the internal CubeTexture used to render to */
  65394. get cubeTexture(): RenderTargetTexture;
  65395. /** Gets the list of meshes to render */
  65396. get renderList(): Nullable<AbstractMesh[]>;
  65397. /**
  65398. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  65399. * @param mesh defines the mesh to attach to
  65400. */
  65401. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  65402. /**
  65403. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  65404. * @param renderingGroupId The rendering group id corresponding to its index
  65405. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  65406. */
  65407. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  65408. /**
  65409. * Clean all associated resources
  65410. */
  65411. dispose(): void;
  65412. /**
  65413. * Converts the reflection probe information to a readable string for debug purpose.
  65414. * @param fullDetails Supports for multiple levels of logging within scene loading
  65415. * @returns the human readable reflection probe info
  65416. */
  65417. toString(fullDetails?: boolean): string;
  65418. /**
  65419. * Get the class name of the relfection probe.
  65420. * @returns "ReflectionProbe"
  65421. */
  65422. getClassName(): string;
  65423. /**
  65424. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  65425. * @returns The JSON representation of the texture
  65426. */
  65427. serialize(): any;
  65428. /**
  65429. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  65430. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  65431. * @param scene Define the scene the parsed reflection probe should be instantiated in
  65432. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  65433. * @returns The parsed reflection probe if successful
  65434. */
  65435. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  65436. }
  65437. }
  65438. declare module BABYLON {
  65439. /** @hidden */
  65440. export var _BabylonLoaderRegistered: boolean;
  65441. /**
  65442. * Helps setting up some configuration for the babylon file loader.
  65443. */
  65444. export class BabylonFileLoaderConfiguration {
  65445. /**
  65446. * The loader does not allow injecting custom physix engine into the plugins.
  65447. * Unfortunately in ES6, we need to manually inject them into the plugin.
  65448. * So you could set this variable to your engine import to make it work.
  65449. */
  65450. static LoaderInjectedPhysicsEngine: any;
  65451. }
  65452. }
  65453. declare module BABYLON {
  65454. /**
  65455. * A material to use for fast depth-only rendering.
  65456. */
  65457. export class OcclusionMaterial extends ShaderMaterial {
  65458. constructor(name: string, scene: Scene);
  65459. }
  65460. }
  65461. declare module BABYLON {
  65462. /**
  65463. * The Physically based simple base material of BJS.
  65464. *
  65465. * This enables better naming and convention enforcements on top of the pbrMaterial.
  65466. * It is used as the base class for both the specGloss and metalRough conventions.
  65467. */
  65468. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  65469. /**
  65470. * Number of Simultaneous lights allowed on the material.
  65471. */
  65472. maxSimultaneousLights: number;
  65473. /**
  65474. * If sets to true, disables all the lights affecting the material.
  65475. */
  65476. disableLighting: boolean;
  65477. /**
  65478. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  65479. */
  65480. environmentTexture: BaseTexture;
  65481. /**
  65482. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  65483. */
  65484. invertNormalMapX: boolean;
  65485. /**
  65486. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  65487. */
  65488. invertNormalMapY: boolean;
  65489. /**
  65490. * Normal map used in the model.
  65491. */
  65492. normalTexture: BaseTexture;
  65493. /**
  65494. * Emissivie color used to self-illuminate the model.
  65495. */
  65496. emissiveColor: Color3;
  65497. /**
  65498. * Emissivie texture used to self-illuminate the model.
  65499. */
  65500. emissiveTexture: BaseTexture;
  65501. /**
  65502. * Occlusion Channel Strenght.
  65503. */
  65504. occlusionStrength: number;
  65505. /**
  65506. * Occlusion Texture of the material (adding extra occlusion effects).
  65507. */
  65508. occlusionTexture: BaseTexture;
  65509. /**
  65510. * Defines the alpha limits in alpha test mode.
  65511. */
  65512. alphaCutOff: number;
  65513. /**
  65514. * Gets the current double sided mode.
  65515. */
  65516. get doubleSided(): boolean;
  65517. /**
  65518. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  65519. */
  65520. set doubleSided(value: boolean);
  65521. /**
  65522. * Stores the pre-calculated light information of a mesh in a texture.
  65523. */
  65524. lightmapTexture: BaseTexture;
  65525. /**
  65526. * If true, the light map contains occlusion information instead of lighting info.
  65527. */
  65528. useLightmapAsShadowmap: boolean;
  65529. /**
  65530. * Instantiates a new PBRMaterial instance.
  65531. *
  65532. * @param name The material name
  65533. * @param scene The scene the material will be use in.
  65534. */
  65535. constructor(name: string, scene: Scene);
  65536. getClassName(): string;
  65537. }
  65538. }
  65539. declare module BABYLON {
  65540. /**
  65541. * The PBR material of BJS following the metal roughness convention.
  65542. *
  65543. * This fits to the PBR convention in the GLTF definition:
  65544. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  65545. */
  65546. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  65547. /**
  65548. * The base color has two different interpretations depending on the value of metalness.
  65549. * When the material is a metal, the base color is the specific measured reflectance value
  65550. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  65551. * of the material.
  65552. */
  65553. baseColor: Color3;
  65554. /**
  65555. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  65556. * well as opacity information in the alpha channel.
  65557. */
  65558. baseTexture: BaseTexture;
  65559. /**
  65560. * Specifies the metallic scalar value of the material.
  65561. * Can also be used to scale the metalness values of the metallic texture.
  65562. */
  65563. metallic: number;
  65564. /**
  65565. * Specifies the roughness scalar value of the material.
  65566. * Can also be used to scale the roughness values of the metallic texture.
  65567. */
  65568. roughness: number;
  65569. /**
  65570. * Texture containing both the metallic value in the B channel and the
  65571. * roughness value in the G channel to keep better precision.
  65572. */
  65573. metallicRoughnessTexture: BaseTexture;
  65574. /**
  65575. * Instantiates a new PBRMetalRoughnessMaterial instance.
  65576. *
  65577. * @param name The material name
  65578. * @param scene The scene the material will be use in.
  65579. */
  65580. constructor(name: string, scene: Scene);
  65581. /**
  65582. * Return the currrent class name of the material.
  65583. */
  65584. getClassName(): string;
  65585. /**
  65586. * Makes a duplicate of the current material.
  65587. * @param name - name to use for the new material.
  65588. */
  65589. clone(name: string): PBRMetallicRoughnessMaterial;
  65590. /**
  65591. * Serialize the material to a parsable JSON object.
  65592. */
  65593. serialize(): any;
  65594. /**
  65595. * Parses a JSON object correponding to the serialize function.
  65596. */
  65597. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  65598. }
  65599. }
  65600. declare module BABYLON {
  65601. /**
  65602. * The PBR material of BJS following the specular glossiness convention.
  65603. *
  65604. * This fits to the PBR convention in the GLTF definition:
  65605. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  65606. */
  65607. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  65608. /**
  65609. * Specifies the diffuse color of the material.
  65610. */
  65611. diffuseColor: Color3;
  65612. /**
  65613. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  65614. * channel.
  65615. */
  65616. diffuseTexture: BaseTexture;
  65617. /**
  65618. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  65619. */
  65620. specularColor: Color3;
  65621. /**
  65622. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  65623. */
  65624. glossiness: number;
  65625. /**
  65626. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  65627. */
  65628. specularGlossinessTexture: BaseTexture;
  65629. /**
  65630. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  65631. */
  65632. get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
  65633. /**
  65634. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  65635. *
  65636. * @param name The material name
  65637. * @param scene The scene the material will be use in.
  65638. */
  65639. constructor(name: string, scene: Scene);
  65640. /**
  65641. * Return the currrent class name of the material.
  65642. */
  65643. getClassName(): string;
  65644. /**
  65645. * Makes a duplicate of the current material.
  65646. * @param name - name to use for the new material.
  65647. */
  65648. clone(name: string): PBRSpecularGlossinessMaterial;
  65649. /**
  65650. * Serialize the material to a parsable JSON object.
  65651. */
  65652. serialize(): any;
  65653. /**
  65654. * Parses a JSON object correponding to the serialize function.
  65655. */
  65656. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  65657. }
  65658. }
  65659. declare module BABYLON {
  65660. /**
  65661. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  65662. * It can help converting any input color in a desired output one. This can then be used to create effects
  65663. * from sepia, black and white to sixties or futuristic rendering...
  65664. *
  65665. * The only supported format is currently 3dl.
  65666. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  65667. */
  65668. export class ColorGradingTexture extends BaseTexture {
  65669. /**
  65670. * The texture URL.
  65671. */
  65672. url: string;
  65673. /**
  65674. * Empty line regex stored for GC.
  65675. */
  65676. private static _noneEmptyLineRegex;
  65677. private _textureMatrix;
  65678. private _onLoad;
  65679. /**
  65680. * Instantiates a ColorGradingTexture from the following parameters.
  65681. *
  65682. * @param url The location of the color gradind data (currently only supporting 3dl)
  65683. * @param sceneOrEngine The scene or engine the texture will be used in
  65684. * @param onLoad defines a callback triggered when the texture has been loaded
  65685. */
  65686. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  65687. /**
  65688. * Fires the onload event from the constructor if requested.
  65689. */
  65690. private _triggerOnLoad;
  65691. /**
  65692. * Returns the texture matrix used in most of the material.
  65693. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  65694. */
  65695. getTextureMatrix(): Matrix;
  65696. /**
  65697. * Occurs when the file being loaded is a .3dl LUT file.
  65698. */
  65699. private load3dlTexture;
  65700. /**
  65701. * Starts the loading process of the texture.
  65702. */
  65703. private loadTexture;
  65704. /**
  65705. * Clones the color gradind texture.
  65706. */
  65707. clone(): ColorGradingTexture;
  65708. /**
  65709. * Called during delayed load for textures.
  65710. */
  65711. delayLoad(): void;
  65712. /**
  65713. * Parses a color grading texture serialized by Babylon.
  65714. * @param parsedTexture The texture information being parsedTexture
  65715. * @param scene The scene to load the texture in
  65716. * @param rootUrl The root url of the data assets to load
  65717. * @return A color gradind texture
  65718. */
  65719. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  65720. /**
  65721. * Serializes the LUT texture to json format.
  65722. */
  65723. serialize(): any;
  65724. }
  65725. }
  65726. declare module BABYLON {
  65727. /**
  65728. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  65729. */
  65730. export class EquiRectangularCubeTexture extends BaseTexture {
  65731. /** The six faces of the cube. */
  65732. private static _FacesMapping;
  65733. private _noMipmap;
  65734. private _onLoad;
  65735. private _onError;
  65736. /** The size of the cubemap. */
  65737. private _size;
  65738. /** The buffer of the image. */
  65739. private _buffer;
  65740. /** The width of the input image. */
  65741. private _width;
  65742. /** The height of the input image. */
  65743. private _height;
  65744. /** The URL to the image. */
  65745. url: string;
  65746. /**
  65747. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  65748. * @param url The location of the image
  65749. * @param scene The scene the texture will be used in
  65750. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  65751. * @param noMipmap Forces to not generate the mipmap if true
  65752. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65753. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65754. * @param onLoad — defines a callback called when texture is loaded
  65755. * @param onError — defines a callback called if there is an error
  65756. */
  65757. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  65758. /**
  65759. * Load the image data, by putting the image on a canvas and extracting its buffer.
  65760. */
  65761. private loadImage;
  65762. /**
  65763. * Convert the image buffer into a cubemap and create a CubeTexture.
  65764. */
  65765. private loadTexture;
  65766. /**
  65767. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  65768. * @param buffer The ArrayBuffer that should be converted.
  65769. * @returns The buffer as Float32Array.
  65770. */
  65771. private getFloat32ArrayFromArrayBuffer;
  65772. /**
  65773. * Get the current class name of the texture useful for serialization or dynamic coding.
  65774. * @returns "EquiRectangularCubeTexture"
  65775. */
  65776. getClassName(): string;
  65777. /**
  65778. * Create a clone of the current EquiRectangularCubeTexture and return it.
  65779. * @returns A clone of the current EquiRectangularCubeTexture.
  65780. */
  65781. clone(): EquiRectangularCubeTexture;
  65782. }
  65783. }
  65784. declare module BABYLON {
  65785. /**
  65786. * Defines the options related to the creation of an HtmlElementTexture
  65787. */
  65788. export interface IHtmlElementTextureOptions {
  65789. /**
  65790. * Defines wether mip maps should be created or not.
  65791. */
  65792. generateMipMaps?: boolean;
  65793. /**
  65794. * Defines the sampling mode of the texture.
  65795. */
  65796. samplingMode?: number;
  65797. /**
  65798. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  65799. */
  65800. engine: Nullable<ThinEngine>;
  65801. /**
  65802. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  65803. */
  65804. scene: Nullable<Scene>;
  65805. }
  65806. /**
  65807. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  65808. * To be as efficient as possible depending on your constraints nothing aside the first upload
  65809. * is automatically managed.
  65810. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  65811. * in your application.
  65812. *
  65813. * As the update is not automatic, you need to call them manually.
  65814. */
  65815. export class HtmlElementTexture extends BaseTexture {
  65816. /**
  65817. * The texture URL.
  65818. */
  65819. element: HTMLVideoElement | HTMLCanvasElement;
  65820. private static readonly DefaultOptions;
  65821. private _textureMatrix;
  65822. private _isVideo;
  65823. private _generateMipMaps;
  65824. private _samplingMode;
  65825. /**
  65826. * Instantiates a HtmlElementTexture from the following parameters.
  65827. *
  65828. * @param name Defines the name of the texture
  65829. * @param element Defines the video or canvas the texture is filled with
  65830. * @param options Defines the other none mandatory texture creation options
  65831. */
  65832. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  65833. private _createInternalTexture;
  65834. /**
  65835. * Returns the texture matrix used in most of the material.
  65836. */
  65837. getTextureMatrix(): Matrix;
  65838. /**
  65839. * Updates the content of the texture.
  65840. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  65841. */
  65842. update(invertY?: Nullable<boolean>): void;
  65843. }
  65844. }
  65845. declare module BABYLON {
  65846. /**
  65847. * Based on jsTGALoader - Javascript loader for TGA file
  65848. * By Vincent Thibault
  65849. * @see http://blog.robrowser.com/javascript-tga-loader.html
  65850. */
  65851. export class TGATools {
  65852. private static _TYPE_INDEXED;
  65853. private static _TYPE_RGB;
  65854. private static _TYPE_GREY;
  65855. private static _TYPE_RLE_INDEXED;
  65856. private static _TYPE_RLE_RGB;
  65857. private static _TYPE_RLE_GREY;
  65858. private static _ORIGIN_MASK;
  65859. private static _ORIGIN_SHIFT;
  65860. private static _ORIGIN_BL;
  65861. private static _ORIGIN_BR;
  65862. private static _ORIGIN_UL;
  65863. private static _ORIGIN_UR;
  65864. /**
  65865. * Gets the header of a TGA file
  65866. * @param data defines the TGA data
  65867. * @returns the header
  65868. */
  65869. static GetTGAHeader(data: Uint8Array): any;
  65870. /**
  65871. * Uploads TGA content to a Babylon Texture
  65872. * @hidden
  65873. */
  65874. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  65875. /** @hidden */
  65876. 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;
  65877. /** @hidden */
  65878. 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;
  65879. /** @hidden */
  65880. 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;
  65881. /** @hidden */
  65882. 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;
  65883. /** @hidden */
  65884. 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;
  65885. /** @hidden */
  65886. 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;
  65887. }
  65888. }
  65889. declare module BABYLON {
  65890. /**
  65891. * Implementation of the TGA Texture Loader.
  65892. * @hidden
  65893. */
  65894. export class _TGATextureLoader implements IInternalTextureLoader {
  65895. /**
  65896. * Defines wether the loader supports cascade loading the different faces.
  65897. */
  65898. readonly supportCascades: boolean;
  65899. /**
  65900. * This returns if the loader support the current file information.
  65901. * @param extension defines the file extension of the file being loaded
  65902. * @returns true if the loader can load the specified file
  65903. */
  65904. canLoad(extension: string): boolean;
  65905. /**
  65906. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65907. * @param data contains the texture data
  65908. * @param texture defines the BabylonJS internal texture
  65909. * @param createPolynomials will be true if polynomials have been requested
  65910. * @param onLoad defines the callback to trigger once the texture is ready
  65911. * @param onError defines the callback to trigger in case of error
  65912. */
  65913. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65914. /**
  65915. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65916. * @param data contains the texture data
  65917. * @param texture defines the BabylonJS internal texture
  65918. * @param callback defines the method to call once ready to upload
  65919. */
  65920. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65921. }
  65922. }
  65923. declare module BABYLON {
  65924. /**
  65925. * Info about the .basis files
  65926. */
  65927. class BasisFileInfo {
  65928. /**
  65929. * If the file has alpha
  65930. */
  65931. hasAlpha: boolean;
  65932. /**
  65933. * Info about each image of the basis file
  65934. */
  65935. images: Array<{
  65936. levels: Array<{
  65937. width: number;
  65938. height: number;
  65939. transcodedPixels: ArrayBufferView;
  65940. }>;
  65941. }>;
  65942. }
  65943. /**
  65944. * Result of transcoding a basis file
  65945. */
  65946. class TranscodeResult {
  65947. /**
  65948. * Info about the .basis file
  65949. */
  65950. fileInfo: BasisFileInfo;
  65951. /**
  65952. * Format to use when loading the file
  65953. */
  65954. format: number;
  65955. }
  65956. /**
  65957. * Configuration options for the Basis transcoder
  65958. */
  65959. export class BasisTranscodeConfiguration {
  65960. /**
  65961. * Supported compression formats used to determine the supported output format of the transcoder
  65962. */
  65963. supportedCompressionFormats?: {
  65964. /**
  65965. * etc1 compression format
  65966. */
  65967. etc1?: boolean;
  65968. /**
  65969. * s3tc compression format
  65970. */
  65971. s3tc?: boolean;
  65972. /**
  65973. * pvrtc compression format
  65974. */
  65975. pvrtc?: boolean;
  65976. /**
  65977. * etc2 compression format
  65978. */
  65979. etc2?: boolean;
  65980. };
  65981. /**
  65982. * If mipmap levels should be loaded for transcoded images (Default: true)
  65983. */
  65984. loadMipmapLevels?: boolean;
  65985. /**
  65986. * Index of a single image to load (Default: all images)
  65987. */
  65988. loadSingleImage?: number;
  65989. }
  65990. /**
  65991. * Used to load .Basis files
  65992. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  65993. */
  65994. export class BasisTools {
  65995. private static _IgnoreSupportedFormats;
  65996. /**
  65997. * URL to use when loading the basis transcoder
  65998. */
  65999. static JSModuleURL: string;
  66000. /**
  66001. * URL to use when loading the wasm module for the transcoder
  66002. */
  66003. static WasmModuleURL: string;
  66004. /**
  66005. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  66006. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  66007. * @returns internal format corresponding to the Basis format
  66008. */
  66009. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  66010. private static _WorkerPromise;
  66011. private static _Worker;
  66012. private static _actionId;
  66013. private static _CreateWorkerAsync;
  66014. /**
  66015. * Transcodes a loaded image file to compressed pixel data
  66016. * @param data image data to transcode
  66017. * @param config configuration options for the transcoding
  66018. * @returns a promise resulting in the transcoded image
  66019. */
  66020. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  66021. /**
  66022. * Loads a texture from the transcode result
  66023. * @param texture texture load to
  66024. * @param transcodeResult the result of transcoding the basis file to load from
  66025. */
  66026. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  66027. }
  66028. }
  66029. declare module BABYLON {
  66030. /**
  66031. * Loader for .basis file format
  66032. */
  66033. export class _BasisTextureLoader implements IInternalTextureLoader {
  66034. /**
  66035. * Defines whether the loader supports cascade loading the different faces.
  66036. */
  66037. readonly supportCascades: boolean;
  66038. /**
  66039. * This returns if the loader support the current file information.
  66040. * @param extension defines the file extension of the file being loaded
  66041. * @returns true if the loader can load the specified file
  66042. */
  66043. canLoad(extension: string): boolean;
  66044. /**
  66045. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66046. * @param data contains the texture data
  66047. * @param texture defines the BabylonJS internal texture
  66048. * @param createPolynomials will be true if polynomials have been requested
  66049. * @param onLoad defines the callback to trigger once the texture is ready
  66050. * @param onError defines the callback to trigger in case of error
  66051. */
  66052. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66053. /**
  66054. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66055. * @param data contains the texture data
  66056. * @param texture defines the BabylonJS internal texture
  66057. * @param callback defines the method to call once ready to upload
  66058. */
  66059. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66060. }
  66061. }
  66062. declare module BABYLON {
  66063. /**
  66064. * Defines the basic options interface of a TexturePacker Frame
  66065. */
  66066. export interface ITexturePackerFrame {
  66067. /**
  66068. * The frame ID
  66069. */
  66070. id: number;
  66071. /**
  66072. * The frames Scale
  66073. */
  66074. scale: Vector2;
  66075. /**
  66076. * The Frames offset
  66077. */
  66078. offset: Vector2;
  66079. }
  66080. /**
  66081. * This is a support class for frame Data on texture packer sets.
  66082. */
  66083. export class TexturePackerFrame implements ITexturePackerFrame {
  66084. /**
  66085. * The frame ID
  66086. */
  66087. id: number;
  66088. /**
  66089. * The frames Scale
  66090. */
  66091. scale: Vector2;
  66092. /**
  66093. * The Frames offset
  66094. */
  66095. offset: Vector2;
  66096. /**
  66097. * Initializes a texture package frame.
  66098. * @param id The numerical frame identifier
  66099. * @param scale Scalar Vector2 for UV frame
  66100. * @param offset Vector2 for the frame position in UV units.
  66101. * @returns TexturePackerFrame
  66102. */
  66103. constructor(id: number, scale: Vector2, offset: Vector2);
  66104. }
  66105. }
  66106. declare module BABYLON {
  66107. /**
  66108. * Defines the basic options interface of a TexturePacker
  66109. */
  66110. export interface ITexturePackerOptions {
  66111. /**
  66112. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  66113. */
  66114. map?: string[];
  66115. /**
  66116. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66117. */
  66118. uvsIn?: string;
  66119. /**
  66120. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66121. */
  66122. uvsOut?: string;
  66123. /**
  66124. * number representing the layout style. Defaults to LAYOUT_STRIP
  66125. */
  66126. layout?: number;
  66127. /**
  66128. * number of columns if using custom column count layout(2). This defaults to 4.
  66129. */
  66130. colnum?: number;
  66131. /**
  66132. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  66133. */
  66134. updateInputMeshes?: boolean;
  66135. /**
  66136. * boolean flag to dispose all the source textures. Defaults to true.
  66137. */
  66138. disposeSources?: boolean;
  66139. /**
  66140. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  66141. */
  66142. fillBlanks?: boolean;
  66143. /**
  66144. * string value representing the context fill style color. Defaults to 'black'.
  66145. */
  66146. customFillColor?: string;
  66147. /**
  66148. * Width and Height Value of each Frame in the TexturePacker Sets
  66149. */
  66150. frameSize?: number;
  66151. /**
  66152. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  66153. */
  66154. paddingRatio?: number;
  66155. /**
  66156. * Number that declares the fill method for the padding gutter.
  66157. */
  66158. paddingMode?: number;
  66159. /**
  66160. * If in SUBUV_COLOR padding mode what color to use.
  66161. */
  66162. paddingColor?: Color3 | Color4;
  66163. }
  66164. /**
  66165. * Defines the basic interface of a TexturePacker JSON File
  66166. */
  66167. export interface ITexturePackerJSON {
  66168. /**
  66169. * The frame ID
  66170. */
  66171. name: string;
  66172. /**
  66173. * The base64 channel data
  66174. */
  66175. sets: any;
  66176. /**
  66177. * The options of the Packer
  66178. */
  66179. options: ITexturePackerOptions;
  66180. /**
  66181. * The frame data of the Packer
  66182. */
  66183. frames: Array<number>;
  66184. }
  66185. /**
  66186. * This is a support class that generates a series of packed texture sets.
  66187. * @see https://doc.babylonjs.com/babylon101/materials
  66188. */
  66189. export class TexturePacker {
  66190. /** Packer Layout Constant 0 */
  66191. static readonly LAYOUT_STRIP: number;
  66192. /** Packer Layout Constant 1 */
  66193. static readonly LAYOUT_POWER2: number;
  66194. /** Packer Layout Constant 2 */
  66195. static readonly LAYOUT_COLNUM: number;
  66196. /** Packer Layout Constant 0 */
  66197. static readonly SUBUV_WRAP: number;
  66198. /** Packer Layout Constant 1 */
  66199. static readonly SUBUV_EXTEND: number;
  66200. /** Packer Layout Constant 2 */
  66201. static readonly SUBUV_COLOR: number;
  66202. /** The Name of the Texture Package */
  66203. name: string;
  66204. /** The scene scope of the TexturePacker */
  66205. scene: Scene;
  66206. /** The Meshes to target */
  66207. meshes: AbstractMesh[];
  66208. /** Arguments passed with the Constructor */
  66209. options: ITexturePackerOptions;
  66210. /** The promise that is started upon initialization */
  66211. promise: Nullable<Promise<TexturePacker | string>>;
  66212. /** The Container object for the channel sets that are generated */
  66213. sets: object;
  66214. /** The Container array for the frames that are generated */
  66215. frames: TexturePackerFrame[];
  66216. /** The expected number of textures the system is parsing. */
  66217. private _expecting;
  66218. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  66219. private _paddingValue;
  66220. /**
  66221. * Initializes a texture package series from an array of meshes or a single mesh.
  66222. * @param name The name of the package
  66223. * @param meshes The target meshes to compose the package from
  66224. * @param options The arguments that texture packer should follow while building.
  66225. * @param scene The scene which the textures are scoped to.
  66226. * @returns TexturePacker
  66227. */
  66228. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  66229. /**
  66230. * Starts the package process
  66231. * @param resolve The promises resolution function
  66232. * @returns TexturePacker
  66233. */
  66234. private _createFrames;
  66235. /**
  66236. * Calculates the Size of the Channel Sets
  66237. * @returns Vector2
  66238. */
  66239. private _calculateSize;
  66240. /**
  66241. * Calculates the UV data for the frames.
  66242. * @param baseSize the base frameSize
  66243. * @param padding the base frame padding
  66244. * @param dtSize size of the Dynamic Texture for that channel
  66245. * @param dtUnits is 1/dtSize
  66246. * @param update flag to update the input meshes
  66247. */
  66248. private _calculateMeshUVFrames;
  66249. /**
  66250. * Calculates the frames Offset.
  66251. * @param index of the frame
  66252. * @returns Vector2
  66253. */
  66254. private _getFrameOffset;
  66255. /**
  66256. * Updates a Mesh to the frame data
  66257. * @param mesh that is the target
  66258. * @param frameID or the frame index
  66259. */
  66260. private _updateMeshUV;
  66261. /**
  66262. * Updates a Meshes materials to use the texture packer channels
  66263. * @param m is the mesh to target
  66264. * @param force all channels on the packer to be set.
  66265. */
  66266. private _updateTextureReferences;
  66267. /**
  66268. * Public method to set a Mesh to a frame
  66269. * @param m that is the target
  66270. * @param frameID or the frame index
  66271. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  66272. */
  66273. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  66274. /**
  66275. * Starts the async promise to compile the texture packer.
  66276. * @returns Promise<void>
  66277. */
  66278. processAsync(): Promise<void>;
  66279. /**
  66280. * Disposes all textures associated with this packer
  66281. */
  66282. dispose(): void;
  66283. /**
  66284. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  66285. * @param imageType is the image type to use.
  66286. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  66287. */
  66288. download(imageType?: string, quality?: number): void;
  66289. /**
  66290. * Public method to load a texturePacker JSON file.
  66291. * @param data of the JSON file in string format.
  66292. */
  66293. updateFromJSON(data: string): void;
  66294. }
  66295. }
  66296. declare module BABYLON {
  66297. /**
  66298. * 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.
  66299. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66300. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66301. */
  66302. export class CustomProceduralTexture extends ProceduralTexture {
  66303. private _animate;
  66304. private _time;
  66305. private _config;
  66306. private _texturePath;
  66307. /**
  66308. * Instantiates a new Custom Procedural Texture.
  66309. * 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.
  66310. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66311. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66312. * @param name Define the name of the texture
  66313. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  66314. * @param size Define the size of the texture to create
  66315. * @param scene Define the scene the texture belongs to
  66316. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  66317. * @param generateMipMaps Define if the texture should creates mip maps or not
  66318. */
  66319. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66320. private _loadJson;
  66321. /**
  66322. * Is the texture ready to be used ? (rendered at least once)
  66323. * @returns true if ready, otherwise, false.
  66324. */
  66325. isReady(): boolean;
  66326. /**
  66327. * Render the texture to its associated render target.
  66328. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  66329. */
  66330. render(useCameraPostProcess?: boolean): void;
  66331. /**
  66332. * Update the list of dependant textures samplers in the shader.
  66333. */
  66334. updateTextures(): void;
  66335. /**
  66336. * Update the uniform values of the procedural texture in the shader.
  66337. */
  66338. updateShaderUniforms(): void;
  66339. /**
  66340. * Define if the texture animates or not.
  66341. */
  66342. get animate(): boolean;
  66343. set animate(value: boolean);
  66344. }
  66345. }
  66346. declare module BABYLON {
  66347. /** @hidden */
  66348. export var noisePixelShader: {
  66349. name: string;
  66350. shader: string;
  66351. };
  66352. }
  66353. declare module BABYLON {
  66354. /**
  66355. * Class used to generate noise procedural textures
  66356. */
  66357. export class NoiseProceduralTexture extends ProceduralTexture {
  66358. /** Gets or sets the start time (default is 0) */
  66359. time: number;
  66360. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  66361. brightness: number;
  66362. /** Defines the number of octaves to process */
  66363. octaves: number;
  66364. /** Defines the level of persistence (0.8 by default) */
  66365. persistence: number;
  66366. /** Gets or sets animation speed factor (default is 1) */
  66367. animationSpeedFactor: number;
  66368. /**
  66369. * Creates a new NoiseProceduralTexture
  66370. * @param name defines the name fo the texture
  66371. * @param size defines the size of the texture (default is 256)
  66372. * @param scene defines the hosting scene
  66373. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  66374. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  66375. */
  66376. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66377. private _updateShaderUniforms;
  66378. protected _getDefines(): string;
  66379. /** Generate the current state of the procedural texture */
  66380. render(useCameraPostProcess?: boolean): void;
  66381. /**
  66382. * Serializes this noise procedural texture
  66383. * @returns a serialized noise procedural texture object
  66384. */
  66385. serialize(): any;
  66386. /**
  66387. * Clone the texture.
  66388. * @returns the cloned texture
  66389. */
  66390. clone(): NoiseProceduralTexture;
  66391. /**
  66392. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  66393. * @param parsedTexture defines parsed texture data
  66394. * @param scene defines the current scene
  66395. * @param rootUrl defines the root URL containing noise procedural texture information
  66396. * @returns a parsed NoiseProceduralTexture
  66397. */
  66398. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  66399. }
  66400. }
  66401. declare module BABYLON {
  66402. /**
  66403. * Raw cube texture where the raw buffers are passed in
  66404. */
  66405. export class RawCubeTexture extends CubeTexture {
  66406. /**
  66407. * Creates a cube texture where the raw buffers are passed in.
  66408. * @param scene defines the scene the texture is attached to
  66409. * @param data defines the array of data to use to create each face
  66410. * @param size defines the size of the textures
  66411. * @param format defines the format of the data
  66412. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  66413. * @param generateMipMaps defines if the engine should generate the mip levels
  66414. * @param invertY defines if data must be stored with Y axis inverted
  66415. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  66416. * @param compression defines the compression used (null by default)
  66417. */
  66418. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  66419. /**
  66420. * Updates the raw cube texture.
  66421. * @param data defines the data to store
  66422. * @param format defines the data format
  66423. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66424. * @param invertY defines if data must be stored with Y axis inverted
  66425. * @param compression defines the compression used (null by default)
  66426. * @param level defines which level of the texture to update
  66427. */
  66428. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  66429. /**
  66430. * Updates a raw cube texture with RGBD encoded data.
  66431. * @param data defines the array of data [mipmap][face] to use to create each face
  66432. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  66433. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  66434. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  66435. * @returns a promsie that resolves when the operation is complete
  66436. */
  66437. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  66438. /**
  66439. * Clones the raw cube texture.
  66440. * @return a new cube texture
  66441. */
  66442. clone(): CubeTexture;
  66443. /** @hidden */
  66444. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  66445. }
  66446. }
  66447. declare module BABYLON {
  66448. /**
  66449. * Class used to store 2D array textures containing user data
  66450. */
  66451. export class RawTexture2DArray extends Texture {
  66452. /** Gets or sets the texture format to use */
  66453. format: number;
  66454. /**
  66455. * Create a new RawTexture2DArray
  66456. * @param data defines the data of the texture
  66457. * @param width defines the width of the texture
  66458. * @param height defines the height of the texture
  66459. * @param depth defines the number of layers of the texture
  66460. * @param format defines the texture format to use
  66461. * @param scene defines the hosting scene
  66462. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66463. * @param invertY defines if texture must be stored with Y axis inverted
  66464. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66465. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66466. */
  66467. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66468. /** Gets or sets the texture format to use */
  66469. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66470. /**
  66471. * Update the texture with new data
  66472. * @param data defines the data to store in the texture
  66473. */
  66474. update(data: ArrayBufferView): void;
  66475. }
  66476. }
  66477. declare module BABYLON {
  66478. /**
  66479. * Class used to store 3D textures containing user data
  66480. */
  66481. export class RawTexture3D extends Texture {
  66482. /** Gets or sets the texture format to use */
  66483. format: number;
  66484. /**
  66485. * Create a new RawTexture3D
  66486. * @param data defines the data of the texture
  66487. * @param width defines the width of the texture
  66488. * @param height defines the height of the texture
  66489. * @param depth defines the depth of the texture
  66490. * @param format defines the texture format to use
  66491. * @param scene defines the hosting scene
  66492. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66493. * @param invertY defines if texture must be stored with Y axis inverted
  66494. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66495. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66496. */
  66497. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66498. /** Gets or sets the texture format to use */
  66499. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66500. /**
  66501. * Update the texture with new data
  66502. * @param data defines the data to store in the texture
  66503. */
  66504. update(data: ArrayBufferView): void;
  66505. }
  66506. }
  66507. declare module BABYLON {
  66508. /**
  66509. * Creates a refraction texture used by refraction channel of the standard material.
  66510. * It is like a mirror but to see through a material.
  66511. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66512. */
  66513. export class RefractionTexture extends RenderTargetTexture {
  66514. /**
  66515. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  66516. * 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.
  66517. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66518. */
  66519. refractionPlane: Plane;
  66520. /**
  66521. * Define how deep under the surface we should see.
  66522. */
  66523. depth: number;
  66524. /**
  66525. * Creates a refraction texture used by refraction channel of the standard material.
  66526. * It is like a mirror but to see through a material.
  66527. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66528. * @param name Define the texture name
  66529. * @param size Define the size of the underlying texture
  66530. * @param scene Define the scene the refraction belongs to
  66531. * @param generateMipMaps Define if we need to generate mips level for the refraction
  66532. */
  66533. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  66534. /**
  66535. * Clone the refraction texture.
  66536. * @returns the cloned texture
  66537. */
  66538. clone(): RefractionTexture;
  66539. /**
  66540. * Serialize the texture to a JSON representation you could use in Parse later on
  66541. * @returns the serialized JSON representation
  66542. */
  66543. serialize(): any;
  66544. }
  66545. }
  66546. declare module BABYLON {
  66547. /**
  66548. * Block used to add support for vertex skinning (bones)
  66549. */
  66550. export class BonesBlock extends NodeMaterialBlock {
  66551. /**
  66552. * Creates a new BonesBlock
  66553. * @param name defines the block name
  66554. */
  66555. constructor(name: string);
  66556. /**
  66557. * Initialize the block and prepare the context for build
  66558. * @param state defines the state that will be used for the build
  66559. */
  66560. initialize(state: NodeMaterialBuildState): void;
  66561. /**
  66562. * Gets the current class name
  66563. * @returns the class name
  66564. */
  66565. getClassName(): string;
  66566. /**
  66567. * Gets the matrix indices input component
  66568. */
  66569. get matricesIndices(): NodeMaterialConnectionPoint;
  66570. /**
  66571. * Gets the matrix weights input component
  66572. */
  66573. get matricesWeights(): NodeMaterialConnectionPoint;
  66574. /**
  66575. * Gets the extra matrix indices input component
  66576. */
  66577. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  66578. /**
  66579. * Gets the extra matrix weights input component
  66580. */
  66581. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  66582. /**
  66583. * Gets the world input component
  66584. */
  66585. get world(): NodeMaterialConnectionPoint;
  66586. /**
  66587. * Gets the output component
  66588. */
  66589. get output(): NodeMaterialConnectionPoint;
  66590. autoConfigure(material: NodeMaterial): void;
  66591. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  66592. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66593. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66594. protected _buildBlock(state: NodeMaterialBuildState): this;
  66595. }
  66596. }
  66597. declare module BABYLON {
  66598. /**
  66599. * Block used to add support for instances
  66600. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  66601. */
  66602. export class InstancesBlock extends NodeMaterialBlock {
  66603. /**
  66604. * Creates a new InstancesBlock
  66605. * @param name defines the block name
  66606. */
  66607. constructor(name: string);
  66608. /**
  66609. * Gets the current class name
  66610. * @returns the class name
  66611. */
  66612. getClassName(): string;
  66613. /**
  66614. * Gets the first world row input component
  66615. */
  66616. get world0(): NodeMaterialConnectionPoint;
  66617. /**
  66618. * Gets the second world row input component
  66619. */
  66620. get world1(): NodeMaterialConnectionPoint;
  66621. /**
  66622. * Gets the third world row input component
  66623. */
  66624. get world2(): NodeMaterialConnectionPoint;
  66625. /**
  66626. * Gets the forth world row input component
  66627. */
  66628. get world3(): NodeMaterialConnectionPoint;
  66629. /**
  66630. * Gets the world input component
  66631. */
  66632. get world(): NodeMaterialConnectionPoint;
  66633. /**
  66634. * Gets the output component
  66635. */
  66636. get output(): NodeMaterialConnectionPoint;
  66637. /**
  66638. * Gets the isntanceID component
  66639. */
  66640. get instanceID(): NodeMaterialConnectionPoint;
  66641. autoConfigure(material: NodeMaterial): void;
  66642. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  66643. protected _buildBlock(state: NodeMaterialBuildState): this;
  66644. }
  66645. }
  66646. declare module BABYLON {
  66647. /**
  66648. * Block used to add morph targets support to vertex shader
  66649. */
  66650. export class MorphTargetsBlock extends NodeMaterialBlock {
  66651. private _repeatableContentAnchor;
  66652. /**
  66653. * Create a new MorphTargetsBlock
  66654. * @param name defines the block name
  66655. */
  66656. constructor(name: string);
  66657. /**
  66658. * Gets the current class name
  66659. * @returns the class name
  66660. */
  66661. getClassName(): string;
  66662. /**
  66663. * Gets the position input component
  66664. */
  66665. get position(): NodeMaterialConnectionPoint;
  66666. /**
  66667. * Gets the normal input component
  66668. */
  66669. get normal(): NodeMaterialConnectionPoint;
  66670. /**
  66671. * Gets the tangent input component
  66672. */
  66673. get tangent(): NodeMaterialConnectionPoint;
  66674. /**
  66675. * Gets the tangent input component
  66676. */
  66677. get uv(): NodeMaterialConnectionPoint;
  66678. /**
  66679. * Gets the position output component
  66680. */
  66681. get positionOutput(): NodeMaterialConnectionPoint;
  66682. /**
  66683. * Gets the normal output component
  66684. */
  66685. get normalOutput(): NodeMaterialConnectionPoint;
  66686. /**
  66687. * Gets the tangent output component
  66688. */
  66689. get tangentOutput(): NodeMaterialConnectionPoint;
  66690. /**
  66691. * Gets the tangent output component
  66692. */
  66693. get uvOutput(): NodeMaterialConnectionPoint;
  66694. initialize(state: NodeMaterialBuildState): void;
  66695. autoConfigure(material: NodeMaterial): void;
  66696. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66697. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66698. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  66699. protected _buildBlock(state: NodeMaterialBuildState): this;
  66700. }
  66701. }
  66702. declare module BABYLON {
  66703. /**
  66704. * Block used to get data information from a light
  66705. */
  66706. export class LightInformationBlock extends NodeMaterialBlock {
  66707. private _lightDataUniformName;
  66708. private _lightColorUniformName;
  66709. private _lightTypeDefineName;
  66710. /**
  66711. * Gets or sets the light associated with this block
  66712. */
  66713. light: Nullable<Light>;
  66714. /**
  66715. * Creates a new LightInformationBlock
  66716. * @param name defines the block name
  66717. */
  66718. constructor(name: string);
  66719. /**
  66720. * Gets the current class name
  66721. * @returns the class name
  66722. */
  66723. getClassName(): string;
  66724. /**
  66725. * Gets the world position input component
  66726. */
  66727. get worldPosition(): NodeMaterialConnectionPoint;
  66728. /**
  66729. * Gets the direction output component
  66730. */
  66731. get direction(): NodeMaterialConnectionPoint;
  66732. /**
  66733. * Gets the direction output component
  66734. */
  66735. get color(): NodeMaterialConnectionPoint;
  66736. /**
  66737. * Gets the direction output component
  66738. */
  66739. get intensity(): NodeMaterialConnectionPoint;
  66740. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66741. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66742. protected _buildBlock(state: NodeMaterialBuildState): this;
  66743. serialize(): any;
  66744. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66745. }
  66746. }
  66747. declare module BABYLON {
  66748. /**
  66749. * Block used to add image processing support to fragment shader
  66750. */
  66751. export class ImageProcessingBlock extends NodeMaterialBlock {
  66752. /**
  66753. * Create a new ImageProcessingBlock
  66754. * @param name defines the block name
  66755. */
  66756. constructor(name: string);
  66757. /**
  66758. * Gets the current class name
  66759. * @returns the class name
  66760. */
  66761. getClassName(): string;
  66762. /**
  66763. * Gets the color input component
  66764. */
  66765. get color(): NodeMaterialConnectionPoint;
  66766. /**
  66767. * Gets the output component
  66768. */
  66769. get output(): NodeMaterialConnectionPoint;
  66770. /**
  66771. * Initialize the block and prepare the context for build
  66772. * @param state defines the state that will be used for the build
  66773. */
  66774. initialize(state: NodeMaterialBuildState): void;
  66775. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  66776. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66777. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66778. protected _buildBlock(state: NodeMaterialBuildState): this;
  66779. }
  66780. }
  66781. declare module BABYLON {
  66782. /**
  66783. * Block used to pertub normals based on a normal map
  66784. */
  66785. export class PerturbNormalBlock extends NodeMaterialBlock {
  66786. private _tangentSpaceParameterName;
  66787. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66788. invertX: boolean;
  66789. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  66790. invertY: boolean;
  66791. /**
  66792. * Create a new PerturbNormalBlock
  66793. * @param name defines the block name
  66794. */
  66795. constructor(name: string);
  66796. /**
  66797. * Gets the current class name
  66798. * @returns the class name
  66799. */
  66800. getClassName(): string;
  66801. /**
  66802. * Gets the world position input component
  66803. */
  66804. get worldPosition(): NodeMaterialConnectionPoint;
  66805. /**
  66806. * Gets the world normal input component
  66807. */
  66808. get worldNormal(): NodeMaterialConnectionPoint;
  66809. /**
  66810. * Gets the world tangent input component
  66811. */
  66812. get worldTangent(): NodeMaterialConnectionPoint;
  66813. /**
  66814. * Gets the uv input component
  66815. */
  66816. get uv(): NodeMaterialConnectionPoint;
  66817. /**
  66818. * Gets the normal map color input component
  66819. */
  66820. get normalMapColor(): NodeMaterialConnectionPoint;
  66821. /**
  66822. * Gets the strength input component
  66823. */
  66824. get strength(): NodeMaterialConnectionPoint;
  66825. /**
  66826. * Gets the output component
  66827. */
  66828. get output(): NodeMaterialConnectionPoint;
  66829. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66830. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66831. autoConfigure(material: NodeMaterial): void;
  66832. protected _buildBlock(state: NodeMaterialBuildState): this;
  66833. protected _dumpPropertiesCode(): string;
  66834. serialize(): any;
  66835. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66836. }
  66837. }
  66838. declare module BABYLON {
  66839. /**
  66840. * Block used to discard a pixel if a value is smaller than a cutoff
  66841. */
  66842. export class DiscardBlock extends NodeMaterialBlock {
  66843. /**
  66844. * Create a new DiscardBlock
  66845. * @param name defines the block name
  66846. */
  66847. constructor(name: string);
  66848. /**
  66849. * Gets the current class name
  66850. * @returns the class name
  66851. */
  66852. getClassName(): string;
  66853. /**
  66854. * Gets the color input component
  66855. */
  66856. get value(): NodeMaterialConnectionPoint;
  66857. /**
  66858. * Gets the cutoff input component
  66859. */
  66860. get cutoff(): NodeMaterialConnectionPoint;
  66861. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66862. }
  66863. }
  66864. declare module BABYLON {
  66865. /**
  66866. * Block used to test if the fragment shader is front facing
  66867. */
  66868. export class FrontFacingBlock extends NodeMaterialBlock {
  66869. /**
  66870. * Creates a new FrontFacingBlock
  66871. * @param name defines the block name
  66872. */
  66873. constructor(name: string);
  66874. /**
  66875. * Gets the current class name
  66876. * @returns the class name
  66877. */
  66878. getClassName(): string;
  66879. /**
  66880. * Gets the output component
  66881. */
  66882. get output(): NodeMaterialConnectionPoint;
  66883. protected _buildBlock(state: NodeMaterialBuildState): this;
  66884. }
  66885. }
  66886. declare module BABYLON {
  66887. /**
  66888. * Block used to get the derivative value on x and y of a given input
  66889. */
  66890. export class DerivativeBlock extends NodeMaterialBlock {
  66891. /**
  66892. * Create a new DerivativeBlock
  66893. * @param name defines the block name
  66894. */
  66895. constructor(name: string);
  66896. /**
  66897. * Gets the current class name
  66898. * @returns the class name
  66899. */
  66900. getClassName(): string;
  66901. /**
  66902. * Gets the input component
  66903. */
  66904. get input(): NodeMaterialConnectionPoint;
  66905. /**
  66906. * Gets the derivative output on x
  66907. */
  66908. get dx(): NodeMaterialConnectionPoint;
  66909. /**
  66910. * Gets the derivative output on y
  66911. */
  66912. get dy(): NodeMaterialConnectionPoint;
  66913. protected _buildBlock(state: NodeMaterialBuildState): this;
  66914. }
  66915. }
  66916. declare module BABYLON {
  66917. /**
  66918. * Block used to make gl_FragCoord available
  66919. */
  66920. export class FragCoordBlock extends NodeMaterialBlock {
  66921. /**
  66922. * Creates a new FragCoordBlock
  66923. * @param name defines the block name
  66924. */
  66925. constructor(name: string);
  66926. /**
  66927. * Gets the current class name
  66928. * @returns the class name
  66929. */
  66930. getClassName(): string;
  66931. /**
  66932. * Gets the xy component
  66933. */
  66934. get xy(): NodeMaterialConnectionPoint;
  66935. /**
  66936. * Gets the xyz component
  66937. */
  66938. get xyz(): NodeMaterialConnectionPoint;
  66939. /**
  66940. * Gets the xyzw component
  66941. */
  66942. get xyzw(): NodeMaterialConnectionPoint;
  66943. /**
  66944. * Gets the x component
  66945. */
  66946. get x(): NodeMaterialConnectionPoint;
  66947. /**
  66948. * Gets the y component
  66949. */
  66950. get y(): NodeMaterialConnectionPoint;
  66951. /**
  66952. * Gets the z component
  66953. */
  66954. get z(): NodeMaterialConnectionPoint;
  66955. /**
  66956. * Gets the w component
  66957. */
  66958. get output(): NodeMaterialConnectionPoint;
  66959. protected writeOutputs(state: NodeMaterialBuildState): string;
  66960. protected _buildBlock(state: NodeMaterialBuildState): this;
  66961. }
  66962. }
  66963. declare module BABYLON {
  66964. /**
  66965. * Block used to get the screen sizes
  66966. */
  66967. export class ScreenSizeBlock extends NodeMaterialBlock {
  66968. private _varName;
  66969. private _scene;
  66970. /**
  66971. * Creates a new ScreenSizeBlock
  66972. * @param name defines the block name
  66973. */
  66974. constructor(name: string);
  66975. /**
  66976. * Gets the current class name
  66977. * @returns the class name
  66978. */
  66979. getClassName(): string;
  66980. /**
  66981. * Gets the xy component
  66982. */
  66983. get xy(): NodeMaterialConnectionPoint;
  66984. /**
  66985. * Gets the x component
  66986. */
  66987. get x(): NodeMaterialConnectionPoint;
  66988. /**
  66989. * Gets the y component
  66990. */
  66991. get y(): NodeMaterialConnectionPoint;
  66992. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66993. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  66994. protected _buildBlock(state: NodeMaterialBuildState): this;
  66995. }
  66996. }
  66997. declare module BABYLON {
  66998. /**
  66999. * Block used to add support for scene fog
  67000. */
  67001. export class FogBlock extends NodeMaterialBlock {
  67002. private _fogDistanceName;
  67003. private _fogParameters;
  67004. /**
  67005. * Create a new FogBlock
  67006. * @param name defines the block name
  67007. */
  67008. constructor(name: string);
  67009. /**
  67010. * Gets the current class name
  67011. * @returns the class name
  67012. */
  67013. getClassName(): string;
  67014. /**
  67015. * Gets the world position input component
  67016. */
  67017. get worldPosition(): NodeMaterialConnectionPoint;
  67018. /**
  67019. * Gets the view input component
  67020. */
  67021. get view(): NodeMaterialConnectionPoint;
  67022. /**
  67023. * Gets the color input component
  67024. */
  67025. get input(): NodeMaterialConnectionPoint;
  67026. /**
  67027. * Gets the fog color input component
  67028. */
  67029. get fogColor(): NodeMaterialConnectionPoint;
  67030. /**
  67031. * Gets the output component
  67032. */
  67033. get output(): NodeMaterialConnectionPoint;
  67034. autoConfigure(material: NodeMaterial): void;
  67035. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67036. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67037. protected _buildBlock(state: NodeMaterialBuildState): this;
  67038. }
  67039. }
  67040. declare module BABYLON {
  67041. /**
  67042. * Block used to add light in the fragment shader
  67043. */
  67044. export class LightBlock extends NodeMaterialBlock {
  67045. private _lightId;
  67046. /**
  67047. * Gets or sets the light associated with this block
  67048. */
  67049. light: Nullable<Light>;
  67050. /**
  67051. * Create a new LightBlock
  67052. * @param name defines the block name
  67053. */
  67054. constructor(name: string);
  67055. /**
  67056. * Gets the current class name
  67057. * @returns the class name
  67058. */
  67059. getClassName(): string;
  67060. /**
  67061. * Gets the world position input component
  67062. */
  67063. get worldPosition(): NodeMaterialConnectionPoint;
  67064. /**
  67065. * Gets the world normal input component
  67066. */
  67067. get worldNormal(): NodeMaterialConnectionPoint;
  67068. /**
  67069. * Gets the camera (or eye) position component
  67070. */
  67071. get cameraPosition(): NodeMaterialConnectionPoint;
  67072. /**
  67073. * Gets the glossiness component
  67074. */
  67075. get glossiness(): NodeMaterialConnectionPoint;
  67076. /**
  67077. * Gets the glossinness power component
  67078. */
  67079. get glossPower(): NodeMaterialConnectionPoint;
  67080. /**
  67081. * Gets the diffuse color component
  67082. */
  67083. get diffuseColor(): NodeMaterialConnectionPoint;
  67084. /**
  67085. * Gets the specular color component
  67086. */
  67087. get specularColor(): NodeMaterialConnectionPoint;
  67088. /**
  67089. * Gets the view matrix component
  67090. */
  67091. get view(): NodeMaterialConnectionPoint;
  67092. /**
  67093. * Gets the diffuse output component
  67094. */
  67095. get diffuseOutput(): NodeMaterialConnectionPoint;
  67096. /**
  67097. * Gets the specular output component
  67098. */
  67099. get specularOutput(): NodeMaterialConnectionPoint;
  67100. /**
  67101. * Gets the shadow output component
  67102. */
  67103. get shadow(): NodeMaterialConnectionPoint;
  67104. autoConfigure(material: NodeMaterial): void;
  67105. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67106. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67107. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67108. private _injectVertexCode;
  67109. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67110. serialize(): any;
  67111. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67112. }
  67113. }
  67114. declare module BABYLON {
  67115. /**
  67116. * Block used to read a reflection texture from a sampler
  67117. */
  67118. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  67119. /**
  67120. * Create a new ReflectionTextureBlock
  67121. * @param name defines the block name
  67122. */
  67123. constructor(name: string);
  67124. /**
  67125. * Gets the current class name
  67126. * @returns the class name
  67127. */
  67128. getClassName(): string;
  67129. /**
  67130. * Gets the world position input component
  67131. */
  67132. get position(): NodeMaterialConnectionPoint;
  67133. /**
  67134. * Gets the world position input component
  67135. */
  67136. get worldPosition(): NodeMaterialConnectionPoint;
  67137. /**
  67138. * Gets the world normal input component
  67139. */
  67140. get worldNormal(): NodeMaterialConnectionPoint;
  67141. /**
  67142. * Gets the world input component
  67143. */
  67144. get world(): NodeMaterialConnectionPoint;
  67145. /**
  67146. * Gets the camera (or eye) position component
  67147. */
  67148. get cameraPosition(): NodeMaterialConnectionPoint;
  67149. /**
  67150. * Gets the view input component
  67151. */
  67152. get view(): NodeMaterialConnectionPoint;
  67153. /**
  67154. * Gets the rgb output component
  67155. */
  67156. get rgb(): NodeMaterialConnectionPoint;
  67157. /**
  67158. * Gets the rgba output component
  67159. */
  67160. get rgba(): NodeMaterialConnectionPoint;
  67161. /**
  67162. * Gets the r output component
  67163. */
  67164. get r(): NodeMaterialConnectionPoint;
  67165. /**
  67166. * Gets the g output component
  67167. */
  67168. get g(): NodeMaterialConnectionPoint;
  67169. /**
  67170. * Gets the b output component
  67171. */
  67172. get b(): NodeMaterialConnectionPoint;
  67173. /**
  67174. * Gets the a output component
  67175. */
  67176. get a(): NodeMaterialConnectionPoint;
  67177. autoConfigure(material: NodeMaterial): void;
  67178. protected _buildBlock(state: NodeMaterialBuildState): this;
  67179. }
  67180. }
  67181. declare module BABYLON {
  67182. /**
  67183. * Block used to add 2 vectors
  67184. */
  67185. export class AddBlock extends NodeMaterialBlock {
  67186. /**
  67187. * Creates a new AddBlock
  67188. * @param name defines the block name
  67189. */
  67190. constructor(name: string);
  67191. /**
  67192. * Gets the current class name
  67193. * @returns the class name
  67194. */
  67195. getClassName(): string;
  67196. /**
  67197. * Gets the left operand input component
  67198. */
  67199. get left(): NodeMaterialConnectionPoint;
  67200. /**
  67201. * Gets the right operand input component
  67202. */
  67203. get right(): NodeMaterialConnectionPoint;
  67204. /**
  67205. * Gets the output component
  67206. */
  67207. get output(): NodeMaterialConnectionPoint;
  67208. protected _buildBlock(state: NodeMaterialBuildState): this;
  67209. }
  67210. }
  67211. declare module BABYLON {
  67212. /**
  67213. * Block used to scale a vector by a float
  67214. */
  67215. export class ScaleBlock extends NodeMaterialBlock {
  67216. /**
  67217. * Creates a new ScaleBlock
  67218. * @param name defines the block name
  67219. */
  67220. constructor(name: string);
  67221. /**
  67222. * Gets the current class name
  67223. * @returns the class name
  67224. */
  67225. getClassName(): string;
  67226. /**
  67227. * Gets the input component
  67228. */
  67229. get input(): NodeMaterialConnectionPoint;
  67230. /**
  67231. * Gets the factor input component
  67232. */
  67233. get factor(): NodeMaterialConnectionPoint;
  67234. /**
  67235. * Gets the output component
  67236. */
  67237. get output(): NodeMaterialConnectionPoint;
  67238. protected _buildBlock(state: NodeMaterialBuildState): this;
  67239. }
  67240. }
  67241. declare module BABYLON {
  67242. /**
  67243. * Block used to clamp a float
  67244. */
  67245. export class ClampBlock extends NodeMaterialBlock {
  67246. /** Gets or sets the minimum range */
  67247. minimum: number;
  67248. /** Gets or sets the maximum range */
  67249. maximum: number;
  67250. /**
  67251. * Creates a new ClampBlock
  67252. * @param name defines the block name
  67253. */
  67254. constructor(name: string);
  67255. /**
  67256. * Gets the current class name
  67257. * @returns the class name
  67258. */
  67259. getClassName(): string;
  67260. /**
  67261. * Gets the value input component
  67262. */
  67263. get value(): NodeMaterialConnectionPoint;
  67264. /**
  67265. * Gets the output component
  67266. */
  67267. get output(): NodeMaterialConnectionPoint;
  67268. protected _buildBlock(state: NodeMaterialBuildState): this;
  67269. protected _dumpPropertiesCode(): string;
  67270. serialize(): any;
  67271. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67272. }
  67273. }
  67274. declare module BABYLON {
  67275. /**
  67276. * Block used to apply a cross product between 2 vectors
  67277. */
  67278. export class CrossBlock extends NodeMaterialBlock {
  67279. /**
  67280. * Creates a new CrossBlock
  67281. * @param name defines the block name
  67282. */
  67283. constructor(name: string);
  67284. /**
  67285. * Gets the current class name
  67286. * @returns the class name
  67287. */
  67288. getClassName(): string;
  67289. /**
  67290. * Gets the left operand input component
  67291. */
  67292. get left(): NodeMaterialConnectionPoint;
  67293. /**
  67294. * Gets the right operand input component
  67295. */
  67296. get right(): NodeMaterialConnectionPoint;
  67297. /**
  67298. * Gets the output component
  67299. */
  67300. get output(): NodeMaterialConnectionPoint;
  67301. protected _buildBlock(state: NodeMaterialBuildState): this;
  67302. }
  67303. }
  67304. declare module BABYLON {
  67305. /**
  67306. * Block used to apply a dot product between 2 vectors
  67307. */
  67308. export class DotBlock extends NodeMaterialBlock {
  67309. /**
  67310. * Creates a new DotBlock
  67311. * @param name defines the block name
  67312. */
  67313. constructor(name: string);
  67314. /**
  67315. * Gets the current class name
  67316. * @returns the class name
  67317. */
  67318. getClassName(): string;
  67319. /**
  67320. * Gets the left operand input component
  67321. */
  67322. get left(): NodeMaterialConnectionPoint;
  67323. /**
  67324. * Gets the right operand input component
  67325. */
  67326. get right(): NodeMaterialConnectionPoint;
  67327. /**
  67328. * Gets the output component
  67329. */
  67330. get output(): NodeMaterialConnectionPoint;
  67331. protected _buildBlock(state: NodeMaterialBuildState): this;
  67332. }
  67333. }
  67334. declare module BABYLON {
  67335. /**
  67336. * Block used to normalize a vector
  67337. */
  67338. export class NormalizeBlock extends NodeMaterialBlock {
  67339. /**
  67340. * Creates a new NormalizeBlock
  67341. * @param name defines the block name
  67342. */
  67343. constructor(name: string);
  67344. /**
  67345. * Gets the current class name
  67346. * @returns the class name
  67347. */
  67348. getClassName(): string;
  67349. /**
  67350. * Gets the input component
  67351. */
  67352. get input(): NodeMaterialConnectionPoint;
  67353. /**
  67354. * Gets the output component
  67355. */
  67356. get output(): NodeMaterialConnectionPoint;
  67357. protected _buildBlock(state: NodeMaterialBuildState): this;
  67358. }
  67359. }
  67360. declare module BABYLON {
  67361. /**
  67362. * Block used to create a Color3/4 out of individual inputs (one for each component)
  67363. */
  67364. export class ColorMergerBlock extends NodeMaterialBlock {
  67365. /**
  67366. * Create a new ColorMergerBlock
  67367. * @param name defines the block name
  67368. */
  67369. constructor(name: string);
  67370. /**
  67371. * Gets the current class name
  67372. * @returns the class name
  67373. */
  67374. getClassName(): string;
  67375. /**
  67376. * Gets the rgb component (input)
  67377. */
  67378. get rgbIn(): NodeMaterialConnectionPoint;
  67379. /**
  67380. * Gets the r component (input)
  67381. */
  67382. get r(): NodeMaterialConnectionPoint;
  67383. /**
  67384. * Gets the g component (input)
  67385. */
  67386. get g(): NodeMaterialConnectionPoint;
  67387. /**
  67388. * Gets the b component (input)
  67389. */
  67390. get b(): NodeMaterialConnectionPoint;
  67391. /**
  67392. * Gets the a component (input)
  67393. */
  67394. get a(): NodeMaterialConnectionPoint;
  67395. /**
  67396. * Gets the rgba component (output)
  67397. */
  67398. get rgba(): NodeMaterialConnectionPoint;
  67399. /**
  67400. * Gets the rgb component (output)
  67401. */
  67402. get rgbOut(): NodeMaterialConnectionPoint;
  67403. /**
  67404. * Gets the rgb component (output)
  67405. * @deprecated Please use rgbOut instead.
  67406. */
  67407. get rgb(): NodeMaterialConnectionPoint;
  67408. protected _buildBlock(state: NodeMaterialBuildState): this;
  67409. }
  67410. }
  67411. declare module BABYLON {
  67412. /**
  67413. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  67414. */
  67415. export class VectorSplitterBlock extends NodeMaterialBlock {
  67416. /**
  67417. * Create a new VectorSplitterBlock
  67418. * @param name defines the block name
  67419. */
  67420. constructor(name: string);
  67421. /**
  67422. * Gets the current class name
  67423. * @returns the class name
  67424. */
  67425. getClassName(): string;
  67426. /**
  67427. * Gets the xyzw component (input)
  67428. */
  67429. get xyzw(): NodeMaterialConnectionPoint;
  67430. /**
  67431. * Gets the xyz component (input)
  67432. */
  67433. get xyzIn(): NodeMaterialConnectionPoint;
  67434. /**
  67435. * Gets the xy component (input)
  67436. */
  67437. get xyIn(): NodeMaterialConnectionPoint;
  67438. /**
  67439. * Gets the xyz component (output)
  67440. */
  67441. get xyzOut(): NodeMaterialConnectionPoint;
  67442. /**
  67443. * Gets the xy component (output)
  67444. */
  67445. get xyOut(): NodeMaterialConnectionPoint;
  67446. /**
  67447. * Gets the x component (output)
  67448. */
  67449. get x(): NodeMaterialConnectionPoint;
  67450. /**
  67451. * Gets the y component (output)
  67452. */
  67453. get y(): NodeMaterialConnectionPoint;
  67454. /**
  67455. * Gets the z component (output)
  67456. */
  67457. get z(): NodeMaterialConnectionPoint;
  67458. /**
  67459. * Gets the w component (output)
  67460. */
  67461. get w(): NodeMaterialConnectionPoint;
  67462. protected _inputRename(name: string): string;
  67463. protected _outputRename(name: string): string;
  67464. protected _buildBlock(state: NodeMaterialBuildState): this;
  67465. }
  67466. }
  67467. declare module BABYLON {
  67468. /**
  67469. * Block used to lerp between 2 values
  67470. */
  67471. export class LerpBlock extends NodeMaterialBlock {
  67472. /**
  67473. * Creates a new LerpBlock
  67474. * @param name defines the block name
  67475. */
  67476. constructor(name: string);
  67477. /**
  67478. * Gets the current class name
  67479. * @returns the class name
  67480. */
  67481. getClassName(): string;
  67482. /**
  67483. * Gets the left operand input component
  67484. */
  67485. get left(): NodeMaterialConnectionPoint;
  67486. /**
  67487. * Gets the right operand input component
  67488. */
  67489. get right(): NodeMaterialConnectionPoint;
  67490. /**
  67491. * Gets the gradient operand input component
  67492. */
  67493. get gradient(): NodeMaterialConnectionPoint;
  67494. /**
  67495. * Gets the output component
  67496. */
  67497. get output(): NodeMaterialConnectionPoint;
  67498. protected _buildBlock(state: NodeMaterialBuildState): this;
  67499. }
  67500. }
  67501. declare module BABYLON {
  67502. /**
  67503. * Block used to divide 2 vectors
  67504. */
  67505. export class DivideBlock extends NodeMaterialBlock {
  67506. /**
  67507. * Creates a new DivideBlock
  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 left operand input component
  67518. */
  67519. get left(): NodeMaterialConnectionPoint;
  67520. /**
  67521. * Gets the right operand input component
  67522. */
  67523. get right(): NodeMaterialConnectionPoint;
  67524. /**
  67525. * Gets the output component
  67526. */
  67527. get output(): NodeMaterialConnectionPoint;
  67528. protected _buildBlock(state: NodeMaterialBuildState): this;
  67529. }
  67530. }
  67531. declare module BABYLON {
  67532. /**
  67533. * Block used to subtract 2 vectors
  67534. */
  67535. export class SubtractBlock extends NodeMaterialBlock {
  67536. /**
  67537. * Creates a new SubtractBlock
  67538. * @param name defines the block name
  67539. */
  67540. constructor(name: string);
  67541. /**
  67542. * Gets the current class name
  67543. * @returns the class name
  67544. */
  67545. getClassName(): string;
  67546. /**
  67547. * Gets the left operand input component
  67548. */
  67549. get left(): NodeMaterialConnectionPoint;
  67550. /**
  67551. * Gets the right operand input component
  67552. */
  67553. get right(): NodeMaterialConnectionPoint;
  67554. /**
  67555. * Gets the output component
  67556. */
  67557. get output(): NodeMaterialConnectionPoint;
  67558. protected _buildBlock(state: NodeMaterialBuildState): this;
  67559. }
  67560. }
  67561. declare module BABYLON {
  67562. /**
  67563. * Block used to step a value
  67564. */
  67565. export class StepBlock extends NodeMaterialBlock {
  67566. /**
  67567. * Creates a new StepBlock
  67568. * @param name defines the block name
  67569. */
  67570. constructor(name: string);
  67571. /**
  67572. * Gets the current class name
  67573. * @returns the class name
  67574. */
  67575. getClassName(): string;
  67576. /**
  67577. * Gets the value operand input component
  67578. */
  67579. get value(): NodeMaterialConnectionPoint;
  67580. /**
  67581. * Gets the edge operand input component
  67582. */
  67583. get edge(): NodeMaterialConnectionPoint;
  67584. /**
  67585. * Gets the output component
  67586. */
  67587. get output(): NodeMaterialConnectionPoint;
  67588. protected _buildBlock(state: NodeMaterialBuildState): this;
  67589. }
  67590. }
  67591. declare module BABYLON {
  67592. /**
  67593. * Block used to get the opposite (1 - x) of a value
  67594. */
  67595. export class OneMinusBlock extends NodeMaterialBlock {
  67596. /**
  67597. * Creates a new OneMinusBlock
  67598. * @param name defines the block name
  67599. */
  67600. constructor(name: string);
  67601. /**
  67602. * Gets the current class name
  67603. * @returns the class name
  67604. */
  67605. getClassName(): string;
  67606. /**
  67607. * Gets the input component
  67608. */
  67609. get input(): NodeMaterialConnectionPoint;
  67610. /**
  67611. * Gets the output component
  67612. */
  67613. get output(): NodeMaterialConnectionPoint;
  67614. protected _buildBlock(state: NodeMaterialBuildState): this;
  67615. }
  67616. }
  67617. declare module BABYLON {
  67618. /**
  67619. * Block used to get the view direction
  67620. */
  67621. export class ViewDirectionBlock extends NodeMaterialBlock {
  67622. /**
  67623. * Creates a new ViewDirectionBlock
  67624. * @param name defines the block name
  67625. */
  67626. constructor(name: string);
  67627. /**
  67628. * Gets the current class name
  67629. * @returns the class name
  67630. */
  67631. getClassName(): string;
  67632. /**
  67633. * Gets the world position component
  67634. */
  67635. get worldPosition(): NodeMaterialConnectionPoint;
  67636. /**
  67637. * Gets the camera position component
  67638. */
  67639. get cameraPosition(): NodeMaterialConnectionPoint;
  67640. /**
  67641. * Gets the output component
  67642. */
  67643. get output(): NodeMaterialConnectionPoint;
  67644. autoConfigure(material: NodeMaterial): void;
  67645. protected _buildBlock(state: NodeMaterialBuildState): this;
  67646. }
  67647. }
  67648. declare module BABYLON {
  67649. /**
  67650. * Block used to compute fresnel value
  67651. */
  67652. export class FresnelBlock extends NodeMaterialBlock {
  67653. /**
  67654. * Create a new FresnelBlock
  67655. * @param name defines the block name
  67656. */
  67657. constructor(name: string);
  67658. /**
  67659. * Gets the current class name
  67660. * @returns the class name
  67661. */
  67662. getClassName(): string;
  67663. /**
  67664. * Gets the world normal input component
  67665. */
  67666. get worldNormal(): NodeMaterialConnectionPoint;
  67667. /**
  67668. * Gets the view direction input component
  67669. */
  67670. get viewDirection(): NodeMaterialConnectionPoint;
  67671. /**
  67672. * Gets the bias input component
  67673. */
  67674. get bias(): NodeMaterialConnectionPoint;
  67675. /**
  67676. * Gets the camera (or eye) position component
  67677. */
  67678. get power(): NodeMaterialConnectionPoint;
  67679. /**
  67680. * Gets the fresnel output component
  67681. */
  67682. get fresnel(): NodeMaterialConnectionPoint;
  67683. autoConfigure(material: NodeMaterial): void;
  67684. protected _buildBlock(state: NodeMaterialBuildState): this;
  67685. }
  67686. }
  67687. declare module BABYLON {
  67688. /**
  67689. * Block used to get the max of 2 values
  67690. */
  67691. export class MaxBlock extends NodeMaterialBlock {
  67692. /**
  67693. * Creates a new MaxBlock
  67694. * @param name defines the block name
  67695. */
  67696. constructor(name: string);
  67697. /**
  67698. * Gets the current class name
  67699. * @returns the class name
  67700. */
  67701. getClassName(): string;
  67702. /**
  67703. * Gets the left operand input component
  67704. */
  67705. get left(): NodeMaterialConnectionPoint;
  67706. /**
  67707. * Gets the right operand input component
  67708. */
  67709. get right(): NodeMaterialConnectionPoint;
  67710. /**
  67711. * Gets the output component
  67712. */
  67713. get output(): NodeMaterialConnectionPoint;
  67714. protected _buildBlock(state: NodeMaterialBuildState): this;
  67715. }
  67716. }
  67717. declare module BABYLON {
  67718. /**
  67719. * Block used to get the min of 2 values
  67720. */
  67721. export class MinBlock extends NodeMaterialBlock {
  67722. /**
  67723. * Creates a new MinBlock
  67724. * @param name defines the block name
  67725. */
  67726. constructor(name: string);
  67727. /**
  67728. * Gets the current class name
  67729. * @returns the class name
  67730. */
  67731. getClassName(): string;
  67732. /**
  67733. * Gets the left operand input component
  67734. */
  67735. get left(): NodeMaterialConnectionPoint;
  67736. /**
  67737. * Gets the right operand input component
  67738. */
  67739. get right(): NodeMaterialConnectionPoint;
  67740. /**
  67741. * Gets the output component
  67742. */
  67743. get output(): NodeMaterialConnectionPoint;
  67744. protected _buildBlock(state: NodeMaterialBuildState): this;
  67745. }
  67746. }
  67747. declare module BABYLON {
  67748. /**
  67749. * Block used to get the distance between 2 values
  67750. */
  67751. export class DistanceBlock extends NodeMaterialBlock {
  67752. /**
  67753. * Creates a new DistanceBlock
  67754. * @param name defines the block name
  67755. */
  67756. constructor(name: string);
  67757. /**
  67758. * Gets the current class name
  67759. * @returns the class name
  67760. */
  67761. getClassName(): string;
  67762. /**
  67763. * Gets the left operand input component
  67764. */
  67765. get left(): NodeMaterialConnectionPoint;
  67766. /**
  67767. * Gets the right operand input component
  67768. */
  67769. get right(): NodeMaterialConnectionPoint;
  67770. /**
  67771. * Gets the output component
  67772. */
  67773. get output(): NodeMaterialConnectionPoint;
  67774. protected _buildBlock(state: NodeMaterialBuildState): this;
  67775. }
  67776. }
  67777. declare module BABYLON {
  67778. /**
  67779. * Block used to get the length of a vector
  67780. */
  67781. export class LengthBlock extends NodeMaterialBlock {
  67782. /**
  67783. * Creates a new LengthBlock
  67784. * @param name defines the block name
  67785. */
  67786. constructor(name: string);
  67787. /**
  67788. * Gets the current class name
  67789. * @returns the class name
  67790. */
  67791. getClassName(): string;
  67792. /**
  67793. * Gets the value input component
  67794. */
  67795. get value(): NodeMaterialConnectionPoint;
  67796. /**
  67797. * Gets the output component
  67798. */
  67799. get output(): NodeMaterialConnectionPoint;
  67800. protected _buildBlock(state: NodeMaterialBuildState): this;
  67801. }
  67802. }
  67803. declare module BABYLON {
  67804. /**
  67805. * Block used to get negative version of a value (i.e. x * -1)
  67806. */
  67807. export class NegateBlock extends NodeMaterialBlock {
  67808. /**
  67809. * Creates a new NegateBlock
  67810. * @param name defines the block name
  67811. */
  67812. constructor(name: string);
  67813. /**
  67814. * Gets the current class name
  67815. * @returns the class name
  67816. */
  67817. getClassName(): string;
  67818. /**
  67819. * Gets the value input component
  67820. */
  67821. get value(): NodeMaterialConnectionPoint;
  67822. /**
  67823. * Gets the output component
  67824. */
  67825. get output(): NodeMaterialConnectionPoint;
  67826. protected _buildBlock(state: NodeMaterialBuildState): this;
  67827. }
  67828. }
  67829. declare module BABYLON {
  67830. /**
  67831. * Block used to get the value of the first parameter raised to the power of the second
  67832. */
  67833. export class PowBlock extends NodeMaterialBlock {
  67834. /**
  67835. * Creates a new PowBlock
  67836. * @param name defines the block name
  67837. */
  67838. constructor(name: string);
  67839. /**
  67840. * Gets the current class name
  67841. * @returns the class name
  67842. */
  67843. getClassName(): string;
  67844. /**
  67845. * Gets the value operand input component
  67846. */
  67847. get value(): NodeMaterialConnectionPoint;
  67848. /**
  67849. * Gets the power operand input component
  67850. */
  67851. get power(): NodeMaterialConnectionPoint;
  67852. /**
  67853. * Gets the output component
  67854. */
  67855. get output(): NodeMaterialConnectionPoint;
  67856. protected _buildBlock(state: NodeMaterialBuildState): this;
  67857. }
  67858. }
  67859. declare module BABYLON {
  67860. /**
  67861. * Block used to get a random number
  67862. */
  67863. export class RandomNumberBlock extends NodeMaterialBlock {
  67864. /**
  67865. * Creates a new RandomNumberBlock
  67866. * @param name defines the block name
  67867. */
  67868. constructor(name: string);
  67869. /**
  67870. * Gets the current class name
  67871. * @returns the class name
  67872. */
  67873. getClassName(): string;
  67874. /**
  67875. * Gets the seed input component
  67876. */
  67877. get seed(): NodeMaterialConnectionPoint;
  67878. /**
  67879. * Gets the output component
  67880. */
  67881. get output(): NodeMaterialConnectionPoint;
  67882. protected _buildBlock(state: NodeMaterialBuildState): this;
  67883. }
  67884. }
  67885. declare module BABYLON {
  67886. /**
  67887. * Block used to compute arc tangent of 2 values
  67888. */
  67889. export class ArcTan2Block extends NodeMaterialBlock {
  67890. /**
  67891. * Creates a new ArcTan2Block
  67892. * @param name defines the block name
  67893. */
  67894. constructor(name: string);
  67895. /**
  67896. * Gets the current class name
  67897. * @returns the class name
  67898. */
  67899. getClassName(): string;
  67900. /**
  67901. * Gets the x operand input component
  67902. */
  67903. get x(): NodeMaterialConnectionPoint;
  67904. /**
  67905. * Gets the y operand input component
  67906. */
  67907. get y(): NodeMaterialConnectionPoint;
  67908. /**
  67909. * Gets the output component
  67910. */
  67911. get output(): NodeMaterialConnectionPoint;
  67912. protected _buildBlock(state: NodeMaterialBuildState): this;
  67913. }
  67914. }
  67915. declare module BABYLON {
  67916. /**
  67917. * Block used to smooth step a value
  67918. */
  67919. export class SmoothStepBlock extends NodeMaterialBlock {
  67920. /**
  67921. * Creates a new SmoothStepBlock
  67922. * @param name defines the block name
  67923. */
  67924. constructor(name: string);
  67925. /**
  67926. * Gets the current class name
  67927. * @returns the class name
  67928. */
  67929. getClassName(): string;
  67930. /**
  67931. * Gets the value operand input component
  67932. */
  67933. get value(): NodeMaterialConnectionPoint;
  67934. /**
  67935. * Gets the first edge operand input component
  67936. */
  67937. get edge0(): NodeMaterialConnectionPoint;
  67938. /**
  67939. * Gets the second edge operand input component
  67940. */
  67941. get edge1(): NodeMaterialConnectionPoint;
  67942. /**
  67943. * Gets the output component
  67944. */
  67945. get output(): NodeMaterialConnectionPoint;
  67946. protected _buildBlock(state: NodeMaterialBuildState): this;
  67947. }
  67948. }
  67949. declare module BABYLON {
  67950. /**
  67951. * Block used to get the reciprocal (1 / x) of a value
  67952. */
  67953. export class ReciprocalBlock extends NodeMaterialBlock {
  67954. /**
  67955. * Creates a new ReciprocalBlock
  67956. * @param name defines the block name
  67957. */
  67958. constructor(name: string);
  67959. /**
  67960. * Gets the current class name
  67961. * @returns the class name
  67962. */
  67963. getClassName(): string;
  67964. /**
  67965. * Gets the input component
  67966. */
  67967. get input(): NodeMaterialConnectionPoint;
  67968. /**
  67969. * Gets the output component
  67970. */
  67971. get output(): NodeMaterialConnectionPoint;
  67972. protected _buildBlock(state: NodeMaterialBuildState): this;
  67973. }
  67974. }
  67975. declare module BABYLON {
  67976. /**
  67977. * Block used to replace a color by another one
  67978. */
  67979. export class ReplaceColorBlock extends NodeMaterialBlock {
  67980. /**
  67981. * Creates a new ReplaceColorBlock
  67982. * @param name defines the block name
  67983. */
  67984. constructor(name: string);
  67985. /**
  67986. * Gets the current class name
  67987. * @returns the class name
  67988. */
  67989. getClassName(): string;
  67990. /**
  67991. * Gets the value input component
  67992. */
  67993. get value(): NodeMaterialConnectionPoint;
  67994. /**
  67995. * Gets the reference input component
  67996. */
  67997. get reference(): NodeMaterialConnectionPoint;
  67998. /**
  67999. * Gets the distance input component
  68000. */
  68001. get distance(): NodeMaterialConnectionPoint;
  68002. /**
  68003. * Gets the replacement input component
  68004. */
  68005. get replacement(): NodeMaterialConnectionPoint;
  68006. /**
  68007. * Gets the output component
  68008. */
  68009. get output(): NodeMaterialConnectionPoint;
  68010. protected _buildBlock(state: NodeMaterialBuildState): this;
  68011. }
  68012. }
  68013. declare module BABYLON {
  68014. /**
  68015. * Block used to posterize a value
  68016. * @see https://en.wikipedia.org/wiki/Posterization
  68017. */
  68018. export class PosterizeBlock extends NodeMaterialBlock {
  68019. /**
  68020. * Creates a new PosterizeBlock
  68021. * @param name defines the block name
  68022. */
  68023. constructor(name: string);
  68024. /**
  68025. * Gets the current class name
  68026. * @returns the class name
  68027. */
  68028. getClassName(): string;
  68029. /**
  68030. * Gets the value input component
  68031. */
  68032. get value(): NodeMaterialConnectionPoint;
  68033. /**
  68034. * Gets the steps input component
  68035. */
  68036. get steps(): NodeMaterialConnectionPoint;
  68037. /**
  68038. * Gets the output component
  68039. */
  68040. get output(): NodeMaterialConnectionPoint;
  68041. protected _buildBlock(state: NodeMaterialBuildState): this;
  68042. }
  68043. }
  68044. declare module BABYLON {
  68045. /**
  68046. * Operations supported by the Wave block
  68047. */
  68048. export enum WaveBlockKind {
  68049. /** SawTooth */
  68050. SawTooth = 0,
  68051. /** Square */
  68052. Square = 1,
  68053. /** Triangle */
  68054. Triangle = 2
  68055. }
  68056. /**
  68057. * Block used to apply wave operation to floats
  68058. */
  68059. export class WaveBlock extends NodeMaterialBlock {
  68060. /**
  68061. * Gets or sets the kibnd of wave to be applied by the block
  68062. */
  68063. kind: WaveBlockKind;
  68064. /**
  68065. * Creates a new WaveBlock
  68066. * @param name defines the block name
  68067. */
  68068. constructor(name: string);
  68069. /**
  68070. * Gets the current class name
  68071. * @returns the class name
  68072. */
  68073. getClassName(): string;
  68074. /**
  68075. * Gets the input component
  68076. */
  68077. get input(): NodeMaterialConnectionPoint;
  68078. /**
  68079. * Gets the output component
  68080. */
  68081. get output(): NodeMaterialConnectionPoint;
  68082. protected _buildBlock(state: NodeMaterialBuildState): this;
  68083. serialize(): any;
  68084. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68085. }
  68086. }
  68087. declare module BABYLON {
  68088. /**
  68089. * Class used to store a color step for the GradientBlock
  68090. */
  68091. export class GradientBlockColorStep {
  68092. private _step;
  68093. /**
  68094. * Gets value indicating which step this color is associated with (between 0 and 1)
  68095. */
  68096. get step(): number;
  68097. /**
  68098. * Sets a value indicating which step this color is associated with (between 0 and 1)
  68099. */
  68100. set step(val: number);
  68101. private _color;
  68102. /**
  68103. * Gets the color associated with this step
  68104. */
  68105. get color(): Color3;
  68106. /**
  68107. * Sets the color associated with this step
  68108. */
  68109. set color(val: Color3);
  68110. /**
  68111. * Creates a new GradientBlockColorStep
  68112. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  68113. * @param color defines the color associated with this step
  68114. */
  68115. constructor(step: number, color: Color3);
  68116. }
  68117. /**
  68118. * Block used to return a color from a gradient based on an input value between 0 and 1
  68119. */
  68120. export class GradientBlock extends NodeMaterialBlock {
  68121. /**
  68122. * Gets or sets the list of color steps
  68123. */
  68124. colorSteps: GradientBlockColorStep[];
  68125. /** Gets an observable raised when the value is changed */
  68126. onValueChangedObservable: Observable<GradientBlock>;
  68127. /** calls observable when the value is changed*/
  68128. colorStepsUpdated(): void;
  68129. /**
  68130. * Creates a new GradientBlock
  68131. * @param name defines the block name
  68132. */
  68133. constructor(name: string);
  68134. /**
  68135. * Gets the current class name
  68136. * @returns the class name
  68137. */
  68138. getClassName(): string;
  68139. /**
  68140. * Gets the gradient input component
  68141. */
  68142. get gradient(): NodeMaterialConnectionPoint;
  68143. /**
  68144. * Gets the output component
  68145. */
  68146. get output(): NodeMaterialConnectionPoint;
  68147. private _writeColorConstant;
  68148. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68149. serialize(): any;
  68150. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68151. protected _dumpPropertiesCode(): string;
  68152. }
  68153. }
  68154. declare module BABYLON {
  68155. /**
  68156. * Block used to normalize lerp between 2 values
  68157. */
  68158. export class NLerpBlock extends NodeMaterialBlock {
  68159. /**
  68160. * Creates a new NLerpBlock
  68161. * @param name defines the block name
  68162. */
  68163. constructor(name: string);
  68164. /**
  68165. * Gets the current class name
  68166. * @returns the class name
  68167. */
  68168. getClassName(): string;
  68169. /**
  68170. * Gets the left operand input component
  68171. */
  68172. get left(): NodeMaterialConnectionPoint;
  68173. /**
  68174. * Gets the right operand input component
  68175. */
  68176. get right(): NodeMaterialConnectionPoint;
  68177. /**
  68178. * Gets the gradient operand input component
  68179. */
  68180. get gradient(): NodeMaterialConnectionPoint;
  68181. /**
  68182. * Gets the output component
  68183. */
  68184. get output(): NodeMaterialConnectionPoint;
  68185. protected _buildBlock(state: NodeMaterialBuildState): this;
  68186. }
  68187. }
  68188. declare module BABYLON {
  68189. /**
  68190. * block used to Generate a Worley Noise 3D Noise Pattern
  68191. */
  68192. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  68193. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  68194. manhattanDistance: boolean;
  68195. /**
  68196. * Creates a new WorleyNoise3DBlock
  68197. * @param name defines the block name
  68198. */
  68199. constructor(name: string);
  68200. /**
  68201. * Gets the current class name
  68202. * @returns the class name
  68203. */
  68204. getClassName(): string;
  68205. /**
  68206. * Gets the seed input component
  68207. */
  68208. get seed(): NodeMaterialConnectionPoint;
  68209. /**
  68210. * Gets the jitter input component
  68211. */
  68212. get jitter(): NodeMaterialConnectionPoint;
  68213. /**
  68214. * Gets the output component
  68215. */
  68216. get output(): NodeMaterialConnectionPoint;
  68217. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68218. /**
  68219. * Exposes the properties to the UI?
  68220. */
  68221. protected _dumpPropertiesCode(): string;
  68222. /**
  68223. * Exposes the properties to the Seralize?
  68224. */
  68225. serialize(): any;
  68226. /**
  68227. * Exposes the properties to the deseralize?
  68228. */
  68229. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68230. }
  68231. }
  68232. declare module BABYLON {
  68233. /**
  68234. * block used to Generate a Simplex Perlin 3d Noise Pattern
  68235. */
  68236. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  68237. /**
  68238. * Creates a new SimplexPerlin3DBlock
  68239. * @param name defines the block name
  68240. */
  68241. constructor(name: string);
  68242. /**
  68243. * Gets the current class name
  68244. * @returns the class name
  68245. */
  68246. getClassName(): string;
  68247. /**
  68248. * Gets the seed operand input component
  68249. */
  68250. get seed(): NodeMaterialConnectionPoint;
  68251. /**
  68252. * Gets the output component
  68253. */
  68254. get output(): NodeMaterialConnectionPoint;
  68255. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68256. }
  68257. }
  68258. declare module BABYLON {
  68259. /**
  68260. * Block used to blend normals
  68261. */
  68262. export class NormalBlendBlock extends NodeMaterialBlock {
  68263. /**
  68264. * Creates a new NormalBlendBlock
  68265. * @param name defines the block name
  68266. */
  68267. constructor(name: string);
  68268. /**
  68269. * Gets the current class name
  68270. * @returns the class name
  68271. */
  68272. getClassName(): string;
  68273. /**
  68274. * Gets the first input component
  68275. */
  68276. get normalMap0(): NodeMaterialConnectionPoint;
  68277. /**
  68278. * Gets the second input component
  68279. */
  68280. get normalMap1(): NodeMaterialConnectionPoint;
  68281. /**
  68282. * Gets the output component
  68283. */
  68284. get output(): NodeMaterialConnectionPoint;
  68285. protected _buildBlock(state: NodeMaterialBuildState): this;
  68286. }
  68287. }
  68288. declare module BABYLON {
  68289. /**
  68290. * Block used to rotate a 2d vector by a given angle
  68291. */
  68292. export class Rotate2dBlock extends NodeMaterialBlock {
  68293. /**
  68294. * Creates a new Rotate2dBlock
  68295. * @param name defines the block name
  68296. */
  68297. constructor(name: string);
  68298. /**
  68299. * Gets the current class name
  68300. * @returns the class name
  68301. */
  68302. getClassName(): string;
  68303. /**
  68304. * Gets the input vector
  68305. */
  68306. get input(): NodeMaterialConnectionPoint;
  68307. /**
  68308. * Gets the input angle
  68309. */
  68310. get angle(): NodeMaterialConnectionPoint;
  68311. /**
  68312. * Gets the output component
  68313. */
  68314. get output(): NodeMaterialConnectionPoint;
  68315. autoConfigure(material: NodeMaterial): void;
  68316. protected _buildBlock(state: NodeMaterialBuildState): this;
  68317. }
  68318. }
  68319. declare module BABYLON {
  68320. /**
  68321. * Block used to get the reflected vector from a direction and a normal
  68322. */
  68323. export class ReflectBlock extends NodeMaterialBlock {
  68324. /**
  68325. * Creates a new ReflectBlock
  68326. * @param name defines the block name
  68327. */
  68328. constructor(name: string);
  68329. /**
  68330. * Gets the current class name
  68331. * @returns the class name
  68332. */
  68333. getClassName(): string;
  68334. /**
  68335. * Gets the incident component
  68336. */
  68337. get incident(): NodeMaterialConnectionPoint;
  68338. /**
  68339. * Gets the normal component
  68340. */
  68341. get normal(): NodeMaterialConnectionPoint;
  68342. /**
  68343. * Gets the output component
  68344. */
  68345. get output(): NodeMaterialConnectionPoint;
  68346. protected _buildBlock(state: NodeMaterialBuildState): this;
  68347. }
  68348. }
  68349. declare module BABYLON {
  68350. /**
  68351. * Block used to get the refracted vector from a direction and a normal
  68352. */
  68353. export class RefractBlock extends NodeMaterialBlock {
  68354. /**
  68355. * Creates a new RefractBlock
  68356. * @param name defines the block name
  68357. */
  68358. constructor(name: string);
  68359. /**
  68360. * Gets the current class name
  68361. * @returns the class name
  68362. */
  68363. getClassName(): string;
  68364. /**
  68365. * Gets the incident component
  68366. */
  68367. get incident(): NodeMaterialConnectionPoint;
  68368. /**
  68369. * Gets the normal component
  68370. */
  68371. get normal(): NodeMaterialConnectionPoint;
  68372. /**
  68373. * Gets the index of refraction component
  68374. */
  68375. get ior(): 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 desaturate a color
  68386. */
  68387. export class DesaturateBlock extends NodeMaterialBlock {
  68388. /**
  68389. * Creates a new DesaturateBlock
  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 color operand input component
  68400. */
  68401. get color(): NodeMaterialConnectionPoint;
  68402. /**
  68403. * Gets the level operand input component
  68404. */
  68405. get level(): NodeMaterialConnectionPoint;
  68406. /**
  68407. * Gets the output component
  68408. */
  68409. get output(): NodeMaterialConnectionPoint;
  68410. protected _buildBlock(state: NodeMaterialBuildState): this;
  68411. }
  68412. }
  68413. declare module BABYLON {
  68414. /**
  68415. * Block used to implement the reflection module of the PBR material
  68416. */
  68417. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  68418. /** @hidden */
  68419. _defineLODReflectionAlpha: string;
  68420. /** @hidden */
  68421. _defineLinearSpecularReflection: string;
  68422. private _vEnvironmentIrradianceName;
  68423. /** @hidden */
  68424. _vReflectionMicrosurfaceInfosName: string;
  68425. /** @hidden */
  68426. _vReflectionInfosName: string;
  68427. /** @hidden */
  68428. _vReflectionFilteringInfoName: string;
  68429. private _scene;
  68430. /**
  68431. * The properties below are set by the main PBR block prior to calling methods of this class.
  68432. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68433. * It's less burden on the user side in the editor part.
  68434. */
  68435. /** @hidden */
  68436. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68437. /** @hidden */
  68438. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68439. /** @hidden */
  68440. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  68441. /** @hidden */
  68442. viewConnectionPoint: NodeMaterialConnectionPoint;
  68443. /**
  68444. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  68445. * diffuse part of the IBL.
  68446. */
  68447. useSphericalHarmonics: boolean;
  68448. /**
  68449. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  68450. */
  68451. forceIrradianceInFragment: boolean;
  68452. /**
  68453. * Create a new ReflectionBlock
  68454. * @param name defines the block name
  68455. */
  68456. constructor(name: string);
  68457. /**
  68458. * Gets the current class name
  68459. * @returns the class name
  68460. */
  68461. getClassName(): string;
  68462. /**
  68463. * Gets the position input component
  68464. */
  68465. get position(): NodeMaterialConnectionPoint;
  68466. /**
  68467. * Gets the world position input component
  68468. */
  68469. get worldPosition(): NodeMaterialConnectionPoint;
  68470. /**
  68471. * Gets the world normal input component
  68472. */
  68473. get worldNormal(): NodeMaterialConnectionPoint;
  68474. /**
  68475. * Gets the world input component
  68476. */
  68477. get world(): NodeMaterialConnectionPoint;
  68478. /**
  68479. * Gets the camera (or eye) position component
  68480. */
  68481. get cameraPosition(): NodeMaterialConnectionPoint;
  68482. /**
  68483. * Gets the view input component
  68484. */
  68485. get view(): NodeMaterialConnectionPoint;
  68486. /**
  68487. * Gets the color input component
  68488. */
  68489. get color(): NodeMaterialConnectionPoint;
  68490. /**
  68491. * Gets the reflection object output component
  68492. */
  68493. get reflection(): NodeMaterialConnectionPoint;
  68494. /**
  68495. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  68496. */
  68497. get hasTexture(): boolean;
  68498. /**
  68499. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  68500. */
  68501. get reflectionColor(): string;
  68502. protected _getTexture(): Nullable<BaseTexture>;
  68503. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68504. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68505. /**
  68506. * Gets the code to inject in the vertex shader
  68507. * @param state current state of the node material building
  68508. * @returns the shader code
  68509. */
  68510. handleVertexSide(state: NodeMaterialBuildState): string;
  68511. /**
  68512. * Gets the main code of the block (fragment side)
  68513. * @param state current state of the node material building
  68514. * @param normalVarName name of the existing variable corresponding to the normal
  68515. * @returns the shader code
  68516. */
  68517. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  68518. protected _buildBlock(state: NodeMaterialBuildState): this;
  68519. protected _dumpPropertiesCode(): string;
  68520. serialize(): any;
  68521. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68522. }
  68523. }
  68524. declare module BABYLON {
  68525. /**
  68526. * Block used to implement the sheen module of the PBR material
  68527. */
  68528. export class SheenBlock extends NodeMaterialBlock {
  68529. /**
  68530. * Create a new SheenBlock
  68531. * @param name defines the block name
  68532. */
  68533. constructor(name: string);
  68534. /**
  68535. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  68536. * It allows the strength of the sheen effect to not depend on the base color of the material,
  68537. * making it easier to setup and tweak the effect
  68538. */
  68539. albedoScaling: boolean;
  68540. /**
  68541. * Defines if the sheen is linked to the sheen color.
  68542. */
  68543. linkSheenWithAlbedo: boolean;
  68544. /**
  68545. * Initialize the block and prepare the context for build
  68546. * @param state defines the state that will be used for the build
  68547. */
  68548. initialize(state: NodeMaterialBuildState): void;
  68549. /**
  68550. * Gets the current class name
  68551. * @returns the class name
  68552. */
  68553. getClassName(): string;
  68554. /**
  68555. * Gets the intensity input component
  68556. */
  68557. get intensity(): NodeMaterialConnectionPoint;
  68558. /**
  68559. * Gets the color input component
  68560. */
  68561. get color(): NodeMaterialConnectionPoint;
  68562. /**
  68563. * Gets the roughness input component
  68564. */
  68565. get roughness(): NodeMaterialConnectionPoint;
  68566. /**
  68567. * Gets the sheen object output component
  68568. */
  68569. get sheen(): NodeMaterialConnectionPoint;
  68570. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68571. /**
  68572. * Gets the main code of the block (fragment side)
  68573. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68574. * @returns the shader code
  68575. */
  68576. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  68577. protected _buildBlock(state: NodeMaterialBuildState): this;
  68578. protected _dumpPropertiesCode(): string;
  68579. serialize(): any;
  68580. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68581. }
  68582. }
  68583. declare module BABYLON {
  68584. /**
  68585. * Block used to implement the anisotropy module of the PBR material
  68586. */
  68587. export class AnisotropyBlock extends NodeMaterialBlock {
  68588. /**
  68589. * The two properties below are set by the main PBR block prior to calling methods of this class.
  68590. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68591. * It's less burden on the user side in the editor part.
  68592. */
  68593. /** @hidden */
  68594. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68595. /** @hidden */
  68596. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68597. /**
  68598. * Create a new AnisotropyBlock
  68599. * @param name defines the block name
  68600. */
  68601. constructor(name: string);
  68602. /**
  68603. * Initialize the block and prepare the context for build
  68604. * @param state defines the state that will be used for the build
  68605. */
  68606. initialize(state: NodeMaterialBuildState): void;
  68607. /**
  68608. * Gets the current class name
  68609. * @returns the class name
  68610. */
  68611. getClassName(): string;
  68612. /**
  68613. * Gets the intensity input component
  68614. */
  68615. get intensity(): NodeMaterialConnectionPoint;
  68616. /**
  68617. * Gets the direction input component
  68618. */
  68619. get direction(): NodeMaterialConnectionPoint;
  68620. /**
  68621. * Gets the uv input component
  68622. */
  68623. get uv(): NodeMaterialConnectionPoint;
  68624. /**
  68625. * Gets the worldTangent input component
  68626. */
  68627. get worldTangent(): NodeMaterialConnectionPoint;
  68628. /**
  68629. * Gets the anisotropy object output component
  68630. */
  68631. get anisotropy(): NodeMaterialConnectionPoint;
  68632. private _generateTBNSpace;
  68633. /**
  68634. * Gets the main code of the block (fragment side)
  68635. * @param state current state of the node material building
  68636. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68637. * @returns the shader code
  68638. */
  68639. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  68640. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68641. protected _buildBlock(state: NodeMaterialBuildState): this;
  68642. }
  68643. }
  68644. declare module BABYLON {
  68645. /**
  68646. * Block used to implement the clear coat module of the PBR material
  68647. */
  68648. export class ClearCoatBlock extends NodeMaterialBlock {
  68649. private _scene;
  68650. /**
  68651. * Create a new ClearCoatBlock
  68652. * @param name defines the block name
  68653. */
  68654. constructor(name: string);
  68655. /**
  68656. * Defines if the F0 value should be remapped to account for the interface change in the material.
  68657. */
  68658. remapF0OnInterfaceChange: boolean;
  68659. /**
  68660. * Initialize the block and prepare the context for build
  68661. * @param state defines the state that will be used for the build
  68662. */
  68663. initialize(state: NodeMaterialBuildState): void;
  68664. /**
  68665. * Gets the current class name
  68666. * @returns the class name
  68667. */
  68668. getClassName(): string;
  68669. /**
  68670. * Gets the intensity input component
  68671. */
  68672. get intensity(): NodeMaterialConnectionPoint;
  68673. /**
  68674. * Gets the roughness input component
  68675. */
  68676. get roughness(): NodeMaterialConnectionPoint;
  68677. /**
  68678. * Gets the ior input component
  68679. */
  68680. get indexOfRefraction(): NodeMaterialConnectionPoint;
  68681. /**
  68682. * Gets the bump texture input component
  68683. */
  68684. get normalMapColor(): NodeMaterialConnectionPoint;
  68685. /**
  68686. * Gets the uv input component
  68687. */
  68688. get uv(): NodeMaterialConnectionPoint;
  68689. /**
  68690. * Gets the tint color input component
  68691. */
  68692. get tintColor(): NodeMaterialConnectionPoint;
  68693. /**
  68694. * Gets the tint "at distance" input component
  68695. */
  68696. get tintAtDistance(): NodeMaterialConnectionPoint;
  68697. /**
  68698. * Gets the tint thickness input component
  68699. */
  68700. get tintThickness(): NodeMaterialConnectionPoint;
  68701. /**
  68702. * Gets the world tangent input component
  68703. */
  68704. get worldTangent(): NodeMaterialConnectionPoint;
  68705. /**
  68706. * Gets the clear coat object output component
  68707. */
  68708. get clearcoat(): NodeMaterialConnectionPoint;
  68709. autoConfigure(material: NodeMaterial): void;
  68710. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68711. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68712. private _generateTBNSpace;
  68713. /**
  68714. * Gets the main code of the block (fragment side)
  68715. * @param state current state of the node material building
  68716. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  68717. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68718. * @param worldPosVarName name of the variable holding the world position
  68719. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68720. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  68721. * @param worldNormalVarName name of the variable holding the world normal
  68722. * @returns the shader code
  68723. */
  68724. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  68725. protected _buildBlock(state: NodeMaterialBuildState): this;
  68726. protected _dumpPropertiesCode(): string;
  68727. serialize(): any;
  68728. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68729. }
  68730. }
  68731. declare module BABYLON {
  68732. /**
  68733. * Block used to implement the sub surface module of the PBR material
  68734. */
  68735. export class SubSurfaceBlock extends NodeMaterialBlock {
  68736. /**
  68737. * Create a new SubSurfaceBlock
  68738. * @param name defines the block name
  68739. */
  68740. constructor(name: string);
  68741. /**
  68742. * Initialize the block and prepare the context for build
  68743. * @param state defines the state that will be used for the build
  68744. */
  68745. initialize(state: NodeMaterialBuildState): void;
  68746. /**
  68747. * Gets the current class name
  68748. * @returns the class name
  68749. */
  68750. getClassName(): string;
  68751. /**
  68752. * Gets the thickness component
  68753. */
  68754. get thickness(): NodeMaterialConnectionPoint;
  68755. /**
  68756. * Gets the tint color input component
  68757. */
  68758. get tintColor(): NodeMaterialConnectionPoint;
  68759. /**
  68760. * Gets the translucency intensity input component
  68761. */
  68762. get translucencyIntensity(): NodeMaterialConnectionPoint;
  68763. /**
  68764. * Gets the translucency diffusion distance input component
  68765. */
  68766. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  68767. /**
  68768. * Gets the refraction object parameters
  68769. */
  68770. get refraction(): NodeMaterialConnectionPoint;
  68771. /**
  68772. * Gets the sub surface object output component
  68773. */
  68774. get subsurface(): NodeMaterialConnectionPoint;
  68775. autoConfigure(material: NodeMaterial): void;
  68776. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68777. /**
  68778. * Gets the main code of the block (fragment side)
  68779. * @param state current state of the node material building
  68780. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  68781. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68782. * @param worldPosVarName name of the variable holding the world position
  68783. * @returns the shader code
  68784. */
  68785. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  68786. protected _buildBlock(state: NodeMaterialBuildState): this;
  68787. }
  68788. }
  68789. declare module BABYLON {
  68790. /**
  68791. * Block used to implement the PBR metallic/roughness model
  68792. */
  68793. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  68794. /**
  68795. * Gets or sets the light associated with this block
  68796. */
  68797. light: Nullable<Light>;
  68798. private _lightId;
  68799. private _scene;
  68800. private _environmentBRDFTexture;
  68801. private _environmentBrdfSamplerName;
  68802. private _vNormalWName;
  68803. private _invertNormalName;
  68804. private _metallicReflectanceColor;
  68805. private _metallicF0Factor;
  68806. private _vMetallicReflectanceFactorsName;
  68807. /**
  68808. * Create a new ReflectionBlock
  68809. * @param name defines the block name
  68810. */
  68811. constructor(name: string);
  68812. /**
  68813. * Intensity of the direct lights e.g. the four lights available in your scene.
  68814. * This impacts both the direct diffuse and specular highlights.
  68815. */
  68816. directIntensity: number;
  68817. /**
  68818. * Intensity of the environment e.g. how much the environment will light the object
  68819. * either through harmonics for rough material or through the refelction for shiny ones.
  68820. */
  68821. environmentIntensity: number;
  68822. /**
  68823. * This is a special control allowing the reduction of the specular highlights coming from the
  68824. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  68825. */
  68826. specularIntensity: number;
  68827. /**
  68828. * Defines the falloff type used in this material.
  68829. * It by default is Physical.
  68830. */
  68831. lightFalloff: number;
  68832. /**
  68833. * Specifies that alpha test should be used
  68834. */
  68835. useAlphaTest: boolean;
  68836. /**
  68837. * Defines the alpha limits in alpha test mode.
  68838. */
  68839. alphaTestCutoff: number;
  68840. /**
  68841. * Specifies that alpha blending should be used
  68842. */
  68843. useAlphaBlending: boolean;
  68844. /**
  68845. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  68846. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  68847. */
  68848. useRadianceOverAlpha: boolean;
  68849. /**
  68850. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  68851. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  68852. */
  68853. useSpecularOverAlpha: boolean;
  68854. /**
  68855. * Enables specular anti aliasing in the PBR shader.
  68856. * It will both interacts on the Geometry for analytical and IBL lighting.
  68857. * It also prefilter the roughness map based on the bump values.
  68858. */
  68859. enableSpecularAntiAliasing: boolean;
  68860. /**
  68861. * Enables realtime filtering on the texture.
  68862. */
  68863. realTimeFiltering: boolean;
  68864. /**
  68865. * Quality switch for realtime filtering
  68866. */
  68867. realTimeFilteringQuality: number;
  68868. /**
  68869. * Defines if the material uses energy conservation.
  68870. */
  68871. useEnergyConservation: boolean;
  68872. /**
  68873. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  68874. * too much the area relying on ambient texture to define their ambient occlusion.
  68875. */
  68876. useRadianceOcclusion: boolean;
  68877. /**
  68878. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  68879. * makes the reflect vector face the model (under horizon).
  68880. */
  68881. useHorizonOcclusion: boolean;
  68882. /**
  68883. * If set to true, no lighting calculations will be applied.
  68884. */
  68885. unlit: boolean;
  68886. /**
  68887. * Force normal to face away from face.
  68888. */
  68889. forceNormalForward: boolean;
  68890. /**
  68891. * Defines the material debug mode.
  68892. * It helps seeing only some components of the material while troubleshooting.
  68893. */
  68894. debugMode: number;
  68895. /**
  68896. * Specify from where on screen the debug mode should start.
  68897. * The value goes from -1 (full screen) to 1 (not visible)
  68898. * It helps with side by side comparison against the final render
  68899. * This defaults to 0
  68900. */
  68901. debugLimit: number;
  68902. /**
  68903. * As the default viewing range might not be enough (if the ambient is really small for instance)
  68904. * You can use the factor to better multiply the final value.
  68905. */
  68906. debugFactor: number;
  68907. /**
  68908. * Initialize the block and prepare the context for build
  68909. * @param state defines the state that will be used for the build
  68910. */
  68911. initialize(state: NodeMaterialBuildState): void;
  68912. /**
  68913. * Gets the current class name
  68914. * @returns the class name
  68915. */
  68916. getClassName(): string;
  68917. /**
  68918. * Gets the world position input component
  68919. */
  68920. get worldPosition(): NodeMaterialConnectionPoint;
  68921. /**
  68922. * Gets the world normal input component
  68923. */
  68924. get worldNormal(): NodeMaterialConnectionPoint;
  68925. /**
  68926. * Gets the view matrix parameter
  68927. */
  68928. get view(): NodeMaterialConnectionPoint;
  68929. /**
  68930. * Gets the camera position input component
  68931. */
  68932. get cameraPosition(): NodeMaterialConnectionPoint;
  68933. /**
  68934. * Gets the perturbed normal input component
  68935. */
  68936. get perturbedNormal(): NodeMaterialConnectionPoint;
  68937. /**
  68938. * Gets the base color input component
  68939. */
  68940. get baseColor(): NodeMaterialConnectionPoint;
  68941. /**
  68942. * Gets the metallic input component
  68943. */
  68944. get metallic(): NodeMaterialConnectionPoint;
  68945. /**
  68946. * Gets the roughness input component
  68947. */
  68948. get roughness(): NodeMaterialConnectionPoint;
  68949. /**
  68950. * Gets the ambient occlusion input component
  68951. */
  68952. get ambientOcc(): NodeMaterialConnectionPoint;
  68953. /**
  68954. * Gets the opacity input component
  68955. */
  68956. get opacity(): NodeMaterialConnectionPoint;
  68957. /**
  68958. * Gets the index of refraction input component
  68959. */
  68960. get indexOfRefraction(): NodeMaterialConnectionPoint;
  68961. /**
  68962. * Gets the ambient color input component
  68963. */
  68964. get ambientColor(): NodeMaterialConnectionPoint;
  68965. /**
  68966. * Gets the reflection object parameters
  68967. */
  68968. get reflection(): NodeMaterialConnectionPoint;
  68969. /**
  68970. * Gets the clear coat object parameters
  68971. */
  68972. get clearcoat(): NodeMaterialConnectionPoint;
  68973. /**
  68974. * Gets the sheen object parameters
  68975. */
  68976. get sheen(): NodeMaterialConnectionPoint;
  68977. /**
  68978. * Gets the sub surface object parameters
  68979. */
  68980. get subsurface(): NodeMaterialConnectionPoint;
  68981. /**
  68982. * Gets the anisotropy object parameters
  68983. */
  68984. get anisotropy(): NodeMaterialConnectionPoint;
  68985. /**
  68986. * Gets the ambient output component
  68987. */
  68988. get ambientClr(): NodeMaterialConnectionPoint;
  68989. /**
  68990. * Gets the diffuse output component
  68991. */
  68992. get diffuseDir(): NodeMaterialConnectionPoint;
  68993. /**
  68994. * Gets the specular output component
  68995. */
  68996. get specularDir(): NodeMaterialConnectionPoint;
  68997. /**
  68998. * Gets the clear coat output component
  68999. */
  69000. get clearcoatDir(): NodeMaterialConnectionPoint;
  69001. /**
  69002. * Gets the sheen output component
  69003. */
  69004. get sheenDir(): NodeMaterialConnectionPoint;
  69005. /**
  69006. * Gets the indirect diffuse output component
  69007. */
  69008. get diffuseIndirect(): NodeMaterialConnectionPoint;
  69009. /**
  69010. * Gets the indirect specular output component
  69011. */
  69012. get specularIndirect(): NodeMaterialConnectionPoint;
  69013. /**
  69014. * Gets the indirect clear coat output component
  69015. */
  69016. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  69017. /**
  69018. * Gets the indirect sheen output component
  69019. */
  69020. get sheenIndirect(): NodeMaterialConnectionPoint;
  69021. /**
  69022. * Gets the refraction output component
  69023. */
  69024. get refraction(): NodeMaterialConnectionPoint;
  69025. /**
  69026. * Gets the global lighting output component
  69027. */
  69028. get lighting(): NodeMaterialConnectionPoint;
  69029. /**
  69030. * Gets the shadow output component
  69031. */
  69032. get shadow(): NodeMaterialConnectionPoint;
  69033. /**
  69034. * Gets the alpha output component
  69035. */
  69036. get alpha(): NodeMaterialConnectionPoint;
  69037. autoConfigure(material: NodeMaterial): void;
  69038. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69039. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  69040. isReady(): boolean;
  69041. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69042. private _injectVertexCode;
  69043. private _getAlbedoOpacityCode;
  69044. private _getAmbientOcclusionCode;
  69045. private _getReflectivityCode;
  69046. protected _buildBlock(state: NodeMaterialBuildState): this;
  69047. protected _dumpPropertiesCode(): string;
  69048. serialize(): any;
  69049. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69050. }
  69051. }
  69052. declare module BABYLON {
  69053. /**
  69054. * Block used to compute value of one parameter modulo another
  69055. */
  69056. export class ModBlock extends NodeMaterialBlock {
  69057. /**
  69058. * Creates a new ModBlock
  69059. * @param name defines the block name
  69060. */
  69061. constructor(name: string);
  69062. /**
  69063. * Gets the current class name
  69064. * @returns the class name
  69065. */
  69066. getClassName(): string;
  69067. /**
  69068. * Gets the left operand input component
  69069. */
  69070. get left(): NodeMaterialConnectionPoint;
  69071. /**
  69072. * Gets the right operand input component
  69073. */
  69074. get right(): NodeMaterialConnectionPoint;
  69075. /**
  69076. * Gets the output component
  69077. */
  69078. get output(): NodeMaterialConnectionPoint;
  69079. protected _buildBlock(state: NodeMaterialBuildState): this;
  69080. }
  69081. }
  69082. declare module BABYLON {
  69083. /**
  69084. * Configuration for Draco compression
  69085. */
  69086. export interface IDracoCompressionConfiguration {
  69087. /**
  69088. * Configuration for the decoder.
  69089. */
  69090. decoder: {
  69091. /**
  69092. * The url to the WebAssembly module.
  69093. */
  69094. wasmUrl?: string;
  69095. /**
  69096. * The url to the WebAssembly binary.
  69097. */
  69098. wasmBinaryUrl?: string;
  69099. /**
  69100. * The url to the fallback JavaScript module.
  69101. */
  69102. fallbackUrl?: string;
  69103. };
  69104. }
  69105. /**
  69106. * Draco compression (https://google.github.io/draco/)
  69107. *
  69108. * This class wraps the Draco module.
  69109. *
  69110. * **Encoder**
  69111. *
  69112. * The encoder is not currently implemented.
  69113. *
  69114. * **Decoder**
  69115. *
  69116. * 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.
  69117. *
  69118. * To update the configuration, use the following code:
  69119. * ```javascript
  69120. * DracoCompression.Configuration = {
  69121. * decoder: {
  69122. * wasmUrl: "<url to the WebAssembly library>",
  69123. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69124. * fallbackUrl: "<url to the fallback JavaScript library>",
  69125. * }
  69126. * };
  69127. * ```
  69128. *
  69129. * Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support Webssembly or only support the JavaScript version.
  69130. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69131. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69132. *
  69133. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69134. * ```javascript
  69135. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69136. * ```
  69137. *
  69138. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69139. */
  69140. export class DracoCompression implements IDisposable {
  69141. private _workerPoolPromise?;
  69142. private _decoderModulePromise?;
  69143. /**
  69144. * The configuration. Defaults to the following urls:
  69145. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69146. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69147. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69148. */
  69149. static Configuration: IDracoCompressionConfiguration;
  69150. /**
  69151. * Returns true if the decoder configuration is available.
  69152. */
  69153. static get DecoderAvailable(): boolean;
  69154. /**
  69155. * Default number of workers to create when creating the draco compression object.
  69156. */
  69157. static DefaultNumWorkers: number;
  69158. private static GetDefaultNumWorkers;
  69159. private static _Default;
  69160. /**
  69161. * Default instance for the draco compression object.
  69162. */
  69163. static get Default(): DracoCompression;
  69164. /**
  69165. * Constructor
  69166. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69167. */
  69168. constructor(numWorkers?: number);
  69169. /**
  69170. * Stop all async operations and release resources.
  69171. */
  69172. dispose(): void;
  69173. /**
  69174. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69175. * @returns a promise that resolves when ready
  69176. */
  69177. whenReadyAsync(): Promise<void>;
  69178. /**
  69179. * Decode Draco compressed mesh data to vertex data.
  69180. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69181. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69182. * @returns A promise that resolves with the decoded vertex data
  69183. */
  69184. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  69185. [kind: string]: number;
  69186. }): Promise<VertexData>;
  69187. }
  69188. }
  69189. declare module BABYLON {
  69190. /**
  69191. * Class for building Constructive Solid Geometry
  69192. */
  69193. export class CSG {
  69194. private polygons;
  69195. /**
  69196. * The world matrix
  69197. */
  69198. matrix: Matrix;
  69199. /**
  69200. * Stores the position
  69201. */
  69202. position: Vector3;
  69203. /**
  69204. * Stores the rotation
  69205. */
  69206. rotation: Vector3;
  69207. /**
  69208. * Stores the rotation quaternion
  69209. */
  69210. rotationQuaternion: Nullable<Quaternion>;
  69211. /**
  69212. * Stores the scaling vector
  69213. */
  69214. scaling: Vector3;
  69215. /**
  69216. * Convert the Mesh to CSG
  69217. * @param mesh The Mesh to convert to CSG
  69218. * @returns A new CSG from the Mesh
  69219. */
  69220. static FromMesh(mesh: Mesh): CSG;
  69221. /**
  69222. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  69223. * @param polygons Polygons used to construct a CSG solid
  69224. */
  69225. private static FromPolygons;
  69226. /**
  69227. * Clones, or makes a deep copy, of the CSG
  69228. * @returns A new CSG
  69229. */
  69230. clone(): CSG;
  69231. /**
  69232. * Unions this CSG with another CSG
  69233. * @param csg The CSG to union against this CSG
  69234. * @returns The unioned CSG
  69235. */
  69236. union(csg: CSG): CSG;
  69237. /**
  69238. * Unions this CSG with another CSG in place
  69239. * @param csg The CSG to union against this CSG
  69240. */
  69241. unionInPlace(csg: CSG): void;
  69242. /**
  69243. * Subtracts this CSG with another CSG
  69244. * @param csg The CSG to subtract against this CSG
  69245. * @returns A new CSG
  69246. */
  69247. subtract(csg: CSG): CSG;
  69248. /**
  69249. * Subtracts this CSG with another CSG in place
  69250. * @param csg The CSG to subtact against this CSG
  69251. */
  69252. subtractInPlace(csg: CSG): void;
  69253. /**
  69254. * Intersect this CSG with another CSG
  69255. * @param csg The CSG to intersect against this CSG
  69256. * @returns A new CSG
  69257. */
  69258. intersect(csg: CSG): CSG;
  69259. /**
  69260. * Intersects this CSG with another CSG in place
  69261. * @param csg The CSG to intersect against this CSG
  69262. */
  69263. intersectInPlace(csg: CSG): void;
  69264. /**
  69265. * Return a new CSG solid with solid and empty space switched. This solid is
  69266. * not modified.
  69267. * @returns A new CSG solid with solid and empty space switched
  69268. */
  69269. inverse(): CSG;
  69270. /**
  69271. * Inverses the CSG in place
  69272. */
  69273. inverseInPlace(): void;
  69274. /**
  69275. * This is used to keep meshes transformations so they can be restored
  69276. * when we build back a Babylon Mesh
  69277. * NB : All CSG operations are performed in world coordinates
  69278. * @param csg The CSG to copy the transform attributes from
  69279. * @returns This CSG
  69280. */
  69281. copyTransformAttributes(csg: CSG): CSG;
  69282. /**
  69283. * Build Raw mesh from CSG
  69284. * Coordinates here are in world space
  69285. * @param name The name of the mesh geometry
  69286. * @param scene The Scene
  69287. * @param keepSubMeshes Specifies if the submeshes should be kept
  69288. * @returns A new Mesh
  69289. */
  69290. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69291. /**
  69292. * Build Mesh from CSG taking material and transforms into account
  69293. * @param name The name of the Mesh
  69294. * @param material The material of the Mesh
  69295. * @param scene The Scene
  69296. * @param keepSubMeshes Specifies if submeshes should be kept
  69297. * @returns The new Mesh
  69298. */
  69299. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69300. }
  69301. }
  69302. declare module BABYLON {
  69303. /**
  69304. * Class used to create a trail following a mesh
  69305. */
  69306. export class TrailMesh extends Mesh {
  69307. private _generator;
  69308. private _autoStart;
  69309. private _running;
  69310. private _diameter;
  69311. private _length;
  69312. private _sectionPolygonPointsCount;
  69313. private _sectionVectors;
  69314. private _sectionNormalVectors;
  69315. private _beforeRenderObserver;
  69316. /**
  69317. * @constructor
  69318. * @param name The value used by scene.getMeshByName() to do a lookup.
  69319. * @param generator The mesh or transform node to generate a trail.
  69320. * @param scene The scene to add this mesh to.
  69321. * @param diameter Diameter of trailing mesh. Default is 1.
  69322. * @param length Length of trailing mesh. Default is 60.
  69323. * @param autoStart Automatically start trailing mesh. Default true.
  69324. */
  69325. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  69326. /**
  69327. * "TrailMesh"
  69328. * @returns "TrailMesh"
  69329. */
  69330. getClassName(): string;
  69331. private _createMesh;
  69332. /**
  69333. * Start trailing mesh.
  69334. */
  69335. start(): void;
  69336. /**
  69337. * Stop trailing mesh.
  69338. */
  69339. stop(): void;
  69340. /**
  69341. * Update trailing mesh geometry.
  69342. */
  69343. update(): void;
  69344. /**
  69345. * Returns a new TrailMesh object.
  69346. * @param name is a string, the name given to the new mesh
  69347. * @param newGenerator use new generator object for cloned trail mesh
  69348. * @returns a new mesh
  69349. */
  69350. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  69351. /**
  69352. * Serializes this trail mesh
  69353. * @param serializationObject object to write serialization to
  69354. */
  69355. serialize(serializationObject: any): void;
  69356. /**
  69357. * Parses a serialized trail mesh
  69358. * @param parsedMesh the serialized mesh
  69359. * @param scene the scene to create the trail mesh in
  69360. * @returns the created trail mesh
  69361. */
  69362. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  69363. }
  69364. }
  69365. declare module BABYLON {
  69366. /**
  69367. * Class containing static functions to help procedurally build meshes
  69368. */
  69369. export class TiledBoxBuilder {
  69370. /**
  69371. * Creates a box mesh
  69372. * 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)
  69373. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69375. * * 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
  69376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69377. * @param name defines the name of the mesh
  69378. * @param options defines the options used to create the mesh
  69379. * @param scene defines the hosting scene
  69380. * @returns the box mesh
  69381. */
  69382. static CreateTiledBox(name: string, options: {
  69383. pattern?: number;
  69384. width?: number;
  69385. height?: number;
  69386. depth?: number;
  69387. tileSize?: number;
  69388. tileWidth?: number;
  69389. tileHeight?: number;
  69390. alignHorizontal?: number;
  69391. alignVertical?: number;
  69392. faceUV?: Vector4[];
  69393. faceColors?: Color4[];
  69394. sideOrientation?: number;
  69395. updatable?: boolean;
  69396. }, scene?: Nullable<Scene>): Mesh;
  69397. }
  69398. }
  69399. declare module BABYLON {
  69400. /**
  69401. * Class containing static functions to help procedurally build meshes
  69402. */
  69403. export class TorusKnotBuilder {
  69404. /**
  69405. * Creates a torus knot mesh
  69406. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69407. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69408. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69409. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69410. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69411. * * 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
  69412. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69413. * @param name defines the name of the mesh
  69414. * @param options defines the options used to create the mesh
  69415. * @param scene defines the hosting scene
  69416. * @returns the torus knot mesh
  69417. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69418. */
  69419. static CreateTorusKnot(name: string, options: {
  69420. radius?: number;
  69421. tube?: number;
  69422. radialSegments?: number;
  69423. tubularSegments?: number;
  69424. p?: number;
  69425. q?: number;
  69426. updatable?: boolean;
  69427. sideOrientation?: number;
  69428. frontUVs?: Vector4;
  69429. backUVs?: Vector4;
  69430. }, scene: any): Mesh;
  69431. }
  69432. }
  69433. declare module BABYLON {
  69434. /**
  69435. * Polygon
  69436. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  69437. */
  69438. export class Polygon {
  69439. /**
  69440. * Creates a rectangle
  69441. * @param xmin bottom X coord
  69442. * @param ymin bottom Y coord
  69443. * @param xmax top X coord
  69444. * @param ymax top Y coord
  69445. * @returns points that make the resulting rectation
  69446. */
  69447. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  69448. /**
  69449. * Creates a circle
  69450. * @param radius radius of circle
  69451. * @param cx scale in x
  69452. * @param cy scale in y
  69453. * @param numberOfSides number of sides that make up the circle
  69454. * @returns points that make the resulting circle
  69455. */
  69456. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  69457. /**
  69458. * Creates a polygon from input string
  69459. * @param input Input polygon data
  69460. * @returns the parsed points
  69461. */
  69462. static Parse(input: string): Vector2[];
  69463. /**
  69464. * Starts building a polygon from x and y coordinates
  69465. * @param x x coordinate
  69466. * @param y y coordinate
  69467. * @returns the started path2
  69468. */
  69469. static StartingAt(x: number, y: number): Path2;
  69470. }
  69471. /**
  69472. * Builds a polygon
  69473. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  69474. */
  69475. export class PolygonMeshBuilder {
  69476. private _points;
  69477. private _outlinepoints;
  69478. private _holes;
  69479. private _name;
  69480. private _scene;
  69481. private _epoints;
  69482. private _eholes;
  69483. private _addToepoint;
  69484. /**
  69485. * Babylon reference to the earcut plugin.
  69486. */
  69487. bjsEarcut: any;
  69488. /**
  69489. * Creates a PolygonMeshBuilder
  69490. * @param name name of the builder
  69491. * @param contours Path of the polygon
  69492. * @param scene scene to add to when creating the mesh
  69493. * @param earcutInjection can be used to inject your own earcut reference
  69494. */
  69495. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  69496. /**
  69497. * Adds a whole within the polygon
  69498. * @param hole Array of points defining the hole
  69499. * @returns this
  69500. */
  69501. addHole(hole: Vector2[]): PolygonMeshBuilder;
  69502. /**
  69503. * Creates the polygon
  69504. * @param updatable If the mesh should be updatable
  69505. * @param depth The depth of the mesh created
  69506. * @returns the created mesh
  69507. */
  69508. build(updatable?: boolean, depth?: number): Mesh;
  69509. /**
  69510. * Creates the polygon
  69511. * @param depth The depth of the mesh created
  69512. * @returns the created VertexData
  69513. */
  69514. buildVertexData(depth?: number): VertexData;
  69515. /**
  69516. * Adds a side to the polygon
  69517. * @param positions points that make the polygon
  69518. * @param normals normals of the polygon
  69519. * @param uvs uvs of the polygon
  69520. * @param indices indices of the polygon
  69521. * @param bounds bounds of the polygon
  69522. * @param points points of the polygon
  69523. * @param depth depth of the polygon
  69524. * @param flip flip of the polygon
  69525. */
  69526. private addSide;
  69527. }
  69528. }
  69529. declare module BABYLON {
  69530. /**
  69531. * Class containing static functions to help procedurally build meshes
  69532. */
  69533. export class PolygonBuilder {
  69534. /**
  69535. * Creates a polygon mesh
  69536. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69537. * * 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
  69538. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69540. * * 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)
  69541. * * Remember you can only change the shape positions, not their number when updating a polygon
  69542. * @param name defines the name of the mesh
  69543. * @param options defines the options used to create the mesh
  69544. * @param scene defines the hosting scene
  69545. * @param earcutInjection can be used to inject your own earcut reference
  69546. * @returns the polygon mesh
  69547. */
  69548. static CreatePolygon(name: string, options: {
  69549. shape: Vector3[];
  69550. holes?: Vector3[][];
  69551. depth?: number;
  69552. faceUV?: Vector4[];
  69553. faceColors?: Color4[];
  69554. updatable?: boolean;
  69555. sideOrientation?: number;
  69556. frontUVs?: Vector4;
  69557. backUVs?: Vector4;
  69558. wrap?: boolean;
  69559. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69560. /**
  69561. * Creates an extruded polygon mesh, with depth in the Y direction.
  69562. * * 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)
  69563. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69564. * @param name defines the name of the mesh
  69565. * @param options defines the options used to create the mesh
  69566. * @param scene defines the hosting scene
  69567. * @param earcutInjection can be used to inject your own earcut reference
  69568. * @returns the polygon mesh
  69569. */
  69570. static ExtrudePolygon(name: string, options: {
  69571. shape: Vector3[];
  69572. holes?: Vector3[][];
  69573. depth?: number;
  69574. faceUV?: Vector4[];
  69575. faceColors?: Color4[];
  69576. updatable?: boolean;
  69577. sideOrientation?: number;
  69578. frontUVs?: Vector4;
  69579. backUVs?: Vector4;
  69580. wrap?: boolean;
  69581. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69582. }
  69583. }
  69584. declare module BABYLON {
  69585. /**
  69586. * Class containing static functions to help procedurally build meshes
  69587. */
  69588. export class LatheBuilder {
  69589. /**
  69590. * Creates lathe mesh.
  69591. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69592. * * 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
  69593. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69594. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69595. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69596. * * 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
  69597. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69598. * * 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
  69599. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69600. * * 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
  69601. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69603. * @param name defines the name of the mesh
  69604. * @param options defines the options used to create the mesh
  69605. * @param scene defines the hosting scene
  69606. * @returns the lathe mesh
  69607. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69608. */
  69609. static CreateLathe(name: string, options: {
  69610. shape: Vector3[];
  69611. radius?: number;
  69612. tessellation?: number;
  69613. clip?: number;
  69614. arc?: number;
  69615. closed?: boolean;
  69616. updatable?: boolean;
  69617. sideOrientation?: number;
  69618. frontUVs?: Vector4;
  69619. backUVs?: Vector4;
  69620. cap?: number;
  69621. invertUV?: boolean;
  69622. }, scene?: Nullable<Scene>): Mesh;
  69623. }
  69624. }
  69625. declare module BABYLON {
  69626. /**
  69627. * Class containing static functions to help procedurally build meshes
  69628. */
  69629. export class TiledPlaneBuilder {
  69630. /**
  69631. * Creates a tiled plane mesh
  69632. * * The parameter `pattern` will, depending on value, do nothing or
  69633. * * * flip (reflect about central vertical) alternate tiles across and up
  69634. * * * flip every tile on alternate rows
  69635. * * * rotate (180 degs) alternate tiles across and up
  69636. * * * rotate every tile on alternate rows
  69637. * * * flip and rotate alternate tiles across and up
  69638. * * * flip and rotate every tile on alternate rows
  69639. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69640. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69641. * * 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
  69642. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69643. * * 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)
  69644. * * 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)
  69645. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69646. * @param name defines the name of the mesh
  69647. * @param options defines the options used to create the mesh
  69648. * @param scene defines the hosting scene
  69649. * @returns the box mesh
  69650. */
  69651. static CreateTiledPlane(name: string, options: {
  69652. pattern?: number;
  69653. tileSize?: number;
  69654. tileWidth?: number;
  69655. tileHeight?: number;
  69656. size?: number;
  69657. width?: number;
  69658. height?: number;
  69659. alignHorizontal?: number;
  69660. alignVertical?: number;
  69661. sideOrientation?: number;
  69662. frontUVs?: Vector4;
  69663. backUVs?: Vector4;
  69664. updatable?: boolean;
  69665. }, scene?: Nullable<Scene>): Mesh;
  69666. }
  69667. }
  69668. declare module BABYLON {
  69669. /**
  69670. * Class containing static functions to help procedurally build meshes
  69671. */
  69672. export class TubeBuilder {
  69673. /**
  69674. * Creates a tube mesh.
  69675. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69676. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69677. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69678. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69679. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69680. * * 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)
  69681. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69682. * * 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
  69683. * * 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
  69684. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69685. * * 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
  69686. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69688. * @param name defines the name of the mesh
  69689. * @param options defines the options used to create the mesh
  69690. * @param scene defines the hosting scene
  69691. * @returns the tube mesh
  69692. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69693. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69694. */
  69695. static CreateTube(name: string, options: {
  69696. path: Vector3[];
  69697. radius?: number;
  69698. tessellation?: number;
  69699. radiusFunction?: {
  69700. (i: number, distance: number): number;
  69701. };
  69702. cap?: number;
  69703. arc?: number;
  69704. updatable?: boolean;
  69705. sideOrientation?: number;
  69706. frontUVs?: Vector4;
  69707. backUVs?: Vector4;
  69708. instance?: Mesh;
  69709. invertUV?: boolean;
  69710. }, scene?: Nullable<Scene>): Mesh;
  69711. }
  69712. }
  69713. declare module BABYLON {
  69714. /**
  69715. * Class containing static functions to help procedurally build meshes
  69716. */
  69717. export class IcoSphereBuilder {
  69718. /**
  69719. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69720. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69721. * * 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`)
  69722. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69723. * * 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
  69724. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69725. * * 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
  69726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69727. * @param name defines the name of the mesh
  69728. * @param options defines the options used to create the mesh
  69729. * @param scene defines the hosting scene
  69730. * @returns the icosahedron mesh
  69731. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69732. */
  69733. static CreateIcoSphere(name: string, options: {
  69734. radius?: number;
  69735. radiusX?: number;
  69736. radiusY?: number;
  69737. radiusZ?: number;
  69738. flat?: boolean;
  69739. subdivisions?: number;
  69740. sideOrientation?: number;
  69741. frontUVs?: Vector4;
  69742. backUVs?: Vector4;
  69743. updatable?: boolean;
  69744. }, scene?: Nullable<Scene>): Mesh;
  69745. }
  69746. }
  69747. declare module BABYLON {
  69748. /**
  69749. * Class containing static functions to help procedurally build meshes
  69750. */
  69751. export class DecalBuilder {
  69752. /**
  69753. * Creates a decal mesh.
  69754. * 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
  69755. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69756. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69757. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69758. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69759. * @param name defines the name of the mesh
  69760. * @param sourceMesh defines the mesh where the decal must be applied
  69761. * @param options defines the options used to create the mesh
  69762. * @param scene defines the hosting scene
  69763. * @returns the decal mesh
  69764. * @see https://doc.babylonjs.com/how_to/decals
  69765. */
  69766. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69767. position?: Vector3;
  69768. normal?: Vector3;
  69769. size?: Vector3;
  69770. angle?: number;
  69771. }): Mesh;
  69772. }
  69773. }
  69774. declare module BABYLON {
  69775. /**
  69776. * Class containing static functions to help procedurally build meshes
  69777. */
  69778. export class MeshBuilder {
  69779. /**
  69780. * Creates a box mesh
  69781. * * The parameter `size` sets the size (float) of each box side (default 1)
  69782. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  69783. * * 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)
  69784. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69785. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69786. * * 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
  69787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69788. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69789. * @param name defines the name of the mesh
  69790. * @param options defines the options used to create the mesh
  69791. * @param scene defines the hosting scene
  69792. * @returns the box mesh
  69793. */
  69794. static CreateBox(name: string, options: {
  69795. size?: number;
  69796. width?: number;
  69797. height?: number;
  69798. depth?: number;
  69799. faceUV?: Vector4[];
  69800. faceColors?: Color4[];
  69801. sideOrientation?: number;
  69802. frontUVs?: Vector4;
  69803. backUVs?: Vector4;
  69804. wrap?: boolean;
  69805. topBaseAt?: number;
  69806. bottomBaseAt?: number;
  69807. updatable?: boolean;
  69808. }, scene?: Nullable<Scene>): Mesh;
  69809. /**
  69810. * Creates a tiled box mesh
  69811. * * faceTiles sets the pattern, tile size and number of tiles for a face
  69812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69813. * @param name defines the name of the mesh
  69814. * @param options defines the options used to create the mesh
  69815. * @param scene defines the hosting scene
  69816. * @returns the tiled box mesh
  69817. */
  69818. static CreateTiledBox(name: string, options: {
  69819. pattern?: number;
  69820. size?: number;
  69821. width?: number;
  69822. height?: number;
  69823. depth: number;
  69824. tileSize?: number;
  69825. tileWidth?: number;
  69826. tileHeight?: number;
  69827. faceUV?: Vector4[];
  69828. faceColors?: Color4[];
  69829. alignHorizontal?: number;
  69830. alignVertical?: number;
  69831. sideOrientation?: number;
  69832. updatable?: boolean;
  69833. }, scene?: Nullable<Scene>): Mesh;
  69834. /**
  69835. * Creates a sphere mesh
  69836. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  69837. * * 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`)
  69838. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  69839. * * 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
  69840. * * 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)
  69841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69842. * * 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
  69843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69844. * @param name defines the name of the mesh
  69845. * @param options defines the options used to create the mesh
  69846. * @param scene defines the hosting scene
  69847. * @returns the sphere mesh
  69848. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  69849. */
  69850. static CreateSphere(name: string, options: {
  69851. segments?: number;
  69852. diameter?: number;
  69853. diameterX?: number;
  69854. diameterY?: number;
  69855. diameterZ?: number;
  69856. arc?: number;
  69857. slice?: number;
  69858. sideOrientation?: number;
  69859. frontUVs?: Vector4;
  69860. backUVs?: Vector4;
  69861. updatable?: boolean;
  69862. }, scene?: Nullable<Scene>): Mesh;
  69863. /**
  69864. * Creates a plane polygonal mesh. By default, this is a disc
  69865. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  69866. * * 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
  69867. * * 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
  69868. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69869. * * 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
  69870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69871. * @param name defines the name of the mesh
  69872. * @param options defines the options used to create the mesh
  69873. * @param scene defines the hosting scene
  69874. * @returns the plane polygonal mesh
  69875. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  69876. */
  69877. static CreateDisc(name: string, options: {
  69878. radius?: number;
  69879. tessellation?: number;
  69880. arc?: number;
  69881. updatable?: boolean;
  69882. sideOrientation?: number;
  69883. frontUVs?: Vector4;
  69884. backUVs?: Vector4;
  69885. }, scene?: Nullable<Scene>): Mesh;
  69886. /**
  69887. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69888. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69889. * * 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`)
  69890. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69891. * * 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
  69892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69893. * * 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
  69894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69895. * @param name defines the name of the mesh
  69896. * @param options defines the options used to create the mesh
  69897. * @param scene defines the hosting scene
  69898. * @returns the icosahedron mesh
  69899. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69900. */
  69901. static CreateIcoSphere(name: string, options: {
  69902. radius?: number;
  69903. radiusX?: number;
  69904. radiusY?: number;
  69905. radiusZ?: number;
  69906. flat?: boolean;
  69907. subdivisions?: number;
  69908. sideOrientation?: number;
  69909. frontUVs?: Vector4;
  69910. backUVs?: Vector4;
  69911. updatable?: boolean;
  69912. }, scene?: Nullable<Scene>): Mesh;
  69913. /**
  69914. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69915. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  69916. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  69917. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  69918. * * 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
  69919. * * 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
  69920. * * 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
  69921. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69922. * * 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
  69923. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69924. * * 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
  69925. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  69926. * * 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
  69927. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  69928. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69929. * @param name defines the name of the mesh
  69930. * @param options defines the options used to create the mesh
  69931. * @param scene defines the hosting scene
  69932. * @returns the ribbon mesh
  69933. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  69934. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69935. */
  69936. static CreateRibbon(name: string, options: {
  69937. pathArray: Vector3[][];
  69938. closeArray?: boolean;
  69939. closePath?: boolean;
  69940. offset?: number;
  69941. updatable?: boolean;
  69942. sideOrientation?: number;
  69943. frontUVs?: Vector4;
  69944. backUVs?: Vector4;
  69945. instance?: Mesh;
  69946. invertUV?: boolean;
  69947. uvs?: Vector2[];
  69948. colors?: Color4[];
  69949. }, scene?: Nullable<Scene>): Mesh;
  69950. /**
  69951. * Creates a cylinder or a cone mesh
  69952. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  69953. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  69954. * * 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.
  69955. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  69956. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  69957. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  69958. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  69959. * * 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).
  69960. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  69961. * * 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).
  69962. * * 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
  69963. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  69964. * * 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
  69965. * * 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.
  69966. * * If `enclose` is false, a ring surface is one element.
  69967. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  69968. * * 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
  69969. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69970. * * 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
  69971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69972. * @param name defines the name of the mesh
  69973. * @param options defines the options used to create the mesh
  69974. * @param scene defines the hosting scene
  69975. * @returns the cylinder mesh
  69976. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  69977. */
  69978. static CreateCylinder(name: string, options: {
  69979. height?: number;
  69980. diameterTop?: number;
  69981. diameterBottom?: number;
  69982. diameter?: number;
  69983. tessellation?: number;
  69984. subdivisions?: number;
  69985. arc?: number;
  69986. faceColors?: Color4[];
  69987. faceUV?: Vector4[];
  69988. updatable?: boolean;
  69989. hasRings?: boolean;
  69990. enclose?: boolean;
  69991. cap?: number;
  69992. sideOrientation?: number;
  69993. frontUVs?: Vector4;
  69994. backUVs?: Vector4;
  69995. }, scene?: Nullable<Scene>): Mesh;
  69996. /**
  69997. * Creates a torus mesh
  69998. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  69999. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70000. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  70001. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70002. * * 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
  70003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70004. * @param name defines the name of the mesh
  70005. * @param options defines the options used to create the mesh
  70006. * @param scene defines the hosting scene
  70007. * @returns the torus mesh
  70008. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70009. */
  70010. static CreateTorus(name: string, options: {
  70011. diameter?: number;
  70012. thickness?: number;
  70013. tessellation?: number;
  70014. updatable?: boolean;
  70015. sideOrientation?: number;
  70016. frontUVs?: Vector4;
  70017. backUVs?: Vector4;
  70018. }, scene?: Nullable<Scene>): Mesh;
  70019. /**
  70020. * Creates a torus knot mesh
  70021. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70022. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70023. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70024. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70025. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70026. * * 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
  70027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70028. * @param name defines the name of the mesh
  70029. * @param options defines the options used to create the mesh
  70030. * @param scene defines the hosting scene
  70031. * @returns the torus knot mesh
  70032. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70033. */
  70034. static CreateTorusKnot(name: string, options: {
  70035. radius?: number;
  70036. tube?: number;
  70037. radialSegments?: number;
  70038. tubularSegments?: number;
  70039. p?: number;
  70040. q?: number;
  70041. updatable?: boolean;
  70042. sideOrientation?: number;
  70043. frontUVs?: Vector4;
  70044. backUVs?: Vector4;
  70045. }, scene?: Nullable<Scene>): Mesh;
  70046. /**
  70047. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70048. * * 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
  70049. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70050. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70051. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70052. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70053. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70054. * * 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
  70055. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70057. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70058. * @param name defines the name of the new line system
  70059. * @param options defines the options used to create the line system
  70060. * @param scene defines the hosting scene
  70061. * @returns a new line system mesh
  70062. */
  70063. static CreateLineSystem(name: string, options: {
  70064. lines: Vector3[][];
  70065. updatable?: boolean;
  70066. instance?: Nullable<LinesMesh>;
  70067. colors?: Nullable<Color4[][]>;
  70068. useVertexAlpha?: boolean;
  70069. }, scene: Nullable<Scene>): LinesMesh;
  70070. /**
  70071. * Creates a line mesh
  70072. * 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
  70073. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70074. * * The parameter `points` is an array successive Vector3
  70075. * * 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
  70076. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70077. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70078. * * When updating an instance, remember that only point positions can change, not the number of points
  70079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70080. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70081. * @param name defines the name of the new line system
  70082. * @param options defines the options used to create the line system
  70083. * @param scene defines the hosting scene
  70084. * @returns a new line mesh
  70085. */
  70086. static CreateLines(name: string, options: {
  70087. points: Vector3[];
  70088. updatable?: boolean;
  70089. instance?: Nullable<LinesMesh>;
  70090. colors?: Color4[];
  70091. useVertexAlpha?: boolean;
  70092. }, scene?: Nullable<Scene>): LinesMesh;
  70093. /**
  70094. * Creates a dashed line mesh
  70095. * * 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
  70096. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70097. * * The parameter `points` is an array successive Vector3
  70098. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70099. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70100. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70101. * * 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
  70102. * * When updating an instance, remember that only point positions can change, not the number of points
  70103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70104. * @param name defines the name of the mesh
  70105. * @param options defines the options used to create the mesh
  70106. * @param scene defines the hosting scene
  70107. * @returns the dashed line mesh
  70108. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70109. */
  70110. static CreateDashedLines(name: string, options: {
  70111. points: Vector3[];
  70112. dashSize?: number;
  70113. gapSize?: number;
  70114. dashNb?: number;
  70115. updatable?: boolean;
  70116. instance?: LinesMesh;
  70117. }, scene?: Nullable<Scene>): LinesMesh;
  70118. /**
  70119. * 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.
  70120. * * 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.
  70121. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70122. * * 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.
  70123. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70124. * * 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
  70125. * * 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
  70126. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70128. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70129. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  70130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70131. * @param name defines the name of the mesh
  70132. * @param options defines the options used to create the mesh
  70133. * @param scene defines the hosting scene
  70134. * @returns the extruded shape mesh
  70135. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70136. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70137. */
  70138. static ExtrudeShape(name: string, options: {
  70139. shape: Vector3[];
  70140. path: Vector3[];
  70141. scale?: number;
  70142. rotation?: number;
  70143. cap?: number;
  70144. updatable?: boolean;
  70145. sideOrientation?: number;
  70146. frontUVs?: Vector4;
  70147. backUVs?: Vector4;
  70148. instance?: Mesh;
  70149. invertUV?: boolean;
  70150. }, scene?: Nullable<Scene>): Mesh;
  70151. /**
  70152. * Creates an custom extruded shape mesh.
  70153. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  70154. * * 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.
  70155. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70156. * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  70157. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  70158. * * 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
  70159. * * It must returns a float value that will be the scale value applied to the shape on each path point
  70160. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  70161. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  70162. * * 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
  70163. * * 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
  70164. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  70165. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70166. * * 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
  70167. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  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 custom extruded shape mesh
  70173. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  70174. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70175. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70176. */
  70177. static ExtrudeShapeCustom(name: string, options: {
  70178. shape: Vector3[];
  70179. path: Vector3[];
  70180. scaleFunction?: any;
  70181. rotationFunction?: any;
  70182. ribbonCloseArray?: boolean;
  70183. ribbonClosePath?: boolean;
  70184. cap?: number;
  70185. updatable?: boolean;
  70186. sideOrientation?: number;
  70187. frontUVs?: Vector4;
  70188. backUVs?: Vector4;
  70189. instance?: Mesh;
  70190. invertUV?: boolean;
  70191. }, scene?: Nullable<Scene>): Mesh;
  70192. /**
  70193. * Creates lathe mesh.
  70194. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70195. * * 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
  70196. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70197. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70198. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70199. * * 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
  70200. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70201. * * 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
  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 optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70206. * @param name defines the name of the mesh
  70207. * @param options defines the options used to create the mesh
  70208. * @param scene defines the hosting scene
  70209. * @returns the lathe mesh
  70210. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70211. */
  70212. static CreateLathe(name: string, options: {
  70213. shape: Vector3[];
  70214. radius?: number;
  70215. tessellation?: number;
  70216. clip?: number;
  70217. arc?: number;
  70218. closed?: boolean;
  70219. updatable?: boolean;
  70220. sideOrientation?: number;
  70221. frontUVs?: Vector4;
  70222. backUVs?: Vector4;
  70223. cap?: number;
  70224. invertUV?: boolean;
  70225. }, scene?: Nullable<Scene>): Mesh;
  70226. /**
  70227. * Creates a tiled plane mesh
  70228. * * You can set a limited pattern arrangement with the tiles
  70229. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70230. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70232. * @param name defines the name of the mesh
  70233. * @param options defines the options used to create the mesh
  70234. * @param scene defines the hosting scene
  70235. * @returns the plane mesh
  70236. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70237. */
  70238. static CreateTiledPlane(name: string, options: {
  70239. pattern?: number;
  70240. tileSize?: number;
  70241. tileWidth?: number;
  70242. tileHeight?: number;
  70243. size?: number;
  70244. width?: number;
  70245. height?: number;
  70246. alignHorizontal?: number;
  70247. alignVertical?: number;
  70248. sideOrientation?: number;
  70249. frontUVs?: Vector4;
  70250. backUVs?: Vector4;
  70251. updatable?: boolean;
  70252. }, scene?: Nullable<Scene>): Mesh;
  70253. /**
  70254. * Creates a plane mesh
  70255. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  70256. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  70257. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  70258. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70259. * * 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
  70260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70261. * @param name defines the name of the mesh
  70262. * @param options defines the options used to create the mesh
  70263. * @param scene defines the hosting scene
  70264. * @returns the plane mesh
  70265. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70266. */
  70267. static CreatePlane(name: string, options: {
  70268. size?: number;
  70269. width?: number;
  70270. height?: number;
  70271. sideOrientation?: number;
  70272. frontUVs?: Vector4;
  70273. backUVs?: Vector4;
  70274. updatable?: boolean;
  70275. sourcePlane?: Plane;
  70276. }, scene?: Nullable<Scene>): Mesh;
  70277. /**
  70278. * Creates a ground mesh
  70279. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  70280. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  70281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70282. * @param name defines the name of the mesh
  70283. * @param options defines the options used to create the mesh
  70284. * @param scene defines the hosting scene
  70285. * @returns the ground mesh
  70286. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  70287. */
  70288. static CreateGround(name: string, options: {
  70289. width?: number;
  70290. height?: number;
  70291. subdivisions?: number;
  70292. subdivisionsX?: number;
  70293. subdivisionsY?: number;
  70294. updatable?: boolean;
  70295. }, scene?: Nullable<Scene>): Mesh;
  70296. /**
  70297. * Creates a tiled ground mesh
  70298. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  70299. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  70300. * * 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
  70301. * * 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
  70302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70303. * @param name defines the name of the mesh
  70304. * @param options defines the options used to create the mesh
  70305. * @param scene defines the hosting scene
  70306. * @returns the tiled ground mesh
  70307. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  70308. */
  70309. static CreateTiledGround(name: string, options: {
  70310. xmin: number;
  70311. zmin: number;
  70312. xmax: number;
  70313. zmax: number;
  70314. subdivisions?: {
  70315. w: number;
  70316. h: number;
  70317. };
  70318. precision?: {
  70319. w: number;
  70320. h: number;
  70321. };
  70322. updatable?: boolean;
  70323. }, scene?: Nullable<Scene>): Mesh;
  70324. /**
  70325. * Creates a ground mesh from a height map
  70326. * * The parameter `url` sets the URL of the height map image resource.
  70327. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  70328. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  70329. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  70330. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  70331. * * 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.
  70332. * * 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).
  70333. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  70334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70335. * @param name defines the name of the mesh
  70336. * @param url defines the url to the height map
  70337. * @param options defines the options used to create the mesh
  70338. * @param scene defines the hosting scene
  70339. * @returns the ground mesh
  70340. * @see https://doc.babylonjs.com/babylon101/height_map
  70341. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  70342. */
  70343. static CreateGroundFromHeightMap(name: string, url: string, options: {
  70344. width?: number;
  70345. height?: number;
  70346. subdivisions?: number;
  70347. minHeight?: number;
  70348. maxHeight?: number;
  70349. colorFilter?: Color3;
  70350. alphaFilter?: number;
  70351. updatable?: boolean;
  70352. onReady?: (mesh: GroundMesh) => void;
  70353. }, scene?: Nullable<Scene>): GroundMesh;
  70354. /**
  70355. * Creates a polygon mesh
  70356. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70357. * * 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
  70358. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70360. * * 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)
  70361. * * Remember you can only change the shape positions, not their number when updating a polygon
  70362. * @param name defines the name of the mesh
  70363. * @param options defines the options used to create the mesh
  70364. * @param scene defines the hosting scene
  70365. * @param earcutInjection can be used to inject your own earcut reference
  70366. * @returns the polygon mesh
  70367. */
  70368. static CreatePolygon(name: string, options: {
  70369. shape: Vector3[];
  70370. holes?: Vector3[][];
  70371. depth?: number;
  70372. faceUV?: Vector4[];
  70373. faceColors?: Color4[];
  70374. updatable?: boolean;
  70375. sideOrientation?: number;
  70376. frontUVs?: Vector4;
  70377. backUVs?: Vector4;
  70378. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70379. /**
  70380. * Creates an extruded polygon mesh, with depth in the Y direction.
  70381. * * 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)
  70382. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70383. * @param name defines the name of the mesh
  70384. * @param options defines the options used to create the mesh
  70385. * @param scene defines the hosting scene
  70386. * @param earcutInjection can be used to inject your own earcut reference
  70387. * @returns the polygon mesh
  70388. */
  70389. static ExtrudePolygon(name: string, options: {
  70390. shape: Vector3[];
  70391. holes?: Vector3[][];
  70392. depth?: number;
  70393. faceUV?: Vector4[];
  70394. faceColors?: Color4[];
  70395. updatable?: boolean;
  70396. sideOrientation?: number;
  70397. frontUVs?: Vector4;
  70398. backUVs?: Vector4;
  70399. wrap?: boolean;
  70400. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70401. /**
  70402. * Creates a tube mesh.
  70403. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70404. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70405. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70406. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70407. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70408. * * 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)
  70409. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70410. * * 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
  70411. * * 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
  70412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70413. * * 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
  70414. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70416. * @param name defines the name of the mesh
  70417. * @param options defines the options used to create the mesh
  70418. * @param scene defines the hosting scene
  70419. * @returns the tube mesh
  70420. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70421. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70422. */
  70423. static CreateTube(name: string, options: {
  70424. path: Vector3[];
  70425. radius?: number;
  70426. tessellation?: number;
  70427. radiusFunction?: {
  70428. (i: number, distance: number): number;
  70429. };
  70430. cap?: number;
  70431. arc?: number;
  70432. updatable?: boolean;
  70433. sideOrientation?: number;
  70434. frontUVs?: Vector4;
  70435. backUVs?: Vector4;
  70436. instance?: Mesh;
  70437. invertUV?: boolean;
  70438. }, scene?: Nullable<Scene>): Mesh;
  70439. /**
  70440. * Creates a polyhedron mesh
  70441. * * 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
  70442. * * The parameter `size` (positive float, default 1) sets the polygon size
  70443. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  70444. * * 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`
  70445. * * 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
  70446. * * 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)`)
  70447. * * 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
  70448. * * 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
  70449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70450. * * 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
  70451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70452. * @param name defines the name of the mesh
  70453. * @param options defines the options used to create the mesh
  70454. * @param scene defines the hosting scene
  70455. * @returns the polyhedron mesh
  70456. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  70457. */
  70458. static CreatePolyhedron(name: string, options: {
  70459. type?: number;
  70460. size?: number;
  70461. sizeX?: number;
  70462. sizeY?: number;
  70463. sizeZ?: number;
  70464. custom?: any;
  70465. faceUV?: Vector4[];
  70466. faceColors?: Color4[];
  70467. flat?: boolean;
  70468. updatable?: boolean;
  70469. sideOrientation?: number;
  70470. frontUVs?: Vector4;
  70471. backUVs?: Vector4;
  70472. }, scene?: Nullable<Scene>): Mesh;
  70473. /**
  70474. * Creates a decal mesh.
  70475. * 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
  70476. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70477. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70478. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70479. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70480. * @param name defines the name of the mesh
  70481. * @param sourceMesh defines the mesh where the decal must be applied
  70482. * @param options defines the options used to create the mesh
  70483. * @param scene defines the hosting scene
  70484. * @returns the decal mesh
  70485. * @see https://doc.babylonjs.com/how_to/decals
  70486. */
  70487. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70488. position?: Vector3;
  70489. normal?: Vector3;
  70490. size?: Vector3;
  70491. angle?: number;
  70492. }): Mesh;
  70493. /**
  70494. * Creates a Capsule Mesh
  70495. * @param name defines the name of the mesh.
  70496. * @param options the constructors options used to shape the mesh.
  70497. * @param scene defines the scene the mesh is scoped to.
  70498. * @returns the capsule mesh
  70499. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70500. */
  70501. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70502. }
  70503. }
  70504. declare module BABYLON {
  70505. /**
  70506. * A simplifier interface for future simplification implementations
  70507. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70508. */
  70509. export interface ISimplifier {
  70510. /**
  70511. * Simplification of a given mesh according to the given settings.
  70512. * Since this requires computation, it is assumed that the function runs async.
  70513. * @param settings The settings of the simplification, including quality and distance
  70514. * @param successCallback A callback that will be called after the mesh was simplified.
  70515. * @param errorCallback in case of an error, this callback will be called. optional.
  70516. */
  70517. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70518. }
  70519. /**
  70520. * Expected simplification settings.
  70521. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70522. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70523. */
  70524. export interface ISimplificationSettings {
  70525. /**
  70526. * Gets or sets the expected quality
  70527. */
  70528. quality: number;
  70529. /**
  70530. * Gets or sets the distance when this optimized version should be used
  70531. */
  70532. distance: number;
  70533. /**
  70534. * Gets an already optimized mesh
  70535. */
  70536. optimizeMesh?: boolean;
  70537. }
  70538. /**
  70539. * Class used to specify simplification options
  70540. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70541. */
  70542. export class SimplificationSettings implements ISimplificationSettings {
  70543. /** expected quality */
  70544. quality: number;
  70545. /** distance when this optimized version should be used */
  70546. distance: number;
  70547. /** already optimized mesh */
  70548. optimizeMesh?: boolean | undefined;
  70549. /**
  70550. * Creates a SimplificationSettings
  70551. * @param quality expected quality
  70552. * @param distance distance when this optimized version should be used
  70553. * @param optimizeMesh already optimized mesh
  70554. */
  70555. constructor(
  70556. /** expected quality */
  70557. quality: number,
  70558. /** distance when this optimized version should be used */
  70559. distance: number,
  70560. /** already optimized mesh */
  70561. optimizeMesh?: boolean | undefined);
  70562. }
  70563. /**
  70564. * Interface used to define a simplification task
  70565. */
  70566. export interface ISimplificationTask {
  70567. /**
  70568. * Array of settings
  70569. */
  70570. settings: Array<ISimplificationSettings>;
  70571. /**
  70572. * Simplification type
  70573. */
  70574. simplificationType: SimplificationType;
  70575. /**
  70576. * Mesh to simplify
  70577. */
  70578. mesh: Mesh;
  70579. /**
  70580. * Callback called on success
  70581. */
  70582. successCallback?: () => void;
  70583. /**
  70584. * Defines if parallel processing can be used
  70585. */
  70586. parallelProcessing: boolean;
  70587. }
  70588. /**
  70589. * Queue used to order the simplification tasks
  70590. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70591. */
  70592. export class SimplificationQueue {
  70593. private _simplificationArray;
  70594. /**
  70595. * Gets a boolean indicating that the process is still running
  70596. */
  70597. running: boolean;
  70598. /**
  70599. * Creates a new queue
  70600. */
  70601. constructor();
  70602. /**
  70603. * Adds a new simplification task
  70604. * @param task defines a task to add
  70605. */
  70606. addTask(task: ISimplificationTask): void;
  70607. /**
  70608. * Execute next task
  70609. */
  70610. executeNext(): void;
  70611. /**
  70612. * Execute a simplification task
  70613. * @param task defines the task to run
  70614. */
  70615. runSimplification(task: ISimplificationTask): void;
  70616. private getSimplifier;
  70617. }
  70618. /**
  70619. * The implemented types of simplification
  70620. * At the moment only Quadratic Error Decimation is implemented
  70621. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70622. */
  70623. export enum SimplificationType {
  70624. /** Quadratic error decimation */
  70625. QUADRATIC = 0
  70626. }
  70627. /**
  70628. * An implementation of the Quadratic Error simplification algorithm.
  70629. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70630. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70631. * @author RaananW
  70632. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70633. */
  70634. export class QuadraticErrorSimplification implements ISimplifier {
  70635. private _mesh;
  70636. private triangles;
  70637. private vertices;
  70638. private references;
  70639. private _reconstructedMesh;
  70640. /** Gets or sets the number pf sync interations */
  70641. syncIterations: number;
  70642. /** Gets or sets the aggressiveness of the simplifier */
  70643. aggressiveness: number;
  70644. /** Gets or sets the number of allowed iterations for decimation */
  70645. decimationIterations: number;
  70646. /** Gets or sets the espilon to use for bounding box computation */
  70647. boundingBoxEpsilon: number;
  70648. /**
  70649. * Creates a new QuadraticErrorSimplification
  70650. * @param _mesh defines the target mesh
  70651. */
  70652. constructor(_mesh: Mesh);
  70653. /**
  70654. * Simplification of a given mesh according to the given settings.
  70655. * Since this requires computation, it is assumed that the function runs async.
  70656. * @param settings The settings of the simplification, including quality and distance
  70657. * @param successCallback A callback that will be called after the mesh was simplified.
  70658. */
  70659. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70660. private runDecimation;
  70661. private initWithMesh;
  70662. private init;
  70663. private reconstructMesh;
  70664. private initDecimatedMesh;
  70665. private isFlipped;
  70666. private updateTriangles;
  70667. private identifyBorder;
  70668. private updateMesh;
  70669. private vertexError;
  70670. private calculateError;
  70671. }
  70672. }
  70673. declare module BABYLON {
  70674. interface Scene {
  70675. /** @hidden (Backing field) */
  70676. _simplificationQueue: SimplificationQueue;
  70677. /**
  70678. * Gets or sets the simplification queue attached to the scene
  70679. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70680. */
  70681. simplificationQueue: SimplificationQueue;
  70682. }
  70683. interface Mesh {
  70684. /**
  70685. * Simplify the mesh according to the given array of settings.
  70686. * Function will return immediately and will simplify async
  70687. * @param settings a collection of simplification settings
  70688. * @param parallelProcessing should all levels calculate parallel or one after the other
  70689. * @param simplificationType the type of simplification to run
  70690. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70691. * @returns the current mesh
  70692. */
  70693. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70694. }
  70695. /**
  70696. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70697. * created in a scene
  70698. */
  70699. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70700. /**
  70701. * The component name helpfull to identify the component in the list of scene components.
  70702. */
  70703. readonly name: string;
  70704. /**
  70705. * The scene the component belongs to.
  70706. */
  70707. scene: Scene;
  70708. /**
  70709. * Creates a new instance of the component for the given scene
  70710. * @param scene Defines the scene to register the component in
  70711. */
  70712. constructor(scene: Scene);
  70713. /**
  70714. * Registers the component in a given scene
  70715. */
  70716. register(): void;
  70717. /**
  70718. * Rebuilds the elements related to this component in case of
  70719. * context lost for instance.
  70720. */
  70721. rebuild(): void;
  70722. /**
  70723. * Disposes the component and the associated ressources
  70724. */
  70725. dispose(): void;
  70726. private _beforeCameraUpdate;
  70727. }
  70728. }
  70729. declare module BABYLON {
  70730. interface Mesh {
  70731. /**
  70732. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  70733. */
  70734. thinInstanceEnablePicking: boolean;
  70735. /**
  70736. * Creates a new thin instance
  70737. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  70738. * @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
  70739. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  70740. */
  70741. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70742. /**
  70743. * Adds the transformation (matrix) of the current mesh as a thin instance
  70744. * @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
  70745. * @returns the thin instance index number
  70746. */
  70747. thinInstanceAddSelf(refresh: boolean): number;
  70748. /**
  70749. * Registers a custom attribute to be used with thin instances
  70750. * @param kind name of the attribute
  70751. * @param stride size in floats of the attribute
  70752. */
  70753. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70754. /**
  70755. * Sets the matrix of a thin instance
  70756. * @param index index of the thin instance
  70757. * @param matrix matrix to set
  70758. * @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
  70759. */
  70760. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  70761. /**
  70762. * Sets the value of a custom attribute for a thin instance
  70763. * @param kind name of the attribute
  70764. * @param index index of the thin instance
  70765. * @param value value to set
  70766. * @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
  70767. */
  70768. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  70769. /**
  70770. * 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.
  70771. */
  70772. thinInstanceCount: number;
  70773. /**
  70774. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  70775. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  70776. * @param buffer buffer to set
  70777. * @param stride size in floats of each value of the buffer
  70778. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  70779. */
  70780. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  70781. /**
  70782. * Gets the list of world matrices
  70783. * @return an array containing all the world matrices from the thin instances
  70784. */
  70785. thinInstanceGetWorldMatrices(): Matrix[];
  70786. /**
  70787. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  70788. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70789. */
  70790. thinInstanceBufferUpdated(kind: string): void;
  70791. /**
  70792. * Applies a partial update to a buffer directly on the GPU
  70793. * 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
  70794. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70795. * @param data the data to set in the GPU buffer
  70796. * @param offset the offset in the GPU buffer where to update the data
  70797. */
  70798. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  70799. /**
  70800. * Refreshes the bounding info, taking into account all the thin instances defined
  70801. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  70802. */
  70803. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  70804. /** @hidden */
  70805. _thinInstanceInitializeUserStorage(): void;
  70806. /** @hidden */
  70807. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  70808. /** @hidden */
  70809. _userThinInstanceBuffersStorage: {
  70810. data: {
  70811. [key: string]: Float32Array;
  70812. };
  70813. sizes: {
  70814. [key: string]: number;
  70815. };
  70816. vertexBuffers: {
  70817. [key: string]: Nullable<VertexBuffer>;
  70818. };
  70819. strides: {
  70820. [key: string]: number;
  70821. };
  70822. };
  70823. }
  70824. }
  70825. declare module BABYLON {
  70826. /**
  70827. * Navigation plugin interface to add navigation constrained by a navigation mesh
  70828. */
  70829. export interface INavigationEnginePlugin {
  70830. /**
  70831. * plugin name
  70832. */
  70833. name: string;
  70834. /**
  70835. * Creates a navigation mesh
  70836. * @param meshes array of all the geometry used to compute the navigatio mesh
  70837. * @param parameters bunch of parameters used to filter geometry
  70838. */
  70839. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70840. /**
  70841. * Create a navigation mesh debug mesh
  70842. * @param scene is where the mesh will be added
  70843. * @returns debug display mesh
  70844. */
  70845. createDebugNavMesh(scene: Scene): Mesh;
  70846. /**
  70847. * Get a navigation mesh constrained position, closest to the parameter position
  70848. * @param position world position
  70849. * @returns the closest point to position constrained by the navigation mesh
  70850. */
  70851. getClosestPoint(position: Vector3): Vector3;
  70852. /**
  70853. * Get a navigation mesh constrained position, closest to the parameter position
  70854. * @param position world position
  70855. * @param result output the closest point to position constrained by the navigation mesh
  70856. */
  70857. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70858. /**
  70859. * Get a navigation mesh constrained position, within a particular radius
  70860. * @param position world position
  70861. * @param maxRadius the maximum distance to the constrained world position
  70862. * @returns the closest point to position constrained by the navigation mesh
  70863. */
  70864. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70865. /**
  70866. * Get a navigation mesh constrained position, within a particular radius
  70867. * @param position world position
  70868. * @param maxRadius the maximum distance to the constrained world position
  70869. * @param result output the closest point to position constrained by the navigation mesh
  70870. */
  70871. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70872. /**
  70873. * Compute the final position from a segment made of destination-position
  70874. * @param position world position
  70875. * @param destination world position
  70876. * @returns the resulting point along the navmesh
  70877. */
  70878. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70879. /**
  70880. * Compute the final position from a segment made of destination-position
  70881. * @param position world position
  70882. * @param destination world position
  70883. * @param result output the resulting point along the navmesh
  70884. */
  70885. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70886. /**
  70887. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70888. * @param start world position
  70889. * @param end world position
  70890. * @returns array containing world position composing the path
  70891. */
  70892. computePath(start: Vector3, end: Vector3): Vector3[];
  70893. /**
  70894. * If this plugin is supported
  70895. * @returns true if plugin is supported
  70896. */
  70897. isSupported(): boolean;
  70898. /**
  70899. * Create a new Crowd so you can add agents
  70900. * @param maxAgents the maximum agent count in the crowd
  70901. * @param maxAgentRadius the maximum radius an agent can have
  70902. * @param scene to attach the crowd to
  70903. * @returns the crowd you can add agents to
  70904. */
  70905. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70906. /**
  70907. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70908. * The queries will try to find a solution within those bounds
  70909. * default is (1,1,1)
  70910. * @param extent x,y,z value that define the extent around the queries point of reference
  70911. */
  70912. setDefaultQueryExtent(extent: Vector3): void;
  70913. /**
  70914. * Get the Bounding box extent specified by setDefaultQueryExtent
  70915. * @returns the box extent values
  70916. */
  70917. getDefaultQueryExtent(): Vector3;
  70918. /**
  70919. * build the navmesh from a previously saved state using getNavmeshData
  70920. * @param data the Uint8Array returned by getNavmeshData
  70921. */
  70922. buildFromNavmeshData(data: Uint8Array): void;
  70923. /**
  70924. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70925. * @returns data the Uint8Array that can be saved and reused
  70926. */
  70927. getNavmeshData(): Uint8Array;
  70928. /**
  70929. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70930. * @param result output the box extent values
  70931. */
  70932. getDefaultQueryExtentToRef(result: Vector3): void;
  70933. /**
  70934. * Set the time step of the navigation tick update.
  70935. * Default is 1/60.
  70936. * A value of 0 will disable fixed time update
  70937. * @param newTimeStep the new timestep to apply to this world.
  70938. */
  70939. setTimeStep(newTimeStep: number): void;
  70940. /**
  70941. * Get the time step of the navigation tick update.
  70942. * @returns the current time step
  70943. */
  70944. getTimeStep(): number;
  70945. /**
  70946. * If delta time in navigation tick update is greater than the time step
  70947. * a number of sub iterations are done. If more iterations are need to reach deltatime
  70948. * they will be discarded.
  70949. * A value of 0 will set to no maximum and update will use as many substeps as needed
  70950. * @param newStepCount the maximum number of iterations
  70951. */
  70952. setMaximumSubStepCount(newStepCount: number): void;
  70953. /**
  70954. * Get the maximum number of iterations per navigation tick update
  70955. * @returns the maximum number of iterations
  70956. */
  70957. getMaximumSubStepCount(): number;
  70958. /**
  70959. * Release all resources
  70960. */
  70961. dispose(): void;
  70962. }
  70963. /**
  70964. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  70965. */
  70966. export interface ICrowd {
  70967. /**
  70968. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70969. * You can attach anything to that node. The node position is updated in the scene update tick.
  70970. * @param pos world position that will be constrained by the navigation mesh
  70971. * @param parameters agent parameters
  70972. * @param transform hooked to the agent that will be update by the scene
  70973. * @returns agent index
  70974. */
  70975. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70976. /**
  70977. * Returns the agent position in world space
  70978. * @param index agent index returned by addAgent
  70979. * @returns world space position
  70980. */
  70981. getAgentPosition(index: number): Vector3;
  70982. /**
  70983. * Gets the agent position result in world space
  70984. * @param index agent index returned by addAgent
  70985. * @param result output world space position
  70986. */
  70987. getAgentPositionToRef(index: number, result: Vector3): void;
  70988. /**
  70989. * Gets the agent velocity in world space
  70990. * @param index agent index returned by addAgent
  70991. * @returns world space velocity
  70992. */
  70993. getAgentVelocity(index: number): Vector3;
  70994. /**
  70995. * Gets the agent velocity result in world space
  70996. * @param index agent index returned by addAgent
  70997. * @param result output world space velocity
  70998. */
  70999. getAgentVelocityToRef(index: number, result: Vector3): void;
  71000. /**
  71001. * Gets the agent next target point on the path
  71002. * @param index agent index returned by addAgent
  71003. * @returns world space position
  71004. */
  71005. getAgentNextTargetPath(index: number): Vector3;
  71006. /**
  71007. * Gets the agent state
  71008. * @param index agent index returned by addAgent
  71009. * @returns agent state
  71010. */
  71011. getAgentState(index: number): number;
  71012. /**
  71013. * returns true if the agent in over an off mesh link connection
  71014. * @param index agent index returned by addAgent
  71015. * @returns true if over an off mesh link connection
  71016. */
  71017. overOffmeshConnection(index: number): boolean;
  71018. /**
  71019. * Gets the agent next target point on the path
  71020. * @param index agent index returned by addAgent
  71021. * @param result output world space position
  71022. */
  71023. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71024. /**
  71025. * remove a particular agent previously created
  71026. * @param index agent index returned by addAgent
  71027. */
  71028. removeAgent(index: number): void;
  71029. /**
  71030. * get the list of all agents attached to this crowd
  71031. * @returns list of agent indices
  71032. */
  71033. getAgents(): number[];
  71034. /**
  71035. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71036. * @param deltaTime in seconds
  71037. */
  71038. update(deltaTime: number): void;
  71039. /**
  71040. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71041. * @param index agent index returned by addAgent
  71042. * @param destination targeted world position
  71043. */
  71044. agentGoto(index: number, destination: Vector3): void;
  71045. /**
  71046. * Teleport the agent to a new position
  71047. * @param index agent index returned by addAgent
  71048. * @param destination targeted world position
  71049. */
  71050. agentTeleport(index: number, destination: Vector3): void;
  71051. /**
  71052. * Update agent parameters
  71053. * @param index agent index returned by addAgent
  71054. * @param parameters agent parameters
  71055. */
  71056. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71057. /**
  71058. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71059. * The queries will try to find a solution within those bounds
  71060. * default is (1,1,1)
  71061. * @param extent x,y,z value that define the extent around the queries point of reference
  71062. */
  71063. setDefaultQueryExtent(extent: Vector3): void;
  71064. /**
  71065. * Get the Bounding box extent specified by setDefaultQueryExtent
  71066. * @returns the box extent values
  71067. */
  71068. getDefaultQueryExtent(): Vector3;
  71069. /**
  71070. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71071. * @param result output the box extent values
  71072. */
  71073. getDefaultQueryExtentToRef(result: Vector3): void;
  71074. /**
  71075. * Release all resources
  71076. */
  71077. dispose(): void;
  71078. }
  71079. /**
  71080. * Configures an agent
  71081. */
  71082. export interface IAgentParameters {
  71083. /**
  71084. * Agent radius. [Limit: >= 0]
  71085. */
  71086. radius: number;
  71087. /**
  71088. * Agent height. [Limit: > 0]
  71089. */
  71090. height: number;
  71091. /**
  71092. * Maximum allowed acceleration. [Limit: >= 0]
  71093. */
  71094. maxAcceleration: number;
  71095. /**
  71096. * Maximum allowed speed. [Limit: >= 0]
  71097. */
  71098. maxSpeed: number;
  71099. /**
  71100. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  71101. */
  71102. collisionQueryRange: number;
  71103. /**
  71104. * The path visibility optimization range. [Limit: > 0]
  71105. */
  71106. pathOptimizationRange: number;
  71107. /**
  71108. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  71109. */
  71110. separationWeight: number;
  71111. }
  71112. /**
  71113. * Configures the navigation mesh creation
  71114. */
  71115. export interface INavMeshParameters {
  71116. /**
  71117. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  71118. */
  71119. cs: number;
  71120. /**
  71121. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  71122. */
  71123. ch: number;
  71124. /**
  71125. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  71126. */
  71127. walkableSlopeAngle: number;
  71128. /**
  71129. * Minimum floor to 'ceiling' height that will still allow the floor area to
  71130. * be considered walkable. [Limit: >= 3] [Units: vx]
  71131. */
  71132. walkableHeight: number;
  71133. /**
  71134. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  71135. */
  71136. walkableClimb: number;
  71137. /**
  71138. * The distance to erode/shrink the walkable area of the heightfield away from
  71139. * obstructions. [Limit: >=0] [Units: vx]
  71140. */
  71141. walkableRadius: number;
  71142. /**
  71143. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  71144. */
  71145. maxEdgeLen: number;
  71146. /**
  71147. * The maximum distance a simplfied contour's border edges should deviate
  71148. * the original raw contour. [Limit: >=0] [Units: vx]
  71149. */
  71150. maxSimplificationError: number;
  71151. /**
  71152. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  71153. */
  71154. minRegionArea: number;
  71155. /**
  71156. * Any regions with a span count smaller than this value will, if possible,
  71157. * be merged with larger regions. [Limit: >=0] [Units: vx]
  71158. */
  71159. mergeRegionArea: number;
  71160. /**
  71161. * The maximum number of vertices allowed for polygons generated during the
  71162. * contour to polygon conversion process. [Limit: >= 3]
  71163. */
  71164. maxVertsPerPoly: number;
  71165. /**
  71166. * Sets the sampling distance to use when generating the detail mesh.
  71167. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  71168. */
  71169. detailSampleDist: number;
  71170. /**
  71171. * The maximum distance the detail mesh surface should deviate from heightfield
  71172. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  71173. */
  71174. detailSampleMaxError: number;
  71175. }
  71176. }
  71177. declare module BABYLON {
  71178. /**
  71179. * RecastJS navigation plugin
  71180. */
  71181. export class RecastJSPlugin implements INavigationEnginePlugin {
  71182. /**
  71183. * Reference to the Recast library
  71184. */
  71185. bjsRECAST: any;
  71186. /**
  71187. * plugin name
  71188. */
  71189. name: string;
  71190. /**
  71191. * the first navmesh created. We might extend this to support multiple navmeshes
  71192. */
  71193. navMesh: any;
  71194. private _maximumSubStepCount;
  71195. private _timeStep;
  71196. /**
  71197. * Initializes the recastJS plugin
  71198. * @param recastInjection can be used to inject your own recast reference
  71199. */
  71200. constructor(recastInjection?: any);
  71201. /**
  71202. * Set the time step of the navigation tick update.
  71203. * Default is 1/60.
  71204. * A value of 0 will disable fixed time update
  71205. * @param newTimeStep the new timestep to apply to this world.
  71206. */
  71207. setTimeStep(newTimeStep?: number): void;
  71208. /**
  71209. * Get the time step of the navigation tick update.
  71210. * @returns the current time step
  71211. */
  71212. getTimeStep(): number;
  71213. /**
  71214. * If delta time in navigation tick update is greater than the time step
  71215. * a number of sub iterations are done. If more iterations are need to reach deltatime
  71216. * they will be discarded.
  71217. * A value of 0 will set to no maximum and update will use as many substeps as needed
  71218. * @param newStepCount the maximum number of iterations
  71219. */
  71220. setMaximumSubStepCount(newStepCount?: number): void;
  71221. /**
  71222. * Get the maximum number of iterations per navigation tick update
  71223. * @returns the maximum number of iterations
  71224. */
  71225. getMaximumSubStepCount(): number;
  71226. /**
  71227. * Creates a navigation mesh
  71228. * @param meshes array of all the geometry used to compute the navigatio mesh
  71229. * @param parameters bunch of parameters used to filter geometry
  71230. */
  71231. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71232. /**
  71233. * Create a navigation mesh debug mesh
  71234. * @param scene is where the mesh will be added
  71235. * @returns debug display mesh
  71236. */
  71237. createDebugNavMesh(scene: Scene): Mesh;
  71238. /**
  71239. * Get a navigation mesh constrained position, closest to the parameter position
  71240. * @param position world position
  71241. * @returns the closest point to position constrained by the navigation mesh
  71242. */
  71243. getClosestPoint(position: Vector3): Vector3;
  71244. /**
  71245. * Get a navigation mesh constrained position, closest to the parameter position
  71246. * @param position world position
  71247. * @param result output the closest point to position constrained by the navigation mesh
  71248. */
  71249. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71250. /**
  71251. * Get a navigation mesh constrained position, within a particular radius
  71252. * @param position world position
  71253. * @param maxRadius the maximum distance to the constrained world position
  71254. * @returns the closest point to position constrained by the navigation mesh
  71255. */
  71256. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71257. /**
  71258. * Get a navigation mesh constrained position, within a particular radius
  71259. * @param position world position
  71260. * @param maxRadius the maximum distance to the constrained world position
  71261. * @param result output the closest point to position constrained by the navigation mesh
  71262. */
  71263. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71264. /**
  71265. * Compute the final position from a segment made of destination-position
  71266. * @param position world position
  71267. * @param destination world position
  71268. * @returns the resulting point along the navmesh
  71269. */
  71270. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71271. /**
  71272. * Compute the final position from a segment made of destination-position
  71273. * @param position world position
  71274. * @param destination world position
  71275. * @param result output the resulting point along the navmesh
  71276. */
  71277. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71278. /**
  71279. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71280. * @param start world position
  71281. * @param end world position
  71282. * @returns array containing world position composing the path
  71283. */
  71284. computePath(start: Vector3, end: Vector3): Vector3[];
  71285. /**
  71286. * Create a new Crowd so you can add agents
  71287. * @param maxAgents the maximum agent count in the crowd
  71288. * @param maxAgentRadius the maximum radius an agent can have
  71289. * @param scene to attach the crowd to
  71290. * @returns the crowd you can add agents to
  71291. */
  71292. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71293. /**
  71294. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71295. * The queries will try to find a solution within those bounds
  71296. * default is (1,1,1)
  71297. * @param extent x,y,z value that define the extent around the queries point of reference
  71298. */
  71299. setDefaultQueryExtent(extent: Vector3): void;
  71300. /**
  71301. * Get the Bounding box extent specified by setDefaultQueryExtent
  71302. * @returns the box extent values
  71303. */
  71304. getDefaultQueryExtent(): Vector3;
  71305. /**
  71306. * build the navmesh from a previously saved state using getNavmeshData
  71307. * @param data the Uint8Array returned by getNavmeshData
  71308. */
  71309. buildFromNavmeshData(data: Uint8Array): void;
  71310. /**
  71311. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71312. * @returns data the Uint8Array that can be saved and reused
  71313. */
  71314. getNavmeshData(): Uint8Array;
  71315. /**
  71316. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71317. * @param result output the box extent values
  71318. */
  71319. getDefaultQueryExtentToRef(result: Vector3): void;
  71320. /**
  71321. * Disposes
  71322. */
  71323. dispose(): void;
  71324. /**
  71325. * If this plugin is supported
  71326. * @returns true if plugin is supported
  71327. */
  71328. isSupported(): boolean;
  71329. }
  71330. /**
  71331. * Recast detour crowd implementation
  71332. */
  71333. export class RecastJSCrowd implements ICrowd {
  71334. /**
  71335. * Recast/detour plugin
  71336. */
  71337. bjsRECASTPlugin: RecastJSPlugin;
  71338. /**
  71339. * Link to the detour crowd
  71340. */
  71341. recastCrowd: any;
  71342. /**
  71343. * One transform per agent
  71344. */
  71345. transforms: TransformNode[];
  71346. /**
  71347. * All agents created
  71348. */
  71349. agents: number[];
  71350. /**
  71351. * Link to the scene is kept to unregister the crowd from the scene
  71352. */
  71353. private _scene;
  71354. /**
  71355. * Observer for crowd updates
  71356. */
  71357. private _onBeforeAnimationsObserver;
  71358. /**
  71359. * Constructor
  71360. * @param plugin recastJS plugin
  71361. * @param maxAgents the maximum agent count in the crowd
  71362. * @param maxAgentRadius the maximum radius an agent can have
  71363. * @param scene to attach the crowd to
  71364. * @returns the crowd you can add agents to
  71365. */
  71366. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  71367. /**
  71368. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71369. * You can attach anything to that node. The node position is updated in the scene update tick.
  71370. * @param pos world position that will be constrained by the navigation mesh
  71371. * @param parameters agent parameters
  71372. * @param transform hooked to the agent that will be update by the scene
  71373. * @returns agent index
  71374. */
  71375. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71376. /**
  71377. * Returns the agent position in world space
  71378. * @param index agent index returned by addAgent
  71379. * @returns world space position
  71380. */
  71381. getAgentPosition(index: number): Vector3;
  71382. /**
  71383. * Returns the agent position result in world space
  71384. * @param index agent index returned by addAgent
  71385. * @param result output world space position
  71386. */
  71387. getAgentPositionToRef(index: number, result: Vector3): void;
  71388. /**
  71389. * Returns the agent velocity in world space
  71390. * @param index agent index returned by addAgent
  71391. * @returns world space velocity
  71392. */
  71393. getAgentVelocity(index: number): Vector3;
  71394. /**
  71395. * Returns the agent velocity result in world space
  71396. * @param index agent index returned by addAgent
  71397. * @param result output world space velocity
  71398. */
  71399. getAgentVelocityToRef(index: number, result: Vector3): void;
  71400. /**
  71401. * Returns the agent next target point on the path
  71402. * @param index agent index returned by addAgent
  71403. * @returns world space position
  71404. */
  71405. getAgentNextTargetPath(index: number): Vector3;
  71406. /**
  71407. * Returns the agent next target point on the path
  71408. * @param index agent index returned by addAgent
  71409. * @param result output world space position
  71410. */
  71411. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71412. /**
  71413. * Gets the agent state
  71414. * @param index agent index returned by addAgent
  71415. * @returns agent state
  71416. */
  71417. getAgentState(index: number): number;
  71418. /**
  71419. * returns true if the agent in over an off mesh link connection
  71420. * @param index agent index returned by addAgent
  71421. * @returns true if over an off mesh link connection
  71422. */
  71423. overOffmeshConnection(index: number): boolean;
  71424. /**
  71425. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71426. * @param index agent index returned by addAgent
  71427. * @param destination targeted world position
  71428. */
  71429. agentGoto(index: number, destination: Vector3): void;
  71430. /**
  71431. * Teleport the agent to a new position
  71432. * @param index agent index returned by addAgent
  71433. * @param destination targeted world position
  71434. */
  71435. agentTeleport(index: number, destination: Vector3): void;
  71436. /**
  71437. * Update agent parameters
  71438. * @param index agent index returned by addAgent
  71439. * @param parameters agent parameters
  71440. */
  71441. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71442. /**
  71443. * remove a particular agent previously created
  71444. * @param index agent index returned by addAgent
  71445. */
  71446. removeAgent(index: number): void;
  71447. /**
  71448. * get the list of all agents attached to this crowd
  71449. * @returns list of agent indices
  71450. */
  71451. getAgents(): number[];
  71452. /**
  71453. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71454. * @param deltaTime in seconds
  71455. */
  71456. update(deltaTime: number): void;
  71457. /**
  71458. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71459. * The queries will try to find a solution within those bounds
  71460. * default is (1,1,1)
  71461. * @param extent x,y,z value that define the extent around the queries point of reference
  71462. */
  71463. setDefaultQueryExtent(extent: Vector3): void;
  71464. /**
  71465. * Get the Bounding box extent specified by setDefaultQueryExtent
  71466. * @returns the box extent values
  71467. */
  71468. getDefaultQueryExtent(): Vector3;
  71469. /**
  71470. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71471. * @param result output the box extent values
  71472. */
  71473. getDefaultQueryExtentToRef(result: Vector3): void;
  71474. /**
  71475. * Release all resources
  71476. */
  71477. dispose(): void;
  71478. }
  71479. }
  71480. declare module BABYLON {
  71481. /**
  71482. * Class used to enable access to IndexedDB
  71483. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71484. */
  71485. export class Database implements IOfflineProvider {
  71486. private _callbackManifestChecked;
  71487. private _currentSceneUrl;
  71488. private _db;
  71489. private _enableSceneOffline;
  71490. private _enableTexturesOffline;
  71491. private _manifestVersionFound;
  71492. private _mustUpdateRessources;
  71493. private _hasReachedQuota;
  71494. private _isSupported;
  71495. private _idbFactory;
  71496. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  71497. private static IsUASupportingBlobStorage;
  71498. /**
  71499. * Gets a boolean indicating if Database storate is enabled (off by default)
  71500. */
  71501. static IDBStorageEnabled: boolean;
  71502. /**
  71503. * Gets a boolean indicating if scene must be saved in the database
  71504. */
  71505. get enableSceneOffline(): boolean;
  71506. /**
  71507. * Gets a boolean indicating if textures must be saved in the database
  71508. */
  71509. get enableTexturesOffline(): boolean;
  71510. /**
  71511. * Creates a new Database
  71512. * @param urlToScene defines the url to load the scene
  71513. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71514. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71515. */
  71516. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71517. private static _ParseURL;
  71518. private static _ReturnFullUrlLocation;
  71519. private _checkManifestFile;
  71520. /**
  71521. * Open the database and make it available
  71522. * @param successCallback defines the callback to call on success
  71523. * @param errorCallback defines the callback to call on error
  71524. */
  71525. open(successCallback: () => void, errorCallback: () => void): void;
  71526. /**
  71527. * Loads an image from the database
  71528. * @param url defines the url to load from
  71529. * @param image defines the target DOM image
  71530. */
  71531. loadImage(url: string, image: HTMLImageElement): void;
  71532. private _loadImageFromDBAsync;
  71533. private _saveImageIntoDBAsync;
  71534. private _checkVersionFromDB;
  71535. private _loadVersionFromDBAsync;
  71536. private _saveVersionIntoDBAsync;
  71537. /**
  71538. * Loads a file from database
  71539. * @param url defines the URL to load from
  71540. * @param sceneLoaded defines a callback to call on success
  71541. * @param progressCallBack defines a callback to call when progress changed
  71542. * @param errorCallback defines a callback to call on error
  71543. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71544. */
  71545. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71546. private _loadFileAsync;
  71547. private _saveFileAsync;
  71548. /**
  71549. * Validates if xhr data is correct
  71550. * @param xhr defines the request to validate
  71551. * @param dataType defines the expected data type
  71552. * @returns true if data is correct
  71553. */
  71554. private static _ValidateXHRData;
  71555. }
  71556. }
  71557. declare module BABYLON {
  71558. /** @hidden */
  71559. export var gpuUpdateParticlesPixelShader: {
  71560. name: string;
  71561. shader: string;
  71562. };
  71563. }
  71564. declare module BABYLON {
  71565. /** @hidden */
  71566. export var gpuUpdateParticlesVertexShader: {
  71567. name: string;
  71568. shader: string;
  71569. };
  71570. }
  71571. declare module BABYLON {
  71572. /** @hidden */
  71573. export var clipPlaneFragmentDeclaration2: {
  71574. name: string;
  71575. shader: string;
  71576. };
  71577. }
  71578. declare module BABYLON {
  71579. /** @hidden */
  71580. export var gpuRenderParticlesPixelShader: {
  71581. name: string;
  71582. shader: string;
  71583. };
  71584. }
  71585. declare module BABYLON {
  71586. /** @hidden */
  71587. export var clipPlaneVertexDeclaration2: {
  71588. name: string;
  71589. shader: string;
  71590. };
  71591. }
  71592. declare module BABYLON {
  71593. /** @hidden */
  71594. export var gpuRenderParticlesVertexShader: {
  71595. name: string;
  71596. shader: string;
  71597. };
  71598. }
  71599. declare module BABYLON {
  71600. /**
  71601. * This represents a GPU particle system in Babylon
  71602. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71603. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71604. */
  71605. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71606. /**
  71607. * The layer mask we are rendering the particles through.
  71608. */
  71609. layerMask: number;
  71610. private _capacity;
  71611. private _activeCount;
  71612. private _currentActiveCount;
  71613. private _accumulatedCount;
  71614. private _renderEffect;
  71615. private _updateEffect;
  71616. private _buffer0;
  71617. private _buffer1;
  71618. private _spriteBuffer;
  71619. private _updateVAO;
  71620. private _renderVAO;
  71621. private _targetIndex;
  71622. private _sourceBuffer;
  71623. private _targetBuffer;
  71624. private _currentRenderId;
  71625. private _started;
  71626. private _stopped;
  71627. private _timeDelta;
  71628. private _randomTexture;
  71629. private _randomTexture2;
  71630. private _attributesStrideSize;
  71631. private _updateEffectOptions;
  71632. private _randomTextureSize;
  71633. private _actualFrame;
  71634. private _customEffect;
  71635. private readonly _rawTextureWidth;
  71636. /**
  71637. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71638. */
  71639. static get IsSupported(): boolean;
  71640. /**
  71641. * An event triggered when the system is disposed.
  71642. */
  71643. onDisposeObservable: Observable<IParticleSystem>;
  71644. /**
  71645. * An event triggered when the system is stopped
  71646. */
  71647. onStoppedObservable: Observable<IParticleSystem>;
  71648. /**
  71649. * Gets the maximum number of particles active at the same time.
  71650. * @returns The max number of active particles.
  71651. */
  71652. getCapacity(): number;
  71653. /**
  71654. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71655. * to override the particles.
  71656. */
  71657. forceDepthWrite: boolean;
  71658. /**
  71659. * Gets or set the number of active particles
  71660. */
  71661. get activeParticleCount(): number;
  71662. set activeParticleCount(value: number);
  71663. private _preWarmDone;
  71664. /**
  71665. * Specifies if the particles are updated in emitter local space or world space.
  71666. */
  71667. isLocal: boolean;
  71668. /** Gets or sets a matrix to use to compute projection */
  71669. defaultProjectionMatrix: Matrix;
  71670. /**
  71671. * Is this system ready to be used/rendered
  71672. * @return true if the system is ready
  71673. */
  71674. isReady(): boolean;
  71675. /**
  71676. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71677. * @returns True if it has been started, otherwise false.
  71678. */
  71679. isStarted(): boolean;
  71680. /**
  71681. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71682. * @returns True if it has been stopped, otherwise false.
  71683. */
  71684. isStopped(): boolean;
  71685. /**
  71686. * Gets a boolean indicating that the system is stopping
  71687. * @returns true if the system is currently stopping
  71688. */
  71689. isStopping(): boolean;
  71690. /**
  71691. * Gets the number of particles active at the same time.
  71692. * @returns The number of active particles.
  71693. */
  71694. getActiveCount(): number;
  71695. /**
  71696. * Starts the particle system and begins to emit
  71697. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71698. */
  71699. start(delay?: number): void;
  71700. /**
  71701. * Stops the particle system.
  71702. */
  71703. stop(): void;
  71704. /**
  71705. * Remove all active particles
  71706. */
  71707. reset(): void;
  71708. /**
  71709. * Returns the string "GPUParticleSystem"
  71710. * @returns a string containing the class name
  71711. */
  71712. getClassName(): string;
  71713. /**
  71714. * Gets the custom effect used to render the particles
  71715. * @param blendMode Blend mode for which the effect should be retrieved
  71716. * @returns The effect
  71717. */
  71718. getCustomEffect(blendMode?: number): Nullable<Effect>;
  71719. /**
  71720. * Sets the custom effect used to render the particles
  71721. * @param effect The effect to set
  71722. * @param blendMode Blend mode for which the effect should be set
  71723. */
  71724. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71725. /** @hidden */
  71726. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71727. /**
  71728. * Observable that will be called just before the particles are drawn
  71729. */
  71730. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71731. /**
  71732. * Gets the name of the particle vertex shader
  71733. */
  71734. get vertexShaderName(): string;
  71735. private _colorGradientsTexture;
  71736. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  71737. /**
  71738. * Adds a new color gradient
  71739. * @param gradient defines the gradient to use (between 0 and 1)
  71740. * @param color1 defines the color to affect to the specified gradient
  71741. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71742. * @returns the current particle system
  71743. */
  71744. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  71745. private _refreshColorGradient;
  71746. /** Force the system to rebuild all gradients that need to be resync */
  71747. forceRefreshGradients(): void;
  71748. /**
  71749. * Remove a specific color gradient
  71750. * @param gradient defines the gradient to remove
  71751. * @returns the current particle system
  71752. */
  71753. removeColorGradient(gradient: number): GPUParticleSystem;
  71754. private _angularSpeedGradientsTexture;
  71755. private _sizeGradientsTexture;
  71756. private _velocityGradientsTexture;
  71757. private _limitVelocityGradientsTexture;
  71758. private _dragGradientsTexture;
  71759. private _addFactorGradient;
  71760. /**
  71761. * Adds a new size gradient
  71762. * @param gradient defines the gradient to use (between 0 and 1)
  71763. * @param factor defines the size factor to affect to the specified gradient
  71764. * @returns the current particle system
  71765. */
  71766. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  71767. /**
  71768. * Remove a specific size gradient
  71769. * @param gradient defines the gradient to remove
  71770. * @returns the current particle system
  71771. */
  71772. removeSizeGradient(gradient: number): GPUParticleSystem;
  71773. private _refreshFactorGradient;
  71774. /**
  71775. * Adds a new angular speed gradient
  71776. * @param gradient defines the gradient to use (between 0 and 1)
  71777. * @param factor defines the angular speed to affect to the specified gradient
  71778. * @returns the current particle system
  71779. */
  71780. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  71781. /**
  71782. * Remove a specific angular speed gradient
  71783. * @param gradient defines the gradient to remove
  71784. * @returns the current particle system
  71785. */
  71786. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  71787. /**
  71788. * Adds a new velocity gradient
  71789. * @param gradient defines the gradient to use (between 0 and 1)
  71790. * @param factor defines the velocity to affect to the specified gradient
  71791. * @returns the current particle system
  71792. */
  71793. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71794. /**
  71795. * Remove a specific velocity gradient
  71796. * @param gradient defines the gradient to remove
  71797. * @returns the current particle system
  71798. */
  71799. removeVelocityGradient(gradient: number): GPUParticleSystem;
  71800. /**
  71801. * Adds a new limit velocity gradient
  71802. * @param gradient defines the gradient to use (between 0 and 1)
  71803. * @param factor defines the limit velocity value to affect to the specified gradient
  71804. * @returns the current particle system
  71805. */
  71806. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71807. /**
  71808. * Remove a specific limit velocity gradient
  71809. * @param gradient defines the gradient to remove
  71810. * @returns the current particle system
  71811. */
  71812. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  71813. /**
  71814. * Adds a new drag gradient
  71815. * @param gradient defines the gradient to use (between 0 and 1)
  71816. * @param factor defines the drag value to affect to the specified gradient
  71817. * @returns the current particle system
  71818. */
  71819. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  71820. /**
  71821. * Remove a specific drag gradient
  71822. * @param gradient defines the gradient to remove
  71823. * @returns the current particle system
  71824. */
  71825. removeDragGradient(gradient: number): GPUParticleSystem;
  71826. /**
  71827. * Not supported by GPUParticleSystem
  71828. * @param gradient defines the gradient to use (between 0 and 1)
  71829. * @param factor defines the emit rate value to affect to the specified gradient
  71830. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71831. * @returns the current particle system
  71832. */
  71833. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71834. /**
  71835. * Not supported by GPUParticleSystem
  71836. * @param gradient defines the gradient to remove
  71837. * @returns the current particle system
  71838. */
  71839. removeEmitRateGradient(gradient: number): IParticleSystem;
  71840. /**
  71841. * Not supported by GPUParticleSystem
  71842. * @param gradient defines the gradient to use (between 0 and 1)
  71843. * @param factor defines the start size value to affect to the specified gradient
  71844. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71845. * @returns the current particle system
  71846. */
  71847. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71848. /**
  71849. * Not supported by GPUParticleSystem
  71850. * @param gradient defines the gradient to remove
  71851. * @returns the current particle system
  71852. */
  71853. removeStartSizeGradient(gradient: number): IParticleSystem;
  71854. /**
  71855. * Not supported by GPUParticleSystem
  71856. * @param gradient defines the gradient to use (between 0 and 1)
  71857. * @param min defines the color remap minimal range
  71858. * @param max defines the color remap maximal range
  71859. * @returns the current particle system
  71860. */
  71861. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71862. /**
  71863. * Not supported by GPUParticleSystem
  71864. * @param gradient defines the gradient to remove
  71865. * @returns the current particle system
  71866. */
  71867. removeColorRemapGradient(): IParticleSystem;
  71868. /**
  71869. * Not supported by GPUParticleSystem
  71870. * @param gradient defines the gradient to use (between 0 and 1)
  71871. * @param min defines the alpha remap minimal range
  71872. * @param max defines the alpha remap maximal range
  71873. * @returns the current particle system
  71874. */
  71875. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71876. /**
  71877. * Not supported by GPUParticleSystem
  71878. * @param gradient defines the gradient to remove
  71879. * @returns the current particle system
  71880. */
  71881. removeAlphaRemapGradient(): IParticleSystem;
  71882. /**
  71883. * Not supported by GPUParticleSystem
  71884. * @param gradient defines the gradient to use (between 0 and 1)
  71885. * @param color defines the color to affect to the specified gradient
  71886. * @returns the current particle system
  71887. */
  71888. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  71889. /**
  71890. * Not supported by GPUParticleSystem
  71891. * @param gradient defines the gradient to remove
  71892. * @returns the current particle system
  71893. */
  71894. removeRampGradient(): IParticleSystem;
  71895. /**
  71896. * Not supported by GPUParticleSystem
  71897. * @returns the list of ramp gradients
  71898. */
  71899. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71900. /**
  71901. * Not supported by GPUParticleSystem
  71902. * Gets or sets a boolean indicating that ramp gradients must be used
  71903. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71904. */
  71905. get useRampGradients(): boolean;
  71906. set useRampGradients(value: boolean);
  71907. /**
  71908. * Not supported by GPUParticleSystem
  71909. * @param gradient defines the gradient to use (between 0 and 1)
  71910. * @param factor defines the life time factor to affect to the specified gradient
  71911. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71912. * @returns the current particle system
  71913. */
  71914. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71915. /**
  71916. * Not supported by GPUParticleSystem
  71917. * @param gradient defines the gradient to remove
  71918. * @returns the current particle system
  71919. */
  71920. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71921. /**
  71922. * Instantiates a GPU particle system.
  71923. * 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.
  71924. * @param name The name of the particle system
  71925. * @param options The options used to create the system
  71926. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  71927. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71928. * @param customEffect a custom effect used to change the way particles are rendered by default
  71929. */
  71930. constructor(name: string, options: Partial<{
  71931. capacity: number;
  71932. randomTextureSize: number;
  71933. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  71934. protected _reset(): void;
  71935. private _createUpdateVAO;
  71936. private _createRenderVAO;
  71937. private _initialize;
  71938. /** @hidden */
  71939. _recreateUpdateEffect(): void;
  71940. private _getEffect;
  71941. /**
  71942. * Fill the defines array according to the current settings of the particle system
  71943. * @param defines Array to be updated
  71944. * @param blendMode blend mode to take into account when updating the array
  71945. */
  71946. fillDefines(defines: Array<string>, blendMode?: number): void;
  71947. /**
  71948. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  71949. * @param uniforms Uniforms array to fill
  71950. * @param attributes Attributes array to fill
  71951. * @param samplers Samplers array to fill
  71952. */
  71953. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  71954. /** @hidden */
  71955. _recreateRenderEffect(): Effect;
  71956. /**
  71957. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  71958. * @param preWarm defines if we are in the pre-warmimg phase
  71959. */
  71960. animate(preWarm?: boolean): void;
  71961. private _createFactorGradientTexture;
  71962. private _createSizeGradientTexture;
  71963. private _createAngularSpeedGradientTexture;
  71964. private _createVelocityGradientTexture;
  71965. private _createLimitVelocityGradientTexture;
  71966. private _createDragGradientTexture;
  71967. private _createColorGradientTexture;
  71968. /**
  71969. * Renders the particle system in its current state
  71970. * @param preWarm defines if the system should only update the particles but not render them
  71971. * @returns the current number of particles
  71972. */
  71973. render(preWarm?: boolean): number;
  71974. /**
  71975. * Rebuilds the particle system
  71976. */
  71977. rebuild(): void;
  71978. private _releaseBuffers;
  71979. private _releaseVAOs;
  71980. /**
  71981. * Disposes the particle system and free the associated resources
  71982. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71983. */
  71984. dispose(disposeTexture?: boolean): void;
  71985. /**
  71986. * Clones the particle system.
  71987. * @param name The name of the cloned object
  71988. * @param newEmitter The new emitter to use
  71989. * @returns the cloned particle system
  71990. */
  71991. clone(name: string, newEmitter: any): GPUParticleSystem;
  71992. /**
  71993. * Serializes the particle system to a JSON object
  71994. * @param serializeTexture defines if the texture must be serialized as well
  71995. * @returns the JSON object
  71996. */
  71997. serialize(serializeTexture?: boolean): any;
  71998. /**
  71999. * Parses a JSON object to create a GPU particle system.
  72000. * @param parsedParticleSystem The JSON object to parse
  72001. * @param sceneOrEngine The scene or the engine to create the particle system in
  72002. * @param rootUrl The root url to use to load external dependencies like texture
  72003. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72004. * @returns the parsed GPU particle system
  72005. */
  72006. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  72007. }
  72008. }
  72009. declare module BABYLON {
  72010. /**
  72011. * Represents a set of particle systems working together to create a specific effect
  72012. */
  72013. export class ParticleSystemSet implements IDisposable {
  72014. /**
  72015. * Gets or sets base Assets URL
  72016. */
  72017. static BaseAssetsUrl: string;
  72018. private _emitterCreationOptions;
  72019. private _emitterNode;
  72020. /**
  72021. * Gets the particle system list
  72022. */
  72023. systems: IParticleSystem[];
  72024. /**
  72025. * Gets the emitter node used with this set
  72026. */
  72027. get emitterNode(): Nullable<TransformNode>;
  72028. /**
  72029. * Creates a new emitter mesh as a sphere
  72030. * @param options defines the options used to create the sphere
  72031. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72032. * @param scene defines the hosting scene
  72033. */
  72034. setEmitterAsSphere(options: {
  72035. diameter: number;
  72036. segments: number;
  72037. color: Color3;
  72038. }, renderingGroupId: number, scene: Scene): void;
  72039. /**
  72040. * Starts all particle systems of the set
  72041. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72042. */
  72043. start(emitter?: AbstractMesh): void;
  72044. /**
  72045. * Release all associated resources
  72046. */
  72047. dispose(): void;
  72048. /**
  72049. * Serialize the set into a JSON compatible object
  72050. * @param serializeTexture defines if the texture must be serialized as well
  72051. * @returns a JSON compatible representation of the set
  72052. */
  72053. serialize(serializeTexture?: boolean): any;
  72054. /**
  72055. * Parse a new ParticleSystemSet from a serialized source
  72056. * @param data defines a JSON compatible representation of the set
  72057. * @param scene defines the hosting scene
  72058. * @param gpu defines if we want GPU particles or CPU particles
  72059. * @returns a new ParticleSystemSet
  72060. */
  72061. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72062. }
  72063. }
  72064. declare module BABYLON {
  72065. /**
  72066. * This class is made for on one-liner static method to help creating particle system set.
  72067. */
  72068. export class ParticleHelper {
  72069. /**
  72070. * Gets or sets base Assets URL
  72071. */
  72072. static BaseAssetsUrl: string;
  72073. /** Define the Url to load snippets */
  72074. static SnippetUrl: string;
  72075. /**
  72076. * Create a default particle system that you can tweak
  72077. * @param emitter defines the emitter to use
  72078. * @param capacity defines the system capacity (default is 500 particles)
  72079. * @param scene defines the hosting scene
  72080. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  72081. * @returns the new Particle system
  72082. */
  72083. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  72084. /**
  72085. * This is the main static method (one-liner) of this helper to create different particle systems
  72086. * @param type This string represents the type to the particle system to create
  72087. * @param scene The scene where the particle system should live
  72088. * @param gpu If the system will use gpu
  72089. * @returns the ParticleSystemSet created
  72090. */
  72091. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  72092. /**
  72093. * Static function used to export a particle system to a ParticleSystemSet variable.
  72094. * Please note that the emitter shape is not exported
  72095. * @param systems defines the particle systems to export
  72096. * @returns the created particle system set
  72097. */
  72098. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  72099. /**
  72100. * Creates a particle system from a snippet saved in a remote file
  72101. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  72102. * @param url defines the url to load from
  72103. * @param scene defines the hosting scene
  72104. * @param gpu If the system will use gpu
  72105. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72106. * @returns a promise that will resolve to the new particle system
  72107. */
  72108. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72109. /**
  72110. * Creates a particle system from a snippet saved by the particle system editor
  72111. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  72112. * @param scene defines the hosting scene
  72113. * @param gpu If the system will use gpu
  72114. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72115. * @returns a promise that will resolve to the new particle system
  72116. */
  72117. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72118. }
  72119. }
  72120. declare module BABYLON {
  72121. interface Engine {
  72122. /**
  72123. * Create an effect to use with particle systems.
  72124. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  72125. * the particle system for which you want to create a custom effect in the last parameter
  72126. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  72127. * @param uniformsNames defines a list of attribute names
  72128. * @param samplers defines an array of string used to represent textures
  72129. * @param defines defines the string containing the defines to use to compile the shaders
  72130. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  72131. * @param onCompiled defines a function to call when the effect creation is successful
  72132. * @param onError defines a function to call when the effect creation has failed
  72133. * @param particleSystem the particle system you want to create the effect for
  72134. * @returns the new Effect
  72135. */
  72136. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  72137. }
  72138. interface Mesh {
  72139. /**
  72140. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  72141. * @returns an array of IParticleSystem
  72142. */
  72143. getEmittedParticleSystems(): IParticleSystem[];
  72144. /**
  72145. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  72146. * @returns an array of IParticleSystem
  72147. */
  72148. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  72149. }
  72150. }
  72151. declare module BABYLON {
  72152. /** Defines the 4 color options */
  72153. export enum PointColor {
  72154. /** color value */
  72155. Color = 2,
  72156. /** uv value */
  72157. UV = 1,
  72158. /** random value */
  72159. Random = 0,
  72160. /** stated value */
  72161. Stated = 3
  72162. }
  72163. /**
  72164. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  72165. * 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.
  72166. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  72167. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  72168. *
  72169. * Full documentation here : TO BE ENTERED
  72170. */
  72171. export class PointsCloudSystem implements IDisposable {
  72172. /**
  72173. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  72174. * Example : var p = SPS.particles[i];
  72175. */
  72176. particles: CloudPoint[];
  72177. /**
  72178. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  72179. */
  72180. nbParticles: number;
  72181. /**
  72182. * This a counter for your own usage. It's not set by any SPS functions.
  72183. */
  72184. counter: number;
  72185. /**
  72186. * The PCS name. This name is also given to the underlying mesh.
  72187. */
  72188. name: string;
  72189. /**
  72190. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  72191. */
  72192. mesh: Mesh;
  72193. /**
  72194. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  72195. * Please read :
  72196. */
  72197. vars: any;
  72198. /**
  72199. * @hidden
  72200. */
  72201. _size: number;
  72202. private _scene;
  72203. private _promises;
  72204. private _positions;
  72205. private _indices;
  72206. private _normals;
  72207. private _colors;
  72208. private _uvs;
  72209. private _indices32;
  72210. private _positions32;
  72211. private _colors32;
  72212. private _uvs32;
  72213. private _updatable;
  72214. private _isVisibilityBoxLocked;
  72215. private _alwaysVisible;
  72216. private _groups;
  72217. private _groupCounter;
  72218. private _computeParticleColor;
  72219. private _computeParticleTexture;
  72220. private _computeParticleRotation;
  72221. private _computeBoundingBox;
  72222. private _isReady;
  72223. /**
  72224. * Creates a PCS (Points Cloud System) object
  72225. * @param name (String) is the PCS name, this will be the underlying mesh name
  72226. * @param pointSize (number) is the size for each point
  72227. * @param scene (Scene) is the scene in which the PCS is added
  72228. * @param options defines the options of the PCS e.g.
  72229. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  72230. */
  72231. constructor(name: string, pointSize: number, scene: Scene, options?: {
  72232. updatable?: boolean;
  72233. });
  72234. /**
  72235. * Builds the PCS underlying mesh. Returns a standard Mesh.
  72236. * If no points were added to the PCS, the returned mesh is just a single point.
  72237. * @returns a promise for the created mesh
  72238. */
  72239. buildMeshAsync(): Promise<Mesh>;
  72240. /**
  72241. * @hidden
  72242. */
  72243. private _buildMesh;
  72244. private _addParticle;
  72245. private _randomUnitVector;
  72246. private _getColorIndicesForCoord;
  72247. private _setPointsColorOrUV;
  72248. private _colorFromTexture;
  72249. private _calculateDensity;
  72250. /**
  72251. * Adds points to the PCS in random positions within a unit sphere
  72252. * @param nb (positive integer) the number of particles to be created from this model
  72253. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  72254. * @returns the number of groups in the system
  72255. */
  72256. addPoints(nb: number, pointFunction?: any): number;
  72257. /**
  72258. * Adds points to the PCS from the surface of the model shape
  72259. * @param mesh is any Mesh object that will be used as a surface model for the points
  72260. * @param nb (positive integer) the number of particles to be created from this model
  72261. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72262. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72263. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72264. * @returns the number of groups in the system
  72265. */
  72266. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72267. /**
  72268. * Adds points to the PCS inside the model shape
  72269. * @param mesh is any Mesh object that will be used as a surface model for the points
  72270. * @param nb (positive integer) the number of particles to be created from this model
  72271. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72272. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72273. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72274. * @returns the number of groups in the system
  72275. */
  72276. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72277. /**
  72278. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  72279. * This method calls `updateParticle()` for each particle of the SPS.
  72280. * For an animated SPS, it is usually called within the render loop.
  72281. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  72282. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  72283. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  72284. * @returns the PCS.
  72285. */
  72286. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  72287. /**
  72288. * Disposes the PCS.
  72289. */
  72290. dispose(): void;
  72291. /**
  72292. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  72293. * doc :
  72294. * @returns the PCS.
  72295. */
  72296. refreshVisibleSize(): PointsCloudSystem;
  72297. /**
  72298. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  72299. * @param size the size (float) of the visibility box
  72300. * note : this doesn't lock the PCS mesh bounding box.
  72301. * doc :
  72302. */
  72303. setVisibilityBox(size: number): void;
  72304. /**
  72305. * Gets whether the PCS is always visible or not
  72306. * doc :
  72307. */
  72308. get isAlwaysVisible(): boolean;
  72309. /**
  72310. * Sets the PCS as always visible or not
  72311. * doc :
  72312. */
  72313. set isAlwaysVisible(val: boolean);
  72314. /**
  72315. * Tells to `setParticles()` to compute the particle rotations or not
  72316. * Default value : false. The PCS is faster when it's set to false
  72317. * Note : particle rotations are only applied to parent particles
  72318. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  72319. */
  72320. set computeParticleRotation(val: boolean);
  72321. /**
  72322. * Tells to `setParticles()` to compute the particle colors or not.
  72323. * Default value : true. The PCS is faster when it's set to false.
  72324. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72325. */
  72326. set computeParticleColor(val: boolean);
  72327. set computeParticleTexture(val: boolean);
  72328. /**
  72329. * Gets if `setParticles()` computes the particle colors or not.
  72330. * Default value : false. The PCS is faster when it's set to false.
  72331. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72332. */
  72333. get computeParticleColor(): boolean;
  72334. /**
  72335. * Gets if `setParticles()` computes the particle textures or not.
  72336. * Default value : false. The PCS is faster when it's set to false.
  72337. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  72338. */
  72339. get computeParticleTexture(): boolean;
  72340. /**
  72341. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  72342. */
  72343. set computeBoundingBox(val: boolean);
  72344. /**
  72345. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  72346. */
  72347. get computeBoundingBox(): boolean;
  72348. /**
  72349. * This function does nothing. It may be overwritten to set all the particle first values.
  72350. * The PCS doesn't call this function, you may have to call it by your own.
  72351. * doc :
  72352. */
  72353. initParticles(): void;
  72354. /**
  72355. * This function does nothing. It may be overwritten to recycle a particle
  72356. * The PCS doesn't call this function, you can to call it
  72357. * doc :
  72358. * @param particle The particle to recycle
  72359. * @returns the recycled particle
  72360. */
  72361. recycleParticle(particle: CloudPoint): CloudPoint;
  72362. /**
  72363. * Updates a particle : this function should be overwritten by the user.
  72364. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  72365. * doc :
  72366. * @example : just set a particle position or velocity and recycle conditions
  72367. * @param particle The particle to update
  72368. * @returns the updated particle
  72369. */
  72370. updateParticle(particle: CloudPoint): CloudPoint;
  72371. /**
  72372. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  72373. * This does nothing and may be overwritten by the user.
  72374. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72375. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72376. * @param update the boolean update value actually passed to setParticles()
  72377. */
  72378. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72379. /**
  72380. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  72381. * This will be passed three parameters.
  72382. * This does nothing and may be overwritten by the user.
  72383. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72384. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72385. * @param update the boolean update value actually passed to setParticles()
  72386. */
  72387. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72388. }
  72389. }
  72390. declare module BABYLON {
  72391. /**
  72392. * Represents one particle of a points cloud system.
  72393. */
  72394. export class CloudPoint {
  72395. /**
  72396. * particle global index
  72397. */
  72398. idx: number;
  72399. /**
  72400. * The color of the particle
  72401. */
  72402. color: Nullable<Color4>;
  72403. /**
  72404. * The world space position of the particle.
  72405. */
  72406. position: Vector3;
  72407. /**
  72408. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  72409. */
  72410. rotation: Vector3;
  72411. /**
  72412. * The world space rotation quaternion of the particle.
  72413. */
  72414. rotationQuaternion: Nullable<Quaternion>;
  72415. /**
  72416. * The uv of the particle.
  72417. */
  72418. uv: Nullable<Vector2>;
  72419. /**
  72420. * The current speed of the particle.
  72421. */
  72422. velocity: Vector3;
  72423. /**
  72424. * The pivot point in the particle local space.
  72425. */
  72426. pivot: Vector3;
  72427. /**
  72428. * Must the particle be translated from its pivot point in its local space ?
  72429. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  72430. * Default : false
  72431. */
  72432. translateFromPivot: boolean;
  72433. /**
  72434. * Index of this particle in the global "positions" array (Internal use)
  72435. * @hidden
  72436. */
  72437. _pos: number;
  72438. /**
  72439. * @hidden Index of this particle in the global "indices" array (Internal use)
  72440. */
  72441. _ind: number;
  72442. /**
  72443. * Group this particle belongs to
  72444. */
  72445. _group: PointsGroup;
  72446. /**
  72447. * Group id of this particle
  72448. */
  72449. groupId: number;
  72450. /**
  72451. * Index of the particle in its group id (Internal use)
  72452. */
  72453. idxInGroup: number;
  72454. /**
  72455. * @hidden Particle BoundingInfo object (Internal use)
  72456. */
  72457. _boundingInfo: BoundingInfo;
  72458. /**
  72459. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72460. */
  72461. _pcs: PointsCloudSystem;
  72462. /**
  72463. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72464. */
  72465. _stillInvisible: boolean;
  72466. /**
  72467. * @hidden Last computed particle rotation matrix
  72468. */
  72469. _rotationMatrix: number[];
  72470. /**
  72471. * Parent particle Id, if any.
  72472. * Default null.
  72473. */
  72474. parentId: Nullable<number>;
  72475. /**
  72476. * @hidden Internal global position in the PCS.
  72477. */
  72478. _globalPosition: Vector3;
  72479. /**
  72480. * Creates a Point Cloud object.
  72481. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72482. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72483. * @param group (PointsGroup) is the group the particle belongs to
  72484. * @param groupId (integer) is the group identifier in the PCS.
  72485. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72486. * @param pcs defines the PCS it is associated to
  72487. */
  72488. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72489. /**
  72490. * get point size
  72491. */
  72492. get size(): Vector3;
  72493. /**
  72494. * Set point size
  72495. */
  72496. set size(scale: Vector3);
  72497. /**
  72498. * Legacy support, changed quaternion to rotationQuaternion
  72499. */
  72500. get quaternion(): Nullable<Quaternion>;
  72501. /**
  72502. * Legacy support, changed quaternion to rotationQuaternion
  72503. */
  72504. set quaternion(q: Nullable<Quaternion>);
  72505. /**
  72506. * Returns a boolean. True if the particle intersects a mesh, else false
  72507. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72508. * @param target is the object (point or mesh) what the intersection is computed against
  72509. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72510. * @returns true if it intersects
  72511. */
  72512. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72513. /**
  72514. * get the rotation matrix of the particle
  72515. * @hidden
  72516. */
  72517. getRotationMatrix(m: Matrix): void;
  72518. }
  72519. /**
  72520. * Represents a group of points in a points cloud system
  72521. * * PCS internal tool, don't use it manually.
  72522. */
  72523. export class PointsGroup {
  72524. /**
  72525. * The group id
  72526. * @hidden
  72527. */
  72528. groupID: number;
  72529. /**
  72530. * image data for group (internal use)
  72531. * @hidden
  72532. */
  72533. _groupImageData: Nullable<ArrayBufferView>;
  72534. /**
  72535. * Image Width (internal use)
  72536. * @hidden
  72537. */
  72538. _groupImgWidth: number;
  72539. /**
  72540. * Image Height (internal use)
  72541. * @hidden
  72542. */
  72543. _groupImgHeight: number;
  72544. /**
  72545. * Custom position function (internal use)
  72546. * @hidden
  72547. */
  72548. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72549. /**
  72550. * density per facet for surface points
  72551. * @hidden
  72552. */
  72553. _groupDensity: number[];
  72554. /**
  72555. * Only when points are colored by texture carries pointer to texture list array
  72556. * @hidden
  72557. */
  72558. _textureNb: number;
  72559. /**
  72560. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72561. * PCS internal tool, don't use it manually.
  72562. * @hidden
  72563. */
  72564. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72565. }
  72566. }
  72567. declare module BABYLON {
  72568. interface Scene {
  72569. /** @hidden (Backing field) */
  72570. _physicsEngine: Nullable<IPhysicsEngine>;
  72571. /** @hidden */
  72572. _physicsTimeAccumulator: number;
  72573. /**
  72574. * Gets the current physics engine
  72575. * @returns a IPhysicsEngine or null if none attached
  72576. */
  72577. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72578. /**
  72579. * Enables physics to the current scene
  72580. * @param gravity defines the scene's gravity for the physics engine
  72581. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72582. * @return a boolean indicating if the physics engine was initialized
  72583. */
  72584. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72585. /**
  72586. * Disables and disposes the physics engine associated with the scene
  72587. */
  72588. disablePhysicsEngine(): void;
  72589. /**
  72590. * Gets a boolean indicating if there is an active physics engine
  72591. * @returns a boolean indicating if there is an active physics engine
  72592. */
  72593. isPhysicsEnabled(): boolean;
  72594. /**
  72595. * Deletes a physics compound impostor
  72596. * @param compound defines the compound to delete
  72597. */
  72598. deleteCompoundImpostor(compound: any): void;
  72599. /**
  72600. * An event triggered when physic simulation is about to be run
  72601. */
  72602. onBeforePhysicsObservable: Observable<Scene>;
  72603. /**
  72604. * An event triggered when physic simulation has been done
  72605. */
  72606. onAfterPhysicsObservable: Observable<Scene>;
  72607. }
  72608. interface AbstractMesh {
  72609. /** @hidden */
  72610. _physicsImpostor: Nullable<PhysicsImpostor>;
  72611. /**
  72612. * Gets or sets impostor used for physic simulation
  72613. * @see https://doc.babylonjs.com/features/physics_engine
  72614. */
  72615. physicsImpostor: Nullable<PhysicsImpostor>;
  72616. /**
  72617. * Gets the current physics impostor
  72618. * @see https://doc.babylonjs.com/features/physics_engine
  72619. * @returns a physics impostor or null
  72620. */
  72621. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72622. /** Apply a physic impulse to the mesh
  72623. * @param force defines the force to apply
  72624. * @param contactPoint defines where to apply the force
  72625. * @returns the current mesh
  72626. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72627. */
  72628. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72629. /**
  72630. * Creates a physic joint between two meshes
  72631. * @param otherMesh defines the other mesh to use
  72632. * @param pivot1 defines the pivot to use on this mesh
  72633. * @param pivot2 defines the pivot to use on the other mesh
  72634. * @param options defines additional options (can be plugin dependent)
  72635. * @returns the current mesh
  72636. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72637. */
  72638. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72639. /** @hidden */
  72640. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72641. }
  72642. /**
  72643. * Defines the physics engine scene component responsible to manage a physics engine
  72644. */
  72645. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72646. /**
  72647. * The component name helpful to identify the component in the list of scene components.
  72648. */
  72649. readonly name: string;
  72650. /**
  72651. * The scene the component belongs to.
  72652. */
  72653. scene: Scene;
  72654. /**
  72655. * Creates a new instance of the component for the given scene
  72656. * @param scene Defines the scene to register the component in
  72657. */
  72658. constructor(scene: Scene);
  72659. /**
  72660. * Registers the component in a given scene
  72661. */
  72662. register(): void;
  72663. /**
  72664. * Rebuilds the elements related to this component in case of
  72665. * context lost for instance.
  72666. */
  72667. rebuild(): void;
  72668. /**
  72669. * Disposes the component and the associated ressources
  72670. */
  72671. dispose(): void;
  72672. }
  72673. }
  72674. declare module BABYLON {
  72675. /**
  72676. * A helper for physics simulations
  72677. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72678. */
  72679. export class PhysicsHelper {
  72680. private _scene;
  72681. private _physicsEngine;
  72682. /**
  72683. * Initializes the Physics helper
  72684. * @param scene Babylon.js scene
  72685. */
  72686. constructor(scene: Scene);
  72687. /**
  72688. * Applies a radial explosion impulse
  72689. * @param origin the origin of the explosion
  72690. * @param radiusOrEventOptions the radius or the options of radial explosion
  72691. * @param strength the explosion strength
  72692. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72693. * @returns A physics radial explosion event, or null
  72694. */
  72695. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72696. /**
  72697. * Applies a radial explosion force
  72698. * @param origin the origin of the explosion
  72699. * @param radiusOrEventOptions the radius or the options of radial explosion
  72700. * @param strength the explosion strength
  72701. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72702. * @returns A physics radial explosion event, or null
  72703. */
  72704. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72705. /**
  72706. * Creates a gravitational field
  72707. * @param origin the origin of the explosion
  72708. * @param radiusOrEventOptions the radius or the options of radial explosion
  72709. * @param strength the explosion strength
  72710. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72711. * @returns A physics gravitational field event, or null
  72712. */
  72713. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72714. /**
  72715. * Creates a physics updraft event
  72716. * @param origin the origin of the updraft
  72717. * @param radiusOrEventOptions the radius or the options of the updraft
  72718. * @param strength the strength of the updraft
  72719. * @param height the height of the updraft
  72720. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  72721. * @returns A physics updraft event, or null
  72722. */
  72723. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  72724. /**
  72725. * Creates a physics vortex event
  72726. * @param origin the of the vortex
  72727. * @param radiusOrEventOptions the radius or the options of the vortex
  72728. * @param strength the strength of the vortex
  72729. * @param height the height of the vortex
  72730. * @returns a Physics vortex event, or null
  72731. * A physics vortex event or null
  72732. */
  72733. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  72734. }
  72735. /**
  72736. * Represents a physics radial explosion event
  72737. */
  72738. class PhysicsRadialExplosionEvent {
  72739. private _scene;
  72740. private _options;
  72741. private _sphere;
  72742. private _dataFetched;
  72743. /**
  72744. * Initializes a radial explosioin event
  72745. * @param _scene BabylonJS scene
  72746. * @param _options The options for the vortex event
  72747. */
  72748. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  72749. /**
  72750. * Returns the data related to the radial explosion event (sphere).
  72751. * @returns The radial explosion event data
  72752. */
  72753. getData(): PhysicsRadialExplosionEventData;
  72754. /**
  72755. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  72756. * @param impostor A physics imposter
  72757. * @param origin the origin of the explosion
  72758. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  72759. */
  72760. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  72761. /**
  72762. * Triggers affecterd impostors callbacks
  72763. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  72764. */
  72765. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  72766. /**
  72767. * Disposes the sphere.
  72768. * @param force Specifies if the sphere should be disposed by force
  72769. */
  72770. dispose(force?: boolean): void;
  72771. /*** Helpers ***/
  72772. private _prepareSphere;
  72773. private _intersectsWithSphere;
  72774. }
  72775. /**
  72776. * Represents a gravitational field event
  72777. */
  72778. class PhysicsGravitationalFieldEvent {
  72779. private _physicsHelper;
  72780. private _scene;
  72781. private _origin;
  72782. private _options;
  72783. private _tickCallback;
  72784. private _sphere;
  72785. private _dataFetched;
  72786. /**
  72787. * Initializes the physics gravitational field event
  72788. * @param _physicsHelper A physics helper
  72789. * @param _scene BabylonJS scene
  72790. * @param _origin The origin position of the gravitational field event
  72791. * @param _options The options for the vortex event
  72792. */
  72793. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  72794. /**
  72795. * Returns the data related to the gravitational field event (sphere).
  72796. * @returns A gravitational field event
  72797. */
  72798. getData(): PhysicsGravitationalFieldEventData;
  72799. /**
  72800. * Enables the gravitational field.
  72801. */
  72802. enable(): void;
  72803. /**
  72804. * Disables the gravitational field.
  72805. */
  72806. disable(): void;
  72807. /**
  72808. * Disposes the sphere.
  72809. * @param force The force to dispose from the gravitational field event
  72810. */
  72811. dispose(force?: boolean): void;
  72812. private _tick;
  72813. }
  72814. /**
  72815. * Represents a physics updraft event
  72816. */
  72817. class PhysicsUpdraftEvent {
  72818. private _scene;
  72819. private _origin;
  72820. private _options;
  72821. private _physicsEngine;
  72822. private _originTop;
  72823. private _originDirection;
  72824. private _tickCallback;
  72825. private _cylinder;
  72826. private _cylinderPosition;
  72827. private _dataFetched;
  72828. /**
  72829. * Initializes the physics updraft event
  72830. * @param _scene BabylonJS scene
  72831. * @param _origin The origin position of the updraft
  72832. * @param _options The options for the updraft event
  72833. */
  72834. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  72835. /**
  72836. * Returns the data related to the updraft event (cylinder).
  72837. * @returns A physics updraft event
  72838. */
  72839. getData(): PhysicsUpdraftEventData;
  72840. /**
  72841. * Enables the updraft.
  72842. */
  72843. enable(): void;
  72844. /**
  72845. * Disables the updraft.
  72846. */
  72847. disable(): void;
  72848. /**
  72849. * Disposes the cylinder.
  72850. * @param force Specifies if the updraft should be disposed by force
  72851. */
  72852. dispose(force?: boolean): void;
  72853. private getImpostorHitData;
  72854. private _tick;
  72855. /*** Helpers ***/
  72856. private _prepareCylinder;
  72857. private _intersectsWithCylinder;
  72858. }
  72859. /**
  72860. * Represents a physics vortex event
  72861. */
  72862. class PhysicsVortexEvent {
  72863. private _scene;
  72864. private _origin;
  72865. private _options;
  72866. private _physicsEngine;
  72867. private _originTop;
  72868. private _tickCallback;
  72869. private _cylinder;
  72870. private _cylinderPosition;
  72871. private _dataFetched;
  72872. /**
  72873. * Initializes the physics vortex event
  72874. * @param _scene The BabylonJS scene
  72875. * @param _origin The origin position of the vortex
  72876. * @param _options The options for the vortex event
  72877. */
  72878. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  72879. /**
  72880. * Returns the data related to the vortex event (cylinder).
  72881. * @returns The physics vortex event data
  72882. */
  72883. getData(): PhysicsVortexEventData;
  72884. /**
  72885. * Enables the vortex.
  72886. */
  72887. enable(): void;
  72888. /**
  72889. * Disables the cortex.
  72890. */
  72891. disable(): void;
  72892. /**
  72893. * Disposes the sphere.
  72894. * @param force
  72895. */
  72896. dispose(force?: boolean): void;
  72897. private getImpostorHitData;
  72898. private _tick;
  72899. /*** Helpers ***/
  72900. private _prepareCylinder;
  72901. private _intersectsWithCylinder;
  72902. }
  72903. /**
  72904. * Options fot the radial explosion event
  72905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72906. */
  72907. export class PhysicsRadialExplosionEventOptions {
  72908. /**
  72909. * The radius of the sphere for the radial explosion.
  72910. */
  72911. radius: number;
  72912. /**
  72913. * The strenth of the explosion.
  72914. */
  72915. strength: number;
  72916. /**
  72917. * The strenght of the force in correspondence to the distance of the affected object
  72918. */
  72919. falloff: PhysicsRadialImpulseFalloff;
  72920. /**
  72921. * Sphere options for the radial explosion.
  72922. */
  72923. sphere: {
  72924. segments: number;
  72925. diameter: number;
  72926. };
  72927. /**
  72928. * Sphere options for the radial explosion.
  72929. */
  72930. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  72931. }
  72932. /**
  72933. * Options fot the updraft event
  72934. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72935. */
  72936. export class PhysicsUpdraftEventOptions {
  72937. /**
  72938. * The radius of the cylinder for the vortex
  72939. */
  72940. radius: number;
  72941. /**
  72942. * The strenth of the updraft.
  72943. */
  72944. strength: number;
  72945. /**
  72946. * The height of the cylinder for the updraft.
  72947. */
  72948. height: number;
  72949. /**
  72950. * The mode for the the updraft.
  72951. */
  72952. updraftMode: PhysicsUpdraftMode;
  72953. }
  72954. /**
  72955. * Options fot the vortex event
  72956. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72957. */
  72958. export class PhysicsVortexEventOptions {
  72959. /**
  72960. * The radius of the cylinder for the vortex
  72961. */
  72962. radius: number;
  72963. /**
  72964. * The strenth of the vortex.
  72965. */
  72966. strength: number;
  72967. /**
  72968. * The height of the cylinder for the vortex.
  72969. */
  72970. height: number;
  72971. /**
  72972. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  72973. */
  72974. centripetalForceThreshold: number;
  72975. /**
  72976. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  72977. */
  72978. centripetalForceMultiplier: number;
  72979. /**
  72980. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  72981. */
  72982. centrifugalForceMultiplier: number;
  72983. /**
  72984. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  72985. */
  72986. updraftForceMultiplier: number;
  72987. }
  72988. /**
  72989. * The strenght of the force in correspondence to the distance of the affected object
  72990. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72991. */
  72992. export enum PhysicsRadialImpulseFalloff {
  72993. /** Defines that impulse is constant in strength across it's whole radius */
  72994. Constant = 0,
  72995. /** Defines that impulse gets weaker if it's further from the origin */
  72996. Linear = 1
  72997. }
  72998. /**
  72999. * The strength of the force in correspondence to the distance of the affected object
  73000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73001. */
  73002. export enum PhysicsUpdraftMode {
  73003. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  73004. Center = 0,
  73005. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  73006. Perpendicular = 1
  73007. }
  73008. /**
  73009. * Interface for a physics hit data
  73010. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73011. */
  73012. export interface PhysicsHitData {
  73013. /**
  73014. * The force applied at the contact point
  73015. */
  73016. force: Vector3;
  73017. /**
  73018. * The contact point
  73019. */
  73020. contactPoint: Vector3;
  73021. /**
  73022. * The distance from the origin to the contact point
  73023. */
  73024. distanceFromOrigin: number;
  73025. }
  73026. /**
  73027. * Interface for radial explosion event data
  73028. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73029. */
  73030. export interface PhysicsRadialExplosionEventData {
  73031. /**
  73032. * A sphere used for the radial explosion event
  73033. */
  73034. sphere: Mesh;
  73035. }
  73036. /**
  73037. * Interface for gravitational field event data
  73038. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73039. */
  73040. export interface PhysicsGravitationalFieldEventData {
  73041. /**
  73042. * A sphere mesh used for the gravitational field event
  73043. */
  73044. sphere: Mesh;
  73045. }
  73046. /**
  73047. * Interface for updraft event data
  73048. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73049. */
  73050. export interface PhysicsUpdraftEventData {
  73051. /**
  73052. * A cylinder used for the updraft event
  73053. */
  73054. cylinder: Mesh;
  73055. }
  73056. /**
  73057. * Interface for vortex event data
  73058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73059. */
  73060. export interface PhysicsVortexEventData {
  73061. /**
  73062. * A cylinder used for the vortex event
  73063. */
  73064. cylinder: Mesh;
  73065. }
  73066. /**
  73067. * Interface for an affected physics impostor
  73068. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73069. */
  73070. export interface PhysicsAffectedImpostorWithData {
  73071. /**
  73072. * The impostor affected by the effect
  73073. */
  73074. impostor: PhysicsImpostor;
  73075. /**
  73076. * The data about the hit/horce from the explosion
  73077. */
  73078. hitData: PhysicsHitData;
  73079. }
  73080. }
  73081. declare module BABYLON {
  73082. /** @hidden */
  73083. export var blackAndWhitePixelShader: {
  73084. name: string;
  73085. shader: string;
  73086. };
  73087. }
  73088. declare module BABYLON {
  73089. /**
  73090. * Post process used to render in black and white
  73091. */
  73092. export class BlackAndWhitePostProcess extends PostProcess {
  73093. /**
  73094. * Linear about to convert he result to black and white (default: 1)
  73095. */
  73096. degree: number;
  73097. /**
  73098. * Gets a string identifying the name of the class
  73099. * @returns "BlackAndWhitePostProcess" string
  73100. */
  73101. getClassName(): string;
  73102. /**
  73103. * Creates a black and white post process
  73104. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  73105. * @param name The name of the effect.
  73106. * @param options The required width/height ratio to downsize to before computing the render pass.
  73107. * @param camera The camera to apply the render pass to.
  73108. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73109. * @param engine The engine which the post process will be applied. (default: current engine)
  73110. * @param reusable If the post process can be reused on the same frame. (default: false)
  73111. */
  73112. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73113. /** @hidden */
  73114. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  73115. }
  73116. }
  73117. declare module BABYLON {
  73118. /**
  73119. * This represents a set of one or more post processes in Babylon.
  73120. * A post process can be used to apply a shader to a texture after it is rendered.
  73121. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73122. */
  73123. export class PostProcessRenderEffect {
  73124. private _postProcesses;
  73125. private _getPostProcesses;
  73126. private _singleInstance;
  73127. private _cameras;
  73128. private _indicesForCamera;
  73129. /**
  73130. * Name of the effect
  73131. * @hidden
  73132. */
  73133. _name: string;
  73134. /**
  73135. * Instantiates a post process render effect.
  73136. * A post process can be used to apply a shader to a texture after it is rendered.
  73137. * @param engine The engine the effect is tied to
  73138. * @param name The name of the effect
  73139. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  73140. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  73141. */
  73142. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  73143. /**
  73144. * Checks if all the post processes in the effect are supported.
  73145. */
  73146. get isSupported(): boolean;
  73147. /**
  73148. * Updates the current state of the effect
  73149. * @hidden
  73150. */
  73151. _update(): void;
  73152. /**
  73153. * Attaches the effect on cameras
  73154. * @param cameras The camera to attach to.
  73155. * @hidden
  73156. */
  73157. _attachCameras(cameras: Camera): void;
  73158. /**
  73159. * Attaches the effect on cameras
  73160. * @param cameras The camera to attach to.
  73161. * @hidden
  73162. */
  73163. _attachCameras(cameras: Camera[]): void;
  73164. /**
  73165. * Detaches the effect on cameras
  73166. * @param cameras The camera to detatch from.
  73167. * @hidden
  73168. */
  73169. _detachCameras(cameras: Camera): void;
  73170. /**
  73171. * Detatches the effect on cameras
  73172. * @param cameras The camera to detatch from.
  73173. * @hidden
  73174. */
  73175. _detachCameras(cameras: Camera[]): void;
  73176. /**
  73177. * Enables the effect on given cameras
  73178. * @param cameras The camera to enable.
  73179. * @hidden
  73180. */
  73181. _enable(cameras: Camera): void;
  73182. /**
  73183. * Enables the effect on given cameras
  73184. * @param cameras The camera to enable.
  73185. * @hidden
  73186. */
  73187. _enable(cameras: Nullable<Camera[]>): void;
  73188. /**
  73189. * Disables the effect on the given cameras
  73190. * @param cameras The camera to disable.
  73191. * @hidden
  73192. */
  73193. _disable(cameras: Camera): void;
  73194. /**
  73195. * Disables the effect on the given cameras
  73196. * @param cameras The camera to disable.
  73197. * @hidden
  73198. */
  73199. _disable(cameras: Nullable<Camera[]>): void;
  73200. /**
  73201. * Gets a list of the post processes contained in the effect.
  73202. * @param camera The camera to get the post processes on.
  73203. * @returns The list of the post processes in the effect.
  73204. */
  73205. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  73206. }
  73207. }
  73208. declare module BABYLON {
  73209. /** @hidden */
  73210. export var extractHighlightsPixelShader: {
  73211. name: string;
  73212. shader: string;
  73213. };
  73214. }
  73215. declare module BABYLON {
  73216. /**
  73217. * 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.
  73218. */
  73219. export class ExtractHighlightsPostProcess extends PostProcess {
  73220. /**
  73221. * The luminance threshold, pixels below this value will be set to black.
  73222. */
  73223. threshold: number;
  73224. /** @hidden */
  73225. _exposure: number;
  73226. /**
  73227. * Post process which has the input texture to be used when performing highlight extraction
  73228. * @hidden
  73229. */
  73230. _inputPostProcess: Nullable<PostProcess>;
  73231. /**
  73232. * Gets a string identifying the name of the class
  73233. * @returns "ExtractHighlightsPostProcess" string
  73234. */
  73235. getClassName(): string;
  73236. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73237. }
  73238. }
  73239. declare module BABYLON {
  73240. /** @hidden */
  73241. export var bloomMergePixelShader: {
  73242. name: string;
  73243. shader: string;
  73244. };
  73245. }
  73246. declare module BABYLON {
  73247. /**
  73248. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73249. */
  73250. export class BloomMergePostProcess extends PostProcess {
  73251. /** Weight of the bloom to be added to the original input. */
  73252. weight: number;
  73253. /**
  73254. * Gets a string identifying the name of the class
  73255. * @returns "BloomMergePostProcess" string
  73256. */
  73257. getClassName(): string;
  73258. /**
  73259. * Creates a new instance of @see BloomMergePostProcess
  73260. * @param name The name of the effect.
  73261. * @param originalFromInput Post process which's input will be used for the merge.
  73262. * @param blurred Blurred highlights post process which's output will be used.
  73263. * @param weight Weight of the bloom to be added to the original input.
  73264. * @param options The required width/height ratio to downsize to before computing the render pass.
  73265. * @param camera The camera to apply the render pass to.
  73266. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73267. * @param engine The engine which the post process will be applied. (default: current engine)
  73268. * @param reusable If the post process can be reused on the same frame. (default: false)
  73269. * @param textureType Type of textures used when performing the post process. (default: 0)
  73270. * @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)
  73271. */
  73272. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  73273. /** Weight of the bloom to be added to the original input. */
  73274. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73275. }
  73276. }
  73277. declare module BABYLON {
  73278. /**
  73279. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  73280. */
  73281. export class BloomEffect extends PostProcessRenderEffect {
  73282. private bloomScale;
  73283. /**
  73284. * @hidden Internal
  73285. */
  73286. _effects: Array<PostProcess>;
  73287. /**
  73288. * @hidden Internal
  73289. */
  73290. _downscale: ExtractHighlightsPostProcess;
  73291. private _blurX;
  73292. private _blurY;
  73293. private _merge;
  73294. /**
  73295. * The luminance threshold to find bright areas of the image to bloom.
  73296. */
  73297. get threshold(): number;
  73298. set threshold(value: number);
  73299. /**
  73300. * The strength of the bloom.
  73301. */
  73302. get weight(): number;
  73303. set weight(value: number);
  73304. /**
  73305. * Specifies the size of the bloom blur kernel, relative to the final output size
  73306. */
  73307. get kernel(): number;
  73308. set kernel(value: number);
  73309. /**
  73310. * Creates a new instance of @see BloomEffect
  73311. * @param scene The scene the effect belongs to.
  73312. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  73313. * @param bloomKernel The size of the kernel to be used when applying the blur.
  73314. * @param bloomWeight The the strength of bloom.
  73315. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73316. * @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)
  73317. */
  73318. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  73319. /**
  73320. * Disposes each of the internal effects for a given camera.
  73321. * @param camera The camera to dispose the effect on.
  73322. */
  73323. disposeEffects(camera: Camera): void;
  73324. /**
  73325. * @hidden Internal
  73326. */
  73327. _updateEffects(): void;
  73328. /**
  73329. * Internal
  73330. * @returns if all the contained post processes are ready.
  73331. * @hidden
  73332. */
  73333. _isReady(): boolean;
  73334. }
  73335. }
  73336. declare module BABYLON {
  73337. /** @hidden */
  73338. export var chromaticAberrationPixelShader: {
  73339. name: string;
  73340. shader: string;
  73341. };
  73342. }
  73343. declare module BABYLON {
  73344. /**
  73345. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  73346. */
  73347. export class ChromaticAberrationPostProcess extends PostProcess {
  73348. /**
  73349. * The amount of seperation of rgb channels (default: 30)
  73350. */
  73351. aberrationAmount: number;
  73352. /**
  73353. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73354. */
  73355. radialIntensity: number;
  73356. /**
  73357. * The normilized direction in which the rgb channels should be seperated. If set to 0,0 radial direction will be used. (default: Vector2(0.707,0.707))
  73358. */
  73359. direction: Vector2;
  73360. /**
  73361. * The center position where the radialIntensity should be around. [0.5,0.5 is center of screen, 1,1 is top right corder] (default: Vector2(0.5 ,0.5))
  73362. */
  73363. centerPosition: Vector2;
  73364. /** The width of the screen to apply the effect on */
  73365. screenWidth: number;
  73366. /** The height of the screen to apply the effect on */
  73367. screenHeight: number;
  73368. /**
  73369. * Gets a string identifying the name of the class
  73370. * @returns "ChromaticAberrationPostProcess" string
  73371. */
  73372. getClassName(): string;
  73373. /**
  73374. * Creates a new instance ChromaticAberrationPostProcess
  73375. * @param name The name of the effect.
  73376. * @param screenWidth The width of the screen to apply the effect on.
  73377. * @param screenHeight The height of the screen to apply the effect on.
  73378. * @param options The required width/height ratio to downsize to before computing the render pass.
  73379. * @param camera The camera to apply the render pass to.
  73380. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73381. * @param engine The engine which the post process will be applied. (default: current engine)
  73382. * @param reusable If the post process can be reused on the same frame. (default: false)
  73383. * @param textureType Type of textures used when performing the post process. (default: 0)
  73384. * @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)
  73385. */
  73386. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73387. /** @hidden */
  73388. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73389. }
  73390. }
  73391. declare module BABYLON {
  73392. /** @hidden */
  73393. export var circleOfConfusionPixelShader: {
  73394. name: string;
  73395. shader: string;
  73396. };
  73397. }
  73398. declare module BABYLON {
  73399. /**
  73400. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73401. */
  73402. export class CircleOfConfusionPostProcess extends PostProcess {
  73403. /**
  73404. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diamater of the resulting aperture can be computed by lensSize/fStop.
  73405. */
  73406. lensSize: number;
  73407. /**
  73408. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73409. */
  73410. fStop: number;
  73411. /**
  73412. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73413. */
  73414. focusDistance: number;
  73415. /**
  73416. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73417. */
  73418. focalLength: number;
  73419. /**
  73420. * Gets a string identifying the name of the class
  73421. * @returns "CircleOfConfusionPostProcess" string
  73422. */
  73423. getClassName(): string;
  73424. private _depthTexture;
  73425. /**
  73426. * Creates a new instance CircleOfConfusionPostProcess
  73427. * @param name The name of the effect.
  73428. * @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.
  73429. * @param options The required width/height ratio to downsize to before computing the render pass.
  73430. * @param camera The camera to apply the render pass to.
  73431. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73432. * @param engine The engine which the post process will be applied. (default: current engine)
  73433. * @param reusable If the post process can be reused on the same frame. (default: false)
  73434. * @param textureType Type of textures used when performing the post process. (default: 0)
  73435. * @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)
  73436. */
  73437. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73438. /**
  73439. * 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.
  73440. */
  73441. set depthTexture(value: RenderTargetTexture);
  73442. }
  73443. }
  73444. declare module BABYLON {
  73445. /** @hidden */
  73446. export var colorCorrectionPixelShader: {
  73447. name: string;
  73448. shader: string;
  73449. };
  73450. }
  73451. declare module BABYLON {
  73452. /**
  73453. *
  73454. * This post-process allows the modification of rendered colors by using
  73455. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73456. *
  73457. * The object needs to be provided an url to a texture containing the color
  73458. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73459. * Use an image editing software to tweak the LUT to match your needs.
  73460. *
  73461. * For an example of a color LUT, see here:
  73462. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73463. * For explanations on color grading, see here:
  73464. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73465. *
  73466. */
  73467. export class ColorCorrectionPostProcess extends PostProcess {
  73468. private _colorTableTexture;
  73469. /**
  73470. * Gets the color table url used to create the LUT texture
  73471. */
  73472. colorTableUrl: string;
  73473. /**
  73474. * Gets a string identifying the name of the class
  73475. * @returns "ColorCorrectionPostProcess" string
  73476. */
  73477. getClassName(): string;
  73478. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73479. /** @hidden */
  73480. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73481. }
  73482. }
  73483. declare module BABYLON {
  73484. /** @hidden */
  73485. export var convolutionPixelShader: {
  73486. name: string;
  73487. shader: string;
  73488. };
  73489. }
  73490. declare module BABYLON {
  73491. /**
  73492. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73493. * input texture to perform effects such as edge detection or sharpening
  73494. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73495. */
  73496. export class ConvolutionPostProcess extends PostProcess {
  73497. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73498. kernel: number[];
  73499. /**
  73500. * Gets a string identifying the name of the class
  73501. * @returns "ConvolutionPostProcess" string
  73502. */
  73503. getClassName(): string;
  73504. /**
  73505. * Creates a new instance ConvolutionPostProcess
  73506. * @param name The name of the effect.
  73507. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73508. * @param options The required width/height ratio to downsize to before computing the render pass.
  73509. * @param camera The camera to apply the render pass to.
  73510. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73511. * @param engine The engine which the post process will be applied. (default: current engine)
  73512. * @param reusable If the post process can be reused on the same frame. (default: false)
  73513. * @param textureType Type of textures used when performing the post process. (default: 0)
  73514. */
  73515. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73516. /** @hidden */
  73517. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73518. /**
  73519. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73520. */
  73521. static EdgeDetect0Kernel: number[];
  73522. /**
  73523. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73524. */
  73525. static EdgeDetect1Kernel: number[];
  73526. /**
  73527. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73528. */
  73529. static EdgeDetect2Kernel: number[];
  73530. /**
  73531. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73532. */
  73533. static SharpenKernel: number[];
  73534. /**
  73535. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73536. */
  73537. static EmbossKernel: number[];
  73538. /**
  73539. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73540. */
  73541. static GaussianKernel: number[];
  73542. }
  73543. }
  73544. declare module BABYLON {
  73545. /**
  73546. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73547. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73548. * based on samples that have a large difference in distance than the center pixel.
  73549. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73550. */
  73551. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73552. /**
  73553. * The direction the blur should be applied
  73554. */
  73555. direction: Vector2;
  73556. /**
  73557. * Gets a string identifying the name of the class
  73558. * @returns "DepthOfFieldBlurPostProcess" string
  73559. */
  73560. getClassName(): string;
  73561. /**
  73562. * Creates a new instance CircleOfConfusionPostProcess
  73563. * @param name The name of the effect.
  73564. * @param scene The scene the effect belongs to.
  73565. * @param direction The direction the blur should be applied.
  73566. * @param kernel The size of the kernel used to blur.
  73567. * @param options The required width/height ratio to downsize to before computing the render pass.
  73568. * @param camera The camera to apply the render pass to.
  73569. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73570. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73571. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73572. * @param engine The engine which the post process will be applied. (default: current engine)
  73573. * @param reusable If the post process can be reused on the same frame. (default: false)
  73574. * @param textureType Type of textures used when performing the post process. (default: 0)
  73575. * @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)
  73576. */
  73577. 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);
  73578. }
  73579. }
  73580. declare module BABYLON {
  73581. /** @hidden */
  73582. export var depthOfFieldMergePixelShader: {
  73583. name: string;
  73584. shader: string;
  73585. };
  73586. }
  73587. declare module BABYLON {
  73588. /**
  73589. * Options to be set when merging outputs from the default pipeline.
  73590. */
  73591. export class DepthOfFieldMergePostProcessOptions {
  73592. /**
  73593. * The original image to merge on top of
  73594. */
  73595. originalFromInput: PostProcess;
  73596. /**
  73597. * Parameters to perform the merge of the depth of field effect
  73598. */
  73599. depthOfField?: {
  73600. circleOfConfusion: PostProcess;
  73601. blurSteps: Array<PostProcess>;
  73602. };
  73603. /**
  73604. * Parameters to perform the merge of bloom effect
  73605. */
  73606. bloom?: {
  73607. blurred: PostProcess;
  73608. weight: number;
  73609. };
  73610. }
  73611. /**
  73612. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73613. */
  73614. export class DepthOfFieldMergePostProcess extends PostProcess {
  73615. private blurSteps;
  73616. /**
  73617. * Gets a string identifying the name of the class
  73618. * @returns "DepthOfFieldMergePostProcess" string
  73619. */
  73620. getClassName(): string;
  73621. /**
  73622. * Creates a new instance of DepthOfFieldMergePostProcess
  73623. * @param name The name of the effect.
  73624. * @param originalFromInput Post process which's input will be used for the merge.
  73625. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73626. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73627. * @param options The required width/height ratio to downsize to before computing the render pass.
  73628. * @param camera The camera to apply the render pass to.
  73629. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73630. * @param engine The engine which the post process will be applied. (default: current engine)
  73631. * @param reusable If the post process can be reused on the same frame. (default: false)
  73632. * @param textureType Type of textures used when performing the post process. (default: 0)
  73633. * @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)
  73634. */
  73635. 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);
  73636. /**
  73637. * Updates the effect with the current post process compile time values and recompiles the shader.
  73638. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73639. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73640. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73641. * @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
  73642. * @param onCompiled Called when the shader has been compiled.
  73643. * @param onError Called if there is an error when compiling a shader.
  73644. */
  73645. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73646. }
  73647. }
  73648. declare module BABYLON {
  73649. /**
  73650. * Specifies the level of max blur that should be applied when using the depth of field effect
  73651. */
  73652. export enum DepthOfFieldEffectBlurLevel {
  73653. /**
  73654. * Subtle blur
  73655. */
  73656. Low = 0,
  73657. /**
  73658. * Medium blur
  73659. */
  73660. Medium = 1,
  73661. /**
  73662. * Large blur
  73663. */
  73664. High = 2
  73665. }
  73666. /**
  73667. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73668. */
  73669. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73670. private _circleOfConfusion;
  73671. /**
  73672. * @hidden Internal, blurs from high to low
  73673. */
  73674. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73675. private _depthOfFieldBlurY;
  73676. private _dofMerge;
  73677. /**
  73678. * @hidden Internal post processes in depth of field effect
  73679. */
  73680. _effects: Array<PostProcess>;
  73681. /**
  73682. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73683. */
  73684. set focalLength(value: number);
  73685. get focalLength(): number;
  73686. /**
  73687. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73688. */
  73689. set fStop(value: number);
  73690. get fStop(): number;
  73691. /**
  73692. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73693. */
  73694. set focusDistance(value: number);
  73695. get focusDistance(): number;
  73696. /**
  73697. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diamater of the resulting aperture can be computed by lensSize/fStop.
  73698. */
  73699. set lensSize(value: number);
  73700. get lensSize(): number;
  73701. /**
  73702. * Creates a new instance DepthOfFieldEffect
  73703. * @param scene The scene the effect belongs to.
  73704. * @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.
  73705. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73706. * @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)
  73707. */
  73708. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  73709. /**
  73710. * Get the current class name of the current effet
  73711. * @returns "DepthOfFieldEffect"
  73712. */
  73713. getClassName(): string;
  73714. /**
  73715. * 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.
  73716. */
  73717. set depthTexture(value: RenderTargetTexture);
  73718. /**
  73719. * Disposes each of the internal effects for a given camera.
  73720. * @param camera The camera to dispose the effect on.
  73721. */
  73722. disposeEffects(camera: Camera): void;
  73723. /**
  73724. * @hidden Internal
  73725. */
  73726. _updateEffects(): void;
  73727. /**
  73728. * Internal
  73729. * @returns if all the contained post processes are ready.
  73730. * @hidden
  73731. */
  73732. _isReady(): boolean;
  73733. }
  73734. }
  73735. declare module BABYLON {
  73736. /** @hidden */
  73737. export var displayPassPixelShader: {
  73738. name: string;
  73739. shader: string;
  73740. };
  73741. }
  73742. declare module BABYLON {
  73743. /**
  73744. * DisplayPassPostProcess which produces an output the same as it's input
  73745. */
  73746. export class DisplayPassPostProcess extends PostProcess {
  73747. /**
  73748. * Gets a string identifying the name of the class
  73749. * @returns "DisplayPassPostProcess" string
  73750. */
  73751. getClassName(): string;
  73752. /**
  73753. * Creates the DisplayPassPostProcess
  73754. * @param name The name of the effect.
  73755. * @param options The required width/height ratio to downsize to before computing the render pass.
  73756. * @param camera The camera to apply the render pass to.
  73757. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73758. * @param engine The engine which the post process will be applied. (default: current engine)
  73759. * @param reusable If the post process can be reused on the same frame. (default: false)
  73760. */
  73761. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73762. /** @hidden */
  73763. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  73764. }
  73765. }
  73766. declare module BABYLON {
  73767. /** @hidden */
  73768. export var filterPixelShader: {
  73769. name: string;
  73770. shader: string;
  73771. };
  73772. }
  73773. declare module BABYLON {
  73774. /**
  73775. * Applies a kernel filter to the image
  73776. */
  73777. export class FilterPostProcess extends PostProcess {
  73778. /** The matrix to be applied to the image */
  73779. kernelMatrix: Matrix;
  73780. /**
  73781. * Gets a string identifying the name of the class
  73782. * @returns "FilterPostProcess" string
  73783. */
  73784. getClassName(): string;
  73785. /**
  73786. *
  73787. * @param name The name of the effect.
  73788. * @param kernelMatrix The matrix to be applied to the image
  73789. * @param options The required width/height ratio to downsize to before computing the render pass.
  73790. * @param camera The camera to apply the render pass to.
  73791. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73792. * @param engine The engine which the post process will be applied. (default: current engine)
  73793. * @param reusable If the post process can be reused on the same frame. (default: false)
  73794. */
  73795. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73796. /** @hidden */
  73797. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  73798. }
  73799. }
  73800. declare module BABYLON {
  73801. /** @hidden */
  73802. export var fxaaPixelShader: {
  73803. name: string;
  73804. shader: string;
  73805. };
  73806. }
  73807. declare module BABYLON {
  73808. /** @hidden */
  73809. export var fxaaVertexShader: {
  73810. name: string;
  73811. shader: string;
  73812. };
  73813. }
  73814. declare module BABYLON {
  73815. /**
  73816. * Fxaa post process
  73817. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  73818. */
  73819. export class FxaaPostProcess extends PostProcess {
  73820. /**
  73821. * Gets a string identifying the name of the class
  73822. * @returns "FxaaPostProcess" string
  73823. */
  73824. getClassName(): string;
  73825. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73826. private _getDefines;
  73827. /** @hidden */
  73828. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  73829. }
  73830. }
  73831. declare module BABYLON {
  73832. /** @hidden */
  73833. export var grainPixelShader: {
  73834. name: string;
  73835. shader: string;
  73836. };
  73837. }
  73838. declare module BABYLON {
  73839. /**
  73840. * The GrainPostProcess adds noise to the image at mid luminance levels
  73841. */
  73842. export class GrainPostProcess extends PostProcess {
  73843. /**
  73844. * The intensity of the grain added (default: 30)
  73845. */
  73846. intensity: number;
  73847. /**
  73848. * If the grain should be randomized on every frame
  73849. */
  73850. animated: boolean;
  73851. /**
  73852. * Gets a string identifying the name of the class
  73853. * @returns "GrainPostProcess" string
  73854. */
  73855. getClassName(): string;
  73856. /**
  73857. * Creates a new instance of @see GrainPostProcess
  73858. * @param name The name of the effect.
  73859. * @param options The required width/height ratio to downsize to before computing the render pass.
  73860. * @param camera The camera to apply the render pass to.
  73861. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73862. * @param engine The engine which the post process will be applied. (default: current engine)
  73863. * @param reusable If the post process can be reused on the same frame. (default: false)
  73864. * @param textureType Type of textures used when performing the post process. (default: 0)
  73865. * @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)
  73866. */
  73867. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73868. /** @hidden */
  73869. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  73870. }
  73871. }
  73872. declare module BABYLON {
  73873. /** @hidden */
  73874. export var highlightsPixelShader: {
  73875. name: string;
  73876. shader: string;
  73877. };
  73878. }
  73879. declare module BABYLON {
  73880. /**
  73881. * Extracts highlights from the image
  73882. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73883. */
  73884. export class HighlightsPostProcess extends PostProcess {
  73885. /**
  73886. * Gets a string identifying the name of the class
  73887. * @returns "HighlightsPostProcess" string
  73888. */
  73889. getClassName(): string;
  73890. /**
  73891. * Extracts highlights from the image
  73892. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73893. * @param name The name of the effect.
  73894. * @param options The required width/height ratio to downsize to before computing the render pass.
  73895. * @param camera The camera to apply the render pass to.
  73896. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73897. * @param engine The engine which the post process will be applied. (default: current engine)
  73898. * @param reusable If the post process can be reused on the same frame. (default: false)
  73899. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  73900. */
  73901. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73902. }
  73903. }
  73904. declare module BABYLON {
  73905. /**
  73906. * Contains all parameters needed for the prepass to perform
  73907. * motion blur
  73908. */
  73909. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  73910. /**
  73911. * Is motion blur enabled
  73912. */
  73913. enabled: boolean;
  73914. /**
  73915. * Name of the configuration
  73916. */
  73917. name: string;
  73918. /**
  73919. * Textures that should be present in the MRT for this effect to work
  73920. */
  73921. readonly texturesRequired: number[];
  73922. }
  73923. }
  73924. declare module BABYLON {
  73925. interface Scene {
  73926. /** @hidden (Backing field) */
  73927. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73928. /**
  73929. * Gets or Sets the current geometry buffer associated to the scene.
  73930. */
  73931. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73932. /**
  73933. * Enables a GeometryBufferRender and associates it with the scene
  73934. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  73935. * @returns the GeometryBufferRenderer
  73936. */
  73937. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  73938. /**
  73939. * Disables the GeometryBufferRender associated with the scene
  73940. */
  73941. disableGeometryBufferRenderer(): void;
  73942. }
  73943. /**
  73944. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73945. * in several rendering techniques.
  73946. */
  73947. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  73948. /**
  73949. * The component name helpful to identify the component in the list of scene components.
  73950. */
  73951. readonly name: string;
  73952. /**
  73953. * The scene the component belongs to.
  73954. */
  73955. scene: Scene;
  73956. /**
  73957. * Creates a new instance of the component for the given scene
  73958. * @param scene Defines the scene to register the component in
  73959. */
  73960. constructor(scene: Scene);
  73961. /**
  73962. * Registers the component in a given scene
  73963. */
  73964. register(): void;
  73965. /**
  73966. * Rebuilds the elements related to this component in case of
  73967. * context lost for instance.
  73968. */
  73969. rebuild(): void;
  73970. /**
  73971. * Disposes the component and the associated ressources
  73972. */
  73973. dispose(): void;
  73974. private _gatherRenderTargets;
  73975. }
  73976. }
  73977. declare module BABYLON {
  73978. /** @hidden */
  73979. export var motionBlurPixelShader: {
  73980. name: string;
  73981. shader: string;
  73982. };
  73983. }
  73984. declare module BABYLON {
  73985. /**
  73986. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  73987. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  73988. * As an example, all you have to do is to create the post-process:
  73989. * var mb = new BABYLON.MotionBlurPostProcess(
  73990. * 'mb', // The name of the effect.
  73991. * scene, // The scene containing the objects to blur according to their velocity.
  73992. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  73993. * camera // The camera to apply the render pass to.
  73994. * );
  73995. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  73996. */
  73997. export class MotionBlurPostProcess extends PostProcess {
  73998. /**
  73999. * Defines how much the image is blurred by the movement. Default value is equal to 1
  74000. */
  74001. motionStrength: number;
  74002. /**
  74003. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  74004. */
  74005. get motionBlurSamples(): number;
  74006. /**
  74007. * Sets the number of iterations to be used for motion blur quality
  74008. */
  74009. set motionBlurSamples(samples: number);
  74010. private _motionBlurSamples;
  74011. /**
  74012. * Gets wether or not the motion blur post-process is in object based mode.
  74013. */
  74014. get isObjectBased(): boolean;
  74015. /**
  74016. * Sets wether or not the motion blur post-process is in object based mode.
  74017. */
  74018. set isObjectBased(value: boolean);
  74019. private _isObjectBased;
  74020. private _forceGeometryBuffer;
  74021. private _geometryBufferRenderer;
  74022. private _prePassRenderer;
  74023. private _invViewProjection;
  74024. private _previousViewProjection;
  74025. /**
  74026. * Gets a string identifying the name of the class
  74027. * @returns "MotionBlurPostProcess" string
  74028. */
  74029. getClassName(): string;
  74030. /**
  74031. * Creates a new instance MotionBlurPostProcess
  74032. * @param name The name of the effect.
  74033. * @param scene The scene containing the objects to blur according to their velocity.
  74034. * @param options The required width/height ratio to downsize to before computing the render pass.
  74035. * @param camera The camera to apply the render pass to.
  74036. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74037. * @param engine The engine which the post process will be applied. (default: current engine)
  74038. * @param reusable If the post process can be reused on the same frame. (default: false)
  74039. * @param textureType Type of textures used when performing the post process. (default: 0)
  74040. * @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)
  74041. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74042. */
  74043. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74044. /**
  74045. * Excludes the given skinned mesh from computing bones velocities.
  74046. * 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.
  74047. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74048. */
  74049. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74050. /**
  74051. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74052. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74053. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74054. */
  74055. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74056. /**
  74057. * Disposes the post process.
  74058. * @param camera The camera to dispose the post process on.
  74059. */
  74060. dispose(camera?: Camera): void;
  74061. /**
  74062. * Called on the mode changed (object based or screen based).
  74063. */
  74064. private _applyMode;
  74065. /**
  74066. * Called on the effect is applied when the motion blur post-process is in object based mode.
  74067. */
  74068. private _onApplyObjectBased;
  74069. /**
  74070. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  74071. */
  74072. private _onApplyScreenBased;
  74073. /**
  74074. * Called on the effect must be updated (changed mode, samples count, etc.).
  74075. */
  74076. private _updateEffect;
  74077. /** @hidden */
  74078. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74079. }
  74080. }
  74081. declare module BABYLON {
  74082. /** @hidden */
  74083. export var refractionPixelShader: {
  74084. name: string;
  74085. shader: string;
  74086. };
  74087. }
  74088. declare module BABYLON {
  74089. /**
  74090. * Post process which applies a refractin texture
  74091. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74092. */
  74093. export class RefractionPostProcess extends PostProcess {
  74094. private _refTexture;
  74095. private _ownRefractionTexture;
  74096. /** the base color of the refraction (used to taint the rendering) */
  74097. color: Color3;
  74098. /** simulated refraction depth */
  74099. depth: number;
  74100. /** the coefficient of the base color (0 to remove base color tainting) */
  74101. colorLevel: number;
  74102. /** Gets the url used to load the refraction texture */
  74103. refractionTextureUrl: string;
  74104. /**
  74105. * Gets or sets the refraction texture
  74106. * Please note that you are responsible for disposing the texture if you set it manually
  74107. */
  74108. get refractionTexture(): Texture;
  74109. set refractionTexture(value: Texture);
  74110. /**
  74111. * Gets a string identifying the name of the class
  74112. * @returns "RefractionPostProcess" string
  74113. */
  74114. getClassName(): string;
  74115. /**
  74116. * Initializes the RefractionPostProcess
  74117. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74118. * @param name The name of the effect.
  74119. * @param refractionTextureUrl Url of the refraction texture to use
  74120. * @param color the base color of the refraction (used to taint the rendering)
  74121. * @param depth simulated refraction depth
  74122. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74123. * @param camera The camera to apply the render pass to.
  74124. * @param options The required width/height ratio to downsize to before computing the render pass.
  74125. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74126. * @param engine The engine which the post process will be applied. (default: current engine)
  74127. * @param reusable If the post process can be reused on the same frame. (default: false)
  74128. */
  74129. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74130. /**
  74131. * Disposes of the post process
  74132. * @param camera Camera to dispose post process on
  74133. */
  74134. dispose(camera: Camera): void;
  74135. /** @hidden */
  74136. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74137. }
  74138. }
  74139. declare module BABYLON {
  74140. /** @hidden */
  74141. export var sharpenPixelShader: {
  74142. name: string;
  74143. shader: string;
  74144. };
  74145. }
  74146. declare module BABYLON {
  74147. /**
  74148. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74149. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74150. */
  74151. export class SharpenPostProcess extends PostProcess {
  74152. /**
  74153. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74154. */
  74155. colorAmount: number;
  74156. /**
  74157. * How much sharpness should be applied (default: 0.3)
  74158. */
  74159. edgeAmount: number;
  74160. /**
  74161. * Gets a string identifying the name of the class
  74162. * @returns "SharpenPostProcess" string
  74163. */
  74164. getClassName(): string;
  74165. /**
  74166. * Creates a new instance ConvolutionPostProcess
  74167. * @param name The name of the effect.
  74168. * @param options The required width/height ratio to downsize to before computing the render pass.
  74169. * @param camera The camera to apply the render pass to.
  74170. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74171. * @param engine The engine which the post process will be applied. (default: current engine)
  74172. * @param reusable If the post process can be reused on the same frame. (default: false)
  74173. * @param textureType Type of textures used when performing the post process. (default: 0)
  74174. * @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)
  74175. */
  74176. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74177. /** @hidden */
  74178. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74179. }
  74180. }
  74181. declare module BABYLON {
  74182. /**
  74183. * PostProcessRenderPipeline
  74184. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74185. */
  74186. export class PostProcessRenderPipeline {
  74187. private engine;
  74188. private _renderEffects;
  74189. private _renderEffectsForIsolatedPass;
  74190. /**
  74191. * List of inspectable custom properties (used by the Inspector)
  74192. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74193. */
  74194. inspectableCustomProperties: IInspectable[];
  74195. /**
  74196. * @hidden
  74197. */
  74198. protected _cameras: Camera[];
  74199. /** @hidden */
  74200. _name: string;
  74201. /**
  74202. * Gets pipeline name
  74203. */
  74204. get name(): string;
  74205. /** Gets the list of attached cameras */
  74206. get cameras(): Camera[];
  74207. /**
  74208. * Initializes a PostProcessRenderPipeline
  74209. * @param engine engine to add the pipeline to
  74210. * @param name name of the pipeline
  74211. */
  74212. constructor(engine: Engine, name: string);
  74213. /**
  74214. * Gets the class name
  74215. * @returns "PostProcessRenderPipeline"
  74216. */
  74217. getClassName(): string;
  74218. /**
  74219. * If all the render effects in the pipeline are supported
  74220. */
  74221. get isSupported(): boolean;
  74222. /**
  74223. * Adds an effect to the pipeline
  74224. * @param renderEffect the effect to add
  74225. */
  74226. addEffect(renderEffect: PostProcessRenderEffect): void;
  74227. /** @hidden */
  74228. _rebuild(): void;
  74229. /** @hidden */
  74230. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74231. /** @hidden */
  74232. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74233. /** @hidden */
  74234. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74235. /** @hidden */
  74236. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74237. /** @hidden */
  74238. _attachCameras(cameras: Camera, unique: boolean): void;
  74239. /** @hidden */
  74240. _attachCameras(cameras: Camera[], unique: boolean): void;
  74241. /** @hidden */
  74242. _detachCameras(cameras: Camera): void;
  74243. /** @hidden */
  74244. _detachCameras(cameras: Nullable<Camera[]>): void;
  74245. /** @hidden */
  74246. _update(): void;
  74247. /** @hidden */
  74248. _reset(): void;
  74249. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74250. /**
  74251. * Sets the required values to the prepass renderer.
  74252. * @param prePassRenderer defines the prepass renderer to setup.
  74253. * @returns true if the pre pass is needed.
  74254. */
  74255. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74256. /**
  74257. * Disposes of the pipeline
  74258. */
  74259. dispose(): void;
  74260. }
  74261. }
  74262. declare module BABYLON {
  74263. /**
  74264. * PostProcessRenderPipelineManager class
  74265. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74266. */
  74267. export class PostProcessRenderPipelineManager {
  74268. private _renderPipelines;
  74269. /**
  74270. * Initializes a PostProcessRenderPipelineManager
  74271. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74272. */
  74273. constructor();
  74274. /**
  74275. * Gets the list of supported render pipelines
  74276. */
  74277. get supportedPipelines(): PostProcessRenderPipeline[];
  74278. /**
  74279. * Adds a pipeline to the manager
  74280. * @param renderPipeline The pipeline to add
  74281. */
  74282. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74283. /**
  74284. * Attaches a camera to the pipeline
  74285. * @param renderPipelineName The name of the pipeline to attach to
  74286. * @param cameras the camera to attach
  74287. * @param unique if the camera can be attached multiple times to the pipeline
  74288. */
  74289. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74290. /**
  74291. * Detaches a camera from the pipeline
  74292. * @param renderPipelineName The name of the pipeline to detach from
  74293. * @param cameras the camera to detach
  74294. */
  74295. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74296. /**
  74297. * Enables an effect by name on a pipeline
  74298. * @param renderPipelineName the name of the pipeline to enable the effect in
  74299. * @param renderEffectName the name of the effect to enable
  74300. * @param cameras the cameras that the effect should be enabled on
  74301. */
  74302. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74303. /**
  74304. * Disables an effect by name on a pipeline
  74305. * @param renderPipelineName the name of the pipeline to disable the effect in
  74306. * @param renderEffectName the name of the effect to disable
  74307. * @param cameras the cameras that the effect should be disabled on
  74308. */
  74309. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74310. /**
  74311. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74312. */
  74313. update(): void;
  74314. /** @hidden */
  74315. _rebuild(): void;
  74316. /**
  74317. * Disposes of the manager and pipelines
  74318. */
  74319. dispose(): void;
  74320. }
  74321. }
  74322. declare module BABYLON {
  74323. interface Scene {
  74324. /** @hidden (Backing field) */
  74325. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74326. /**
  74327. * Gets the postprocess render pipeline manager
  74328. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74329. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74330. */
  74331. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74332. }
  74333. /**
  74334. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74335. */
  74336. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74337. /**
  74338. * The component name helpfull to identify the component in the list of scene components.
  74339. */
  74340. readonly name: string;
  74341. /**
  74342. * The scene the component belongs to.
  74343. */
  74344. scene: Scene;
  74345. /**
  74346. * Creates a new instance of the component for the given scene
  74347. * @param scene Defines the scene to register the component in
  74348. */
  74349. constructor(scene: Scene);
  74350. /**
  74351. * Registers the component in a given scene
  74352. */
  74353. register(): void;
  74354. /**
  74355. * Rebuilds the elements related to this component in case of
  74356. * context lost for instance.
  74357. */
  74358. rebuild(): void;
  74359. /**
  74360. * Disposes the component and the associated ressources
  74361. */
  74362. dispose(): void;
  74363. private _gatherRenderTargets;
  74364. }
  74365. }
  74366. declare module BABYLON {
  74367. /**
  74368. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74369. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74370. */
  74371. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74372. private _scene;
  74373. private _camerasToBeAttached;
  74374. /**
  74375. * ID of the sharpen post process,
  74376. */
  74377. private readonly SharpenPostProcessId;
  74378. /**
  74379. * @ignore
  74380. * ID of the image processing post process;
  74381. */
  74382. readonly ImageProcessingPostProcessId: string;
  74383. /**
  74384. * @ignore
  74385. * ID of the Fast Approximate Anti-Aliasing post process;
  74386. */
  74387. readonly FxaaPostProcessId: string;
  74388. /**
  74389. * ID of the chromatic aberration post process,
  74390. */
  74391. private readonly ChromaticAberrationPostProcessId;
  74392. /**
  74393. * ID of the grain post process
  74394. */
  74395. private readonly GrainPostProcessId;
  74396. /**
  74397. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74398. */
  74399. sharpen: SharpenPostProcess;
  74400. private _sharpenEffect;
  74401. private bloom;
  74402. /**
  74403. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74404. */
  74405. depthOfField: DepthOfFieldEffect;
  74406. /**
  74407. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74408. */
  74409. fxaa: FxaaPostProcess;
  74410. /**
  74411. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74412. */
  74413. imageProcessing: ImageProcessingPostProcess;
  74414. /**
  74415. * Chromatic aberration post process which will shift rgb colors in the image
  74416. */
  74417. chromaticAberration: ChromaticAberrationPostProcess;
  74418. private _chromaticAberrationEffect;
  74419. /**
  74420. * Grain post process which add noise to the image
  74421. */
  74422. grain: GrainPostProcess;
  74423. private _grainEffect;
  74424. /**
  74425. * Glow post process which adds a glow to emissive areas of the image
  74426. */
  74427. private _glowLayer;
  74428. /**
  74429. * Animations which can be used to tweak settings over a period of time
  74430. */
  74431. animations: Animation[];
  74432. private _imageProcessingConfigurationObserver;
  74433. private _sharpenEnabled;
  74434. private _bloomEnabled;
  74435. private _depthOfFieldEnabled;
  74436. private _depthOfFieldBlurLevel;
  74437. private _fxaaEnabled;
  74438. private _imageProcessingEnabled;
  74439. private _defaultPipelineTextureType;
  74440. private _bloomScale;
  74441. private _chromaticAberrationEnabled;
  74442. private _grainEnabled;
  74443. private _buildAllowed;
  74444. /**
  74445. * This is triggered each time the pipeline has been built.
  74446. */
  74447. onBuildObservable: Observable<DefaultRenderingPipeline>;
  74448. /**
  74449. * Gets active scene
  74450. */
  74451. get scene(): Scene;
  74452. /**
  74453. * Enable or disable the sharpen process from the pipeline
  74454. */
  74455. set sharpenEnabled(enabled: boolean);
  74456. get sharpenEnabled(): boolean;
  74457. private _resizeObserver;
  74458. private _hardwareScaleLevel;
  74459. private _bloomKernel;
  74460. /**
  74461. * Specifies the size of the bloom blur kernel, relative to the final output size
  74462. */
  74463. get bloomKernel(): number;
  74464. set bloomKernel(value: number);
  74465. /**
  74466. * Specifies the weight of the bloom in the final rendering
  74467. */
  74468. private _bloomWeight;
  74469. /**
  74470. * Specifies the luma threshold for the area that will be blurred by the bloom
  74471. */
  74472. private _bloomThreshold;
  74473. private _hdr;
  74474. /**
  74475. * The strength of the bloom.
  74476. */
  74477. set bloomWeight(value: number);
  74478. get bloomWeight(): number;
  74479. /**
  74480. * The strength of the bloom.
  74481. */
  74482. set bloomThreshold(value: number);
  74483. get bloomThreshold(): number;
  74484. /**
  74485. * The scale of the bloom, lower value will provide better performance.
  74486. */
  74487. set bloomScale(value: number);
  74488. get bloomScale(): number;
  74489. /**
  74490. * Enable or disable the bloom from the pipeline
  74491. */
  74492. set bloomEnabled(enabled: boolean);
  74493. get bloomEnabled(): boolean;
  74494. private _rebuildBloom;
  74495. /**
  74496. * If the depth of field is enabled.
  74497. */
  74498. get depthOfFieldEnabled(): boolean;
  74499. set depthOfFieldEnabled(enabled: boolean);
  74500. /**
  74501. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74502. */
  74503. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74504. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74505. /**
  74506. * If the anti aliasing is enabled.
  74507. */
  74508. set fxaaEnabled(enabled: boolean);
  74509. get fxaaEnabled(): boolean;
  74510. private _samples;
  74511. /**
  74512. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74513. */
  74514. set samples(sampleCount: number);
  74515. get samples(): number;
  74516. /**
  74517. * If image processing is enabled.
  74518. */
  74519. set imageProcessingEnabled(enabled: boolean);
  74520. get imageProcessingEnabled(): boolean;
  74521. /**
  74522. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74523. */
  74524. set glowLayerEnabled(enabled: boolean);
  74525. get glowLayerEnabled(): boolean;
  74526. /**
  74527. * Gets the glow layer (or null if not defined)
  74528. */
  74529. get glowLayer(): Nullable<GlowLayer>;
  74530. /**
  74531. * Enable or disable the chromaticAberration process from the pipeline
  74532. */
  74533. set chromaticAberrationEnabled(enabled: boolean);
  74534. get chromaticAberrationEnabled(): boolean;
  74535. /**
  74536. * Enable or disable the grain process from the pipeline
  74537. */
  74538. set grainEnabled(enabled: boolean);
  74539. get grainEnabled(): boolean;
  74540. /**
  74541. * @constructor
  74542. * @param name - The rendering pipeline name (default: "")
  74543. * @param hdr - If high dynamic range textures should be used (default: true)
  74544. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74545. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74546. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74547. */
  74548. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74549. /**
  74550. * Get the class name
  74551. * @returns "DefaultRenderingPipeline"
  74552. */
  74553. getClassName(): string;
  74554. /**
  74555. * Force the compilation of the entire pipeline.
  74556. */
  74557. prepare(): void;
  74558. private _hasCleared;
  74559. private _prevPostProcess;
  74560. private _prevPrevPostProcess;
  74561. private _setAutoClearAndTextureSharing;
  74562. private _depthOfFieldSceneObserver;
  74563. private _buildPipeline;
  74564. private _disposePostProcesses;
  74565. /**
  74566. * Adds a camera to the pipeline
  74567. * @param camera the camera to be added
  74568. */
  74569. addCamera(camera: Camera): void;
  74570. /**
  74571. * Removes a camera from the pipeline
  74572. * @param camera the camera to remove
  74573. */
  74574. removeCamera(camera: Camera): void;
  74575. /**
  74576. * Dispose of the pipeline and stop all post processes
  74577. */
  74578. dispose(): void;
  74579. /**
  74580. * Serialize the rendering pipeline (Used when exporting)
  74581. * @returns the serialized object
  74582. */
  74583. serialize(): any;
  74584. /**
  74585. * Parse the serialized pipeline
  74586. * @param source Source pipeline.
  74587. * @param scene The scene to load the pipeline to.
  74588. * @param rootUrl The URL of the serialized pipeline.
  74589. * @returns An instantiated pipeline from the serialized object.
  74590. */
  74591. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74592. }
  74593. }
  74594. declare module BABYLON {
  74595. /** @hidden */
  74596. export var lensHighlightsPixelShader: {
  74597. name: string;
  74598. shader: string;
  74599. };
  74600. }
  74601. declare module BABYLON {
  74602. /** @hidden */
  74603. export var depthOfFieldPixelShader: {
  74604. name: string;
  74605. shader: string;
  74606. };
  74607. }
  74608. declare module BABYLON {
  74609. /**
  74610. * BABYLON.JS Chromatic Aberration GLSL Shader
  74611. * Author: Olivier Guyot
  74612. * Separates very slightly R, G and B colors on the edges of the screen
  74613. * Inspired by Francois Tarlier & Martins Upitis
  74614. */
  74615. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74616. /**
  74617. * @ignore
  74618. * The chromatic aberration PostProcess id in the pipeline
  74619. */
  74620. LensChromaticAberrationEffect: string;
  74621. /**
  74622. * @ignore
  74623. * The highlights enhancing PostProcess id in the pipeline
  74624. */
  74625. HighlightsEnhancingEffect: string;
  74626. /**
  74627. * @ignore
  74628. * The depth-of-field PostProcess id in the pipeline
  74629. */
  74630. LensDepthOfFieldEffect: string;
  74631. private _scene;
  74632. private _depthTexture;
  74633. private _grainTexture;
  74634. private _chromaticAberrationPostProcess;
  74635. private _highlightsPostProcess;
  74636. private _depthOfFieldPostProcess;
  74637. private _edgeBlur;
  74638. private _grainAmount;
  74639. private _chromaticAberration;
  74640. private _distortion;
  74641. private _highlightsGain;
  74642. private _highlightsThreshold;
  74643. private _dofDistance;
  74644. private _dofAperture;
  74645. private _dofDarken;
  74646. private _dofPentagon;
  74647. private _blurNoise;
  74648. /**
  74649. * @constructor
  74650. *
  74651. * Effect parameters are as follow:
  74652. * {
  74653. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74654. * edge_blur: number; // from 0 to x (1 for realism)
  74655. * distortion: number; // from 0 to x (1 for realism)
  74656. * grain_amount: number; // from 0 to 1
  74657. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74658. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74659. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74660. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74661. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74662. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74663. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74664. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74665. * }
  74666. * Note: if an effect parameter is unset, effect is disabled
  74667. *
  74668. * @param name The rendering pipeline name
  74669. * @param parameters - An object containing all parameters (see above)
  74670. * @param scene The scene linked to this pipeline
  74671. * @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)
  74672. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74673. */
  74674. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74675. /**
  74676. * Get the class name
  74677. * @returns "LensRenderingPipeline"
  74678. */
  74679. getClassName(): string;
  74680. /**
  74681. * Gets associated scene
  74682. */
  74683. get scene(): Scene;
  74684. /**
  74685. * Gets or sets the edge blur
  74686. */
  74687. get edgeBlur(): number;
  74688. set edgeBlur(value: number);
  74689. /**
  74690. * Gets or sets the grain amount
  74691. */
  74692. get grainAmount(): number;
  74693. set grainAmount(value: number);
  74694. /**
  74695. * Gets or sets the chromatic aberration amount
  74696. */
  74697. get chromaticAberration(): number;
  74698. set chromaticAberration(value: number);
  74699. /**
  74700. * Gets or sets the depth of field aperture
  74701. */
  74702. get dofAperture(): number;
  74703. set dofAperture(value: number);
  74704. /**
  74705. * Gets or sets the edge distortion
  74706. */
  74707. get edgeDistortion(): number;
  74708. set edgeDistortion(value: number);
  74709. /**
  74710. * Gets or sets the depth of field distortion
  74711. */
  74712. get dofDistortion(): number;
  74713. set dofDistortion(value: number);
  74714. /**
  74715. * Gets or sets the darken out of focus amount
  74716. */
  74717. get darkenOutOfFocus(): number;
  74718. set darkenOutOfFocus(value: number);
  74719. /**
  74720. * Gets or sets a boolean indicating if blur noise is enabled
  74721. */
  74722. get blurNoise(): boolean;
  74723. set blurNoise(value: boolean);
  74724. /**
  74725. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  74726. */
  74727. get pentagonBokeh(): boolean;
  74728. set pentagonBokeh(value: boolean);
  74729. /**
  74730. * Gets or sets the highlight grain amount
  74731. */
  74732. get highlightsGain(): number;
  74733. set highlightsGain(value: number);
  74734. /**
  74735. * Gets or sets the highlight threshold
  74736. */
  74737. get highlightsThreshold(): number;
  74738. set highlightsThreshold(value: number);
  74739. /**
  74740. * Sets the amount of blur at the edges
  74741. * @param amount blur amount
  74742. */
  74743. setEdgeBlur(amount: number): void;
  74744. /**
  74745. * Sets edge blur to 0
  74746. */
  74747. disableEdgeBlur(): void;
  74748. /**
  74749. * Sets the amout of grain
  74750. * @param amount Amount of grain
  74751. */
  74752. setGrainAmount(amount: number): void;
  74753. /**
  74754. * Set grain amount to 0
  74755. */
  74756. disableGrain(): void;
  74757. /**
  74758. * Sets the chromatic aberration amount
  74759. * @param amount amount of chromatic aberration
  74760. */
  74761. setChromaticAberration(amount: number): void;
  74762. /**
  74763. * Sets chromatic aberration amount to 0
  74764. */
  74765. disableChromaticAberration(): void;
  74766. /**
  74767. * Sets the EdgeDistortion amount
  74768. * @param amount amount of EdgeDistortion
  74769. */
  74770. setEdgeDistortion(amount: number): void;
  74771. /**
  74772. * Sets edge distortion to 0
  74773. */
  74774. disableEdgeDistortion(): void;
  74775. /**
  74776. * Sets the FocusDistance amount
  74777. * @param amount amount of FocusDistance
  74778. */
  74779. setFocusDistance(amount: number): void;
  74780. /**
  74781. * Disables depth of field
  74782. */
  74783. disableDepthOfField(): void;
  74784. /**
  74785. * Sets the Aperture amount
  74786. * @param amount amount of Aperture
  74787. */
  74788. setAperture(amount: number): void;
  74789. /**
  74790. * Sets the DarkenOutOfFocus amount
  74791. * @param amount amount of DarkenOutOfFocus
  74792. */
  74793. setDarkenOutOfFocus(amount: number): void;
  74794. private _pentagonBokehIsEnabled;
  74795. /**
  74796. * Creates a pentagon bokeh effect
  74797. */
  74798. enablePentagonBokeh(): void;
  74799. /**
  74800. * Disables the pentagon bokeh effect
  74801. */
  74802. disablePentagonBokeh(): void;
  74803. /**
  74804. * Enables noise blur
  74805. */
  74806. enableNoiseBlur(): void;
  74807. /**
  74808. * Disables noise blur
  74809. */
  74810. disableNoiseBlur(): void;
  74811. /**
  74812. * Sets the HighlightsGain amount
  74813. * @param amount amount of HighlightsGain
  74814. */
  74815. setHighlightsGain(amount: number): void;
  74816. /**
  74817. * Sets the HighlightsThreshold amount
  74818. * @param amount amount of HighlightsThreshold
  74819. */
  74820. setHighlightsThreshold(amount: number): void;
  74821. /**
  74822. * Disables highlights
  74823. */
  74824. disableHighlights(): void;
  74825. /**
  74826. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  74827. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  74828. */
  74829. dispose(disableDepthRender?: boolean): void;
  74830. private _createChromaticAberrationPostProcess;
  74831. private _createHighlightsPostProcess;
  74832. private _createDepthOfFieldPostProcess;
  74833. private _createGrainTexture;
  74834. }
  74835. }
  74836. declare module BABYLON {
  74837. /**
  74838. * Contains all parameters needed for the prepass to perform
  74839. * screen space subsurface scattering
  74840. */
  74841. export class SSAO2Configuration implements PrePassEffectConfiguration {
  74842. /**
  74843. * Is subsurface enabled
  74844. */
  74845. enabled: boolean;
  74846. /**
  74847. * Name of the configuration
  74848. */
  74849. name: string;
  74850. /**
  74851. * Textures that should be present in the MRT for this effect to work
  74852. */
  74853. readonly texturesRequired: number[];
  74854. }
  74855. }
  74856. declare module BABYLON {
  74857. /** @hidden */
  74858. export var ssao2PixelShader: {
  74859. name: string;
  74860. shader: string;
  74861. };
  74862. }
  74863. declare module BABYLON {
  74864. /** @hidden */
  74865. export var ssaoCombinePixelShader: {
  74866. name: string;
  74867. shader: string;
  74868. };
  74869. }
  74870. declare module BABYLON {
  74871. /**
  74872. * Render pipeline to produce ssao effect
  74873. */
  74874. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  74875. /**
  74876. * @ignore
  74877. * The PassPostProcess id in the pipeline that contains the original scene color
  74878. */
  74879. SSAOOriginalSceneColorEffect: string;
  74880. /**
  74881. * @ignore
  74882. * The SSAO PostProcess id in the pipeline
  74883. */
  74884. SSAORenderEffect: string;
  74885. /**
  74886. * @ignore
  74887. * The horizontal blur PostProcess id in the pipeline
  74888. */
  74889. SSAOBlurHRenderEffect: string;
  74890. /**
  74891. * @ignore
  74892. * The vertical blur PostProcess id in the pipeline
  74893. */
  74894. SSAOBlurVRenderEffect: string;
  74895. /**
  74896. * @ignore
  74897. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74898. */
  74899. SSAOCombineRenderEffect: string;
  74900. /**
  74901. * The output strength of the SSAO post-process. Default value is 1.0.
  74902. */
  74903. totalStrength: number;
  74904. /**
  74905. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  74906. */
  74907. maxZ: number;
  74908. /**
  74909. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  74910. */
  74911. minZAspect: number;
  74912. private _samples;
  74913. /**
  74914. * Number of samples used for the SSAO calculations. Default value is 8
  74915. */
  74916. set samples(n: number);
  74917. get samples(): number;
  74918. private _textureSamples;
  74919. /**
  74920. * Number of samples to use for antialiasing
  74921. */
  74922. set textureSamples(n: number);
  74923. get textureSamples(): number;
  74924. /**
  74925. * Force rendering the geometry through geometry buffer
  74926. */
  74927. private _forceGeometryBuffer;
  74928. /**
  74929. * Ratio object used for SSAO ratio and blur ratio
  74930. */
  74931. private _ratio;
  74932. /**
  74933. * Dynamically generated sphere sampler.
  74934. */
  74935. private _sampleSphere;
  74936. /**
  74937. * Blur filter offsets
  74938. */
  74939. private _samplerOffsets;
  74940. private _expensiveBlur;
  74941. /**
  74942. * If bilateral blur should be used
  74943. */
  74944. set expensiveBlur(b: boolean);
  74945. get expensiveBlur(): boolean;
  74946. /**
  74947. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  74948. */
  74949. radius: number;
  74950. /**
  74951. * The base color of the SSAO post-process
  74952. * The final result is "base + ssao" between [0, 1]
  74953. */
  74954. base: number;
  74955. /**
  74956. * Support test.
  74957. */
  74958. static get IsSupported(): boolean;
  74959. private _scene;
  74960. private _randomTexture;
  74961. private _originalColorPostProcess;
  74962. private _ssaoPostProcess;
  74963. private _blurHPostProcess;
  74964. private _blurVPostProcess;
  74965. private _ssaoCombinePostProcess;
  74966. private _prePassRenderer;
  74967. /**
  74968. * Gets active scene
  74969. */
  74970. get scene(): Scene;
  74971. /**
  74972. * @constructor
  74973. * @param name The rendering pipeline name
  74974. * @param scene The scene linked to this pipeline
  74975. * @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 }
  74976. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74977. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  74978. */
  74979. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  74980. /**
  74981. * Get the class name
  74982. * @returns "SSAO2RenderingPipeline"
  74983. */
  74984. getClassName(): string;
  74985. /**
  74986. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74987. */
  74988. dispose(disableGeometryBufferRenderer?: boolean): void;
  74989. private _createBlurPostProcess;
  74990. /** @hidden */
  74991. _rebuild(): void;
  74992. private _bits;
  74993. private _radicalInverse_VdC;
  74994. private _hammersley;
  74995. private _hemisphereSample_uniform;
  74996. private _generateHemisphere;
  74997. private _getDefinesForSSAO;
  74998. private static readonly ORTHO_DEPTH_PROJECTION;
  74999. private static readonly PERSPECTIVE_DEPTH_PROJECTION;
  75000. private _createSSAOPostProcess;
  75001. private _createSSAOCombinePostProcess;
  75002. private _createRandomTexture;
  75003. /**
  75004. * Serialize the rendering pipeline (Used when exporting)
  75005. * @returns the serialized object
  75006. */
  75007. serialize(): any;
  75008. /**
  75009. * Parse the serialized pipeline
  75010. * @param source Source pipeline.
  75011. * @param scene The scene to load the pipeline to.
  75012. * @param rootUrl The URL of the serialized pipeline.
  75013. * @returns An instantiated pipeline from the serialized object.
  75014. */
  75015. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75016. }
  75017. }
  75018. declare module BABYLON {
  75019. /** @hidden */
  75020. export var ssaoPixelShader: {
  75021. name: string;
  75022. shader: string;
  75023. };
  75024. }
  75025. declare module BABYLON {
  75026. /**
  75027. * Render pipeline to produce ssao effect
  75028. */
  75029. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75030. /**
  75031. * @ignore
  75032. * The PassPostProcess id in the pipeline that contains the original scene color
  75033. */
  75034. SSAOOriginalSceneColorEffect: string;
  75035. /**
  75036. * @ignore
  75037. * The SSAO PostProcess id in the pipeline
  75038. */
  75039. SSAORenderEffect: string;
  75040. /**
  75041. * @ignore
  75042. * The horizontal blur PostProcess id in the pipeline
  75043. */
  75044. SSAOBlurHRenderEffect: string;
  75045. /**
  75046. * @ignore
  75047. * The vertical blur PostProcess id in the pipeline
  75048. */
  75049. SSAOBlurVRenderEffect: string;
  75050. /**
  75051. * @ignore
  75052. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75053. */
  75054. SSAOCombineRenderEffect: string;
  75055. /**
  75056. * The output strength of the SSAO post-process. Default value is 1.0.
  75057. */
  75058. totalStrength: number;
  75059. /**
  75060. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75061. */
  75062. radius: number;
  75063. /**
  75064. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75065. * Must not be equal to fallOff and superior to fallOff.
  75066. * Default value is 0.0075
  75067. */
  75068. area: number;
  75069. /**
  75070. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75071. * Must not be equal to area and inferior to area.
  75072. * Default value is 0.000001
  75073. */
  75074. fallOff: number;
  75075. /**
  75076. * The base color of the SSAO post-process
  75077. * The final result is "base + ssao" between [0, 1]
  75078. */
  75079. base: number;
  75080. private _scene;
  75081. private _depthTexture;
  75082. private _randomTexture;
  75083. private _originalColorPostProcess;
  75084. private _ssaoPostProcess;
  75085. private _blurHPostProcess;
  75086. private _blurVPostProcess;
  75087. private _ssaoCombinePostProcess;
  75088. private _firstUpdate;
  75089. /**
  75090. * Gets active scene
  75091. */
  75092. get scene(): Scene;
  75093. /**
  75094. * @constructor
  75095. * @param name - The rendering pipeline name
  75096. * @param scene - The scene linked to this pipeline
  75097. * @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 }
  75098. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75099. */
  75100. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75101. /**
  75102. * Get the class name
  75103. * @returns "SSAORenderingPipeline"
  75104. */
  75105. getClassName(): string;
  75106. /**
  75107. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75108. */
  75109. dispose(disableDepthRender?: boolean): void;
  75110. private _createBlurPostProcess;
  75111. /** @hidden */
  75112. _rebuild(): void;
  75113. private _createSSAOPostProcess;
  75114. private _createSSAOCombinePostProcess;
  75115. private _createRandomTexture;
  75116. }
  75117. }
  75118. declare module BABYLON {
  75119. /**
  75120. * Contains all parameters needed for the prepass to perform
  75121. * screen space reflections
  75122. */
  75123. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75124. /**
  75125. * Is ssr enabled
  75126. */
  75127. enabled: boolean;
  75128. /**
  75129. * Name of the configuration
  75130. */
  75131. name: string;
  75132. /**
  75133. * Textures that should be present in the MRT for this effect to work
  75134. */
  75135. readonly texturesRequired: number[];
  75136. }
  75137. }
  75138. declare module BABYLON {
  75139. /** @hidden */
  75140. export var screenSpaceReflectionPixelShader: {
  75141. name: string;
  75142. shader: string;
  75143. };
  75144. }
  75145. declare module BABYLON {
  75146. /**
  75147. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75148. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75149. */
  75150. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75151. /**
  75152. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75153. */
  75154. threshold: number;
  75155. /**
  75156. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75157. */
  75158. strength: number;
  75159. /**
  75160. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75161. */
  75162. reflectionSpecularFalloffExponent: number;
  75163. /**
  75164. * 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]
  75165. */
  75166. step: number;
  75167. /**
  75168. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75169. */
  75170. roughnessFactor: number;
  75171. private _forceGeometryBuffer;
  75172. private _geometryBufferRenderer;
  75173. private _prePassRenderer;
  75174. private _enableSmoothReflections;
  75175. private _reflectionSamples;
  75176. private _smoothSteps;
  75177. /**
  75178. * Gets a string identifying the name of the class
  75179. * @returns "ScreenSpaceReflectionPostProcess" string
  75180. */
  75181. getClassName(): string;
  75182. /**
  75183. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75184. * @param name The name of the effect.
  75185. * @param scene The scene containing the objects to calculate reflections.
  75186. * @param options The required width/height ratio to downsize to before computing the render pass.
  75187. * @param camera The camera to apply the render pass to.
  75188. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75189. * @param engine The engine which the post process will be applied. (default: current engine)
  75190. * @param reusable If the post process can be reused on the same frame. (default: false)
  75191. * @param textureType Type of textures used when performing the post process. (default: 0)
  75192. * @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)
  75193. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75194. */
  75195. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75196. /**
  75197. * Gets wether or not smoothing reflections is enabled.
  75198. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75199. */
  75200. get enableSmoothReflections(): boolean;
  75201. /**
  75202. * Sets wether or not smoothing reflections is enabled.
  75203. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75204. */
  75205. set enableSmoothReflections(enabled: boolean);
  75206. /**
  75207. * Gets the number of samples taken while computing reflections. More samples count is high,
  75208. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75209. */
  75210. get reflectionSamples(): number;
  75211. /**
  75212. * Sets the number of samples taken while computing reflections. More samples count is high,
  75213. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75214. */
  75215. set reflectionSamples(samples: number);
  75216. /**
  75217. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75218. * more the post-process will require GPU power and can generate a drop in FPS.
  75219. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75220. */
  75221. get smoothSteps(): number;
  75222. set smoothSteps(steps: number);
  75223. private _updateEffectDefines;
  75224. /** @hidden */
  75225. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75226. }
  75227. }
  75228. declare module BABYLON {
  75229. /** @hidden */
  75230. export var standardPixelShader: {
  75231. name: string;
  75232. shader: string;
  75233. };
  75234. }
  75235. declare module BABYLON {
  75236. /**
  75237. * Standard rendering pipeline
  75238. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75239. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75240. */
  75241. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75242. /**
  75243. * Public members
  75244. */
  75245. /**
  75246. * Post-process which contains the original scene color before the pipeline applies all the effects
  75247. */
  75248. originalPostProcess: Nullable<PostProcess>;
  75249. /**
  75250. * Post-process used to down scale an image x4
  75251. */
  75252. downSampleX4PostProcess: Nullable<PostProcess>;
  75253. /**
  75254. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75255. */
  75256. brightPassPostProcess: Nullable<PostProcess>;
  75257. /**
  75258. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75259. */
  75260. blurHPostProcesses: PostProcess[];
  75261. /**
  75262. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75263. */
  75264. blurVPostProcesses: PostProcess[];
  75265. /**
  75266. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75267. */
  75268. textureAdderPostProcess: Nullable<PostProcess>;
  75269. /**
  75270. * Post-process used to create volumetric lighting effect
  75271. */
  75272. volumetricLightPostProcess: Nullable<PostProcess>;
  75273. /**
  75274. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75275. */
  75276. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75277. /**
  75278. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75279. */
  75280. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75281. /**
  75282. * Post-process used to merge the volumetric light effect and the real scene color
  75283. */
  75284. volumetricLightMergePostProces: Nullable<PostProcess>;
  75285. /**
  75286. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75287. */
  75288. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75289. /**
  75290. * Base post-process used to calculate the average luminance of the final image for HDR
  75291. */
  75292. luminancePostProcess: Nullable<PostProcess>;
  75293. /**
  75294. * Post-processes used to create down sample post-processes in order to get
  75295. * the average luminance of the final image for HDR
  75296. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75297. */
  75298. luminanceDownSamplePostProcesses: PostProcess[];
  75299. /**
  75300. * Post-process used to create a HDR effect (light adaptation)
  75301. */
  75302. hdrPostProcess: Nullable<PostProcess>;
  75303. /**
  75304. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75305. */
  75306. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75307. /**
  75308. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75309. */
  75310. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75311. /**
  75312. * Post-process used to merge the final HDR post-process and the real scene color
  75313. */
  75314. hdrFinalPostProcess: Nullable<PostProcess>;
  75315. /**
  75316. * Post-process used to create a lens flare effect
  75317. */
  75318. lensFlarePostProcess: Nullable<PostProcess>;
  75319. /**
  75320. * Post-process that merges the result of the lens flare post-process and the real scene color
  75321. */
  75322. lensFlareComposePostProcess: Nullable<PostProcess>;
  75323. /**
  75324. * Post-process used to create a motion blur effect
  75325. */
  75326. motionBlurPostProcess: Nullable<PostProcess>;
  75327. /**
  75328. * Post-process used to create a depth of field effect
  75329. */
  75330. depthOfFieldPostProcess: Nullable<PostProcess>;
  75331. /**
  75332. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75333. */
  75334. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75335. /**
  75336. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75337. */
  75338. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75339. /**
  75340. * Represents the brightness threshold in order to configure the illuminated surfaces
  75341. */
  75342. brightThreshold: number;
  75343. /**
  75344. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75345. */
  75346. blurWidth: number;
  75347. /**
  75348. * Sets if the blur for highlighted surfaces must be only horizontal
  75349. */
  75350. horizontalBlur: boolean;
  75351. /**
  75352. * Gets the overall exposure used by the pipeline
  75353. */
  75354. get exposure(): number;
  75355. /**
  75356. * Sets the overall exposure used by the pipeline
  75357. */
  75358. set exposure(value: number);
  75359. /**
  75360. * Texture used typically to simulate "dirty" on camera lens
  75361. */
  75362. lensTexture: Nullable<Texture>;
  75363. /**
  75364. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75365. */
  75366. volumetricLightCoefficient: number;
  75367. /**
  75368. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75369. */
  75370. volumetricLightPower: number;
  75371. /**
  75372. * Used the set the blur intensity to smooth the volumetric lights
  75373. */
  75374. volumetricLightBlurScale: number;
  75375. /**
  75376. * Light (spot or directional) used to generate the volumetric lights rays
  75377. * The source light must have a shadow generate so the pipeline can get its
  75378. * depth map
  75379. */
  75380. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75381. /**
  75382. * For eye adaptation, represents the minimum luminance the eye can see
  75383. */
  75384. hdrMinimumLuminance: number;
  75385. /**
  75386. * For eye adaptation, represents the decrease luminance speed
  75387. */
  75388. hdrDecreaseRate: number;
  75389. /**
  75390. * For eye adaptation, represents the increase luminance speed
  75391. */
  75392. hdrIncreaseRate: number;
  75393. /**
  75394. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75395. */
  75396. get hdrAutoExposure(): boolean;
  75397. /**
  75398. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75399. */
  75400. set hdrAutoExposure(value: boolean);
  75401. /**
  75402. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75403. */
  75404. lensColorTexture: Nullable<Texture>;
  75405. /**
  75406. * The overall strengh for the lens flare effect
  75407. */
  75408. lensFlareStrength: number;
  75409. /**
  75410. * Dispersion coefficient for lens flare ghosts
  75411. */
  75412. lensFlareGhostDispersal: number;
  75413. /**
  75414. * Main lens flare halo width
  75415. */
  75416. lensFlareHaloWidth: number;
  75417. /**
  75418. * Based on the lens distortion effect, defines how much the lens flare result
  75419. * is distorted
  75420. */
  75421. lensFlareDistortionStrength: number;
  75422. /**
  75423. * Configures the blur intensity used for for lens flare (halo)
  75424. */
  75425. lensFlareBlurWidth: number;
  75426. /**
  75427. * Lens star texture must be used to simulate rays on the flares and is available
  75428. * in the documentation
  75429. */
  75430. lensStarTexture: Nullable<Texture>;
  75431. /**
  75432. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75433. * flare effect by taking account of the dirt texture
  75434. */
  75435. lensFlareDirtTexture: Nullable<Texture>;
  75436. /**
  75437. * Represents the focal length for the depth of field effect
  75438. */
  75439. depthOfFieldDistance: number;
  75440. /**
  75441. * Represents the blur intensity for the blurred part of the depth of field effect
  75442. */
  75443. depthOfFieldBlurWidth: number;
  75444. /**
  75445. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75446. */
  75447. get motionStrength(): number;
  75448. /**
  75449. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75450. */
  75451. set motionStrength(strength: number);
  75452. /**
  75453. * Gets wether or not the motion blur post-process is object based or screen based.
  75454. */
  75455. get objectBasedMotionBlur(): boolean;
  75456. /**
  75457. * Sets wether or not the motion blur post-process should be object based or screen based
  75458. */
  75459. set objectBasedMotionBlur(value: boolean);
  75460. /**
  75461. * List of animations for the pipeline (IAnimatable implementation)
  75462. */
  75463. animations: Animation[];
  75464. /**
  75465. * Private members
  75466. */
  75467. private _scene;
  75468. private _currentDepthOfFieldSource;
  75469. private _basePostProcess;
  75470. private _fixedExposure;
  75471. private _currentExposure;
  75472. private _hdrAutoExposure;
  75473. private _hdrCurrentLuminance;
  75474. private _motionStrength;
  75475. private _isObjectBasedMotionBlur;
  75476. private _floatTextureType;
  75477. private _camerasToBeAttached;
  75478. private _ratio;
  75479. private _bloomEnabled;
  75480. private _depthOfFieldEnabled;
  75481. private _vlsEnabled;
  75482. private _lensFlareEnabled;
  75483. private _hdrEnabled;
  75484. private _motionBlurEnabled;
  75485. private _fxaaEnabled;
  75486. private _screenSpaceReflectionsEnabled;
  75487. private _motionBlurSamples;
  75488. private _volumetricLightStepsCount;
  75489. private _samples;
  75490. /**
  75491. * @ignore
  75492. * Specifies if the bloom pipeline is enabled
  75493. */
  75494. get BloomEnabled(): boolean;
  75495. set BloomEnabled(enabled: boolean);
  75496. /**
  75497. * @ignore
  75498. * Specifies if the depth of field pipeline is enabed
  75499. */
  75500. get DepthOfFieldEnabled(): boolean;
  75501. set DepthOfFieldEnabled(enabled: boolean);
  75502. /**
  75503. * @ignore
  75504. * Specifies if the lens flare pipeline is enabed
  75505. */
  75506. get LensFlareEnabled(): boolean;
  75507. set LensFlareEnabled(enabled: boolean);
  75508. /**
  75509. * @ignore
  75510. * Specifies if the HDR pipeline is enabled
  75511. */
  75512. get HDREnabled(): boolean;
  75513. set HDREnabled(enabled: boolean);
  75514. /**
  75515. * @ignore
  75516. * Specifies if the volumetric lights scattering effect is enabled
  75517. */
  75518. get VLSEnabled(): boolean;
  75519. set VLSEnabled(enabled: boolean);
  75520. /**
  75521. * @ignore
  75522. * Specifies if the motion blur effect is enabled
  75523. */
  75524. get MotionBlurEnabled(): boolean;
  75525. set MotionBlurEnabled(enabled: boolean);
  75526. /**
  75527. * Specifies if anti-aliasing is enabled
  75528. */
  75529. get fxaaEnabled(): boolean;
  75530. set fxaaEnabled(enabled: boolean);
  75531. /**
  75532. * Specifies if screen space reflections are enabled.
  75533. */
  75534. get screenSpaceReflectionsEnabled(): boolean;
  75535. set screenSpaceReflectionsEnabled(enabled: boolean);
  75536. /**
  75537. * Specifies the number of steps used to calculate the volumetric lights
  75538. * Typically in interval [50, 200]
  75539. */
  75540. get volumetricLightStepsCount(): number;
  75541. set volumetricLightStepsCount(count: number);
  75542. /**
  75543. * Specifies the number of samples used for the motion blur effect
  75544. * Typically in interval [16, 64]
  75545. */
  75546. get motionBlurSamples(): number;
  75547. set motionBlurSamples(samples: number);
  75548. /**
  75549. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75550. */
  75551. get samples(): number;
  75552. set samples(sampleCount: number);
  75553. /**
  75554. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75555. * @constructor
  75556. * @param name The rendering pipeline name
  75557. * @param scene The scene linked to this pipeline
  75558. * @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)
  75559. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75560. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75561. */
  75562. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75563. private _buildPipeline;
  75564. private _createDownSampleX4PostProcess;
  75565. private _createBrightPassPostProcess;
  75566. private _createBlurPostProcesses;
  75567. private _createTextureAdderPostProcess;
  75568. private _createVolumetricLightPostProcess;
  75569. private _createLuminancePostProcesses;
  75570. private _createHdrPostProcess;
  75571. private _createLensFlarePostProcess;
  75572. private _createDepthOfFieldPostProcess;
  75573. private _createMotionBlurPostProcess;
  75574. private _getDepthTexture;
  75575. private _disposePostProcesses;
  75576. /**
  75577. * Dispose of the pipeline and stop all post processes
  75578. */
  75579. dispose(): void;
  75580. /**
  75581. * Serialize the rendering pipeline (Used when exporting)
  75582. * @returns the serialized object
  75583. */
  75584. serialize(): any;
  75585. /**
  75586. * Parse the serialized pipeline
  75587. * @param source Source pipeline.
  75588. * @param scene The scene to load the pipeline to.
  75589. * @param rootUrl The URL of the serialized pipeline.
  75590. * @returns An instantiated pipeline from the serialized object.
  75591. */
  75592. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75593. /**
  75594. * Luminance steps
  75595. */
  75596. static LuminanceSteps: number;
  75597. }
  75598. }
  75599. declare module BABYLON {
  75600. /** @hidden */
  75601. export var stereoscopicInterlacePixelShader: {
  75602. name: string;
  75603. shader: string;
  75604. };
  75605. }
  75606. declare module BABYLON {
  75607. /**
  75608. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  75609. */
  75610. export class StereoscopicInterlacePostProcessI extends PostProcess {
  75611. private _stepSize;
  75612. private _passedProcess;
  75613. /**
  75614. * Gets a string identifying the name of the class
  75615. * @returns "StereoscopicInterlacePostProcessI" string
  75616. */
  75617. getClassName(): string;
  75618. /**
  75619. * Initializes a StereoscopicInterlacePostProcessI
  75620. * @param name The name of the effect.
  75621. * @param rigCameras The rig cameras to be appled to the post process
  75622. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  75623. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  75624. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75625. * @param engine The engine which the post process will be applied. (default: current engine)
  75626. * @param reusable If the post process can be reused on the same frame. (default: false)
  75627. */
  75628. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75629. }
  75630. /**
  75631. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  75632. */
  75633. export class StereoscopicInterlacePostProcess extends PostProcess {
  75634. private _stepSize;
  75635. private _passedProcess;
  75636. /**
  75637. * Gets a string identifying the name of the class
  75638. * @returns "StereoscopicInterlacePostProcess" string
  75639. */
  75640. getClassName(): string;
  75641. /**
  75642. * Initializes a StereoscopicInterlacePostProcess
  75643. * @param name The name of the effect.
  75644. * @param rigCameras The rig cameras to be appled to the post process
  75645. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  75646. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75647. * @param engine The engine which the post process will be applied. (default: current engine)
  75648. * @param reusable If the post process can be reused on the same frame. (default: false)
  75649. */
  75650. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75651. }
  75652. }
  75653. declare module BABYLON {
  75654. /** @hidden */
  75655. export var tonemapPixelShader: {
  75656. name: string;
  75657. shader: string;
  75658. };
  75659. }
  75660. declare module BABYLON {
  75661. /** Defines operator used for tonemapping */
  75662. export enum TonemappingOperator {
  75663. /** Hable */
  75664. Hable = 0,
  75665. /** Reinhard */
  75666. Reinhard = 1,
  75667. /** HejiDawson */
  75668. HejiDawson = 2,
  75669. /** Photographic */
  75670. Photographic = 3
  75671. }
  75672. /**
  75673. * Defines a post process to apply tone mapping
  75674. */
  75675. export class TonemapPostProcess extends PostProcess {
  75676. private _operator;
  75677. /** Defines the required exposure adjustement */
  75678. exposureAdjustment: number;
  75679. /**
  75680. * Gets a string identifying the name of the class
  75681. * @returns "TonemapPostProcess" string
  75682. */
  75683. getClassName(): string;
  75684. /**
  75685. * Creates a new TonemapPostProcess
  75686. * @param name defines the name of the postprocess
  75687. * @param _operator defines the operator to use
  75688. * @param exposureAdjustment defines the required exposure adjustement
  75689. * @param camera defines the camera to use (can be null)
  75690. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  75691. * @param engine defines the hosting engine (can be ignore if camera is set)
  75692. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75693. */
  75694. constructor(name: string, _operator: TonemappingOperator,
  75695. /** Defines the required exposure adjustement */
  75696. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  75697. }
  75698. }
  75699. declare module BABYLON {
  75700. /** @hidden */
  75701. export var volumetricLightScatteringPixelShader: {
  75702. name: string;
  75703. shader: string;
  75704. };
  75705. }
  75706. declare module BABYLON {
  75707. /** @hidden */
  75708. export var volumetricLightScatteringPassVertexShader: {
  75709. name: string;
  75710. shader: string;
  75711. };
  75712. }
  75713. declare module BABYLON {
  75714. /** @hidden */
  75715. export var volumetricLightScatteringPassPixelShader: {
  75716. name: string;
  75717. shader: string;
  75718. };
  75719. }
  75720. declare module BABYLON {
  75721. /**
  75722. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  75723. */
  75724. export class VolumetricLightScatteringPostProcess extends PostProcess {
  75725. private _volumetricLightScatteringPass;
  75726. private _volumetricLightScatteringRTT;
  75727. private _viewPort;
  75728. private _screenCoordinates;
  75729. private _cachedDefines;
  75730. /**
  75731. * If not undefined, the mesh position is computed from the attached node position
  75732. */
  75733. attachedNode: {
  75734. position: Vector3;
  75735. };
  75736. /**
  75737. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  75738. */
  75739. customMeshPosition: Vector3;
  75740. /**
  75741. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  75742. */
  75743. useCustomMeshPosition: boolean;
  75744. /**
  75745. * If the post-process should inverse the light scattering direction
  75746. */
  75747. invert: boolean;
  75748. /**
  75749. * The internal mesh used by the post-process
  75750. */
  75751. mesh: Mesh;
  75752. /**
  75753. * @hidden
  75754. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  75755. */
  75756. get useDiffuseColor(): boolean;
  75757. set useDiffuseColor(useDiffuseColor: boolean);
  75758. /**
  75759. * Array containing the excluded meshes not rendered in the internal pass
  75760. */
  75761. excludedMeshes: AbstractMesh[];
  75762. /**
  75763. * Controls the overall intensity of the post-process
  75764. */
  75765. exposure: number;
  75766. /**
  75767. * Dissipates each sample's contribution in range [0, 1]
  75768. */
  75769. decay: number;
  75770. /**
  75771. * Controls the overall intensity of each sample
  75772. */
  75773. weight: number;
  75774. /**
  75775. * Controls the density of each sample
  75776. */
  75777. density: number;
  75778. /**
  75779. * @constructor
  75780. * @param name The post-process name
  75781. * @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)
  75782. * @param camera The camera that the post-process will be attached to
  75783. * @param mesh The mesh used to create the light scattering
  75784. * @param samples The post-process quality, default 100
  75785. * @param samplingModeThe post-process filtering mode
  75786. * @param engine The babylon engine
  75787. * @param reusable If the post-process is reusable
  75788. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  75789. */
  75790. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  75791. /**
  75792. * Returns the string "VolumetricLightScatteringPostProcess"
  75793. * @returns "VolumetricLightScatteringPostProcess"
  75794. */
  75795. getClassName(): string;
  75796. private _isReady;
  75797. /**
  75798. * Sets the new light position for light scattering effect
  75799. * @param position The new custom light position
  75800. */
  75801. setCustomMeshPosition(position: Vector3): void;
  75802. /**
  75803. * Returns the light position for light scattering effect
  75804. * @return Vector3 The custom light position
  75805. */
  75806. getCustomMeshPosition(): Vector3;
  75807. /**
  75808. * Disposes the internal assets and detaches the post-process from the camera
  75809. */
  75810. dispose(camera: Camera): void;
  75811. /**
  75812. * Returns the render target texture used by the post-process
  75813. * @return the render target texture used by the post-process
  75814. */
  75815. getPass(): RenderTargetTexture;
  75816. private _meshExcluded;
  75817. private _createPass;
  75818. private _updateMeshScreenCoordinates;
  75819. /**
  75820. * Creates a default mesh for the Volumeric Light Scattering post-process
  75821. * @param name The mesh name
  75822. * @param scene The scene where to create the mesh
  75823. * @return the default mesh
  75824. */
  75825. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  75826. }
  75827. }
  75828. declare module BABYLON {
  75829. /** @hidden */
  75830. export var screenSpaceCurvaturePixelShader: {
  75831. name: string;
  75832. shader: string;
  75833. };
  75834. }
  75835. declare module BABYLON {
  75836. /**
  75837. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  75838. */
  75839. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  75840. /**
  75841. * Defines how much ridge the curvature effect displays.
  75842. */
  75843. ridge: number;
  75844. /**
  75845. * Defines how much valley the curvature effect displays.
  75846. */
  75847. valley: number;
  75848. private _geometryBufferRenderer;
  75849. /**
  75850. * Gets a string identifying the name of the class
  75851. * @returns "ScreenSpaceCurvaturePostProcess" string
  75852. */
  75853. getClassName(): string;
  75854. /**
  75855. * Creates a new instance ScreenSpaceCurvaturePostProcess
  75856. * @param name The name of the effect.
  75857. * @param scene The scene containing the objects to blur according to their velocity.
  75858. * @param options The required width/height ratio to downsize to before computing the render pass.
  75859. * @param camera The camera to apply the render pass to.
  75860. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75861. * @param engine The engine which the post process will be applied. (default: current engine)
  75862. * @param reusable If the post process can be reused on the same frame. (default: false)
  75863. * @param textureType Type of textures used when performing the post process. (default: 0)
  75864. * @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)
  75865. */
  75866. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75867. /**
  75868. * Support test.
  75869. */
  75870. static get IsSupported(): boolean;
  75871. /** @hidden */
  75872. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  75873. }
  75874. }
  75875. declare module BABYLON {
  75876. interface Scene {
  75877. /** @hidden (Backing field) */
  75878. _boundingBoxRenderer: BoundingBoxRenderer;
  75879. /** @hidden (Backing field) */
  75880. _forceShowBoundingBoxes: boolean;
  75881. /**
  75882. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  75883. */
  75884. forceShowBoundingBoxes: boolean;
  75885. /**
  75886. * Gets the bounding box renderer associated with the scene
  75887. * @returns a BoundingBoxRenderer
  75888. */
  75889. getBoundingBoxRenderer(): BoundingBoxRenderer;
  75890. }
  75891. interface AbstractMesh {
  75892. /** @hidden (Backing field) */
  75893. _showBoundingBox: boolean;
  75894. /**
  75895. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  75896. */
  75897. showBoundingBox: boolean;
  75898. }
  75899. /**
  75900. * Component responsible of rendering the bounding box of the meshes in a scene.
  75901. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  75902. */
  75903. export class BoundingBoxRenderer implements ISceneComponent {
  75904. /**
  75905. * The component name helpfull to identify the component in the list of scene components.
  75906. */
  75907. readonly name: string;
  75908. /**
  75909. * The scene the component belongs to.
  75910. */
  75911. scene: Scene;
  75912. /**
  75913. * Color of the bounding box lines placed in front of an object
  75914. */
  75915. frontColor: Color3;
  75916. /**
  75917. * Color of the bounding box lines placed behind an object
  75918. */
  75919. backColor: Color3;
  75920. /**
  75921. * Defines if the renderer should show the back lines or not
  75922. */
  75923. showBackLines: boolean;
  75924. /**
  75925. * Observable raised before rendering a bounding box
  75926. */
  75927. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  75928. /**
  75929. * Observable raised after rendering a bounding box
  75930. */
  75931. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  75932. /**
  75933. * Observable raised after resources are created
  75934. */
  75935. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  75936. /**
  75937. * When false, no bounding boxes will be rendered
  75938. */
  75939. enabled: boolean;
  75940. /**
  75941. * @hidden
  75942. */
  75943. renderList: SmartArray<BoundingBox>;
  75944. private _colorShader;
  75945. private _vertexBuffers;
  75946. private _indexBuffer;
  75947. private _fillIndexBuffer;
  75948. private _fillIndexData;
  75949. /**
  75950. * Instantiates a new bounding box renderer in a scene.
  75951. * @param scene the scene the renderer renders in
  75952. */
  75953. constructor(scene: Scene);
  75954. /**
  75955. * Registers the component in a given scene
  75956. */
  75957. register(): void;
  75958. private _evaluateSubMesh;
  75959. private _preActiveMesh;
  75960. private _prepareResources;
  75961. private _createIndexBuffer;
  75962. /**
  75963. * Rebuilds the elements related to this component in case of
  75964. * context lost for instance.
  75965. */
  75966. rebuild(): void;
  75967. /**
  75968. * @hidden
  75969. */
  75970. reset(): void;
  75971. /**
  75972. * Render the bounding boxes of a specific rendering group
  75973. * @param renderingGroupId defines the rendering group to render
  75974. */
  75975. render(renderingGroupId: number): void;
  75976. /**
  75977. * In case of occlusion queries, we can render the occlusion bounding box through this method
  75978. * @param mesh Define the mesh to render the occlusion bounding box for
  75979. */
  75980. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  75981. /**
  75982. * Dispose and release the resources attached to this renderer.
  75983. */
  75984. dispose(): void;
  75985. }
  75986. }
  75987. declare module BABYLON {
  75988. interface Scene {
  75989. /** @hidden (Backing field) */
  75990. _depthRenderer: {
  75991. [id: string]: DepthRenderer;
  75992. };
  75993. /**
  75994. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  75995. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  75996. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  75997. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  75998. * @returns the created depth renderer
  75999. */
  76000. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76001. /**
  76002. * Disables a depth renderer for a given camera
  76003. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76004. */
  76005. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76006. }
  76007. /**
  76008. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76009. * in several rendering techniques.
  76010. */
  76011. export class DepthRendererSceneComponent implements ISceneComponent {
  76012. /**
  76013. * The component name helpfull to identify the component in the list of scene components.
  76014. */
  76015. readonly name: string;
  76016. /**
  76017. * The scene the component belongs to.
  76018. */
  76019. scene: Scene;
  76020. /**
  76021. * Creates a new instance of the component for the given scene
  76022. * @param scene Defines the scene to register the component in
  76023. */
  76024. constructor(scene: Scene);
  76025. /**
  76026. * Registers the component in a given scene
  76027. */
  76028. register(): void;
  76029. /**
  76030. * Rebuilds the elements related to this component in case of
  76031. * context lost for instance.
  76032. */
  76033. rebuild(): void;
  76034. /**
  76035. * Disposes the component and the associated ressources
  76036. */
  76037. dispose(): void;
  76038. private _gatherRenderTargets;
  76039. private _gatherActiveCameraRenderTargets;
  76040. }
  76041. }
  76042. declare module BABYLON {
  76043. interface AbstractScene {
  76044. /** @hidden (Backing field) */
  76045. _prePassRenderer: Nullable<PrePassRenderer>;
  76046. /**
  76047. * Gets or Sets the current prepass renderer associated to the scene.
  76048. */
  76049. prePassRenderer: Nullable<PrePassRenderer>;
  76050. /**
  76051. * Enables the prepass and associates it with the scene
  76052. * @returns the PrePassRenderer
  76053. */
  76054. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76055. /**
  76056. * Disables the prepass associated with the scene
  76057. */
  76058. disablePrePassRenderer(): void;
  76059. }
  76060. /**
  76061. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76062. * in several rendering techniques.
  76063. */
  76064. export class PrePassRendererSceneComponent implements ISceneComponent {
  76065. /**
  76066. * The component name helpful to identify the component in the list of scene components.
  76067. */
  76068. readonly name: string;
  76069. /**
  76070. * The scene the component belongs to.
  76071. */
  76072. scene: Scene;
  76073. /**
  76074. * Creates a new instance of the component for the given scene
  76075. * @param scene Defines the scene to register the component in
  76076. */
  76077. constructor(scene: Scene);
  76078. /**
  76079. * Registers the component in a given scene
  76080. */
  76081. register(): void;
  76082. private _beforeCameraDraw;
  76083. private _afterCameraDraw;
  76084. private _beforeClearStage;
  76085. private _beforeRenderingMeshStage;
  76086. private _afterRenderingMeshStage;
  76087. /**
  76088. * Rebuilds the elements related to this component in case of
  76089. * context lost for instance.
  76090. */
  76091. rebuild(): void;
  76092. /**
  76093. * Disposes the component and the associated ressources
  76094. */
  76095. dispose(): void;
  76096. }
  76097. }
  76098. declare module BABYLON {
  76099. /** @hidden */
  76100. export var fibonacci: {
  76101. name: string;
  76102. shader: string;
  76103. };
  76104. }
  76105. declare module BABYLON {
  76106. /** @hidden */
  76107. export var diffusionProfile: {
  76108. name: string;
  76109. shader: string;
  76110. };
  76111. }
  76112. declare module BABYLON {
  76113. /** @hidden */
  76114. export var subSurfaceScatteringPixelShader: {
  76115. name: string;
  76116. shader: string;
  76117. };
  76118. }
  76119. declare module BABYLON {
  76120. /**
  76121. * Sub surface scattering post process
  76122. */
  76123. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76124. /**
  76125. * Gets a string identifying the name of the class
  76126. * @returns "SubSurfaceScatteringPostProcess" string
  76127. */
  76128. getClassName(): string;
  76129. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76130. }
  76131. }
  76132. declare module BABYLON {
  76133. /**
  76134. * Contains all parameters needed for the prepass to perform
  76135. * screen space subsurface scattering
  76136. */
  76137. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76138. /** @hidden */
  76139. static _SceneComponentInitialization: (scene: Scene) => void;
  76140. private _ssDiffusionS;
  76141. private _ssFilterRadii;
  76142. private _ssDiffusionD;
  76143. /**
  76144. * Post process to attach for screen space subsurface scattering
  76145. */
  76146. postProcess: SubSurfaceScatteringPostProcess;
  76147. /**
  76148. * Diffusion profile color for subsurface scattering
  76149. */
  76150. get ssDiffusionS(): number[];
  76151. /**
  76152. * Diffusion profile max color channel value for subsurface scattering
  76153. */
  76154. get ssDiffusionD(): number[];
  76155. /**
  76156. * Diffusion profile filter radius for subsurface scattering
  76157. */
  76158. get ssFilterRadii(): number[];
  76159. /**
  76160. * Is subsurface enabled
  76161. */
  76162. enabled: boolean;
  76163. /**
  76164. * Name of the configuration
  76165. */
  76166. name: string;
  76167. /**
  76168. * Diffusion profile colors for subsurface scattering
  76169. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76170. * See ...
  76171. * Note that you can only store up to 5 of them
  76172. */
  76173. ssDiffusionProfileColors: Color3[];
  76174. /**
  76175. * Defines the ratio real world => scene units.
  76176. * Used for subsurface scattering
  76177. */
  76178. metersPerUnit: number;
  76179. /**
  76180. * Textures that should be present in the MRT for this effect to work
  76181. */
  76182. readonly texturesRequired: number[];
  76183. private _scene;
  76184. /**
  76185. * Builds a subsurface configuration object
  76186. * @param scene The scene
  76187. */
  76188. constructor(scene: Scene);
  76189. /**
  76190. * Adds a new diffusion profile.
  76191. * Useful for more realistic subsurface scattering on diverse materials.
  76192. * @param color The color of the diffusion profile. Should be the average color of the material.
  76193. * @return The index of the diffusion profile for the material subsurface configuration
  76194. */
  76195. addDiffusionProfile(color: Color3): number;
  76196. /**
  76197. * Creates the sss post process
  76198. * @return The created post process
  76199. */
  76200. createPostProcess(): SubSurfaceScatteringPostProcess;
  76201. /**
  76202. * Deletes all diffusion profiles.
  76203. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76204. */
  76205. clearAllDiffusionProfiles(): void;
  76206. /**
  76207. * Disposes this object
  76208. */
  76209. dispose(): void;
  76210. /**
  76211. * @hidden
  76212. * https://zero-radiance.github.io/post/sampling-diffusion/
  76213. *
  76214. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76215. * ------------------------------------------------------------------------------------
  76216. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76217. * PDF[r, phi, s] = r * R[r, phi, s]
  76218. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76219. * ------------------------------------------------------------------------------------
  76220. * We importance sample the color channel with the widest scattering distance.
  76221. */
  76222. getDiffusionProfileParameters(color: Color3): number;
  76223. /**
  76224. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76225. * 'u' is the random number (the value of the CDF): [0, 1).
  76226. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76227. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76228. */
  76229. private _sampleBurleyDiffusionProfile;
  76230. }
  76231. }
  76232. declare module BABYLON {
  76233. interface AbstractScene {
  76234. /** @hidden (Backing field) */
  76235. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76236. /**
  76237. * Gets or Sets the current prepass renderer associated to the scene.
  76238. */
  76239. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76240. /**
  76241. * Enables the subsurface effect for prepass
  76242. * @returns the SubSurfaceConfiguration
  76243. */
  76244. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76245. /**
  76246. * Disables the subsurface effect for prepass
  76247. */
  76248. disableSubSurfaceForPrePass(): void;
  76249. }
  76250. /**
  76251. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76252. * in several rendering techniques.
  76253. */
  76254. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76255. /**
  76256. * The component name helpful to identify the component in the list of scene components.
  76257. */
  76258. readonly name: string;
  76259. /**
  76260. * The scene the component belongs to.
  76261. */
  76262. scene: Scene;
  76263. /**
  76264. * Creates a new instance of the component for the given scene
  76265. * @param scene Defines the scene to register the component in
  76266. */
  76267. constructor(scene: Scene);
  76268. /**
  76269. * Registers the component in a given scene
  76270. */
  76271. register(): void;
  76272. /**
  76273. * Serializes the component data to the specified json object
  76274. * @param serializationObject The object to serialize to
  76275. */
  76276. serialize(serializationObject: any): void;
  76277. /**
  76278. * Adds all the elements from the container to the scene
  76279. * @param container the container holding the elements
  76280. */
  76281. addFromContainer(container: AbstractScene): void;
  76282. /**
  76283. * Removes all the elements in the container from the scene
  76284. * @param container contains the elements to remove
  76285. * @param dispose if the removed element should be disposed (default: false)
  76286. */
  76287. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76288. /**
  76289. * Rebuilds the elements related to this component in case of
  76290. * context lost for instance.
  76291. */
  76292. rebuild(): void;
  76293. /**
  76294. * Disposes the component and the associated ressources
  76295. */
  76296. dispose(): void;
  76297. }
  76298. }
  76299. declare module BABYLON {
  76300. /** @hidden */
  76301. export var outlinePixelShader: {
  76302. name: string;
  76303. shader: string;
  76304. };
  76305. }
  76306. declare module BABYLON {
  76307. /** @hidden */
  76308. export var outlineVertexShader: {
  76309. name: string;
  76310. shader: string;
  76311. };
  76312. }
  76313. declare module BABYLON {
  76314. interface Scene {
  76315. /** @hidden */
  76316. _outlineRenderer: OutlineRenderer;
  76317. /**
  76318. * Gets the outline renderer associated with the scene
  76319. * @returns a OutlineRenderer
  76320. */
  76321. getOutlineRenderer(): OutlineRenderer;
  76322. }
  76323. interface AbstractMesh {
  76324. /** @hidden (Backing field) */
  76325. _renderOutline: boolean;
  76326. /**
  76327. * Gets or sets a boolean indicating if the outline must be rendered as well
  76328. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76329. */
  76330. renderOutline: boolean;
  76331. /** @hidden (Backing field) */
  76332. _renderOverlay: boolean;
  76333. /**
  76334. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76335. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76336. */
  76337. renderOverlay: boolean;
  76338. }
  76339. /**
  76340. * This class is responsible to draw bothe outline/overlay of meshes.
  76341. * It should not be used directly but through the available method on mesh.
  76342. */
  76343. export class OutlineRenderer implements ISceneComponent {
  76344. /**
  76345. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76346. */
  76347. private static _StencilReference;
  76348. /**
  76349. * The name of the component. Each component must have a unique name.
  76350. */
  76351. name: string;
  76352. /**
  76353. * The scene the component belongs to.
  76354. */
  76355. scene: Scene;
  76356. /**
  76357. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76358. */
  76359. zOffset: number;
  76360. private _engine;
  76361. private _effect;
  76362. private _cachedDefines;
  76363. private _savedDepthWrite;
  76364. /**
  76365. * Instantiates a new outline renderer. (There could be only one per scene).
  76366. * @param scene Defines the scene it belongs to
  76367. */
  76368. constructor(scene: Scene);
  76369. /**
  76370. * Register the component to one instance of a scene.
  76371. */
  76372. register(): void;
  76373. /**
  76374. * Rebuilds the elements related to this component in case of
  76375. * context lost for instance.
  76376. */
  76377. rebuild(): void;
  76378. /**
  76379. * Disposes the component and the associated ressources.
  76380. */
  76381. dispose(): void;
  76382. /**
  76383. * Renders the outline in the canvas.
  76384. * @param subMesh Defines the sumesh to render
  76385. * @param batch Defines the batch of meshes in case of instances
  76386. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76387. */
  76388. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76389. /**
  76390. * Returns whether or not the outline renderer is ready for a given submesh.
  76391. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76392. * @param subMesh Defines the submesh to check readyness for
  76393. * @param useInstances Defines wheter wee are trying to render instances or not
  76394. * @returns true if ready otherwise false
  76395. */
  76396. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76397. private _beforeRenderingMesh;
  76398. private _afterRenderingMesh;
  76399. }
  76400. }
  76401. declare module BABYLON {
  76402. /**
  76403. * Defines the basic options interface of a Sprite Frame Source Size.
  76404. */
  76405. export interface ISpriteJSONSpriteSourceSize {
  76406. /**
  76407. * number of the original width of the Frame
  76408. */
  76409. w: number;
  76410. /**
  76411. * number of the original height of the Frame
  76412. */
  76413. h: number;
  76414. }
  76415. /**
  76416. * Defines the basic options interface of a Sprite Frame Data.
  76417. */
  76418. export interface ISpriteJSONSpriteFrameData {
  76419. /**
  76420. * number of the x offset of the Frame
  76421. */
  76422. x: number;
  76423. /**
  76424. * number of the y offset of the Frame
  76425. */
  76426. y: number;
  76427. /**
  76428. * number of the width of the Frame
  76429. */
  76430. w: number;
  76431. /**
  76432. * number of the height of the Frame
  76433. */
  76434. h: number;
  76435. }
  76436. /**
  76437. * Defines the basic options interface of a JSON Sprite.
  76438. */
  76439. export interface ISpriteJSONSprite {
  76440. /**
  76441. * string name of the Frame
  76442. */
  76443. filename: string;
  76444. /**
  76445. * ISpriteJSONSpriteFrame basic object of the frame data
  76446. */
  76447. frame: ISpriteJSONSpriteFrameData;
  76448. /**
  76449. * boolean to flag is the frame was rotated.
  76450. */
  76451. rotated: boolean;
  76452. /**
  76453. * boolean to flag is the frame was trimmed.
  76454. */
  76455. trimmed: boolean;
  76456. /**
  76457. * ISpriteJSONSpriteFrame basic object of the source data
  76458. */
  76459. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76460. /**
  76461. * ISpriteJSONSpriteFrame basic object of the source data
  76462. */
  76463. sourceSize: ISpriteJSONSpriteSourceSize;
  76464. }
  76465. /**
  76466. * Defines the basic options interface of a JSON atlas.
  76467. */
  76468. export interface ISpriteJSONAtlas {
  76469. /**
  76470. * Array of objects that contain the frame data.
  76471. */
  76472. frames: Array<ISpriteJSONSprite>;
  76473. /**
  76474. * object basic object containing the sprite meta data.
  76475. */
  76476. meta?: object;
  76477. }
  76478. }
  76479. declare module BABYLON {
  76480. /** @hidden */
  76481. export var spriteMapPixelShader: {
  76482. name: string;
  76483. shader: string;
  76484. };
  76485. }
  76486. declare module BABYLON {
  76487. /** @hidden */
  76488. export var spriteMapVertexShader: {
  76489. name: string;
  76490. shader: string;
  76491. };
  76492. }
  76493. declare module BABYLON {
  76494. /**
  76495. * Defines the basic options interface of a SpriteMap
  76496. */
  76497. export interface ISpriteMapOptions {
  76498. /**
  76499. * Vector2 of the number of cells in the grid.
  76500. */
  76501. stageSize?: Vector2;
  76502. /**
  76503. * Vector2 of the size of the output plane in World Units.
  76504. */
  76505. outputSize?: Vector2;
  76506. /**
  76507. * Vector3 of the position of the output plane in World Units.
  76508. */
  76509. outputPosition?: Vector3;
  76510. /**
  76511. * Vector3 of the rotation of the output plane.
  76512. */
  76513. outputRotation?: Vector3;
  76514. /**
  76515. * number of layers that the system will reserve in resources.
  76516. */
  76517. layerCount?: number;
  76518. /**
  76519. * number of max animation frames a single cell will reserve in resources.
  76520. */
  76521. maxAnimationFrames?: number;
  76522. /**
  76523. * number cell index of the base tile when the system compiles.
  76524. */
  76525. baseTile?: number;
  76526. /**
  76527. * boolean flip the sprite after its been repositioned by the framing data.
  76528. */
  76529. flipU?: boolean;
  76530. /**
  76531. * Vector3 scalar of the global RGB values of the SpriteMap.
  76532. */
  76533. colorMultiply?: Vector3;
  76534. }
  76535. /**
  76536. * Defines the IDisposable interface in order to be cleanable from resources.
  76537. */
  76538. export interface ISpriteMap extends IDisposable {
  76539. /**
  76540. * String name of the SpriteMap.
  76541. */
  76542. name: string;
  76543. /**
  76544. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  76545. */
  76546. atlasJSON: ISpriteJSONAtlas;
  76547. /**
  76548. * Texture of the SpriteMap.
  76549. */
  76550. spriteSheet: Texture;
  76551. /**
  76552. * The parameters to initialize the SpriteMap with.
  76553. */
  76554. options: ISpriteMapOptions;
  76555. }
  76556. /**
  76557. * Class used to manage a grid restricted sprite deployment on an Output plane.
  76558. */
  76559. export class SpriteMap implements ISpriteMap {
  76560. /** The Name of the spriteMap */
  76561. name: string;
  76562. /** The JSON file with the frame and meta data */
  76563. atlasJSON: ISpriteJSONAtlas;
  76564. /** The systems Sprite Sheet Texture */
  76565. spriteSheet: Texture;
  76566. /** Arguments passed with the Constructor */
  76567. options: ISpriteMapOptions;
  76568. /** Public Sprite Storage array, parsed from atlasJSON */
  76569. sprites: Array<ISpriteJSONSprite>;
  76570. /** Returns the Number of Sprites in the System */
  76571. get spriteCount(): number;
  76572. /** Returns the Position of Output Plane*/
  76573. get position(): Vector3;
  76574. /** Returns the Position of Output Plane*/
  76575. set position(v: Vector3);
  76576. /** Returns the Rotation of Output Plane*/
  76577. get rotation(): Vector3;
  76578. /** Returns the Rotation of Output Plane*/
  76579. set rotation(v: Vector3);
  76580. /** Sets the AnimationMap*/
  76581. get animationMap(): RawTexture;
  76582. /** Sets the AnimationMap*/
  76583. set animationMap(v: RawTexture);
  76584. /** Scene that the SpriteMap was created in */
  76585. private _scene;
  76586. /** Texture Buffer of Float32 that holds tile frame data*/
  76587. private _frameMap;
  76588. /** Texture Buffers of Float32 that holds tileMap data*/
  76589. private _tileMaps;
  76590. /** Texture Buffer of Float32 that holds Animation Data*/
  76591. private _animationMap;
  76592. /** Custom ShaderMaterial Central to the System*/
  76593. private _material;
  76594. /** Custom ShaderMaterial Central to the System*/
  76595. private _output;
  76596. /** Systems Time Ticker*/
  76597. private _time;
  76598. /**
  76599. * Creates a new SpriteMap
  76600. * @param name defines the SpriteMaps Name
  76601. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  76602. * @param spriteSheet is the Texture that the Sprites are on.
  76603. * @param options a basic deployment configuration
  76604. * @param scene The Scene that the map is deployed on
  76605. */
  76606. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  76607. /**
  76608. * Returns tileID location
  76609. * @returns Vector2 the cell position ID
  76610. */
  76611. getTileID(): Vector2;
  76612. /**
  76613. * Gets the UV location of the mouse over the SpriteMap.
  76614. * @returns Vector2 the UV position of the mouse interaction
  76615. */
  76616. getMousePosition(): Vector2;
  76617. /**
  76618. * Creates the "frame" texture Buffer
  76619. * -------------------------------------
  76620. * Structure of frames
  76621. * "filename": "Falling-Water-2.png",
  76622. * "frame": {"x":69,"y":103,"w":24,"h":32},
  76623. * "rotated": true,
  76624. * "trimmed": true,
  76625. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  76626. * "sourceSize": {"w":32,"h":32}
  76627. * @returns RawTexture of the frameMap
  76628. */
  76629. private _createFrameBuffer;
  76630. /**
  76631. * Creates the tileMap texture Buffer
  76632. * @param buffer normally and array of numbers, or a false to generate from scratch
  76633. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  76634. * @returns RawTexture of the tileMap
  76635. */
  76636. private _createTileBuffer;
  76637. /**
  76638. * Modifies the data of the tileMaps
  76639. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  76640. * @param pos is the iVector2 Coordinates of the Tile
  76641. * @param tile The SpriteIndex of the new Tile
  76642. */
  76643. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  76644. /**
  76645. * Creates the animationMap texture Buffer
  76646. * @param buffer normally and array of numbers, or a false to generate from scratch
  76647. * @returns RawTexture of the animationMap
  76648. */
  76649. private _createTileAnimationBuffer;
  76650. /**
  76651. * Modifies the data of the animationMap
  76652. * @param cellID is the Index of the Sprite
  76653. * @param _frame is the target Animation frame
  76654. * @param toCell is the Target Index of the next frame of the animation
  76655. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  76656. * @param speed is a global scalar of the time variable on the map.
  76657. */
  76658. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  76659. /**
  76660. * Exports the .tilemaps file
  76661. */
  76662. saveTileMaps(): void;
  76663. /**
  76664. * Imports the .tilemaps file
  76665. * @param url of the .tilemaps file
  76666. */
  76667. loadTileMaps(url: string): void;
  76668. /**
  76669. * Release associated resources
  76670. */
  76671. dispose(): void;
  76672. }
  76673. }
  76674. declare module BABYLON {
  76675. /**
  76676. * Class used to manage multiple sprites of different sizes on the same spritesheet
  76677. * @see https://doc.babylonjs.com/babylon101/sprites
  76678. */
  76679. export class SpritePackedManager extends SpriteManager {
  76680. /** defines the packed manager's name */
  76681. name: string;
  76682. /**
  76683. * Creates a new sprite manager from a packed sprite sheet
  76684. * @param name defines the manager's name
  76685. * @param imgUrl defines the sprite sheet url
  76686. * @param capacity defines the maximum allowed number of sprites
  76687. * @param scene defines the hosting scene
  76688. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  76689. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76690. * @param samplingMode defines the smapling mode to use with spritesheet
  76691. * @param fromPacked set to true; do not alter
  76692. */
  76693. constructor(
  76694. /** defines the packed manager's name */
  76695. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  76696. }
  76697. }
  76698. declare module BABYLON {
  76699. /**
  76700. * Defines the list of states available for a task inside a AssetsManager
  76701. */
  76702. export enum AssetTaskState {
  76703. /**
  76704. * Initialization
  76705. */
  76706. INIT = 0,
  76707. /**
  76708. * Running
  76709. */
  76710. RUNNING = 1,
  76711. /**
  76712. * Done
  76713. */
  76714. DONE = 2,
  76715. /**
  76716. * Error
  76717. */
  76718. ERROR = 3
  76719. }
  76720. /**
  76721. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  76722. */
  76723. export abstract class AbstractAssetTask {
  76724. /**
  76725. * Task name
  76726. */ name: string;
  76727. /**
  76728. * Callback called when the task is successful
  76729. */
  76730. onSuccess: (task: any) => void;
  76731. /**
  76732. * Callback called when the task is not successful
  76733. */
  76734. onError: (task: any, message?: string, exception?: any) => void;
  76735. /**
  76736. * Creates a new AssetsManager
  76737. * @param name defines the name of the task
  76738. */
  76739. constructor(
  76740. /**
  76741. * Task name
  76742. */ name: string);
  76743. private _isCompleted;
  76744. private _taskState;
  76745. private _errorObject;
  76746. /**
  76747. * Get if the task is completed
  76748. */
  76749. get isCompleted(): boolean;
  76750. /**
  76751. * Gets the current state of the task
  76752. */
  76753. get taskState(): AssetTaskState;
  76754. /**
  76755. * Gets the current error object (if task is in error)
  76756. */
  76757. get errorObject(): {
  76758. message?: string;
  76759. exception?: any;
  76760. };
  76761. /**
  76762. * Internal only
  76763. * @hidden
  76764. */
  76765. _setErrorObject(message?: string, exception?: any): void;
  76766. /**
  76767. * Execute the current task
  76768. * @param scene defines the scene where you want your assets to be loaded
  76769. * @param onSuccess is a callback called when the task is successfully executed
  76770. * @param onError is a callback called if an error occurs
  76771. */
  76772. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76773. /**
  76774. * Execute the current task
  76775. * @param scene defines the scene where you want your assets to be loaded
  76776. * @param onSuccess is a callback called when the task is successfully executed
  76777. * @param onError is a callback called if an error occurs
  76778. */
  76779. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76780. /**
  76781. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  76782. * This can be used with failed tasks that have the reason for failure fixed.
  76783. */
  76784. reset(): void;
  76785. private onErrorCallback;
  76786. private onDoneCallback;
  76787. }
  76788. /**
  76789. * Define the interface used by progress events raised during assets loading
  76790. */
  76791. export interface IAssetsProgressEvent {
  76792. /**
  76793. * Defines the number of remaining tasks to process
  76794. */
  76795. remainingCount: number;
  76796. /**
  76797. * Defines the total number of tasks
  76798. */
  76799. totalCount: number;
  76800. /**
  76801. * Defines the task that was just processed
  76802. */
  76803. task: AbstractAssetTask;
  76804. }
  76805. /**
  76806. * Class used to share progress information about assets loading
  76807. */
  76808. export class AssetsProgressEvent implements IAssetsProgressEvent {
  76809. /**
  76810. * Defines the number of remaining tasks to process
  76811. */
  76812. remainingCount: number;
  76813. /**
  76814. * Defines the total number of tasks
  76815. */
  76816. totalCount: number;
  76817. /**
  76818. * Defines the task that was just processed
  76819. */
  76820. task: AbstractAssetTask;
  76821. /**
  76822. * Creates a AssetsProgressEvent
  76823. * @param remainingCount defines the number of remaining tasks to process
  76824. * @param totalCount defines the total number of tasks
  76825. * @param task defines the task that was just processed
  76826. */
  76827. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  76828. }
  76829. /**
  76830. * Define a task used by AssetsManager to load assets into a container
  76831. */
  76832. export class ContainerAssetTask extends AbstractAssetTask {
  76833. /**
  76834. * Defines the name of the task
  76835. */
  76836. name: string;
  76837. /**
  76838. * Defines the list of mesh's names you want to load
  76839. */
  76840. meshesNames: any;
  76841. /**
  76842. * Defines the root url to use as a base to load your meshes and associated resources
  76843. */
  76844. rootUrl: string;
  76845. /**
  76846. * Defines the filename or File of the scene to load from
  76847. */
  76848. sceneFilename: string | File;
  76849. /**
  76850. * Get the loaded asset container
  76851. */
  76852. loadedContainer: AssetContainer;
  76853. /**
  76854. * Gets the list of loaded meshes
  76855. */
  76856. loadedMeshes: Array<AbstractMesh>;
  76857. /**
  76858. * Gets the list of loaded particle systems
  76859. */
  76860. loadedParticleSystems: Array<IParticleSystem>;
  76861. /**
  76862. * Gets the list of loaded skeletons
  76863. */
  76864. loadedSkeletons: Array<Skeleton>;
  76865. /**
  76866. * Gets the list of loaded animation groups
  76867. */
  76868. loadedAnimationGroups: Array<AnimationGroup>;
  76869. /**
  76870. * Callback called when the task is successful
  76871. */
  76872. onSuccess: (task: ContainerAssetTask) => void;
  76873. /**
  76874. * Callback called when the task is successful
  76875. */
  76876. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  76877. /**
  76878. * Creates a new ContainerAssetTask
  76879. * @param name defines the name of the task
  76880. * @param meshesNames defines the list of mesh's names you want to load
  76881. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76882. * @param sceneFilename defines the filename or File of the scene to load from
  76883. */
  76884. constructor(
  76885. /**
  76886. * Defines the name of the task
  76887. */
  76888. name: string,
  76889. /**
  76890. * Defines the list of mesh's names you want to load
  76891. */
  76892. meshesNames: any,
  76893. /**
  76894. * Defines the root url to use as a base to load your meshes and associated resources
  76895. */
  76896. rootUrl: string,
  76897. /**
  76898. * Defines the filename or File of the scene to load from
  76899. */
  76900. sceneFilename: string | File);
  76901. /**
  76902. * Execute the current task
  76903. * @param scene defines the scene where you want your assets to be loaded
  76904. * @param onSuccess is a callback called when the task is successfully executed
  76905. * @param onError is a callback called if an error occurs
  76906. */
  76907. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76908. }
  76909. /**
  76910. * Define a task used by AssetsManager to load meshes
  76911. */
  76912. export class MeshAssetTask extends AbstractAssetTask {
  76913. /**
  76914. * Defines the name of the task
  76915. */
  76916. name: string;
  76917. /**
  76918. * Defines the list of mesh's names you want to load
  76919. */
  76920. meshesNames: any;
  76921. /**
  76922. * Defines the root url to use as a base to load your meshes and associated resources
  76923. */
  76924. rootUrl: string;
  76925. /**
  76926. * Defines the filename or File of the scene to load from
  76927. */
  76928. sceneFilename: string | File;
  76929. /**
  76930. * Gets the list of loaded meshes
  76931. */
  76932. loadedMeshes: Array<AbstractMesh>;
  76933. /**
  76934. * Gets the list of loaded particle systems
  76935. */
  76936. loadedParticleSystems: Array<IParticleSystem>;
  76937. /**
  76938. * Gets the list of loaded skeletons
  76939. */
  76940. loadedSkeletons: Array<Skeleton>;
  76941. /**
  76942. * Gets the list of loaded animation groups
  76943. */
  76944. loadedAnimationGroups: Array<AnimationGroup>;
  76945. /**
  76946. * Callback called when the task is successful
  76947. */
  76948. onSuccess: (task: MeshAssetTask) => void;
  76949. /**
  76950. * Callback called when the task is successful
  76951. */
  76952. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  76953. /**
  76954. * Creates a new MeshAssetTask
  76955. * @param name defines the name of the task
  76956. * @param meshesNames defines the list of mesh's names you want to load
  76957. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76958. * @param sceneFilename defines the filename or File of the scene to load from
  76959. */
  76960. constructor(
  76961. /**
  76962. * Defines the name of the task
  76963. */
  76964. name: string,
  76965. /**
  76966. * Defines the list of mesh's names you want to load
  76967. */
  76968. meshesNames: any,
  76969. /**
  76970. * Defines the root url to use as a base to load your meshes and associated resources
  76971. */
  76972. rootUrl: string,
  76973. /**
  76974. * Defines the filename or File of the scene to load from
  76975. */
  76976. sceneFilename: string | File);
  76977. /**
  76978. * Execute the current task
  76979. * @param scene defines the scene where you want your assets to be loaded
  76980. * @param onSuccess is a callback called when the task is successfully executed
  76981. * @param onError is a callback called if an error occurs
  76982. */
  76983. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76984. }
  76985. /**
  76986. * Define a task used by AssetsManager to load text content
  76987. */
  76988. export class TextFileAssetTask extends AbstractAssetTask {
  76989. /**
  76990. * Defines the name of the task
  76991. */
  76992. name: string;
  76993. /**
  76994. * Defines the location of the file to load
  76995. */
  76996. url: string;
  76997. /**
  76998. * Gets the loaded text string
  76999. */
  77000. text: string;
  77001. /**
  77002. * Callback called when the task is successful
  77003. */
  77004. onSuccess: (task: TextFileAssetTask) => void;
  77005. /**
  77006. * Callback called when the task is successful
  77007. */
  77008. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77009. /**
  77010. * Creates a new TextFileAssetTask object
  77011. * @param name defines the name of the task
  77012. * @param url defines the location of the file to load
  77013. */
  77014. constructor(
  77015. /**
  77016. * Defines the name of the task
  77017. */
  77018. name: string,
  77019. /**
  77020. * Defines the location of the file to load
  77021. */
  77022. url: string);
  77023. /**
  77024. * Execute the current task
  77025. * @param scene defines the scene where you want your assets to be loaded
  77026. * @param onSuccess is a callback called when the task is successfully executed
  77027. * @param onError is a callback called if an error occurs
  77028. */
  77029. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77030. }
  77031. /**
  77032. * Define a task used by AssetsManager to load binary data
  77033. */
  77034. export class BinaryFileAssetTask extends AbstractAssetTask {
  77035. /**
  77036. * Defines the name of the task
  77037. */
  77038. name: string;
  77039. /**
  77040. * Defines the location of the file to load
  77041. */
  77042. url: string;
  77043. /**
  77044. * Gets the lodaded data (as an array buffer)
  77045. */
  77046. data: ArrayBuffer;
  77047. /**
  77048. * Callback called when the task is successful
  77049. */
  77050. onSuccess: (task: BinaryFileAssetTask) => void;
  77051. /**
  77052. * Callback called when the task is successful
  77053. */
  77054. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77055. /**
  77056. * Creates a new BinaryFileAssetTask object
  77057. * @param name defines the name of the new task
  77058. * @param url defines the location of the file to load
  77059. */
  77060. constructor(
  77061. /**
  77062. * Defines the name of the task
  77063. */
  77064. name: string,
  77065. /**
  77066. * Defines the location of the file to load
  77067. */
  77068. url: string);
  77069. /**
  77070. * Execute the current task
  77071. * @param scene defines the scene where you want your assets to be loaded
  77072. * @param onSuccess is a callback called when the task is successfully executed
  77073. * @param onError is a callback called if an error occurs
  77074. */
  77075. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77076. }
  77077. /**
  77078. * Define a task used by AssetsManager to load images
  77079. */
  77080. export class ImageAssetTask extends AbstractAssetTask {
  77081. /**
  77082. * Defines the name of the task
  77083. */
  77084. name: string;
  77085. /**
  77086. * Defines the location of the image to load
  77087. */
  77088. url: string;
  77089. /**
  77090. * Gets the loaded images
  77091. */
  77092. image: HTMLImageElement;
  77093. /**
  77094. * Callback called when the task is successful
  77095. */
  77096. onSuccess: (task: ImageAssetTask) => void;
  77097. /**
  77098. * Callback called when the task is successful
  77099. */
  77100. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77101. /**
  77102. * Creates a new ImageAssetTask
  77103. * @param name defines the name of the task
  77104. * @param url defines the location of the image to load
  77105. */
  77106. constructor(
  77107. /**
  77108. * Defines the name of the task
  77109. */
  77110. name: string,
  77111. /**
  77112. * Defines the location of the image to load
  77113. */
  77114. url: string);
  77115. /**
  77116. * Execute the current task
  77117. * @param scene defines the scene where you want your assets to be loaded
  77118. * @param onSuccess is a callback called when the task is successfully executed
  77119. * @param onError is a callback called if an error occurs
  77120. */
  77121. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77122. }
  77123. /**
  77124. * Defines the interface used by texture loading tasks
  77125. */
  77126. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77127. /**
  77128. * Gets the loaded texture
  77129. */
  77130. texture: TEX;
  77131. }
  77132. /**
  77133. * Define a task used by AssetsManager to load 2D textures
  77134. */
  77135. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77136. /**
  77137. * Defines the name of the task
  77138. */
  77139. name: string;
  77140. /**
  77141. * Defines the location of the file to load
  77142. */
  77143. url: string;
  77144. /**
  77145. * Defines if mipmap should not be generated (default is false)
  77146. */
  77147. noMipmap?: boolean | undefined;
  77148. /**
  77149. * Defines if texture must be inverted on Y axis (default is true)
  77150. */
  77151. invertY: boolean;
  77152. /**
  77153. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77154. */
  77155. samplingMode: number;
  77156. /**
  77157. * Gets the loaded texture
  77158. */
  77159. texture: Texture;
  77160. /**
  77161. * Callback called when the task is successful
  77162. */
  77163. onSuccess: (task: TextureAssetTask) => void;
  77164. /**
  77165. * Callback called when the task is successful
  77166. */
  77167. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77168. /**
  77169. * Creates a new TextureAssetTask object
  77170. * @param name defines the name of the task
  77171. * @param url defines the location of the file to load
  77172. * @param noMipmap defines if mipmap should not be generated (default is false)
  77173. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77174. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77175. */
  77176. constructor(
  77177. /**
  77178. * Defines the name of the task
  77179. */
  77180. name: string,
  77181. /**
  77182. * Defines the location of the file to load
  77183. */
  77184. url: string,
  77185. /**
  77186. * Defines if mipmap should not be generated (default is false)
  77187. */
  77188. noMipmap?: boolean | undefined,
  77189. /**
  77190. * Defines if texture must be inverted on Y axis (default is true)
  77191. */
  77192. invertY?: boolean,
  77193. /**
  77194. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77195. */
  77196. samplingMode?: number);
  77197. /**
  77198. * Execute the current task
  77199. * @param scene defines the scene where you want your assets to be loaded
  77200. * @param onSuccess is a callback called when the task is successfully executed
  77201. * @param onError is a callback called if an error occurs
  77202. */
  77203. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77204. }
  77205. /**
  77206. * Define a task used by AssetsManager to load cube textures
  77207. */
  77208. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77209. /**
  77210. * Defines the name of the task
  77211. */
  77212. name: string;
  77213. /**
  77214. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77215. */
  77216. url: string;
  77217. /**
  77218. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77219. */
  77220. extensions?: string[] | undefined;
  77221. /**
  77222. * Defines if mipmaps should not be generated (default is false)
  77223. */
  77224. noMipmap?: boolean | undefined;
  77225. /**
  77226. * Defines the explicit list of files (undefined by default)
  77227. */
  77228. files?: string[] | undefined;
  77229. /**
  77230. * Gets the loaded texture
  77231. */
  77232. texture: CubeTexture;
  77233. /**
  77234. * Callback called when the task is successful
  77235. */
  77236. onSuccess: (task: CubeTextureAssetTask) => void;
  77237. /**
  77238. * Callback called when the task is successful
  77239. */
  77240. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77241. /**
  77242. * Creates a new CubeTextureAssetTask
  77243. * @param name defines the name of the task
  77244. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77245. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77246. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77247. * @param files defines the explicit list of files (undefined by default)
  77248. */
  77249. constructor(
  77250. /**
  77251. * Defines the name of the task
  77252. */
  77253. name: string,
  77254. /**
  77255. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77256. */
  77257. url: string,
  77258. /**
  77259. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77260. */
  77261. extensions?: string[] | undefined,
  77262. /**
  77263. * Defines if mipmaps should not be generated (default is false)
  77264. */
  77265. noMipmap?: boolean | undefined,
  77266. /**
  77267. * Defines the explicit list of files (undefined by default)
  77268. */
  77269. files?: string[] | undefined);
  77270. /**
  77271. * Execute the current task
  77272. * @param scene defines the scene where you want your assets to be loaded
  77273. * @param onSuccess is a callback called when the task is successfully executed
  77274. * @param onError is a callback called if an error occurs
  77275. */
  77276. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77277. }
  77278. /**
  77279. * Define a task used by AssetsManager to load HDR cube textures
  77280. */
  77281. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77282. /**
  77283. * Defines the name of the task
  77284. */
  77285. name: string;
  77286. /**
  77287. * Defines the location of the file to load
  77288. */
  77289. url: string;
  77290. /**
  77291. * Defines the desired size (the more it increases the longer the generation will be)
  77292. */
  77293. size: number;
  77294. /**
  77295. * Defines if mipmaps should not be generated (default is false)
  77296. */
  77297. noMipmap: boolean;
  77298. /**
  77299. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77300. */
  77301. generateHarmonics: boolean;
  77302. /**
  77303. * 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)
  77304. */
  77305. gammaSpace: boolean;
  77306. /**
  77307. * Internal Use Only
  77308. */
  77309. reserved: boolean;
  77310. /**
  77311. * Gets the loaded texture
  77312. */
  77313. texture: HDRCubeTexture;
  77314. /**
  77315. * Callback called when the task is successful
  77316. */
  77317. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77318. /**
  77319. * Callback called when the task is successful
  77320. */
  77321. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77322. /**
  77323. * Creates a new HDRCubeTextureAssetTask object
  77324. * @param name defines the name of the task
  77325. * @param url defines the location of the file to load
  77326. * @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.
  77327. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77328. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77329. * @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)
  77330. * @param reserved Internal use only
  77331. */
  77332. constructor(
  77333. /**
  77334. * Defines the name of the task
  77335. */
  77336. name: string,
  77337. /**
  77338. * Defines the location of the file to load
  77339. */
  77340. url: string,
  77341. /**
  77342. * Defines the desired size (the more it increases the longer the generation will be)
  77343. */
  77344. size: number,
  77345. /**
  77346. * Defines if mipmaps should not be generated (default is false)
  77347. */
  77348. noMipmap?: boolean,
  77349. /**
  77350. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77351. */
  77352. generateHarmonics?: boolean,
  77353. /**
  77354. * 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)
  77355. */
  77356. gammaSpace?: boolean,
  77357. /**
  77358. * Internal Use Only
  77359. */
  77360. reserved?: boolean);
  77361. /**
  77362. * Execute the current task
  77363. * @param scene defines the scene where you want your assets to be loaded
  77364. * @param onSuccess is a callback called when the task is successfully executed
  77365. * @param onError is a callback called if an error occurs
  77366. */
  77367. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77368. }
  77369. /**
  77370. * Define a task used by AssetsManager to load Equirectangular cube textures
  77371. */
  77372. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77373. /**
  77374. * Defines the name of the task
  77375. */
  77376. name: string;
  77377. /**
  77378. * Defines the location of the file to load
  77379. */
  77380. url: string;
  77381. /**
  77382. * Defines the desired size (the more it increases the longer the generation will be)
  77383. */
  77384. size: number;
  77385. /**
  77386. * Defines if mipmaps should not be generated (default is false)
  77387. */
  77388. noMipmap: boolean;
  77389. /**
  77390. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77391. * but the standard material would require them in Gamma space) (default is true)
  77392. */
  77393. gammaSpace: boolean;
  77394. /**
  77395. * Gets the loaded texture
  77396. */
  77397. texture: EquiRectangularCubeTexture;
  77398. /**
  77399. * Callback called when the task is successful
  77400. */
  77401. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77402. /**
  77403. * Callback called when the task is successful
  77404. */
  77405. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77406. /**
  77407. * Creates a new EquiRectangularCubeTextureAssetTask object
  77408. * @param name defines the name of the task
  77409. * @param url defines the location of the file to load
  77410. * @param size defines the desired size (the more it increases the longer the generation will be)
  77411. * If the size is omitted this implies you are using a preprocessed cubemap.
  77412. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77413. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77414. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77415. * (default is true)
  77416. */
  77417. constructor(
  77418. /**
  77419. * Defines the name of the task
  77420. */
  77421. name: string,
  77422. /**
  77423. * Defines the location of the file to load
  77424. */
  77425. url: string,
  77426. /**
  77427. * Defines the desired size (the more it increases the longer the generation will be)
  77428. */
  77429. size: number,
  77430. /**
  77431. * Defines if mipmaps should not be generated (default is false)
  77432. */
  77433. noMipmap?: boolean,
  77434. /**
  77435. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77436. * but the standard material would require them in Gamma space) (default is true)
  77437. */
  77438. gammaSpace?: boolean);
  77439. /**
  77440. * Execute the current task
  77441. * @param scene defines the scene where you want your assets to be loaded
  77442. * @param onSuccess is a callback called when the task is successfully executed
  77443. * @param onError is a callback called if an error occurs
  77444. */
  77445. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77446. }
  77447. /**
  77448. * This class can be used to easily import assets into a scene
  77449. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77450. */
  77451. export class AssetsManager {
  77452. private _scene;
  77453. private _isLoading;
  77454. protected _tasks: AbstractAssetTask[];
  77455. protected _waitingTasksCount: number;
  77456. protected _totalTasksCount: number;
  77457. /**
  77458. * Callback called when all tasks are processed
  77459. */
  77460. onFinish: (tasks: AbstractAssetTask[]) => void;
  77461. /**
  77462. * Callback called when a task is successful
  77463. */
  77464. onTaskSuccess: (task: AbstractAssetTask) => void;
  77465. /**
  77466. * Callback called when a task had an error
  77467. */
  77468. onTaskError: (task: AbstractAssetTask) => void;
  77469. /**
  77470. * Callback called when a task is done (whatever the result is)
  77471. */
  77472. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77473. /**
  77474. * Observable called when all tasks are processed
  77475. */
  77476. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  77477. /**
  77478. * Observable called when a task had an error
  77479. */
  77480. onTaskErrorObservable: Observable<AbstractAssetTask>;
  77481. /**
  77482. * Observable called when all tasks were executed
  77483. */
  77484. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  77485. /**
  77486. * Observable called when a task is done (whatever the result is)
  77487. */
  77488. onProgressObservable: Observable<IAssetsProgressEvent>;
  77489. /**
  77490. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  77491. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  77492. */
  77493. useDefaultLoadingScreen: boolean;
  77494. /**
  77495. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  77496. * when all assets have been downloaded.
  77497. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  77498. */
  77499. autoHideLoadingUI: boolean;
  77500. /**
  77501. * Creates a new AssetsManager
  77502. * @param scene defines the scene to work on
  77503. */
  77504. constructor(scene: Scene);
  77505. /**
  77506. * Add a ContainerAssetTask to the list of active tasks
  77507. * @param taskName defines the name of the new task
  77508. * @param meshesNames defines the name of meshes to load
  77509. * @param rootUrl defines the root url to use to locate files
  77510. * @param sceneFilename defines the filename of the scene file
  77511. * @returns a new ContainerAssetTask object
  77512. */
  77513. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  77514. /**
  77515. * Add a MeshAssetTask to the list of active tasks
  77516. * @param taskName defines the name of the new task
  77517. * @param meshesNames defines the name of meshes to load
  77518. * @param rootUrl defines the root url to use to locate files
  77519. * @param sceneFilename defines the filename of the scene file
  77520. * @returns a new MeshAssetTask object
  77521. */
  77522. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  77523. /**
  77524. * Add a TextFileAssetTask to the list of active tasks
  77525. * @param taskName defines the name of the new task
  77526. * @param url defines the url of the file to load
  77527. * @returns a new TextFileAssetTask object
  77528. */
  77529. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  77530. /**
  77531. * Add a BinaryFileAssetTask to the list of active tasks
  77532. * @param taskName defines the name of the new task
  77533. * @param url defines the url of the file to load
  77534. * @returns a new BinaryFileAssetTask object
  77535. */
  77536. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  77537. /**
  77538. * Add a ImageAssetTask to the list of active tasks
  77539. * @param taskName defines the name of the new task
  77540. * @param url defines the url of the file to load
  77541. * @returns a new ImageAssetTask object
  77542. */
  77543. addImageTask(taskName: string, url: string): ImageAssetTask;
  77544. /**
  77545. * Add a TextureAssetTask to the list of active tasks
  77546. * @param taskName defines the name of the new task
  77547. * @param url defines the url of the file to load
  77548. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77549. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  77550. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  77551. * @returns a new TextureAssetTask object
  77552. */
  77553. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  77554. /**
  77555. * Add a CubeTextureAssetTask to the list of active tasks
  77556. * @param taskName defines the name of the new task
  77557. * @param url defines the url of the file to load
  77558. * @param extensions defines the extension to use to load the cube map (can be null)
  77559. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77560. * @param files defines the list of files to load (can be null)
  77561. * @returns a new CubeTextureAssetTask object
  77562. */
  77563. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  77564. /**
  77565. *
  77566. * Add a HDRCubeTextureAssetTask to the list of active tasks
  77567. * @param taskName defines the name of the new task
  77568. * @param url defines the url of the file to load
  77569. * @param size defines the size you want for the cubemap (can be null)
  77570. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77571. * @param generateHarmonics defines if you want to automatically generate (true by default)
  77572. * @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)
  77573. * @param reserved Internal use only
  77574. * @returns a new HDRCubeTextureAssetTask object
  77575. */
  77576. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  77577. /**
  77578. *
  77579. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  77580. * @param taskName defines the name of the new task
  77581. * @param url defines the url of the file to load
  77582. * @param size defines the size you want for the cubemap (can be null)
  77583. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77584. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  77585. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  77586. * @returns a new EquiRectangularCubeTextureAssetTask object
  77587. */
  77588. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  77589. /**
  77590. * Remove a task from the assets manager.
  77591. * @param task the task to remove
  77592. */
  77593. removeTask(task: AbstractAssetTask): void;
  77594. private _decreaseWaitingTasksCount;
  77595. private _runTask;
  77596. /**
  77597. * Reset the AssetsManager and remove all tasks
  77598. * @return the current instance of the AssetsManager
  77599. */
  77600. reset(): AssetsManager;
  77601. /**
  77602. * Start the loading process
  77603. * @return the current instance of the AssetsManager
  77604. */
  77605. load(): AssetsManager;
  77606. /**
  77607. * Start the loading process as an async operation
  77608. * @return a promise returning the list of failed tasks
  77609. */
  77610. loadAsync(): Promise<void>;
  77611. }
  77612. }
  77613. declare module BABYLON {
  77614. /**
  77615. * Wrapper class for promise with external resolve and reject.
  77616. */
  77617. export class Deferred<T> {
  77618. /**
  77619. * The promise associated with this deferred object.
  77620. */
  77621. readonly promise: Promise<T>;
  77622. private _resolve;
  77623. private _reject;
  77624. /**
  77625. * The resolve method of the promise associated with this deferred object.
  77626. */
  77627. get resolve(): (value: T | PromiseLike<T>) => void;
  77628. /**
  77629. * The reject method of the promise associated with this deferred object.
  77630. */
  77631. get reject(): (reason?: any) => void;
  77632. /**
  77633. * Constructor for this deferred object.
  77634. */
  77635. constructor();
  77636. }
  77637. }
  77638. declare module BABYLON {
  77639. /**
  77640. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  77641. */
  77642. export class MeshExploder {
  77643. private _centerMesh;
  77644. private _meshes;
  77645. private _meshesOrigins;
  77646. private _toCenterVectors;
  77647. private _scaledDirection;
  77648. private _newPosition;
  77649. private _centerPosition;
  77650. /**
  77651. * Explodes meshes from a center mesh.
  77652. * @param meshes The meshes to explode.
  77653. * @param centerMesh The mesh to be center of explosion.
  77654. */
  77655. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  77656. private _setCenterMesh;
  77657. /**
  77658. * Get class name
  77659. * @returns "MeshExploder"
  77660. */
  77661. getClassName(): string;
  77662. /**
  77663. * "Exploded meshes"
  77664. * @returns Array of meshes with the centerMesh at index 0.
  77665. */
  77666. getMeshes(): Array<Mesh>;
  77667. /**
  77668. * Explodes meshes giving a specific direction
  77669. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  77670. */
  77671. explode(direction?: number): void;
  77672. }
  77673. }
  77674. declare module BABYLON {
  77675. /**
  77676. * Class used to help managing file picking and drag'n'drop
  77677. */
  77678. export class FilesInput {
  77679. /**
  77680. * List of files ready to be loaded
  77681. */
  77682. static get FilesToLoad(): {
  77683. [key: string]: File;
  77684. };
  77685. /**
  77686. * Callback called when a file is processed
  77687. */
  77688. onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean;
  77689. /**
  77690. * Function used when loading the scene file
  77691. */
  77692. loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene>;
  77693. private _engine;
  77694. private _currentScene;
  77695. private _sceneLoadedCallback;
  77696. private _progressCallback;
  77697. private _additionalRenderLoopLogicCallback;
  77698. private _textureLoadingCallback;
  77699. private _startingProcessingFilesCallback;
  77700. private _onReloadCallback;
  77701. private _errorCallback;
  77702. private _elementToMonitor;
  77703. private _sceneFileToLoad;
  77704. private _filesToLoad;
  77705. /**
  77706. * Creates a new FilesInput
  77707. * @param engine defines the rendering engine
  77708. * @param scene defines the hosting scene
  77709. * @param sceneLoadedCallback callback called when scene is loaded
  77710. * @param progressCallback callback called to track progress
  77711. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  77712. * @param textureLoadingCallback callback called when a texture is loading
  77713. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  77714. * @param onReloadCallback callback called when a reload is requested
  77715. * @param errorCallback callback call if an error occurs
  77716. */
  77717. 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>);
  77718. private _dragEnterHandler;
  77719. private _dragOverHandler;
  77720. private _dropHandler;
  77721. /**
  77722. * Calls this function to listen to drag'n'drop events on a specific DOM element
  77723. * @param elementToMonitor defines the DOM element to track
  77724. */
  77725. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  77726. /** Gets the current list of files to load */
  77727. get filesToLoad(): File[];
  77728. /**
  77729. * Release all associated resources
  77730. */
  77731. dispose(): void;
  77732. private renderFunction;
  77733. private drag;
  77734. private drop;
  77735. private _traverseFolder;
  77736. private _processFiles;
  77737. /**
  77738. * Load files from a drop event
  77739. * @param event defines the drop event to use as source
  77740. */
  77741. loadFiles(event: any): void;
  77742. private _processReload;
  77743. /**
  77744. * Reload the current scene from the loaded files
  77745. */
  77746. reload(): void;
  77747. }
  77748. }
  77749. declare module BABYLON {
  77750. /**
  77751. * Defines the root class used to create scene optimization to use with SceneOptimizer
  77752. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77753. */
  77754. export class SceneOptimization {
  77755. /**
  77756. * Defines the priority of this optimization (0 by default which means first in the list)
  77757. */
  77758. priority: number;
  77759. /**
  77760. * Gets a string describing the action executed by the current optimization
  77761. * @returns description string
  77762. */
  77763. getDescription(): string;
  77764. /**
  77765. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77766. * @param scene defines the current scene where to apply this optimization
  77767. * @param optimizer defines the current optimizer
  77768. * @returns true if everything that can be done was applied
  77769. */
  77770. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77771. /**
  77772. * Creates the SceneOptimization object
  77773. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77774. * @param desc defines the description associated with the optimization
  77775. */
  77776. constructor(
  77777. /**
  77778. * Defines the priority of this optimization (0 by default which means first in the list)
  77779. */
  77780. priority?: number);
  77781. }
  77782. /**
  77783. * Defines an optimization used to reduce the size of render target textures
  77784. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77785. */
  77786. export class TextureOptimization extends SceneOptimization {
  77787. /**
  77788. * Defines the priority of this optimization (0 by default which means first in the list)
  77789. */
  77790. priority: number;
  77791. /**
  77792. * 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
  77793. */
  77794. maximumSize: number;
  77795. /**
  77796. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77797. */
  77798. step: number;
  77799. /**
  77800. * Gets a string describing the action executed by the current optimization
  77801. * @returns description string
  77802. */
  77803. getDescription(): string;
  77804. /**
  77805. * Creates the TextureOptimization object
  77806. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77807. * @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
  77808. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77809. */
  77810. constructor(
  77811. /**
  77812. * Defines the priority of this optimization (0 by default which means first in the list)
  77813. */
  77814. priority?: number,
  77815. /**
  77816. * 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
  77817. */
  77818. maximumSize?: number,
  77819. /**
  77820. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77821. */
  77822. step?: number);
  77823. /**
  77824. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77825. * @param scene defines the current scene where to apply this optimization
  77826. * @param optimizer defines the current optimizer
  77827. * @returns true if everything that can be done was applied
  77828. */
  77829. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77830. }
  77831. /**
  77832. * Defines an optimization used to increase or decrease the rendering resolution
  77833. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77834. */
  77835. export class HardwareScalingOptimization extends SceneOptimization {
  77836. /**
  77837. * Defines the priority of this optimization (0 by default which means first in the list)
  77838. */
  77839. priority: number;
  77840. /**
  77841. * Defines the maximum scale to use (2 by default)
  77842. */
  77843. maximumScale: number;
  77844. /**
  77845. * Defines the step to use between two passes (0.5 by default)
  77846. */
  77847. step: number;
  77848. private _currentScale;
  77849. private _directionOffset;
  77850. /**
  77851. * Gets a string describing the action executed by the current optimization
  77852. * @return description string
  77853. */
  77854. getDescription(): string;
  77855. /**
  77856. * Creates the HardwareScalingOptimization object
  77857. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77858. * @param maximumScale defines the maximum scale to use (2 by default)
  77859. * @param step defines the step to use between two passes (0.5 by default)
  77860. */
  77861. constructor(
  77862. /**
  77863. * Defines the priority of this optimization (0 by default which means first in the list)
  77864. */
  77865. priority?: number,
  77866. /**
  77867. * Defines the maximum scale to use (2 by default)
  77868. */
  77869. maximumScale?: number,
  77870. /**
  77871. * Defines the step to use between two passes (0.5 by default)
  77872. */
  77873. step?: number);
  77874. /**
  77875. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77876. * @param scene defines the current scene where to apply this optimization
  77877. * @param optimizer defines the current optimizer
  77878. * @returns true if everything that can be done was applied
  77879. */
  77880. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77881. }
  77882. /**
  77883. * Defines an optimization used to remove shadows
  77884. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77885. */
  77886. export class ShadowsOptimization extends SceneOptimization {
  77887. /**
  77888. * Gets a string describing the action executed by the current optimization
  77889. * @return description string
  77890. */
  77891. getDescription(): string;
  77892. /**
  77893. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77894. * @param scene defines the current scene where to apply this optimization
  77895. * @param optimizer defines the current optimizer
  77896. * @returns true if everything that can be done was applied
  77897. */
  77898. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77899. }
  77900. /**
  77901. * Defines an optimization used to turn post-processes off
  77902. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77903. */
  77904. export class PostProcessesOptimization extends SceneOptimization {
  77905. /**
  77906. * Gets a string describing the action executed by the current optimization
  77907. * @return description string
  77908. */
  77909. getDescription(): string;
  77910. /**
  77911. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77912. * @param scene defines the current scene where to apply this optimization
  77913. * @param optimizer defines the current optimizer
  77914. * @returns true if everything that can be done was applied
  77915. */
  77916. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77917. }
  77918. /**
  77919. * Defines an optimization used to turn lens flares off
  77920. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77921. */
  77922. export class LensFlaresOptimization extends SceneOptimization {
  77923. /**
  77924. * Gets a string describing the action executed by the current optimization
  77925. * @return description string
  77926. */
  77927. getDescription(): string;
  77928. /**
  77929. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77930. * @param scene defines the current scene where to apply this optimization
  77931. * @param optimizer defines the current optimizer
  77932. * @returns true if everything that can be done was applied
  77933. */
  77934. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77935. }
  77936. /**
  77937. * Defines an optimization based on user defined callback.
  77938. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77939. */
  77940. export class CustomOptimization extends SceneOptimization {
  77941. /**
  77942. * Callback called to apply the custom optimization.
  77943. */
  77944. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  77945. /**
  77946. * Callback called to get custom description
  77947. */
  77948. onGetDescription: () => string;
  77949. /**
  77950. * Gets a string describing the action executed by the current optimization
  77951. * @returns description string
  77952. */
  77953. getDescription(): string;
  77954. /**
  77955. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77956. * @param scene defines the current scene where to apply this optimization
  77957. * @param optimizer defines the current optimizer
  77958. * @returns true if everything that can be done was applied
  77959. */
  77960. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77961. }
  77962. /**
  77963. * Defines an optimization used to turn particles off
  77964. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77965. */
  77966. export class ParticlesOptimization extends SceneOptimization {
  77967. /**
  77968. * Gets a string describing the action executed by the current optimization
  77969. * @return description string
  77970. */
  77971. getDescription(): string;
  77972. /**
  77973. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77974. * @param scene defines the current scene where to apply this optimization
  77975. * @param optimizer defines the current optimizer
  77976. * @returns true if everything that can be done was applied
  77977. */
  77978. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77979. }
  77980. /**
  77981. * Defines an optimization used to turn render targets off
  77982. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77983. */
  77984. export class RenderTargetsOptimization extends SceneOptimization {
  77985. /**
  77986. * Gets a string describing the action executed by the current optimization
  77987. * @return description string
  77988. */
  77989. getDescription(): string;
  77990. /**
  77991. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77992. * @param scene defines the current scene where to apply this optimization
  77993. * @param optimizer defines the current optimizer
  77994. * @returns true if everything that can be done was applied
  77995. */
  77996. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77997. }
  77998. /**
  77999. * Defines an optimization used to merge meshes with compatible materials
  78000. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78001. */
  78002. export class MergeMeshesOptimization extends SceneOptimization {
  78003. private static _UpdateSelectionTree;
  78004. /**
  78005. * Gets or sets a boolean which defines if optimization octree has to be updated
  78006. */
  78007. static get UpdateSelectionTree(): boolean;
  78008. /**
  78009. * Gets or sets a boolean which defines if optimization octree has to be updated
  78010. */
  78011. static set UpdateSelectionTree(value: boolean);
  78012. /**
  78013. * Gets a string describing the action executed by the current optimization
  78014. * @return description string
  78015. */
  78016. getDescription(): string;
  78017. private _canBeMerged;
  78018. /**
  78019. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78020. * @param scene defines the current scene where to apply this optimization
  78021. * @param optimizer defines the current optimizer
  78022. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78023. * @returns true if everything that can be done was applied
  78024. */
  78025. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78026. }
  78027. /**
  78028. * Defines a list of options used by SceneOptimizer
  78029. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78030. */
  78031. export class SceneOptimizerOptions {
  78032. /**
  78033. * Defines the target frame rate to reach (60 by default)
  78034. */
  78035. targetFrameRate: number;
  78036. /**
  78037. * Defines the interval between two checkes (2000ms by default)
  78038. */
  78039. trackerDuration: number;
  78040. /**
  78041. * Gets the list of optimizations to apply
  78042. */
  78043. optimizations: SceneOptimization[];
  78044. /**
  78045. * Creates a new list of options used by SceneOptimizer
  78046. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78047. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  78048. */
  78049. constructor(
  78050. /**
  78051. * Defines the target frame rate to reach (60 by default)
  78052. */
  78053. targetFrameRate?: number,
  78054. /**
  78055. * Defines the interval between two checkes (2000ms by default)
  78056. */
  78057. trackerDuration?: number);
  78058. /**
  78059. * Add a new optimization
  78060. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78061. * @returns the current SceneOptimizerOptions
  78062. */
  78063. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78064. /**
  78065. * Add a new custom optimization
  78066. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78067. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78068. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78069. * @returns the current SceneOptimizerOptions
  78070. */
  78071. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78072. /**
  78073. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78074. * @param targetFrameRate defines the target frame rate (60 by default)
  78075. * @returns a SceneOptimizerOptions object
  78076. */
  78077. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78078. /**
  78079. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78080. * @param targetFrameRate defines the target frame rate (60 by default)
  78081. * @returns a SceneOptimizerOptions object
  78082. */
  78083. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78084. /**
  78085. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78086. * @param targetFrameRate defines the target frame rate (60 by default)
  78087. * @returns a SceneOptimizerOptions object
  78088. */
  78089. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78090. }
  78091. /**
  78092. * Class used to run optimizations in order to reach a target frame rate
  78093. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78094. */
  78095. export class SceneOptimizer implements IDisposable {
  78096. private _isRunning;
  78097. private _options;
  78098. private _scene;
  78099. private _currentPriorityLevel;
  78100. private _targetFrameRate;
  78101. private _trackerDuration;
  78102. private _currentFrameRate;
  78103. private _sceneDisposeObserver;
  78104. private _improvementMode;
  78105. /**
  78106. * Defines an observable called when the optimizer reaches the target frame rate
  78107. */
  78108. onSuccessObservable: Observable<SceneOptimizer>;
  78109. /**
  78110. * Defines an observable called when the optimizer enables an optimization
  78111. */
  78112. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78113. /**
  78114. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78115. */
  78116. onFailureObservable: Observable<SceneOptimizer>;
  78117. /**
  78118. * Gets a boolean indicating if the optimizer is in improvement mode
  78119. */
  78120. get isInImprovementMode(): boolean;
  78121. /**
  78122. * Gets the current priority level (0 at start)
  78123. */
  78124. get currentPriorityLevel(): number;
  78125. /**
  78126. * Gets the current frame rate checked by the SceneOptimizer
  78127. */
  78128. get currentFrameRate(): number;
  78129. /**
  78130. * Gets or sets the current target frame rate (60 by default)
  78131. */
  78132. get targetFrameRate(): number;
  78133. /**
  78134. * Gets or sets the current target frame rate (60 by default)
  78135. */
  78136. set targetFrameRate(value: number);
  78137. /**
  78138. * Gets or sets the current interval between two checks (every 2000ms by default)
  78139. */
  78140. get trackerDuration(): number;
  78141. /**
  78142. * Gets or sets the current interval between two checks (every 2000ms by default)
  78143. */
  78144. set trackerDuration(value: number);
  78145. /**
  78146. * Gets the list of active optimizations
  78147. */
  78148. get optimizations(): SceneOptimization[];
  78149. /**
  78150. * Creates a new SceneOptimizer
  78151. * @param scene defines the scene to work on
  78152. * @param options defines the options to use with the SceneOptimizer
  78153. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78154. * @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)
  78155. */
  78156. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78157. /**
  78158. * Stops the current optimizer
  78159. */
  78160. stop(): void;
  78161. /**
  78162. * Reset the optimizer to initial step (current priority level = 0)
  78163. */
  78164. reset(): void;
  78165. /**
  78166. * Start the optimizer. By default it will try to reach a specific framerate
  78167. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78168. */
  78169. start(): void;
  78170. private _checkCurrentState;
  78171. /**
  78172. * Release all resources
  78173. */
  78174. dispose(): void;
  78175. /**
  78176. * Helper function to create a SceneOptimizer with one single line of code
  78177. * @param scene defines the scene to work on
  78178. * @param options defines the options to use with the SceneOptimizer
  78179. * @param onSuccess defines a callback to call on success
  78180. * @param onFailure defines a callback to call on failure
  78181. * @returns the new SceneOptimizer object
  78182. */
  78183. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78184. }
  78185. }
  78186. declare module BABYLON {
  78187. /**
  78188. * Class used to serialize a scene into a string
  78189. */
  78190. export class SceneSerializer {
  78191. /**
  78192. * Clear cache used by a previous serialization
  78193. */
  78194. static ClearCache(): void;
  78195. /**
  78196. * Serialize a scene into a JSON compatible object
  78197. * @param scene defines the scene to serialize
  78198. * @returns a JSON compatible object
  78199. */
  78200. static Serialize(scene: Scene): any;
  78201. /**
  78202. * Serialize a mesh into a JSON compatible object
  78203. * @param toSerialize defines the mesh to serialize
  78204. * @param withParents defines if parents must be serialized as well
  78205. * @param withChildren defines if children must be serialized as well
  78206. * @returns a JSON compatible object
  78207. */
  78208. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78209. }
  78210. }
  78211. declare module BABYLON {
  78212. /**
  78213. * This represents the different options available for the video capture.
  78214. */
  78215. export interface VideoRecorderOptions {
  78216. /** Defines the mime type of the video. */
  78217. mimeType: string;
  78218. /** Defines the FPS the video should be recorded at. */
  78219. fps: number;
  78220. /** Defines the chunk size for the recording data. */
  78221. recordChunckSize: number;
  78222. /** The audio tracks to attach to the recording. */
  78223. audioTracks?: MediaStreamTrack[];
  78224. }
  78225. /**
  78226. * This can help with recording videos from BabylonJS.
  78227. * This is based on the available WebRTC functionalities of the browser.
  78228. *
  78229. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78230. */
  78231. export class VideoRecorder {
  78232. private static readonly _defaultOptions;
  78233. /**
  78234. * Returns whether or not the VideoRecorder is available in your browser.
  78235. * @param engine Defines the Babylon Engine.
  78236. * @returns true if supported otherwise false.
  78237. */
  78238. static IsSupported(engine: Engine): boolean;
  78239. private readonly _options;
  78240. private _canvas;
  78241. private _mediaRecorder;
  78242. private _recordedChunks;
  78243. private _fileName;
  78244. private _resolve;
  78245. private _reject;
  78246. /**
  78247. * True when a recording is already in progress.
  78248. */
  78249. get isRecording(): boolean;
  78250. /**
  78251. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78252. * @param engine Defines the BabylonJS Engine you wish to record.
  78253. * @param options Defines options that can be used to customize the capture.
  78254. */
  78255. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78256. /**
  78257. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78258. */
  78259. stopRecording(): void;
  78260. /**
  78261. * Starts recording the canvas for a max duration specified in parameters.
  78262. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78263. * If null no automatic download will start and you can rely on the promise to get the data back.
  78264. * @param maxDuration Defines the maximum recording time in seconds.
  78265. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78266. * @return A promise callback at the end of the recording with the video data in Blob.
  78267. */
  78268. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78269. /**
  78270. * Releases internal resources used during the recording.
  78271. */
  78272. dispose(): void;
  78273. private _handleDataAvailable;
  78274. private _handleError;
  78275. private _handleStop;
  78276. }
  78277. }
  78278. declare module BABYLON {
  78279. /**
  78280. * Class containing a set of static utilities functions for screenshots
  78281. */
  78282. export class ScreenshotTools {
  78283. /**
  78284. * Captures a screenshot of the current rendering
  78285. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78286. * @param engine defines the rendering engine
  78287. * @param camera defines the source camera
  78288. * @param size This parameter can be set to a single number or to an object with the
  78289. * following (optional) properties: precision, width, height. If a single number is passed,
  78290. * it will be used for both width and height. If an object is passed, the screenshot size
  78291. * will be derived from the parameters. The precision property is a multiplier allowing
  78292. * rendering at a higher or lower resolution
  78293. * @param successCallback defines the callback receives a single parameter which contains the
  78294. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78295. * src parameter of an <img> to display it
  78296. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78297. * Check your browser for supported MIME types
  78298. */
  78299. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  78300. /**
  78301. * Captures a screenshot of the current rendering
  78302. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78303. * @param engine defines the rendering engine
  78304. * @param camera defines the source camera
  78305. * @param size This parameter can be set to a single number or to an object with the
  78306. * following (optional) properties: precision, width, height. If a single number is passed,
  78307. * it will be used for both width and height. If an object is passed, the screenshot size
  78308. * will be derived from the parameters. The precision property is a multiplier allowing
  78309. * rendering at a higher or lower resolution
  78310. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78311. * Check your browser for supported MIME types
  78312. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78313. * to the src parameter of an <img> to display it
  78314. */
  78315. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78316. /**
  78317. * Generates an image screenshot from the specified camera.
  78318. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78319. * @param engine The engine to use for rendering
  78320. * @param camera The camera to use for rendering
  78321. * @param size This parameter can be set to a single number or to an object with the
  78322. * following (optional) properties: precision, width, height. If a single number is passed,
  78323. * it will be used for both width and height. If an object is passed, the screenshot size
  78324. * will be derived from the parameters. The precision property is a multiplier allowing
  78325. * rendering at a higher or lower resolution
  78326. * @param successCallback The callback receives a single parameter which contains the
  78327. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78328. * src parameter of an <img> to display it
  78329. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78330. * Check your browser for supported MIME types
  78331. * @param samples Texture samples (default: 1)
  78332. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78333. * @param fileName A name for for the downloaded file.
  78334. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78335. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78336. */
  78337. 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;
  78338. /**
  78339. * Generates an image screenshot from the specified camera.
  78340. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78341. * @param engine The engine to use for rendering
  78342. * @param camera The camera to use for rendering
  78343. * @param size This parameter can be set to a single number or to an object with the
  78344. * following (optional) properties: precision, width, height. If a single number is passed,
  78345. * it will be used for both width and height. If an object is passed, the screenshot size
  78346. * will be derived from the parameters. The precision property is a multiplier allowing
  78347. * rendering at a higher or lower resolution
  78348. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78349. * Check your browser for supported MIME types
  78350. * @param samples Texture samples (default: 1)
  78351. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78352. * @param fileName A name for for the downloaded file.
  78353. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78354. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78355. * to the src parameter of an <img> to display it
  78356. */
  78357. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78358. /**
  78359. * Gets height and width for screenshot size
  78360. * @private
  78361. */
  78362. private static _getScreenshotSize;
  78363. }
  78364. }
  78365. declare module BABYLON {
  78366. /**
  78367. * Interface for a data buffer
  78368. */
  78369. export interface IDataBuffer {
  78370. /**
  78371. * Reads bytes from the data buffer.
  78372. * @param byteOffset The byte offset to read
  78373. * @param byteLength The byte length to read
  78374. * @returns A promise that resolves when the bytes are read
  78375. */
  78376. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78377. /**
  78378. * The byte length of the buffer.
  78379. */
  78380. readonly byteLength: number;
  78381. }
  78382. /**
  78383. * Utility class for reading from a data buffer
  78384. */
  78385. export class DataReader {
  78386. /**
  78387. * The data buffer associated with this data reader.
  78388. */
  78389. readonly buffer: IDataBuffer;
  78390. /**
  78391. * The current byte offset from the beginning of the data buffer.
  78392. */
  78393. byteOffset: number;
  78394. private _dataView;
  78395. private _dataByteOffset;
  78396. /**
  78397. * Constructor
  78398. * @param buffer The buffer to read
  78399. */
  78400. constructor(buffer: IDataBuffer);
  78401. /**
  78402. * Loads the given byte length.
  78403. * @param byteLength The byte length to load
  78404. * @returns A promise that resolves when the load is complete
  78405. */
  78406. loadAsync(byteLength: number): Promise<void>;
  78407. /**
  78408. * Read a unsigned 32-bit integer from the currently loaded data range.
  78409. * @returns The 32-bit integer read
  78410. */
  78411. readUint32(): number;
  78412. /**
  78413. * Read a byte array from the currently loaded data range.
  78414. * @param byteLength The byte length to read
  78415. * @returns The byte array read
  78416. */
  78417. readUint8Array(byteLength: number): Uint8Array;
  78418. /**
  78419. * Read a string from the currently loaded data range.
  78420. * @param byteLength The byte length to read
  78421. * @returns The string read
  78422. */
  78423. readString(byteLength: number): string;
  78424. /**
  78425. * Skips the given byte length the currently loaded data range.
  78426. * @param byteLength The byte length to skip
  78427. */
  78428. skipBytes(byteLength: number): void;
  78429. }
  78430. }
  78431. declare module BABYLON {
  78432. /**
  78433. * Class for storing data to local storage if available or in-memory storage otherwise
  78434. */
  78435. export class DataStorage {
  78436. private static _Storage;
  78437. private static _GetStorage;
  78438. /**
  78439. * Reads a string from the data storage
  78440. * @param key The key to read
  78441. * @param defaultValue The value if the key doesn't exist
  78442. * @returns The string value
  78443. */
  78444. static ReadString(key: string, defaultValue: string): string;
  78445. /**
  78446. * Writes a string to the data storage
  78447. * @param key The key to write
  78448. * @param value The value to write
  78449. */
  78450. static WriteString(key: string, value: string): void;
  78451. /**
  78452. * Reads a boolean from the data storage
  78453. * @param key The key to read
  78454. * @param defaultValue The value if the key doesn't exist
  78455. * @returns The boolean value
  78456. */
  78457. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  78458. /**
  78459. * Writes a boolean to the data storage
  78460. * @param key The key to write
  78461. * @param value The value to write
  78462. */
  78463. static WriteBoolean(key: string, value: boolean): void;
  78464. /**
  78465. * Reads a number from the data storage
  78466. * @param key The key to read
  78467. * @param defaultValue The value if the key doesn't exist
  78468. * @returns The number value
  78469. */
  78470. static ReadNumber(key: string, defaultValue: number): number;
  78471. /**
  78472. * Writes a number to the data storage
  78473. * @param key The key to write
  78474. * @param value The value to write
  78475. */
  78476. static WriteNumber(key: string, value: number): void;
  78477. }
  78478. }
  78479. declare module BABYLON {
  78480. /**
  78481. * Class used to record delta files between 2 scene states
  78482. */
  78483. export class SceneRecorder {
  78484. private _trackedScene;
  78485. private _savedJSON;
  78486. /**
  78487. * Track a given scene. This means the current scene state will be considered the original state
  78488. * @param scene defines the scene to track
  78489. */
  78490. track(scene: Scene): void;
  78491. /**
  78492. * Get the delta between current state and original state
  78493. * @returns a string containing the delta
  78494. */
  78495. getDelta(): any;
  78496. private _compareArray;
  78497. private _compareObjects;
  78498. private _compareCollections;
  78499. private static GetShadowGeneratorById;
  78500. /**
  78501. * Apply a given delta to a given scene
  78502. * @param deltaJSON defines the JSON containing the delta
  78503. * @param scene defines the scene to apply the delta to
  78504. */
  78505. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  78506. private static _ApplyPropertiesToEntity;
  78507. private static _ApplyDeltaForEntity;
  78508. }
  78509. }
  78510. declare module BABYLON {
  78511. /**
  78512. * A 3D trajectory consisting of an order list of vectors describing a
  78513. * path of motion through 3D space.
  78514. */
  78515. export class Trajectory {
  78516. private _points;
  78517. private readonly _segmentLength;
  78518. /**
  78519. * Serialize to JSON.
  78520. * @returns serialized JSON string
  78521. */
  78522. serialize(): string;
  78523. /**
  78524. * Deserialize from JSON.
  78525. * @param json serialized JSON string
  78526. * @returns deserialized Trajectory
  78527. */
  78528. static Deserialize(json: string): Trajectory;
  78529. /**
  78530. * Create a new empty Trajectory.
  78531. * @param segmentLength radius of discretization for Trajectory points
  78532. */
  78533. constructor(segmentLength?: number);
  78534. /**
  78535. * Get the length of the Trajectory.
  78536. * @returns length of the Trajectory
  78537. */
  78538. getLength(): number;
  78539. /**
  78540. * Append a new point to the Trajectory.
  78541. * NOTE: This implementation has many allocations.
  78542. * @param point point to append to the Trajectory
  78543. */
  78544. add(point: DeepImmutable<Vector3>): void;
  78545. /**
  78546. * Create a new Trajectory with a segment length chosen to make it
  78547. * probable that the new Trajectory will have a specified number of
  78548. * segments. This operation is imprecise.
  78549. * @param targetResolution number of segments desired
  78550. * @returns new Trajectory with approximately the requested number of segments
  78551. */
  78552. resampleAtTargetResolution(targetResolution: number): Trajectory;
  78553. /**
  78554. * Convert Trajectory segments into tokenized representation. This
  78555. * representation is an array of numbers where each nth number is the
  78556. * index of the token which is most similar to the nth segment of the
  78557. * Trajectory.
  78558. * @param tokens list of vectors which serve as discrete tokens
  78559. * @returns list of indices of most similar token per segment
  78560. */
  78561. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  78562. private static _forwardDir;
  78563. private static _inverseFromVec;
  78564. private static _upDir;
  78565. private static _fromToVec;
  78566. private static _lookMatrix;
  78567. /**
  78568. * Transform the rotation (i.e., direction) of a segment to isolate
  78569. * the relative transformation represented by the segment. This operation
  78570. * may or may not succeed due to singularities in the equations that define
  78571. * motion relativity in this context.
  78572. * @param priorVec the origin of the prior segment
  78573. * @param fromVec the origin of the current segment
  78574. * @param toVec the destination of the current segment
  78575. * @param result reference to output variable
  78576. * @returns whether or not transformation was successful
  78577. */
  78578. private static _transformSegmentDirToRef;
  78579. private static _bestMatch;
  78580. private static _score;
  78581. private static _bestScore;
  78582. /**
  78583. * Determine which token vector is most similar to the
  78584. * segment vector.
  78585. * @param segment segment vector
  78586. * @param tokens token vector list
  78587. * @returns index of the most similar token to the segment
  78588. */
  78589. private static _tokenizeSegment;
  78590. }
  78591. /**
  78592. * Class representing a set of known, named trajectories to which Trajectories can be
  78593. * added and using which Trajectories can be recognized.
  78594. */
  78595. export class TrajectoryClassifier {
  78596. private _maximumAllowableMatchCost;
  78597. private _vector3Alphabet;
  78598. private _levenshteinAlphabet;
  78599. private _nameToDescribedTrajectory;
  78600. /**
  78601. * Serialize to JSON.
  78602. * @returns JSON serialization
  78603. */
  78604. serialize(): string;
  78605. /**
  78606. * Deserialize from JSON.
  78607. * @param json JSON serialization
  78608. * @returns deserialized TrajectorySet
  78609. */
  78610. static Deserialize(json: string): TrajectoryClassifier;
  78611. /**
  78612. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  78613. * VERY naive, need to be generating these things from known
  78614. * sets. Better version later, probably eliminating this one.
  78615. * @returns auto-generated TrajectorySet
  78616. */
  78617. static Generate(): TrajectoryClassifier;
  78618. private constructor();
  78619. /**
  78620. * Add a new Trajectory to the set with a given name.
  78621. * @param trajectory new Trajectory to be added
  78622. * @param classification name to which to add the Trajectory
  78623. */
  78624. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  78625. /**
  78626. * Remove a known named trajectory and all Trajectories associated with it.
  78627. * @param classification name to remove
  78628. * @returns whether anything was removed
  78629. */
  78630. deleteClassification(classification: string): boolean;
  78631. /**
  78632. * Attempt to recognize a Trajectory from among all the classifications
  78633. * already known to the classifier.
  78634. * @param trajectory Trajectory to be recognized
  78635. * @returns classification of Trajectory if recognized, null otherwise
  78636. */
  78637. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  78638. }
  78639. }
  78640. declare module BABYLON {
  78641. /**
  78642. * An interface for all Hit test features
  78643. */
  78644. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  78645. /**
  78646. * Triggered when new babylon (transformed) hit test results are available
  78647. */
  78648. onHitTestResultObservable: Observable<T[]>;
  78649. }
  78650. /**
  78651. * Options used for hit testing
  78652. */
  78653. export interface IWebXRLegacyHitTestOptions {
  78654. /**
  78655. * Only test when user interacted with the scene. Default - hit test every frame
  78656. */
  78657. testOnPointerDownOnly?: boolean;
  78658. /**
  78659. * The node to use to transform the local results to world coordinates
  78660. */
  78661. worldParentNode?: TransformNode;
  78662. }
  78663. /**
  78664. * Interface defining the babylon result of raycasting/hit-test
  78665. */
  78666. export interface IWebXRLegacyHitResult {
  78667. /**
  78668. * Transformation matrix that can be applied to a node that will put it in the hit point location
  78669. */
  78670. transformationMatrix: Matrix;
  78671. /**
  78672. * The native hit test result
  78673. */
  78674. xrHitResult: XRHitResult | XRHitTestResult;
  78675. }
  78676. /**
  78677. * The currently-working hit-test module.
  78678. * Hit test (or Ray-casting) is used to interact with the real world.
  78679. * For further information read here - https://github.com/immersive-web/hit-test
  78680. */
  78681. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  78682. /**
  78683. * options to use when constructing this feature
  78684. */
  78685. readonly options: IWebXRLegacyHitTestOptions;
  78686. private _direction;
  78687. private _mat;
  78688. private _onSelectEnabled;
  78689. private _origin;
  78690. /**
  78691. * The module's name
  78692. */
  78693. static readonly Name: string;
  78694. /**
  78695. * The (Babylon) version of this module.
  78696. * This is an integer representing the implementation version.
  78697. * This number does not correspond to the WebXR specs version
  78698. */
  78699. static readonly Version: number;
  78700. /**
  78701. * Populated with the last native XR Hit Results
  78702. */
  78703. lastNativeXRHitResults: XRHitResult[];
  78704. /**
  78705. * Triggered when new babylon (transformed) hit test results are available
  78706. */
  78707. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  78708. /**
  78709. * Creates a new instance of the (legacy version) hit test feature
  78710. * @param _xrSessionManager an instance of WebXRSessionManager
  78711. * @param options options to use when constructing this feature
  78712. */
  78713. constructor(_xrSessionManager: WebXRSessionManager,
  78714. /**
  78715. * options to use when constructing this feature
  78716. */
  78717. options?: IWebXRLegacyHitTestOptions);
  78718. /**
  78719. * execute a hit test with an XR Ray
  78720. *
  78721. * @param xrSession a native xrSession that will execute this hit test
  78722. * @param xrRay the ray (position and direction) to use for ray-casting
  78723. * @param referenceSpace native XR reference space to use for the hit-test
  78724. * @param filter filter function that will filter the results
  78725. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78726. */
  78727. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  78728. /**
  78729. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  78730. * @param event the (select) event to use to select with
  78731. * @param referenceSpace the reference space to use for this hit test
  78732. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78733. */
  78734. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  78735. /**
  78736. * attach this feature
  78737. * Will usually be called by the features manager
  78738. *
  78739. * @returns true if successful.
  78740. */
  78741. attach(): boolean;
  78742. /**
  78743. * detach this feature.
  78744. * Will usually be called by the features manager
  78745. *
  78746. * @returns true if successful.
  78747. */
  78748. detach(): boolean;
  78749. /**
  78750. * Dispose this feature and all of the resources attached
  78751. */
  78752. dispose(): void;
  78753. protected _onXRFrame(frame: XRFrame): void;
  78754. private _onHitTestResults;
  78755. private _onSelect;
  78756. }
  78757. }
  78758. declare module BABYLON {
  78759. /**
  78760. * Options used for hit testing (version 2)
  78761. */
  78762. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  78763. /**
  78764. * Do not create a permanent hit test. Will usually be used when only
  78765. * transient inputs are needed.
  78766. */
  78767. disablePermanentHitTest?: boolean;
  78768. /**
  78769. * Enable transient (for example touch-based) hit test inspections
  78770. */
  78771. enableTransientHitTest?: boolean;
  78772. /**
  78773. * Offset ray for the permanent hit test
  78774. */
  78775. offsetRay?: Vector3;
  78776. /**
  78777. * Offset ray for the transient hit test
  78778. */
  78779. transientOffsetRay?: Vector3;
  78780. /**
  78781. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  78782. */
  78783. useReferenceSpace?: boolean;
  78784. /**
  78785. * Override the default entity type(s) of the hit-test result
  78786. */
  78787. entityTypes?: XRHitTestTrackableType[];
  78788. }
  78789. /**
  78790. * Interface defining the babylon result of hit-test
  78791. */
  78792. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  78793. /**
  78794. * The input source that generated this hit test (if transient)
  78795. */
  78796. inputSource?: XRInputSource;
  78797. /**
  78798. * Is this a transient hit test
  78799. */
  78800. isTransient?: boolean;
  78801. /**
  78802. * Position of the hit test result
  78803. */
  78804. position: Vector3;
  78805. /**
  78806. * Rotation of the hit test result
  78807. */
  78808. rotationQuaternion: Quaternion;
  78809. /**
  78810. * The native hit test result
  78811. */
  78812. xrHitResult: XRHitTestResult;
  78813. }
  78814. /**
  78815. * The currently-working hit-test module.
  78816. * Hit test (or Ray-casting) is used to interact with the real world.
  78817. * For further information read here - https://github.com/immersive-web/hit-test
  78818. *
  78819. * Tested on chrome (mobile) 80.
  78820. */
  78821. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  78822. /**
  78823. * options to use when constructing this feature
  78824. */
  78825. readonly options: IWebXRHitTestOptions;
  78826. private _tmpMat;
  78827. private _tmpPos;
  78828. private _tmpQuat;
  78829. private _transientXrHitTestSource;
  78830. private _xrHitTestSource;
  78831. private initHitTestSource;
  78832. /**
  78833. * The module's name
  78834. */
  78835. static readonly Name: string;
  78836. /**
  78837. * The (Babylon) version of this module.
  78838. * This is an integer representing the implementation version.
  78839. * This number does not correspond to the WebXR specs version
  78840. */
  78841. static readonly Version: number;
  78842. /**
  78843. * When set to true, each hit test will have its own position/rotation objects
  78844. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  78845. * the developers will clone them or copy them as they see fit.
  78846. */
  78847. autoCloneTransformation: boolean;
  78848. /**
  78849. * Triggered when new babylon (transformed) hit test results are available
  78850. * Note - this will be called when results come back from the device. It can be an empty array!!
  78851. */
  78852. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  78853. /**
  78854. * Use this to temporarily pause hit test checks.
  78855. */
  78856. paused: boolean;
  78857. /**
  78858. * Creates a new instance of the hit test feature
  78859. * @param _xrSessionManager an instance of WebXRSessionManager
  78860. * @param options options to use when constructing this feature
  78861. */
  78862. constructor(_xrSessionManager: WebXRSessionManager,
  78863. /**
  78864. * options to use when constructing this feature
  78865. */
  78866. options?: IWebXRHitTestOptions);
  78867. /**
  78868. * attach this feature
  78869. * Will usually be called by the features manager
  78870. *
  78871. * @returns true if successful.
  78872. */
  78873. attach(): boolean;
  78874. /**
  78875. * detach this feature.
  78876. * Will usually be called by the features manager
  78877. *
  78878. * @returns true if successful.
  78879. */
  78880. detach(): boolean;
  78881. /**
  78882. * Dispose this feature and all of the resources attached
  78883. */
  78884. dispose(): void;
  78885. protected _onXRFrame(frame: XRFrame): void;
  78886. private _processWebXRHitTestResult;
  78887. }
  78888. }
  78889. declare module BABYLON {
  78890. /**
  78891. * Configuration options of the anchor system
  78892. */
  78893. export interface IWebXRAnchorSystemOptions {
  78894. /**
  78895. * a node that will be used to convert local to world coordinates
  78896. */
  78897. worldParentNode?: TransformNode;
  78898. /**
  78899. * If set to true a reference of the created anchors will be kept until the next session starts
  78900. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  78901. */
  78902. doNotRemoveAnchorsOnSessionEnded?: boolean;
  78903. }
  78904. /**
  78905. * A babylon container for an XR Anchor
  78906. */
  78907. export interface IWebXRAnchor {
  78908. /**
  78909. * A babylon-assigned ID for this anchor
  78910. */
  78911. id: number;
  78912. /**
  78913. * Transformation matrix to apply to an object attached to this anchor
  78914. */
  78915. transformationMatrix: Matrix;
  78916. /**
  78917. * The native anchor object
  78918. */
  78919. xrAnchor: XRAnchor;
  78920. /**
  78921. * if defined, this object will be constantly updated by the anchor's position and rotation
  78922. */
  78923. attachedNode?: TransformNode;
  78924. /**
  78925. * Remove this anchor from the scene
  78926. */
  78927. remove(): void;
  78928. }
  78929. /**
  78930. * An implementation of the anchor system for WebXR.
  78931. * For further information see https://github.com/immersive-web/anchors/
  78932. */
  78933. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  78934. private _options;
  78935. private _lastFrameDetected;
  78936. private _trackedAnchors;
  78937. private _referenceSpaceForFrameAnchors;
  78938. private _futureAnchors;
  78939. /**
  78940. * The module's name
  78941. */
  78942. static readonly Name: string;
  78943. /**
  78944. * The (Babylon) version of this module.
  78945. * This is an integer representing the implementation version.
  78946. * This number does not correspond to the WebXR specs version
  78947. */
  78948. static readonly Version: number;
  78949. /**
  78950. * Observers registered here will be executed when a new anchor was added to the session
  78951. */
  78952. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  78953. /**
  78954. * Observers registered here will be executed when an anchor was removed from the session
  78955. */
  78956. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  78957. /**
  78958. * Observers registered here will be executed when an existing anchor updates
  78959. * This can execute N times every frame
  78960. */
  78961. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  78962. /**
  78963. * Set the reference space to use for anchor creation, when not using a hit test.
  78964. * Will default to the session's reference space if not defined
  78965. */
  78966. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  78967. /**
  78968. * constructs a new anchor system
  78969. * @param _xrSessionManager an instance of WebXRSessionManager
  78970. * @param _options configuration object for this feature
  78971. */
  78972. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  78973. private _tmpVector;
  78974. private _tmpQuaternion;
  78975. private _populateTmpTransformation;
  78976. /**
  78977. * Create a new anchor point using a hit test result at a specific point in the scene
  78978. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78979. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78980. *
  78981. * @param hitTestResult The hit test result to use for this anchor creation
  78982. * @param position an optional position offset for this anchor
  78983. * @param rotationQuaternion an optional rotation offset for this anchor
  78984. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  78985. */
  78986. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  78987. /**
  78988. * Add a new anchor at a specific position and rotation
  78989. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  78990. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  78991. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78992. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78993. *
  78994. * @param position the position in which to add an anchor
  78995. * @param rotationQuaternion an optional rotation for the anchor transformation
  78996. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  78997. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  78998. */
  78999. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  79000. /**
  79001. * Get the list of anchors currently being tracked by the system
  79002. */
  79003. get anchors(): IWebXRAnchor[];
  79004. /**
  79005. * detach this feature.
  79006. * Will usually be called by the features manager
  79007. *
  79008. * @returns true if successful.
  79009. */
  79010. detach(): boolean;
  79011. /**
  79012. * Dispose this feature and all of the resources attached
  79013. */
  79014. dispose(): void;
  79015. protected _onXRFrame(frame: XRFrame): void;
  79016. /**
  79017. * avoiding using Array.find for global support.
  79018. * @param xrAnchor the plane to find in the array
  79019. */
  79020. private _findIndexInAnchorArray;
  79021. private _updateAnchorWithXRFrame;
  79022. private _createAnchorAtTransformation;
  79023. }
  79024. }
  79025. declare module BABYLON {
  79026. /**
  79027. * Options used in the plane detector module
  79028. */
  79029. export interface IWebXRPlaneDetectorOptions {
  79030. /**
  79031. * The node to use to transform the local results to world coordinates
  79032. */
  79033. worldParentNode?: TransformNode;
  79034. /**
  79035. * If set to true a reference of the created planes will be kept until the next session starts
  79036. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79037. */
  79038. doNotRemovePlanesOnSessionEnded?: boolean;
  79039. /**
  79040. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  79041. */
  79042. preferredDetectorOptions?: XRGeometryDetectorOptions;
  79043. }
  79044. /**
  79045. * A babylon interface for a WebXR plane.
  79046. * A Plane is actually a polygon, built from N points in space
  79047. *
  79048. * Supported in chrome 79, not supported in canary 81 ATM
  79049. */
  79050. export interface IWebXRPlane {
  79051. /**
  79052. * a babylon-assigned ID for this polygon
  79053. */
  79054. id: number;
  79055. /**
  79056. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79057. */
  79058. polygonDefinition: Array<Vector3>;
  79059. /**
  79060. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79061. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79062. */
  79063. transformationMatrix: Matrix;
  79064. /**
  79065. * the native xr-plane object
  79066. */
  79067. xrPlane: XRPlane;
  79068. }
  79069. /**
  79070. * The plane detector is used to detect planes in the real world when in AR
  79071. * For more information see https://github.com/immersive-web/real-world-geometry/
  79072. */
  79073. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79074. private _options;
  79075. private _detectedPlanes;
  79076. private _enabled;
  79077. private _lastFrameDetected;
  79078. /**
  79079. * The module's name
  79080. */
  79081. static readonly Name: string;
  79082. /**
  79083. * The (Babylon) version of this module.
  79084. * This is an integer representing the implementation version.
  79085. * This number does not correspond to the WebXR specs version
  79086. */
  79087. static readonly Version: number;
  79088. /**
  79089. * Observers registered here will be executed when a new plane was added to the session
  79090. */
  79091. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79092. /**
  79093. * Observers registered here will be executed when a plane is no longer detected in the session
  79094. */
  79095. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79096. /**
  79097. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79098. * This can execute N times every frame
  79099. */
  79100. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79101. /**
  79102. * construct a new Plane Detector
  79103. * @param _xrSessionManager an instance of xr Session manager
  79104. * @param _options configuration to use when constructing this feature
  79105. */
  79106. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79107. /**
  79108. * detach this feature.
  79109. * Will usually be called by the features manager
  79110. *
  79111. * @returns true if successful.
  79112. */
  79113. detach(): boolean;
  79114. /**
  79115. * Dispose this feature and all of the resources attached
  79116. */
  79117. dispose(): void;
  79118. /**
  79119. * Check if the needed objects are defined.
  79120. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79121. */
  79122. isCompatible(): boolean;
  79123. protected _onXRFrame(frame: XRFrame): void;
  79124. private _init;
  79125. private _updatePlaneWithXRPlane;
  79126. /**
  79127. * avoiding using Array.find for global support.
  79128. * @param xrPlane the plane to find in the array
  79129. */
  79130. private _findIndexInPlaneArray;
  79131. }
  79132. }
  79133. declare module BABYLON {
  79134. /**
  79135. * Options interface for the background remover plugin
  79136. */
  79137. export interface IWebXRBackgroundRemoverOptions {
  79138. /**
  79139. * Further background meshes to disable when entering AR
  79140. */
  79141. backgroundMeshes?: AbstractMesh[];
  79142. /**
  79143. * flags to configure the removal of the environment helper.
  79144. * If not set, the entire background will be removed. If set, flags should be set as well.
  79145. */
  79146. environmentHelperRemovalFlags?: {
  79147. /**
  79148. * Should the skybox be removed (default false)
  79149. */
  79150. skyBox?: boolean;
  79151. /**
  79152. * Should the ground be removed (default false)
  79153. */
  79154. ground?: boolean;
  79155. };
  79156. /**
  79157. * don't disable the environment helper
  79158. */
  79159. ignoreEnvironmentHelper?: boolean;
  79160. }
  79161. /**
  79162. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79163. */
  79164. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79165. /**
  79166. * read-only options to be used in this module
  79167. */
  79168. readonly options: IWebXRBackgroundRemoverOptions;
  79169. /**
  79170. * The module's name
  79171. */
  79172. static readonly Name: string;
  79173. /**
  79174. * The (Babylon) version of this module.
  79175. * This is an integer representing the implementation version.
  79176. * This number does not correspond to the WebXR specs version
  79177. */
  79178. static readonly Version: number;
  79179. /**
  79180. * registered observers will be triggered when the background state changes
  79181. */
  79182. onBackgroundStateChangedObservable: Observable<boolean>;
  79183. /**
  79184. * constructs a new background remover module
  79185. * @param _xrSessionManager the session manager for this module
  79186. * @param options read-only options to be used in this module
  79187. */
  79188. constructor(_xrSessionManager: WebXRSessionManager,
  79189. /**
  79190. * read-only options to be used in this module
  79191. */
  79192. options?: IWebXRBackgroundRemoverOptions);
  79193. /**
  79194. * attach this feature
  79195. * Will usually be called by the features manager
  79196. *
  79197. * @returns true if successful.
  79198. */
  79199. attach(): boolean;
  79200. /**
  79201. * detach this feature.
  79202. * Will usually be called by the features manager
  79203. *
  79204. * @returns true if successful.
  79205. */
  79206. detach(): boolean;
  79207. /**
  79208. * Dispose this feature and all of the resources attached
  79209. */
  79210. dispose(): void;
  79211. protected _onXRFrame(_xrFrame: XRFrame): void;
  79212. private _setBackgroundState;
  79213. }
  79214. }
  79215. declare module BABYLON {
  79216. /**
  79217. * Options for the controller physics feature
  79218. */
  79219. export class IWebXRControllerPhysicsOptions {
  79220. /**
  79221. * Should the headset get its own impostor
  79222. */
  79223. enableHeadsetImpostor?: boolean;
  79224. /**
  79225. * Optional parameters for the headset impostor
  79226. */
  79227. headsetImpostorParams?: {
  79228. /**
  79229. * The type of impostor to create. Default is sphere
  79230. */
  79231. impostorType: number;
  79232. /**
  79233. * the size of the impostor. Defaults to 10cm
  79234. */
  79235. impostorSize?: number | {
  79236. width: number;
  79237. height: number;
  79238. depth: number;
  79239. };
  79240. /**
  79241. * Friction definitions
  79242. */
  79243. friction?: number;
  79244. /**
  79245. * Restitution
  79246. */
  79247. restitution?: number;
  79248. };
  79249. /**
  79250. * The physics properties of the future impostors
  79251. */
  79252. physicsProperties?: {
  79253. /**
  79254. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79255. * Note that this requires a physics engine that supports mesh impostors!
  79256. */
  79257. useControllerMesh?: boolean;
  79258. /**
  79259. * The type of impostor to create. Default is sphere
  79260. */
  79261. impostorType?: number;
  79262. /**
  79263. * the size of the impostor. Defaults to 10cm
  79264. */
  79265. impostorSize?: number | {
  79266. width: number;
  79267. height: number;
  79268. depth: number;
  79269. };
  79270. /**
  79271. * Friction definitions
  79272. */
  79273. friction?: number;
  79274. /**
  79275. * Restitution
  79276. */
  79277. restitution?: number;
  79278. };
  79279. /**
  79280. * the xr input to use with this pointer selection
  79281. */
  79282. xrInput: WebXRInput;
  79283. }
  79284. /**
  79285. * Add physics impostor to your webxr controllers,
  79286. * including naive calculation of their linear and angular velocity
  79287. */
  79288. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79289. private readonly _options;
  79290. private _attachController;
  79291. private _controllers;
  79292. private _debugMode;
  79293. private _delta;
  79294. private _headsetImpostor?;
  79295. private _headsetMesh?;
  79296. private _lastTimestamp;
  79297. private _tmpQuaternion;
  79298. private _tmpVector;
  79299. /**
  79300. * The module's name
  79301. */
  79302. static readonly Name: string;
  79303. /**
  79304. * The (Babylon) version of this module.
  79305. * This is an integer representing the implementation version.
  79306. * This number does not correspond to the webxr specs version
  79307. */
  79308. static readonly Version: number;
  79309. /**
  79310. * Construct a new Controller Physics Feature
  79311. * @param _xrSessionManager the corresponding xr session manager
  79312. * @param _options options to create this feature with
  79313. */
  79314. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  79315. /**
  79316. * @hidden
  79317. * enable debugging - will show console outputs and the impostor mesh
  79318. */
  79319. _enablePhysicsDebug(): void;
  79320. /**
  79321. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  79322. * @param xrController the controller to add
  79323. */
  79324. addController(xrController: WebXRInputSource): void;
  79325. /**
  79326. * attach this feature
  79327. * Will usually be called by the features manager
  79328. *
  79329. * @returns true if successful.
  79330. */
  79331. attach(): boolean;
  79332. /**
  79333. * detach this feature.
  79334. * Will usually be called by the features manager
  79335. *
  79336. * @returns true if successful.
  79337. */
  79338. detach(): boolean;
  79339. /**
  79340. * Get the headset impostor, if enabled
  79341. * @returns the impostor
  79342. */
  79343. getHeadsetImpostor(): PhysicsImpostor | undefined;
  79344. /**
  79345. * Get the physics impostor of a specific controller.
  79346. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  79347. * @param controller the controller or the controller id of which to get the impostor
  79348. * @returns the impostor or null
  79349. */
  79350. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  79351. /**
  79352. * Update the physics properties provided in the constructor
  79353. * @param newProperties the new properties object
  79354. */
  79355. setPhysicsProperties(newProperties: {
  79356. impostorType?: number;
  79357. impostorSize?: number | {
  79358. width: number;
  79359. height: number;
  79360. depth: number;
  79361. };
  79362. friction?: number;
  79363. restitution?: number;
  79364. }): void;
  79365. protected _onXRFrame(_xrFrame: any): void;
  79366. private _detachController;
  79367. }
  79368. }
  79369. declare module BABYLON {
  79370. /**
  79371. * A babylon interface for a "WebXR" feature point.
  79372. * Represents the position and confidence value of a given feature point.
  79373. */
  79374. export interface IWebXRFeaturePoint {
  79375. /**
  79376. * Represents the position of the feature point in world space.
  79377. */
  79378. position: Vector3;
  79379. /**
  79380. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  79381. */
  79382. confidenceValue: number;
  79383. }
  79384. /**
  79385. * The feature point system is used to detect feature points from real world geometry.
  79386. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  79387. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  79388. */
  79389. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  79390. private _enabled;
  79391. private _featurePointCloud;
  79392. /**
  79393. * The module's name
  79394. */
  79395. static readonly Name: string;
  79396. /**
  79397. * The (Babylon) version of this module.
  79398. * This is an integer representing the implementation version.
  79399. * This number does not correspond to the WebXR specs version
  79400. */
  79401. static readonly Version: number;
  79402. /**
  79403. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  79404. * Will notify the observers about which feature points have been added.
  79405. */
  79406. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  79407. /**
  79408. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  79409. * Will notify the observers about which feature points have been updated.
  79410. */
  79411. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  79412. /**
  79413. * The current feature point cloud maintained across frames.
  79414. */
  79415. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  79416. /**
  79417. * construct the feature point system
  79418. * @param _xrSessionManager an instance of xr Session manager
  79419. */
  79420. constructor(_xrSessionManager: WebXRSessionManager);
  79421. /**
  79422. * Detach this feature.
  79423. * Will usually be called by the features manager
  79424. *
  79425. * @returns true if successful.
  79426. */
  79427. detach(): boolean;
  79428. /**
  79429. * Dispose this feature and all of the resources attached
  79430. */
  79431. dispose(): void;
  79432. /**
  79433. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  79434. */
  79435. protected _onXRFrame(frame: XRFrame): void;
  79436. /**
  79437. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  79438. */
  79439. private _init;
  79440. }
  79441. }
  79442. declare module BABYLON {
  79443. /**
  79444. * Configuration interface for the hand tracking feature
  79445. */
  79446. export interface IWebXRHandTrackingOptions {
  79447. /**
  79448. * The xrInput that will be used as source for new hands
  79449. */
  79450. xrInput: WebXRInput;
  79451. /**
  79452. * Configuration object for the joint meshes
  79453. */
  79454. jointMeshes?: {
  79455. /**
  79456. * Should the meshes created be invisible (defaults to false)
  79457. */
  79458. invisible?: boolean;
  79459. /**
  79460. * A source mesh to be used to create instances. Defaults to a sphere.
  79461. * This mesh will be the source for all other (25) meshes.
  79462. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  79463. */
  79464. sourceMesh?: Mesh;
  79465. /**
  79466. * This function will be called after a mesh was created for a specific joint.
  79467. * Using this function you can either manipulate the instance or return a new mesh.
  79468. * When returning a new mesh the instance created before will be disposed
  79469. */
  79470. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  79471. /**
  79472. * Should the source mesh stay visible. Defaults to false
  79473. */
  79474. keepOriginalVisible?: boolean;
  79475. /**
  79476. * Scale factor for all instances (defaults to 2)
  79477. */
  79478. scaleFactor?: number;
  79479. /**
  79480. * Should each instance have its own physics impostor
  79481. */
  79482. enablePhysics?: boolean;
  79483. /**
  79484. * If enabled, override default physics properties
  79485. */
  79486. physicsProps?: {
  79487. friction?: number;
  79488. restitution?: number;
  79489. impostorType?: number;
  79490. };
  79491. /**
  79492. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  79493. */
  79494. disableDefaultHandMesh?: boolean;
  79495. /**
  79496. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  79497. */
  79498. handMeshes?: {
  79499. right: AbstractMesh;
  79500. left: AbstractMesh;
  79501. };
  79502. /**
  79503. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  79504. */
  79505. rigMapping?: {
  79506. right: string[];
  79507. left: string[];
  79508. };
  79509. };
  79510. }
  79511. /**
  79512. * Parts of the hands divided to writs and finger names
  79513. */
  79514. export const enum HandPart {
  79515. /**
  79516. * HandPart - Wrist
  79517. */
  79518. WRIST = "wrist",
  79519. /**
  79520. * HandPart - The THumb
  79521. */
  79522. THUMB = "thumb",
  79523. /**
  79524. * HandPart - Index finger
  79525. */
  79526. INDEX = "index",
  79527. /**
  79528. * HandPart - Middle finger
  79529. */
  79530. MIDDLE = "middle",
  79531. /**
  79532. * HandPart - Ring finger
  79533. */
  79534. RING = "ring",
  79535. /**
  79536. * HandPart - Little finger
  79537. */
  79538. LITTLE = "little"
  79539. }
  79540. /**
  79541. * Representing a single hand (with its corresponding native XRHand object)
  79542. */
  79543. export class WebXRHand implements IDisposable {
  79544. /** the controller to which the hand correlates */
  79545. readonly xrController: WebXRInputSource;
  79546. /** the meshes to be used to track the hand joints */
  79547. readonly trackedMeshes: AbstractMesh[];
  79548. private _handMesh?;
  79549. private _rigMapping?;
  79550. private _scene;
  79551. private _defaultHandMesh;
  79552. private _transformNodeMapping;
  79553. /**
  79554. * Hand-parts definition (key is HandPart)
  79555. */
  79556. handPartsDefinition: {
  79557. [key: string]: number[];
  79558. };
  79559. /**
  79560. * Observers will be triggered when the mesh for this hand was initialized.
  79561. */
  79562. onHandMeshReadyObservable: Observable<WebXRHand>;
  79563. /**
  79564. * Populate the HandPartsDefinition object.
  79565. * This is called as a side effect since certain browsers don't have XRHand defined.
  79566. */
  79567. private generateHandPartsDefinition;
  79568. /**
  79569. * Construct a new hand object
  79570. * @param xrController the controller to which the hand correlates
  79571. * @param trackedMeshes the meshes to be used to track the hand joints
  79572. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  79573. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  79574. * @param disableDefaultHandMesh should the default mesh creation be disabled
  79575. */
  79576. constructor(
  79577. /** the controller to which the hand correlates */
  79578. xrController: WebXRInputSource,
  79579. /** the meshes to be used to track the hand joints */
  79580. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean);
  79581. /**
  79582. * Get the hand mesh. It is possible that the hand mesh is not yet ready!
  79583. */
  79584. get handMesh(): AbstractMesh | undefined;
  79585. /**
  79586. * Update this hand from the latest xr frame
  79587. * @param xrFrame xrFrame to update from
  79588. * @param referenceSpace The current viewer reference space
  79589. * @param scaleFactor optional scale factor for the meshes
  79590. */
  79591. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  79592. /**
  79593. * Get meshes of part of the hand
  79594. * @param part the part of hand to get
  79595. * @returns An array of meshes that correlate to the hand part requested
  79596. */
  79597. getHandPartMeshes(part: HandPart): AbstractMesh[];
  79598. /**
  79599. * Dispose this Hand object
  79600. */
  79601. dispose(): void;
  79602. private _generateDefaultHandMesh;
  79603. }
  79604. /**
  79605. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  79606. */
  79607. export class WebXRHandTracking extends WebXRAbstractFeature {
  79608. /**
  79609. * options to use when constructing this feature
  79610. */
  79611. readonly options: IWebXRHandTrackingOptions;
  79612. private static _idCounter;
  79613. /**
  79614. * The module's name
  79615. */
  79616. static readonly Name: string;
  79617. /**
  79618. * The (Babylon) version of this module.
  79619. * This is an integer representing the implementation version.
  79620. * This number does not correspond to the WebXR specs version
  79621. */
  79622. static readonly Version: number;
  79623. /**
  79624. * This observable will notify registered observers when a new hand object was added and initialized
  79625. */
  79626. onHandAddedObservable: Observable<WebXRHand>;
  79627. /**
  79628. * This observable will notify its observers right before the hand object is disposed
  79629. */
  79630. onHandRemovedObservable: Observable<WebXRHand>;
  79631. private _hands;
  79632. /**
  79633. * Creates a new instance of the hit test feature
  79634. * @param _xrSessionManager an instance of WebXRSessionManager
  79635. * @param options options to use when constructing this feature
  79636. */
  79637. constructor(_xrSessionManager: WebXRSessionManager,
  79638. /**
  79639. * options to use when constructing this feature
  79640. */
  79641. options: IWebXRHandTrackingOptions);
  79642. /**
  79643. * Check if the needed objects are defined.
  79644. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79645. */
  79646. isCompatible(): boolean;
  79647. /**
  79648. * attach this feature
  79649. * Will usually be called by the features manager
  79650. *
  79651. * @returns true if successful.
  79652. */
  79653. attach(): boolean;
  79654. /**
  79655. * detach this feature.
  79656. * Will usually be called by the features manager
  79657. *
  79658. * @returns true if successful.
  79659. */
  79660. detach(): boolean;
  79661. /**
  79662. * Dispose this feature and all of the resources attached
  79663. */
  79664. dispose(): void;
  79665. /**
  79666. * Get the hand object according to the controller id
  79667. * @param controllerId the controller id to which we want to get the hand
  79668. * @returns null if not found or the WebXRHand object if found
  79669. */
  79670. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  79671. /**
  79672. * Get a hand object according to the requested handedness
  79673. * @param handedness the handedness to request
  79674. * @returns null if not found or the WebXRHand object if found
  79675. */
  79676. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  79677. protected _onXRFrame(_xrFrame: XRFrame): void;
  79678. private _attachHand;
  79679. private _detachHand;
  79680. }
  79681. }
  79682. declare module BABYLON {
  79683. /**
  79684. * Options used in the mesh detector module
  79685. */
  79686. export interface IWebXRMeshDetectorOptions {
  79687. /**
  79688. * The node to use to transform the local results to world coordinates
  79689. */
  79690. worldParentNode?: TransformNode;
  79691. /**
  79692. * If set to true a reference of the created meshes will be kept until the next session starts
  79693. * If not defined, meshes will be removed from the array when the feature is detached or the session ended.
  79694. */
  79695. doNotRemoveMeshesOnSessionEnded?: boolean;
  79696. /**
  79697. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  79698. */
  79699. preferredDetectorOptions?: XRGeometryDetectorOptions;
  79700. /**
  79701. * If set to true, WebXRMeshDetector will convert coordinate systems for meshes.
  79702. * If not defined, mesh conversions from right handed to left handed coordinate systems won't be conducted.
  79703. * Right handed mesh data will be available through IWebXRVertexData.xrMesh.
  79704. */
  79705. convertCoordinateSystems?: boolean;
  79706. }
  79707. /**
  79708. * A babylon interface for a XR mesh's vertex data.
  79709. *
  79710. * Currently not supported by WebXR, available only with BabylonNative
  79711. */
  79712. export interface IWebXRVertexData {
  79713. /**
  79714. * A babylon-assigned ID for this mesh
  79715. */
  79716. id: number;
  79717. /**
  79718. * Data required for constructing a mesh in Babylon.js.
  79719. */
  79720. xrMesh: XRMesh;
  79721. /**
  79722. * The node to use to transform the local results to world coordinates.
  79723. * WorldParentNode will only exist if it was declared in the IWebXRMeshDetectorOptions.
  79724. */
  79725. worldParentNode?: TransformNode;
  79726. /**
  79727. * An array of vertex positions in babylon space. right/left hand system is taken into account.
  79728. * Positions will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  79729. */
  79730. positions?: Float32Array;
  79731. /**
  79732. * An array of indices in babylon space. right/left hand system is taken into account.
  79733. * Indices will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  79734. */
  79735. indices?: Uint32Array;
  79736. /**
  79737. * An array of vertex normals in babylon space. right/left hand system is taken into account.
  79738. * Normals will not be calculated if convertCoordinateSystems is undefined in the IWebXRMeshDetectorOptions.
  79739. * Different platforms may or may not support mesh normals when convertCoordinateSystems is set to true.
  79740. */
  79741. normals?: Float32Array;
  79742. /**
  79743. * A transformation matrix to apply on the mesh that will be built using the meshDefinition.
  79744. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module.
  79745. * TransformationMatrix will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  79746. */
  79747. transformationMatrix?: Matrix;
  79748. }
  79749. /**
  79750. * The mesh detector is used to detect meshes in the real world when in AR
  79751. */
  79752. export class WebXRMeshDetector extends WebXRAbstractFeature {
  79753. private _options;
  79754. private _detectedMeshes;
  79755. /**
  79756. * The module's name
  79757. */
  79758. static readonly Name: string;
  79759. /**
  79760. * The (Babylon) version of this module.
  79761. * This is an integer representing the implementation version.
  79762. * This number does not correspond to the WebXR specs version
  79763. */
  79764. static readonly Version: number;
  79765. /**
  79766. * Observers registered here will be executed when a new mesh was added to the session
  79767. */
  79768. onMeshAddedObservable: Observable<IWebXRVertexData>;
  79769. /**
  79770. * Observers registered here will be executed when a mesh is no longer detected in the session
  79771. */
  79772. onMeshRemovedObservable: Observable<IWebXRVertexData>;
  79773. /**
  79774. * Observers registered here will be executed when an existing mesh updates
  79775. */
  79776. onMeshUpdatedObservable: Observable<IWebXRVertexData>;
  79777. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRMeshDetectorOptions);
  79778. detach(): boolean;
  79779. dispose(): void;
  79780. protected _onXRFrame(frame: XRFrame): void;
  79781. private _init;
  79782. private _updateVertexDataWithXRMesh;
  79783. }
  79784. }
  79785. declare module BABYLON {
  79786. /**
  79787. * The motion controller class for all microsoft mixed reality controllers
  79788. */
  79789. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  79790. protected readonly _mapping: {
  79791. defaultButton: {
  79792. valueNodeName: string;
  79793. unpressedNodeName: string;
  79794. pressedNodeName: string;
  79795. };
  79796. defaultAxis: {
  79797. valueNodeName: string;
  79798. minNodeName: string;
  79799. maxNodeName: string;
  79800. };
  79801. buttons: {
  79802. "xr-standard-trigger": {
  79803. rootNodeName: string;
  79804. componentProperty: string;
  79805. states: string[];
  79806. };
  79807. "xr-standard-squeeze": {
  79808. rootNodeName: string;
  79809. componentProperty: string;
  79810. states: string[];
  79811. };
  79812. "xr-standard-touchpad": {
  79813. rootNodeName: string;
  79814. labelAnchorNodeName: string;
  79815. touchPointNodeName: string;
  79816. };
  79817. "xr-standard-thumbstick": {
  79818. rootNodeName: string;
  79819. componentProperty: string;
  79820. states: string[];
  79821. };
  79822. };
  79823. axes: {
  79824. "xr-standard-touchpad": {
  79825. "x-axis": {
  79826. rootNodeName: string;
  79827. };
  79828. "y-axis": {
  79829. rootNodeName: string;
  79830. };
  79831. };
  79832. "xr-standard-thumbstick": {
  79833. "x-axis": {
  79834. rootNodeName: string;
  79835. };
  79836. "y-axis": {
  79837. rootNodeName: string;
  79838. };
  79839. };
  79840. };
  79841. };
  79842. /**
  79843. * The base url used to load the left and right controller models
  79844. */
  79845. static MODEL_BASE_URL: string;
  79846. /**
  79847. * The name of the left controller model file
  79848. */
  79849. static MODEL_LEFT_FILENAME: string;
  79850. /**
  79851. * The name of the right controller model file
  79852. */
  79853. static MODEL_RIGHT_FILENAME: string;
  79854. profileId: string;
  79855. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  79856. protected _getFilenameAndPath(): {
  79857. filename: string;
  79858. path: string;
  79859. };
  79860. protected _getModelLoadingConstraints(): boolean;
  79861. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79862. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79863. protected _updateModel(): void;
  79864. }
  79865. }
  79866. declare module BABYLON {
  79867. /**
  79868. * The motion controller class for oculus touch (quest, rift).
  79869. * This class supports legacy mapping as well the standard xr mapping
  79870. */
  79871. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  79872. private _forceLegacyControllers;
  79873. private _modelRootNode;
  79874. /**
  79875. * The base url used to load the left and right controller models
  79876. */
  79877. static MODEL_BASE_URL: string;
  79878. /**
  79879. * The name of the left controller model file
  79880. */
  79881. static MODEL_LEFT_FILENAME: string;
  79882. /**
  79883. * The name of the right controller model file
  79884. */
  79885. static MODEL_RIGHT_FILENAME: string;
  79886. /**
  79887. * Base Url for the Quest controller model.
  79888. */
  79889. static QUEST_MODEL_BASE_URL: string;
  79890. profileId: string;
  79891. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  79892. protected _getFilenameAndPath(): {
  79893. filename: string;
  79894. path: string;
  79895. };
  79896. protected _getModelLoadingConstraints(): boolean;
  79897. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79898. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79899. protected _updateModel(): void;
  79900. /**
  79901. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  79902. * between the touch and touch 2.
  79903. */
  79904. private _isQuest;
  79905. }
  79906. }
  79907. declare module BABYLON {
  79908. /**
  79909. * The motion controller class for the standard HTC-Vive controllers
  79910. */
  79911. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  79912. private _modelRootNode;
  79913. /**
  79914. * The base url used to load the left and right controller models
  79915. */
  79916. static MODEL_BASE_URL: string;
  79917. /**
  79918. * File name for the controller model.
  79919. */
  79920. static MODEL_FILENAME: string;
  79921. profileId: string;
  79922. /**
  79923. * Create a new Vive motion controller object
  79924. * @param scene the scene to use to create this controller
  79925. * @param gamepadObject the corresponding gamepad object
  79926. * @param handedness the handedness of the controller
  79927. */
  79928. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  79929. protected _getFilenameAndPath(): {
  79930. filename: string;
  79931. path: string;
  79932. };
  79933. protected _getModelLoadingConstraints(): boolean;
  79934. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79935. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79936. protected _updateModel(): void;
  79937. }
  79938. }
  79939. declare module BABYLON {
  79940. /**
  79941. * A cursor which tracks a point on a path
  79942. */
  79943. export class PathCursor {
  79944. private path;
  79945. /**
  79946. * Stores path cursor callbacks for when an onchange event is triggered
  79947. */
  79948. private _onchange;
  79949. /**
  79950. * The value of the path cursor
  79951. */
  79952. value: number;
  79953. /**
  79954. * The animation array of the path cursor
  79955. */
  79956. animations: Animation[];
  79957. /**
  79958. * Initializes the path cursor
  79959. * @param path The path to track
  79960. */
  79961. constructor(path: Path2);
  79962. /**
  79963. * Gets the cursor point on the path
  79964. * @returns A point on the path cursor at the cursor location
  79965. */
  79966. getPoint(): Vector3;
  79967. /**
  79968. * Moves the cursor ahead by the step amount
  79969. * @param step The amount to move the cursor forward
  79970. * @returns This path cursor
  79971. */
  79972. moveAhead(step?: number): PathCursor;
  79973. /**
  79974. * Moves the cursor behind by the step amount
  79975. * @param step The amount to move the cursor back
  79976. * @returns This path cursor
  79977. */
  79978. moveBack(step?: number): PathCursor;
  79979. /**
  79980. * Moves the cursor by the step amount
  79981. * If the step amount is greater than one, an exception is thrown
  79982. * @param step The amount to move the cursor
  79983. * @returns This path cursor
  79984. */
  79985. move(step: number): PathCursor;
  79986. /**
  79987. * Ensures that the value is limited between zero and one
  79988. * @returns This path cursor
  79989. */
  79990. private ensureLimits;
  79991. /**
  79992. * Runs onchange callbacks on change (used by the animation engine)
  79993. * @returns This path cursor
  79994. */
  79995. private raiseOnChange;
  79996. /**
  79997. * Executes a function on change
  79998. * @param f A path cursor onchange callback
  79999. * @returns This path cursor
  80000. */
  80001. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80002. }
  80003. }
  80004. declare module BABYLON {
  80005. /** @hidden */
  80006. export var blurPixelShader: {
  80007. name: string;
  80008. shader: string;
  80009. };
  80010. }
  80011. declare module BABYLON {
  80012. /** @hidden */
  80013. export var pointCloudVertexDeclaration: {
  80014. name: string;
  80015. shader: string;
  80016. };
  80017. }
  80018. // Mixins
  80019. interface Window {
  80020. mozIndexedDB: IDBFactory;
  80021. webkitIndexedDB: IDBFactory;
  80022. msIndexedDB: IDBFactory;
  80023. webkitURL: typeof URL;
  80024. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  80025. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  80026. WebGLRenderingContext: WebGLRenderingContext;
  80027. MSGesture: MSGesture;
  80028. CANNON: any;
  80029. AudioContext: AudioContext;
  80030. webkitAudioContext: AudioContext;
  80031. PointerEvent: any;
  80032. Math: Math;
  80033. Uint8Array: Uint8ArrayConstructor;
  80034. Float32Array: Float32ArrayConstructor;
  80035. mozURL: typeof URL;
  80036. msURL: typeof URL;
  80037. VRFrameData: any; // WebVR, from specs 1.1
  80038. DracoDecoderModule: any;
  80039. setImmediate(handler: (...args: any[]) => void): number;
  80040. }
  80041. interface HTMLCanvasElement {
  80042. requestPointerLock(): void;
  80043. msRequestPointerLock?(): void;
  80044. mozRequestPointerLock?(): void;
  80045. webkitRequestPointerLock?(): void;
  80046. /** Track wether a record is in progress */
  80047. isRecording: boolean;
  80048. /** Capture Stream method defined by some browsers */
  80049. captureStream(fps?: number): MediaStream;
  80050. }
  80051. interface CanvasRenderingContext2D {
  80052. msImageSmoothingEnabled: boolean;
  80053. }
  80054. interface MouseEvent {
  80055. mozMovementX: number;
  80056. mozMovementY: number;
  80057. webkitMovementX: number;
  80058. webkitMovementY: number;
  80059. msMovementX: number;
  80060. msMovementY: number;
  80061. }
  80062. interface Navigator {
  80063. mozGetVRDevices: (any: any) => any;
  80064. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80065. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80066. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80067. webkitGetGamepads(): Gamepad[];
  80068. msGetGamepads(): Gamepad[];
  80069. webkitGamepads(): Gamepad[];
  80070. }
  80071. interface HTMLVideoElement {
  80072. mozSrcObject: any;
  80073. }
  80074. interface Math {
  80075. fround(x: number): number;
  80076. imul(a: number, b: number): number;
  80077. log2(x: number): number;
  80078. }
  80079. interface WebGLRenderingContext {
  80080. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  80081. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  80082. vertexAttribDivisor(index: number, divisor: number): void;
  80083. createVertexArray(): any;
  80084. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  80085. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  80086. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  80087. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  80088. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  80089. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  80090. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  80091. // Queries
  80092. createQuery(): WebGLQuery;
  80093. deleteQuery(query: WebGLQuery): void;
  80094. beginQuery(target: number, query: WebGLQuery): void;
  80095. endQuery(target: number): void;
  80096. getQueryParameter(query: WebGLQuery, pname: number): any;
  80097. getQuery(target: number, pname: number): any;
  80098. MAX_SAMPLES: number;
  80099. RGBA8: number;
  80100. READ_FRAMEBUFFER: number;
  80101. DRAW_FRAMEBUFFER: number;
  80102. UNIFORM_BUFFER: number;
  80103. HALF_FLOAT_OES: number;
  80104. RGBA16F: number;
  80105. RGBA32F: number;
  80106. R32F: number;
  80107. RG32F: number;
  80108. RGB32F: number;
  80109. R16F: number;
  80110. RG16F: number;
  80111. RGB16F: number;
  80112. RED: number;
  80113. RG: number;
  80114. R8: number;
  80115. RG8: number;
  80116. UNSIGNED_INT_24_8: number;
  80117. DEPTH24_STENCIL8: number;
  80118. MIN: number;
  80119. MAX: number;
  80120. /* Multiple Render Targets */
  80121. drawBuffers(buffers: number[]): void;
  80122. readBuffer(src: number): void;
  80123. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  80124. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  80125. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  80126. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  80127. // Occlusion Query
  80128. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  80129. ANY_SAMPLES_PASSED: number;
  80130. QUERY_RESULT_AVAILABLE: number;
  80131. QUERY_RESULT: number;
  80132. }
  80133. interface WebGLProgram {
  80134. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  80135. }
  80136. interface EXT_disjoint_timer_query {
  80137. QUERY_COUNTER_BITS_EXT: number;
  80138. TIME_ELAPSED_EXT: number;
  80139. TIMESTAMP_EXT: number;
  80140. GPU_DISJOINT_EXT: number;
  80141. QUERY_RESULT_EXT: number;
  80142. QUERY_RESULT_AVAILABLE_EXT: number;
  80143. queryCounterEXT(query: WebGLQuery, target: number): void;
  80144. createQueryEXT(): WebGLQuery;
  80145. beginQueryEXT(target: number, query: WebGLQuery): void;
  80146. endQueryEXT(target: number): void;
  80147. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  80148. deleteQueryEXT(query: WebGLQuery): void;
  80149. }
  80150. interface WebGLUniformLocation {
  80151. _currentState: any;
  80152. }
  80153. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  80154. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  80155. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  80156. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  80157. interface WebGLRenderingContext {
  80158. readonly RASTERIZER_DISCARD: number;
  80159. readonly DEPTH_COMPONENT24: number;
  80160. readonly TEXTURE_3D: number;
  80161. readonly TEXTURE_2D_ARRAY: number;
  80162. readonly TEXTURE_COMPARE_FUNC: number;
  80163. readonly TEXTURE_COMPARE_MODE: number;
  80164. readonly COMPARE_REF_TO_TEXTURE: number;
  80165. readonly TEXTURE_WRAP_R: number;
  80166. readonly HALF_FLOAT: number;
  80167. readonly RGB8: number;
  80168. readonly RED_INTEGER: number;
  80169. readonly RG_INTEGER: number;
  80170. readonly RGB_INTEGER: number;
  80171. readonly RGBA_INTEGER: number;
  80172. readonly R8_SNORM: number;
  80173. readonly RG8_SNORM: number;
  80174. readonly RGB8_SNORM: number;
  80175. readonly RGBA8_SNORM: number;
  80176. readonly R8I: number;
  80177. readonly RG8I: number;
  80178. readonly RGB8I: number;
  80179. readonly RGBA8I: number;
  80180. readonly R8UI: number;
  80181. readonly RG8UI: number;
  80182. readonly RGB8UI: number;
  80183. readonly RGBA8UI: number;
  80184. readonly R16I: number;
  80185. readonly RG16I: number;
  80186. readonly RGB16I: number;
  80187. readonly RGBA16I: number;
  80188. readonly R16UI: number;
  80189. readonly RG16UI: number;
  80190. readonly RGB16UI: number;
  80191. readonly RGBA16UI: number;
  80192. readonly R32I: number;
  80193. readonly RG32I: number;
  80194. readonly RGB32I: number;
  80195. readonly RGBA32I: number;
  80196. readonly R32UI: number;
  80197. readonly RG32UI: number;
  80198. readonly RGB32UI: number;
  80199. readonly RGBA32UI: number;
  80200. readonly RGB10_A2UI: number;
  80201. readonly R11F_G11F_B10F: number;
  80202. readonly RGB9_E5: number;
  80203. readonly RGB10_A2: number;
  80204. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  80205. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  80206. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  80207. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  80208. readonly DEPTH_COMPONENT32F: number;
  80209. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  80210. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  80211. 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;
  80212. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  80213. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  80214. readonly TRANSFORM_FEEDBACK: number;
  80215. readonly INTERLEAVED_ATTRIBS: number;
  80216. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  80217. createTransformFeedback(): WebGLTransformFeedback;
  80218. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  80219. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  80220. beginTransformFeedback(primitiveMode: number): void;
  80221. endTransformFeedback(): void;
  80222. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  80223. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80224. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80225. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80226. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  80227. }
  80228. interface ImageBitmap {
  80229. readonly width: number;
  80230. readonly height: number;
  80231. close(): void;
  80232. }
  80233. interface WebGLQuery extends WebGLObject {
  80234. }
  80235. declare var WebGLQuery: {
  80236. prototype: WebGLQuery;
  80237. new(): WebGLQuery;
  80238. };
  80239. interface WebGLSampler extends WebGLObject {
  80240. }
  80241. declare var WebGLSampler: {
  80242. prototype: WebGLSampler;
  80243. new(): WebGLSampler;
  80244. };
  80245. interface WebGLSync extends WebGLObject {
  80246. }
  80247. declare var WebGLSync: {
  80248. prototype: WebGLSync;
  80249. new(): WebGLSync;
  80250. };
  80251. interface WebGLTransformFeedback extends WebGLObject {
  80252. }
  80253. declare var WebGLTransformFeedback: {
  80254. prototype: WebGLTransformFeedback;
  80255. new(): WebGLTransformFeedback;
  80256. };
  80257. interface WebGLVertexArrayObject extends WebGLObject {
  80258. }
  80259. declare var WebGLVertexArrayObject: {
  80260. prototype: WebGLVertexArrayObject;
  80261. new(): WebGLVertexArrayObject;
  80262. };
  80263. interface Navigator {
  80264. readonly gpu: GPU | undefined;
  80265. }
  80266. interface GPUColorDict {
  80267. a: number;
  80268. b: number;
  80269. g: number;
  80270. r: number;
  80271. }
  80272. type GPUColor = [number, number, number, number] | GPUColorDict;
  80273. interface GPUOrigin2DDict {
  80274. x?: number;
  80275. y?: number;
  80276. }
  80277. type GPUOrigin2D = [number, number] | GPUOrigin2DDict;
  80278. interface GPUOrigin3DDict {
  80279. x?: number;
  80280. y?: number;
  80281. z?: number;
  80282. }
  80283. type GPUOrigin3D = [number, number, number] | GPUOrigin3DDict;
  80284. interface GPUExtent3DDict {
  80285. width: number;
  80286. height: number;
  80287. depth: number;
  80288. }
  80289. type GPUExtent3D = [number, number, number] | GPUExtent3DDict;
  80290. type GPUBindingResource =
  80291. | GPUSampler
  80292. | GPUTextureView
  80293. | GPUBufferBinding;
  80294. type GPUExtensionName =
  80295. | "texture-compression-bc"
  80296. | "timestamp-query"
  80297. | "pipeline-statistics-query"
  80298. | "depth-clamping"
  80299. | "depth24unorm-stencil8"
  80300. | "depth32float-stencil8";
  80301. type GPUAddressMode = "clamp-to-edge" | "repeat" | "mirror-repeat";
  80302. type GPUBindingType =
  80303. | "uniform-buffer"
  80304. | "storage-buffer"
  80305. | "readonly-storage-buffer"
  80306. | "sampler"
  80307. | "comparison-sampler"
  80308. | "sampled-texture"
  80309. | "readonly-storage-texture"
  80310. | "writeonly-storage-texture";
  80311. type GPUBlendFactor =
  80312. | "zero"
  80313. | "one"
  80314. | "src-color"
  80315. | "one-minus-src-color"
  80316. | "src-alpha"
  80317. | "one-minus-src-alpha"
  80318. | "dst-color"
  80319. | "one-minus-dst-color"
  80320. | "dst-alpha"
  80321. | "one-minus-dst-alpha"
  80322. | "src-alpha-saturated"
  80323. | "blend-color"
  80324. | "one-minus-blend-color";
  80325. type GPUBlendOperation =
  80326. | "add"
  80327. | "subtract"
  80328. | "reverse-subtract"
  80329. | "min"
  80330. | "max";
  80331. type GPUCompareFunction =
  80332. | "never"
  80333. | "less"
  80334. | "equal"
  80335. | "less-equal"
  80336. | "greater"
  80337. | "not-equal"
  80338. | "greater-equal"
  80339. | "always";
  80340. type GPUCullMode = "none" | "front" | "back";
  80341. type GPUFilterMode = "nearest" | "linear";
  80342. type GPUFrontFace = "ccw" | "cw";
  80343. type GPUIndexFormat = "uint16" | "uint32";
  80344. type GPUInputStepMode = "vertex" | "instance";
  80345. type GPULoadOp = "load";
  80346. type GPUPrimitiveTopology =
  80347. | "point-list"
  80348. | "line-list"
  80349. | "line-strip"
  80350. | "triangle-list"
  80351. | "triangle-strip";
  80352. type GPUStencilOperation =
  80353. | "keep"
  80354. | "zero"
  80355. | "replace"
  80356. | "invert"
  80357. | "increment-clamp"
  80358. | "decrement-clamp"
  80359. | "increment-wrap"
  80360. | "decrement-wrap";
  80361. type GPUStoreOp = "store" | "clear";
  80362. type GPUTextureDimension = "1d" | "2d" | "3d";
  80363. type GPUTextureFormat =
  80364. | "r8unorm"
  80365. | "r8snorm"
  80366. | "r8uint"
  80367. | "r8sint"
  80368. | "r16uint"
  80369. | "r16sint"
  80370. | "r16float"
  80371. | "rg8unorm"
  80372. | "rg8snorm"
  80373. | "rg8uint"
  80374. | "rg8sint"
  80375. | "r32uint"
  80376. | "r32sint"
  80377. | "r32float"
  80378. | "rg16uint"
  80379. | "rg16sint"
  80380. | "rg16float"
  80381. | "rgba8unorm"
  80382. | "rgba8unorm-srgb"
  80383. | "rgba8snorm"
  80384. | "rgba8uint"
  80385. | "rgba8sint"
  80386. | "bgra8unorm"
  80387. | "bgra8unorm-srgb"
  80388. | "rgb9e5ufloat"
  80389. | "rgb10a2unorm"
  80390. | "rg11b10ufloat"
  80391. | "rg32uint"
  80392. | "rg32sint"
  80393. | "rg32float"
  80394. | "rgba16uint"
  80395. | "rgba16sint"
  80396. | "rgba16float"
  80397. | "rgba32uint"
  80398. | "rgba32sint"
  80399. | "rgba32float"
  80400. | "stencil8"
  80401. | "depth16unorm"
  80402. | "depth24plus"
  80403. | "depth24plus-stencil8"
  80404. | "depth32float"
  80405. | "bc1-rgba-unorm"
  80406. | "bc1-rgba-unorm-srgb"
  80407. | "bc2-rgba-unorm"
  80408. | "bc2-rgba-unorm-srgb"
  80409. | "bc3-rgba-unorm"
  80410. | "bc3-rgba-unorm-srgb"
  80411. | "bc4-r-unorm"
  80412. | "bc4-r-snorm"
  80413. | "bc5-rg-unorm"
  80414. | "bc5-rg-snorm"
  80415. | "bc6h-rgb-ufloat"
  80416. | "bc6h-rgb-float"
  80417. | "bc7-rgba-unorm"
  80418. | "bc7-rgba-unorm-srgb"
  80419. | "depth24unorm-stencil8"
  80420. | "depth32float-stencil8";
  80421. type GPUTextureComponentType = "float" | "sint" | "uint" | "depth-comparison";
  80422. type GPUTextureViewDimension =
  80423. | "1d"
  80424. | "2d"
  80425. | "2d-array"
  80426. | "cube"
  80427. | "cube-array"
  80428. | "3d";
  80429. type GPUVertexFormat =
  80430. | "uchar2"
  80431. | "uchar4"
  80432. | "char2"
  80433. | "char4"
  80434. | "uchar2norm"
  80435. | "uchar4norm"
  80436. | "char2norm"
  80437. | "char4norm"
  80438. | "ushort2"
  80439. | "ushort4"
  80440. | "short2"
  80441. | "short4"
  80442. | "ushort2norm"
  80443. | "ushort4norm"
  80444. | "short2norm"
  80445. | "short4norm"
  80446. | "half2"
  80447. | "half4"
  80448. | "float"
  80449. | "float2"
  80450. | "float3"
  80451. | "float4"
  80452. | "uint"
  80453. | "uint2"
  80454. | "uint3"
  80455. | "uint4"
  80456. | "int"
  80457. | "int2"
  80458. | "int3"
  80459. | "int4";
  80460. type GPUTextureAspect = "all" | "stencil-only" | "depth-only";
  80461. type GPUBufferUsageFlags = number;
  80462. type GPUColorWriteFlags = number;
  80463. type GPUShaderStageFlags = number;
  80464. type GPUTextureUsageFlags = number;
  80465. type GPUMapModeFlags = number;
  80466. interface GPUBindGroupEntry {
  80467. binding: number;
  80468. resource: GPUBindingResource;
  80469. }
  80470. interface GPUBindGroupDescriptor extends GPUObjectDescriptorBase {
  80471. layout: GPUBindGroupLayout;
  80472. entries: Iterable<GPUBindGroupEntry>;
  80473. }
  80474. interface GPUBindGroupLayoutEntry {
  80475. binding: number;
  80476. visibility: GPUShaderStageFlags;
  80477. type: GPUBindingType;
  80478. hasDynamicOffset?: boolean;
  80479. minBufferBindingSize?: number;
  80480. viewDimension?: GPUTextureViewDimension;
  80481. textureComponentType?: GPUTextureComponentType;
  80482. storageTextureFormat?: GPUTextureFormat;
  80483. }
  80484. interface GPUBindGroupLayoutDescriptor
  80485. extends GPUObjectDescriptorBase {
  80486. entries: Iterable<GPUBindGroupLayoutEntry>;
  80487. }
  80488. interface GPUBlendDescriptor {
  80489. dstFactor?: GPUBlendFactor;
  80490. operation?: GPUBlendOperation;
  80491. srcFactor?: GPUBlendFactor;
  80492. }
  80493. interface GPUColorStateDescriptor {
  80494. format: GPUTextureFormat;
  80495. alphaBlend?: GPUBlendDescriptor;
  80496. colorBlend?: GPUBlendDescriptor;
  80497. writeMask?: GPUColorWriteFlags;
  80498. }
  80499. interface GPUBufferBinding {
  80500. buffer: GPUBuffer;
  80501. offset?: number;
  80502. size?: number;
  80503. }
  80504. interface GPUTextureDataLayout {
  80505. offset?: number;
  80506. bytesPerRow: number;
  80507. rowsPerImage?: number;
  80508. }
  80509. interface GPUBufferCopyView extends GPUTextureDataLayout {
  80510. buffer: GPUBuffer;
  80511. }
  80512. interface GPUTextureCopyView {
  80513. texture: GPUTexture;
  80514. mipLevel?: number;
  80515. origin?: GPUOrigin3D;
  80516. }
  80517. interface GPUImageBitmapCopyView {
  80518. imageBitmap: ImageBitmap;
  80519. origin?: GPUOrigin2D;
  80520. }
  80521. interface GPUBufferDescriptor extends GPUObjectDescriptorBase {
  80522. size: number;
  80523. usage: GPUBufferUsageFlags;
  80524. mappedAtCreation?: boolean;
  80525. }
  80526. interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {
  80527. label?: string;
  80528. measureExecutionTime?: boolean;
  80529. }
  80530. interface GPUComputePipelineDescriptor
  80531. extends GPUPipelineDescriptorBase {
  80532. computeStage: GPUProgrammableStageDescriptor;
  80533. }
  80534. interface GPUDepthStencilStateDescriptor {
  80535. format: GPUTextureFormat;
  80536. depthWriteEnabled?: boolean;
  80537. depthCompare?: GPUCompareFunction;
  80538. stencilFront?: GPUStencilStateFaceDescriptor;
  80539. stencilBack?: GPUStencilStateFaceDescriptor;
  80540. stencilReadMask?: number;
  80541. stencilWriteMask?: number;
  80542. }
  80543. interface GPUDeviceDescriptor extends GPUObjectDescriptorBase {
  80544. extensions?: Iterable<GPUExtensionName>;
  80545. limits?: GPULimits;
  80546. }
  80547. interface GPUFenceDescriptor extends GPUObjectDescriptorBase {
  80548. initialValue?: number;
  80549. label?: string;
  80550. signalQueue?: GPUQueue;
  80551. }
  80552. interface GPUVertexAttributeDescriptor {
  80553. format: GPUVertexFormat;
  80554. offset: number;
  80555. shaderLocation: number;
  80556. }
  80557. interface GPUVertexBufferLayoutDescriptor {
  80558. arrayStride: number;
  80559. stepMode?: GPUInputStepMode;
  80560. attributes: Iterable<GPUVertexAttributeDescriptor>;
  80561. }
  80562. interface GPUVertexStateDescriptor {
  80563. indexFormat?: GPUIndexFormat;
  80564. vertexBuffers?: Iterable<GPUVertexBufferLayoutDescriptor>;
  80565. }
  80566. interface GPULimits {
  80567. maxBindGroups?: number;
  80568. maxDynamicUniformBuffersPerPipelineLayout?: number;
  80569. maxDynamicStorageBuffersPerPipelineLayout?: number;
  80570. maxSampledTexturesPerShaderStage?: number;
  80571. maxSamplersPerShaderStage?: number;
  80572. maxStorageBuffersPerShaderStage?: number;
  80573. maxStorageTexturesPerShaderStage?: number;
  80574. maxUniformBuffersPerShaderStage?: number;
  80575. maxUniformBufferBindingSize?: number;
  80576. }
  80577. interface GPUPipelineDescriptorBase {
  80578. label?: string;
  80579. layout?: GPUPipelineLayout;
  80580. }
  80581. interface GPUPipelineLayoutDescriptor extends GPUObjectDescriptorBase {
  80582. bindGroupLayouts: Iterable<GPUBindGroupLayout>;
  80583. }
  80584. interface GPUProgrammableStageDescriptor {
  80585. module: GPUShaderModule;
  80586. entryPoint: string;
  80587. }
  80588. interface GPURasterizationStateDescriptor {
  80589. frontFace?: GPUFrontFace;
  80590. cullMode?: GPUCullMode;
  80591. clampDepth?: boolean;
  80592. depthBias?: number;
  80593. depthBiasSlopeScale?: number;
  80594. depthBiasClamp?: number;
  80595. }
  80596. interface GPURenderPassColorAttachmentDescriptor {
  80597. attachment: GPUTextureView;
  80598. resolveTarget?: GPUTextureView;
  80599. loadValue: GPULoadOp | GPUColor;
  80600. storeOp?: GPUStoreOp;
  80601. }
  80602. interface GPURenderPassDepthStencilAttachmentDescriptor {
  80603. attachment: GPUTextureView;
  80604. depthLoadValue: GPULoadOp | number;
  80605. depthStoreOp: GPUStoreOp;
  80606. depthReadOnly?: boolean;
  80607. stencilLoadValue: GPULoadOp | number;
  80608. stencilStoreOp: GPUStoreOp;
  80609. stencilReadOnly?: boolean;
  80610. }
  80611. interface GPURenderPassDescriptor extends GPUObjectDescriptorBase {
  80612. colorAttachments: Iterable<GPURenderPassColorAttachmentDescriptor>;
  80613. depthStencilAttachment?: GPURenderPassDepthStencilAttachmentDescriptor;
  80614. }
  80615. interface GPURenderPipelineDescriptor
  80616. extends GPUPipelineDescriptorBase {
  80617. vertexStage: GPUProgrammableStageDescriptor;
  80618. fragmentStage?: GPUProgrammableStageDescriptor;
  80619. primitiveTopology: GPUPrimitiveTopology;
  80620. rasterizationState?: GPURasterizationStateDescriptor;
  80621. colorStates: Iterable<GPUColorStateDescriptor>;
  80622. depthStencilState?: GPUDepthStencilStateDescriptor;
  80623. vertexState?: GPUVertexStateDescriptor;
  80624. sampleCount?: number;
  80625. sampleMask?: number;
  80626. alphaToCoverageEnabled?: boolean;
  80627. }
  80628. interface GPUSamplerDescriptor extends GPUObjectDescriptorBase {
  80629. addressModeU?: GPUAddressMode;
  80630. addressModeV?: GPUAddressMode;
  80631. addressModeW?: GPUAddressMode;
  80632. magFilter?: GPUFilterMode;
  80633. minFilter?: GPUFilterMode;
  80634. mipmapFilter?: GPUFilterMode;
  80635. lodMinClamp?: number;
  80636. lodMaxClamp?: number;
  80637. compare?: GPUCompareFunction;
  80638. maxAnisotropy?: number;
  80639. }
  80640. interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase {
  80641. code: Uint32Array | string;
  80642. label?: string;
  80643. sourceMap?: object;
  80644. }
  80645. interface GPUStencilStateFaceDescriptor {
  80646. compare?: GPUCompareFunction;
  80647. depthFailOp?: GPUStencilOperation;
  80648. passOp?: GPUStencilOperation;
  80649. failOp?: GPUStencilOperation;
  80650. }
  80651. interface GPUSwapChainDescriptor extends GPUObjectDescriptorBase {
  80652. device: GPUDevice;
  80653. format: GPUTextureFormat;
  80654. usage?: GPUTextureUsageFlags;
  80655. }
  80656. interface GPUTextureDescriptor extends GPUObjectDescriptorBase {
  80657. size: GPUExtent3D;
  80658. mipLevelCount?: number;
  80659. sampleCount?: number;
  80660. dimension?: GPUTextureDimension;
  80661. format: GPUTextureFormat;
  80662. usage: GPUTextureUsageFlags;
  80663. }
  80664. interface GPUTextureViewDescriptor extends GPUObjectDescriptorBase {
  80665. format?: GPUTextureFormat;
  80666. dimension?: GPUTextureViewDimension;
  80667. aspect?: GPUTextureAspect;
  80668. baseArrayLayer?: number;
  80669. baseMipLevel?: number;
  80670. arrayLayerCount?: number;
  80671. mipLevelCount?: number;
  80672. }
  80673. declare class GPUAdapter {
  80674. // https://michalzalecki.com/nominal-typing-in-typescript/#approach-1-class-with-a-private-property
  80675. private __brand: void;
  80676. readonly name: string;
  80677. readonly extensions: GPUExtensionName[];
  80678. readonly limits: Required<GPULimits>;
  80679. requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice | null>;
  80680. }
  80681. declare class GPUBindGroup implements GPUObjectBase {
  80682. private __brand: void;
  80683. label: string | undefined;
  80684. }
  80685. declare class GPUBindGroupLayout implements GPUObjectBase {
  80686. private __brand: void;
  80687. label: string | undefined;
  80688. }
  80689. declare class GPUBuffer implements GPUObjectBase {
  80690. private __brand: void;
  80691. label: string | undefined;
  80692. destroy(): void;
  80693. unmap(): void;
  80694. mapAsync(mode: GPUMapModeFlags, offset?: number, size?: number): Promise<void>;
  80695. getMappedRange(offset?: number, size?: number): ArrayBuffer;
  80696. }
  80697. declare class GPUCommandBuffer implements GPUObjectBase {
  80698. private __brand: void;
  80699. label: string | undefined;
  80700. readonly executionTime: Promise<number>;
  80701. }
  80702. interface GPUCommandBufferDescriptor extends GPUObjectDescriptorBase { }
  80703. declare class GPUCommandEncoder implements GPUObjectBase {
  80704. private __brand: void;
  80705. label: string | undefined;
  80706. beginComputePass(
  80707. descriptor?: GPUComputePassDescriptor
  80708. ): GPUComputePassEncoder;
  80709. beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder;
  80710. copyBufferToBuffer(
  80711. source: GPUBuffer,
  80712. sourceOffset: number,
  80713. destination: GPUBuffer,
  80714. destinationOffset: number,
  80715. size: number
  80716. ): void;
  80717. copyBufferToTexture(
  80718. source: GPUBufferCopyView,
  80719. destination: GPUTextureCopyView,
  80720. copySize: GPUExtent3D
  80721. ): void;
  80722. copyTextureToBuffer(
  80723. source: GPUTextureCopyView,
  80724. destination: GPUBufferCopyView,
  80725. copySize: GPUExtent3D
  80726. ): void;
  80727. copyTextureToTexture(
  80728. source: GPUTextureCopyView,
  80729. destination: GPUTextureCopyView,
  80730. copySize: GPUExtent3D
  80731. ): void;
  80732. finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer;
  80733. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  80734. popDebugGroup(): void;
  80735. pushDebugGroup(groupLabel: string): void;
  80736. insertDebugMarker(markerLabel: string): void;
  80737. }
  80738. interface GPUComputePassDescriptor extends GPUObjectDescriptorBase { }
  80739. declare class GPUComputePassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder {
  80740. private __brand: void;
  80741. label: string | undefined;
  80742. setBindGroup(
  80743. index: number,
  80744. bindGroup: GPUBindGroup,
  80745. dynamicOffsets?: Iterable<number>
  80746. ): void;
  80747. popDebugGroup(): void;
  80748. pushDebugGroup(groupLabel: string): void;
  80749. insertDebugMarker(markerLabel: string): void;
  80750. setPipeline(pipeline: GPUComputePipeline): void;
  80751. dispatch(x: number, y?: number, z?: number): void;
  80752. dispatchIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  80753. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  80754. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  80755. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  80756. endPass(): void;
  80757. }
  80758. declare class GPUComputePipeline implements GPUPipelineBase {
  80759. private __brand: void;
  80760. label: string | undefined;
  80761. getBindGroupLayout(index: number): GPUBindGroupLayout;
  80762. }
  80763. interface GPUObjectBase {
  80764. label: string | undefined;
  80765. }
  80766. interface GPUObjectDescriptorBase {
  80767. label?: string;
  80768. }
  80769. // SwapChain / CanvasContext
  80770. declare class GPUCanvasContext {
  80771. private __brand: void;
  80772. configureSwapChain(descriptor: GPUSwapChainDescriptor): GPUSwapChain;
  80773. getSwapChainPreferredFormat(device: GPUDevice): Promise<GPUTextureFormat>;
  80774. }
  80775. declare class GPUDevice extends EventTarget implements GPUObjectBase {
  80776. private __brand: void;
  80777. label: string | undefined;
  80778. readonly adapter: GPUAdapter;
  80779. readonly extensions: GPUExtensionName[];
  80780. readonly limits: Required<GPULimits>;
  80781. createBindGroup(descriptor: GPUBindGroupDescriptor): GPUBindGroup;
  80782. createBindGroupLayout(
  80783. descriptor: GPUBindGroupLayoutDescriptor
  80784. ): GPUBindGroupLayout;
  80785. createBuffer(descriptor: GPUBufferDescriptor): GPUBuffer;
  80786. createPipelineLayout(
  80787. descriptor: GPUPipelineLayoutDescriptor
  80788. ): GPUPipelineLayout;
  80789. createSampler(descriptor?: GPUSamplerDescriptor): GPUSampler;
  80790. createShaderModule(descriptor: GPUShaderModuleDescriptor): GPUShaderModule;
  80791. createTexture(descriptor: GPUTextureDescriptor): GPUTexture;
  80792. createComputePipeline(
  80793. descriptor: GPUComputePipelineDescriptor
  80794. ): GPUComputePipeline;
  80795. createRenderPipeline(
  80796. descriptor: GPURenderPipelineDescriptor
  80797. ): GPURenderPipeline;
  80798. createReadyComputePipeline(
  80799. descriptor: GPUComputePipelineDescriptor
  80800. ): Promise<GPUComputePipeline>;
  80801. createReadyRenderPipeline(
  80802. descriptor: GPURenderPipelineDescriptor
  80803. ): Promise<GPURenderPipeline>;
  80804. createCommandEncoder(
  80805. descriptor?: GPUCommandEncoderDescriptor
  80806. ): GPUCommandEncoder;
  80807. createRenderBundleEncoder(
  80808. descriptor: GPURenderBundleEncoderDescriptor
  80809. ): GPURenderBundleEncoder;
  80810. createQuerySet(descriptor: GPUQuerySetDescriptor): GPUQuerySet;
  80811. defaultQueue: GPUQueue;
  80812. pushErrorScope(filter: GPUErrorFilter): void;
  80813. popErrorScope(): Promise<GPUError | null>;
  80814. onuncapturederror: Event | undefined;
  80815. readonly lost: Promise<GPUDeviceLostInfo>;
  80816. }
  80817. declare class GPUFence implements GPUObjectBase {
  80818. private __brand: void;
  80819. label: string | undefined;
  80820. getCompletedValue(): number;
  80821. onCompletion(completionValue: number): Promise<void>;
  80822. }
  80823. interface GPUPipelineBase extends GPUObjectBase {
  80824. getBindGroupLayout(index: number): GPUBindGroupLayout;
  80825. }
  80826. declare class GPUPipelineLayout implements GPUObjectBase {
  80827. private __brand: void;
  80828. label: string | undefined;
  80829. }
  80830. interface GPUProgrammablePassEncoder {
  80831. setBindGroup(
  80832. index: number,
  80833. bindGroup: GPUBindGroup,
  80834. dynamicOffsets?: Iterable<number>
  80835. ): void;
  80836. popDebugGroup(): void;
  80837. pushDebugGroup(groupLabel: string): void;
  80838. insertDebugMarker(markerLabel: string): void;
  80839. }
  80840. declare class GPUQueue implements GPUObjectBase {
  80841. private __brand: void;
  80842. label: string | undefined;
  80843. signal(fence: GPUFence, signalValue: number): void;
  80844. submit(commandBuffers: Iterable<GPUCommandBuffer>): void;
  80845. createFence(descriptor?: GPUFenceDescriptor): GPUFence;
  80846. writeBuffer(buffer: GPUBuffer,
  80847. bufferOffset: number,
  80848. data: BufferSource | ArrayBuffer,
  80849. dataOffset?: number,
  80850. size?: number): void;
  80851. writeTexture(destination: GPUTextureCopyView,
  80852. data: BufferSource | ArrayBuffer,
  80853. dataLayout: GPUTextureDataLayout,
  80854. size: GPUExtent3D): void;
  80855. copyImageBitmapToTexture(
  80856. source: GPUImageBitmapCopyView,
  80857. destination: GPUTextureCopyView,
  80858. copySize: GPUExtent3D
  80859. ): void;
  80860. }
  80861. type GPUQueryType =
  80862. | "occlusion"
  80863. | "timestamp"
  80864. | "pipeline-statistics";
  80865. type GPUPipelineStatisticName =
  80866. | "vertex-shader-invocations"
  80867. | "clipper-invocations"
  80868. | "clipper-primitives-out"
  80869. | "fragment-shader-invocations"
  80870. | "compute-shader-invocations";
  80871. interface GPUQuerySetDescriptor extends GPUObjectDescriptorBase {
  80872. type: GPUQueryType;
  80873. count: number;
  80874. pipelineStatistics?: Iterable<GPUPipelineStatisticName>;
  80875. }
  80876. declare class GPUQuerySet implements GPUObjectBase {
  80877. private __brand: void;
  80878. label: string | undefined;
  80879. destroy(): void;
  80880. }
  80881. interface GPURenderEncoderBase {
  80882. setPipeline(pipeline: GPURenderPipeline): void;
  80883. setIndexBuffer(buffer: GPUBuffer, offset?: number, size?: number): void;
  80884. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  80885. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number, size?: number): void;
  80886. draw(
  80887. vertexCount: number,
  80888. instanceCount?: number,
  80889. firstVertex?: number,
  80890. firstInstance?: number
  80891. ): void;
  80892. drawIndexed(
  80893. indexCount: number,
  80894. instanceCount?: number,
  80895. firstIndex?: number,
  80896. baseVertex?: number,
  80897. firstInstance?: number
  80898. ): void;
  80899. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  80900. drawIndexedIndirect(
  80901. indirectBuffer: GPUBuffer,
  80902. indirectOffset: number
  80903. ): void;
  80904. }
  80905. declare class GPURenderPassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder, GPURenderEncoderBase {
  80906. private __brand: void;
  80907. label: string | undefined;
  80908. setBindGroup(
  80909. index: number,
  80910. bindGroup: GPUBindGroup,
  80911. dynamicOffsets?: Iterable<number>
  80912. ): void;
  80913. popDebugGroup(): void;
  80914. pushDebugGroup(groupLabel: string): void;
  80915. insertDebugMarker(markerLabel: string): void;
  80916. setPipeline(pipeline: GPURenderPipeline): void;
  80917. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  80918. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  80919. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  80920. draw(
  80921. vertexCount: number,
  80922. instanceCount?: number,
  80923. firstVertex?: number,
  80924. firstInstance?: number
  80925. ): void;
  80926. drawIndexed(
  80927. indexCount: number,
  80928. instanceCount?: number,
  80929. firstIndex?: number,
  80930. baseVertex?: number,
  80931. firstInstance?: number
  80932. ): void;
  80933. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  80934. drawIndexedIndirect(
  80935. indirectBuffer: GPUBuffer,
  80936. indirectOffset: number
  80937. ): void;
  80938. setViewport(
  80939. x: number,
  80940. y: number,
  80941. width: number,
  80942. height: number,
  80943. minDepth: number,
  80944. maxDepth: number
  80945. ): void;
  80946. setScissorRect(x: number, y: number, width: number, height: number): void;
  80947. setBlendColor(color: GPUColor): void;
  80948. setStencilReference(reference: number): void;
  80949. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  80950. beginOcclusionQuery(queryIndex: number): void;
  80951. endOcclusionQuery(): void;
  80952. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  80953. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  80954. executeBundles(bundles: Iterable<GPURenderBundle>): void;
  80955. endPass(): void;
  80956. }
  80957. interface GPURenderBundleDescriptor extends GPUObjectDescriptorBase { }
  80958. declare class GPURenderBundle implements GPUObjectBase {
  80959. private __brand: void;
  80960. label: string | undefined;
  80961. }
  80962. declare class GPURenderBundleEncoder implements GPURenderEncoderBase {
  80963. private __brand: void;
  80964. label: string | undefined;
  80965. setBindGroup(
  80966. index: number,
  80967. bindGroup: GPUBindGroup,
  80968. dynamicOffsets?: Iterable<number>
  80969. ): void;
  80970. popDebugGroup(): void;
  80971. pushDebugGroup(groupLabel: string): void;
  80972. insertDebugMarker(markerLabel: string): void;
  80973. setPipeline(pipeline: GPURenderPipeline): void;
  80974. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  80975. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  80976. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  80977. draw(
  80978. vertexCount: number,
  80979. instanceCount?: number,
  80980. firstVertex?: number,
  80981. firstInstance?: number
  80982. ): void;
  80983. drawIndexed(
  80984. indexCount: number,
  80985. instanceCount?: number,
  80986. firstIndex?: number,
  80987. baseVertex?: number,
  80988. firstInstance?: number
  80989. ): void;
  80990. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  80991. drawIndexedIndirect(
  80992. indirectBuffer: GPUBuffer,
  80993. indirectOffset: number
  80994. ): void;
  80995. finish(descriptor?: GPURenderBundleDescriptor): GPURenderBundle;
  80996. }
  80997. interface GPURenderBundleEncoderDescriptor
  80998. extends GPUObjectDescriptorBase {
  80999. colorFormats: Iterable<GPUTextureFormat>;
  81000. depthStencilFormat?: GPUTextureFormat;
  81001. sampleCount?: number;
  81002. }
  81003. declare class GPURenderPipeline implements GPUPipelineBase {
  81004. private __brand: void;
  81005. label: string | undefined;
  81006. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81007. }
  81008. declare class GPUSampler implements GPUObjectBase {
  81009. private __brand: void;
  81010. label: string | undefined;
  81011. }
  81012. type GPUCompilationMessageType =
  81013. | "error"
  81014. | "warning"
  81015. | "info";
  81016. interface GPUCompilationMessage {
  81017. readonly message: string;
  81018. readonly type: GPUCompilationMessageType;
  81019. readonly lineNum: number;
  81020. readonly linePos: number;
  81021. }
  81022. interface GPUCompilationInfo {
  81023. readonly messages: readonly GPUCompilationMessage[];
  81024. }
  81025. declare class GPUShaderModule implements GPUObjectBase {
  81026. private __brand: void;
  81027. label: string | undefined;
  81028. compilationInfo(): Promise<GPUCompilationInfo>;
  81029. }
  81030. declare class GPUSwapChain implements GPUObjectBase {
  81031. private __brand: void;
  81032. label: string | undefined;
  81033. getCurrentTexture(): GPUTexture;
  81034. }
  81035. declare class GPUTexture implements GPUObjectBase {
  81036. private __brand: void;
  81037. label: string | undefined;
  81038. createView(descriptor?: GPUTextureViewDescriptor): GPUTextureView;
  81039. destroy(): void;
  81040. }
  81041. declare class GPUTextureView implements GPUObjectBase {
  81042. private __brand: void;
  81043. label: string | undefined;
  81044. }
  81045. type GPUPowerPreference = "low-power" | "high-performance";
  81046. interface GPURequestAdapterOptions {
  81047. powerPreference?: GPUPowerPreference;
  81048. }
  81049. declare class GPU {
  81050. private __brand: void;
  81051. requestAdapter(options?: GPURequestAdapterOptions): Promise<GPUAdapter | null>;
  81052. }
  81053. // ****************************************************************************
  81054. // ERROR SCOPES
  81055. // ****************************************************************************
  81056. type GPUErrorFilter = "out-of-memory" | "validation";
  81057. declare class GPUOutOfMemoryError {
  81058. private __brand: void;
  81059. constructor();
  81060. }
  81061. declare class GPUValidationError {
  81062. private __brand: void;
  81063. constructor(message: string);
  81064. readonly message: string;
  81065. }
  81066. type GPUError = GPUOutOfMemoryError | GPUValidationError;
  81067. // ****************************************************************************
  81068. // TELEMETRY
  81069. // ****************************************************************************
  81070. declare class GPUUncapturedErrorEvent extends Event {
  81071. private __brand: void;
  81072. constructor(
  81073. type: string,
  81074. gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit
  81075. );
  81076. readonly error: GPUError;
  81077. }
  81078. interface GPUUncapturedErrorEventInit extends EventInit {
  81079. error: GPUError;
  81080. }
  81081. declare class GPUDeviceLostInfo {
  81082. private __brand: void;
  81083. readonly message: string;
  81084. }
  81085. // Type definitions for WebVR API
  81086. // Project: https://w3c.github.io/webvr/
  81087. // Definitions by: six a <https://github.com/lostfictions>
  81088. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  81089. interface VRDisplay extends EventTarget {
  81090. /**
  81091. * Dictionary of capabilities describing the VRDisplay.
  81092. */
  81093. readonly capabilities: VRDisplayCapabilities;
  81094. /**
  81095. * z-depth defining the far plane of the eye view frustum
  81096. * enables mapping of values in the render target depth
  81097. * attachment to scene coordinates. Initially set to 10000.0.
  81098. */
  81099. depthFar: number;
  81100. /**
  81101. * z-depth defining the near plane of the eye view frustum
  81102. * enables mapping of values in the render target depth
  81103. * attachment to scene coordinates. Initially set to 0.01.
  81104. */
  81105. depthNear: number;
  81106. /**
  81107. * An identifier for this distinct VRDisplay. Used as an
  81108. * association point in the Gamepad API.
  81109. */
  81110. readonly displayId: number;
  81111. /**
  81112. * A display name, a user-readable name identifying it.
  81113. */
  81114. readonly displayName: string;
  81115. readonly isConnected: boolean;
  81116. readonly isPresenting: boolean;
  81117. /**
  81118. * If this VRDisplay supports room-scale experiences, the optional
  81119. * stage attribute contains details on the room-scale parameters.
  81120. */
  81121. readonly stageParameters: VRStageParameters | null;
  81122. /**
  81123. * Passing the value returned by `requestAnimationFrame` to
  81124. * `cancelAnimationFrame` will unregister the callback.
  81125. * @param handle Define the hanle of the request to cancel
  81126. */
  81127. cancelAnimationFrame(handle: number): void;
  81128. /**
  81129. * Stops presenting to the VRDisplay.
  81130. * @returns a promise to know when it stopped
  81131. */
  81132. exitPresent(): Promise<void>;
  81133. /**
  81134. * Return the current VREyeParameters for the given eye.
  81135. * @param whichEye Define the eye we want the parameter for
  81136. * @returns the eye parameters
  81137. */
  81138. getEyeParameters(whichEye: string): VREyeParameters;
  81139. /**
  81140. * Populates the passed VRFrameData with the information required to render
  81141. * the current frame.
  81142. * @param frameData Define the data structure to populate
  81143. * @returns true if ok otherwise false
  81144. */
  81145. getFrameData(frameData: VRFrameData): boolean;
  81146. /**
  81147. * Get the layers currently being presented.
  81148. * @returns the list of VR layers
  81149. */
  81150. getLayers(): VRLayer[];
  81151. /**
  81152. * Return a VRPose containing the future predicted pose of the VRDisplay
  81153. * when the current frame will be presented. The value returned will not
  81154. * change until JavaScript has returned control to the browser.
  81155. *
  81156. * The VRPose will contain the position, orientation, velocity,
  81157. * and acceleration of each of these properties.
  81158. * @returns the pose object
  81159. */
  81160. getPose(): VRPose;
  81161. /**
  81162. * Return the current instantaneous pose of the VRDisplay, with no
  81163. * prediction applied.
  81164. * @returns the current instantaneous pose
  81165. */
  81166. getImmediatePose(): VRPose;
  81167. /**
  81168. * The callback passed to `requestAnimationFrame` will be called
  81169. * any time a new frame should be rendered. When the VRDisplay is
  81170. * presenting the callback will be called at the native refresh
  81171. * rate of the HMD. When not presenting this function acts
  81172. * identically to how window.requestAnimationFrame acts. Content should
  81173. * make no assumptions of frame rate or vsync behavior as the HMD runs
  81174. * asynchronously from other displays and at differing refresh rates.
  81175. * @param callback Define the eaction to run next frame
  81176. * @returns the request handle it
  81177. */
  81178. requestAnimationFrame(callback: FrameRequestCallback): number;
  81179. /**
  81180. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  81181. * Repeat calls while already presenting will update the VRLayers being displayed.
  81182. * @param layers Define the list of layer to present
  81183. * @returns a promise to know when the request has been fulfilled
  81184. */
  81185. requestPresent(layers: VRLayer[]): Promise<void>;
  81186. /**
  81187. * Reset the pose for this display, treating its current position and
  81188. * orientation as the "origin/zero" values. VRPose.position,
  81189. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  81190. * updated when calling resetPose(). This should be called in only
  81191. * sitting-space experiences.
  81192. */
  81193. resetPose(): void;
  81194. /**
  81195. * The VRLayer provided to the VRDisplay will be captured and presented
  81196. * in the HMD. Calling this function has the same effect on the source
  81197. * canvas as any other operation that uses its source image, and canvases
  81198. * created without preserveDrawingBuffer set to true will be cleared.
  81199. * @param pose Define the pose to submit
  81200. */
  81201. submitFrame(pose?: VRPose): void;
  81202. }
  81203. declare var VRDisplay: {
  81204. prototype: VRDisplay;
  81205. new(): VRDisplay;
  81206. };
  81207. interface VRLayer {
  81208. leftBounds?: number[] | Float32Array | null;
  81209. rightBounds?: number[] | Float32Array | null;
  81210. source?: HTMLCanvasElement | null;
  81211. }
  81212. interface VRDisplayCapabilities {
  81213. readonly canPresent: boolean;
  81214. readonly hasExternalDisplay: boolean;
  81215. readonly hasOrientation: boolean;
  81216. readonly hasPosition: boolean;
  81217. readonly maxLayers: number;
  81218. }
  81219. interface VREyeParameters {
  81220. /** @deprecated */
  81221. readonly fieldOfView: VRFieldOfView;
  81222. readonly offset: Float32Array;
  81223. readonly renderHeight: number;
  81224. readonly renderWidth: number;
  81225. }
  81226. interface VRFieldOfView {
  81227. readonly downDegrees: number;
  81228. readonly leftDegrees: number;
  81229. readonly rightDegrees: number;
  81230. readonly upDegrees: number;
  81231. }
  81232. interface VRFrameData {
  81233. readonly leftProjectionMatrix: Float32Array;
  81234. readonly leftViewMatrix: Float32Array;
  81235. readonly pose: VRPose;
  81236. readonly rightProjectionMatrix: Float32Array;
  81237. readonly rightViewMatrix: Float32Array;
  81238. readonly timestamp: number;
  81239. }
  81240. interface VRPose {
  81241. readonly angularAcceleration: Float32Array | null;
  81242. readonly angularVelocity: Float32Array | null;
  81243. readonly linearAcceleration: Float32Array | null;
  81244. readonly linearVelocity: Float32Array | null;
  81245. readonly orientation: Float32Array | null;
  81246. readonly position: Float32Array | null;
  81247. readonly timestamp: number;
  81248. }
  81249. interface VRStageParameters {
  81250. sittingToStandingTransform?: Float32Array;
  81251. sizeX?: number;
  81252. sizeY?: number;
  81253. }
  81254. interface Navigator {
  81255. getVRDisplays(): Promise<VRDisplay[]>;
  81256. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  81257. }
  81258. interface Window {
  81259. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  81260. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  81261. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  81262. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  81263. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  81264. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  81265. }
  81266. interface Gamepad {
  81267. readonly displayId: number;
  81268. }
  81269. /**
  81270. * Available session modes
  81271. */
  81272. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  81273. /**
  81274. * Reference space types
  81275. */
  81276. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  81277. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  81278. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  81279. /**
  81280. * Handedness types
  81281. */
  81282. type XRHandedness = "none" | "left" | "right";
  81283. /**
  81284. * InputSource target ray modes
  81285. */
  81286. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  81287. /**
  81288. * Eye types
  81289. */
  81290. type XREye = "none" | "left" | "right";
  81291. /**
  81292. * Type of XR events available
  81293. */
  81294. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  81295. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  81296. type XRPlaneSet = Set<XRPlane>;
  81297. type XRAnchorSet = Set<XRAnchor>;
  81298. type XREventHandler = (callback: any) => void;
  81299. interface XRLayer extends EventTarget {}
  81300. interface XRSessionInit {
  81301. optionalFeatures?: string[];
  81302. requiredFeatures?: string[];
  81303. }
  81304. interface XRSessionEvent extends Event {
  81305. readonly session: XRSession;
  81306. }
  81307. interface XRSystem {
  81308. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  81309. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  81310. }
  81311. interface XRViewport {
  81312. readonly x: number;
  81313. readonly y: number;
  81314. readonly width: number;
  81315. readonly height: number;
  81316. }
  81317. interface XRWebGLLayerInit {
  81318. antialias?: boolean;
  81319. depth?: boolean;
  81320. stencil?: boolean;
  81321. alpha?: boolean;
  81322. multiview?: boolean;
  81323. framebufferScaleFactor?: number;
  81324. }
  81325. declare class XRWebGLLayer {
  81326. static getNativeFramebufferScaleFactor(session: XRSession): number;
  81327. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  81328. readonly antialias: boolean;
  81329. readonly framebuffer: WebGLFramebuffer;
  81330. readonly framebufferWidth: number;
  81331. readonly framebufferHeight: number;
  81332. readonly ignoreDepthValues: boolean;
  81333. getViewport: (view: XRView) => XRViewport;
  81334. }
  81335. // tslint:disable-next-line no-empty-interface
  81336. interface XRSpace extends EventTarget {}
  81337. interface XRRenderState {
  81338. readonly baseLayer?: XRWebGLLayer;
  81339. readonly depthFar: number;
  81340. readonly depthNear: number;
  81341. readonly inlineVerticalFieldOfView?: number;
  81342. }
  81343. interface XRRenderStateInit extends XRRenderState {
  81344. baseLayer: XRWebGLLayer;
  81345. depthFar: number;
  81346. depthNear: number;
  81347. inlineVerticalFieldOfView?: number;
  81348. layers?: XRLayer[];
  81349. }
  81350. interface XRReferenceSpace extends XRSpace {
  81351. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  81352. onreset: XREventHandler;
  81353. }
  81354. interface XRBoundedReferenceSpace extends XRSpace {
  81355. readonly boundsGeometry: DOMPointReadOnly[];
  81356. }
  81357. interface XRInputSource {
  81358. readonly handedness: XRHandedness;
  81359. readonly targetRayMode: XRTargetRayMode;
  81360. readonly targetRaySpace: XRSpace;
  81361. readonly gripSpace?: XRSpace;
  81362. readonly gamepad?: Gamepad;
  81363. readonly profiles: Array<string>;
  81364. readonly hand?: XRHand;
  81365. }
  81366. interface XRPose {
  81367. readonly transform: XRRigidTransform;
  81368. readonly emulatedPosition: boolean;
  81369. }
  81370. interface XRWorldInformation {
  81371. detectedPlanes?: XRPlaneSet;
  81372. }
  81373. interface XRFrame {
  81374. readonly session: XRSession;
  81375. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  81376. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  81377. // AR
  81378. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  81379. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  81380. // Anchors
  81381. trackedAnchors?: XRAnchorSet;
  81382. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  81383. // World geometries
  81384. worldInformation?: XRWorldInformation;
  81385. // Hand tracking
  81386. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  81387. }
  81388. interface XRInputSourceEvent extends Event {
  81389. readonly frame: XRFrame;
  81390. readonly inputSource: XRInputSource;
  81391. }
  81392. type XRInputSourceArray = XRInputSource[];
  81393. interface XRSession {
  81394. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  81395. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  81396. /**
  81397. * Returns a list of this session's XRInputSources, each representing an input device
  81398. * used to control the camera and/or scene.
  81399. */
  81400. readonly inputSources: Array<XRInputSource>;
  81401. /**
  81402. * object which contains options affecting how the imagery is rendered.
  81403. * This includes things such as the near and far clipping planes
  81404. */
  81405. readonly renderState: XRRenderState;
  81406. readonly visibilityState: XRVisibilityState;
  81407. /**
  81408. * Removes a callback from the animation frame painting callback from
  81409. * XRSession's set of animation frame rendering callbacks, given the
  81410. * identifying handle returned by a previous call to requestAnimationFrame().
  81411. */
  81412. cancelAnimationFrame: (handle: number) => void;
  81413. /**
  81414. * Ends the WebXR session. Returns a promise which resolves when the
  81415. * session has been shut down.
  81416. */
  81417. end(): Promise<void>;
  81418. /**
  81419. * Schedules the specified method to be called the next time the user agent
  81420. * is working on rendering an animation frame for the WebXR device. Returns an
  81421. * integer value which can be used to identify the request for the purposes of
  81422. * canceling the callback using cancelAnimationFrame(). This method is comparable
  81423. * to the Window.requestAnimationFrame() method.
  81424. */
  81425. requestAnimationFrame: XRFrameRequestCallback;
  81426. /**
  81427. * Requests that a new XRReferenceSpace of the specified type be created.
  81428. * Returns a promise which resolves with the XRReferenceSpace or
  81429. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  81430. * the requested space type isn't supported by the device.
  81431. */
  81432. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  81433. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  81434. onend: XREventHandler;
  81435. oninputsourceschange: XREventHandler;
  81436. onselect: XREventHandler;
  81437. onselectstart: XREventHandler;
  81438. onselectend: XREventHandler;
  81439. onsqueeze: XREventHandler;
  81440. onsqueezestart: XREventHandler;
  81441. onsqueezeend: XREventHandler;
  81442. onvisibilitychange: XREventHandler;
  81443. // hit test
  81444. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  81445. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  81446. // legacy AR hit test
  81447. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  81448. // legacy plane detection
  81449. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  81450. }
  81451. interface XRViewerPose extends XRPose {
  81452. readonly views: Array<XRView>;
  81453. }
  81454. declare class XRRigidTransform {
  81455. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  81456. position: DOMPointReadOnly;
  81457. orientation: DOMPointReadOnly;
  81458. matrix: Float32Array;
  81459. inverse: XRRigidTransform;
  81460. }
  81461. interface XRView {
  81462. readonly eye: XREye;
  81463. readonly projectionMatrix: Float32Array;
  81464. readonly transform: XRRigidTransform;
  81465. readonly recommendedViewportScale?: number;
  81466. requestViewportScale(scale: number): void;
  81467. }
  81468. interface XRInputSourceChangeEvent extends Event {
  81469. session: XRSession;
  81470. removed: Array<XRInputSource>;
  81471. added: Array<XRInputSource>;
  81472. }
  81473. // Experimental/Draft features
  81474. declare class XRRay {
  81475. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  81476. origin: DOMPointReadOnly;
  81477. direction: DOMPointReadOnly;
  81478. matrix: Float32Array;
  81479. }
  81480. declare enum XRHitTestTrackableType {
  81481. "point",
  81482. "plane",
  81483. "mesh",
  81484. }
  81485. interface XRHitResult {
  81486. hitMatrix: Float32Array;
  81487. }
  81488. interface XRTransientInputHitTestResult {
  81489. readonly inputSource: XRInputSource;
  81490. readonly results: Array<XRHitTestResult>;
  81491. }
  81492. interface XRHitTestResult {
  81493. getPose(baseSpace: XRSpace): XRPose | undefined;
  81494. // When anchor system is enabled
  81495. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  81496. }
  81497. interface XRHitTestSource {
  81498. cancel(): void;
  81499. }
  81500. interface XRTransientInputHitTestSource {
  81501. cancel(): void;
  81502. }
  81503. interface XRHitTestOptionsInit {
  81504. space: XRSpace;
  81505. entityTypes?: Array<XRHitTestTrackableType>;
  81506. offsetRay?: XRRay;
  81507. }
  81508. interface XRTransientInputHitTestOptionsInit {
  81509. profile: string;
  81510. entityTypes?: Array<XRHitTestTrackableType>;
  81511. offsetRay?: XRRay;
  81512. }
  81513. interface XRAnchor {
  81514. anchorSpace: XRSpace;
  81515. delete(): void;
  81516. }
  81517. interface XRPlane {
  81518. orientation: "Horizontal" | "Vertical";
  81519. planeSpace: XRSpace;
  81520. polygon: Array<DOMPointReadOnly>;
  81521. lastChangedTime: number;
  81522. }
  81523. interface XRJointSpace extends XRSpace {}
  81524. interface XRJointPose extends XRPose {
  81525. radius: number | undefined;
  81526. }
  81527. interface XRHand extends Iterable<XRJointSpace> {
  81528. readonly length: number;
  81529. [index: number]: XRJointSpace;
  81530. readonly WRIST: number;
  81531. readonly THUMB_METACARPAL: number;
  81532. readonly THUMB_PHALANX_PROXIMAL: number;
  81533. readonly THUMB_PHALANX_DISTAL: number;
  81534. readonly THUMB_PHALANX_TIP: number;
  81535. readonly INDEX_METACARPAL: number;
  81536. readonly INDEX_PHALANX_PROXIMAL: number;
  81537. readonly INDEX_PHALANX_INTERMEDIATE: number;
  81538. readonly INDEX_PHALANX_DISTAL: number;
  81539. readonly INDEX_PHALANX_TIP: number;
  81540. readonly MIDDLE_METACARPAL: number;
  81541. readonly MIDDLE_PHALANX_PROXIMAL: number;
  81542. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  81543. readonly MIDDLE_PHALANX_DISTAL: number;
  81544. readonly MIDDLE_PHALANX_TIP: number;
  81545. readonly RING_METACARPAL: number;
  81546. readonly RING_PHALANX_PROXIMAL: number;
  81547. readonly RING_PHALANX_INTERMEDIATE: number;
  81548. readonly RING_PHALANX_DISTAL: number;
  81549. readonly RING_PHALANX_TIP: number;
  81550. readonly LITTLE_METACARPAL: number;
  81551. readonly LITTLE_PHALANX_PROXIMAL: number;
  81552. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  81553. readonly LITTLE_PHALANX_DISTAL: number;
  81554. readonly LITTLE_PHALANX_TIP: number;
  81555. }
  81556. // This file contains native only extensions for WebXR. These APIs are not supported in the browser yet.
  81557. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  81558. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  81559. type XRSceneObjectType = "unknown" | "background" | "wall" | "floor" | "ceiling" | "platform";
  81560. interface XRSceneObject {
  81561. type: XRSceneObjectType;
  81562. }
  81563. interface XRFieldOfView {
  81564. angleLeft: number;
  81565. angleRight: number;
  81566. angleUp: number;
  81567. angleDown: number;
  81568. }
  81569. interface XRFrustum {
  81570. position: DOMPointReadOnly;
  81571. orientation: DOMPointReadOnly;
  81572. fieldOfView: XRFieldOfView;
  81573. farDistance: number;
  81574. }
  81575. interface XRPlane {
  81576. parentSceneObject?: XRSceneObject;
  81577. }
  81578. interface XRMesh {
  81579. meshSpace: XRSpace;
  81580. positions: Float32Array;
  81581. indices: Uint32Array;
  81582. normals?: Float32Array;
  81583. lastChangedTime: number;
  81584. parentSceneObject?: XRSceneObject;
  81585. }
  81586. interface XRFrustumDetectionBoundary {
  81587. type: "frustum";
  81588. frustum: XRFrustum;
  81589. }
  81590. interface XRSphereDetectionBoundary {
  81591. type: "sphere";
  81592. radius: number;
  81593. }
  81594. interface XRBoxDetectionBoundary {
  81595. type: "box";
  81596. extent: DOMPointReadOnly;
  81597. }
  81598. type XRDetectionBoundary = XRFrustumDetectionBoundary | XRSphereDetectionBoundary | XRBoxDetectionBoundary;
  81599. interface XRGeometryDetectorOptions {
  81600. detectionBoundary?: XRDetectionBoundary;
  81601. updateInterval?: number;
  81602. }
  81603. interface XRSession {
  81604. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  81605. trySetPreferredPlaneDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  81606. trySetMeshDetectorEnabled(enabled: boolean): boolean;
  81607. trySetPreferredMeshDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  81608. }
  81609. interface XRFrame {
  81610. featurePointCloud?: Array<number>;
  81611. }
  81612. type XRMeshSet = Set<XRMesh>;
  81613. interface XRWorldInformation {
  81614. detectedMeshes?: XRMeshSet;
  81615. }
  81616. /**
  81617. * @ignore
  81618. */
  81619. declare module BABYLON.GLTF2.Exporter {
  81620. }
  81621. /**
  81622. * @ignore
  81623. */
  81624. declare module BABYLON.GLTF1 {
  81625. }
  81626. declare module BABYLON.GUI {
  81627. /**
  81628. * Interface used to define a control that can receive focus
  81629. */
  81630. export interface IFocusableControl {
  81631. /**
  81632. * Function called when the control receives the focus
  81633. */
  81634. onFocus(): void;
  81635. /**
  81636. * Function called when the control loses the focus
  81637. */
  81638. onBlur(): void;
  81639. /**
  81640. * Function called to let the control handle keyboard events
  81641. * @param evt defines the current keyboard event
  81642. */
  81643. processKeyboard(evt: KeyboardEvent): void;
  81644. /**
  81645. * Function called to get the list of controls that should not steal the focus from this control
  81646. * @returns an array of controls
  81647. */
  81648. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  81649. /**
  81650. * Function to focus the control programmatically
  81651. */
  81652. focus(): void;
  81653. /**
  81654. * Function to unfocus the control programmatically
  81655. */
  81656. blur(): void;
  81657. }
  81658. }
  81659. declare module BABYLON.GUI {
  81660. /**
  81661. * Class used to specific a value and its associated unit
  81662. */
  81663. export class ValueAndUnit {
  81664. /** defines the unit to store */
  81665. unit: number;
  81666. /** defines a boolean indicating if the value can be negative */
  81667. negativeValueAllowed: boolean;
  81668. private _value;
  81669. private _originalUnit;
  81670. /**
  81671. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  81672. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  81673. */
  81674. ignoreAdaptiveScaling: boolean;
  81675. /**
  81676. * Creates a new ValueAndUnit
  81677. * @param value defines the value to store
  81678. * @param unit defines the unit to store
  81679. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  81680. */
  81681. constructor(value: number,
  81682. /** defines the unit to store */
  81683. unit?: number,
  81684. /** defines a boolean indicating if the value can be negative */
  81685. negativeValueAllowed?: boolean);
  81686. /** Gets a boolean indicating if the value is a percentage */
  81687. get isPercentage(): boolean;
  81688. /** Gets a boolean indicating if the value is store as pixel */
  81689. get isPixel(): boolean;
  81690. /** Gets direct internal value */
  81691. get internalValue(): number;
  81692. /**
  81693. * Gets value as pixel
  81694. * @param host defines the root host
  81695. * @param refValue defines the reference value for percentages
  81696. * @returns the value as pixel
  81697. */
  81698. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  81699. /**
  81700. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  81701. * @param value defines the value to store
  81702. * @param unit defines the unit to store
  81703. * @returns the current ValueAndUnit
  81704. */
  81705. updateInPlace(value: number, unit?: number): ValueAndUnit;
  81706. /**
  81707. * Gets the value accordingly to its unit
  81708. * @param host defines the root host
  81709. * @returns the value
  81710. */
  81711. getValue(host: AdvancedDynamicTexture): number;
  81712. /**
  81713. * Gets a string representation of the value
  81714. * @param host defines the root host
  81715. * @param decimals defines an optional number of decimals to display
  81716. * @returns a string
  81717. */
  81718. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  81719. /**
  81720. * Store a value parsed from a string
  81721. * @param source defines the source string
  81722. * @returns true if the value was successfully parsed
  81723. */
  81724. fromString(source: string | number): boolean;
  81725. private static _Regex;
  81726. private static _UNITMODE_PERCENTAGE;
  81727. private static _UNITMODE_PIXEL;
  81728. /** UNITMODE_PERCENTAGE */
  81729. static get UNITMODE_PERCENTAGE(): number;
  81730. /** UNITMODE_PIXEL */
  81731. static get UNITMODE_PIXEL(): number;
  81732. }
  81733. }
  81734. declare module BABYLON.GUI {
  81735. /**
  81736. * Define a style used by control to automatically setup properties based on a template.
  81737. * Only support font related properties so far
  81738. */
  81739. export class Style implements BABYLON.IDisposable {
  81740. private _fontFamily;
  81741. private _fontStyle;
  81742. private _fontWeight;
  81743. /** @hidden */
  81744. _host: AdvancedDynamicTexture;
  81745. /** @hidden */
  81746. _fontSize: ValueAndUnit;
  81747. /**
  81748. * BABYLON.Observable raised when the style values are changed
  81749. */
  81750. onChangedObservable: BABYLON.Observable<Style>;
  81751. /**
  81752. * Creates a new style object
  81753. * @param host defines the AdvancedDynamicTexture which hosts this style
  81754. */
  81755. constructor(host: AdvancedDynamicTexture);
  81756. /**
  81757. * Gets or sets the font size
  81758. */
  81759. get fontSize(): string | number;
  81760. set fontSize(value: string | number);
  81761. /**
  81762. * Gets or sets the font family
  81763. */
  81764. get fontFamily(): string;
  81765. set fontFamily(value: string);
  81766. /**
  81767. * Gets or sets the font style
  81768. */
  81769. get fontStyle(): string;
  81770. set fontStyle(value: string);
  81771. /** Gets or sets font weight */
  81772. get fontWeight(): string;
  81773. set fontWeight(value: string);
  81774. /** Dispose all associated resources */
  81775. dispose(): void;
  81776. }
  81777. }
  81778. declare module BABYLON.GUI {
  81779. /**
  81780. * Class used to transport BABYLON.Vector2 information for pointer events
  81781. */
  81782. export class Vector2WithInfo extends BABYLON.Vector2 {
  81783. /** defines the current mouse button index */
  81784. buttonIndex: number;
  81785. /**
  81786. * Creates a new Vector2WithInfo
  81787. * @param source defines the vector2 data to transport
  81788. * @param buttonIndex defines the current mouse button index
  81789. */
  81790. constructor(source: BABYLON.Vector2,
  81791. /** defines the current mouse button index */
  81792. buttonIndex?: number);
  81793. }
  81794. /** Class used to provide 2D matrix features */
  81795. export class Matrix2D {
  81796. /** Gets the internal array of 6 floats used to store matrix data */
  81797. m: Float32Array;
  81798. /**
  81799. * Creates a new matrix
  81800. * @param m00 defines value for (0, 0)
  81801. * @param m01 defines value for (0, 1)
  81802. * @param m10 defines value for (1, 0)
  81803. * @param m11 defines value for (1, 1)
  81804. * @param m20 defines value for (2, 0)
  81805. * @param m21 defines value for (2, 1)
  81806. */
  81807. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  81808. /**
  81809. * Fills the matrix from direct values
  81810. * @param m00 defines value for (0, 0)
  81811. * @param m01 defines value for (0, 1)
  81812. * @param m10 defines value for (1, 0)
  81813. * @param m11 defines value for (1, 1)
  81814. * @param m20 defines value for (2, 0)
  81815. * @param m21 defines value for (2, 1)
  81816. * @returns the current modified matrix
  81817. */
  81818. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  81819. /**
  81820. * Gets matrix determinant
  81821. * @returns the determinant
  81822. */
  81823. determinant(): number;
  81824. /**
  81825. * Inverses the matrix and stores it in a target matrix
  81826. * @param result defines the target matrix
  81827. * @returns the current matrix
  81828. */
  81829. invertToRef(result: Matrix2D): Matrix2D;
  81830. /**
  81831. * Multiplies the current matrix with another one
  81832. * @param other defines the second operand
  81833. * @param result defines the target matrix
  81834. * @returns the current matrix
  81835. */
  81836. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  81837. /**
  81838. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  81839. * @param x defines the x coordinate to transform
  81840. * @param y defines the x coordinate to transform
  81841. * @param result defines the target vector2
  81842. * @returns the current matrix
  81843. */
  81844. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  81845. /**
  81846. * Creates an identity matrix
  81847. * @returns a new matrix
  81848. */
  81849. static Identity(): Matrix2D;
  81850. /**
  81851. * Creates a translation matrix and stores it in a target matrix
  81852. * @param x defines the x coordinate of the translation
  81853. * @param y defines the y coordinate of the translation
  81854. * @param result defines the target matrix
  81855. */
  81856. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  81857. /**
  81858. * Creates a scaling matrix and stores it in a target matrix
  81859. * @param x defines the x coordinate of the scaling
  81860. * @param y defines the y coordinate of the scaling
  81861. * @param result defines the target matrix
  81862. */
  81863. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  81864. /**
  81865. * Creates a rotation matrix and stores it in a target matrix
  81866. * @param angle defines the rotation angle
  81867. * @param result defines the target matrix
  81868. */
  81869. static RotationToRef(angle: number, result: Matrix2D): void;
  81870. private static _TempPreTranslationMatrix;
  81871. private static _TempPostTranslationMatrix;
  81872. private static _TempRotationMatrix;
  81873. private static _TempScalingMatrix;
  81874. private static _TempCompose0;
  81875. private static _TempCompose1;
  81876. private static _TempCompose2;
  81877. /**
  81878. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  81879. * @param tx defines the x coordinate of the translation
  81880. * @param ty defines the y coordinate of the translation
  81881. * @param angle defines the rotation angle
  81882. * @param scaleX defines the x coordinate of the scaling
  81883. * @param scaleY defines the y coordinate of the scaling
  81884. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  81885. * @param result defines the target matrix
  81886. */
  81887. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  81888. }
  81889. }
  81890. declare module BABYLON.GUI {
  81891. /**
  81892. * Class used to store 2D control sizes
  81893. */
  81894. export class Measure {
  81895. /** defines left coordinate */
  81896. left: number;
  81897. /** defines top coordinate */
  81898. top: number;
  81899. /** defines width dimension */
  81900. width: number;
  81901. /** defines height dimension */
  81902. height: number;
  81903. /**
  81904. * Creates a new measure
  81905. * @param left defines left coordinate
  81906. * @param top defines top coordinate
  81907. * @param width defines width dimension
  81908. * @param height defines height dimension
  81909. */
  81910. constructor(
  81911. /** defines left coordinate */
  81912. left: number,
  81913. /** defines top coordinate */
  81914. top: number,
  81915. /** defines width dimension */
  81916. width: number,
  81917. /** defines height dimension */
  81918. height: number);
  81919. /**
  81920. * Copy from another measure
  81921. * @param other defines the other measure to copy from
  81922. */
  81923. copyFrom(other: Measure): void;
  81924. /**
  81925. * Copy from a group of 4 floats
  81926. * @param left defines left coordinate
  81927. * @param top defines top coordinate
  81928. * @param width defines width dimension
  81929. * @param height defines height dimension
  81930. */
  81931. copyFromFloats(left: number, top: number, width: number, height: number): void;
  81932. /**
  81933. * Computes the axis aligned bounding box measure for two given measures
  81934. * @param a Input measure
  81935. * @param b Input measure
  81936. * @param result the resulting bounding measure
  81937. */
  81938. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  81939. /**
  81940. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  81941. * @param transform the matrix to transform the measure before computing the AABB
  81942. * @param addX number to add to left
  81943. * @param addY number to add to top
  81944. * @param addWidth number to add to width
  81945. * @param addHeight number to add to height
  81946. * @param result the resulting AABB
  81947. */
  81948. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  81949. /**
  81950. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  81951. * @param transform the matrix to transform the measure before computing the AABB
  81952. * @param result the resulting AABB
  81953. */
  81954. transformToRef(transform: Matrix2D, result: Measure): void;
  81955. /**
  81956. * Check equality between this measure and another one
  81957. * @param other defines the other measures
  81958. * @returns true if both measures are equals
  81959. */
  81960. isEqualsTo(other: Measure): boolean;
  81961. /**
  81962. * Creates an empty measure
  81963. * @returns a new measure
  81964. */
  81965. static Empty(): Measure;
  81966. }
  81967. }
  81968. declare module BABYLON.GUI {
  81969. /**
  81970. * Class used to create texture to support 2D GUI elements
  81971. * @see https://doc.babylonjs.com/how_to/gui
  81972. */
  81973. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  81974. private _isDirty;
  81975. private _renderObserver;
  81976. private _resizeObserver;
  81977. private _preKeyboardObserver;
  81978. private _pointerMoveObserver;
  81979. private _pointerObserver;
  81980. private _canvasPointerOutObserver;
  81981. private _canvasBlurObserver;
  81982. private _background;
  81983. /** @hidden */
  81984. _rootContainer: Container;
  81985. /** @hidden */
  81986. _lastPickedControl: Control;
  81987. /** @hidden */
  81988. _lastControlOver: {
  81989. [pointerId: number]: Control;
  81990. };
  81991. /** @hidden */
  81992. _lastControlDown: {
  81993. [pointerId: number]: Control;
  81994. };
  81995. /** @hidden */
  81996. _capturingControl: {
  81997. [pointerId: number]: Control;
  81998. };
  81999. /** @hidden */
  82000. _shouldBlockPointer: boolean;
  82001. /** @hidden */
  82002. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  82003. /** @hidden */
  82004. _linkedControls: Control[];
  82005. private _isFullscreen;
  82006. private _fullscreenViewport;
  82007. private _idealWidth;
  82008. private _idealHeight;
  82009. private _useSmallestIdeal;
  82010. private _renderAtIdealSize;
  82011. private _focusedControl;
  82012. private _blockNextFocusCheck;
  82013. private _renderScale;
  82014. private _rootElement;
  82015. private _cursorChanged;
  82016. private _defaultMousePointerId;
  82017. /** @hidden */
  82018. _numLayoutCalls: number;
  82019. /** Gets the number of layout calls made the last time the ADT has been rendered */
  82020. get numLayoutCalls(): number;
  82021. /** @hidden */
  82022. _numRenderCalls: number;
  82023. /** Gets the number of render calls made the last time the ADT has been rendered */
  82024. get numRenderCalls(): number;
  82025. /**
  82026. * Define type to string to ensure compatibility across browsers
  82027. * Safari doesn't support DataTransfer constructor
  82028. */
  82029. private _clipboardData;
  82030. /**
  82031. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  82032. */
  82033. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  82034. /**
  82035. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  82036. */
  82037. onControlPickedObservable: BABYLON.Observable<Control>;
  82038. /**
  82039. * BABYLON.Observable event triggered before layout is evaluated
  82040. */
  82041. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82042. /**
  82043. * BABYLON.Observable event triggered after the layout was evaluated
  82044. */
  82045. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82046. /**
  82047. * BABYLON.Observable event triggered before the texture is rendered
  82048. */
  82049. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82050. /**
  82051. * BABYLON.Observable event triggered after the texture was rendered
  82052. */
  82053. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82054. /**
  82055. * Gets or sets a boolean defining if alpha is stored as premultiplied
  82056. */
  82057. premulAlpha: boolean;
  82058. /**
  82059. * Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
  82060. */
  82061. applyYInversionOnUpdate: boolean;
  82062. /**
  82063. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  82064. * Useful when you want more antialiasing
  82065. */
  82066. get renderScale(): number;
  82067. set renderScale(value: number);
  82068. /** Gets or sets the background color */
  82069. get background(): string;
  82070. set background(value: string);
  82071. /**
  82072. * Gets or sets the ideal width used to design controls.
  82073. * The GUI will then rescale everything accordingly
  82074. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82075. */
  82076. get idealWidth(): number;
  82077. set idealWidth(value: number);
  82078. /**
  82079. * Gets or sets the ideal height used to design controls.
  82080. * The GUI will then rescale everything accordingly
  82081. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82082. */
  82083. get idealHeight(): number;
  82084. set idealHeight(value: number);
  82085. /**
  82086. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  82087. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82088. */
  82089. get useSmallestIdeal(): boolean;
  82090. set useSmallestIdeal(value: boolean);
  82091. /**
  82092. * Gets or sets a boolean indicating if adaptive scaling must be used
  82093. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82094. */
  82095. get renderAtIdealSize(): boolean;
  82096. set renderAtIdealSize(value: boolean);
  82097. /**
  82098. * Gets the ratio used when in "ideal mode"
  82099. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82100. * */
  82101. get idealRatio(): number;
  82102. /**
  82103. * Gets the underlying layer used to render the texture when in fullscreen mode
  82104. */
  82105. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  82106. /**
  82107. * Gets the root container control
  82108. */
  82109. get rootContainer(): Container;
  82110. /**
  82111. * Returns an array containing the root container.
  82112. * This is mostly used to let the Inspector introspects the ADT
  82113. * @returns an array containing the rootContainer
  82114. */
  82115. getChildren(): Array<Container>;
  82116. /**
  82117. * Will return all controls that are inside this texture
  82118. * @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
  82119. * @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
  82120. * @return all child controls
  82121. */
  82122. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  82123. /**
  82124. * Gets or sets the current focused control
  82125. */
  82126. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  82127. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  82128. /**
  82129. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  82130. */
  82131. get isForeground(): boolean;
  82132. set isForeground(value: boolean);
  82133. /**
  82134. * Gets or set information about clipboardData
  82135. */
  82136. get clipboardData(): string;
  82137. set clipboardData(value: string);
  82138. /**
  82139. * Creates a new AdvancedDynamicTexture
  82140. * @param name defines the name of the texture
  82141. * @param width defines the width of the texture
  82142. * @param height defines the height of the texture
  82143. * @param scene defines the hosting scene
  82144. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  82145. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  82146. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  82147. */
  82148. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  82149. /**
  82150. * Get the current class name of the texture useful for serialization or dynamic coding.
  82151. * @returns "AdvancedDynamicTexture"
  82152. */
  82153. getClassName(): string;
  82154. /**
  82155. * Function used to execute a function on all controls
  82156. * @param func defines the function to execute
  82157. * @param container defines the container where controls belong. If null the root container will be used
  82158. */
  82159. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  82160. private _useInvalidateRectOptimization;
  82161. /**
  82162. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  82163. */
  82164. get useInvalidateRectOptimization(): boolean;
  82165. set useInvalidateRectOptimization(value: boolean);
  82166. private _invalidatedRectangle;
  82167. /**
  82168. * Invalidates a rectangle area on the gui texture
  82169. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  82170. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  82171. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  82172. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  82173. */
  82174. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  82175. /**
  82176. * Marks the texture as dirty forcing a complete update
  82177. */
  82178. markAsDirty(): void;
  82179. /**
  82180. * Helper function used to create a new style
  82181. * @returns a new style
  82182. * @see https://doc.babylonjs.com/how_to/gui#styles
  82183. */
  82184. createStyle(): Style;
  82185. /**
  82186. * Adds a new control to the root container
  82187. * @param control defines the control to add
  82188. * @returns the current texture
  82189. */
  82190. addControl(control: Control): AdvancedDynamicTexture;
  82191. /**
  82192. * Removes a control from the root container
  82193. * @param control defines the control to remove
  82194. * @returns the current texture
  82195. */
  82196. removeControl(control: Control): AdvancedDynamicTexture;
  82197. /**
  82198. * Release all resources
  82199. */
  82200. dispose(): void;
  82201. private _onResize;
  82202. /** @hidden */
  82203. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  82204. /**
  82205. * Get screen coordinates for a vector3
  82206. * @param position defines the position to project
  82207. * @param worldMatrix defines the world matrix to use
  82208. * @returns the projected position
  82209. */
  82210. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  82211. /**
  82212. * Get screen coordinates for a vector3
  82213. * @param position defines the position to project
  82214. * @param worldMatrix defines the world matrix to use
  82215. * @returns the projected position with Z
  82216. */
  82217. getProjectedPositionWithZ(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector3;
  82218. private _checkUpdate;
  82219. private _clearMeasure;
  82220. private _render;
  82221. /** @hidden */
  82222. _changeCursor(cursor: string): void;
  82223. /** @hidden */
  82224. _registerLastControlDown(control: Control, pointerId: number): void;
  82225. private _doPicking;
  82226. /** @hidden */
  82227. _cleanControlAfterRemovalFromList(list: {
  82228. [pointerId: number]: Control;
  82229. }, control: Control): void;
  82230. /** @hidden */
  82231. _cleanControlAfterRemoval(control: Control): void;
  82232. /** Attach to all scene events required to support pointer events */
  82233. attach(): void;
  82234. /** @hidden */
  82235. private onClipboardCopy;
  82236. /** @hidden */
  82237. private onClipboardCut;
  82238. /** @hidden */
  82239. private onClipboardPaste;
  82240. /**
  82241. * Register the clipboard Events onto the canvas
  82242. */
  82243. registerClipboardEvents(): void;
  82244. /**
  82245. * Unregister the clipboard Events from the canvas
  82246. */
  82247. unRegisterClipboardEvents(): void;
  82248. /**
  82249. * Connect the texture to a hosting mesh to enable interactions
  82250. * @param mesh defines the mesh to attach to
  82251. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  82252. */
  82253. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  82254. /**
  82255. * Move the focus to a specific control
  82256. * @param control defines the control which will receive the focus
  82257. */
  82258. moveFocusToControl(control: IFocusableControl): void;
  82259. private _manageFocus;
  82260. private _attachToOnPointerOut;
  82261. private _attachToOnBlur;
  82262. /**
  82263. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  82264. * @param mesh defines the mesh which will receive the texture
  82265. * @param width defines the texture width (1024 by default)
  82266. * @param height defines the texture height (1024 by default)
  82267. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  82268. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  82269. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  82270. * @returns a new AdvancedDynamicTexture
  82271. */
  82272. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  82273. /**
  82274. * 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
  82275. * @param mesh defines the mesh which will receive the texture
  82276. * @param width defines the texture width (1024 by default)
  82277. * @param height defines the texture height (1024 by default)
  82278. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  82279. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  82280. * @returns a new AdvancedDynamicTexture
  82281. */
  82282. static CreateForMeshTexture(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  82283. /**
  82284. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  82285. * In this mode the texture will rely on a layer for its rendering.
  82286. * This allows it to be treated like any other layer.
  82287. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  82288. * LayerMask is set through advancedTexture.layer.layerMask
  82289. * @param name defines name for the texture
  82290. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  82291. * @param scene defines the hsoting scene
  82292. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  82293. * @returns a new AdvancedDynamicTexture
  82294. */
  82295. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  82296. }
  82297. }
  82298. declare module BABYLON.GUI {
  82299. /**
  82300. * Root class used for all 2D controls
  82301. * @see https://doc.babylonjs.com/how_to/gui#controls
  82302. */
  82303. export class Control {
  82304. /** defines the name of the control */
  82305. name?: string | undefined;
  82306. /**
  82307. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  82308. */
  82309. static AllowAlphaInheritance: boolean;
  82310. private _alpha;
  82311. private _alphaSet;
  82312. private _zIndex;
  82313. /** @hidden */
  82314. _host: AdvancedDynamicTexture;
  82315. /** Gets or sets the control parent */
  82316. parent: BABYLON.Nullable<Container>;
  82317. /** @hidden */
  82318. _currentMeasure: Measure;
  82319. private _fontFamily;
  82320. private _fontStyle;
  82321. private _fontWeight;
  82322. private _fontSize;
  82323. private _font;
  82324. /** @hidden */
  82325. _width: ValueAndUnit;
  82326. /** @hidden */
  82327. _height: ValueAndUnit;
  82328. /** @hidden */
  82329. protected _fontOffset: {
  82330. ascent: number;
  82331. height: number;
  82332. descent: number;
  82333. };
  82334. private _color;
  82335. private _style;
  82336. private _styleObserver;
  82337. /** @hidden */
  82338. protected _horizontalAlignment: number;
  82339. /** @hidden */
  82340. protected _verticalAlignment: number;
  82341. /** @hidden */
  82342. protected _isDirty: boolean;
  82343. /** @hidden */
  82344. protected _wasDirty: boolean;
  82345. /** @hidden */
  82346. _tempParentMeasure: Measure;
  82347. /** @hidden */
  82348. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  82349. /** @hidden */
  82350. protected _cachedParentMeasure: Measure;
  82351. private _paddingLeft;
  82352. private _paddingRight;
  82353. private _paddingTop;
  82354. private _paddingBottom;
  82355. /** @hidden */
  82356. _left: ValueAndUnit;
  82357. /** @hidden */
  82358. _top: ValueAndUnit;
  82359. private _scaleX;
  82360. private _scaleY;
  82361. private _rotation;
  82362. private _transformCenterX;
  82363. private _transformCenterY;
  82364. /** @hidden */
  82365. _transformMatrix: Matrix2D;
  82366. /** @hidden */
  82367. protected _invertTransformMatrix: Matrix2D;
  82368. /** @hidden */
  82369. protected _transformedPosition: BABYLON.Vector2;
  82370. private _isMatrixDirty;
  82371. private _cachedOffsetX;
  82372. private _cachedOffsetY;
  82373. private _isVisible;
  82374. private _isHighlighted;
  82375. /** @hidden */
  82376. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  82377. private _fontSet;
  82378. private _dummyVector2;
  82379. private _downCount;
  82380. private _enterCount;
  82381. private _doNotRender;
  82382. private _downPointerIds;
  82383. protected _isEnabled: boolean;
  82384. protected _disabledColor: string;
  82385. protected _disabledColorItem: string;
  82386. /** @hidden */
  82387. protected _rebuildLayout: boolean;
  82388. /** @hidden */
  82389. _customData: any;
  82390. /** @hidden */
  82391. _isClipped: boolean;
  82392. /** @hidden */
  82393. _automaticSize: boolean;
  82394. /** @hidden */
  82395. _tag: any;
  82396. /**
  82397. * 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
  82398. */
  82399. uniqueId: number;
  82400. /**
  82401. * Gets or sets an object used to store user defined information for the node
  82402. */
  82403. metadata: any;
  82404. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  82405. isHitTestVisible: boolean;
  82406. /** Gets or sets a boolean indicating if the control can block pointer events */
  82407. isPointerBlocker: boolean;
  82408. /** Gets or sets a boolean indicating if the control can be focusable */
  82409. isFocusInvisible: boolean;
  82410. /**
  82411. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  82412. * 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
  82413. */
  82414. clipChildren: boolean;
  82415. /**
  82416. * Gets or sets a boolean indicating that control content must be clipped
  82417. * 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
  82418. */
  82419. clipContent: boolean;
  82420. /**
  82421. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  82422. */
  82423. useBitmapCache: boolean;
  82424. private _cacheData;
  82425. private _shadowOffsetX;
  82426. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  82427. get shadowOffsetX(): number;
  82428. set shadowOffsetX(value: number);
  82429. private _shadowOffsetY;
  82430. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  82431. get shadowOffsetY(): number;
  82432. set shadowOffsetY(value: number);
  82433. private _shadowBlur;
  82434. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  82435. get shadowBlur(): number;
  82436. set shadowBlur(value: number);
  82437. private _shadowColor;
  82438. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  82439. get shadowColor(): string;
  82440. set shadowColor(value: string);
  82441. /** Gets or sets the cursor to use when the control is hovered */
  82442. hoverCursor: string;
  82443. /** @hidden */
  82444. protected _linkOffsetX: ValueAndUnit;
  82445. /** @hidden */
  82446. protected _linkOffsetY: ValueAndUnit;
  82447. /** Gets the control type name */
  82448. get typeName(): string;
  82449. /**
  82450. * Get the current class name of the control.
  82451. * @returns current class name
  82452. */
  82453. getClassName(): string;
  82454. /**
  82455. * An event triggered when pointer wheel is scrolled
  82456. */
  82457. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  82458. /**
  82459. * An event triggered when the pointer move over the control.
  82460. */
  82461. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  82462. /**
  82463. * An event triggered when the pointer move out of the control.
  82464. */
  82465. onPointerOutObservable: BABYLON.Observable<Control>;
  82466. /**
  82467. * An event triggered when the pointer taps the control
  82468. */
  82469. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  82470. /**
  82471. * An event triggered when pointer up
  82472. */
  82473. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  82474. /**
  82475. * An event triggered when a control is clicked on
  82476. */
  82477. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  82478. /**
  82479. * An event triggered when pointer enters the control
  82480. */
  82481. onPointerEnterObservable: BABYLON.Observable<Control>;
  82482. /**
  82483. * An event triggered when the control is marked as dirty
  82484. */
  82485. onDirtyObservable: BABYLON.Observable<Control>;
  82486. /**
  82487. * An event triggered before drawing the control
  82488. */
  82489. onBeforeDrawObservable: BABYLON.Observable<Control>;
  82490. /**
  82491. * An event triggered after the control was drawn
  82492. */
  82493. onAfterDrawObservable: BABYLON.Observable<Control>;
  82494. /**
  82495. * An event triggered when the control has been disposed
  82496. */
  82497. onDisposeObservable: BABYLON.Observable<Control>;
  82498. /**
  82499. * Get the hosting AdvancedDynamicTexture
  82500. */
  82501. get host(): AdvancedDynamicTexture;
  82502. /** Gets or set information about font offsets (used to render and align text) */
  82503. get fontOffset(): {
  82504. ascent: number;
  82505. height: number;
  82506. descent: number;
  82507. };
  82508. set fontOffset(offset: {
  82509. ascent: number;
  82510. height: number;
  82511. descent: number;
  82512. });
  82513. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  82514. get alpha(): number;
  82515. set alpha(value: number);
  82516. /**
  82517. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  82518. */
  82519. get isHighlighted(): boolean;
  82520. set isHighlighted(value: boolean);
  82521. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  82522. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  82523. */
  82524. get scaleX(): number;
  82525. set scaleX(value: number);
  82526. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  82527. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  82528. */
  82529. get scaleY(): number;
  82530. set scaleY(value: number);
  82531. /** Gets or sets the rotation angle (0 by default)
  82532. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  82533. */
  82534. get rotation(): number;
  82535. set rotation(value: number);
  82536. /** Gets or sets the transformation center on Y axis (0 by default)
  82537. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  82538. */
  82539. get transformCenterY(): number;
  82540. set transformCenterY(value: number);
  82541. /** Gets or sets the transformation center on X axis (0 by default)
  82542. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  82543. */
  82544. get transformCenterX(): number;
  82545. set transformCenterX(value: number);
  82546. /**
  82547. * Gets or sets the horizontal alignment
  82548. * @see https://doc.babylonjs.com/how_to/gui#alignments
  82549. */
  82550. get horizontalAlignment(): number;
  82551. set horizontalAlignment(value: number);
  82552. /**
  82553. * Gets or sets the vertical alignment
  82554. * @see https://doc.babylonjs.com/how_to/gui#alignments
  82555. */
  82556. get verticalAlignment(): number;
  82557. set verticalAlignment(value: number);
  82558. /**
  82559. * Gets or sets a fixed ratio for this control.
  82560. * When different from 0, the ratio is used to compute the "second" dimension.
  82561. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  82562. * second dimension is computed as first dimension * fixedRatio
  82563. */
  82564. fixedRatio: number;
  82565. private _fixedRatioMasterIsWidth;
  82566. /**
  82567. * Gets or sets control width
  82568. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82569. */
  82570. get width(): string | number;
  82571. set width(value: string | number);
  82572. /**
  82573. * Gets or sets the control width in pixel
  82574. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82575. */
  82576. get widthInPixels(): number;
  82577. set widthInPixels(value: number);
  82578. /**
  82579. * Gets or sets control height
  82580. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82581. */
  82582. get height(): string | number;
  82583. set height(value: string | number);
  82584. /**
  82585. * Gets or sets control height in pixel
  82586. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82587. */
  82588. get heightInPixels(): number;
  82589. set heightInPixels(value: number);
  82590. /** Gets or set font family */
  82591. get fontFamily(): string;
  82592. set fontFamily(value: string);
  82593. /** Gets or sets font style */
  82594. get fontStyle(): string;
  82595. set fontStyle(value: string);
  82596. /** Gets or sets font weight */
  82597. get fontWeight(): string;
  82598. set fontWeight(value: string);
  82599. /**
  82600. * Gets or sets style
  82601. * @see https://doc.babylonjs.com/how_to/gui#styles
  82602. */
  82603. get style(): BABYLON.Nullable<Style>;
  82604. set style(value: BABYLON.Nullable<Style>);
  82605. /** @hidden */
  82606. get _isFontSizeInPercentage(): boolean;
  82607. /** Gets or sets font size in pixels */
  82608. get fontSizeInPixels(): number;
  82609. set fontSizeInPixels(value: number);
  82610. /** Gets or sets font size */
  82611. get fontSize(): string | number;
  82612. set fontSize(value: string | number);
  82613. /** Gets or sets foreground color */
  82614. get color(): string;
  82615. set color(value: string);
  82616. /** Gets or sets z index which is used to reorder controls on the z axis */
  82617. get zIndex(): number;
  82618. set zIndex(value: number);
  82619. /** Gets or sets a boolean indicating if the control can be rendered */
  82620. get notRenderable(): boolean;
  82621. set notRenderable(value: boolean);
  82622. /** Gets or sets a boolean indicating if the control is visible */
  82623. get isVisible(): boolean;
  82624. set isVisible(value: boolean);
  82625. /** Gets a boolean indicating that the control needs to update its rendering */
  82626. get isDirty(): boolean;
  82627. /**
  82628. * Gets the current linked mesh (or null if none)
  82629. */
  82630. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  82631. /**
  82632. * Gets or sets a value indicating the padding to use on the left of the control
  82633. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82634. */
  82635. get paddingLeft(): string | number;
  82636. set paddingLeft(value: string | number);
  82637. /**
  82638. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  82639. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82640. */
  82641. get paddingLeftInPixels(): number;
  82642. set paddingLeftInPixels(value: number);
  82643. /**
  82644. * Gets or sets a value indicating the padding to use on the right of the control
  82645. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82646. */
  82647. get paddingRight(): string | number;
  82648. set paddingRight(value: string | number);
  82649. /**
  82650. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  82651. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82652. */
  82653. get paddingRightInPixels(): number;
  82654. set paddingRightInPixels(value: number);
  82655. /**
  82656. * Gets or sets a value indicating the padding to use on the top of the control
  82657. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82658. */
  82659. get paddingTop(): string | number;
  82660. set paddingTop(value: string | number);
  82661. /**
  82662. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  82663. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82664. */
  82665. get paddingTopInPixels(): number;
  82666. set paddingTopInPixels(value: number);
  82667. /**
  82668. * Gets or sets a value indicating the padding to use on the bottom of the control
  82669. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82670. */
  82671. get paddingBottom(): string | number;
  82672. set paddingBottom(value: string | number);
  82673. /**
  82674. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  82675. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82676. */
  82677. get paddingBottomInPixels(): number;
  82678. set paddingBottomInPixels(value: number);
  82679. /**
  82680. * Gets or sets a value indicating the left coordinate of the control
  82681. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82682. */
  82683. get left(): string | number;
  82684. set left(value: string | number);
  82685. /**
  82686. * Gets or sets a value indicating the left coordinate in pixels of the control
  82687. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82688. */
  82689. get leftInPixels(): number;
  82690. set leftInPixels(value: number);
  82691. /**
  82692. * Gets or sets a value indicating the top coordinate of the control
  82693. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82694. */
  82695. get top(): string | number;
  82696. set top(value: string | number);
  82697. /**
  82698. * Gets or sets a value indicating the top coordinate in pixels of the control
  82699. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82700. */
  82701. get topInPixels(): number;
  82702. set topInPixels(value: number);
  82703. /**
  82704. * Gets or sets a value indicating the offset on X axis to the linked mesh
  82705. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  82706. */
  82707. get linkOffsetX(): string | number;
  82708. set linkOffsetX(value: string | number);
  82709. /**
  82710. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  82711. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  82712. */
  82713. get linkOffsetXInPixels(): number;
  82714. set linkOffsetXInPixels(value: number);
  82715. /**
  82716. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  82717. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  82718. */
  82719. get linkOffsetY(): string | number;
  82720. set linkOffsetY(value: string | number);
  82721. /**
  82722. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  82723. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  82724. */
  82725. get linkOffsetYInPixels(): number;
  82726. set linkOffsetYInPixels(value: number);
  82727. /** Gets the center coordinate on X axis */
  82728. get centerX(): number;
  82729. /** Gets the center coordinate on Y axis */
  82730. get centerY(): number;
  82731. /** Gets or sets if control is Enabled*/
  82732. get isEnabled(): boolean;
  82733. set isEnabled(value: boolean);
  82734. /** Gets or sets background color of control if it's disabled*/
  82735. get disabledColor(): string;
  82736. set disabledColor(value: string);
  82737. /** Gets or sets front color of control if it's disabled*/
  82738. get disabledColorItem(): string;
  82739. set disabledColorItem(value: string);
  82740. /**
  82741. * Creates a new control
  82742. * @param name defines the name of the control
  82743. */
  82744. constructor(
  82745. /** defines the name of the control */
  82746. name?: string | undefined);
  82747. /** @hidden */
  82748. protected _getTypeName(): string;
  82749. /**
  82750. * Gets the first ascendant in the hierarchy of the given type
  82751. * @param className defines the required type
  82752. * @returns the ascendant or null if not found
  82753. */
  82754. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  82755. /** @hidden */
  82756. _resetFontCache(): void;
  82757. /**
  82758. * Determines if a container is an ascendant of the current control
  82759. * @param container defines the container to look for
  82760. * @returns true if the container is one of the ascendant of the control
  82761. */
  82762. isAscendant(container: Control): boolean;
  82763. /**
  82764. * Gets coordinates in local control space
  82765. * @param globalCoordinates defines the coordinates to transform
  82766. * @returns the new coordinates in local space
  82767. */
  82768. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  82769. /**
  82770. * Gets coordinates in local control space
  82771. * @param globalCoordinates defines the coordinates to transform
  82772. * @param result defines the target vector2 where to store the result
  82773. * @returns the current control
  82774. */
  82775. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  82776. /**
  82777. * Gets coordinates in parent local control space
  82778. * @param globalCoordinates defines the coordinates to transform
  82779. * @returns the new coordinates in parent local space
  82780. */
  82781. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  82782. /**
  82783. * Move the current control to a vector3 position projected onto the screen.
  82784. * @param position defines the target position
  82785. * @param scene defines the hosting scene
  82786. */
  82787. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  82788. /**
  82789. * Will store all controls that have this control as ascendant in a given array
  82790. * @param results defines the array where to store the descendants
  82791. * @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
  82792. * @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
  82793. */
  82794. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  82795. /**
  82796. * Will return all controls that have this control as ascendant
  82797. * @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
  82798. * @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
  82799. * @return all child controls
  82800. */
  82801. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  82802. /**
  82803. * Link current control with a target mesh
  82804. * @param mesh defines the mesh to link with
  82805. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  82806. */
  82807. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  82808. /** @hidden */
  82809. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  82810. /** @hidden */
  82811. _offsetLeft(offset: number): void;
  82812. /** @hidden */
  82813. _offsetTop(offset: number): void;
  82814. /** @hidden */
  82815. _markMatrixAsDirty(): void;
  82816. /** @hidden */
  82817. _flagDescendantsAsMatrixDirty(): void;
  82818. /** @hidden */
  82819. _intersectsRect(rect: Measure): boolean;
  82820. /** @hidden */
  82821. protected invalidateRect(): void;
  82822. /** @hidden */
  82823. _markAsDirty(force?: boolean): void;
  82824. /** @hidden */
  82825. _markAllAsDirty(): void;
  82826. /** @hidden */
  82827. _link(host: AdvancedDynamicTexture): void;
  82828. /** @hidden */
  82829. protected _transform(context?: CanvasRenderingContext2D): void;
  82830. /** @hidden */
  82831. _renderHighlight(context: CanvasRenderingContext2D): void;
  82832. /** @hidden */
  82833. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  82834. /** @hidden */
  82835. protected _applyStates(context: CanvasRenderingContext2D): void;
  82836. /** @hidden */
  82837. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  82838. /** @hidden */
  82839. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  82840. protected _evaluateClippingState(parentMeasure: Measure): void;
  82841. /** @hidden */
  82842. _measure(): void;
  82843. /** @hidden */
  82844. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  82845. /** @hidden */
  82846. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  82847. /** @hidden */
  82848. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  82849. /** @hidden */
  82850. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  82851. private static _ClipMeasure;
  82852. private _tmpMeasureA;
  82853. private _clip;
  82854. /** @hidden */
  82855. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  82856. /** @hidden */
  82857. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  82858. /**
  82859. * Tests if a given coordinates belong to the current control
  82860. * @param x defines x coordinate to test
  82861. * @param y defines y coordinate to test
  82862. * @returns true if the coordinates are inside the control
  82863. */
  82864. contains(x: number, y: number): boolean;
  82865. /** @hidden */
  82866. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  82867. /** @hidden */
  82868. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  82869. /** @hidden */
  82870. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  82871. /** @hidden */
  82872. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  82873. /** @hidden */
  82874. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  82875. /** @hidden */
  82876. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  82877. /** @hidden */
  82878. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  82879. /** @hidden */
  82880. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  82881. /** @hidden */
  82882. _onCanvasBlur(): void;
  82883. /** @hidden */
  82884. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  82885. private _prepareFont;
  82886. /** Releases associated resources */
  82887. dispose(): void;
  82888. private static _HORIZONTAL_ALIGNMENT_LEFT;
  82889. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  82890. private static _HORIZONTAL_ALIGNMENT_CENTER;
  82891. private static _VERTICAL_ALIGNMENT_TOP;
  82892. private static _VERTICAL_ALIGNMENT_BOTTOM;
  82893. private static _VERTICAL_ALIGNMENT_CENTER;
  82894. /** HORIZONTAL_ALIGNMENT_LEFT */
  82895. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  82896. /** HORIZONTAL_ALIGNMENT_RIGHT */
  82897. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  82898. /** HORIZONTAL_ALIGNMENT_CENTER */
  82899. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  82900. /** VERTICAL_ALIGNMENT_TOP */
  82901. static get VERTICAL_ALIGNMENT_TOP(): number;
  82902. /** VERTICAL_ALIGNMENT_BOTTOM */
  82903. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  82904. /** VERTICAL_ALIGNMENT_CENTER */
  82905. static get VERTICAL_ALIGNMENT_CENTER(): number;
  82906. private static _FontHeightSizes;
  82907. /** @hidden */
  82908. static _GetFontOffset(font: string): {
  82909. ascent: number;
  82910. height: number;
  82911. descent: number;
  82912. };
  82913. /**
  82914. * Creates a stack panel that can be used to render headers
  82915. * @param control defines the control to associate with the header
  82916. * @param text defines the text of the header
  82917. * @param size defines the size of the header
  82918. * @param options defines options used to configure the header
  82919. * @returns a new StackPanel
  82920. * @ignore
  82921. * @hidden
  82922. */
  82923. static AddHeader: (control: Control, text: string, size: string | number, options: {
  82924. isHorizontal: boolean;
  82925. controlFirst: boolean;
  82926. }) => any;
  82927. /** @hidden */
  82928. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  82929. }
  82930. }
  82931. declare module BABYLON.GUI {
  82932. /**
  82933. * Root class for 2D containers
  82934. * @see https://doc.babylonjs.com/how_to/gui#containers
  82935. */
  82936. export class Container extends Control {
  82937. name?: string | undefined;
  82938. /** @hidden */
  82939. _children: Control[];
  82940. /** @hidden */
  82941. protected _measureForChildren: Measure;
  82942. /** @hidden */
  82943. protected _background: string;
  82944. /** @hidden */
  82945. protected _adaptWidthToChildren: boolean;
  82946. /** @hidden */
  82947. protected _adaptHeightToChildren: boolean;
  82948. /**
  82949. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  82950. */
  82951. logLayoutCycleErrors: boolean;
  82952. /**
  82953. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  82954. */
  82955. maxLayoutCycle: number;
  82956. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  82957. get adaptHeightToChildren(): boolean;
  82958. set adaptHeightToChildren(value: boolean);
  82959. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  82960. get adaptWidthToChildren(): boolean;
  82961. set adaptWidthToChildren(value: boolean);
  82962. /** Gets or sets background color */
  82963. get background(): string;
  82964. set background(value: string);
  82965. /** Gets the list of children */
  82966. get children(): Control[];
  82967. /**
  82968. * Creates a new Container
  82969. * @param name defines the name of the container
  82970. */
  82971. constructor(name?: string | undefined);
  82972. protected _getTypeName(): string;
  82973. _flagDescendantsAsMatrixDirty(): void;
  82974. /**
  82975. * Gets a child using its name
  82976. * @param name defines the child name to look for
  82977. * @returns the child control if found
  82978. */
  82979. getChildByName(name: string): BABYLON.Nullable<Control>;
  82980. /**
  82981. * Gets a child using its type and its name
  82982. * @param name defines the child name to look for
  82983. * @param type defines the child type to look for
  82984. * @returns the child control if found
  82985. */
  82986. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  82987. /**
  82988. * Search for a specific control in children
  82989. * @param control defines the control to look for
  82990. * @returns true if the control is in child list
  82991. */
  82992. containsControl(control: Control): boolean;
  82993. /**
  82994. * Adds a new control to the current container
  82995. * @param control defines the control to add
  82996. * @returns the current container
  82997. */
  82998. addControl(control: BABYLON.Nullable<Control>): Container;
  82999. /**
  83000. * Removes all controls from the current container
  83001. * @returns the current container
  83002. */
  83003. clearControls(): Container;
  83004. /**
  83005. * Removes a control from the current container
  83006. * @param control defines the control to remove
  83007. * @returns the current container
  83008. */
  83009. removeControl(control: Control): Container;
  83010. /** @hidden */
  83011. _reOrderControl(control: Control): void;
  83012. /** @hidden */
  83013. _offsetLeft(offset: number): void;
  83014. /** @hidden */
  83015. _offsetTop(offset: number): void;
  83016. /** @hidden */
  83017. _markAllAsDirty(): void;
  83018. /** @hidden */
  83019. protected _localDraw(context: CanvasRenderingContext2D): void;
  83020. /** @hidden */
  83021. _link(host: AdvancedDynamicTexture): void;
  83022. /** @hidden */
  83023. protected _beforeLayout(): void;
  83024. /** @hidden */
  83025. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83026. /** @hidden */
  83027. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  83028. protected _postMeasure(): void;
  83029. /** @hidden */
  83030. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  83031. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  83032. /** @hidden */
  83033. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83034. /** @hidden */
  83035. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83036. /** Releases associated resources */
  83037. dispose(): void;
  83038. }
  83039. }
  83040. declare module BABYLON.GUI {
  83041. /** Class used to create rectangle container */
  83042. export class Rectangle extends Container {
  83043. name?: string | undefined;
  83044. private _thickness;
  83045. private _cornerRadius;
  83046. /** Gets or sets border thickness */
  83047. get thickness(): number;
  83048. set thickness(value: number);
  83049. /** Gets or sets the corner radius angle */
  83050. get cornerRadius(): number;
  83051. set cornerRadius(value: number);
  83052. /**
  83053. * Creates a new Rectangle
  83054. * @param name defines the control name
  83055. */
  83056. constructor(name?: string | undefined);
  83057. protected _getTypeName(): string;
  83058. protected _localDraw(context: CanvasRenderingContext2D): void;
  83059. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83060. private _drawRoundedRect;
  83061. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  83062. }
  83063. }
  83064. declare module BABYLON.GUI {
  83065. /**
  83066. * Enum that determines the text-wrapping mode to use.
  83067. */
  83068. export enum TextWrapping {
  83069. /**
  83070. * Clip the text when it's larger than Control.width; this is the default mode.
  83071. */
  83072. Clip = 0,
  83073. /**
  83074. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  83075. */
  83076. WordWrap = 1,
  83077. /**
  83078. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  83079. */
  83080. Ellipsis = 2
  83081. }
  83082. /**
  83083. * Class used to create text block control
  83084. */
  83085. export class TextBlock extends Control {
  83086. /**
  83087. * Defines the name of the control
  83088. */
  83089. name?: string | undefined;
  83090. private _text;
  83091. private _textWrapping;
  83092. private _textHorizontalAlignment;
  83093. private _textVerticalAlignment;
  83094. private _lines;
  83095. private _resizeToFit;
  83096. private _lineSpacing;
  83097. private _outlineWidth;
  83098. private _outlineColor;
  83099. private _underline;
  83100. private _lineThrough;
  83101. /**
  83102. * An event triggered after the text is changed
  83103. */
  83104. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  83105. /**
  83106. * An event triggered after the text was broken up into lines
  83107. */
  83108. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  83109. /**
  83110. * Function used to split a string into words. By default, a string is split at each space character found
  83111. */
  83112. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  83113. /**
  83114. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  83115. */
  83116. get lines(): any[];
  83117. /**
  83118. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  83119. */
  83120. get resizeToFit(): boolean;
  83121. /**
  83122. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  83123. */
  83124. set resizeToFit(value: boolean);
  83125. /**
  83126. * Gets or sets a boolean indicating if text must be wrapped
  83127. */
  83128. get textWrapping(): TextWrapping | boolean;
  83129. /**
  83130. * Gets or sets a boolean indicating if text must be wrapped
  83131. */
  83132. set textWrapping(value: TextWrapping | boolean);
  83133. /**
  83134. * Gets or sets text to display
  83135. */
  83136. get text(): string;
  83137. /**
  83138. * Gets or sets text to display
  83139. */
  83140. set text(value: string);
  83141. /**
  83142. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  83143. */
  83144. get textHorizontalAlignment(): number;
  83145. /**
  83146. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  83147. */
  83148. set textHorizontalAlignment(value: number);
  83149. /**
  83150. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  83151. */
  83152. get textVerticalAlignment(): number;
  83153. /**
  83154. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  83155. */
  83156. set textVerticalAlignment(value: number);
  83157. /**
  83158. * Gets or sets line spacing value
  83159. */
  83160. set lineSpacing(value: string | number);
  83161. /**
  83162. * Gets or sets line spacing value
  83163. */
  83164. get lineSpacing(): string | number;
  83165. /**
  83166. * Gets or sets outlineWidth of the text to display
  83167. */
  83168. get outlineWidth(): number;
  83169. /**
  83170. * Gets or sets outlineWidth of the text to display
  83171. */
  83172. set outlineWidth(value: number);
  83173. /**
  83174. * Gets or sets a boolean indicating that text must have underline
  83175. */
  83176. get underline(): boolean;
  83177. /**
  83178. * Gets or sets a boolean indicating that text must have underline
  83179. */
  83180. set underline(value: boolean);
  83181. /**
  83182. * Gets or sets an boolean indicating that text must be crossed out
  83183. */
  83184. get lineThrough(): boolean;
  83185. /**
  83186. * Gets or sets an boolean indicating that text must be crossed out
  83187. */
  83188. set lineThrough(value: boolean);
  83189. /**
  83190. * Gets or sets outlineColor of the text to display
  83191. */
  83192. get outlineColor(): string;
  83193. /**
  83194. * Gets or sets outlineColor of the text to display
  83195. */
  83196. set outlineColor(value: string);
  83197. /**
  83198. * Creates a new TextBlock object
  83199. * @param name defines the name of the control
  83200. * @param text defines the text to display (emptry string by default)
  83201. */
  83202. constructor(
  83203. /**
  83204. * Defines the name of the control
  83205. */
  83206. name?: string | undefined, text?: string);
  83207. protected _getTypeName(): string;
  83208. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83209. private _drawText;
  83210. /** @hidden */
  83211. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  83212. protected _applyStates(context: CanvasRenderingContext2D): void;
  83213. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  83214. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  83215. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  83216. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  83217. protected _renderLines(context: CanvasRenderingContext2D): void;
  83218. /**
  83219. * Given a width constraint applied on the text block, find the expected height
  83220. * @returns expected height
  83221. */
  83222. computeExpectedHeight(): number;
  83223. dispose(): void;
  83224. }
  83225. }
  83226. declare module BABYLON.GUI {
  83227. /**
  83228. * Class used to create 2D images
  83229. */
  83230. export class Image extends Control {
  83231. name?: string | undefined;
  83232. private _workingCanvas;
  83233. private _domImage;
  83234. private _imageWidth;
  83235. private _imageHeight;
  83236. private _loaded;
  83237. private _stretch;
  83238. private _source;
  83239. private _autoScale;
  83240. private _sourceLeft;
  83241. private _sourceTop;
  83242. private _sourceWidth;
  83243. private _sourceHeight;
  83244. private _svgAttributesComputationCompleted;
  83245. private _isSVG;
  83246. private _cellWidth;
  83247. private _cellHeight;
  83248. private _cellId;
  83249. private _populateNinePatchSlicesFromImage;
  83250. private _sliceLeft;
  83251. private _sliceRight;
  83252. private _sliceTop;
  83253. private _sliceBottom;
  83254. private _detectPointerOnOpaqueOnly;
  83255. private _imageDataCache;
  83256. /**
  83257. * BABYLON.Observable notified when the content is loaded
  83258. */
  83259. onImageLoadedObservable: BABYLON.Observable<Image>;
  83260. /**
  83261. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  83262. */
  83263. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  83264. /**
  83265. * Gets a boolean indicating that the content is loaded
  83266. */
  83267. get isLoaded(): boolean;
  83268. /**
  83269. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  83270. */
  83271. get populateNinePatchSlicesFromImage(): boolean;
  83272. set populateNinePatchSlicesFromImage(value: boolean);
  83273. /**
  83274. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  83275. * Beware using this as this will comsume more memory as the image has to be stored twice
  83276. */
  83277. get detectPointerOnOpaqueOnly(): boolean;
  83278. set detectPointerOnOpaqueOnly(value: boolean);
  83279. /**
  83280. * Gets or sets the left value for slicing (9-patch)
  83281. */
  83282. get sliceLeft(): number;
  83283. set sliceLeft(value: number);
  83284. /**
  83285. * Gets or sets the right value for slicing (9-patch)
  83286. */
  83287. get sliceRight(): number;
  83288. set sliceRight(value: number);
  83289. /**
  83290. * Gets or sets the top value for slicing (9-patch)
  83291. */
  83292. get sliceTop(): number;
  83293. set sliceTop(value: number);
  83294. /**
  83295. * Gets or sets the bottom value for slicing (9-patch)
  83296. */
  83297. get sliceBottom(): number;
  83298. set sliceBottom(value: number);
  83299. /**
  83300. * Gets or sets the left coordinate in the source image
  83301. */
  83302. get sourceLeft(): number;
  83303. set sourceLeft(value: number);
  83304. /**
  83305. * Gets or sets the top coordinate in the source image
  83306. */
  83307. get sourceTop(): number;
  83308. set sourceTop(value: number);
  83309. /**
  83310. * Gets or sets the width to capture in the source image
  83311. */
  83312. get sourceWidth(): number;
  83313. set sourceWidth(value: number);
  83314. /**
  83315. * Gets or sets the height to capture in the source image
  83316. */
  83317. get sourceHeight(): number;
  83318. set sourceHeight(value: number);
  83319. /** Indicates if the format of the image is SVG */
  83320. get isSVG(): boolean;
  83321. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  83322. get svgAttributesComputationCompleted(): boolean;
  83323. /**
  83324. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  83325. * @see https://doc.babylonjs.com/how_to/gui#image
  83326. */
  83327. get autoScale(): boolean;
  83328. set autoScale(value: boolean);
  83329. /** Gets or sets the streching mode used by the image */
  83330. get stretch(): number;
  83331. set stretch(value: number);
  83332. /** @hidden */
  83333. _rotate90(n: number, preserveProperties?: boolean): Image;
  83334. private _handleRotationForSVGImage;
  83335. private _rotate90SourceProperties;
  83336. /**
  83337. * Gets or sets the internal DOM image used to render the control
  83338. */
  83339. set domImage(value: HTMLImageElement);
  83340. get domImage(): HTMLImageElement;
  83341. private _onImageLoaded;
  83342. private _extractNinePatchSliceDataFromImage;
  83343. /**
  83344. * Gets or sets image source url
  83345. */
  83346. set source(value: BABYLON.Nullable<string>);
  83347. /**
  83348. * Checks for svg document with icon id present
  83349. */
  83350. private _svgCheck;
  83351. /**
  83352. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  83353. * given external svg file and icon id
  83354. */
  83355. private _getSVGAttribs;
  83356. /**
  83357. * Gets or sets the cell width to use when animation sheet is enabled
  83358. * @see https://doc.babylonjs.com/how_to/gui#image
  83359. */
  83360. get cellWidth(): number;
  83361. set cellWidth(value: number);
  83362. /**
  83363. * Gets or sets the cell height to use when animation sheet is enabled
  83364. * @see https://doc.babylonjs.com/how_to/gui#image
  83365. */
  83366. get cellHeight(): number;
  83367. set cellHeight(value: number);
  83368. /**
  83369. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  83370. * @see https://doc.babylonjs.com/how_to/gui#image
  83371. */
  83372. get cellId(): number;
  83373. set cellId(value: number);
  83374. /**
  83375. * Creates a new Image
  83376. * @param name defines the control name
  83377. * @param url defines the image url
  83378. */
  83379. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  83380. /**
  83381. * Tests if a given coordinates belong to the current control
  83382. * @param x defines x coordinate to test
  83383. * @param y defines y coordinate to test
  83384. * @returns true if the coordinates are inside the control
  83385. */
  83386. contains(x: number, y: number): boolean;
  83387. protected _getTypeName(): string;
  83388. /** Force the control to synchronize with its content */
  83389. synchronizeSizeWithContent(): void;
  83390. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83391. private _prepareWorkingCanvasForOpaqueDetection;
  83392. private _drawImage;
  83393. _draw(context: CanvasRenderingContext2D): void;
  83394. private _renderCornerPatch;
  83395. private _renderNinePatch;
  83396. dispose(): void;
  83397. /** STRETCH_NONE */
  83398. static readonly STRETCH_NONE: number;
  83399. /** STRETCH_FILL */
  83400. static readonly STRETCH_FILL: number;
  83401. /** STRETCH_UNIFORM */
  83402. static readonly STRETCH_UNIFORM: number;
  83403. /** STRETCH_EXTEND */
  83404. static readonly STRETCH_EXTEND: number;
  83405. /** NINE_PATCH */
  83406. static readonly STRETCH_NINE_PATCH: number;
  83407. }
  83408. }
  83409. declare module BABYLON.GUI {
  83410. /**
  83411. * Class used to create 2D buttons
  83412. */
  83413. export class Button extends Rectangle {
  83414. name?: string | undefined;
  83415. /**
  83416. * Function called to generate a pointer enter animation
  83417. */
  83418. pointerEnterAnimation: () => void;
  83419. /**
  83420. * Function called to generate a pointer out animation
  83421. */
  83422. pointerOutAnimation: () => void;
  83423. /**
  83424. * Function called to generate a pointer down animation
  83425. */
  83426. pointerDownAnimation: () => void;
  83427. /**
  83428. * Function called to generate a pointer up animation
  83429. */
  83430. pointerUpAnimation: () => void;
  83431. /**
  83432. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  83433. */
  83434. delegatePickingToChildren: boolean;
  83435. private _image;
  83436. /**
  83437. * Returns the image part of the button (if any)
  83438. */
  83439. get image(): BABYLON.Nullable<Image>;
  83440. private _textBlock;
  83441. /**
  83442. * Returns the image part of the button (if any)
  83443. */
  83444. get textBlock(): BABYLON.Nullable<TextBlock>;
  83445. /**
  83446. * Creates a new Button
  83447. * @param name defines the name of the button
  83448. */
  83449. constructor(name?: string | undefined);
  83450. protected _getTypeName(): string;
  83451. /** @hidden */
  83452. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83453. /** @hidden */
  83454. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  83455. /** @hidden */
  83456. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  83457. /** @hidden */
  83458. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  83459. /** @hidden */
  83460. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  83461. /**
  83462. * Creates a new button made with an image and a text
  83463. * @param name defines the name of the button
  83464. * @param text defines the text of the button
  83465. * @param imageUrl defines the url of the image
  83466. * @returns a new Button
  83467. */
  83468. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  83469. /**
  83470. * Creates a new button made with an image
  83471. * @param name defines the name of the button
  83472. * @param imageUrl defines the url of the image
  83473. * @returns a new Button
  83474. */
  83475. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  83476. /**
  83477. * Creates a new button made with a text
  83478. * @param name defines the name of the button
  83479. * @param text defines the text of the button
  83480. * @returns a new Button
  83481. */
  83482. static CreateSimpleButton(name: string, text: string): Button;
  83483. /**
  83484. * Creates a new button made with an image and a centered text
  83485. * @param name defines the name of the button
  83486. * @param text defines the text of the button
  83487. * @param imageUrl defines the url of the image
  83488. * @returns a new Button
  83489. */
  83490. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  83491. }
  83492. }
  83493. declare module BABYLON.GUI {
  83494. /**
  83495. * Class used to create a 2D stack panel container
  83496. */
  83497. export class StackPanel extends Container {
  83498. name?: string | undefined;
  83499. private _isVertical;
  83500. private _manualWidth;
  83501. private _manualHeight;
  83502. private _doNotTrackManualChanges;
  83503. /**
  83504. * Gets or sets a boolean indicating that layou warnings should be ignored
  83505. */
  83506. ignoreLayoutWarnings: boolean;
  83507. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  83508. get isVertical(): boolean;
  83509. set isVertical(value: boolean);
  83510. /**
  83511. * Gets or sets panel width.
  83512. * This value should not be set when in horizontal mode as it will be computed automatically
  83513. */
  83514. set width(value: string | number);
  83515. get width(): string | number;
  83516. /**
  83517. * Gets or sets panel height.
  83518. * This value should not be set when in vertical mode as it will be computed automatically
  83519. */
  83520. set height(value: string | number);
  83521. get height(): string | number;
  83522. /**
  83523. * Creates a new StackPanel
  83524. * @param name defines control name
  83525. */
  83526. constructor(name?: string | undefined);
  83527. protected _getTypeName(): string;
  83528. /** @hidden */
  83529. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83530. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83531. protected _postMeasure(): void;
  83532. }
  83533. }
  83534. declare module BABYLON.GUI {
  83535. /**
  83536. * Class used to represent a 2D checkbox
  83537. */
  83538. export class Checkbox extends Control {
  83539. name?: string | undefined;
  83540. private _isChecked;
  83541. private _background;
  83542. private _checkSizeRatio;
  83543. private _thickness;
  83544. /** Gets or sets border thickness */
  83545. get thickness(): number;
  83546. set thickness(value: number);
  83547. /**
  83548. * BABYLON.Observable raised when isChecked property changes
  83549. */
  83550. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  83551. /** Gets or sets a value indicating the ratio between overall size and check size */
  83552. get checkSizeRatio(): number;
  83553. set checkSizeRatio(value: number);
  83554. /** Gets or sets background color */
  83555. get background(): string;
  83556. set background(value: string);
  83557. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  83558. get isChecked(): boolean;
  83559. set isChecked(value: boolean);
  83560. /**
  83561. * Creates a new CheckBox
  83562. * @param name defines the control name
  83563. */
  83564. constructor(name?: string | undefined);
  83565. protected _getTypeName(): string;
  83566. /** @hidden */
  83567. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  83568. /** @hidden */
  83569. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  83570. /**
  83571. * Utility function to easily create a checkbox with a header
  83572. * @param title defines the label to use for the header
  83573. * @param onValueChanged defines the callback to call when value changes
  83574. * @returns a StackPanel containing the checkbox and a textBlock
  83575. */
  83576. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  83577. }
  83578. }
  83579. declare module BABYLON.GUI {
  83580. /**
  83581. * Class used to store key control properties
  83582. */
  83583. export class KeyPropertySet {
  83584. /** Width */
  83585. width?: string;
  83586. /** Height */
  83587. height?: string;
  83588. /** Left padding */
  83589. paddingLeft?: string;
  83590. /** Right padding */
  83591. paddingRight?: string;
  83592. /** Top padding */
  83593. paddingTop?: string;
  83594. /** Bottom padding */
  83595. paddingBottom?: string;
  83596. /** Foreground color */
  83597. color?: string;
  83598. /** Background color */
  83599. background?: string;
  83600. }
  83601. /**
  83602. * Class used to create virtual keyboard
  83603. */
  83604. export class VirtualKeyboard extends StackPanel {
  83605. /** BABYLON.Observable raised when a key is pressed */
  83606. onKeyPressObservable: BABYLON.Observable<string>;
  83607. /** Gets or sets default key button width */
  83608. defaultButtonWidth: string;
  83609. /** Gets or sets default key button height */
  83610. defaultButtonHeight: string;
  83611. /** Gets or sets default key button left padding */
  83612. defaultButtonPaddingLeft: string;
  83613. /** Gets or sets default key button right padding */
  83614. defaultButtonPaddingRight: string;
  83615. /** Gets or sets default key button top padding */
  83616. defaultButtonPaddingTop: string;
  83617. /** Gets or sets default key button bottom padding */
  83618. defaultButtonPaddingBottom: string;
  83619. /** Gets or sets default key button foreground color */
  83620. defaultButtonColor: string;
  83621. /** Gets or sets default key button background color */
  83622. defaultButtonBackground: string;
  83623. /** Gets or sets shift button foreground color */
  83624. shiftButtonColor: string;
  83625. /** Gets or sets shift button thickness*/
  83626. selectedShiftThickness: number;
  83627. /** Gets shift key state */
  83628. shiftState: number;
  83629. protected _getTypeName(): string;
  83630. private _createKey;
  83631. /**
  83632. * Adds a new row of keys
  83633. * @param keys defines the list of keys to add
  83634. * @param propertySets defines the associated property sets
  83635. */
  83636. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  83637. /**
  83638. * Set the shift key to a specific state
  83639. * @param shiftState defines the new shift state
  83640. */
  83641. applyShiftState(shiftState: number): void;
  83642. private _currentlyConnectedInputText;
  83643. private _connectedInputTexts;
  83644. private _onKeyPressObserver;
  83645. /** Gets the input text control currently attached to the keyboard */
  83646. get connectedInputText(): BABYLON.Nullable<InputText>;
  83647. /**
  83648. * Connects the keyboard with an input text control
  83649. *
  83650. * @param input defines the target control
  83651. */
  83652. connect(input: InputText): void;
  83653. /**
  83654. * Disconnects the keyboard from connected InputText controls
  83655. *
  83656. * @param input optionally defines a target control, otherwise all are disconnected
  83657. */
  83658. disconnect(input?: InputText): void;
  83659. private _removeConnectedInputObservables;
  83660. /**
  83661. * Release all resources
  83662. */
  83663. dispose(): void;
  83664. /**
  83665. * Creates a new keyboard using a default layout
  83666. *
  83667. * @param name defines control name
  83668. * @returns a new VirtualKeyboard
  83669. */
  83670. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  83671. }
  83672. }
  83673. declare module BABYLON.GUI {
  83674. /** @hidden */
  83675. export class TextWrapper {
  83676. private _text;
  83677. private _characters;
  83678. get text(): string;
  83679. set text(txt: string);
  83680. get length(): number;
  83681. removePart(idxStart: number, idxEnd: number, insertTxt?: string): void;
  83682. charAt(idx: number): string;
  83683. substr(from: number, length?: number): string;
  83684. substring(from: number, to?: number): string;
  83685. isWord(index: number): boolean;
  83686. }
  83687. }
  83688. declare module BABYLON.GUI {
  83689. /**
  83690. * Class used to create input text control
  83691. */
  83692. export class InputText extends Control implements IFocusableControl {
  83693. name?: string | undefined;
  83694. private _textWrapper;
  83695. private _placeholderText;
  83696. private _background;
  83697. private _focusedBackground;
  83698. private _focusedColor;
  83699. private _placeholderColor;
  83700. private _thickness;
  83701. private _margin;
  83702. private _autoStretchWidth;
  83703. private _maxWidth;
  83704. private _isFocused;
  83705. private _blinkTimeout;
  83706. private _blinkIsEven;
  83707. private _cursorOffset;
  83708. private _scrollLeft;
  83709. private _textWidth;
  83710. private _clickedCoordinate;
  83711. private _deadKey;
  83712. private _addKey;
  83713. private _currentKey;
  83714. private _isTextHighlightOn;
  83715. private _textHighlightColor;
  83716. private _highligherOpacity;
  83717. private _highlightedText;
  83718. private _startHighlightIndex;
  83719. private _endHighlightIndex;
  83720. private _cursorIndex;
  83721. private _onFocusSelectAll;
  83722. private _isPointerDown;
  83723. private _onClipboardObserver;
  83724. private _onPointerDblTapObserver;
  83725. /** @hidden */
  83726. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  83727. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  83728. promptMessage: string;
  83729. /** Force disable prompt on mobile device */
  83730. disableMobilePrompt: boolean;
  83731. /** BABYLON.Observable raised when the text changes */
  83732. onTextChangedObservable: BABYLON.Observable<InputText>;
  83733. /** BABYLON.Observable raised just before an entered character is to be added */
  83734. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  83735. /** BABYLON.Observable raised when the control gets the focus */
  83736. onFocusObservable: BABYLON.Observable<InputText>;
  83737. /** BABYLON.Observable raised when the control loses the focus */
  83738. onBlurObservable: BABYLON.Observable<InputText>;
  83739. /**Observable raised when the text is highlighted */
  83740. onTextHighlightObservable: BABYLON.Observable<InputText>;
  83741. /**Observable raised when copy event is triggered */
  83742. onTextCopyObservable: BABYLON.Observable<InputText>;
  83743. /** BABYLON.Observable raised when cut event is triggered */
  83744. onTextCutObservable: BABYLON.Observable<InputText>;
  83745. /** BABYLON.Observable raised when paste event is triggered */
  83746. onTextPasteObservable: BABYLON.Observable<InputText>;
  83747. /** BABYLON.Observable raised when a key event was processed */
  83748. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  83749. /** Gets or sets the maximum width allowed by the control */
  83750. get maxWidth(): string | number;
  83751. /** Gets the maximum width allowed by the control in pixels */
  83752. get maxWidthInPixels(): number;
  83753. set maxWidth(value: string | number);
  83754. /** Gets or sets the text highlighter transparency; default: 0.4 */
  83755. get highligherOpacity(): number;
  83756. set highligherOpacity(value: number);
  83757. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  83758. get onFocusSelectAll(): boolean;
  83759. set onFocusSelectAll(value: boolean);
  83760. /** Gets or sets the text hightlight color */
  83761. get textHighlightColor(): string;
  83762. set textHighlightColor(value: string);
  83763. /** Gets or sets control margin */
  83764. get margin(): string;
  83765. /** Gets control margin in pixels */
  83766. get marginInPixels(): number;
  83767. set margin(value: string);
  83768. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  83769. get autoStretchWidth(): boolean;
  83770. set autoStretchWidth(value: boolean);
  83771. /** Gets or sets border thickness */
  83772. get thickness(): number;
  83773. set thickness(value: number);
  83774. /** Gets or sets the background color when focused */
  83775. get focusedBackground(): string;
  83776. set focusedBackground(value: string);
  83777. /** Gets or sets the background color when focused */
  83778. get focusedColor(): string;
  83779. set focusedColor(value: string);
  83780. /** Gets or sets the background color */
  83781. get background(): string;
  83782. set background(value: string);
  83783. /** Gets or sets the placeholder color */
  83784. get placeholderColor(): string;
  83785. set placeholderColor(value: string);
  83786. /** Gets or sets the text displayed when the control is empty */
  83787. get placeholderText(): string;
  83788. set placeholderText(value: string);
  83789. /** Gets or sets the dead key flag */
  83790. get deadKey(): boolean;
  83791. set deadKey(flag: boolean);
  83792. /** Gets or sets the highlight text */
  83793. get highlightedText(): string;
  83794. set highlightedText(text: string);
  83795. /** Gets or sets if the current key should be added */
  83796. get addKey(): boolean;
  83797. set addKey(flag: boolean);
  83798. /** Gets or sets the value of the current key being entered */
  83799. get currentKey(): string;
  83800. set currentKey(key: string);
  83801. /** Gets or sets the text displayed in the control */
  83802. get text(): string;
  83803. set text(value: string);
  83804. private _textHasChanged;
  83805. /** Gets or sets control width */
  83806. get width(): string | number;
  83807. set width(value: string | number);
  83808. /**
  83809. * Creates a new InputText
  83810. * @param name defines the control name
  83811. * @param text defines the text of the control
  83812. */
  83813. constructor(name?: string | undefined, text?: string);
  83814. /** @hidden */
  83815. onBlur(): void;
  83816. /** @hidden */
  83817. onFocus(): void;
  83818. /**
  83819. * Function to focus an inputText programmatically
  83820. */
  83821. focus(): void;
  83822. /**
  83823. * Function to unfocus an inputText programmatically
  83824. */
  83825. blur(): void;
  83826. protected _getTypeName(): string;
  83827. /**
  83828. * Function called to get the list of controls that should not steal the focus from this control
  83829. * @returns an array of controls
  83830. */
  83831. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  83832. /** @hidden */
  83833. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  83834. /** @hidden */
  83835. private _updateValueFromCursorIndex;
  83836. /** @hidden */
  83837. private _processDblClick;
  83838. /** @hidden */
  83839. private _selectAllText;
  83840. /**
  83841. * Handles the keyboard event
  83842. * @param evt Defines the KeyboardEvent
  83843. */
  83844. processKeyboard(evt: KeyboardEvent): void;
  83845. /** @hidden */
  83846. private _onCopyText;
  83847. /** @hidden */
  83848. private _onCutText;
  83849. /** @hidden */
  83850. private _onPasteText;
  83851. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  83852. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  83853. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  83854. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  83855. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  83856. dispose(): void;
  83857. }
  83858. }
  83859. declare module BABYLON.GUI {
  83860. /**
  83861. * Class used to create a 2D grid container
  83862. */
  83863. export class Grid extends Container {
  83864. name?: string | undefined;
  83865. private _rowDefinitions;
  83866. private _columnDefinitions;
  83867. private _cells;
  83868. private _childControls;
  83869. /**
  83870. * Gets the number of columns
  83871. */
  83872. get columnCount(): number;
  83873. /**
  83874. * Gets the number of rows
  83875. */
  83876. get rowCount(): number;
  83877. /** Gets the list of children */
  83878. get children(): Control[];
  83879. /** Gets the list of cells (e.g. the containers) */
  83880. get cells(): {
  83881. [key: string]: Container;
  83882. };
  83883. /**
  83884. * Gets the definition of a specific row
  83885. * @param index defines the index of the row
  83886. * @returns the row definition
  83887. */
  83888. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  83889. /**
  83890. * Gets the definition of a specific column
  83891. * @param index defines the index of the column
  83892. * @returns the column definition
  83893. */
  83894. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  83895. /**
  83896. * Adds a new row to the grid
  83897. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  83898. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  83899. * @returns the current grid
  83900. */
  83901. addRowDefinition(height: number, isPixel?: boolean): Grid;
  83902. /**
  83903. * Adds a new column to the grid
  83904. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  83905. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  83906. * @returns the current grid
  83907. */
  83908. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  83909. /**
  83910. * Update a row definition
  83911. * @param index defines the index of the row to update
  83912. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  83913. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  83914. * @returns the current grid
  83915. */
  83916. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  83917. /**
  83918. * Update a column definition
  83919. * @param index defines the index of the column to update
  83920. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  83921. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  83922. * @returns the current grid
  83923. */
  83924. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  83925. /**
  83926. * Gets the list of children stored in a specific cell
  83927. * @param row defines the row to check
  83928. * @param column defines the column to check
  83929. * @returns the list of controls
  83930. */
  83931. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  83932. /**
  83933. * Gets a string representing the child cell info (row x column)
  83934. * @param child defines the control to get info from
  83935. * @returns a string containing the child cell info (row x column)
  83936. */
  83937. getChildCellInfo(child: Control): string;
  83938. private _removeCell;
  83939. private _offsetCell;
  83940. /**
  83941. * Remove a column definition at specified index
  83942. * @param index defines the index of the column to remove
  83943. * @returns the current grid
  83944. */
  83945. removeColumnDefinition(index: number): Grid;
  83946. /**
  83947. * Remove a row definition at specified index
  83948. * @param index defines the index of the row to remove
  83949. * @returns the current grid
  83950. */
  83951. removeRowDefinition(index: number): Grid;
  83952. /**
  83953. * Adds a new control to the current grid
  83954. * @param control defines the control to add
  83955. * @param row defines the row where to add the control (0 by default)
  83956. * @param column defines the column where to add the control (0 by default)
  83957. * @returns the current grid
  83958. */
  83959. addControl(control: Control, row?: number, column?: number): Grid;
  83960. /**
  83961. * Removes a control from the current container
  83962. * @param control defines the control to remove
  83963. * @returns the current container
  83964. */
  83965. removeControl(control: Control): Container;
  83966. /**
  83967. * Creates a new Grid
  83968. * @param name defines control name
  83969. */
  83970. constructor(name?: string | undefined);
  83971. protected _getTypeName(): string;
  83972. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  83973. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83974. _flagDescendantsAsMatrixDirty(): void;
  83975. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  83976. /** Releases associated resources */
  83977. dispose(): void;
  83978. }
  83979. }
  83980. declare module BABYLON.GUI {
  83981. /** Class used to create color pickers */
  83982. export class ColorPicker extends Control {
  83983. name?: string | undefined;
  83984. private static _Epsilon;
  83985. private _colorWheelCanvas;
  83986. private _value;
  83987. private _tmpColor;
  83988. private _pointerStartedOnSquare;
  83989. private _pointerStartedOnWheel;
  83990. private _squareLeft;
  83991. private _squareTop;
  83992. private _squareSize;
  83993. private _h;
  83994. private _s;
  83995. private _v;
  83996. private _lastPointerDownID;
  83997. /**
  83998. * BABYLON.Observable raised when the value changes
  83999. */
  84000. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  84001. /** Gets or sets the color of the color picker */
  84002. get value(): BABYLON.Color3;
  84003. set value(value: BABYLON.Color3);
  84004. /**
  84005. * Gets or sets control width
  84006. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84007. */
  84008. get width(): string | number;
  84009. set width(value: string | number);
  84010. /**
  84011. * Gets or sets control height
  84012. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84013. */
  84014. get height(): string | number;
  84015. /** Gets or sets control height */
  84016. set height(value: string | number);
  84017. /** Gets or sets control size */
  84018. get size(): string | number;
  84019. set size(value: string | number);
  84020. /**
  84021. * Creates a new ColorPicker
  84022. * @param name defines the control name
  84023. */
  84024. constructor(name?: string | undefined);
  84025. protected _getTypeName(): string;
  84026. /** @hidden */
  84027. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84028. private _updateSquareProps;
  84029. private _drawGradientSquare;
  84030. private _drawCircle;
  84031. private _createColorWheelCanvas;
  84032. /** @hidden */
  84033. _draw(context: CanvasRenderingContext2D): void;
  84034. private _pointerIsDown;
  84035. private _updateValueFromPointer;
  84036. private _isPointOnSquare;
  84037. private _isPointOnWheel;
  84038. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84039. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84040. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  84041. _onCanvasBlur(): void;
  84042. /**
  84043. * This function expands the color picker by creating a color picker dialog with manual
  84044. * color value input and the ability to save colors into an array to be used later in
  84045. * subsequent launches of the dialogue.
  84046. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  84047. * @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.
  84048. * @returns picked color as a hex string and the saved colors array as hex strings.
  84049. */
  84050. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  84051. pickerWidth?: string;
  84052. pickerHeight?: string;
  84053. headerHeight?: string;
  84054. lastColor?: string;
  84055. swatchLimit?: number;
  84056. numSwatchesPerLine?: number;
  84057. savedColors?: Array<string>;
  84058. }): Promise<{
  84059. savedColors?: string[];
  84060. pickedColor: string;
  84061. }>;
  84062. }
  84063. }
  84064. declare module BABYLON.GUI {
  84065. /** Class used to create 2D ellipse containers */
  84066. export class Ellipse extends Container {
  84067. name?: string | undefined;
  84068. private _thickness;
  84069. /** Gets or sets border thickness */
  84070. get thickness(): number;
  84071. set thickness(value: number);
  84072. /**
  84073. * Creates a new Ellipse
  84074. * @param name defines the control name
  84075. */
  84076. constructor(name?: string | undefined);
  84077. protected _getTypeName(): string;
  84078. protected _localDraw(context: CanvasRenderingContext2D): void;
  84079. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84080. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  84081. }
  84082. }
  84083. declare module BABYLON.GUI {
  84084. /**
  84085. * Class used to create a focusable button that can easily handle keyboard events
  84086. */
  84087. export class FocusableButton extends Button implements IFocusableControl {
  84088. name?: string | undefined;
  84089. /** Highlight color when button is focused */
  84090. focusedColor: BABYLON.Nullable<string>;
  84091. private _isFocused;
  84092. private _unfocusedColor;
  84093. /** BABYLON.Observable raised when the control gets the focus */
  84094. onFocusObservable: BABYLON.Observable<Button>;
  84095. /** BABYLON.Observable raised when the control loses the focus */
  84096. onBlurObservable: BABYLON.Observable<Button>;
  84097. /** BABYLON.Observable raised when a key event was processed */
  84098. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  84099. constructor(name?: string | undefined);
  84100. /** @hidden */
  84101. onBlur(): void;
  84102. /** @hidden */
  84103. onFocus(): void;
  84104. /**
  84105. * Function called to get the list of controls that should not steal the focus from this control
  84106. * @returns an array of controls
  84107. */
  84108. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  84109. /**
  84110. * Function to focus a button programmatically
  84111. */
  84112. focus(): void;
  84113. /**
  84114. * Function to unfocus a button programmatically
  84115. */
  84116. blur(): void;
  84117. /**
  84118. * Handles the keyboard event
  84119. * @param evt Defines the KeyboardEvent
  84120. */
  84121. processKeyboard(evt: KeyboardEvent): void;
  84122. /** @hidden */
  84123. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84124. /** @hidden */
  84125. displose(): void;
  84126. }
  84127. }
  84128. declare module BABYLON.GUI {
  84129. /**
  84130. * Class used to create a password control
  84131. */
  84132. export class InputPassword extends InputText {
  84133. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  84134. }
  84135. }
  84136. declare module BABYLON.GUI {
  84137. /** Class used to render 2D lines */
  84138. export class Line extends Control {
  84139. name?: string | undefined;
  84140. private _lineWidth;
  84141. private _x1;
  84142. private _y1;
  84143. private _x2;
  84144. private _y2;
  84145. private _dash;
  84146. private _connectedControl;
  84147. private _connectedControlDirtyObserver;
  84148. /** Gets or sets the dash pattern */
  84149. get dash(): Array<number>;
  84150. set dash(value: Array<number>);
  84151. /** Gets or sets the control connected with the line end */
  84152. get connectedControl(): Control;
  84153. set connectedControl(value: Control);
  84154. /** Gets or sets start coordinates on X axis */
  84155. get x1(): string | number;
  84156. set x1(value: string | number);
  84157. /** Gets or sets start coordinates on Y axis */
  84158. get y1(): string | number;
  84159. set y1(value: string | number);
  84160. /** Gets or sets end coordinates on X axis */
  84161. get x2(): string | number;
  84162. set x2(value: string | number);
  84163. /** Gets or sets end coordinates on Y axis */
  84164. get y2(): string | number;
  84165. set y2(value: string | number);
  84166. /** Gets or sets line width */
  84167. get lineWidth(): number;
  84168. set lineWidth(value: number);
  84169. /** Gets or sets horizontal alignment */
  84170. set horizontalAlignment(value: number);
  84171. /** Gets or sets vertical alignment */
  84172. set verticalAlignment(value: number);
  84173. private get _effectiveX2();
  84174. private get _effectiveY2();
  84175. /**
  84176. * Creates a new Line
  84177. * @param name defines the control name
  84178. */
  84179. constructor(name?: string | undefined);
  84180. protected _getTypeName(): string;
  84181. _draw(context: CanvasRenderingContext2D): void;
  84182. _measure(): void;
  84183. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84184. /**
  84185. * Move one end of the line given 3D cartesian coordinates.
  84186. * @param position Targeted world position
  84187. * @param scene BABYLON.Scene
  84188. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  84189. */
  84190. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  84191. /**
  84192. * Move one end of the line to a position in screen absolute space.
  84193. * @param projectedPosition Position in screen absolute space (X, Y)
  84194. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  84195. */
  84196. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  84197. }
  84198. }
  84199. declare module BABYLON.GUI {
  84200. /**
  84201. * Class used to store a point for a MultiLine object.
  84202. * The point can be pure 2D coordinates, a mesh or a control
  84203. */
  84204. export class MultiLinePoint {
  84205. private _multiLine;
  84206. private _x;
  84207. private _y;
  84208. private _control;
  84209. private _mesh;
  84210. private _controlObserver;
  84211. private _meshObserver;
  84212. /** @hidden */
  84213. _point: BABYLON.Vector3;
  84214. /**
  84215. * Creates a new MultiLinePoint
  84216. * @param multiLine defines the source MultiLine object
  84217. */
  84218. constructor(multiLine: MultiLine);
  84219. /** Gets or sets x coordinate */
  84220. get x(): string | number;
  84221. set x(value: string | number);
  84222. /** Gets or sets y coordinate */
  84223. get y(): string | number;
  84224. set y(value: string | number);
  84225. /** Gets or sets the control associated with this point */
  84226. get control(): BABYLON.Nullable<Control>;
  84227. set control(value: BABYLON.Nullable<Control>);
  84228. /** Gets or sets the mesh associated with this point */
  84229. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  84230. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  84231. /** Resets links */
  84232. resetLinks(): void;
  84233. /**
  84234. * Gets a translation vector with Z component
  84235. * @returns the translation vector
  84236. */
  84237. translate(): BABYLON.Vector3;
  84238. private _translatePoint;
  84239. /** Release associated resources */
  84240. dispose(): void;
  84241. }
  84242. }
  84243. declare module BABYLON.GUI {
  84244. /**
  84245. * Class used to create multi line control
  84246. */
  84247. export class MultiLine extends Control {
  84248. name?: string | undefined;
  84249. private _lineWidth;
  84250. private _dash;
  84251. private _points;
  84252. private _minX;
  84253. private _minY;
  84254. private _maxX;
  84255. private _maxY;
  84256. /**
  84257. * Creates a new MultiLine
  84258. * @param name defines the control name
  84259. */
  84260. constructor(name?: string | undefined);
  84261. /** Gets or sets dash pattern */
  84262. get dash(): Array<number>;
  84263. set dash(value: Array<number>);
  84264. /**
  84265. * Gets point stored at specified index
  84266. * @param index defines the index to look for
  84267. * @returns the requested point if found
  84268. */
  84269. getAt(index: number): MultiLinePoint;
  84270. /** Function called when a point is updated */
  84271. onPointUpdate: () => void;
  84272. /**
  84273. * Adds new points to the point collection
  84274. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  84275. * @returns the list of created MultiLinePoint
  84276. */
  84277. add(...items: (AbstractMesh | Control | {
  84278. x: string | number;
  84279. y: string | number;
  84280. })[]): MultiLinePoint[];
  84281. /**
  84282. * Adds a new point to the point collection
  84283. * @param item defines the item (mesh, control or 2d coordiantes) to add
  84284. * @returns the created MultiLinePoint
  84285. */
  84286. push(item?: (AbstractMesh | Control | {
  84287. x: string | number;
  84288. y: string | number;
  84289. })): MultiLinePoint;
  84290. /**
  84291. * Remove a specific value or point from the active point collection
  84292. * @param value defines the value or point to remove
  84293. */
  84294. remove(value: number | MultiLinePoint): void;
  84295. /**
  84296. * Resets this object to initial state (no point)
  84297. */
  84298. reset(): void;
  84299. /**
  84300. * Resets all links
  84301. */
  84302. resetLinks(): void;
  84303. /** Gets or sets line width */
  84304. get lineWidth(): number;
  84305. set lineWidth(value: number);
  84306. set horizontalAlignment(value: number);
  84307. set verticalAlignment(value: number);
  84308. protected _getTypeName(): string;
  84309. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84310. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84311. _measure(): void;
  84312. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84313. dispose(): void;
  84314. }
  84315. }
  84316. declare module BABYLON.GUI {
  84317. /**
  84318. * Class used to create radio button controls
  84319. */
  84320. export class RadioButton extends Control {
  84321. name?: string | undefined;
  84322. private _isChecked;
  84323. private _background;
  84324. private _checkSizeRatio;
  84325. private _thickness;
  84326. /** Gets or sets border thickness */
  84327. get thickness(): number;
  84328. set thickness(value: number);
  84329. /** Gets or sets group name */
  84330. group: string;
  84331. /** BABYLON.Observable raised when isChecked is changed */
  84332. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  84333. /** Gets or sets a value indicating the ratio between overall size and check size */
  84334. get checkSizeRatio(): number;
  84335. set checkSizeRatio(value: number);
  84336. /** Gets or sets background color */
  84337. get background(): string;
  84338. set background(value: string);
  84339. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  84340. get isChecked(): boolean;
  84341. set isChecked(value: boolean);
  84342. /**
  84343. * Creates a new RadioButton
  84344. * @param name defines the control name
  84345. */
  84346. constructor(name?: string | undefined);
  84347. protected _getTypeName(): string;
  84348. _draw(context: CanvasRenderingContext2D): void;
  84349. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84350. /**
  84351. * Utility function to easily create a radio button with a header
  84352. * @param title defines the label to use for the header
  84353. * @param group defines the group to use for the radio button
  84354. * @param isChecked defines the initial state of the radio button
  84355. * @param onValueChanged defines the callback to call when value changes
  84356. * @returns a StackPanel containing the radio button and a textBlock
  84357. */
  84358. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  84359. }
  84360. }
  84361. declare module BABYLON.GUI {
  84362. /**
  84363. * Class used to create slider controls
  84364. */
  84365. export class BaseSlider extends Control {
  84366. name?: string | undefined;
  84367. protected _thumbWidth: ValueAndUnit;
  84368. private _minimum;
  84369. private _maximum;
  84370. private _value;
  84371. private _isVertical;
  84372. protected _barOffset: ValueAndUnit;
  84373. private _isThumbClamped;
  84374. protected _displayThumb: boolean;
  84375. private _step;
  84376. private _lastPointerDownID;
  84377. protected _effectiveBarOffset: number;
  84378. protected _renderLeft: number;
  84379. protected _renderTop: number;
  84380. protected _renderWidth: number;
  84381. protected _renderHeight: number;
  84382. protected _backgroundBoxLength: number;
  84383. protected _backgroundBoxThickness: number;
  84384. protected _effectiveThumbThickness: number;
  84385. /** BABYLON.Observable raised when the sldier value changes */
  84386. onValueChangedObservable: BABYLON.Observable<number>;
  84387. /** Gets or sets a boolean indicating if the thumb must be rendered */
  84388. get displayThumb(): boolean;
  84389. set displayThumb(value: boolean);
  84390. /** Gets or sets a step to apply to values (0 by default) */
  84391. get step(): number;
  84392. set step(value: number);
  84393. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  84394. get barOffset(): string | number;
  84395. /** Gets main bar offset in pixels*/
  84396. get barOffsetInPixels(): number;
  84397. set barOffset(value: string | number);
  84398. /** Gets or sets thumb width */
  84399. get thumbWidth(): string | number;
  84400. /** Gets thumb width in pixels */
  84401. get thumbWidthInPixels(): number;
  84402. set thumbWidth(value: string | number);
  84403. /** Gets or sets minimum value */
  84404. get minimum(): number;
  84405. set minimum(value: number);
  84406. /** Gets or sets maximum value */
  84407. get maximum(): number;
  84408. set maximum(value: number);
  84409. /** Gets or sets current value */
  84410. get value(): number;
  84411. set value(value: number);
  84412. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  84413. get isVertical(): boolean;
  84414. set isVertical(value: boolean);
  84415. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  84416. get isThumbClamped(): boolean;
  84417. set isThumbClamped(value: boolean);
  84418. /**
  84419. * Creates a new BaseSlider
  84420. * @param name defines the control name
  84421. */
  84422. constructor(name?: string | undefined);
  84423. protected _getTypeName(): string;
  84424. protected _getThumbPosition(): number;
  84425. protected _getThumbThickness(type: string): number;
  84426. protected _prepareRenderingData(type: string): void;
  84427. private _pointerIsDown;
  84428. /** @hidden */
  84429. protected _updateValueFromPointer(x: number, y: number): void;
  84430. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84431. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84432. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  84433. _onCanvasBlur(): void;
  84434. }
  84435. }
  84436. declare module BABYLON.GUI {
  84437. /**
  84438. * Class used to create slider controls
  84439. */
  84440. export class Slider extends BaseSlider {
  84441. name?: string | undefined;
  84442. private _background;
  84443. private _borderColor;
  84444. private _thumbColor;
  84445. private _isThumbCircle;
  84446. protected _displayValueBar: boolean;
  84447. /** Gets or sets a boolean indicating if the value bar must be rendered */
  84448. get displayValueBar(): boolean;
  84449. set displayValueBar(value: boolean);
  84450. /** Gets or sets border color */
  84451. get borderColor(): string;
  84452. set borderColor(value: string);
  84453. /** Gets or sets background color */
  84454. get background(): string;
  84455. set background(value: string);
  84456. /** Gets or sets thumb's color */
  84457. get thumbColor(): string;
  84458. set thumbColor(value: string);
  84459. /** Gets or sets a boolean indicating if the thumb should be round or square */
  84460. get isThumbCircle(): boolean;
  84461. set isThumbCircle(value: boolean);
  84462. /**
  84463. * Creates a new Slider
  84464. * @param name defines the control name
  84465. */
  84466. constructor(name?: string | undefined);
  84467. protected _getTypeName(): string;
  84468. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84469. }
  84470. }
  84471. declare module BABYLON.GUI {
  84472. /** Class used to create a RadioGroup
  84473. * which contains groups of radio buttons
  84474. */
  84475. export class SelectorGroup {
  84476. /** name of SelectorGroup */
  84477. name: string;
  84478. private _groupPanel;
  84479. private _selectors;
  84480. private _groupHeader;
  84481. /**
  84482. * Creates a new SelectorGroup
  84483. * @param name of group, used as a group heading
  84484. */
  84485. constructor(
  84486. /** name of SelectorGroup */
  84487. name: string);
  84488. /** Gets the groupPanel of the SelectorGroup */
  84489. get groupPanel(): StackPanel;
  84490. /** Gets the selectors array */
  84491. get selectors(): StackPanel[];
  84492. /** Gets and sets the group header */
  84493. get header(): string;
  84494. set header(label: string);
  84495. /** @hidden */
  84496. private _addGroupHeader;
  84497. /** @hidden*/
  84498. _getSelector(selectorNb: number): StackPanel | undefined;
  84499. /** Removes the selector at the given position
  84500. * @param selectorNb the position of the selector within the group
  84501. */
  84502. removeSelector(selectorNb: number): void;
  84503. }
  84504. /** Class used to create a CheckboxGroup
  84505. * which contains groups of checkbox buttons
  84506. */
  84507. export class CheckboxGroup extends SelectorGroup {
  84508. /** Adds a checkbox as a control
  84509. * @param text is the label for the selector
  84510. * @param func is the function called when the Selector is checked
  84511. * @param checked is true when Selector is checked
  84512. */
  84513. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  84514. /** @hidden */
  84515. _setSelectorLabel(selectorNb: number, label: string): void;
  84516. /** @hidden */
  84517. _setSelectorLabelColor(selectorNb: number, color: string): void;
  84518. /** @hidden */
  84519. _setSelectorButtonColor(selectorNb: number, color: string): void;
  84520. /** @hidden */
  84521. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  84522. }
  84523. /** Class used to create a RadioGroup
  84524. * which contains groups of radio buttons
  84525. */
  84526. export class RadioGroup extends SelectorGroup {
  84527. private _selectNb;
  84528. /** Adds a radio button as a control
  84529. * @param label is the label for the selector
  84530. * @param func is the function called when the Selector is checked
  84531. * @param checked is true when Selector is checked
  84532. */
  84533. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  84534. /** @hidden */
  84535. _setSelectorLabel(selectorNb: number, label: string): void;
  84536. /** @hidden */
  84537. _setSelectorLabelColor(selectorNb: number, color: string): void;
  84538. /** @hidden */
  84539. _setSelectorButtonColor(selectorNb: number, color: string): void;
  84540. /** @hidden */
  84541. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  84542. }
  84543. /** Class used to create a SliderGroup
  84544. * which contains groups of slider buttons
  84545. */
  84546. export class SliderGroup extends SelectorGroup {
  84547. /**
  84548. * Adds a slider to the SelectorGroup
  84549. * @param label is the label for the SliderBar
  84550. * @param func is the function called when the Slider moves
  84551. * @param unit is a string describing the units used, eg degrees or metres
  84552. * @param min is the minimum value for the Slider
  84553. * @param max is the maximum value for the Slider
  84554. * @param value is the start value for the Slider between min and max
  84555. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  84556. */
  84557. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  84558. /** @hidden */
  84559. _setSelectorLabel(selectorNb: number, label: string): void;
  84560. /** @hidden */
  84561. _setSelectorLabelColor(selectorNb: number, color: string): void;
  84562. /** @hidden */
  84563. _setSelectorButtonColor(selectorNb: number, color: string): void;
  84564. /** @hidden */
  84565. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  84566. }
  84567. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  84568. * @see https://doc.babylonjs.com/how_to/selector
  84569. */
  84570. export class SelectionPanel extends Rectangle {
  84571. /** name of SelectionPanel */
  84572. name: string;
  84573. /** an array of SelectionGroups */
  84574. groups: SelectorGroup[];
  84575. private _panel;
  84576. private _buttonColor;
  84577. private _buttonBackground;
  84578. private _headerColor;
  84579. private _barColor;
  84580. private _barHeight;
  84581. private _spacerHeight;
  84582. private _labelColor;
  84583. private _groups;
  84584. private _bars;
  84585. /**
  84586. * Creates a new SelectionPanel
  84587. * @param name of SelectionPanel
  84588. * @param groups is an array of SelectionGroups
  84589. */
  84590. constructor(
  84591. /** name of SelectionPanel */
  84592. name: string,
  84593. /** an array of SelectionGroups */
  84594. groups?: SelectorGroup[]);
  84595. protected _getTypeName(): string;
  84596. /** Gets the (stack) panel of the SelectionPanel */
  84597. get panel(): StackPanel;
  84598. /** Gets or sets the headerColor */
  84599. get headerColor(): string;
  84600. set headerColor(color: string);
  84601. private _setHeaderColor;
  84602. /** Gets or sets the button color */
  84603. get buttonColor(): string;
  84604. set buttonColor(color: string);
  84605. private _setbuttonColor;
  84606. /** Gets or sets the label color */
  84607. get labelColor(): string;
  84608. set labelColor(color: string);
  84609. private _setLabelColor;
  84610. /** Gets or sets the button background */
  84611. get buttonBackground(): string;
  84612. set buttonBackground(color: string);
  84613. private _setButtonBackground;
  84614. /** Gets or sets the color of separator bar */
  84615. get barColor(): string;
  84616. set barColor(color: string);
  84617. private _setBarColor;
  84618. /** Gets or sets the height of separator bar */
  84619. get barHeight(): string;
  84620. set barHeight(value: string);
  84621. private _setBarHeight;
  84622. /** Gets or sets the height of spacers*/
  84623. get spacerHeight(): string;
  84624. set spacerHeight(value: string);
  84625. private _setSpacerHeight;
  84626. /** Adds a bar between groups */
  84627. private _addSpacer;
  84628. /** Add a group to the selection panel
  84629. * @param group is the selector group to add
  84630. */
  84631. addGroup(group: SelectorGroup): void;
  84632. /** Remove the group from the given position
  84633. * @param groupNb is the position of the group in the list
  84634. */
  84635. removeGroup(groupNb: number): void;
  84636. /** Change a group header label
  84637. * @param label is the new group header label
  84638. * @param groupNb is the number of the group to relabel
  84639. * */
  84640. setHeaderName(label: string, groupNb: number): void;
  84641. /** Change selector label to the one given
  84642. * @param label is the new selector label
  84643. * @param groupNb is the number of the groupcontaining the selector
  84644. * @param selectorNb is the number of the selector within a group to relabel
  84645. * */
  84646. relabel(label: string, groupNb: number, selectorNb: number): void;
  84647. /** For a given group position remove the selector at the given position
  84648. * @param groupNb is the number of the group to remove the selector from
  84649. * @param selectorNb is the number of the selector within the group
  84650. */
  84651. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  84652. /** For a given group position of correct type add a checkbox button
  84653. * @param groupNb is the number of the group to remove the selector from
  84654. * @param label is the label for the selector
  84655. * @param func is the function called when the Selector is checked
  84656. * @param checked is true when Selector is checked
  84657. */
  84658. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  84659. /** For a given group position of correct type add a radio button
  84660. * @param groupNb is the number of the group to remove the selector from
  84661. * @param label is the label for the selector
  84662. * @param func is the function called when the Selector is checked
  84663. * @param checked is true when Selector is checked
  84664. */
  84665. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  84666. /**
  84667. * For a given slider group add a slider
  84668. * @param groupNb is the number of the group to add the slider to
  84669. * @param label is the label for the Slider
  84670. * @param func is the function called when the Slider moves
  84671. * @param unit is a string describing the units used, eg degrees or metres
  84672. * @param min is the minimum value for the Slider
  84673. * @param max is the maximum value for the Slider
  84674. * @param value is the start value for the Slider between min and max
  84675. * @param onVal is the function used to format the value displayed, eg radians to degrees
  84676. */
  84677. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  84678. }
  84679. }
  84680. declare module BABYLON.GUI {
  84681. /**
  84682. * Class used to hold a the container for ScrollViewer
  84683. * @hidden
  84684. */
  84685. export class _ScrollViewerWindow extends Container {
  84686. parentClientWidth: number;
  84687. parentClientHeight: number;
  84688. private _freezeControls;
  84689. private _parentMeasure;
  84690. private _oldLeft;
  84691. private _oldTop;
  84692. get freezeControls(): boolean;
  84693. set freezeControls(value: boolean);
  84694. private _bucketWidth;
  84695. private _bucketHeight;
  84696. private _buckets;
  84697. private _bucketLen;
  84698. get bucketWidth(): number;
  84699. get bucketHeight(): number;
  84700. setBucketSizes(width: number, height: number): void;
  84701. private _useBuckets;
  84702. private _makeBuckets;
  84703. private _dispatchInBuckets;
  84704. private _updateMeasures;
  84705. private _updateChildrenMeasures;
  84706. private _restoreMeasures;
  84707. /**
  84708. * Creates a new ScrollViewerWindow
  84709. * @param name of ScrollViewerWindow
  84710. */
  84711. constructor(name?: string);
  84712. protected _getTypeName(): string;
  84713. /** @hidden */
  84714. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84715. /** @hidden */
  84716. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  84717. private _scrollChildren;
  84718. private _scrollChildrenWithBuckets;
  84719. /** @hidden */
  84720. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  84721. protected _postMeasure(): void;
  84722. }
  84723. }
  84724. declare module BABYLON.GUI {
  84725. /**
  84726. * Class used to create slider controls
  84727. */
  84728. export class ScrollBar extends BaseSlider {
  84729. name?: string | undefined;
  84730. private _background;
  84731. private _borderColor;
  84732. private _tempMeasure;
  84733. /** Gets or sets border color */
  84734. get borderColor(): string;
  84735. set borderColor(value: string);
  84736. /** Gets or sets background color */
  84737. get background(): string;
  84738. set background(value: string);
  84739. /**
  84740. * Creates a new Slider
  84741. * @param name defines the control name
  84742. */
  84743. constructor(name?: string | undefined);
  84744. protected _getTypeName(): string;
  84745. protected _getThumbThickness(): number;
  84746. _draw(context: CanvasRenderingContext2D): void;
  84747. private _first;
  84748. private _originX;
  84749. private _originY;
  84750. /** @hidden */
  84751. protected _updateValueFromPointer(x: number, y: number): void;
  84752. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84753. }
  84754. }
  84755. declare module BABYLON.GUI {
  84756. /**
  84757. * Class used to create slider controls
  84758. */
  84759. export class ImageScrollBar extends BaseSlider {
  84760. name?: string | undefined;
  84761. private _backgroundBaseImage;
  84762. private _backgroundImage;
  84763. private _thumbImage;
  84764. private _thumbBaseImage;
  84765. private _thumbLength;
  84766. private _thumbHeight;
  84767. private _barImageHeight;
  84768. private _tempMeasure;
  84769. /** Number of 90° rotation to apply on the images when in vertical mode */
  84770. num90RotationInVerticalMode: number;
  84771. /**
  84772. * Gets or sets the image used to render the background for horizontal bar
  84773. */
  84774. get backgroundImage(): Image;
  84775. set backgroundImage(value: Image);
  84776. /**
  84777. * Gets or sets the image used to render the thumb
  84778. */
  84779. get thumbImage(): Image;
  84780. set thumbImage(value: Image);
  84781. /**
  84782. * Gets or sets the length of the thumb
  84783. */
  84784. get thumbLength(): number;
  84785. set thumbLength(value: number);
  84786. /**
  84787. * Gets or sets the height of the thumb
  84788. */
  84789. get thumbHeight(): number;
  84790. set thumbHeight(value: number);
  84791. /**
  84792. * Gets or sets the height of the bar image
  84793. */
  84794. get barImageHeight(): number;
  84795. set barImageHeight(value: number);
  84796. /**
  84797. * Creates a new ImageScrollBar
  84798. * @param name defines the control name
  84799. */
  84800. constructor(name?: string | undefined);
  84801. protected _getTypeName(): string;
  84802. protected _getThumbThickness(): number;
  84803. _draw(context: CanvasRenderingContext2D): void;
  84804. private _first;
  84805. private _originX;
  84806. private _originY;
  84807. /** @hidden */
  84808. protected _updateValueFromPointer(x: number, y: number): void;
  84809. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84810. }
  84811. }
  84812. declare module BABYLON.GUI {
  84813. /**
  84814. * Class used to hold a viewer window and sliders in a grid
  84815. */
  84816. export class ScrollViewer extends Rectangle {
  84817. private _grid;
  84818. private _horizontalBarSpace;
  84819. private _verticalBarSpace;
  84820. private _dragSpace;
  84821. private _horizontalBar;
  84822. private _verticalBar;
  84823. private _barColor;
  84824. private _barBackground;
  84825. private _barImage;
  84826. private _horizontalBarImage;
  84827. private _verticalBarImage;
  84828. private _barBackgroundImage;
  84829. private _horizontalBarBackgroundImage;
  84830. private _verticalBarBackgroundImage;
  84831. private _barSize;
  84832. private _window;
  84833. private _pointerIsOver;
  84834. private _wheelPrecision;
  84835. private _onWheelObserver;
  84836. private _clientWidth;
  84837. private _clientHeight;
  84838. private _useImageBar;
  84839. private _thumbLength;
  84840. private _thumbHeight;
  84841. private _barImageHeight;
  84842. private _horizontalBarImageHeight;
  84843. private _verticalBarImageHeight;
  84844. private _oldWindowContentsWidth;
  84845. private _oldWindowContentsHeight;
  84846. /**
  84847. * Gets the horizontal scrollbar
  84848. */
  84849. get horizontalBar(): ScrollBar | ImageScrollBar;
  84850. /**
  84851. * Gets the vertical scrollbar
  84852. */
  84853. get verticalBar(): ScrollBar | ImageScrollBar;
  84854. /**
  84855. * Adds a new control to the current container
  84856. * @param control defines the control to add
  84857. * @returns the current container
  84858. */
  84859. addControl(control: BABYLON.Nullable<Control>): Container;
  84860. /**
  84861. * Removes a control from the current container
  84862. * @param control defines the control to remove
  84863. * @returns the current container
  84864. */
  84865. removeControl(control: Control): Container;
  84866. /** Gets the list of children */
  84867. get children(): Control[];
  84868. _flagDescendantsAsMatrixDirty(): void;
  84869. /**
  84870. * Freezes or unfreezes the controls in the window.
  84871. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  84872. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  84873. */
  84874. get freezeControls(): boolean;
  84875. set freezeControls(value: boolean);
  84876. /** Gets the bucket width */
  84877. get bucketWidth(): number;
  84878. /** Gets the bucket height */
  84879. get bucketHeight(): number;
  84880. /**
  84881. * Sets the bucket sizes.
  84882. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  84883. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  84884. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  84885. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  84886. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  84887. * used), that's why it is not enabled by default.
  84888. * @param width width of the bucket
  84889. * @param height height of the bucket
  84890. */
  84891. setBucketSizes(width: number, height: number): void;
  84892. private _forceHorizontalBar;
  84893. private _forceVerticalBar;
  84894. /**
  84895. * Forces the horizontal scroll bar to be displayed
  84896. */
  84897. get forceHorizontalBar(): boolean;
  84898. set forceHorizontalBar(value: boolean);
  84899. /**
  84900. * Forces the vertical scroll bar to be displayed
  84901. */
  84902. get forceVerticalBar(): boolean;
  84903. set forceVerticalBar(value: boolean);
  84904. /**
  84905. * Creates a new ScrollViewer
  84906. * @param name of ScrollViewer
  84907. */
  84908. constructor(name?: string, isImageBased?: boolean);
  84909. /** Reset the scroll viewer window to initial size */
  84910. resetWindow(): void;
  84911. protected _getTypeName(): string;
  84912. private _buildClientSizes;
  84913. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84914. protected _postMeasure(): void;
  84915. /**
  84916. * Gets or sets the mouse wheel precision
  84917. * from 0 to 1 with a default value of 0.05
  84918. * */
  84919. get wheelPrecision(): number;
  84920. set wheelPrecision(value: number);
  84921. /** Gets or sets the scroll bar container background color */
  84922. get scrollBackground(): string;
  84923. set scrollBackground(color: string);
  84924. /** Gets or sets the bar color */
  84925. get barColor(): string;
  84926. set barColor(color: string);
  84927. /** Gets or sets the bar image */
  84928. get thumbImage(): Image;
  84929. set thumbImage(value: Image);
  84930. /** Gets or sets the horizontal bar image */
  84931. get horizontalThumbImage(): Image;
  84932. set horizontalThumbImage(value: Image);
  84933. /** Gets or sets the vertical bar image */
  84934. get verticalThumbImage(): Image;
  84935. set verticalThumbImage(value: Image);
  84936. /** Gets or sets the size of the bar */
  84937. get barSize(): number;
  84938. set barSize(value: number);
  84939. /** Gets or sets the length of the thumb */
  84940. get thumbLength(): number;
  84941. set thumbLength(value: number);
  84942. /** Gets or sets the height of the thumb */
  84943. get thumbHeight(): number;
  84944. set thumbHeight(value: number);
  84945. /** Gets or sets the height of the bar image */
  84946. get barImageHeight(): number;
  84947. set barImageHeight(value: number);
  84948. /** Gets or sets the height of the horizontal bar image */
  84949. get horizontalBarImageHeight(): number;
  84950. set horizontalBarImageHeight(value: number);
  84951. /** Gets or sets the height of the vertical bar image */
  84952. get verticalBarImageHeight(): number;
  84953. set verticalBarImageHeight(value: number);
  84954. /** Gets or sets the bar background */
  84955. get barBackground(): string;
  84956. set barBackground(color: string);
  84957. /** Gets or sets the bar background image */
  84958. get barImage(): Image;
  84959. set barImage(value: Image);
  84960. /** Gets or sets the horizontal bar background image */
  84961. get horizontalBarImage(): Image;
  84962. set horizontalBarImage(value: Image);
  84963. /** Gets or sets the vertical bar background image */
  84964. get verticalBarImage(): Image;
  84965. set verticalBarImage(value: Image);
  84966. private _setWindowPosition;
  84967. /** @hidden */
  84968. private _updateScroller;
  84969. _link(host: AdvancedDynamicTexture): void;
  84970. /** @hidden */
  84971. private _addBar;
  84972. /** @hidden */
  84973. private _attachWheel;
  84974. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  84975. /** Releases associated resources */
  84976. dispose(): void;
  84977. }
  84978. }
  84979. declare module BABYLON.GUI {
  84980. /** Class used to render a grid */
  84981. export class DisplayGrid extends Control {
  84982. name?: string | undefined;
  84983. private _cellWidth;
  84984. private _cellHeight;
  84985. private _minorLineTickness;
  84986. private _minorLineColor;
  84987. private _majorLineTickness;
  84988. private _majorLineColor;
  84989. private _majorLineFrequency;
  84990. private _background;
  84991. private _displayMajorLines;
  84992. private _displayMinorLines;
  84993. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  84994. get displayMinorLines(): boolean;
  84995. set displayMinorLines(value: boolean);
  84996. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  84997. get displayMajorLines(): boolean;
  84998. set displayMajorLines(value: boolean);
  84999. /** Gets or sets background color (Black by default) */
  85000. get background(): string;
  85001. set background(value: string);
  85002. /** Gets or sets the width of each cell (20 by default) */
  85003. get cellWidth(): number;
  85004. set cellWidth(value: number);
  85005. /** Gets or sets the height of each cell (20 by default) */
  85006. get cellHeight(): number;
  85007. set cellHeight(value: number);
  85008. /** Gets or sets the tickness of minor lines (1 by default) */
  85009. get minorLineTickness(): number;
  85010. set minorLineTickness(value: number);
  85011. /** Gets or sets the color of minor lines (DarkGray by default) */
  85012. get minorLineColor(): string;
  85013. set minorLineColor(value: string);
  85014. /** Gets or sets the tickness of major lines (2 by default) */
  85015. get majorLineTickness(): number;
  85016. set majorLineTickness(value: number);
  85017. /** Gets or sets the color of major lines (White by default) */
  85018. get majorLineColor(): string;
  85019. set majorLineColor(value: string);
  85020. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  85021. get majorLineFrequency(): number;
  85022. set majorLineFrequency(value: number);
  85023. /**
  85024. * Creates a new GridDisplayRectangle
  85025. * @param name defines the control name
  85026. */
  85027. constructor(name?: string | undefined);
  85028. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85029. protected _getTypeName(): string;
  85030. }
  85031. }
  85032. declare module BABYLON.GUI {
  85033. /**
  85034. * Class used to create slider controls based on images
  85035. */
  85036. export class ImageBasedSlider extends BaseSlider {
  85037. name?: string | undefined;
  85038. private _backgroundImage;
  85039. private _thumbImage;
  85040. private _valueBarImage;
  85041. private _tempMeasure;
  85042. get displayThumb(): boolean;
  85043. set displayThumb(value: boolean);
  85044. /**
  85045. * Gets or sets the image used to render the background
  85046. */
  85047. get backgroundImage(): Image;
  85048. set backgroundImage(value: Image);
  85049. /**
  85050. * Gets or sets the image used to render the value bar
  85051. */
  85052. get valueBarImage(): Image;
  85053. set valueBarImage(value: Image);
  85054. /**
  85055. * Gets or sets the image used to render the thumb
  85056. */
  85057. get thumbImage(): Image;
  85058. set thumbImage(value: Image);
  85059. /**
  85060. * Creates a new ImageBasedSlider
  85061. * @param name defines the control name
  85062. */
  85063. constructor(name?: string | undefined);
  85064. protected _getTypeName(): string;
  85065. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85066. }
  85067. }
  85068. declare module BABYLON.GUI {
  85069. /**
  85070. * Forcing an export so that this code will execute
  85071. * @hidden
  85072. */
  85073. const name = "Statics";
  85074. }
  85075. declare module BABYLON.GUI {
  85076. /**
  85077. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  85078. */
  85079. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  85080. /**
  85081. * Define the instrumented AdvancedDynamicTexture.
  85082. */
  85083. texture: AdvancedDynamicTexture;
  85084. private _captureRenderTime;
  85085. private _renderTime;
  85086. private _captureLayoutTime;
  85087. private _layoutTime;
  85088. private _onBeginRenderObserver;
  85089. private _onEndRenderObserver;
  85090. private _onBeginLayoutObserver;
  85091. private _onEndLayoutObserver;
  85092. /**
  85093. * Gets the perf counter used to capture render time
  85094. */
  85095. get renderTimeCounter(): BABYLON.PerfCounter;
  85096. /**
  85097. * Gets the perf counter used to capture layout time
  85098. */
  85099. get layoutTimeCounter(): BABYLON.PerfCounter;
  85100. /**
  85101. * Enable or disable the render time capture
  85102. */
  85103. get captureRenderTime(): boolean;
  85104. set captureRenderTime(value: boolean);
  85105. /**
  85106. * Enable or disable the layout time capture
  85107. */
  85108. get captureLayoutTime(): boolean;
  85109. set captureLayoutTime(value: boolean);
  85110. /**
  85111. * Instantiates a new advanced dynamic texture instrumentation.
  85112. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  85113. * @param texture Defines the AdvancedDynamicTexture to instrument
  85114. */
  85115. constructor(
  85116. /**
  85117. * Define the instrumented AdvancedDynamicTexture.
  85118. */
  85119. texture: AdvancedDynamicTexture);
  85120. /**
  85121. * Dispose and release associated resources.
  85122. */
  85123. dispose(): void;
  85124. }
  85125. }
  85126. declare module BABYLON.GUI {
  85127. /**
  85128. * Class used to load GUI via XML.
  85129. */
  85130. export class XmlLoader {
  85131. private _nodes;
  85132. private _nodeTypes;
  85133. private _isLoaded;
  85134. private _objectAttributes;
  85135. private _parentClass;
  85136. /**
  85137. * Create a new xml loader
  85138. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  85139. */
  85140. constructor(parentClass?: null);
  85141. private _getChainElement;
  85142. private _getClassAttribute;
  85143. private _createGuiElement;
  85144. private _parseGrid;
  85145. private _parseElement;
  85146. private _prepareSourceElement;
  85147. private _parseElementsFromSource;
  85148. private _parseXml;
  85149. /**
  85150. * Gets if the loading has finished.
  85151. * @returns whether the loading has finished or not
  85152. */
  85153. isLoaded(): boolean;
  85154. /**
  85155. * Gets a loaded node / control by id.
  85156. * @param id the Controls id set in the xml
  85157. * @returns element of type Control
  85158. */
  85159. getNodeById(id: string): any;
  85160. /**
  85161. * Gets all loaded nodes / controls
  85162. * @returns Array of controls
  85163. */
  85164. getNodes(): any;
  85165. /**
  85166. * Initiates the xml layout loading
  85167. * @param xmlFile defines the xml layout to load
  85168. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  85169. * @param callback defines the callback called on layout load.
  85170. */
  85171. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  85172. }
  85173. }
  85174. declare module BABYLON.GUI {
  85175. /**
  85176. * Class used to create containers for controls
  85177. */
  85178. export class Container3D extends Control3D {
  85179. private _blockLayout;
  85180. /**
  85181. * Gets the list of child controls
  85182. */
  85183. protected _children: Control3D[];
  85184. /**
  85185. * Gets the list of child controls
  85186. */
  85187. get children(): Array<Control3D>;
  85188. /**
  85189. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  85190. * This is helpful to optimize layout operation when adding multiple children in a row
  85191. */
  85192. get blockLayout(): boolean;
  85193. set blockLayout(value: boolean);
  85194. /**
  85195. * Creates a new container
  85196. * @param name defines the container name
  85197. */
  85198. constructor(name?: string);
  85199. /**
  85200. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  85201. * @returns the current container
  85202. */
  85203. updateLayout(): Container3D;
  85204. /**
  85205. * Gets a boolean indicating if the given control is in the children of this control
  85206. * @param control defines the control to check
  85207. * @returns true if the control is in the child list
  85208. */
  85209. containsControl(control: Control3D): boolean;
  85210. /**
  85211. * Adds a control to the children of this control
  85212. * @param control defines the control to add
  85213. * @returns the current container
  85214. */
  85215. addControl(control: Control3D): Container3D;
  85216. /**
  85217. * This function will be called everytime a new control is added
  85218. */
  85219. protected _arrangeChildren(): void;
  85220. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  85221. /**
  85222. * Removes a control from the children of this control
  85223. * @param control defines the control to remove
  85224. * @returns the current container
  85225. */
  85226. removeControl(control: Control3D): Container3D;
  85227. protected _getTypeName(): string;
  85228. /**
  85229. * Releases all associated resources
  85230. */
  85231. dispose(): void;
  85232. /** Control rotation will remain unchanged */
  85233. static readonly UNSET_ORIENTATION: number;
  85234. /** Control will rotate to make it look at sphere central axis */
  85235. static readonly FACEORIGIN_ORIENTATION: number;
  85236. /** Control will rotate to make it look back at sphere central axis */
  85237. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  85238. /** Control will rotate to look at z axis (0, 0, 1) */
  85239. static readonly FACEFORWARD_ORIENTATION: number;
  85240. /** Control will rotate to look at negative z axis (0, 0, -1) */
  85241. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  85242. }
  85243. }
  85244. declare module BABYLON.GUI {
  85245. /**
  85246. * Class used to manage 3D user interface
  85247. * @see https://doc.babylonjs.com/how_to/gui3d
  85248. */
  85249. export class GUI3DManager implements BABYLON.IDisposable {
  85250. private _scene;
  85251. private _sceneDisposeObserver;
  85252. private _utilityLayer;
  85253. private _rootContainer;
  85254. private _pointerObserver;
  85255. private _pointerOutObserver;
  85256. /** @hidden */
  85257. _lastPickedControl: Control3D;
  85258. /** @hidden */
  85259. _lastControlOver: {
  85260. [pointerId: number]: Control3D;
  85261. };
  85262. /** @hidden */
  85263. _lastControlDown: {
  85264. [pointerId: number]: Control3D;
  85265. };
  85266. /**
  85267. * BABYLON.Observable raised when the point picked by the pointer events changed
  85268. */
  85269. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  85270. /** @hidden */
  85271. _sharedMaterials: {
  85272. [key: string]: BABYLON.Material;
  85273. };
  85274. /** Gets the hosting scene */
  85275. get scene(): BABYLON.Scene;
  85276. /** Gets associated utility layer */
  85277. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  85278. /**
  85279. * Creates a new GUI3DManager
  85280. * @param scene
  85281. */
  85282. constructor(scene?: BABYLON.Scene);
  85283. private _handlePointerOut;
  85284. private _doPicking;
  85285. /**
  85286. * Gets the root container
  85287. */
  85288. get rootContainer(): Container3D;
  85289. /**
  85290. * Gets a boolean indicating if the given control is in the root child list
  85291. * @param control defines the control to check
  85292. * @returns true if the control is in the root child list
  85293. */
  85294. containsControl(control: Control3D): boolean;
  85295. /**
  85296. * Adds a control to the root child list
  85297. * @param control defines the control to add
  85298. * @returns the current manager
  85299. */
  85300. addControl(control: Control3D): GUI3DManager;
  85301. /**
  85302. * Removes a control from the root child list
  85303. * @param control defines the control to remove
  85304. * @returns the current container
  85305. */
  85306. removeControl(control: Control3D): GUI3DManager;
  85307. /**
  85308. * Releases all associated resources
  85309. */
  85310. dispose(): void;
  85311. }
  85312. }
  85313. declare module BABYLON.GUI {
  85314. /**
  85315. * Class used to transport BABYLON.Vector3 information for pointer events
  85316. */
  85317. export class Vector3WithInfo extends BABYLON.Vector3 {
  85318. /** defines the current mouse button index */
  85319. buttonIndex: number;
  85320. /**
  85321. * Creates a new Vector3WithInfo
  85322. * @param source defines the vector3 data to transport
  85323. * @param buttonIndex defines the current mouse button index
  85324. */
  85325. constructor(source: BABYLON.Vector3,
  85326. /** defines the current mouse button index */
  85327. buttonIndex?: number);
  85328. }
  85329. }
  85330. declare module BABYLON.GUI {
  85331. /**
  85332. * Class used as base class for controls
  85333. */
  85334. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  85335. /** Defines the control name */
  85336. name?: string | undefined;
  85337. /** @hidden */
  85338. _host: GUI3DManager;
  85339. private _node;
  85340. private _downCount;
  85341. private _enterCount;
  85342. private _downPointerIds;
  85343. private _isVisible;
  85344. /** Gets or sets the control position in world space */
  85345. get position(): BABYLON.Vector3;
  85346. set position(value: BABYLON.Vector3);
  85347. /** Gets or sets the control scaling in world space */
  85348. get scaling(): BABYLON.Vector3;
  85349. set scaling(value: BABYLON.Vector3);
  85350. /** Callback used to start pointer enter animation */
  85351. pointerEnterAnimation: () => void;
  85352. /** Callback used to start pointer out animation */
  85353. pointerOutAnimation: () => void;
  85354. /** Callback used to start pointer down animation */
  85355. pointerDownAnimation: () => void;
  85356. /** Callback used to start pointer up animation */
  85357. pointerUpAnimation: () => void;
  85358. /**
  85359. * An event triggered when the pointer move over the control
  85360. */
  85361. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  85362. /**
  85363. * An event triggered when the pointer move out of the control
  85364. */
  85365. onPointerOutObservable: BABYLON.Observable<Control3D>;
  85366. /**
  85367. * An event triggered when the pointer taps the control
  85368. */
  85369. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  85370. /**
  85371. * An event triggered when pointer is up
  85372. */
  85373. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  85374. /**
  85375. * An event triggered when a control is clicked on (with a mouse)
  85376. */
  85377. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  85378. /**
  85379. * An event triggered when pointer enters the control
  85380. */
  85381. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  85382. /**
  85383. * Gets or sets the parent container
  85384. */
  85385. parent: BABYLON.Nullable<Container3D>;
  85386. private _behaviors;
  85387. /**
  85388. * Gets the list of attached behaviors
  85389. * @see https://doc.babylonjs.com/features/behaviour
  85390. */
  85391. get behaviors(): BABYLON.Behavior<Control3D>[];
  85392. /**
  85393. * Attach a behavior to the control
  85394. * @see https://doc.babylonjs.com/features/behaviour
  85395. * @param behavior defines the behavior to attach
  85396. * @returns the current control
  85397. */
  85398. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  85399. /**
  85400. * Remove an attached behavior
  85401. * @see https://doc.babylonjs.com/features/behaviour
  85402. * @param behavior defines the behavior to attach
  85403. * @returns the current control
  85404. */
  85405. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  85406. /**
  85407. * Gets an attached behavior by name
  85408. * @param name defines the name of the behavior to look for
  85409. * @see https://doc.babylonjs.com/features/behaviour
  85410. * @returns null if behavior was not found else the requested behavior
  85411. */
  85412. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  85413. /** Gets or sets a boolean indicating if the control is visible */
  85414. get isVisible(): boolean;
  85415. set isVisible(value: boolean);
  85416. /**
  85417. * Creates a new control
  85418. * @param name defines the control name
  85419. */
  85420. constructor(
  85421. /** Defines the control name */
  85422. name?: string | undefined);
  85423. /**
  85424. * Gets a string representing the class name
  85425. */
  85426. get typeName(): string;
  85427. /**
  85428. * Get the current class name of the control.
  85429. * @returns current class name
  85430. */
  85431. getClassName(): string;
  85432. protected _getTypeName(): string;
  85433. /**
  85434. * Gets the transform node used by this control
  85435. */
  85436. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  85437. /**
  85438. * Gets the mesh used to render this control
  85439. */
  85440. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  85441. /**
  85442. * Link the control as child of the given node
  85443. * @param node defines the node to link to. Use null to unlink the control
  85444. * @returns the current control
  85445. */
  85446. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  85447. /** @hidden **/
  85448. _prepareNode(scene: BABYLON.Scene): void;
  85449. /**
  85450. * Node creation.
  85451. * Can be overriden by children
  85452. * @param scene defines the scene where the node must be attached
  85453. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  85454. */
  85455. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  85456. /**
  85457. * Affect a material to the given mesh
  85458. * @param mesh defines the mesh which will represent the control
  85459. */
  85460. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  85461. /** @hidden */
  85462. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  85463. /** @hidden */
  85464. _onPointerEnter(target: Control3D): boolean;
  85465. /** @hidden */
  85466. _onPointerOut(target: Control3D): void;
  85467. /** @hidden */
  85468. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  85469. /** @hidden */
  85470. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  85471. /** @hidden */
  85472. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  85473. /** @hidden */
  85474. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  85475. /** @hidden */
  85476. _disposeNode(): void;
  85477. /**
  85478. * Releases all associated resources
  85479. */
  85480. dispose(): void;
  85481. }
  85482. }
  85483. declare module BABYLON.GUI {
  85484. /**
  85485. * Class used as a root to all buttons
  85486. */
  85487. export class AbstractButton3D extends Control3D {
  85488. /**
  85489. * Creates a new button
  85490. * @param name defines the control name
  85491. */
  85492. constructor(name?: string);
  85493. protected _getTypeName(): string;
  85494. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  85495. }
  85496. }
  85497. declare module BABYLON.GUI {
  85498. /**
  85499. * Class used to create a button in 3D
  85500. */
  85501. export class Button3D extends AbstractButton3D {
  85502. /** @hidden */
  85503. protected _currentMaterial: BABYLON.Material;
  85504. private _facadeTexture;
  85505. private _content;
  85506. private _contentResolution;
  85507. private _contentScaleRatio;
  85508. /**
  85509. * Gets or sets the texture resolution used to render content (512 by default)
  85510. */
  85511. get contentResolution(): BABYLON.int;
  85512. set contentResolution(value: BABYLON.int);
  85513. /**
  85514. * Gets or sets the texture scale ratio used to render content (2 by default)
  85515. */
  85516. get contentScaleRatio(): number;
  85517. set contentScaleRatio(value: number);
  85518. protected _disposeFacadeTexture(): void;
  85519. protected _resetContent(): void;
  85520. /**
  85521. * Creates a new button
  85522. * @param name defines the control name
  85523. */
  85524. constructor(name?: string);
  85525. /**
  85526. * Gets or sets the GUI 2D content used to display the button's facade
  85527. */
  85528. get content(): Control;
  85529. set content(value: Control);
  85530. /**
  85531. * Apply the facade texture (created from the content property).
  85532. * This function can be overloaded by child classes
  85533. * @param facadeTexture defines the AdvancedDynamicTexture to use
  85534. */
  85535. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  85536. protected _getTypeName(): string;
  85537. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  85538. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  85539. /**
  85540. * Releases all associated resources
  85541. */
  85542. dispose(): void;
  85543. }
  85544. }
  85545. declare module BABYLON.GUI {
  85546. /**
  85547. * Abstract class used to create a container panel deployed on the surface of a volume
  85548. */
  85549. export abstract class VolumeBasedPanel extends Container3D {
  85550. private _columns;
  85551. private _rows;
  85552. private _rowThenColum;
  85553. private _orientation;
  85554. protected _cellWidth: number;
  85555. protected _cellHeight: number;
  85556. /**
  85557. * Gets or sets the distance between elements
  85558. */
  85559. margin: number;
  85560. /**
  85561. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  85562. * | Value | Type | Description |
  85563. * | ----- | ----------------------------------- | ----------- |
  85564. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  85565. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  85566. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  85567. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  85568. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  85569. */
  85570. get orientation(): number;
  85571. set orientation(value: number);
  85572. /**
  85573. * Gets or sets the number of columns requested (10 by default).
  85574. * The panel will automatically compute the number of rows based on number of child controls.
  85575. */
  85576. get columns(): BABYLON.int;
  85577. set columns(value: BABYLON.int);
  85578. /**
  85579. * Gets or sets a the number of rows requested.
  85580. * The panel will automatically compute the number of columns based on number of child controls.
  85581. */
  85582. get rows(): BABYLON.int;
  85583. set rows(value: BABYLON.int);
  85584. /**
  85585. * Creates new VolumeBasedPanel
  85586. */
  85587. constructor();
  85588. protected _arrangeChildren(): void;
  85589. /** Child classes must implement this function to provide correct control positioning */
  85590. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  85591. /** Child classes can implement this function to provide additional processing */
  85592. protected _finalProcessing(): void;
  85593. }
  85594. }
  85595. declare module BABYLON.GUI {
  85596. /**
  85597. * Class used to create a container panel deployed on the surface of a cylinder
  85598. */
  85599. export class CylinderPanel extends VolumeBasedPanel {
  85600. private _radius;
  85601. /**
  85602. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  85603. */
  85604. get radius(): BABYLON.float;
  85605. set radius(value: BABYLON.float);
  85606. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  85607. private _cylindricalMapping;
  85608. }
  85609. }
  85610. declare module BABYLON.GUI {
  85611. /** @hidden */
  85612. export var fluentVertexShader: {
  85613. name: string;
  85614. shader: string;
  85615. };
  85616. }
  85617. declare module BABYLON.GUI {
  85618. /** @hidden */
  85619. export var fluentPixelShader: {
  85620. name: string;
  85621. shader: string;
  85622. };
  85623. }
  85624. declare module BABYLON.GUI {
  85625. /** @hidden */
  85626. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  85627. INNERGLOW: boolean;
  85628. BORDER: boolean;
  85629. HOVERLIGHT: boolean;
  85630. TEXTURE: boolean;
  85631. constructor();
  85632. }
  85633. /**
  85634. * Class used to render controls with fluent desgin
  85635. */
  85636. export class FluentMaterial extends BABYLON.PushMaterial {
  85637. /**
  85638. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  85639. */
  85640. innerGlowColorIntensity: number;
  85641. /**
  85642. * Gets or sets the inner glow color (white by default)
  85643. */
  85644. innerGlowColor: BABYLON.Color3;
  85645. /**
  85646. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  85647. */
  85648. albedoColor: BABYLON.Color3;
  85649. /**
  85650. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  85651. */
  85652. renderBorders: boolean;
  85653. /**
  85654. * Gets or sets border width (default is 0.5)
  85655. */
  85656. borderWidth: number;
  85657. /**
  85658. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  85659. */
  85660. edgeSmoothingValue: number;
  85661. /**
  85662. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  85663. */
  85664. borderMinValue: number;
  85665. /**
  85666. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  85667. */
  85668. renderHoverLight: boolean;
  85669. /**
  85670. * Gets or sets the radius used to render the hover light (default is 1.0)
  85671. */
  85672. hoverRadius: number;
  85673. /**
  85674. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  85675. */
  85676. hoverColor: BABYLON.Color4;
  85677. /**
  85678. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  85679. */
  85680. hoverPosition: BABYLON.Vector3;
  85681. private _albedoTexture;
  85682. /** Gets or sets the texture to use for albedo color */
  85683. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85684. /**
  85685. * Creates a new Fluent material
  85686. * @param name defines the name of the material
  85687. * @param scene defines the hosting scene
  85688. */
  85689. constructor(name: string, scene: BABYLON.Scene);
  85690. needAlphaBlending(): boolean;
  85691. needAlphaTesting(): boolean;
  85692. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85693. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85694. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85695. getActiveTextures(): BABYLON.BaseTexture[];
  85696. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85697. dispose(forceDisposeEffect?: boolean): void;
  85698. clone(name: string): FluentMaterial;
  85699. serialize(): any;
  85700. getClassName(): string;
  85701. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  85702. }
  85703. }
  85704. declare module BABYLON.GUI {
  85705. /**
  85706. * Class used to create a holographic button in 3D
  85707. */
  85708. export class HolographicButton extends Button3D {
  85709. private _backPlate;
  85710. private _textPlate;
  85711. private _frontPlate;
  85712. private _text;
  85713. private _imageUrl;
  85714. private _shareMaterials;
  85715. private _frontMaterial;
  85716. private _backMaterial;
  85717. private _plateMaterial;
  85718. private _pickedPointObserver;
  85719. private _tooltipFade;
  85720. private _tooltipTextBlock;
  85721. private _tooltipTexture;
  85722. private _tooltipMesh;
  85723. private _tooltipHoverObserver;
  85724. private _tooltipOutObserver;
  85725. private _disposeTooltip;
  85726. /**
  85727. * Rendering ground id of all the mesh in the button
  85728. */
  85729. set renderingGroupId(id: number);
  85730. get renderingGroupId(): number;
  85731. /**
  85732. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  85733. */
  85734. set tooltipText(text: BABYLON.Nullable<string>);
  85735. get tooltipText(): BABYLON.Nullable<string>;
  85736. /**
  85737. * Gets or sets text for the button
  85738. */
  85739. get text(): string;
  85740. set text(value: string);
  85741. /**
  85742. * Gets or sets the image url for the button
  85743. */
  85744. get imageUrl(): string;
  85745. set imageUrl(value: string);
  85746. /**
  85747. * Gets the back material used by this button
  85748. */
  85749. get backMaterial(): FluentMaterial;
  85750. /**
  85751. * Gets the front material used by this button
  85752. */
  85753. get frontMaterial(): FluentMaterial;
  85754. /**
  85755. * Gets the plate material used by this button
  85756. */
  85757. get plateMaterial(): BABYLON.StandardMaterial;
  85758. /**
  85759. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  85760. */
  85761. get shareMaterials(): boolean;
  85762. /**
  85763. * Creates a new button
  85764. * @param name defines the control name
  85765. */
  85766. constructor(name?: string, shareMaterials?: boolean);
  85767. protected _getTypeName(): string;
  85768. private _rebuildContent;
  85769. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  85770. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  85771. private _createBackMaterial;
  85772. private _createFrontMaterial;
  85773. private _createPlateMaterial;
  85774. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  85775. /**
  85776. * Releases all associated resources
  85777. */
  85778. dispose(): void;
  85779. }
  85780. }
  85781. declare module BABYLON.GUI {
  85782. /**
  85783. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  85784. */
  85785. export class MeshButton3D extends Button3D {
  85786. /** @hidden */
  85787. protected _currentMesh: BABYLON.Mesh;
  85788. /**
  85789. * Creates a new 3D button based on a mesh
  85790. * @param mesh mesh to become a 3D button
  85791. * @param name defines the control name
  85792. */
  85793. constructor(mesh: BABYLON.Mesh, name?: string);
  85794. protected _getTypeName(): string;
  85795. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  85796. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  85797. }
  85798. }
  85799. declare module BABYLON.GUI {
  85800. /**
  85801. * Class used to create a container panel deployed on the surface of a plane
  85802. */
  85803. export class PlanePanel extends VolumeBasedPanel {
  85804. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  85805. }
  85806. }
  85807. declare module BABYLON.GUI {
  85808. /**
  85809. * Class used to create a container panel where items get randomized planar mapping
  85810. */
  85811. export class ScatterPanel extends VolumeBasedPanel {
  85812. private _iteration;
  85813. /**
  85814. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  85815. */
  85816. get iteration(): BABYLON.float;
  85817. set iteration(value: BABYLON.float);
  85818. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  85819. private _scatterMapping;
  85820. protected _finalProcessing(): void;
  85821. }
  85822. }
  85823. declare module BABYLON.GUI {
  85824. /**
  85825. * Class used to create a container panel deployed on the surface of a sphere
  85826. */
  85827. export class SpherePanel extends VolumeBasedPanel {
  85828. private _radius;
  85829. /**
  85830. * Gets or sets the radius of the sphere where to project controls (5 by default)
  85831. */
  85832. get radius(): BABYLON.float;
  85833. set radius(value: BABYLON.float);
  85834. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  85835. private _sphericalMapping;
  85836. }
  85837. }
  85838. declare module BABYLON.GUI {
  85839. /**
  85840. * Class used to create a stack panel in 3D on XY plane
  85841. */
  85842. export class StackPanel3D extends Container3D {
  85843. private _isVertical;
  85844. /**
  85845. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  85846. */
  85847. get isVertical(): boolean;
  85848. set isVertical(value: boolean);
  85849. /**
  85850. * Gets or sets the distance between elements
  85851. */
  85852. margin: number;
  85853. /**
  85854. * Creates new StackPanel
  85855. * @param isVertical
  85856. */
  85857. constructor(isVertical?: boolean);
  85858. protected _arrangeChildren(): void;
  85859. }
  85860. }
  85861. declare module BABYLON {
  85862. /**
  85863. * Configuration for glTF validation
  85864. */
  85865. export interface IGLTFValidationConfiguration {
  85866. /**
  85867. * The url of the glTF validator.
  85868. */
  85869. url: string;
  85870. }
  85871. /**
  85872. * glTF validation
  85873. */
  85874. export class GLTFValidation {
  85875. /**
  85876. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  85877. */
  85878. static Configuration: IGLTFValidationConfiguration;
  85879. private static _LoadScriptPromise;
  85880. /**
  85881. * Validate a glTF asset using the glTF-Validator.
  85882. * @param data The JSON of a glTF or the array buffer of a binary glTF
  85883. * @param rootUrl The root url for the glTF
  85884. * @param fileName The file name for the glTF
  85885. * @param getExternalResource The callback to get external resources for the glTF validator
  85886. * @returns A promise that resolves with the glTF validation results once complete
  85887. */
  85888. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  85889. }
  85890. }
  85891. declare module BABYLON {
  85892. /**
  85893. * Mode that determines the coordinate system to use.
  85894. */
  85895. export enum GLTFLoaderCoordinateSystemMode {
  85896. /**
  85897. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  85898. */
  85899. AUTO = 0,
  85900. /**
  85901. * Sets the useRightHandedSystem flag on the scene.
  85902. */
  85903. FORCE_RIGHT_HANDED = 1
  85904. }
  85905. /**
  85906. * Mode that determines what animations will start.
  85907. */
  85908. export enum GLTFLoaderAnimationStartMode {
  85909. /**
  85910. * No animation will start.
  85911. */
  85912. NONE = 0,
  85913. /**
  85914. * The first animation will start.
  85915. */
  85916. FIRST = 1,
  85917. /**
  85918. * All animations will start.
  85919. */
  85920. ALL = 2
  85921. }
  85922. /**
  85923. * Interface that contains the data for the glTF asset.
  85924. */
  85925. export interface IGLTFLoaderData {
  85926. /**
  85927. * The object that represents the glTF JSON.
  85928. */
  85929. json: Object;
  85930. /**
  85931. * The BIN chunk of a binary glTF.
  85932. */
  85933. bin: Nullable<IDataBuffer>;
  85934. }
  85935. /**
  85936. * Interface for extending the loader.
  85937. */
  85938. export interface IGLTFLoaderExtension {
  85939. /**
  85940. * The name of this extension.
  85941. */
  85942. readonly name: string;
  85943. /**
  85944. * Defines whether this extension is enabled.
  85945. */
  85946. enabled: boolean;
  85947. /**
  85948. * Defines the order of this extension.
  85949. * The loader sorts the extensions using these values when loading.
  85950. */
  85951. order?: number;
  85952. }
  85953. /**
  85954. * Loader state.
  85955. */
  85956. export enum GLTFLoaderState {
  85957. /**
  85958. * The asset is loading.
  85959. */
  85960. LOADING = 0,
  85961. /**
  85962. * The asset is ready for rendering.
  85963. */
  85964. READY = 1,
  85965. /**
  85966. * The asset is completely loaded.
  85967. */
  85968. COMPLETE = 2
  85969. }
  85970. /** @hidden */
  85971. export interface IGLTFLoader extends IDisposable {
  85972. readonly state: Nullable<GLTFLoaderState>;
  85973. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<ISceneLoaderAsyncResult>;
  85974. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  85975. }
  85976. /**
  85977. * File loader for loading glTF files into a scene.
  85978. */
  85979. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  85980. /** @hidden */
  85981. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  85982. /** @hidden */
  85983. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  85984. /**
  85985. * Raised when the asset has been parsed
  85986. */
  85987. onParsedObservable: Observable<IGLTFLoaderData>;
  85988. private _onParsedObserver;
  85989. /**
  85990. * Raised when the asset has been parsed
  85991. */
  85992. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  85993. /**
  85994. * 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.
  85995. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  85996. * Defaults to true.
  85997. * @hidden
  85998. */
  85999. static IncrementalLoading: boolean;
  86000. /**
  86001. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  86002. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  86003. * @hidden
  86004. */
  86005. static HomogeneousCoordinates: boolean;
  86006. /**
  86007. * The coordinate system mode. Defaults to AUTO.
  86008. */
  86009. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  86010. /**
  86011. * The animation start mode. Defaults to FIRST.
  86012. */
  86013. animationStartMode: GLTFLoaderAnimationStartMode;
  86014. /**
  86015. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  86016. */
  86017. compileMaterials: boolean;
  86018. /**
  86019. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  86020. */
  86021. useClipPlane: boolean;
  86022. /**
  86023. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  86024. */
  86025. compileShadowGenerators: boolean;
  86026. /**
  86027. * Defines if the Alpha blended materials are only applied as coverage.
  86028. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  86029. * If true, no extra effects are applied to transparent pixels.
  86030. */
  86031. transparencyAsCoverage: boolean;
  86032. /**
  86033. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  86034. * Enabling will disable offline support and glTF validator.
  86035. * Defaults to false.
  86036. */
  86037. useRangeRequests: boolean;
  86038. /**
  86039. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  86040. */
  86041. createInstances: boolean;
  86042. /**
  86043. * 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.
  86044. */
  86045. alwaysComputeBoundingBox: boolean;
  86046. /**
  86047. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  86048. */
  86049. loadAllMaterials: boolean;
  86050. /**
  86051. * Function called before loading a url referenced by the asset.
  86052. */
  86053. preprocessUrlAsync: (url: string) => Promise<string>;
  86054. /**
  86055. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  86056. * 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, ...)
  86057. */
  86058. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  86059. private _onMeshLoadedObserver;
  86060. /**
  86061. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  86062. * 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, ...)
  86063. */
  86064. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  86065. /**
  86066. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  86067. */
  86068. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  86069. private _onTextureLoadedObserver;
  86070. /**
  86071. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  86072. */
  86073. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  86074. /**
  86075. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  86076. */
  86077. readonly onMaterialLoadedObservable: Observable<Material>;
  86078. private _onMaterialLoadedObserver;
  86079. /**
  86080. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  86081. */
  86082. set onMaterialLoaded(callback: (material: Material) => void);
  86083. /**
  86084. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  86085. */
  86086. readonly onCameraLoadedObservable: Observable<Camera>;
  86087. private _onCameraLoadedObserver;
  86088. /**
  86089. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  86090. */
  86091. set onCameraLoaded(callback: (camera: Camera) => void);
  86092. /**
  86093. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  86094. * For assets with LODs, raised when all of the LODs are complete.
  86095. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  86096. */
  86097. readonly onCompleteObservable: Observable<void>;
  86098. private _onCompleteObserver;
  86099. /**
  86100. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  86101. * For assets with LODs, raised when all of the LODs are complete.
  86102. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  86103. */
  86104. set onComplete(callback: () => void);
  86105. /**
  86106. * Observable raised when an error occurs.
  86107. */
  86108. readonly onErrorObservable: Observable<any>;
  86109. private _onErrorObserver;
  86110. /**
  86111. * Callback raised when an error occurs.
  86112. */
  86113. set onError(callback: (reason: any) => void);
  86114. /**
  86115. * Observable raised after the loader is disposed.
  86116. */
  86117. readonly onDisposeObservable: Observable<void>;
  86118. private _onDisposeObserver;
  86119. /**
  86120. * Callback raised after the loader is disposed.
  86121. */
  86122. set onDispose(callback: () => void);
  86123. /**
  86124. * Observable raised after a loader extension is created.
  86125. * Set additional options for a loader extension in this event.
  86126. */
  86127. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  86128. private _onExtensionLoadedObserver;
  86129. /**
  86130. * Callback raised after a loader extension is created.
  86131. */
  86132. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  86133. /**
  86134. * Defines if the loader logging is enabled.
  86135. */
  86136. get loggingEnabled(): boolean;
  86137. set loggingEnabled(value: boolean);
  86138. /**
  86139. * Defines if the loader should capture performance counters.
  86140. */
  86141. get capturePerformanceCounters(): boolean;
  86142. set capturePerformanceCounters(value: boolean);
  86143. /**
  86144. * Defines if the loader should validate the asset.
  86145. */
  86146. validate: boolean;
  86147. /**
  86148. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  86149. */
  86150. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  86151. private _onValidatedObserver;
  86152. /**
  86153. * Callback raised after a loader extension is created.
  86154. */
  86155. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  86156. private _loader;
  86157. private _progressCallback?;
  86158. private _requests;
  86159. private static magicBase64Encoded;
  86160. /**
  86161. * Name of the loader ("gltf")
  86162. */
  86163. name: string;
  86164. /** @hidden */
  86165. extensions: ISceneLoaderPluginExtensions;
  86166. /**
  86167. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  86168. */
  86169. dispose(): void;
  86170. /** @hidden */
  86171. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  86172. /** @hidden */
  86173. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  86174. /** @hidden */
  86175. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  86176. /** @hidden */
  86177. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  86178. /** @hidden */
  86179. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  86180. /** @hidden */
  86181. canDirectLoad(data: string): boolean;
  86182. /** @hidden */
  86183. directLoad(scene: Scene, data: string): Promise<any>;
  86184. /**
  86185. * The callback that allows custom handling of the root url based on the response url.
  86186. * @param rootUrl the original root url
  86187. * @param responseURL the response url if available
  86188. * @returns the new root url
  86189. */
  86190. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  86191. /** @hidden */
  86192. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  86193. /**
  86194. * The loader state or null if the loader is not active.
  86195. */
  86196. get loaderState(): Nullable<GLTFLoaderState>;
  86197. /**
  86198. * Returns a promise that resolves when the asset is completely loaded.
  86199. * @returns a promise that resolves when the asset is completely loaded.
  86200. */
  86201. whenCompleteAsync(): Promise<void>;
  86202. /** @hidden */
  86203. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  86204. /** @hidden */
  86205. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  86206. private _onProgress;
  86207. private _validate;
  86208. private _getLoader;
  86209. private _parseJson;
  86210. private _unpackBinaryAsync;
  86211. private _unpackBinaryV1Async;
  86212. private _unpackBinaryV2Async;
  86213. private static _parseVersion;
  86214. private static _compareVersion;
  86215. private static readonly _logSpaces;
  86216. private _logIndentLevel;
  86217. private _loggingEnabled;
  86218. /** @hidden */
  86219. _log: (message: string) => void;
  86220. /** @hidden */
  86221. _logOpen(message: string): void;
  86222. /** @hidden */
  86223. _logClose(): void;
  86224. private _logEnabled;
  86225. private _logDisabled;
  86226. private _capturePerformanceCounters;
  86227. /** @hidden */
  86228. _startPerformanceCounter: (counterName: string) => void;
  86229. /** @hidden */
  86230. _endPerformanceCounter: (counterName: string) => void;
  86231. private _startPerformanceCounterEnabled;
  86232. private _startPerformanceCounterDisabled;
  86233. private _endPerformanceCounterEnabled;
  86234. private _endPerformanceCounterDisabled;
  86235. }
  86236. }
  86237. declare module BABYLON.GLTF1 {
  86238. /**
  86239. * Enums
  86240. * @hidden
  86241. */
  86242. export enum EComponentType {
  86243. BYTE = 5120,
  86244. UNSIGNED_BYTE = 5121,
  86245. SHORT = 5122,
  86246. UNSIGNED_SHORT = 5123,
  86247. FLOAT = 5126
  86248. }
  86249. /** @hidden */
  86250. export enum EShaderType {
  86251. FRAGMENT = 35632,
  86252. VERTEX = 35633
  86253. }
  86254. /** @hidden */
  86255. export enum EParameterType {
  86256. BYTE = 5120,
  86257. UNSIGNED_BYTE = 5121,
  86258. SHORT = 5122,
  86259. UNSIGNED_SHORT = 5123,
  86260. INT = 5124,
  86261. UNSIGNED_INT = 5125,
  86262. FLOAT = 5126,
  86263. FLOAT_VEC2 = 35664,
  86264. FLOAT_VEC3 = 35665,
  86265. FLOAT_VEC4 = 35666,
  86266. INT_VEC2 = 35667,
  86267. INT_VEC3 = 35668,
  86268. INT_VEC4 = 35669,
  86269. BOOL = 35670,
  86270. BOOL_VEC2 = 35671,
  86271. BOOL_VEC3 = 35672,
  86272. BOOL_VEC4 = 35673,
  86273. FLOAT_MAT2 = 35674,
  86274. FLOAT_MAT3 = 35675,
  86275. FLOAT_MAT4 = 35676,
  86276. SAMPLER_2D = 35678
  86277. }
  86278. /** @hidden */
  86279. export enum ETextureWrapMode {
  86280. CLAMP_TO_EDGE = 33071,
  86281. MIRRORED_REPEAT = 33648,
  86282. REPEAT = 10497
  86283. }
  86284. /** @hidden */
  86285. export enum ETextureFilterType {
  86286. NEAREST = 9728,
  86287. LINEAR = 9728,
  86288. NEAREST_MIPMAP_NEAREST = 9984,
  86289. LINEAR_MIPMAP_NEAREST = 9985,
  86290. NEAREST_MIPMAP_LINEAR = 9986,
  86291. LINEAR_MIPMAP_LINEAR = 9987
  86292. }
  86293. /** @hidden */
  86294. export enum ETextureFormat {
  86295. ALPHA = 6406,
  86296. RGB = 6407,
  86297. RGBA = 6408,
  86298. LUMINANCE = 6409,
  86299. LUMINANCE_ALPHA = 6410
  86300. }
  86301. /** @hidden */
  86302. export enum ECullingType {
  86303. FRONT = 1028,
  86304. BACK = 1029,
  86305. FRONT_AND_BACK = 1032
  86306. }
  86307. /** @hidden */
  86308. export enum EBlendingFunction {
  86309. ZERO = 0,
  86310. ONE = 1,
  86311. SRC_COLOR = 768,
  86312. ONE_MINUS_SRC_COLOR = 769,
  86313. DST_COLOR = 774,
  86314. ONE_MINUS_DST_COLOR = 775,
  86315. SRC_ALPHA = 770,
  86316. ONE_MINUS_SRC_ALPHA = 771,
  86317. DST_ALPHA = 772,
  86318. ONE_MINUS_DST_ALPHA = 773,
  86319. CONSTANT_COLOR = 32769,
  86320. ONE_MINUS_CONSTANT_COLOR = 32770,
  86321. CONSTANT_ALPHA = 32771,
  86322. ONE_MINUS_CONSTANT_ALPHA = 32772,
  86323. SRC_ALPHA_SATURATE = 776
  86324. }
  86325. /** @hidden */
  86326. export interface IGLTFProperty {
  86327. extensions?: {
  86328. [key: string]: any;
  86329. };
  86330. extras?: Object;
  86331. }
  86332. /** @hidden */
  86333. export interface IGLTFChildRootProperty extends IGLTFProperty {
  86334. name?: string;
  86335. }
  86336. /** @hidden */
  86337. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  86338. bufferView: string;
  86339. byteOffset: number;
  86340. byteStride: number;
  86341. count: number;
  86342. type: string;
  86343. componentType: EComponentType;
  86344. max?: number[];
  86345. min?: number[];
  86346. name?: string;
  86347. }
  86348. /** @hidden */
  86349. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  86350. buffer: string;
  86351. byteOffset: number;
  86352. byteLength: number;
  86353. byteStride: number;
  86354. target?: number;
  86355. }
  86356. /** @hidden */
  86357. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  86358. uri: string;
  86359. byteLength?: number;
  86360. type?: string;
  86361. }
  86362. /** @hidden */
  86363. export interface IGLTFShader extends IGLTFChildRootProperty {
  86364. uri: string;
  86365. type: EShaderType;
  86366. }
  86367. /** @hidden */
  86368. export interface IGLTFProgram extends IGLTFChildRootProperty {
  86369. attributes: string[];
  86370. fragmentShader: string;
  86371. vertexShader: string;
  86372. }
  86373. /** @hidden */
  86374. export interface IGLTFTechniqueParameter {
  86375. type: number;
  86376. count?: number;
  86377. semantic?: string;
  86378. node?: string;
  86379. value?: number | boolean | string | Array<any>;
  86380. source?: string;
  86381. babylonValue?: any;
  86382. }
  86383. /** @hidden */
  86384. export interface IGLTFTechniqueCommonProfile {
  86385. lightingModel: string;
  86386. texcoordBindings: Object;
  86387. parameters?: Array<any>;
  86388. }
  86389. /** @hidden */
  86390. export interface IGLTFTechniqueStatesFunctions {
  86391. blendColor?: number[];
  86392. blendEquationSeparate?: number[];
  86393. blendFuncSeparate?: number[];
  86394. colorMask: boolean[];
  86395. cullFace: number[];
  86396. }
  86397. /** @hidden */
  86398. export interface IGLTFTechniqueStates {
  86399. enable: number[];
  86400. functions: IGLTFTechniqueStatesFunctions;
  86401. }
  86402. /** @hidden */
  86403. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  86404. parameters: {
  86405. [key: string]: IGLTFTechniqueParameter;
  86406. };
  86407. program: string;
  86408. attributes: {
  86409. [key: string]: string;
  86410. };
  86411. uniforms: {
  86412. [key: string]: string;
  86413. };
  86414. states: IGLTFTechniqueStates;
  86415. }
  86416. /** @hidden */
  86417. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  86418. technique?: string;
  86419. values: string[];
  86420. }
  86421. /** @hidden */
  86422. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  86423. attributes: {
  86424. [key: string]: string;
  86425. };
  86426. indices: string;
  86427. material: string;
  86428. mode?: number;
  86429. }
  86430. /** @hidden */
  86431. export interface IGLTFMesh extends IGLTFChildRootProperty {
  86432. primitives: IGLTFMeshPrimitive[];
  86433. }
  86434. /** @hidden */
  86435. export interface IGLTFImage extends IGLTFChildRootProperty {
  86436. uri: string;
  86437. }
  86438. /** @hidden */
  86439. export interface IGLTFSampler extends IGLTFChildRootProperty {
  86440. magFilter?: number;
  86441. minFilter?: number;
  86442. wrapS?: number;
  86443. wrapT?: number;
  86444. }
  86445. /** @hidden */
  86446. export interface IGLTFTexture extends IGLTFChildRootProperty {
  86447. sampler: string;
  86448. source: string;
  86449. format?: ETextureFormat;
  86450. internalFormat?: ETextureFormat;
  86451. target?: number;
  86452. type?: number;
  86453. babylonTexture?: Texture;
  86454. }
  86455. /** @hidden */
  86456. export interface IGLTFAmbienLight {
  86457. color?: number[];
  86458. }
  86459. /** @hidden */
  86460. export interface IGLTFDirectionalLight {
  86461. color?: number[];
  86462. }
  86463. /** @hidden */
  86464. export interface IGLTFPointLight {
  86465. color?: number[];
  86466. constantAttenuation?: number;
  86467. linearAttenuation?: number;
  86468. quadraticAttenuation?: number;
  86469. }
  86470. /** @hidden */
  86471. export interface IGLTFSpotLight {
  86472. color?: number[];
  86473. constantAttenuation?: number;
  86474. fallOfAngle?: number;
  86475. fallOffExponent?: number;
  86476. linearAttenuation?: number;
  86477. quadraticAttenuation?: number;
  86478. }
  86479. /** @hidden */
  86480. export interface IGLTFLight extends IGLTFChildRootProperty {
  86481. type: string;
  86482. }
  86483. /** @hidden */
  86484. export interface IGLTFCameraOrthographic {
  86485. xmag: number;
  86486. ymag: number;
  86487. zfar: number;
  86488. znear: number;
  86489. }
  86490. /** @hidden */
  86491. export interface IGLTFCameraPerspective {
  86492. aspectRatio: number;
  86493. yfov: number;
  86494. zfar: number;
  86495. znear: number;
  86496. }
  86497. /** @hidden */
  86498. export interface IGLTFCamera extends IGLTFChildRootProperty {
  86499. type: string;
  86500. }
  86501. /** @hidden */
  86502. export interface IGLTFAnimationChannelTarget {
  86503. id: string;
  86504. path: string;
  86505. }
  86506. /** @hidden */
  86507. export interface IGLTFAnimationChannel {
  86508. sampler: string;
  86509. target: IGLTFAnimationChannelTarget;
  86510. }
  86511. /** @hidden */
  86512. export interface IGLTFAnimationSampler {
  86513. input: string;
  86514. output: string;
  86515. interpolation?: string;
  86516. }
  86517. /** @hidden */
  86518. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  86519. channels?: IGLTFAnimationChannel[];
  86520. parameters?: {
  86521. [key: string]: string;
  86522. };
  86523. samplers?: {
  86524. [key: string]: IGLTFAnimationSampler;
  86525. };
  86526. }
  86527. /** @hidden */
  86528. export interface IGLTFNodeInstanceSkin {
  86529. skeletons: string[];
  86530. skin: string;
  86531. meshes: string[];
  86532. }
  86533. /** @hidden */
  86534. export interface IGLTFSkins extends IGLTFChildRootProperty {
  86535. bindShapeMatrix: number[];
  86536. inverseBindMatrices: string;
  86537. jointNames: string[];
  86538. babylonSkeleton?: Skeleton;
  86539. }
  86540. /** @hidden */
  86541. export interface IGLTFNode extends IGLTFChildRootProperty {
  86542. camera?: string;
  86543. children: string[];
  86544. skin?: string;
  86545. jointName?: string;
  86546. light?: string;
  86547. matrix: number[];
  86548. mesh?: string;
  86549. meshes?: string[];
  86550. rotation?: number[];
  86551. scale?: number[];
  86552. translation?: number[];
  86553. babylonNode?: Node;
  86554. }
  86555. /** @hidden */
  86556. export interface IGLTFScene extends IGLTFChildRootProperty {
  86557. nodes: string[];
  86558. }
  86559. /** @hidden */
  86560. export interface IGLTFRuntime {
  86561. extensions: {
  86562. [key: string]: any;
  86563. };
  86564. accessors: {
  86565. [key: string]: IGLTFAccessor;
  86566. };
  86567. buffers: {
  86568. [key: string]: IGLTFBuffer;
  86569. };
  86570. bufferViews: {
  86571. [key: string]: IGLTFBufferView;
  86572. };
  86573. meshes: {
  86574. [key: string]: IGLTFMesh;
  86575. };
  86576. lights: {
  86577. [key: string]: IGLTFLight;
  86578. };
  86579. cameras: {
  86580. [key: string]: IGLTFCamera;
  86581. };
  86582. nodes: {
  86583. [key: string]: IGLTFNode;
  86584. };
  86585. images: {
  86586. [key: string]: IGLTFImage;
  86587. };
  86588. textures: {
  86589. [key: string]: IGLTFTexture;
  86590. };
  86591. shaders: {
  86592. [key: string]: IGLTFShader;
  86593. };
  86594. programs: {
  86595. [key: string]: IGLTFProgram;
  86596. };
  86597. samplers: {
  86598. [key: string]: IGLTFSampler;
  86599. };
  86600. techniques: {
  86601. [key: string]: IGLTFTechnique;
  86602. };
  86603. materials: {
  86604. [key: string]: IGLTFMaterial;
  86605. };
  86606. animations: {
  86607. [key: string]: IGLTFAnimation;
  86608. };
  86609. skins: {
  86610. [key: string]: IGLTFSkins;
  86611. };
  86612. currentScene?: Object;
  86613. scenes: {
  86614. [key: string]: IGLTFScene;
  86615. };
  86616. extensionsUsed: string[];
  86617. extensionsRequired?: string[];
  86618. buffersCount: number;
  86619. shaderscount: number;
  86620. scene: Scene;
  86621. rootUrl: string;
  86622. loadedBufferCount: number;
  86623. loadedBufferViews: {
  86624. [name: string]: ArrayBufferView;
  86625. };
  86626. loadedShaderCount: number;
  86627. importOnlyMeshes: boolean;
  86628. importMeshesNames?: string[];
  86629. dummyNodes: Node[];
  86630. forAssetContainer: boolean;
  86631. }
  86632. /** @hidden */
  86633. export interface INodeToRoot {
  86634. bone: Bone;
  86635. node: IGLTFNode;
  86636. id: string;
  86637. }
  86638. /** @hidden */
  86639. export interface IJointNode {
  86640. node: IGLTFNode;
  86641. id: string;
  86642. }
  86643. }
  86644. declare module BABYLON.GLTF1 {
  86645. /**
  86646. * Utils functions for GLTF
  86647. * @hidden
  86648. */
  86649. export class GLTFUtils {
  86650. /**
  86651. * Sets the given "parameter" matrix
  86652. * @param scene: the Scene object
  86653. * @param source: the source node where to pick the matrix
  86654. * @param parameter: the GLTF technique parameter
  86655. * @param uniformName: the name of the shader's uniform
  86656. * @param shaderMaterial: the shader material
  86657. */
  86658. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  86659. /**
  86660. * Sets the given "parameter" matrix
  86661. * @param shaderMaterial: the shader material
  86662. * @param uniform: the name of the shader's uniform
  86663. * @param value: the value of the uniform
  86664. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  86665. */
  86666. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  86667. /**
  86668. * Returns the wrap mode of the texture
  86669. * @param mode: the mode value
  86670. */
  86671. static GetWrapMode(mode: number): number;
  86672. /**
  86673. * Returns the byte stride giving an accessor
  86674. * @param accessor: the GLTF accessor objet
  86675. */
  86676. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  86677. /**
  86678. * Returns the texture filter mode giving a mode value
  86679. * @param mode: the filter mode value
  86680. */
  86681. static GetTextureFilterMode(mode: number): ETextureFilterType;
  86682. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  86683. /**
  86684. * Returns a buffer from its accessor
  86685. * @param gltfRuntime: the GLTF runtime
  86686. * @param accessor: the GLTF accessor
  86687. */
  86688. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  86689. /**
  86690. * Decodes a buffer view into a string
  86691. * @param view: the buffer view
  86692. */
  86693. static DecodeBufferToText(view: ArrayBufferView): string;
  86694. /**
  86695. * Returns the default material of gltf. Related to
  86696. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  86697. * @param scene: the Babylon.js scene
  86698. */
  86699. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  86700. private static _DefaultMaterial;
  86701. }
  86702. }
  86703. declare module BABYLON.GLTF1 {
  86704. /**
  86705. * Implementation of the base glTF spec
  86706. * @hidden
  86707. */
  86708. export class GLTFLoaderBase {
  86709. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  86710. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  86711. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  86712. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  86713. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  86714. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  86715. }
  86716. /**
  86717. * glTF V1 Loader
  86718. * @hidden
  86719. */
  86720. export class GLTFLoader implements IGLTFLoader {
  86721. static Extensions: {
  86722. [name: string]: GLTFLoaderExtension;
  86723. };
  86724. static RegisterExtension(extension: GLTFLoaderExtension): void;
  86725. state: Nullable<GLTFLoaderState>;
  86726. dispose(): void;
  86727. private _importMeshAsync;
  86728. /**
  86729. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  86730. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  86731. * @param scene the scene the meshes should be added to
  86732. * @param forAssetContainer defines if the entities must be stored in the scene
  86733. * @param data gltf data containing information of the meshes in a loaded file
  86734. * @param rootUrl root url to load from
  86735. * @param onProgress event that fires when loading progress has occured
  86736. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  86737. */
  86738. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
  86739. private _loadAsync;
  86740. /**
  86741. * Imports all objects from a loaded gltf file and adds them to the scene
  86742. * @param scene the scene the objects should be added to
  86743. * @param data gltf data containing information of the meshes in a loaded file
  86744. * @param rootUrl root url to load from
  86745. * @param onProgress event that fires when loading progress has occured
  86746. * @returns a promise which completes when objects have been loaded to the scene
  86747. */
  86748. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  86749. private _loadShadersAsync;
  86750. private _loadBuffersAsync;
  86751. private _createNodes;
  86752. }
  86753. /** @hidden */
  86754. export abstract class GLTFLoaderExtension {
  86755. private _name;
  86756. constructor(name: string);
  86757. get name(): string;
  86758. /**
  86759. * Defines an override for loading the runtime
  86760. * Return true to stop further extensions from loading the runtime
  86761. */
  86762. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  86763. /**
  86764. * Defines an onverride for creating gltf runtime
  86765. * Return true to stop further extensions from creating the runtime
  86766. */
  86767. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  86768. /**
  86769. * Defines an override for loading buffers
  86770. * Return true to stop further extensions from loading this buffer
  86771. */
  86772. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  86773. /**
  86774. * Defines an override for loading texture buffers
  86775. * Return true to stop further extensions from loading this texture data
  86776. */
  86777. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  86778. /**
  86779. * Defines an override for creating textures
  86780. * Return true to stop further extensions from loading this texture
  86781. */
  86782. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  86783. /**
  86784. * Defines an override for loading shader strings
  86785. * Return true to stop further extensions from loading this shader data
  86786. */
  86787. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  86788. /**
  86789. * Defines an override for loading materials
  86790. * Return true to stop further extensions from loading this material
  86791. */
  86792. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  86793. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  86794. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  86795. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  86796. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  86797. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  86798. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  86799. private static LoadTextureBufferAsync;
  86800. private static CreateTextureAsync;
  86801. private static ApplyExtensions;
  86802. }
  86803. }
  86804. declare module BABYLON.GLTF1 {
  86805. /** @hidden */
  86806. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  86807. private _bin;
  86808. constructor();
  86809. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  86810. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  86811. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  86812. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  86813. }
  86814. }
  86815. declare module BABYLON.GLTF1 {
  86816. /** @hidden */
  86817. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  86818. constructor();
  86819. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  86820. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  86821. private _loadTexture;
  86822. }
  86823. }
  86824. declare module BABYLON.GLTF2.Loader {
  86825. /**
  86826. * Loader interface with an index field.
  86827. */
  86828. export interface IArrayItem {
  86829. /**
  86830. * The index of this item in the array.
  86831. */
  86832. index: number;
  86833. }
  86834. /**
  86835. * Loader interface with additional members.
  86836. */
  86837. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  86838. /** @hidden */
  86839. _data?: Promise<ArrayBufferView>;
  86840. /** @hidden */
  86841. _babylonVertexBuffer?: Promise<VertexBuffer>;
  86842. }
  86843. /**
  86844. * Loader interface with additional members.
  86845. */
  86846. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  86847. }
  86848. /** @hidden */
  86849. export interface _IAnimationSamplerData {
  86850. input: Float32Array;
  86851. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  86852. output: Float32Array;
  86853. }
  86854. /**
  86855. * Loader interface with additional members.
  86856. */
  86857. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  86858. /** @hidden */
  86859. _data?: Promise<_IAnimationSamplerData>;
  86860. }
  86861. /**
  86862. * Loader interface with additional members.
  86863. */
  86864. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  86865. channels: IAnimationChannel[];
  86866. samplers: IAnimationSampler[];
  86867. /** @hidden */
  86868. _babylonAnimationGroup?: AnimationGroup;
  86869. }
  86870. /**
  86871. * Loader interface with additional members.
  86872. */
  86873. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  86874. /** @hidden */
  86875. _data?: Promise<ArrayBufferView>;
  86876. }
  86877. /**
  86878. * Loader interface with additional members.
  86879. */
  86880. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  86881. /** @hidden */
  86882. _data?: Promise<ArrayBufferView>;
  86883. /** @hidden */
  86884. _babylonBuffer?: Promise<Buffer>;
  86885. }
  86886. /**
  86887. * Loader interface with additional members.
  86888. */
  86889. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  86890. }
  86891. /**
  86892. * Loader interface with additional members.
  86893. */
  86894. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  86895. /** @hidden */
  86896. _data?: Promise<ArrayBufferView>;
  86897. }
  86898. /**
  86899. * Loader interface with additional members.
  86900. */
  86901. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  86902. }
  86903. /**
  86904. * Loader interface with additional members.
  86905. */
  86906. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  86907. }
  86908. /**
  86909. * Loader interface with additional members.
  86910. */
  86911. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  86912. baseColorTexture?: ITextureInfo;
  86913. metallicRoughnessTexture?: ITextureInfo;
  86914. }
  86915. /**
  86916. * Loader interface with additional members.
  86917. */
  86918. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  86919. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  86920. normalTexture?: IMaterialNormalTextureInfo;
  86921. occlusionTexture?: IMaterialOcclusionTextureInfo;
  86922. emissiveTexture?: ITextureInfo;
  86923. /** @hidden */
  86924. _data?: {
  86925. [babylonDrawMode: number]: {
  86926. babylonMaterial: Material;
  86927. babylonMeshes: AbstractMesh[];
  86928. promise: Promise<void>;
  86929. };
  86930. };
  86931. }
  86932. /**
  86933. * Loader interface with additional members.
  86934. */
  86935. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  86936. primitives: IMeshPrimitive[];
  86937. }
  86938. /**
  86939. * Loader interface with additional members.
  86940. */
  86941. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  86942. /** @hidden */
  86943. _instanceData?: {
  86944. babylonSourceMesh: Mesh;
  86945. promise: Promise<any>;
  86946. };
  86947. }
  86948. /**
  86949. * Loader interface with additional members.
  86950. */
  86951. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  86952. /**
  86953. * The parent glTF node.
  86954. */
  86955. parent?: INode;
  86956. /** @hidden */
  86957. _babylonTransformNode?: TransformNode;
  86958. /** @hidden */
  86959. _primitiveBabylonMeshes?: AbstractMesh[];
  86960. /** @hidden */
  86961. _babylonBones?: Bone[];
  86962. /** @hidden */
  86963. _numMorphTargets?: number;
  86964. }
  86965. /** @hidden */
  86966. export interface _ISamplerData {
  86967. noMipMaps: boolean;
  86968. samplingMode: number;
  86969. wrapU: number;
  86970. wrapV: number;
  86971. }
  86972. /**
  86973. * Loader interface with additional members.
  86974. */
  86975. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  86976. /** @hidden */
  86977. _data?: _ISamplerData;
  86978. }
  86979. /**
  86980. * Loader interface with additional members.
  86981. */
  86982. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  86983. }
  86984. /**
  86985. * Loader interface with additional members.
  86986. */
  86987. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  86988. /** @hidden */
  86989. _data?: {
  86990. babylonSkeleton: Skeleton;
  86991. promise: Promise<void>;
  86992. };
  86993. }
  86994. /**
  86995. * Loader interface with additional members.
  86996. */
  86997. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  86998. /** @hidden */
  86999. _textureInfo: ITextureInfo;
  87000. }
  87001. /**
  87002. * Loader interface with additional members.
  87003. */
  87004. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  87005. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  87006. nonColorData?: boolean;
  87007. }
  87008. /**
  87009. * Loader interface with additional members.
  87010. */
  87011. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  87012. accessors?: IAccessor[];
  87013. animations?: IAnimation[];
  87014. buffers?: IBuffer[];
  87015. bufferViews?: IBufferView[];
  87016. cameras?: ICamera[];
  87017. images?: IImage[];
  87018. materials?: IMaterial[];
  87019. meshes?: IMesh[];
  87020. nodes?: INode[];
  87021. samplers?: ISampler[];
  87022. scenes?: IScene[];
  87023. skins?: ISkin[];
  87024. textures?: ITexture[];
  87025. }
  87026. }
  87027. declare module BABYLON.GLTF2 {
  87028. /**
  87029. * Interface for a glTF loader extension.
  87030. */
  87031. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  87032. /**
  87033. * Called after the loader state changes to LOADING.
  87034. */
  87035. onLoading?(): void;
  87036. /**
  87037. * Called after the loader state changes to READY.
  87038. */
  87039. onReady?(): void;
  87040. /**
  87041. * Define this method to modify the default behavior when loading scenes.
  87042. * @param context The context when loading the asset
  87043. * @param scene The glTF scene property
  87044. * @returns A promise that resolves when the load is complete or null if not handled
  87045. */
  87046. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  87047. /**
  87048. * Define this method to modify the default behavior when loading nodes.
  87049. * @param context The context when loading the asset
  87050. * @param node The glTF node property
  87051. * @param assign A function called synchronously after parsing the glTF properties
  87052. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  87053. */
  87054. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  87055. /**
  87056. * Define this method to modify the default behavior when loading cameras.
  87057. * @param context The context when loading the asset
  87058. * @param camera The glTF camera property
  87059. * @param assign A function called synchronously after parsing the glTF properties
  87060. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  87061. */
  87062. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  87063. /**
  87064. * @hidden
  87065. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  87066. * @param context The context when loading the asset
  87067. * @param primitive The glTF mesh primitive property
  87068. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  87069. */
  87070. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  87071. /**
  87072. * @hidden
  87073. * Define this method to modify the default behavior when loading data for mesh primitives.
  87074. * @param context The context when loading the asset
  87075. * @param name The mesh name when loading the asset
  87076. * @param node The glTF node when loading the asset
  87077. * @param mesh The glTF mesh when loading the asset
  87078. * @param primitive The glTF mesh primitive property
  87079. * @param assign A function called synchronously after parsing the glTF properties
  87080. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  87081. */
  87082. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  87083. /**
  87084. * @hidden
  87085. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  87086. * @param context The context when loading the asset
  87087. * @param material The glTF material property
  87088. * @param assign A function called synchronously after parsing the glTF properties
  87089. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  87090. */
  87091. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  87092. /**
  87093. * Define this method to modify the default behavior when creating materials.
  87094. * @param context The context when loading the asset
  87095. * @param material The glTF material property
  87096. * @param babylonDrawMode The draw mode for the Babylon material
  87097. * @returns The Babylon material or null if not handled
  87098. */
  87099. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  87100. /**
  87101. * Define this method to modify the default behavior when loading material properties.
  87102. * @param context The context when loading the asset
  87103. * @param material The glTF material property
  87104. * @param babylonMaterial The Babylon material
  87105. * @returns A promise that resolves when the load is complete or null if not handled
  87106. */
  87107. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  87108. /**
  87109. * Define this method to modify the default behavior when loading texture infos.
  87110. * @param context The context when loading the asset
  87111. * @param textureInfo The glTF texture info property
  87112. * @param assign A function called synchronously after parsing the glTF properties
  87113. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  87114. */
  87115. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  87116. /**
  87117. * @hidden
  87118. * Define this method to modify the default behavior when loading textures.
  87119. * @param context The context when loading the asset
  87120. * @param texture The glTF texture property
  87121. * @param assign A function called synchronously after parsing the glTF properties
  87122. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  87123. */
  87124. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  87125. /**
  87126. * Define this method to modify the default behavior when loading animations.
  87127. * @param context The context when loading the asset
  87128. * @param animation The glTF animation property
  87129. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  87130. */
  87131. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  87132. /**
  87133. * @hidden
  87134. * Define this method to modify the default behavior when loading skins.
  87135. * @param context The context when loading the asset
  87136. * @param node The glTF node property
  87137. * @param skin The glTF skin property
  87138. * @returns A promise that resolves when the load is complete or null if not handled
  87139. */
  87140. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  87141. /**
  87142. * @hidden
  87143. * Define this method to modify the default behavior when loading uris.
  87144. * @param context The context when loading the asset
  87145. * @param property The glTF property associated with the uri
  87146. * @param uri The uri to load
  87147. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  87148. */
  87149. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  87150. /**
  87151. * Define this method to modify the default behavior when loading buffer views.
  87152. * @param context The context when loading the asset
  87153. * @param bufferView The glTF buffer view property
  87154. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  87155. */
  87156. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  87157. /**
  87158. * Define this method to modify the default behavior when loading buffers.
  87159. * @param context The context when loading the asset
  87160. * @param buffer The glTF buffer property
  87161. * @param byteOffset The byte offset to load
  87162. * @param byteLength The byte length to load
  87163. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  87164. */
  87165. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  87166. }
  87167. }
  87168. declare module BABYLON.GLTF2 {
  87169. /**
  87170. * Helper class for working with arrays when loading the glTF asset
  87171. */
  87172. export class ArrayItem {
  87173. /**
  87174. * Gets an item from the given array.
  87175. * @param context The context when loading the asset
  87176. * @param array The array to get the item from
  87177. * @param index The index to the array
  87178. * @returns The array item
  87179. */
  87180. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  87181. /**
  87182. * Assign an `index` field to each item of the given array.
  87183. * @param array The array of items
  87184. */
  87185. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  87186. }
  87187. /**
  87188. * The glTF 2.0 loader
  87189. */
  87190. export class GLTFLoader implements IGLTFLoader {
  87191. /** @hidden */
  87192. _completePromises: Promise<any>[];
  87193. /** @hidden */
  87194. _forAssetContainer: boolean;
  87195. /** Storage */
  87196. _babylonLights: Light[];
  87197. /** @hidden */
  87198. _disableInstancedMesh: number;
  87199. private _disposed;
  87200. private _parent;
  87201. private _state;
  87202. private _extensions;
  87203. private _rootUrl;
  87204. private _fileName;
  87205. private _uniqueRootUrl;
  87206. private _gltf;
  87207. private _bin;
  87208. private _babylonScene;
  87209. private _rootBabylonMesh;
  87210. private _defaultBabylonMaterialData;
  87211. private static _RegisteredExtensions;
  87212. /**
  87213. * The default glTF sampler.
  87214. */
  87215. static readonly DefaultSampler: ISampler;
  87216. /**
  87217. * Registers a loader extension.
  87218. * @param name The name of the loader extension.
  87219. * @param factory The factory function that creates the loader extension.
  87220. */
  87221. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  87222. /**
  87223. * Unregisters a loader extension.
  87224. * @param name The name of the loader extension.
  87225. * @returns A boolean indicating whether the extension has been unregistered
  87226. */
  87227. static UnregisterExtension(name: string): boolean;
  87228. /**
  87229. * The loader state.
  87230. */
  87231. get state(): Nullable<GLTFLoaderState>;
  87232. /**
  87233. * The object that represents the glTF JSON.
  87234. */
  87235. get gltf(): IGLTF;
  87236. /**
  87237. * The BIN chunk of a binary glTF.
  87238. */
  87239. get bin(): Nullable<IDataBuffer>;
  87240. /**
  87241. * The parent file loader.
  87242. */
  87243. get parent(): GLTFFileLoader;
  87244. /**
  87245. * The Babylon scene when loading the asset.
  87246. */
  87247. get babylonScene(): Scene;
  87248. /**
  87249. * The root Babylon mesh when loading the asset.
  87250. */
  87251. get rootBabylonMesh(): Mesh;
  87252. /** @hidden */
  87253. constructor(parent: GLTFFileLoader);
  87254. /** @hidden */
  87255. dispose(): void;
  87256. /** @hidden */
  87257. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  87258. /** @hidden */
  87259. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  87260. private _loadAsync;
  87261. private _loadData;
  87262. private _setupData;
  87263. private _loadExtensions;
  87264. private _checkExtensions;
  87265. private _setState;
  87266. private _createRootNode;
  87267. /**
  87268. * Loads a glTF scene.
  87269. * @param context The context when loading the asset
  87270. * @param scene The glTF scene property
  87271. * @returns A promise that resolves when the load is complete
  87272. */
  87273. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  87274. private _forEachPrimitive;
  87275. private _getGeometries;
  87276. private _getMeshes;
  87277. private _getTransformNodes;
  87278. private _getSkeletons;
  87279. private _getAnimationGroups;
  87280. private _startAnimations;
  87281. /**
  87282. * Loads a glTF node.
  87283. * @param context The context when loading the asset
  87284. * @param node The glTF node property
  87285. * @param assign A function called synchronously after parsing the glTF properties
  87286. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  87287. */
  87288. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  87289. private _loadMeshAsync;
  87290. /**
  87291. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  87292. * @param context The context when loading the asset
  87293. * @param name The mesh name when loading the asset
  87294. * @param node The glTF node when loading the asset
  87295. * @param mesh The glTF mesh when loading the asset
  87296. * @param primitive The glTF mesh primitive property
  87297. * @param assign A function called synchronously after parsing the glTF properties
  87298. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  87299. */
  87300. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  87301. private _loadVertexDataAsync;
  87302. private _createMorphTargets;
  87303. private _loadMorphTargetsAsync;
  87304. private _loadMorphTargetVertexDataAsync;
  87305. private static _LoadTransform;
  87306. private _loadSkinAsync;
  87307. private _loadBones;
  87308. private _loadBone;
  87309. private _loadSkinInverseBindMatricesDataAsync;
  87310. private _updateBoneMatrices;
  87311. private _getNodeMatrix;
  87312. /**
  87313. * Loads a glTF camera.
  87314. * @param context The context when loading the asset
  87315. * @param camera The glTF camera property
  87316. * @param assign A function called synchronously after parsing the glTF properties
  87317. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  87318. */
  87319. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  87320. private _loadAnimationsAsync;
  87321. /**
  87322. * Loads a glTF animation.
  87323. * @param context The context when loading the asset
  87324. * @param animation The glTF animation property
  87325. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  87326. */
  87327. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  87328. /**
  87329. * @hidden Loads a glTF animation channel.
  87330. * @param context The context when loading the asset
  87331. * @param animationContext The context of the animation when loading the asset
  87332. * @param animation The glTF animation property
  87333. * @param channel The glTF animation channel property
  87334. * @param babylonAnimationGroup The babylon animation group property
  87335. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  87336. * @returns A void promise when the channel load is complete
  87337. */
  87338. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  87339. private _loadAnimationSamplerAsync;
  87340. /**
  87341. * Loads a glTF buffer.
  87342. * @param context The context when loading the asset
  87343. * @param buffer The glTF buffer property
  87344. * @param byteOffset The byte offset to use
  87345. * @param byteLength The byte length to use
  87346. * @returns A promise that resolves with the loaded data when the load is complete
  87347. */
  87348. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  87349. /**
  87350. * Loads a glTF buffer view.
  87351. * @param context The context when loading the asset
  87352. * @param bufferView The glTF buffer view property
  87353. * @returns A promise that resolves with the loaded data when the load is complete
  87354. */
  87355. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  87356. private _loadAccessorAsync;
  87357. /** @hidden */
  87358. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  87359. private _loadIndicesAccessorAsync;
  87360. private _loadVertexBufferViewAsync;
  87361. private _loadVertexAccessorAsync;
  87362. private _loadMaterialMetallicRoughnessPropertiesAsync;
  87363. /** @hidden */
  87364. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  87365. private _createDefaultMaterial;
  87366. /**
  87367. * Creates a Babylon material from a glTF material.
  87368. * @param context The context when loading the asset
  87369. * @param material The glTF material property
  87370. * @param babylonDrawMode The draw mode for the Babylon material
  87371. * @returns The Babylon material
  87372. */
  87373. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  87374. /**
  87375. * Loads properties from a glTF material into a Babylon material.
  87376. * @param context The context when loading the asset
  87377. * @param material The glTF material property
  87378. * @param babylonMaterial The Babylon material
  87379. * @returns A promise that resolves when the load is complete
  87380. */
  87381. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  87382. /**
  87383. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  87384. * @param context The context when loading the asset
  87385. * @param material The glTF material property
  87386. * @param babylonMaterial The Babylon material
  87387. * @returns A promise that resolves when the load is complete
  87388. */
  87389. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  87390. /**
  87391. * Loads the alpha properties from a glTF material into a Babylon material.
  87392. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  87393. * @param context The context when loading the asset
  87394. * @param material The glTF material property
  87395. * @param babylonMaterial The Babylon material
  87396. */
  87397. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  87398. /**
  87399. * Loads a glTF texture info.
  87400. * @param context The context when loading the asset
  87401. * @param textureInfo The glTF texture info property
  87402. * @param assign A function called synchronously after parsing the glTF properties
  87403. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  87404. */
  87405. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  87406. /** @hidden */
  87407. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  87408. /** @hidden */
  87409. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  87410. private _loadSampler;
  87411. /**
  87412. * Loads a glTF image.
  87413. * @param context The context when loading the asset
  87414. * @param image The glTF image property
  87415. * @returns A promise that resolves with the loaded data when the load is complete
  87416. */
  87417. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  87418. /**
  87419. * Loads a glTF uri.
  87420. * @param context The context when loading the asset
  87421. * @param property The glTF property associated with the uri
  87422. * @param uri The base64 or relative uri
  87423. * @returns A promise that resolves with the loaded data when the load is complete
  87424. */
  87425. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  87426. /**
  87427. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  87428. * @param babylonObject the Babylon object with metadata
  87429. * @param pointer the JSON pointer
  87430. */
  87431. static AddPointerMetadata(babylonObject: {
  87432. metadata: any;
  87433. }, pointer: string): void;
  87434. private static _GetTextureWrapMode;
  87435. private static _GetTextureSamplingMode;
  87436. private static _GetTypedArrayConstructor;
  87437. private static _GetTypedArray;
  87438. private static _GetNumComponents;
  87439. private static _ValidateUri;
  87440. /** @hidden */
  87441. static _GetDrawMode(context: string, mode: number | undefined): number;
  87442. private _compileMaterialsAsync;
  87443. private _compileShadowGeneratorsAsync;
  87444. private _forEachExtensions;
  87445. private _applyExtensions;
  87446. private _extensionsOnLoading;
  87447. private _extensionsOnReady;
  87448. private _extensionsLoadSceneAsync;
  87449. private _extensionsLoadNodeAsync;
  87450. private _extensionsLoadCameraAsync;
  87451. private _extensionsLoadVertexDataAsync;
  87452. private _extensionsLoadMeshPrimitiveAsync;
  87453. private _extensionsLoadMaterialAsync;
  87454. private _extensionsCreateMaterial;
  87455. private _extensionsLoadMaterialPropertiesAsync;
  87456. private _extensionsLoadTextureInfoAsync;
  87457. private _extensionsLoadTextureAsync;
  87458. private _extensionsLoadAnimationAsync;
  87459. private _extensionsLoadSkinAsync;
  87460. private _extensionsLoadUriAsync;
  87461. private _extensionsLoadBufferViewAsync;
  87462. private _extensionsLoadBufferAsync;
  87463. /**
  87464. * Helper method called by a loader extension to load an glTF extension.
  87465. * @param context The context when loading the asset
  87466. * @param property The glTF property to load the extension from
  87467. * @param extensionName The name of the extension to load
  87468. * @param actionAsync The action to run
  87469. * @returns The promise returned by actionAsync or null if the extension does not exist
  87470. */
  87471. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  87472. /**
  87473. * Helper method called by a loader extension to load a glTF extra.
  87474. * @param context The context when loading the asset
  87475. * @param property The glTF property to load the extra from
  87476. * @param extensionName The name of the extension to load
  87477. * @param actionAsync The action to run
  87478. * @returns The promise returned by actionAsync or null if the extra does not exist
  87479. */
  87480. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  87481. /**
  87482. * Checks for presence of an extension.
  87483. * @param name The name of the extension to check
  87484. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  87485. */
  87486. isExtensionUsed(name: string): boolean;
  87487. /**
  87488. * Increments the indentation level and logs a message.
  87489. * @param message The message to log
  87490. */
  87491. logOpen(message: string): void;
  87492. /**
  87493. * Decrements the indentation level.
  87494. */
  87495. logClose(): void;
  87496. /**
  87497. * Logs a message
  87498. * @param message The message to log
  87499. */
  87500. log(message: string): void;
  87501. /**
  87502. * Starts a performance counter.
  87503. * @param counterName The name of the performance counter
  87504. */
  87505. startPerformanceCounter(counterName: string): void;
  87506. /**
  87507. * Ends a performance counter.
  87508. * @param counterName The name of the performance counter
  87509. */
  87510. endPerformanceCounter(counterName: string): void;
  87511. }
  87512. }
  87513. declare module BABYLON.GLTF2.Loader.Extensions {
  87514. /** @hidden */
  87515. interface IEXTLightsImageBased_LightImageBased {
  87516. _babylonTexture?: BaseTexture;
  87517. _loaded?: Promise<void>;
  87518. }
  87519. /**
  87520. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  87521. */
  87522. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  87523. /**
  87524. * The name of this extension.
  87525. */
  87526. readonly name: string;
  87527. /**
  87528. * Defines whether this extension is enabled.
  87529. */
  87530. enabled: boolean;
  87531. private _loader;
  87532. private _lights?;
  87533. /** @hidden */
  87534. constructor(loader: GLTFLoader);
  87535. /** @hidden */
  87536. dispose(): void;
  87537. /** @hidden */
  87538. onLoading(): void;
  87539. /** @hidden */
  87540. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  87541. private _loadLightAsync;
  87542. }
  87543. }
  87544. declare module BABYLON.GLTF2.Loader.Extensions {
  87545. /**
  87546. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  87547. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  87548. * !!! Experimental Extension Subject to Changes !!!
  87549. */
  87550. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  87551. /**
  87552. * The name of this extension.
  87553. */
  87554. readonly name: string;
  87555. /**
  87556. * Defines whether this extension is enabled.
  87557. */
  87558. enabled: boolean;
  87559. private _loader;
  87560. /** @hidden */
  87561. constructor(loader: GLTFLoader);
  87562. /** @hidden */
  87563. dispose(): void;
  87564. /** @hidden */
  87565. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  87566. }
  87567. }
  87568. declare module BABYLON.GLTF2.Loader.Extensions {
  87569. /**
  87570. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression)
  87571. *
  87572. * This extension uses a WebAssembly decoder module from https://github.com/zeux/meshoptimizer/tree/master/js
  87573. */
  87574. export class EXT_meshopt_compression implements IGLTFLoaderExtension {
  87575. /**
  87576. * The name of this extension.
  87577. */
  87578. readonly name: string;
  87579. /**
  87580. * Defines whether this extension is enabled.
  87581. */
  87582. enabled: boolean;
  87583. /**
  87584. * Path to decoder module; defaults to https://preview.babylonjs.com/meshopt_decoder.js
  87585. */
  87586. static DecoderPath: string;
  87587. private _loader;
  87588. private _decoderPromise?;
  87589. /** @hidden */
  87590. constructor(loader: GLTFLoader);
  87591. /** @hidden */
  87592. dispose(): void;
  87593. /** @hidden */
  87594. loadBufferViewAsync(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  87595. }
  87596. }
  87597. declare module BABYLON.GLTF2.Loader.Extensions {
  87598. /**
  87599. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  87600. */
  87601. export class EXT_texture_webp implements IGLTFLoaderExtension {
  87602. /** The name of this extension. */
  87603. readonly name: string;
  87604. /** Defines whether this extension is enabled. */
  87605. enabled: boolean;
  87606. private _loader;
  87607. /** @hidden */
  87608. constructor(loader: GLTFLoader);
  87609. /** @hidden */
  87610. dispose(): void;
  87611. /** @hidden */
  87612. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  87613. }
  87614. }
  87615. declare module BABYLON.GLTF2.Loader.Extensions {
  87616. /**
  87617. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  87618. */
  87619. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  87620. /**
  87621. * The name of this extension.
  87622. */
  87623. readonly name: string;
  87624. /**
  87625. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  87626. */
  87627. dracoCompression?: DracoCompression;
  87628. /**
  87629. * Defines whether this extension is enabled.
  87630. */
  87631. enabled: boolean;
  87632. private _loader;
  87633. /** @hidden */
  87634. constructor(loader: GLTFLoader);
  87635. /** @hidden */
  87636. dispose(): void;
  87637. /** @hidden */
  87638. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  87639. }
  87640. }
  87641. declare module BABYLON.GLTF2.Loader.Extensions {
  87642. /**
  87643. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  87644. */
  87645. export class KHR_lights implements IGLTFLoaderExtension {
  87646. /**
  87647. * The name of this extension.
  87648. */
  87649. readonly name: string;
  87650. /**
  87651. * Defines whether this extension is enabled.
  87652. */
  87653. enabled: boolean;
  87654. private _loader;
  87655. private _lights?;
  87656. /** @hidden */
  87657. constructor(loader: GLTFLoader);
  87658. /** @hidden */
  87659. dispose(): void;
  87660. /** @hidden */
  87661. onLoading(): void;
  87662. /** @hidden */
  87663. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  87664. }
  87665. }
  87666. declare module BABYLON.GLTF2.Loader.Extensions {
  87667. /**
  87668. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  87669. */
  87670. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  87671. /**
  87672. * The name of this extension.
  87673. */
  87674. readonly name: string;
  87675. /**
  87676. * Defines whether this extension is enabled.
  87677. */
  87678. enabled: boolean;
  87679. /**
  87680. * Defines a number that determines the order the extensions are applied.
  87681. */
  87682. order: number;
  87683. private _loader;
  87684. /** @hidden */
  87685. constructor(loader: GLTFLoader);
  87686. /** @hidden */
  87687. dispose(): void;
  87688. /** @hidden */
  87689. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  87690. private _loadSpecularGlossinessPropertiesAsync;
  87691. }
  87692. }
  87693. declare module BABYLON.GLTF2.Loader.Extensions {
  87694. /**
  87695. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  87696. */
  87697. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  87698. /**
  87699. * The name of this extension.
  87700. */
  87701. readonly name: string;
  87702. /**
  87703. * Defines whether this extension is enabled.
  87704. */
  87705. enabled: boolean;
  87706. /**
  87707. * Defines a number that determines the order the extensions are applied.
  87708. */
  87709. order: number;
  87710. private _loader;
  87711. /** @hidden */
  87712. constructor(loader: GLTFLoader);
  87713. /** @hidden */
  87714. dispose(): void;
  87715. /** @hidden */
  87716. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  87717. private _loadUnlitPropertiesAsync;
  87718. }
  87719. }
  87720. declare module BABYLON.GLTF2.Loader.Extensions {
  87721. /**
  87722. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  87723. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  87724. */
  87725. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  87726. /**
  87727. * The name of this extension.
  87728. */
  87729. readonly name: string;
  87730. /**
  87731. * Defines whether this extension is enabled.
  87732. */
  87733. enabled: boolean;
  87734. /**
  87735. * Defines a number that determines the order the extensions are applied.
  87736. */
  87737. order: number;
  87738. private _loader;
  87739. /** @hidden */
  87740. constructor(loader: GLTFLoader);
  87741. /** @hidden */
  87742. dispose(): void;
  87743. /** @hidden */
  87744. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  87745. private _loadClearCoatPropertiesAsync;
  87746. }
  87747. }
  87748. declare module BABYLON.GLTF2.Loader.Extensions {
  87749. /**
  87750. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_sheen/README.md)
  87751. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  87752. * !!! Experimental Extension Subject to Changes !!!
  87753. */
  87754. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  87755. /**
  87756. * The name of this extension.
  87757. */
  87758. readonly name: string;
  87759. /**
  87760. * Defines whether this extension is enabled.
  87761. */
  87762. enabled: boolean;
  87763. /**
  87764. * Defines a number that determines the order the extensions are applied.
  87765. */
  87766. order: number;
  87767. private _loader;
  87768. /** @hidden */
  87769. constructor(loader: GLTFLoader);
  87770. /** @hidden */
  87771. dispose(): void;
  87772. /** @hidden */
  87773. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  87774. private _loadSheenPropertiesAsync;
  87775. }
  87776. }
  87777. declare module BABYLON.GLTF2.Loader.Extensions {
  87778. /**
  87779. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  87780. * !!! Experimental Extension Subject to Changes !!!
  87781. */
  87782. export class KHR_materials_specular implements IGLTFLoaderExtension {
  87783. /**
  87784. * The name of this extension.
  87785. */
  87786. readonly name: string;
  87787. /**
  87788. * Defines whether this extension is enabled.
  87789. */
  87790. enabled: boolean;
  87791. /**
  87792. * Defines a number that determines the order the extensions are applied.
  87793. */
  87794. order: number;
  87795. private _loader;
  87796. /** @hidden */
  87797. constructor(loader: GLTFLoader);
  87798. /** @hidden */
  87799. dispose(): void;
  87800. /** @hidden */
  87801. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  87802. private _loadSpecularPropertiesAsync;
  87803. }
  87804. }
  87805. declare module BABYLON.GLTF2.Loader.Extensions {
  87806. /**
  87807. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  87808. * !!! Experimental Extension Subject to Changes !!!
  87809. */
  87810. export class KHR_materials_ior implements IGLTFLoaderExtension {
  87811. /**
  87812. * Default ior Value from the spec.
  87813. */
  87814. private static readonly _DEFAULT_IOR;
  87815. /**
  87816. * The name of this extension.
  87817. */
  87818. readonly name: string;
  87819. /**
  87820. * Defines whether this extension is enabled.
  87821. */
  87822. enabled: boolean;
  87823. /**
  87824. * Defines a number that determines the order the extensions are applied.
  87825. */
  87826. order: number;
  87827. private _loader;
  87828. /** @hidden */
  87829. constructor(loader: GLTFLoader);
  87830. /** @hidden */
  87831. dispose(): void;
  87832. /** @hidden */
  87833. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  87834. private _loadIorPropertiesAsync;
  87835. }
  87836. }
  87837. declare module BABYLON.GLTF2.Loader.Extensions {
  87838. /**
  87839. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_variants/README.md)
  87840. */
  87841. export class KHR_materials_variants implements IGLTFLoaderExtension {
  87842. /**
  87843. * The name of this extension.
  87844. */
  87845. readonly name: string;
  87846. /**
  87847. * Defines whether this extension is enabled.
  87848. */
  87849. enabled: boolean;
  87850. private _loader;
  87851. private _variants?;
  87852. /** @hidden */
  87853. constructor(loader: GLTFLoader);
  87854. /** @hidden */
  87855. dispose(): void;
  87856. /**
  87857. * Gets the list of available variant names for this asset.
  87858. * @param rootMesh The glTF root mesh
  87859. * @returns the list of all the variant names for this model
  87860. */
  87861. static GetAvailableVariants(rootMesh: Mesh): string[];
  87862. /**
  87863. * Gets the list of available variant names for this asset.
  87864. * @param rootMesh The glTF root mesh
  87865. * @returns the list of all the variant names for this model
  87866. */
  87867. getAvailableVariants(rootMesh: Mesh): string[];
  87868. /**
  87869. * Select a variant given a variant name or a list of variant names.
  87870. * @param rootMesh The glTF root mesh
  87871. * @param variantName The variant name(s) to select.
  87872. */
  87873. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  87874. /**
  87875. * Select a variant given a variant name or a list of variant names.
  87876. * @param rootMesh The glTF root mesh
  87877. * @param variantName The variant name(s) to select.
  87878. */
  87879. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  87880. /**
  87881. * Reset back to the original before selecting a variant.
  87882. * @param rootMesh The glTF root mesh
  87883. */
  87884. static Reset(rootMesh: Mesh): void;
  87885. /**
  87886. * Reset back to the original before selecting a variant.
  87887. * @param rootMesh The glTF root mesh
  87888. */
  87889. reset(rootMesh: Mesh): void;
  87890. /**
  87891. * Gets the last selected variant name(s) or null if original.
  87892. * @param rootMesh The glTF root mesh
  87893. * @returns The selected variant name(s).
  87894. */
  87895. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  87896. /**
  87897. * Gets the last selected variant name(s) or null if original.
  87898. * @param rootMesh The glTF root mesh
  87899. * @returns The selected variant name(s).
  87900. */
  87901. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  87902. private static _GetExtensionMetadata;
  87903. /** @hidden */
  87904. onLoading(): void;
  87905. /** @hidden */
  87906. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  87907. }
  87908. }
  87909. declare module BABYLON.GLTF2.Loader.Extensions {
  87910. /**
  87911. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_transmission/README.md)
  87912. */
  87913. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  87914. /**
  87915. * The name of this extension.
  87916. */
  87917. readonly name: string;
  87918. /**
  87919. * Defines whether this extension is enabled.
  87920. */
  87921. enabled: boolean;
  87922. /**
  87923. * Defines a number that determines the order the extensions are applied.
  87924. */
  87925. order: number;
  87926. private _loader;
  87927. /** @hidden */
  87928. constructor(loader: GLTFLoader);
  87929. /** @hidden */
  87930. dispose(): void;
  87931. /** @hidden */
  87932. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  87933. private _loadTransparentPropertiesAsync;
  87934. }
  87935. }
  87936. declare module BABYLON.GLTF2.Loader.Extensions {
  87937. /**
  87938. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
  87939. * !!! Experimental Extension Subject to Changes !!!
  87940. */
  87941. export class KHR_materials_translucency implements IGLTFLoaderExtension {
  87942. /**
  87943. * The name of this extension.
  87944. */
  87945. readonly name: string;
  87946. /**
  87947. * Defines whether this extension is enabled.
  87948. */
  87949. enabled: boolean;
  87950. /**
  87951. * Defines a number that determines the order the extensions are applied.
  87952. */
  87953. order: number;
  87954. private _loader;
  87955. /** @hidden */
  87956. constructor(loader: GLTFLoader);
  87957. /** @hidden */
  87958. dispose(): void;
  87959. /** @hidden */
  87960. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  87961. private _loadTranslucentPropertiesAsync;
  87962. }
  87963. }
  87964. declare module BABYLON.GLTF2.Loader.Extensions {
  87965. /**
  87966. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  87967. */
  87968. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  87969. /**
  87970. * The name of this extension.
  87971. */
  87972. readonly name: string;
  87973. /**
  87974. * Defines whether this extension is enabled.
  87975. */
  87976. enabled: boolean;
  87977. /** @hidden */
  87978. constructor(loader: GLTFLoader);
  87979. /** @hidden */
  87980. dispose(): void;
  87981. }
  87982. }
  87983. declare module BABYLON.GLTF2.Loader.Extensions {
  87984. /**
  87985. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  87986. * !!! Experimental Extension Subject to Changes !!!
  87987. */
  87988. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  87989. /** The name of this extension. */
  87990. readonly name: string;
  87991. /** Defines whether this extension is enabled. */
  87992. enabled: boolean;
  87993. private _loader;
  87994. /** @hidden */
  87995. constructor(loader: GLTFLoader);
  87996. /** @hidden */
  87997. dispose(): void;
  87998. /** @hidden */
  87999. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88000. }
  88001. }
  88002. declare module BABYLON.GLTF2.Loader.Extensions {
  88003. /**
  88004. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  88005. */
  88006. export class KHR_texture_transform implements IGLTFLoaderExtension {
  88007. /**
  88008. * The name of this extension.
  88009. */
  88010. readonly name: string;
  88011. /**
  88012. * Defines whether this extension is enabled.
  88013. */
  88014. enabled: boolean;
  88015. private _loader;
  88016. /** @hidden */
  88017. constructor(loader: GLTFLoader);
  88018. /** @hidden */
  88019. dispose(): void;
  88020. /** @hidden */
  88021. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88022. }
  88023. }
  88024. declare module BABYLON.GLTF2.Loader.Extensions {
  88025. /**
  88026. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  88027. */
  88028. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  88029. /**
  88030. * The name of this extension.
  88031. */
  88032. readonly name: string;
  88033. /**
  88034. * Defines whether this extension is enabled.
  88035. */
  88036. enabled: boolean;
  88037. private _loader;
  88038. private _clips;
  88039. private _emitters;
  88040. /** @hidden */
  88041. constructor(loader: GLTFLoader);
  88042. /** @hidden */
  88043. dispose(): void;
  88044. /** @hidden */
  88045. onLoading(): void;
  88046. /** @hidden */
  88047. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  88048. /** @hidden */
  88049. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88050. /** @hidden */
  88051. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  88052. private _loadClipAsync;
  88053. private _loadEmitterAsync;
  88054. private _getEventAction;
  88055. private _loadAnimationEventAsync;
  88056. }
  88057. }
  88058. declare module BABYLON.GLTF2.Loader.Extensions {
  88059. /**
  88060. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  88061. */
  88062. export class MSFT_lod implements IGLTFLoaderExtension {
  88063. /**
  88064. * The name of this extension.
  88065. */
  88066. readonly name: string;
  88067. /**
  88068. * Defines whether this extension is enabled.
  88069. */
  88070. enabled: boolean;
  88071. /**
  88072. * Defines a number that determines the order the extensions are applied.
  88073. */
  88074. order: number;
  88075. /**
  88076. * Maximum number of LODs to load, starting from the lowest LOD.
  88077. */
  88078. maxLODsToLoad: number;
  88079. /**
  88080. * Observable raised when all node LODs of one level are loaded.
  88081. * The event data is the index of the loaded LOD starting from zero.
  88082. * Dispose the loader to cancel the loading of the next level of LODs.
  88083. */
  88084. onNodeLODsLoadedObservable: Observable<number>;
  88085. /**
  88086. * Observable raised when all material LODs of one level are loaded.
  88087. * The event data is the index of the loaded LOD starting from zero.
  88088. * Dispose the loader to cancel the loading of the next level of LODs.
  88089. */
  88090. onMaterialLODsLoadedObservable: Observable<number>;
  88091. private _loader;
  88092. private _bufferLODs;
  88093. private _nodeIndexLOD;
  88094. private _nodeSignalLODs;
  88095. private _nodePromiseLODs;
  88096. private _nodeBufferLODs;
  88097. private _materialIndexLOD;
  88098. private _materialSignalLODs;
  88099. private _materialPromiseLODs;
  88100. private _materialBufferLODs;
  88101. /** @hidden */
  88102. constructor(loader: GLTFLoader);
  88103. /** @hidden */
  88104. dispose(): void;
  88105. /** @hidden */
  88106. onReady(): void;
  88107. /** @hidden */
  88108. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  88109. /** @hidden */
  88110. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88111. /** @hidden */
  88112. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  88113. /** @hidden */
  88114. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  88115. /** @hidden */
  88116. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  88117. private _loadBufferLOD;
  88118. /**
  88119. * Gets an array of LOD properties from lowest to highest.
  88120. */
  88121. private _getLODs;
  88122. private _disposeTransformNode;
  88123. private _disposeMaterials;
  88124. }
  88125. }
  88126. declare module BABYLON.GLTF2.Loader.Extensions {
  88127. /** @hidden */
  88128. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  88129. readonly name: string;
  88130. enabled: boolean;
  88131. private _loader;
  88132. constructor(loader: GLTFLoader);
  88133. dispose(): void;
  88134. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88135. }
  88136. }
  88137. declare module BABYLON.GLTF2.Loader.Extensions {
  88138. /** @hidden */
  88139. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  88140. readonly name: string;
  88141. enabled: boolean;
  88142. private _loader;
  88143. constructor(loader: GLTFLoader);
  88144. dispose(): void;
  88145. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88146. }
  88147. }
  88148. declare module BABYLON.GLTF2.Loader.Extensions {
  88149. /**
  88150. * Store glTF extras (if present) in BJS objects' metadata
  88151. */
  88152. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  88153. /**
  88154. * The name of this extension.
  88155. */
  88156. readonly name: string;
  88157. /**
  88158. * Defines whether this extension is enabled.
  88159. */
  88160. enabled: boolean;
  88161. private _loader;
  88162. private _assignExtras;
  88163. /** @hidden */
  88164. constructor(loader: GLTFLoader);
  88165. /** @hidden */
  88166. dispose(): void;
  88167. /** @hidden */
  88168. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88169. /** @hidden */
  88170. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  88171. /** @hidden */
  88172. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  88173. }
  88174. }
  88175. declare module BABYLON {
  88176. /**
  88177. * Class reading and parsing the MTL file bundled with the obj file.
  88178. */
  88179. export class MTLFileLoader {
  88180. /**
  88181. * Invert Y-Axis of referenced textures on load
  88182. */
  88183. static INVERT_TEXTURE_Y: boolean;
  88184. /**
  88185. * All material loaded from the mtl will be set here
  88186. */
  88187. materials: StandardMaterial[];
  88188. /**
  88189. * This function will read the mtl file and create each material described inside
  88190. * This function could be improve by adding :
  88191. * -some component missing (Ni, Tf...)
  88192. * -including the specific options available
  88193. *
  88194. * @param scene defines the scene the material will be created in
  88195. * @param data defines the mtl data to parse
  88196. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  88197. * @param forAssetContainer defines if the material should be registered in the scene
  88198. */
  88199. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  88200. /**
  88201. * Gets the texture for the material.
  88202. *
  88203. * If the material is imported from input file,
  88204. * We sanitize the url to ensure it takes the textre from aside the material.
  88205. *
  88206. * @param rootUrl The root url to load from
  88207. * @param value The value stored in the mtl
  88208. * @return The Texture
  88209. */
  88210. private static _getTexture;
  88211. }
  88212. }
  88213. declare module BABYLON {
  88214. /**
  88215. * Options for loading OBJ/MTL files
  88216. */
  88217. type MeshLoadOptions = {
  88218. /**
  88219. * Defines if UVs are optimized by default during load.
  88220. */
  88221. OptimizeWithUV: boolean;
  88222. /**
  88223. * Defines custom scaling of UV coordinates of loaded meshes.
  88224. */
  88225. UVScaling: Vector2;
  88226. /**
  88227. * Invert model on y-axis (does a model scaling inversion)
  88228. */
  88229. InvertY: boolean;
  88230. /**
  88231. * Invert Y-Axis of referenced textures on load
  88232. */
  88233. InvertTextureY: boolean;
  88234. /**
  88235. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  88236. */
  88237. ImportVertexColors: boolean;
  88238. /**
  88239. * Compute the normals for the model, even if normals are present in the file.
  88240. */
  88241. ComputeNormals: boolean;
  88242. /**
  88243. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  88244. */
  88245. SkipMaterials: boolean;
  88246. /**
  88247. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  88248. */
  88249. MaterialLoadingFailsSilently: boolean;
  88250. };
  88251. /**
  88252. * OBJ file type loader.
  88253. * This is a babylon scene loader plugin.
  88254. */
  88255. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  88256. /**
  88257. * Defines if UVs are optimized by default during load.
  88258. */
  88259. static OPTIMIZE_WITH_UV: boolean;
  88260. /**
  88261. * Invert model on y-axis (does a model scaling inversion)
  88262. */
  88263. static INVERT_Y: boolean;
  88264. /**
  88265. * Invert Y-Axis of referenced textures on load
  88266. */
  88267. static get INVERT_TEXTURE_Y(): boolean;
  88268. static set INVERT_TEXTURE_Y(value: boolean);
  88269. /**
  88270. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  88271. */
  88272. static IMPORT_VERTEX_COLORS: boolean;
  88273. /**
  88274. * Compute the normals for the model, even if normals are present in the file.
  88275. */
  88276. static COMPUTE_NORMALS: boolean;
  88277. /**
  88278. * Defines custom scaling of UV coordinates of loaded meshes.
  88279. */
  88280. static UV_SCALING: Vector2;
  88281. /**
  88282. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  88283. */
  88284. static SKIP_MATERIALS: boolean;
  88285. /**
  88286. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  88287. *
  88288. * Defaults to true for backwards compatibility.
  88289. */
  88290. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  88291. /**
  88292. * Defines the name of the plugin.
  88293. */
  88294. name: string;
  88295. /**
  88296. * Defines the extension the plugin is able to load.
  88297. */
  88298. extensions: string;
  88299. /** @hidden */
  88300. obj: RegExp;
  88301. /** @hidden */
  88302. group: RegExp;
  88303. /** @hidden */
  88304. mtllib: RegExp;
  88305. /** @hidden */
  88306. usemtl: RegExp;
  88307. /** @hidden */
  88308. smooth: RegExp;
  88309. /** @hidden */
  88310. vertexPattern: RegExp;
  88311. /** @hidden */
  88312. normalPattern: RegExp;
  88313. /** @hidden */
  88314. uvPattern: RegExp;
  88315. /** @hidden */
  88316. facePattern1: RegExp;
  88317. /** @hidden */
  88318. facePattern2: RegExp;
  88319. /** @hidden */
  88320. facePattern3: RegExp;
  88321. /** @hidden */
  88322. facePattern4: RegExp;
  88323. /** @hidden */
  88324. facePattern5: RegExp;
  88325. private _forAssetContainer;
  88326. private _meshLoadOptions;
  88327. /**
  88328. * Creates loader for .OBJ files
  88329. *
  88330. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  88331. */
  88332. constructor(meshLoadOptions?: MeshLoadOptions);
  88333. private static get currentMeshLoadOptions();
  88334. /**
  88335. * Calls synchronously the MTL file attached to this obj.
  88336. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  88337. * Without this function materials are not displayed in the first frame (but displayed after).
  88338. * In consequence it is impossible to get material information in your HTML file
  88339. *
  88340. * @param url The URL of the MTL file
  88341. * @param rootUrl
  88342. * @param onSuccess Callback function to be called when the MTL file is loaded
  88343. * @private
  88344. */
  88345. private _loadMTL;
  88346. /**
  88347. * Instantiates a OBJ file loader plugin.
  88348. * @returns the created plugin
  88349. */
  88350. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  88351. /**
  88352. * If the data string can be loaded directly.
  88353. *
  88354. * @param data string containing the file data
  88355. * @returns if the data can be loaded directly
  88356. */
  88357. canDirectLoad(data: string): boolean;
  88358. /**
  88359. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  88360. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  88361. * @param scene the scene the meshes should be added to
  88362. * @param data the OBJ data to load
  88363. * @param rootUrl root url to load from
  88364. * @param onProgress event that fires when loading progress has occured
  88365. * @param fileName Defines the name of the file to load
  88366. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  88367. */
  88368. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  88369. /**
  88370. * Imports all objects from the loaded OBJ data and adds them to the scene
  88371. * @param scene the scene the objects should be added to
  88372. * @param data the OBJ data to load
  88373. * @param rootUrl root url to load from
  88374. * @param onProgress event that fires when loading progress has occured
  88375. * @param fileName Defines the name of the file to load
  88376. * @returns a promise which completes when objects have been loaded to the scene
  88377. */
  88378. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  88379. /**
  88380. * Load into an asset container.
  88381. * @param scene The scene to load into
  88382. * @param data The data to import
  88383. * @param rootUrl The root url for scene and resources
  88384. * @param onProgress The callback when the load progresses
  88385. * @param fileName Defines the name of the file to load
  88386. * @returns The loaded asset container
  88387. */
  88388. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  88389. /**
  88390. * Read the OBJ file and create an Array of meshes.
  88391. * Each mesh contains all information given by the OBJ and the MTL file.
  88392. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  88393. *
  88394. * @param meshesNames
  88395. * @param scene Scene The scene where are displayed the data
  88396. * @param data String The content of the obj file
  88397. * @param rootUrl String The path to the folder
  88398. * @returns Array<AbstractMesh>
  88399. * @private
  88400. */
  88401. private _parseSolid;
  88402. }
  88403. }
  88404. declare module BABYLON {
  88405. /**
  88406. * STL file type loader.
  88407. * This is a babylon scene loader plugin.
  88408. */
  88409. export class STLFileLoader implements ISceneLoaderPlugin {
  88410. /** @hidden */
  88411. solidPattern: RegExp;
  88412. /** @hidden */
  88413. facetsPattern: RegExp;
  88414. /** @hidden */
  88415. normalPattern: RegExp;
  88416. /** @hidden */
  88417. vertexPattern: RegExp;
  88418. /**
  88419. * Defines the name of the plugin.
  88420. */
  88421. name: string;
  88422. /**
  88423. * Defines the extensions the stl loader is able to load.
  88424. * force data to come in as an ArrayBuffer
  88425. * we'll convert to string if it looks like it's an ASCII .stl
  88426. */
  88427. extensions: ISceneLoaderPluginExtensions;
  88428. /**
  88429. * Import meshes into a scene.
  88430. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  88431. * @param scene The scene to import into
  88432. * @param data The data to import
  88433. * @param rootUrl The root url for scene and resources
  88434. * @param meshes The meshes array to import into
  88435. * @param particleSystems The particle systems array to import into
  88436. * @param skeletons The skeletons array to import into
  88437. * @param onError The callback when import fails
  88438. * @returns True if successful or false otherwise
  88439. */
  88440. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  88441. /**
  88442. * Load into a scene.
  88443. * @param scene The scene to load into
  88444. * @param data The data to import
  88445. * @param rootUrl The root url for scene and resources
  88446. * @param onError The callback when import fails
  88447. * @returns true if successful or false otherwise
  88448. */
  88449. load(scene: Scene, data: any, rootUrl: string): boolean;
  88450. /**
  88451. * Load into an asset container.
  88452. * @param scene The scene to load into
  88453. * @param data The data to import
  88454. * @param rootUrl The root url for scene and resources
  88455. * @param onError The callback when import fails
  88456. * @returns The loaded asset container
  88457. */
  88458. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  88459. private _isBinary;
  88460. private _parseBinary;
  88461. private _parseASCII;
  88462. }
  88463. }
  88464. declare module BABYLON {
  88465. /**
  88466. * Class for generating OBJ data from a Babylon scene.
  88467. */
  88468. export class OBJExport {
  88469. /**
  88470. * Exports the geometry of a Mesh array in .OBJ file format (text)
  88471. * @param mesh defines the list of meshes to serialize
  88472. * @param materials defines if materials should be exported
  88473. * @param matlibname defines the name of the associated mtl file
  88474. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  88475. * @returns the OBJ content
  88476. */
  88477. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  88478. /**
  88479. * Exports the material(s) of a mesh in .MTL file format (text)
  88480. * @param mesh defines the mesh to extract the material from
  88481. * @returns the mtl content
  88482. */
  88483. static MTL(mesh: Mesh): string;
  88484. }
  88485. }
  88486. declare module BABYLON {
  88487. /** @hidden */
  88488. export var __IGLTFExporterExtension: number;
  88489. /**
  88490. * Interface for extending the exporter
  88491. * @hidden
  88492. */
  88493. export interface IGLTFExporterExtension {
  88494. /**
  88495. * The name of this extension
  88496. */
  88497. readonly name: string;
  88498. /**
  88499. * Defines whether this extension is enabled
  88500. */
  88501. enabled: boolean;
  88502. /**
  88503. * Defines whether this extension is required
  88504. */
  88505. required: boolean;
  88506. }
  88507. }
  88508. declare module BABYLON.GLTF2.Exporter {
  88509. /** @hidden */
  88510. export var __IGLTFExporterExtensionV2: number;
  88511. /**
  88512. * Interface for a glTF exporter extension
  88513. * @hidden
  88514. */
  88515. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  88516. /**
  88517. * Define this method to modify the default behavior before exporting a texture
  88518. * @param context The context when loading the asset
  88519. * @param babylonTexture The Babylon.js texture
  88520. * @param mimeType The mime-type of the generated image
  88521. * @returns A promise that resolves with the exported texture
  88522. */
  88523. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  88524. /**
  88525. * Define this method to get notified when a texture info is created
  88526. * @param context The context when loading the asset
  88527. * @param textureInfo The glTF texture info
  88528. * @param babylonTexture The Babylon.js texture
  88529. */
  88530. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  88531. /**
  88532. * Define this method to modify the default behavior when exporting texture info
  88533. * @param context The context when loading the asset
  88534. * @param meshPrimitive glTF mesh primitive
  88535. * @param babylonSubMesh Babylon submesh
  88536. * @param binaryWriter glTF serializer binary writer instance
  88537. * @returns nullable IMeshPrimitive promise
  88538. */
  88539. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  88540. /**
  88541. * Define this method to modify the default behavior when exporting a node
  88542. * @param context The context when exporting the node
  88543. * @param node glTF node
  88544. * @param babylonNode BabylonJS node
  88545. * @returns nullable INode promise
  88546. */
  88547. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  88548. [key: number]: number;
  88549. }): Promise<Nullable<INode>>;
  88550. /**
  88551. * Define this method to modify the default behavior when exporting a material
  88552. * @param material glTF material
  88553. * @param babylonMaterial BabylonJS material
  88554. * @returns nullable IMaterial promise
  88555. */
  88556. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  88557. /**
  88558. * Define this method to return additional textures to export from a material
  88559. * @param material glTF material
  88560. * @param babylonMaterial BabylonJS material
  88561. * @returns List of textures
  88562. */
  88563. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  88564. /** Gets a boolean indicating that this extension was used */
  88565. wasUsed: boolean;
  88566. /** Gets a boolean indicating that this extension is required for the file to work */
  88567. required: boolean;
  88568. /**
  88569. * Called after the exporter state changes to EXPORTING
  88570. */
  88571. onExporting?(): void;
  88572. }
  88573. }
  88574. declare module BABYLON.GLTF2.Exporter {
  88575. /**
  88576. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  88577. * @hidden
  88578. */
  88579. export class _GLTFMaterialExporter {
  88580. /**
  88581. * Represents the dielectric specular values for R, G and B
  88582. */
  88583. private static readonly _DielectricSpecular;
  88584. /**
  88585. * Allows the maximum specular power to be defined for material calculations
  88586. */
  88587. private static readonly _MaxSpecularPower;
  88588. /**
  88589. * Mapping to store textures
  88590. */
  88591. private _textureMap;
  88592. /**
  88593. * Numeric tolerance value
  88594. */
  88595. private static readonly _Epsilon;
  88596. /**
  88597. * Reference to the glTF Exporter
  88598. */
  88599. private _exporter;
  88600. constructor(exporter: _Exporter);
  88601. /**
  88602. * Specifies if two colors are approximately equal in value
  88603. * @param color1 first color to compare to
  88604. * @param color2 second color to compare to
  88605. * @param epsilon threshold value
  88606. */
  88607. private static FuzzyEquals;
  88608. /**
  88609. * Gets the materials from a Babylon scene and converts them to glTF materials
  88610. * @param scene babylonjs scene
  88611. * @param mimeType texture mime type
  88612. * @param images array of images
  88613. * @param textures array of textures
  88614. * @param materials array of materials
  88615. * @param imageData mapping of texture names to base64 textures
  88616. * @param hasTextureCoords specifies if texture coordinates are present on the material
  88617. */
  88618. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  88619. /**
  88620. * Makes a copy of the glTF material without the texture parameters
  88621. * @param originalMaterial original glTF material
  88622. * @returns glTF material without texture parameters
  88623. */
  88624. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  88625. /**
  88626. * Specifies if the material has any texture parameters present
  88627. * @param material glTF Material
  88628. * @returns boolean specifying if texture parameters are present
  88629. */
  88630. _hasTexturesPresent(material: IMaterial): boolean;
  88631. /**
  88632. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  88633. * @param babylonStandardMaterial
  88634. * @returns glTF Metallic Roughness Material representation
  88635. */
  88636. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  88637. /**
  88638. * Computes the metallic factor
  88639. * @param diffuse diffused value
  88640. * @param specular specular value
  88641. * @param oneMinusSpecularStrength one minus the specular strength
  88642. * @returns metallic value
  88643. */
  88644. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  88645. /**
  88646. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  88647. * @param glTFMaterial glTF material
  88648. * @param babylonMaterial Babylon material
  88649. */
  88650. private static _SetAlphaMode;
  88651. /**
  88652. * Converts a Babylon Standard Material to a glTF Material
  88653. * @param babylonStandardMaterial BJS Standard Material
  88654. * @param mimeType mime type to use for the textures
  88655. * @param images array of glTF image interfaces
  88656. * @param textures array of glTF texture interfaces
  88657. * @param materials array of glTF material interfaces
  88658. * @param imageData map of image file name to data
  88659. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  88660. */
  88661. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  88662. private _finishMaterial;
  88663. /**
  88664. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  88665. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  88666. * @param mimeType mime type to use for the textures
  88667. * @param images array of glTF image interfaces
  88668. * @param textures array of glTF texture interfaces
  88669. * @param materials array of glTF material interfaces
  88670. * @param imageData map of image file name to data
  88671. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  88672. */
  88673. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  88674. /**
  88675. * Converts an image typed array buffer to a base64 image
  88676. * @param buffer typed array buffer
  88677. * @param width width of the image
  88678. * @param height height of the image
  88679. * @param mimeType mimetype of the image
  88680. * @returns base64 image string
  88681. */
  88682. private _createBase64FromCanvasAsync;
  88683. /**
  88684. * Generates a white texture based on the specified width and height
  88685. * @param width width of the texture in pixels
  88686. * @param height height of the texture in pixels
  88687. * @param scene babylonjs scene
  88688. * @returns white texture
  88689. */
  88690. private _createWhiteTexture;
  88691. /**
  88692. * 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
  88693. * @param texture1 first texture to resize
  88694. * @param texture2 second texture to resize
  88695. * @param scene babylonjs scene
  88696. * @returns resized textures or null
  88697. */
  88698. private _resizeTexturesToSameDimensions;
  88699. /**
  88700. * Converts an array of pixels to a Float32Array
  88701. * Throws an error if the pixel format is not supported
  88702. * @param pixels - array buffer containing pixel values
  88703. * @returns Float32 of pixels
  88704. */
  88705. private _convertPixelArrayToFloat32;
  88706. /**
  88707. * Convert Specular Glossiness Textures to Metallic Roughness
  88708. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  88709. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  88710. * @param diffuseTexture texture used to store diffuse information
  88711. * @param specularGlossinessTexture texture used to store specular and glossiness information
  88712. * @param factors specular glossiness material factors
  88713. * @param mimeType the mime type to use for the texture
  88714. * @returns pbr metallic roughness interface or null
  88715. */
  88716. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  88717. /**
  88718. * Converts specular glossiness material properties to metallic roughness
  88719. * @param specularGlossiness interface with specular glossiness material properties
  88720. * @returns interface with metallic roughness material properties
  88721. */
  88722. private _convertSpecularGlossinessToMetallicRoughness;
  88723. /**
  88724. * Calculates the surface reflectance, independent of lighting conditions
  88725. * @param color Color source to calculate brightness from
  88726. * @returns number representing the perceived brightness, or zero if color is undefined
  88727. */
  88728. private _getPerceivedBrightness;
  88729. /**
  88730. * Returns the maximum color component value
  88731. * @param color
  88732. * @returns maximum color component value, or zero if color is null or undefined
  88733. */
  88734. private _getMaxComponent;
  88735. /**
  88736. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  88737. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  88738. * @param mimeType mime type to use for the textures
  88739. * @param images array of glTF image interfaces
  88740. * @param textures array of glTF texture interfaces
  88741. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  88742. * @param imageData map of image file name to data
  88743. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  88744. * @returns glTF PBR Metallic Roughness factors
  88745. */
  88746. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  88747. private _getGLTFTextureSampler;
  88748. private _getGLTFTextureWrapMode;
  88749. private _getGLTFTextureWrapModesSampler;
  88750. /**
  88751. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  88752. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  88753. * @param mimeType mime type to use for the textures
  88754. * @param images array of glTF image interfaces
  88755. * @param textures array of glTF texture interfaces
  88756. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  88757. * @param imageData map of image file name to data
  88758. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  88759. * @returns glTF PBR Metallic Roughness factors
  88760. */
  88761. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  88762. /**
  88763. * Converts a Babylon PBR Base Material to a glTF Material
  88764. * @param babylonPBRMaterial BJS PBR Base Material
  88765. * @param mimeType mime type to use for the textures
  88766. * @param images array of glTF image interfaces
  88767. * @param textures array of glTF texture interfaces
  88768. * @param materials array of glTF material interfaces
  88769. * @param imageData map of image file name to data
  88770. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  88771. */
  88772. _convertPBRMaterialAsync(babylonPBRMaterial: PBRBaseMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  88773. private setMetallicRoughnessPbrMaterial;
  88774. private getPixelsFromTexture;
  88775. /**
  88776. * Extracts a texture from a Babylon texture into file data and glTF data
  88777. * @param babylonTexture Babylon texture to extract
  88778. * @param mimeType Mime Type of the babylonTexture
  88779. * @return glTF texture info, or null if the texture format is not supported
  88780. */
  88781. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  88782. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  88783. /**
  88784. * Builds a texture from base64 string
  88785. * @param base64Texture base64 texture string
  88786. * @param baseTextureName Name to use for the texture
  88787. * @param mimeType image mime type for the texture
  88788. * @param images array of images
  88789. * @param textures array of textures
  88790. * @param imageData map of image data
  88791. * @returns glTF texture info, or null if the texture format is not supported
  88792. */
  88793. private _getTextureInfoFromBase64;
  88794. }
  88795. }
  88796. declare module BABYLON {
  88797. /**
  88798. * Class for holding and downloading glTF file data
  88799. */
  88800. export class GLTFData {
  88801. /**
  88802. * Object which contains the file name as the key and its data as the value
  88803. */
  88804. glTFFiles: {
  88805. [fileName: string]: string | Blob;
  88806. };
  88807. /**
  88808. * Initializes the glTF file object
  88809. */
  88810. constructor();
  88811. /**
  88812. * Downloads the glTF data as files based on their names and data
  88813. */
  88814. downloadFiles(): void;
  88815. }
  88816. }
  88817. declare module BABYLON {
  88818. /**
  88819. * Holds a collection of exporter options and parameters
  88820. */
  88821. export interface IExportOptions {
  88822. /**
  88823. * Function which indicates whether a babylon node should be exported or not
  88824. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  88825. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  88826. */
  88827. shouldExportNode?(node: Node): boolean;
  88828. /**
  88829. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  88830. * @param metadata source metadata to read from
  88831. * @returns the data to store to glTF node extras
  88832. */
  88833. metadataSelector?(metadata: any): any;
  88834. /**
  88835. * The sample rate to bake animation curves
  88836. */
  88837. animationSampleRate?: number;
  88838. /**
  88839. * Begin serialization without waiting for the scene to be ready
  88840. */
  88841. exportWithoutWaitingForScene?: boolean;
  88842. /**
  88843. * Indicates if coordinate system swapping root nodes should be included in export
  88844. */
  88845. includeCoordinateSystemConversionNodes?: boolean;
  88846. }
  88847. /**
  88848. * Class for generating glTF data from a Babylon scene.
  88849. */
  88850. export class GLTF2Export {
  88851. /**
  88852. * Exports the geometry of the scene to .gltf file format asynchronously
  88853. * @param scene Babylon scene with scene hierarchy information
  88854. * @param filePrefix File prefix to use when generating the glTF file
  88855. * @param options Exporter options
  88856. * @returns Returns an object with a .gltf file and associates texture names
  88857. * as keys and their data and paths as values
  88858. */
  88859. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  88860. private static _PreExportAsync;
  88861. private static _PostExportAsync;
  88862. /**
  88863. * Exports the geometry of the scene to .glb file format asychronously
  88864. * @param scene Babylon scene with scene hierarchy information
  88865. * @param filePrefix File prefix to use when generating glb file
  88866. * @param options Exporter options
  88867. * @returns Returns an object with a .glb filename as key and data as value
  88868. */
  88869. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  88870. }
  88871. }
  88872. declare module BABYLON.GLTF2.Exporter {
  88873. /**
  88874. * @hidden
  88875. */
  88876. export class _GLTFUtilities {
  88877. /**
  88878. * Creates a buffer view based on the supplied arguments
  88879. * @param bufferIndex index value of the specified buffer
  88880. * @param byteOffset byte offset value
  88881. * @param byteLength byte length of the bufferView
  88882. * @param byteStride byte distance between conequential elements
  88883. * @param name name of the buffer view
  88884. * @returns bufferView for glTF
  88885. */
  88886. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  88887. /**
  88888. * Creates an accessor based on the supplied arguments
  88889. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  88890. * @param name The name of the accessor
  88891. * @param type The type of the accessor
  88892. * @param componentType The datatype of components in the attribute
  88893. * @param count The number of attributes referenced by this accessor
  88894. * @param byteOffset The offset relative to the start of the bufferView in bytes
  88895. * @param min Minimum value of each component in this attribute
  88896. * @param max Maximum value of each component in this attribute
  88897. * @returns accessor for glTF
  88898. */
  88899. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  88900. /**
  88901. * Calculates the minimum and maximum values of an array of position floats
  88902. * @param positions Positions array of a mesh
  88903. * @param vertexStart Starting vertex offset to calculate min and max values
  88904. * @param vertexCount Number of vertices to check for min and max values
  88905. * @returns min number array and max number array
  88906. */
  88907. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  88908. min: number[];
  88909. max: number[];
  88910. };
  88911. /**
  88912. * Converts a new right-handed Vector3
  88913. * @param vector vector3 array
  88914. * @returns right-handed Vector3
  88915. */
  88916. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  88917. /**
  88918. * Converts a Vector3 to right-handed
  88919. * @param vector Vector3 to convert to right-handed
  88920. */
  88921. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  88922. /**
  88923. * Converts a three element number array to right-handed
  88924. * @param vector number array to convert to right-handed
  88925. */
  88926. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  88927. /**
  88928. * Converts a new right-handed Vector3
  88929. * @param vector vector3 array
  88930. * @returns right-handed Vector3
  88931. */
  88932. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  88933. /**
  88934. * Converts a Vector3 to right-handed
  88935. * @param vector Vector3 to convert to right-handed
  88936. */
  88937. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  88938. /**
  88939. * Converts a three element number array to right-handed
  88940. * @param vector number array to convert to right-handed
  88941. */
  88942. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  88943. /**
  88944. * Converts a Vector4 to right-handed
  88945. * @param vector Vector4 to convert to right-handed
  88946. */
  88947. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  88948. /**
  88949. * Converts a Vector4 to right-handed
  88950. * @param vector Vector4 to convert to right-handed
  88951. */
  88952. static _GetRightHandedArray4FromRef(vector: number[]): void;
  88953. /**
  88954. * Converts a Quaternion to right-handed
  88955. * @param quaternion Source quaternion to convert to right-handed
  88956. */
  88957. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  88958. /**
  88959. * Converts a Quaternion to right-handed
  88960. * @param quaternion Source quaternion to convert to right-handed
  88961. */
  88962. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  88963. static _NormalizeTangentFromRef(tangent: Vector4): void;
  88964. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  88965. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  88966. }
  88967. }
  88968. declare module BABYLON.GLTF2.Exporter {
  88969. /**
  88970. * Converts Babylon Scene into glTF 2.0.
  88971. * @hidden
  88972. */
  88973. export class _Exporter {
  88974. /**
  88975. * Stores the glTF to export
  88976. */
  88977. _glTF: IGLTF;
  88978. /**
  88979. * Stores all generated buffer views, which represents views into the main glTF buffer data
  88980. */
  88981. _bufferViews: IBufferView[];
  88982. /**
  88983. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  88984. */
  88985. _accessors: IAccessor[];
  88986. /**
  88987. * Stores all the generated nodes, which contains transform and/or mesh information per node
  88988. */
  88989. _nodes: INode[];
  88990. /**
  88991. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  88992. */
  88993. private _scenes;
  88994. /**
  88995. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  88996. */
  88997. private _meshes;
  88998. /**
  88999. * Stores all the generated material information, which represents the appearance of each primitive
  89000. */
  89001. _materials: IMaterial[];
  89002. _materialMap: {
  89003. [materialID: number]: number;
  89004. };
  89005. /**
  89006. * Stores all the generated texture information, which is referenced by glTF materials
  89007. */
  89008. _textures: ITexture[];
  89009. /**
  89010. * Stores all the generated image information, which is referenced by glTF textures
  89011. */
  89012. _images: IImage[];
  89013. /**
  89014. * Stores all the texture samplers
  89015. */
  89016. _samplers: ISampler[];
  89017. /**
  89018. * Stores all the generated glTF skins
  89019. */
  89020. _skins: ISkin[];
  89021. /**
  89022. * Stores all the generated animation samplers, which is referenced by glTF animations
  89023. */
  89024. /**
  89025. * Stores the animations for glTF models
  89026. */
  89027. private _animations;
  89028. /**
  89029. * Stores the total amount of bytes stored in the glTF buffer
  89030. */
  89031. private _totalByteLength;
  89032. /**
  89033. * Stores a reference to the Babylon scene containing the source geometry and material information
  89034. */
  89035. _babylonScene: Scene;
  89036. /**
  89037. * Stores a map of the image data, where the key is the file name and the value
  89038. * is the image data
  89039. */
  89040. _imageData: {
  89041. [fileName: string]: {
  89042. data: Uint8Array;
  89043. mimeType: ImageMimeType;
  89044. };
  89045. };
  89046. protected _orderedImageData: Array<{
  89047. data: Uint8Array;
  89048. mimeType: ImageMimeType;
  89049. }>;
  89050. /**
  89051. * Stores a map of the unique id of a node to its index in the node array
  89052. */
  89053. _nodeMap: {
  89054. [key: number]: number;
  89055. };
  89056. /**
  89057. * Specifies if the source Babylon scene was left handed, and needed conversion.
  89058. */
  89059. _convertToRightHandedSystem: boolean;
  89060. /**
  89061. * Specifies if a Babylon node should be converted to right-handed on export
  89062. */
  89063. _convertToRightHandedSystemMap: {
  89064. [nodeId: number]: boolean;
  89065. };
  89066. _includeCoordinateSystemConversionNodes: boolean;
  89067. /**
  89068. * Baked animation sample rate
  89069. */
  89070. private _animationSampleRate;
  89071. private _options;
  89072. private _localEngine;
  89073. _glTFMaterialExporter: _GLTFMaterialExporter;
  89074. private _extensions;
  89075. private static _ExtensionNames;
  89076. private static _ExtensionFactories;
  89077. private _applyExtension;
  89078. private _applyExtensions;
  89079. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  89080. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  89081. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  89082. [key: number]: number;
  89083. }): Promise<Nullable<INode>>;
  89084. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  89085. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  89086. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  89087. private _forEachExtensions;
  89088. private _extensionsOnExporting;
  89089. /**
  89090. * Load glTF serializer extensions
  89091. */
  89092. private _loadExtensions;
  89093. /**
  89094. * Creates a glTF Exporter instance, which can accept optional exporter options
  89095. * @param babylonScene Babylon scene object
  89096. * @param options Options to modify the behavior of the exporter
  89097. */
  89098. constructor(babylonScene: Scene, options?: IExportOptions);
  89099. dispose(): void;
  89100. /**
  89101. * Registers a glTF exporter extension
  89102. * @param name Name of the extension to export
  89103. * @param factory The factory function that creates the exporter extension
  89104. */
  89105. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  89106. /**
  89107. * Un-registers an exporter extension
  89108. * @param name The name fo the exporter extension
  89109. * @returns A boolean indicating whether the extension has been un-registered
  89110. */
  89111. static UnregisterExtension(name: string): boolean;
  89112. private reorderIndicesBasedOnPrimitiveMode;
  89113. /**
  89114. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  89115. * clock-wise during export to glTF
  89116. * @param submesh BabylonJS submesh
  89117. * @param primitiveMode Primitive mode of the mesh
  89118. * @param sideOrientation the winding order of the submesh
  89119. * @param vertexBufferKind The type of vertex attribute
  89120. * @param meshAttributeArray The vertex attribute data
  89121. * @param byteOffset The offset to the binary data
  89122. * @param binaryWriter The binary data for the glTF file
  89123. * @param convertToRightHandedSystem Converts the values to right-handed
  89124. */
  89125. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  89126. /**
  89127. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  89128. * clock-wise during export to glTF
  89129. * @param submesh BabylonJS submesh
  89130. * @param primitiveMode Primitive mode of the mesh
  89131. * @param sideOrientation the winding order of the submesh
  89132. * @param vertexBufferKind The type of vertex attribute
  89133. * @param meshAttributeArray The vertex attribute data
  89134. * @param byteOffset The offset to the binary data
  89135. * @param binaryWriter The binary data for the glTF file
  89136. * @param convertToRightHandedSystem Converts the values to right-handed
  89137. */
  89138. private reorderTriangleFillMode;
  89139. /**
  89140. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  89141. * clock-wise during export to glTF
  89142. * @param submesh BabylonJS submesh
  89143. * @param primitiveMode Primitive mode of the mesh
  89144. * @param sideOrientation the winding order of the submesh
  89145. * @param vertexBufferKind The type of vertex attribute
  89146. * @param meshAttributeArray The vertex attribute data
  89147. * @param byteOffset The offset to the binary data
  89148. * @param binaryWriter The binary data for the glTF file
  89149. * @param convertToRightHandedSystem Converts the values to right-handed
  89150. */
  89151. private reorderTriangleStripDrawMode;
  89152. /**
  89153. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  89154. * clock-wise during export to glTF
  89155. * @param submesh BabylonJS submesh
  89156. * @param primitiveMode Primitive mode of the mesh
  89157. * @param sideOrientation the winding order of the submesh
  89158. * @param vertexBufferKind The type of vertex attribute
  89159. * @param meshAttributeArray The vertex attribute data
  89160. * @param byteOffset The offset to the binary data
  89161. * @param binaryWriter The binary data for the glTF file
  89162. * @param convertToRightHandedSystem Converts the values to right-handed
  89163. */
  89164. private reorderTriangleFanMode;
  89165. /**
  89166. * Writes the vertex attribute data to binary
  89167. * @param vertices The vertices to write to the binary writer
  89168. * @param byteOffset The offset into the binary writer to overwrite binary data
  89169. * @param vertexAttributeKind The vertex attribute type
  89170. * @param meshAttributeArray The vertex attribute data
  89171. * @param binaryWriter The writer containing the binary data
  89172. * @param convertToRightHandedSystem Converts the values to right-handed
  89173. */
  89174. private writeVertexAttributeData;
  89175. /**
  89176. * Writes mesh attribute data to a data buffer
  89177. * Returns the bytelength of the data
  89178. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  89179. * @param meshAttributeArray Array containing the attribute data
  89180. * @param byteStride Specifies the space between data
  89181. * @param binaryWriter The buffer to write the binary data to
  89182. * @param convertToRightHandedSystem Converts the values to right-handed
  89183. */
  89184. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  89185. /**
  89186. * Writes mesh attribute data to a data buffer
  89187. * Returns the bytelength of the data
  89188. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  89189. * @param meshAttributeArray Array containing the attribute data
  89190. * @param byteStride Specifies the space between data
  89191. * @param binaryWriter The buffer to write the binary data to
  89192. * @param convertToRightHandedSystem Converts the values to right-handed
  89193. */
  89194. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  89195. /**
  89196. * Generates glTF json data
  89197. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  89198. * @param glTFPrefix Text to use when prefixing a glTF file
  89199. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  89200. * @returns json data as string
  89201. */
  89202. private generateJSON;
  89203. /**
  89204. * Generates data for .gltf and .bin files based on the glTF prefix string
  89205. * @param glTFPrefix Text to use when prefixing a glTF file
  89206. * @param dispose Dispose the exporter
  89207. * @returns GLTFData with glTF file data
  89208. */
  89209. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  89210. /**
  89211. * Creates a binary buffer for glTF
  89212. * @returns array buffer for binary data
  89213. */
  89214. private _generateBinaryAsync;
  89215. /**
  89216. * Pads the number to a multiple of 4
  89217. * @param num number to pad
  89218. * @returns padded number
  89219. */
  89220. private _getPadding;
  89221. /**
  89222. * @hidden
  89223. */
  89224. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  89225. /**
  89226. * Sets the TRS for each node
  89227. * @param node glTF Node for storing the transformation data
  89228. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  89229. * @param convertToRightHandedSystem Converts the values to right-handed
  89230. */
  89231. private setNodeTransformation;
  89232. private getVertexBufferFromMesh;
  89233. /**
  89234. * Creates a bufferview based on the vertices type for the Babylon mesh
  89235. * @param kind Indicates the type of vertices data
  89236. * @param componentType Indicates the numerical type used to store the data
  89237. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  89238. * @param binaryWriter The buffer to write the bufferview data to
  89239. * @param convertToRightHandedSystem Converts the values to right-handed
  89240. */
  89241. private createBufferViewKind;
  89242. /**
  89243. * Creates a bufferview based on the vertices type for the Babylon mesh
  89244. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  89245. * @param babylonMorphTarget the morph target to be exported
  89246. * @param binaryWriter The buffer to write the bufferview data to
  89247. * @param convertToRightHandedSystem Converts the values to right-handed
  89248. */
  89249. private setMorphTargetAttributes;
  89250. /**
  89251. * The primitive mode of the Babylon mesh
  89252. * @param babylonMesh The BabylonJS mesh
  89253. */
  89254. private getMeshPrimitiveMode;
  89255. /**
  89256. * Sets the primitive mode of the glTF mesh primitive
  89257. * @param meshPrimitive glTF mesh primitive
  89258. * @param primitiveMode The primitive mode
  89259. */
  89260. private setPrimitiveMode;
  89261. /**
  89262. * Sets the vertex attribute accessor based of the glTF mesh primitive
  89263. * @param meshPrimitive glTF mesh primitive
  89264. * @param attributeKind vertex attribute
  89265. * @returns boolean specifying if uv coordinates are present
  89266. */
  89267. private setAttributeKind;
  89268. /**
  89269. * Sets data for the primitive attributes of each submesh
  89270. * @param mesh glTF Mesh object to store the primitive attribute information
  89271. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  89272. * @param binaryWriter Buffer to write the attribute data to
  89273. * @param convertToRightHandedSystem Converts the values to right-handed
  89274. */
  89275. private setPrimitiveAttributesAsync;
  89276. /**
  89277. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  89278. * @param node The node to check
  89279. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  89280. */
  89281. private isBabylonCoordinateSystemConvertingNode;
  89282. /**
  89283. * Creates a glTF scene based on the array of meshes
  89284. * Returns the the total byte offset
  89285. * @param babylonScene Babylon scene to get the mesh data from
  89286. * @param binaryWriter Buffer to write binary data to
  89287. */
  89288. private createSceneAsync;
  89289. /**
  89290. * Creates a mapping of Node unique id to node index and handles animations
  89291. * @param babylonScene Babylon Scene
  89292. * @param nodes Babylon transform nodes
  89293. * @param binaryWriter Buffer to write binary data to
  89294. * @returns Node mapping of unique id to index
  89295. */
  89296. private createNodeMapAndAnimationsAsync;
  89297. /**
  89298. * Creates a glTF node from a Babylon mesh
  89299. * @param babylonMesh Source Babylon mesh
  89300. * @param binaryWriter Buffer for storing geometry data
  89301. * @param convertToRightHandedSystem Converts the values to right-handed
  89302. * @param nodeMap Node mapping of unique id to glTF node index
  89303. * @returns glTF node
  89304. */
  89305. private createNodeAsync;
  89306. /**
  89307. * Creates a glTF skin from a Babylon skeleton
  89308. * @param babylonScene Babylon Scene
  89309. * @param nodes Babylon transform nodes
  89310. * @param binaryWriter Buffer to write binary data to
  89311. * @returns Node mapping of unique id to index
  89312. */
  89313. private createSkinsAsync;
  89314. }
  89315. /**
  89316. * @hidden
  89317. *
  89318. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  89319. */
  89320. export class _BinaryWriter {
  89321. /**
  89322. * Array buffer which stores all binary data
  89323. */
  89324. private _arrayBuffer;
  89325. /**
  89326. * View of the array buffer
  89327. */
  89328. private _dataView;
  89329. /**
  89330. * byte offset of data in array buffer
  89331. */
  89332. private _byteOffset;
  89333. /**
  89334. * Initialize binary writer with an initial byte length
  89335. * @param byteLength Initial byte length of the array buffer
  89336. */
  89337. constructor(byteLength: number);
  89338. /**
  89339. * Resize the array buffer to the specified byte length
  89340. * @param byteLength
  89341. */
  89342. private resizeBuffer;
  89343. /**
  89344. * Get an array buffer with the length of the byte offset
  89345. * @returns ArrayBuffer resized to the byte offset
  89346. */
  89347. getArrayBuffer(): ArrayBuffer;
  89348. /**
  89349. * Get the byte offset of the array buffer
  89350. * @returns byte offset
  89351. */
  89352. getByteOffset(): number;
  89353. /**
  89354. * Stores an UInt8 in the array buffer
  89355. * @param entry
  89356. * @param byteOffset If defined, specifies where to set the value as an offset.
  89357. */
  89358. setUInt8(entry: number, byteOffset?: number): void;
  89359. /**
  89360. * Stores an UInt16 in the array buffer
  89361. * @param entry
  89362. * @param byteOffset If defined, specifies where to set the value as an offset.
  89363. */
  89364. setUInt16(entry: number, byteOffset?: number): void;
  89365. /**
  89366. * Gets an UInt32 in the array buffer
  89367. * @param entry
  89368. * @param byteOffset If defined, specifies where to set the value as an offset.
  89369. */
  89370. getUInt32(byteOffset: number): number;
  89371. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  89372. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  89373. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  89374. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  89375. /**
  89376. * Stores a Float32 in the array buffer
  89377. * @param entry
  89378. */
  89379. setFloat32(entry: number, byteOffset?: number): void;
  89380. /**
  89381. * Stores an UInt32 in the array buffer
  89382. * @param entry
  89383. * @param byteOffset If defined, specifies where to set the value as an offset.
  89384. */
  89385. setUInt32(entry: number, byteOffset?: number): void;
  89386. }
  89387. }
  89388. declare module BABYLON.GLTF2.Exporter {
  89389. /**
  89390. * @hidden
  89391. * Interface to store animation data.
  89392. */
  89393. export interface _IAnimationData {
  89394. /**
  89395. * Keyframe data.
  89396. */
  89397. inputs: number[];
  89398. /**
  89399. * Value data.
  89400. */
  89401. outputs: number[][];
  89402. /**
  89403. * Animation interpolation data.
  89404. */
  89405. samplerInterpolation: AnimationSamplerInterpolation;
  89406. /**
  89407. * Minimum keyframe value.
  89408. */
  89409. inputsMin: number;
  89410. /**
  89411. * Maximum keyframe value.
  89412. */
  89413. inputsMax: number;
  89414. }
  89415. /**
  89416. * @hidden
  89417. */
  89418. export interface _IAnimationInfo {
  89419. /**
  89420. * The target channel for the animation
  89421. */
  89422. animationChannelTargetPath: AnimationChannelTargetPath;
  89423. /**
  89424. * The glTF accessor type for the data.
  89425. */
  89426. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  89427. /**
  89428. * Specifies if quaternions should be used.
  89429. */
  89430. useQuaternion: boolean;
  89431. }
  89432. /**
  89433. * @hidden
  89434. * Utility class for generating glTF animation data from BabylonJS.
  89435. */
  89436. export class _GLTFAnimation {
  89437. /**
  89438. * @ignore
  89439. *
  89440. * Creates glTF channel animation from BabylonJS animation.
  89441. * @param babylonTransformNode - BabylonJS mesh.
  89442. * @param animation - animation.
  89443. * @param animationChannelTargetPath - The target animation channel.
  89444. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  89445. * @param useQuaternion - Specifies if quaternions are used.
  89446. * @returns nullable IAnimationData
  89447. */
  89448. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  89449. private static _DeduceAnimationInfo;
  89450. /**
  89451. * @ignore
  89452. * Create node animations from the transform node animations
  89453. * @param babylonNode
  89454. * @param runtimeGLTFAnimation
  89455. * @param idleGLTFAnimations
  89456. * @param nodeMap
  89457. * @param nodes
  89458. * @param binaryWriter
  89459. * @param bufferViews
  89460. * @param accessors
  89461. * @param convertToRightHandedSystem
  89462. * @param animationSampleRate
  89463. */
  89464. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  89465. [key: number]: number;
  89466. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  89467. /**
  89468. * @ignore
  89469. * Create individual morph animations from the mesh's morph target animation tracks
  89470. * @param babylonNode
  89471. * @param runtimeGLTFAnimation
  89472. * @param idleGLTFAnimations
  89473. * @param nodeMap
  89474. * @param nodes
  89475. * @param binaryWriter
  89476. * @param bufferViews
  89477. * @param accessors
  89478. * @param convertToRightHandedSystem
  89479. * @param animationSampleRate
  89480. */
  89481. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  89482. [key: number]: number;
  89483. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  89484. /**
  89485. * @ignore
  89486. * Create node and morph animations from the animation groups
  89487. * @param babylonScene
  89488. * @param glTFAnimations
  89489. * @param nodeMap
  89490. * @param nodes
  89491. * @param binaryWriter
  89492. * @param bufferViews
  89493. * @param accessors
  89494. * @param convertToRightHandedSystemMap
  89495. * @param animationSampleRate
  89496. */
  89497. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  89498. [key: number]: number;
  89499. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  89500. [nodeId: number]: boolean;
  89501. }, animationSampleRate: number): void;
  89502. private static AddAnimation;
  89503. /**
  89504. * Create a baked animation
  89505. * @param babylonTransformNode BabylonJS mesh
  89506. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  89507. * @param animationChannelTargetPath animation target channel
  89508. * @param minFrame minimum animation frame
  89509. * @param maxFrame maximum animation frame
  89510. * @param fps frames per second of the animation
  89511. * @param inputs input key frames of the animation
  89512. * @param outputs output key frame data of the animation
  89513. * @param convertToRightHandedSystem converts the values to right-handed
  89514. * @param useQuaternion specifies if quaternions should be used
  89515. */
  89516. private static _CreateBakedAnimation;
  89517. private static _ConvertFactorToVector3OrQuaternion;
  89518. private static _SetInterpolatedValue;
  89519. /**
  89520. * Creates linear animation from the animation key frames
  89521. * @param babylonTransformNode BabylonJS mesh
  89522. * @param animation BabylonJS animation
  89523. * @param animationChannelTargetPath The target animation channel
  89524. * @param frameDelta The difference between the last and first frame of the animation
  89525. * @param inputs Array to store the key frame times
  89526. * @param outputs Array to store the key frame data
  89527. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  89528. * @param useQuaternion Specifies if quaternions are used in the animation
  89529. */
  89530. private static _CreateLinearOrStepAnimation;
  89531. /**
  89532. * Creates cubic spline animation from the animation key frames
  89533. * @param babylonTransformNode BabylonJS mesh
  89534. * @param animation BabylonJS animation
  89535. * @param animationChannelTargetPath The target animation channel
  89536. * @param frameDelta The difference between the last and first frame of the animation
  89537. * @param inputs Array to store the key frame times
  89538. * @param outputs Array to store the key frame data
  89539. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  89540. * @param useQuaternion Specifies if quaternions are used in the animation
  89541. */
  89542. private static _CreateCubicSplineAnimation;
  89543. private static _GetBasePositionRotationOrScale;
  89544. /**
  89545. * Adds a key frame value
  89546. * @param keyFrame
  89547. * @param animation
  89548. * @param outputs
  89549. * @param animationChannelTargetPath
  89550. * @param basePositionRotationOrScale
  89551. * @param convertToRightHandedSystem
  89552. * @param useQuaternion
  89553. */
  89554. private static _AddKeyframeValue;
  89555. /**
  89556. * Determine the interpolation based on the key frames
  89557. * @param keyFrames
  89558. * @param animationChannelTargetPath
  89559. * @param useQuaternion
  89560. */
  89561. private static _DeduceInterpolation;
  89562. /**
  89563. * Adds an input tangent or output tangent to the output data
  89564. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  89565. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  89566. * @param outputs The animation data by keyframe
  89567. * @param animationChannelTargetPath The target animation channel
  89568. * @param interpolation The interpolation type
  89569. * @param keyFrame The key frame with the animation data
  89570. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  89571. * @param useQuaternion Specifies if quaternions are used
  89572. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  89573. */
  89574. private static AddSplineTangent;
  89575. /**
  89576. * Get the minimum and maximum key frames' frame values
  89577. * @param keyFrames animation key frames
  89578. * @returns the minimum and maximum key frame value
  89579. */
  89580. private static calculateMinMaxKeyFrames;
  89581. }
  89582. }
  89583. declare module BABYLON.GLTF2.Exporter {
  89584. /** @hidden */
  89585. export var textureTransformPixelShader: {
  89586. name: string;
  89587. shader: string;
  89588. };
  89589. }
  89590. declare module BABYLON.GLTF2.Exporter.Extensions {
  89591. /**
  89592. * @hidden
  89593. */
  89594. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  89595. private _recordedTextures;
  89596. /** Name of this extension */
  89597. readonly name: string;
  89598. /** Defines whether this extension is enabled */
  89599. enabled: boolean;
  89600. /** Defines whether this extension is required */
  89601. required: boolean;
  89602. /** Reference to the glTF exporter */
  89603. private _wasUsed;
  89604. constructor(exporter: _Exporter);
  89605. dispose(): void;
  89606. /** @hidden */
  89607. get wasUsed(): boolean;
  89608. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  89609. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  89610. /**
  89611. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  89612. * @param babylonTexture
  89613. * @param offset
  89614. * @param rotation
  89615. * @param scale
  89616. * @param scene
  89617. */
  89618. private _textureTransformTextureAsync;
  89619. }
  89620. }
  89621. declare module BABYLON.GLTF2.Exporter.Extensions {
  89622. /**
  89623. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  89624. */
  89625. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  89626. /** The name of this extension. */
  89627. readonly name: string;
  89628. /** Defines whether this extension is enabled. */
  89629. enabled: boolean;
  89630. /** Defines whether this extension is required */
  89631. required: boolean;
  89632. /** Reference to the glTF exporter */
  89633. private _exporter;
  89634. private _lights;
  89635. /** @hidden */
  89636. constructor(exporter: _Exporter);
  89637. /** @hidden */
  89638. dispose(): void;
  89639. /** @hidden */
  89640. get wasUsed(): boolean;
  89641. /** @hidden */
  89642. onExporting(): void;
  89643. /**
  89644. * Define this method to modify the default behavior when exporting a node
  89645. * @param context The context when exporting the node
  89646. * @param node glTF node
  89647. * @param babylonNode BabylonJS node
  89648. * @param nodeMap Node mapping of unique id to glTF node index
  89649. * @returns nullable INode promise
  89650. */
  89651. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  89652. [key: number]: number;
  89653. }): Promise<Nullable<INode>>;
  89654. }
  89655. }
  89656. declare module BABYLON.GLTF2.Exporter.Extensions {
  89657. /**
  89658. * @hidden
  89659. */
  89660. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  89661. /** Name of this extension */
  89662. readonly name: string;
  89663. /** Defines whether this extension is enabled */
  89664. enabled: boolean;
  89665. /** Defines whether this extension is required */
  89666. required: boolean;
  89667. /** Reference to the glTF exporter */
  89668. private _textureInfos;
  89669. private _exportedTextures;
  89670. private _wasUsed;
  89671. constructor(exporter: _Exporter);
  89672. dispose(): void;
  89673. /** @hidden */
  89674. get wasUsed(): boolean;
  89675. private _getTextureIndex;
  89676. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  89677. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  89678. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  89679. }
  89680. }
  89681. declare module BABYLON.GLTF2.Exporter.Extensions {
  89682. /**
  89683. * @hidden
  89684. */
  89685. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  89686. /** Name of this extension */
  89687. readonly name: string;
  89688. /** Defines whether this extension is enabled */
  89689. enabled: boolean;
  89690. /** Defines whether this extension is required */
  89691. required: boolean;
  89692. private _wasUsed;
  89693. constructor(exporter: _Exporter);
  89694. /** @hidden */
  89695. get wasUsed(): boolean;
  89696. dispose(): void;
  89697. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  89698. }
  89699. }
  89700. declare module BABYLON {
  89701. /**
  89702. * Class for generating STL data from a Babylon scene.
  89703. */
  89704. export class STLExport {
  89705. /**
  89706. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  89707. * @param meshes list defines the mesh to serialize
  89708. * @param download triggers the automatic download of the file.
  89709. * @param fileName changes the downloads fileName.
  89710. * @param binary changes the STL to a binary type.
  89711. * @param isLittleEndian toggle for binary type exporter.
  89712. * @param doNotBakeTransform toggle if meshes transforms should be baked or not.
  89713. * @returns the STL as UTF8 string
  89714. */
  89715. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean, doNotBakeTransform?: boolean): any;
  89716. }
  89717. }
  89718. declare module "babylonjs-gltf2interface" {
  89719. export = BABYLON.GLTF2;
  89720. }
  89721. /**
  89722. * Module for glTF 2.0 Interface
  89723. */
  89724. declare module BABYLON.GLTF2 {
  89725. /**
  89726. * The datatype of the components in the attribute
  89727. */
  89728. const enum AccessorComponentType {
  89729. /**
  89730. * Byte
  89731. */
  89732. BYTE = 5120,
  89733. /**
  89734. * Unsigned Byte
  89735. */
  89736. UNSIGNED_BYTE = 5121,
  89737. /**
  89738. * Short
  89739. */
  89740. SHORT = 5122,
  89741. /**
  89742. * Unsigned Short
  89743. */
  89744. UNSIGNED_SHORT = 5123,
  89745. /**
  89746. * Unsigned Int
  89747. */
  89748. UNSIGNED_INT = 5125,
  89749. /**
  89750. * Float
  89751. */
  89752. FLOAT = 5126,
  89753. }
  89754. /**
  89755. * Specifies if the attirbute is a scalar, vector, or matrix
  89756. */
  89757. const enum AccessorType {
  89758. /**
  89759. * Scalar
  89760. */
  89761. SCALAR = "SCALAR",
  89762. /**
  89763. * Vector2
  89764. */
  89765. VEC2 = "VEC2",
  89766. /**
  89767. * Vector3
  89768. */
  89769. VEC3 = "VEC3",
  89770. /**
  89771. * Vector4
  89772. */
  89773. VEC4 = "VEC4",
  89774. /**
  89775. * Matrix2x2
  89776. */
  89777. MAT2 = "MAT2",
  89778. /**
  89779. * Matrix3x3
  89780. */
  89781. MAT3 = "MAT3",
  89782. /**
  89783. * Matrix4x4
  89784. */
  89785. MAT4 = "MAT4",
  89786. }
  89787. /**
  89788. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  89789. */
  89790. const enum AnimationChannelTargetPath {
  89791. /**
  89792. * Translation
  89793. */
  89794. TRANSLATION = "translation",
  89795. /**
  89796. * Rotation
  89797. */
  89798. ROTATION = "rotation",
  89799. /**
  89800. * Scale
  89801. */
  89802. SCALE = "scale",
  89803. /**
  89804. * Weights
  89805. */
  89806. WEIGHTS = "weights",
  89807. }
  89808. /**
  89809. * Interpolation algorithm
  89810. */
  89811. const enum AnimationSamplerInterpolation {
  89812. /**
  89813. * The animated values are linearly interpolated between keyframes
  89814. */
  89815. LINEAR = "LINEAR",
  89816. /**
  89817. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  89818. */
  89819. STEP = "STEP",
  89820. /**
  89821. * The animation's interpolation is computed using a cubic spline with specified tangents
  89822. */
  89823. CUBICSPLINE = "CUBICSPLINE",
  89824. }
  89825. /**
  89826. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  89827. */
  89828. const enum CameraType {
  89829. /**
  89830. * A perspective camera containing properties to create a perspective projection matrix
  89831. */
  89832. PERSPECTIVE = "perspective",
  89833. /**
  89834. * An orthographic camera containing properties to create an orthographic projection matrix
  89835. */
  89836. ORTHOGRAPHIC = "orthographic",
  89837. }
  89838. /**
  89839. * The mime-type of the image
  89840. */
  89841. const enum ImageMimeType {
  89842. /**
  89843. * JPEG Mime-type
  89844. */
  89845. JPEG = "image/jpeg",
  89846. /**
  89847. * PNG Mime-type
  89848. */
  89849. PNG = "image/png",
  89850. }
  89851. /**
  89852. * The alpha rendering mode of the material
  89853. */
  89854. const enum MaterialAlphaMode {
  89855. /**
  89856. * The alpha value is ignored and the rendered output is fully opaque
  89857. */
  89858. OPAQUE = "OPAQUE",
  89859. /**
  89860. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  89861. */
  89862. MASK = "MASK",
  89863. /**
  89864. * 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)
  89865. */
  89866. BLEND = "BLEND",
  89867. }
  89868. /**
  89869. * The type of the primitives to render
  89870. */
  89871. const enum MeshPrimitiveMode {
  89872. /**
  89873. * Points
  89874. */
  89875. POINTS = 0,
  89876. /**
  89877. * Lines
  89878. */
  89879. LINES = 1,
  89880. /**
  89881. * Line Loop
  89882. */
  89883. LINE_LOOP = 2,
  89884. /**
  89885. * Line Strip
  89886. */
  89887. LINE_STRIP = 3,
  89888. /**
  89889. * Triangles
  89890. */
  89891. TRIANGLES = 4,
  89892. /**
  89893. * Triangle Strip
  89894. */
  89895. TRIANGLE_STRIP = 5,
  89896. /**
  89897. * Triangle Fan
  89898. */
  89899. TRIANGLE_FAN = 6,
  89900. }
  89901. /**
  89902. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  89903. */
  89904. const enum TextureMagFilter {
  89905. /**
  89906. * Nearest
  89907. */
  89908. NEAREST = 9728,
  89909. /**
  89910. * Linear
  89911. */
  89912. LINEAR = 9729,
  89913. }
  89914. /**
  89915. * Minification filter. All valid values correspond to WebGL enums
  89916. */
  89917. const enum TextureMinFilter {
  89918. /**
  89919. * Nearest
  89920. */
  89921. NEAREST = 9728,
  89922. /**
  89923. * Linear
  89924. */
  89925. LINEAR = 9729,
  89926. /**
  89927. * Nearest Mip-Map Nearest
  89928. */
  89929. NEAREST_MIPMAP_NEAREST = 9984,
  89930. /**
  89931. * Linear Mipmap Nearest
  89932. */
  89933. LINEAR_MIPMAP_NEAREST = 9985,
  89934. /**
  89935. * Nearest Mipmap Linear
  89936. */
  89937. NEAREST_MIPMAP_LINEAR = 9986,
  89938. /**
  89939. * Linear Mipmap Linear
  89940. */
  89941. LINEAR_MIPMAP_LINEAR = 9987,
  89942. }
  89943. /**
  89944. * S (U) wrapping mode. All valid values correspond to WebGL enums
  89945. */
  89946. const enum TextureWrapMode {
  89947. /**
  89948. * Clamp to Edge
  89949. */
  89950. CLAMP_TO_EDGE = 33071,
  89951. /**
  89952. * Mirrored Repeat
  89953. */
  89954. MIRRORED_REPEAT = 33648,
  89955. /**
  89956. * Repeat
  89957. */
  89958. REPEAT = 10497,
  89959. }
  89960. /**
  89961. * glTF Property
  89962. */
  89963. interface IProperty {
  89964. /**
  89965. * Dictionary object with extension-specific objects
  89966. */
  89967. extensions?: {
  89968. [key: string]: any;
  89969. };
  89970. /**
  89971. * Application-Specific data
  89972. */
  89973. extras?: any;
  89974. }
  89975. /**
  89976. * glTF Child of Root Property
  89977. */
  89978. interface IChildRootProperty extends IProperty {
  89979. /**
  89980. * The user-defined name of this object
  89981. */
  89982. name?: string;
  89983. }
  89984. /**
  89985. * Indices of those attributes that deviate from their initialization value
  89986. */
  89987. interface IAccessorSparseIndices extends IProperty {
  89988. /**
  89989. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  89990. */
  89991. bufferView: number;
  89992. /**
  89993. * The offset relative to the start of the bufferView in bytes. Must be aligned
  89994. */
  89995. byteOffset?: number;
  89996. /**
  89997. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  89998. */
  89999. componentType: AccessorComponentType;
  90000. }
  90001. /**
  90002. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  90003. */
  90004. interface IAccessorSparseValues extends IProperty {
  90005. /**
  90006. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  90007. */
  90008. bufferView: number;
  90009. /**
  90010. * The offset relative to the start of the bufferView in bytes. Must be aligned
  90011. */
  90012. byteOffset?: number;
  90013. }
  90014. /**
  90015. * Sparse storage of attributes that deviate from their initialization value
  90016. */
  90017. interface IAccessorSparse extends IProperty {
  90018. /**
  90019. * The number of attributes encoded in this sparse accessor
  90020. */
  90021. count: number;
  90022. /**
  90023. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  90024. */
  90025. indices: IAccessorSparseIndices;
  90026. /**
  90027. * 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
  90028. */
  90029. values: IAccessorSparseValues;
  90030. }
  90031. /**
  90032. * 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
  90033. */
  90034. interface IAccessor extends IChildRootProperty {
  90035. /**
  90036. * The index of the bufferview
  90037. */
  90038. bufferView?: number;
  90039. /**
  90040. * The offset relative to the start of the bufferView in bytes
  90041. */
  90042. byteOffset?: number;
  90043. /**
  90044. * The datatype of components in the attribute
  90045. */
  90046. componentType: AccessorComponentType;
  90047. /**
  90048. * Specifies whether integer data values should be normalized
  90049. */
  90050. normalized?: boolean;
  90051. /**
  90052. * The number of attributes referenced by this accessor
  90053. */
  90054. count: number;
  90055. /**
  90056. * Specifies if the attribute is a scalar, vector, or matrix
  90057. */
  90058. type: AccessorType;
  90059. /**
  90060. * Maximum value of each component in this attribute
  90061. */
  90062. max?: number[];
  90063. /**
  90064. * Minimum value of each component in this attribute
  90065. */
  90066. min?: number[];
  90067. /**
  90068. * Sparse storage of attributes that deviate from their initialization value
  90069. */
  90070. sparse?: IAccessorSparse;
  90071. }
  90072. /**
  90073. * Targets an animation's sampler at a node's property
  90074. */
  90075. interface IAnimationChannel extends IProperty {
  90076. /**
  90077. * The index of a sampler in this animation used to compute the value for the target
  90078. */
  90079. sampler: number;
  90080. /**
  90081. * The index of the node and TRS property to target
  90082. */
  90083. target: IAnimationChannelTarget;
  90084. }
  90085. /**
  90086. * The index of the node and TRS property that an animation channel targets
  90087. */
  90088. interface IAnimationChannelTarget extends IProperty {
  90089. /**
  90090. * The index of the node to target
  90091. */
  90092. node: number;
  90093. /**
  90094. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  90095. */
  90096. path: AnimationChannelTargetPath;
  90097. }
  90098. /**
  90099. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  90100. */
  90101. interface IAnimationSampler extends IProperty {
  90102. /**
  90103. * The index of an accessor containing keyframe input values, e.g., time
  90104. */
  90105. input: number;
  90106. /**
  90107. * Interpolation algorithm
  90108. */
  90109. interpolation?: AnimationSamplerInterpolation;
  90110. /**
  90111. * The index of an accessor, containing keyframe output values
  90112. */
  90113. output: number;
  90114. }
  90115. /**
  90116. * A keyframe animation
  90117. */
  90118. interface IAnimation extends IChildRootProperty {
  90119. /**
  90120. * An array of channels, each of which targets an animation's sampler at a node's property
  90121. */
  90122. channels: IAnimationChannel[];
  90123. /**
  90124. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  90125. */
  90126. samplers: IAnimationSampler[];
  90127. }
  90128. /**
  90129. * Metadata about the glTF asset
  90130. */
  90131. interface IAsset extends IChildRootProperty {
  90132. /**
  90133. * A copyright message suitable for display to credit the content creator
  90134. */
  90135. copyright?: string;
  90136. /**
  90137. * Tool that generated this glTF model. Useful for debugging
  90138. */
  90139. generator?: string;
  90140. /**
  90141. * The glTF version that this asset targets
  90142. */
  90143. version: string;
  90144. /**
  90145. * The minimum glTF version that this asset targets
  90146. */
  90147. minVersion?: string;
  90148. }
  90149. /**
  90150. * A buffer points to binary geometry, animation, or skins
  90151. */
  90152. interface IBuffer extends IChildRootProperty {
  90153. /**
  90154. * 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
  90155. */
  90156. uri?: string;
  90157. /**
  90158. * The length of the buffer in bytes
  90159. */
  90160. byteLength: number;
  90161. }
  90162. /**
  90163. * A view into a buffer generally representing a subset of the buffer
  90164. */
  90165. interface IBufferView extends IChildRootProperty {
  90166. /**
  90167. * The index of the buffer
  90168. */
  90169. buffer: number;
  90170. /**
  90171. * The offset into the buffer in bytes
  90172. */
  90173. byteOffset?: number;
  90174. /**
  90175. * The lenth of the bufferView in bytes
  90176. */
  90177. byteLength: number;
  90178. /**
  90179. * The stride, in bytes
  90180. */
  90181. byteStride?: number;
  90182. }
  90183. /**
  90184. * An orthographic camera containing properties to create an orthographic projection matrix
  90185. */
  90186. interface ICameraOrthographic extends IProperty {
  90187. /**
  90188. * The floating-point horizontal magnification of the view. Must not be zero
  90189. */
  90190. xmag: number;
  90191. /**
  90192. * The floating-point vertical magnification of the view. Must not be zero
  90193. */
  90194. ymag: number;
  90195. /**
  90196. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  90197. */
  90198. zfar: number;
  90199. /**
  90200. * The floating-point distance to the near clipping plane
  90201. */
  90202. znear: number;
  90203. }
  90204. /**
  90205. * A perspective camera containing properties to create a perspective projection matrix
  90206. */
  90207. interface ICameraPerspective extends IProperty {
  90208. /**
  90209. * The floating-point aspect ratio of the field of view
  90210. */
  90211. aspectRatio?: number;
  90212. /**
  90213. * The floating-point vertical field of view in radians
  90214. */
  90215. yfov: number;
  90216. /**
  90217. * The floating-point distance to the far clipping plane
  90218. */
  90219. zfar?: number;
  90220. /**
  90221. * The floating-point distance to the near clipping plane
  90222. */
  90223. znear: number;
  90224. }
  90225. /**
  90226. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  90227. */
  90228. interface ICamera extends IChildRootProperty {
  90229. /**
  90230. * An orthographic camera containing properties to create an orthographic projection matrix
  90231. */
  90232. orthographic?: ICameraOrthographic;
  90233. /**
  90234. * A perspective camera containing properties to create a perspective projection matrix
  90235. */
  90236. perspective?: ICameraPerspective;
  90237. /**
  90238. * Specifies if the camera uses a perspective or orthographic projection
  90239. */
  90240. type: CameraType;
  90241. }
  90242. /**
  90243. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  90244. */
  90245. interface IImage extends IChildRootProperty {
  90246. /**
  90247. * 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
  90248. */
  90249. uri?: string;
  90250. /**
  90251. * The image's MIME type
  90252. */
  90253. mimeType?: ImageMimeType;
  90254. /**
  90255. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  90256. */
  90257. bufferView?: number;
  90258. }
  90259. /**
  90260. * Material Normal Texture Info
  90261. */
  90262. interface IMaterialNormalTextureInfo extends ITextureInfo {
  90263. /**
  90264. * The scalar multiplier applied to each normal vector of the normal texture
  90265. */
  90266. scale?: number;
  90267. }
  90268. /**
  90269. * Material Occlusion Texture Info
  90270. */
  90271. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  90272. /**
  90273. * A scalar multiplier controlling the amount of occlusion applied
  90274. */
  90275. strength?: number;
  90276. }
  90277. /**
  90278. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  90279. */
  90280. interface IMaterialPbrMetallicRoughness {
  90281. /**
  90282. * The material's base color factor
  90283. */
  90284. baseColorFactor?: number[];
  90285. /**
  90286. * The base color texture
  90287. */
  90288. baseColorTexture?: ITextureInfo;
  90289. /**
  90290. * The metalness of the material
  90291. */
  90292. metallicFactor?: number;
  90293. /**
  90294. * The roughness of the material
  90295. */
  90296. roughnessFactor?: number;
  90297. /**
  90298. * The metallic-roughness texture
  90299. */
  90300. metallicRoughnessTexture?: ITextureInfo;
  90301. }
  90302. /**
  90303. * The material appearance of a primitive
  90304. */
  90305. interface IMaterial extends IChildRootProperty {
  90306. /**
  90307. * 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
  90308. */
  90309. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  90310. /**
  90311. * The normal map texture
  90312. */
  90313. normalTexture?: IMaterialNormalTextureInfo;
  90314. /**
  90315. * The occlusion map texture
  90316. */
  90317. occlusionTexture?: IMaterialOcclusionTextureInfo;
  90318. /**
  90319. * The emissive map texture
  90320. */
  90321. emissiveTexture?: ITextureInfo;
  90322. /**
  90323. * 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
  90324. */
  90325. emissiveFactor?: number[];
  90326. /**
  90327. * The alpha rendering mode of the material
  90328. */
  90329. alphaMode?: MaterialAlphaMode;
  90330. /**
  90331. * The alpha cutoff value of the material
  90332. */
  90333. alphaCutoff?: number;
  90334. /**
  90335. * Specifies whether the material is double sided
  90336. */
  90337. doubleSided?: boolean;
  90338. }
  90339. /**
  90340. * Geometry to be rendered with the given material
  90341. */
  90342. interface IMeshPrimitive extends IProperty {
  90343. /**
  90344. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  90345. */
  90346. attributes: {
  90347. [name: string]: number;
  90348. };
  90349. /**
  90350. * The index of the accessor that contains the indices
  90351. */
  90352. indices?: number;
  90353. /**
  90354. * The index of the material to apply to this primitive when rendering
  90355. */
  90356. material?: number;
  90357. /**
  90358. * The type of primitives to render. All valid values correspond to WebGL enums
  90359. */
  90360. mode?: MeshPrimitiveMode;
  90361. /**
  90362. * 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
  90363. */
  90364. targets?: {
  90365. [name: string]: number;
  90366. }[];
  90367. }
  90368. /**
  90369. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  90370. */
  90371. interface IMesh extends IChildRootProperty {
  90372. /**
  90373. * An array of primitives, each defining geometry to be rendered with a material
  90374. */
  90375. primitives: IMeshPrimitive[];
  90376. /**
  90377. * Array of weights to be applied to the Morph Targets
  90378. */
  90379. weights?: number[];
  90380. }
  90381. /**
  90382. * A node in the node hierarchy
  90383. */
  90384. interface INode extends IChildRootProperty {
  90385. /**
  90386. * The index of the camera referenced by this node
  90387. */
  90388. camera?: number;
  90389. /**
  90390. * The indices of this node's children
  90391. */
  90392. children?: number[];
  90393. /**
  90394. * The index of the skin referenced by this node
  90395. */
  90396. skin?: number;
  90397. /**
  90398. * A floating-point 4x4 transformation matrix stored in column-major order
  90399. */
  90400. matrix?: number[];
  90401. /**
  90402. * The index of the mesh in this node
  90403. */
  90404. mesh?: number;
  90405. /**
  90406. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  90407. */
  90408. rotation?: number[];
  90409. /**
  90410. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  90411. */
  90412. scale?: number[];
  90413. /**
  90414. * The node's translation along the x, y, and z axes
  90415. */
  90416. translation?: number[];
  90417. /**
  90418. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  90419. */
  90420. weights?: number[];
  90421. }
  90422. /**
  90423. * Texture sampler properties for filtering and wrapping modes
  90424. */
  90425. interface ISampler extends IChildRootProperty {
  90426. /**
  90427. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  90428. */
  90429. magFilter?: TextureMagFilter;
  90430. /**
  90431. * Minification filter. All valid values correspond to WebGL enums
  90432. */
  90433. minFilter?: TextureMinFilter;
  90434. /**
  90435. * S (U) wrapping mode. All valid values correspond to WebGL enums
  90436. */
  90437. wrapS?: TextureWrapMode;
  90438. /**
  90439. * T (V) wrapping mode. All valid values correspond to WebGL enums
  90440. */
  90441. wrapT?: TextureWrapMode;
  90442. }
  90443. /**
  90444. * The root nodes of a scene
  90445. */
  90446. interface IScene extends IChildRootProperty {
  90447. /**
  90448. * The indices of each root node
  90449. */
  90450. nodes: number[];
  90451. }
  90452. /**
  90453. * Joints and matrices defining a skin
  90454. */
  90455. interface ISkin extends IChildRootProperty {
  90456. /**
  90457. * 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
  90458. */
  90459. inverseBindMatrices?: number;
  90460. /**
  90461. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  90462. */
  90463. skeleton?: number;
  90464. /**
  90465. * 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)
  90466. */
  90467. joints: number[];
  90468. }
  90469. /**
  90470. * A texture and its sampler
  90471. */
  90472. interface ITexture extends IChildRootProperty {
  90473. /**
  90474. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  90475. */
  90476. sampler?: number;
  90477. /**
  90478. * The index of the image used by this texture
  90479. */
  90480. source: number;
  90481. }
  90482. /**
  90483. * Reference to a texture
  90484. */
  90485. interface ITextureInfo extends IProperty {
  90486. /**
  90487. * The index of the texture
  90488. */
  90489. index: number;
  90490. /**
  90491. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  90492. */
  90493. texCoord?: number;
  90494. }
  90495. /**
  90496. * The root object for a glTF asset
  90497. */
  90498. interface IGLTF extends IProperty {
  90499. /**
  90500. * An array of accessors. An accessor is a typed view into a bufferView
  90501. */
  90502. accessors?: IAccessor[];
  90503. /**
  90504. * An array of keyframe animations
  90505. */
  90506. animations?: IAnimation[];
  90507. /**
  90508. * Metadata about the glTF asset
  90509. */
  90510. asset: IAsset;
  90511. /**
  90512. * An array of buffers. A buffer points to binary geometry, animation, or skins
  90513. */
  90514. buffers?: IBuffer[];
  90515. /**
  90516. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  90517. */
  90518. bufferViews?: IBufferView[];
  90519. /**
  90520. * An array of cameras
  90521. */
  90522. cameras?: ICamera[];
  90523. /**
  90524. * Names of glTF extensions used somewhere in this asset
  90525. */
  90526. extensionsUsed?: string[];
  90527. /**
  90528. * Names of glTF extensions required to properly load this asset
  90529. */
  90530. extensionsRequired?: string[];
  90531. /**
  90532. * An array of images. An image defines data used to create a texture
  90533. */
  90534. images?: IImage[];
  90535. /**
  90536. * An array of materials. A material defines the appearance of a primitive
  90537. */
  90538. materials?: IMaterial[];
  90539. /**
  90540. * An array of meshes. A mesh is a set of primitives to be rendered
  90541. */
  90542. meshes?: IMesh[];
  90543. /**
  90544. * An array of nodes
  90545. */
  90546. nodes?: INode[];
  90547. /**
  90548. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  90549. */
  90550. samplers?: ISampler[];
  90551. /**
  90552. * The index of the default scene
  90553. */
  90554. scene?: number;
  90555. /**
  90556. * An array of scenes
  90557. */
  90558. scenes?: IScene[];
  90559. /**
  90560. * An array of skins. A skin is defined by joints and matrices
  90561. */
  90562. skins?: ISkin[];
  90563. /**
  90564. * An array of textures
  90565. */
  90566. textures?: ITexture[];
  90567. }
  90568. /**
  90569. * The glTF validation results
  90570. * @ignore
  90571. */
  90572. interface IGLTFValidationResults {
  90573. info: {
  90574. generator: string;
  90575. hasAnimations: boolean;
  90576. hasDefaultScene: boolean;
  90577. hasMaterials: boolean;
  90578. hasMorphTargets: boolean;
  90579. hasSkins: boolean;
  90580. hasTextures: boolean;
  90581. maxAttributesUsed: number;
  90582. primitivesCount: number
  90583. };
  90584. issues: {
  90585. messages: Array<string>;
  90586. numErrors: number;
  90587. numHints: number;
  90588. numInfos: number;
  90589. numWarnings: number;
  90590. truncated: boolean
  90591. };
  90592. mimeType: string;
  90593. uri: string;
  90594. validatedAt: string;
  90595. validatorVersion: string;
  90596. }
  90597. /**
  90598. * The glTF validation options
  90599. */
  90600. interface IGLTFValidationOptions {
  90601. /** Uri to use */
  90602. uri?: string;
  90603. /** Function used to load external resources */
  90604. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  90605. /** Boolean indicating that we need to validate accessor data */
  90606. validateAccessorData?: boolean;
  90607. /** max number of issues allowed */
  90608. maxIssues?: number;
  90609. /** Ignored issues */
  90610. ignoredIssues?: Array<string>;
  90611. /** Value to override severy settings */
  90612. severityOverrides?: Object;
  90613. }
  90614. /**
  90615. * The glTF validator object
  90616. * @ignore
  90617. */
  90618. interface IGLTFValidator {
  90619. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  90620. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  90621. }
  90622. /**
  90623. * Interfaces from the EXT_lights_image_based extension
  90624. */
  90625. /** @hidden */
  90626. interface IEXTLightsImageBased_LightReferenceImageBased {
  90627. light: number;
  90628. }
  90629. /** @hidden */
  90630. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  90631. intensity: number;
  90632. rotation: number[];
  90633. specularImageSize: number;
  90634. specularImages: number[][];
  90635. irradianceCoefficients: number[][];
  90636. }
  90637. /** @hidden */
  90638. interface IEXTLightsImageBased {
  90639. lights: IEXTLightsImageBased_LightImageBased[];
  90640. }
  90641. /**
  90642. * Interfaces from the EXT_mesh_gpu_instancing extension
  90643. * !!! Experimental Extension Subject to Changes !!!
  90644. */
  90645. /** @hidden */
  90646. interface IEXTMeshGpuInstancing {
  90647. mesh?: number;
  90648. attributes: { [name: string]: number };
  90649. }
  90650. /**
  90651. * Interfaces from the KHR_draco_mesh_compression extension
  90652. */
  90653. /** @hidden */
  90654. interface IKHRDracoMeshCompression {
  90655. bufferView: number;
  90656. attributes: { [name: string]: number };
  90657. }
  90658. /**
  90659. * Interfaces from the KHR_lights_punctual extension
  90660. */
  90661. /** @hidden */
  90662. const enum IKHRLightsPunctual_LightType {
  90663. DIRECTIONAL = "directional",
  90664. POINT = "point",
  90665. SPOT = "spot"
  90666. }
  90667. /** @hidden */
  90668. interface IKHRLightsPunctual_LightReference {
  90669. light: number;
  90670. }
  90671. /** @hidden */
  90672. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  90673. type: IKHRLightsPunctual_LightType;
  90674. color?: number[];
  90675. intensity?: number;
  90676. range?: number;
  90677. spot?: {
  90678. innerConeAngle?: number;
  90679. outerConeAngle?: number;
  90680. };
  90681. }
  90682. /** @hidden */
  90683. interface IKHRLightsPunctual {
  90684. lights: IKHRLightsPunctual_Light[];
  90685. }
  90686. /**
  90687. * Interfaces from the KHR_materials_clearcoat extension
  90688. * !!! Experimental Extension Subject to Changes !!!
  90689. */
  90690. /** @hidden */
  90691. interface IKHRMaterialsClearcoat {
  90692. clearcoatFactor: number;
  90693. clearcoatTexture: ITextureInfo;
  90694. clearcoatRoughnessFactor: number;
  90695. clearcoatRoughnessTexture: ITextureInfo;
  90696. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  90697. }
  90698. /**
  90699. * Interfaces from the KHR_materials_ior extension
  90700. * !!! Experimental Extension Subject to Changes !!!
  90701. */
  90702. /** @hidden */
  90703. interface IKHRMaterialsIor {
  90704. ior: number;
  90705. }
  90706. /**
  90707. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  90708. */
  90709. /** @hidden */
  90710. interface IKHRMaterialsPbrSpecularGlossiness {
  90711. diffuseFactor: number[];
  90712. diffuseTexture: ITextureInfo;
  90713. specularFactor: number[];
  90714. glossinessFactor: number;
  90715. specularGlossinessTexture: ITextureInfo;
  90716. }
  90717. /**
  90718. * Interfaces from the KHR_materials_sheen extension
  90719. * !!! Experimental Extension Subject to Changes !!!
  90720. */
  90721. /** @hidden */
  90722. interface IKHRMaterialsSheen {
  90723. sheenColorFactor?: number[];
  90724. sheenColorTexture?: ITextureInfo;
  90725. sheenRoughnessFactor?: number;
  90726. sheenRoughnessTexture?: ITextureInfo;
  90727. }
  90728. /**
  90729. * Interfaces from the KHR_materials_specular extension
  90730. * !!! Experimental Extension Subject to Changes !!!
  90731. */
  90732. /** @hidden */
  90733. interface IKHRMaterialsSpecular {
  90734. specularFactor: number;
  90735. specularColorFactor: number[];
  90736. specularTexture: ITextureInfo;
  90737. }
  90738. /**
  90739. * Interfaces from the KHR_materials_transmission extension
  90740. * !!! Experimental Extension Subject to Changes !!!
  90741. */
  90742. /** @hidden */
  90743. interface IKHRMaterialsTransmission {
  90744. transmissionFactor?: number;
  90745. transmissionTexture?: ITextureInfo;
  90746. }
  90747. /**
  90748. * Interfaces from the KHR_materials_translucency extension
  90749. * !!! Experimental Extension Subject to Changes !!!
  90750. */
  90751. /** @hidden */
  90752. interface IKHRMaterialsTranslucency {
  90753. translucencyFactor?: number;
  90754. translucencyTexture?: ITextureInfo;
  90755. }
  90756. /**
  90757. * Interfaces from the KHR_materials_variants extension
  90758. * !!! Experimental Extension Subject to Changes !!!
  90759. */
  90760. /** @hidden */
  90761. interface IKHRMaterialVariants_Mapping extends IProperty {
  90762. mappings: Array<{
  90763. variants: number[];
  90764. material: number;
  90765. }>;
  90766. }
  90767. /** @hidden */
  90768. interface IKHRMaterialVariants_Variant extends IProperty {
  90769. name: string;
  90770. }
  90771. /** @hidden */
  90772. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  90773. variants: Array<IKHRMaterialVariants_Variant>;
  90774. }
  90775. /**
  90776. * Interfaces from the KHR_texture_basisu extension
  90777. * !!! Experimental Extension Subject to Changes !!!
  90778. */
  90779. /** @hidden */
  90780. interface IKHRTextureBasisU {
  90781. source: number;
  90782. }
  90783. /**
  90784. * Interfaces from the EXT_texture_webp extension
  90785. */
  90786. /** @hidden */
  90787. interface IEXTTextureWebP {
  90788. source: number;
  90789. }
  90790. /**
  90791. * Interfaces from the KHR_texture_transform extension
  90792. */
  90793. /** @hidden */
  90794. interface IKHRTextureTransform {
  90795. offset?: number[];
  90796. rotation?: number;
  90797. scale?: number[];
  90798. texCoord?: number;
  90799. }
  90800. /**
  90801. * Interfaces from the KHR_xmp extension
  90802. * !!! Experimental Extension Subject to Changes !!!
  90803. */
  90804. /** @hidden */
  90805. interface IKHRXmp_Data {
  90806. [key: string]: unknown;
  90807. }
  90808. /** @hidden */
  90809. interface IKHRXmp_Gltf {
  90810. packets: IKHRXmp_Data[];
  90811. }
  90812. /** @hidden */
  90813. interface IKHRXmp_Node {
  90814. packet: number;
  90815. }
  90816. /**
  90817. * Interfaces from the MSFT_audio_emitter extension
  90818. */
  90819. /** @hidden */
  90820. interface IMSFTAudioEmitter_ClipReference {
  90821. clip: number;
  90822. weight?: number;
  90823. }
  90824. /** @hidden */
  90825. interface IMSFTAudioEmitter_EmittersReference {
  90826. emitters: number[];
  90827. }
  90828. /** @hidden */
  90829. const enum IMSFTAudioEmitter_DistanceModel {
  90830. linear = "linear",
  90831. inverse = "inverse",
  90832. exponential = "exponential",
  90833. }
  90834. /** @hidden */
  90835. interface IMSFTAudioEmitter_Emitter {
  90836. name?: string;
  90837. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  90838. refDistance?: number;
  90839. maxDistance?: number;
  90840. rolloffFactor?: number;
  90841. innerAngle?: number;
  90842. outerAngle?: number;
  90843. loop?: boolean;
  90844. volume?: number;
  90845. clips: IMSFTAudioEmitter_ClipReference[];
  90846. }
  90847. /** @hidden */
  90848. const enum IMSFTAudioEmitter_AudioMimeType {
  90849. WAV = "audio/wav",
  90850. }
  90851. /** @hidden */
  90852. interface IMSFTAudioEmitter_Clip extends IProperty {
  90853. uri?: string;
  90854. bufferView?: number;
  90855. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  90856. }
  90857. /** @hidden */
  90858. const enum IMSFTAudioEmitter_AnimationEventAction {
  90859. play = "play",
  90860. pause = "pause",
  90861. stop = "stop",
  90862. }
  90863. /** @hidden */
  90864. interface IMSFTAudioEmitter_AnimationEvent {
  90865. action: IMSFTAudioEmitter_AnimationEventAction;
  90866. emitter: number;
  90867. time: number;
  90868. startOffset?: number;
  90869. }
  90870. /**
  90871. * Interfaces from the MSFT_lod extension
  90872. */
  90873. /** @hidden */
  90874. interface IMSFTLOD {
  90875. ids: number[];
  90876. }
  90877. /**
  90878. * Interfaces from the EXT_meshopt_compression extension
  90879. */
  90880. /** @hidden */
  90881. interface IEXTMeshoptCompression {
  90882. buffer: number;
  90883. byteOffset?: number;
  90884. byteLength: number;
  90885. byteStride: number;
  90886. count: number;
  90887. mode: "ATTRIBUTES" | "TRIANGLES" | "INDICES";
  90888. filter?: "NONE" | "OCTAHEDRAL" | "QUATERNION" | "EXPONENTIAL";
  90889. }
  90890. }
  90891. declare module BABYLON {
  90892. /** @hidden */
  90893. export var cellPixelShader: {
  90894. name: string;
  90895. shader: string;
  90896. };
  90897. }
  90898. declare module BABYLON {
  90899. /** @hidden */
  90900. export var cellVertexShader: {
  90901. name: string;
  90902. shader: string;
  90903. };
  90904. }
  90905. declare module BABYLON {
  90906. export class CellMaterial extends BABYLON.PushMaterial {
  90907. private _diffuseTexture;
  90908. diffuseTexture: BABYLON.BaseTexture;
  90909. diffuseColor: BABYLON.Color3;
  90910. _computeHighLevel: boolean;
  90911. computeHighLevel: boolean;
  90912. private _disableLighting;
  90913. disableLighting: boolean;
  90914. private _maxSimultaneousLights;
  90915. maxSimultaneousLights: number;
  90916. constructor(name: string, scene: BABYLON.Scene);
  90917. needAlphaBlending(): boolean;
  90918. needAlphaTesting(): boolean;
  90919. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  90920. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  90921. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  90922. getAnimatables(): BABYLON.IAnimatable[];
  90923. getActiveTextures(): BABYLON.BaseTexture[];
  90924. hasTexture(texture: BABYLON.BaseTexture): boolean;
  90925. dispose(forceDisposeEffect?: boolean): void;
  90926. getClassName(): string;
  90927. clone(name: string): CellMaterial;
  90928. serialize(): any;
  90929. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  90930. }
  90931. }
  90932. declare module BABYLON {
  90933. export class CustomShaderStructure {
  90934. FragmentStore: string;
  90935. VertexStore: string;
  90936. constructor();
  90937. }
  90938. export class ShaderSpecialParts {
  90939. constructor();
  90940. Fragment_Begin: string;
  90941. Fragment_Definitions: string;
  90942. Fragment_MainBegin: string;
  90943. Fragment_Custom_Diffuse: string;
  90944. Fragment_Before_Lights: string;
  90945. Fragment_Before_Fog: string;
  90946. Fragment_Custom_Alpha: string;
  90947. Fragment_Before_FragColor: string;
  90948. Vertex_Begin: string;
  90949. Vertex_Definitions: string;
  90950. Vertex_MainBegin: string;
  90951. Vertex_Before_PositionUpdated: string;
  90952. Vertex_Before_NormalUpdated: string;
  90953. Vertex_After_WorldPosComputed: string;
  90954. Vertex_MainEnd: string;
  90955. }
  90956. export class CustomMaterial extends BABYLON.StandardMaterial {
  90957. static ShaderIndexer: number;
  90958. CustomParts: ShaderSpecialParts;
  90959. _isCreatedShader: boolean;
  90960. _createdShaderName: string;
  90961. _customUniform: string[];
  90962. _newUniforms: string[];
  90963. _newUniformInstances: {
  90964. [name: string]: any;
  90965. };
  90966. _newSamplerInstances: {
  90967. [name: string]: BABYLON.Texture;
  90968. };
  90969. _customAttributes: string[];
  90970. FragmentShader: string;
  90971. VertexShader: string;
  90972. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  90973. ReviewUniform(name: string, arr: string[]): string[];
  90974. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  90975. constructor(name: string, scene: BABYLON.Scene);
  90976. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  90977. AddAttribute(name: string): CustomMaterial;
  90978. Fragment_Begin(shaderPart: string): CustomMaterial;
  90979. Fragment_Definitions(shaderPart: string): CustomMaterial;
  90980. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  90981. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  90982. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  90983. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  90984. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  90985. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  90986. Vertex_Begin(shaderPart: string): CustomMaterial;
  90987. Vertex_Definitions(shaderPart: string): CustomMaterial;
  90988. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  90989. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  90990. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  90991. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  90992. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  90993. }
  90994. }
  90995. declare module BABYLON {
  90996. export class ShaderAlebdoParts {
  90997. constructor();
  90998. Fragment_Begin: string;
  90999. Fragment_Definitions: string;
  91000. Fragment_MainBegin: string;
  91001. Fragment_Custom_Albedo: string;
  91002. Fragment_Before_Lights: string;
  91003. Fragment_Custom_MetallicRoughness: string;
  91004. Fragment_Custom_MicroSurface: string;
  91005. Fragment_Before_Fog: string;
  91006. Fragment_Custom_Alpha: string;
  91007. Fragment_Before_FragColor: string;
  91008. Vertex_Begin: string;
  91009. Vertex_Definitions: string;
  91010. Vertex_MainBegin: string;
  91011. Vertex_Before_PositionUpdated: string;
  91012. Vertex_Before_NormalUpdated: string;
  91013. Vertex_After_WorldPosComputed: string;
  91014. Vertex_MainEnd: string;
  91015. }
  91016. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  91017. static ShaderIndexer: number;
  91018. CustomParts: ShaderAlebdoParts;
  91019. _isCreatedShader: boolean;
  91020. _createdShaderName: string;
  91021. _customUniform: string[];
  91022. _newUniforms: string[];
  91023. _newUniformInstances: {
  91024. [name: string]: any;
  91025. };
  91026. _newSamplerInstances: {
  91027. [name: string]: BABYLON.Texture;
  91028. };
  91029. _customAttributes: string[];
  91030. FragmentShader: string;
  91031. VertexShader: string;
  91032. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  91033. ReviewUniform(name: string, arr: string[]): string[];
  91034. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  91035. constructor(name: string, scene: BABYLON.Scene);
  91036. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  91037. AddAttribute(name: string): PBRCustomMaterial;
  91038. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  91039. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  91040. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  91041. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  91042. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  91043. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  91044. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  91045. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  91046. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  91047. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  91048. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  91049. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  91050. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  91051. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  91052. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  91053. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  91054. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  91055. }
  91056. }
  91057. declare module BABYLON {
  91058. /** @hidden */
  91059. export var firePixelShader: {
  91060. name: string;
  91061. shader: string;
  91062. };
  91063. }
  91064. declare module BABYLON {
  91065. /** @hidden */
  91066. export var fireVertexShader: {
  91067. name: string;
  91068. shader: string;
  91069. };
  91070. }
  91071. declare module BABYLON {
  91072. export class FireMaterial extends BABYLON.PushMaterial {
  91073. private _diffuseTexture;
  91074. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  91075. private _distortionTexture;
  91076. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  91077. private _opacityTexture;
  91078. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  91079. diffuseColor: BABYLON.Color3;
  91080. speed: number;
  91081. private _scaledDiffuse;
  91082. private _lastTime;
  91083. constructor(name: string, scene: BABYLON.Scene);
  91084. needAlphaBlending(): boolean;
  91085. needAlphaTesting(): boolean;
  91086. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91087. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91088. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91089. getAnimatables(): BABYLON.IAnimatable[];
  91090. getActiveTextures(): BABYLON.BaseTexture[];
  91091. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91092. getClassName(): string;
  91093. dispose(forceDisposeEffect?: boolean): void;
  91094. clone(name: string): FireMaterial;
  91095. serialize(): any;
  91096. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  91097. }
  91098. }
  91099. declare module BABYLON {
  91100. /** @hidden */
  91101. export var furPixelShader: {
  91102. name: string;
  91103. shader: string;
  91104. };
  91105. }
  91106. declare module BABYLON {
  91107. /** @hidden */
  91108. export var furVertexShader: {
  91109. name: string;
  91110. shader: string;
  91111. };
  91112. }
  91113. declare module BABYLON {
  91114. export class FurMaterial extends BABYLON.PushMaterial {
  91115. private _diffuseTexture;
  91116. diffuseTexture: BABYLON.BaseTexture;
  91117. private _heightTexture;
  91118. heightTexture: BABYLON.BaseTexture;
  91119. diffuseColor: BABYLON.Color3;
  91120. furLength: number;
  91121. furAngle: number;
  91122. furColor: BABYLON.Color3;
  91123. furOffset: number;
  91124. furSpacing: number;
  91125. furGravity: BABYLON.Vector3;
  91126. furSpeed: number;
  91127. furDensity: number;
  91128. furOcclusion: number;
  91129. furTexture: BABYLON.DynamicTexture;
  91130. private _disableLighting;
  91131. disableLighting: boolean;
  91132. private _maxSimultaneousLights;
  91133. maxSimultaneousLights: number;
  91134. highLevelFur: boolean;
  91135. _meshes: BABYLON.AbstractMesh[];
  91136. private _furTime;
  91137. constructor(name: string, scene: BABYLON.Scene);
  91138. get furTime(): number;
  91139. set furTime(furTime: number);
  91140. needAlphaBlending(): boolean;
  91141. needAlphaTesting(): boolean;
  91142. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91143. updateFur(): void;
  91144. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91145. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91146. getAnimatables(): BABYLON.IAnimatable[];
  91147. getActiveTextures(): BABYLON.BaseTexture[];
  91148. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91149. dispose(forceDisposeEffect?: boolean): void;
  91150. clone(name: string): FurMaterial;
  91151. serialize(): any;
  91152. getClassName(): string;
  91153. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  91154. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  91155. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  91156. }
  91157. }
  91158. declare module BABYLON {
  91159. /** @hidden */
  91160. export var gradientPixelShader: {
  91161. name: string;
  91162. shader: string;
  91163. };
  91164. }
  91165. declare module BABYLON {
  91166. /** @hidden */
  91167. export var gradientVertexShader: {
  91168. name: string;
  91169. shader: string;
  91170. };
  91171. }
  91172. declare module BABYLON {
  91173. export class GradientMaterial extends BABYLON.PushMaterial {
  91174. private _maxSimultaneousLights;
  91175. maxSimultaneousLights: number;
  91176. topColor: BABYLON.Color3;
  91177. topColorAlpha: number;
  91178. bottomColor: BABYLON.Color3;
  91179. bottomColorAlpha: number;
  91180. offset: number;
  91181. scale: number;
  91182. smoothness: number;
  91183. private _disableLighting;
  91184. disableLighting: boolean;
  91185. constructor(name: string, scene: BABYLON.Scene);
  91186. needAlphaBlending(): boolean;
  91187. needAlphaTesting(): boolean;
  91188. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91189. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91190. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91191. getAnimatables(): BABYLON.IAnimatable[];
  91192. dispose(forceDisposeEffect?: boolean): void;
  91193. clone(name: string): GradientMaterial;
  91194. serialize(): any;
  91195. getClassName(): string;
  91196. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  91197. }
  91198. }
  91199. declare module BABYLON {
  91200. /** @hidden */
  91201. export var gridPixelShader: {
  91202. name: string;
  91203. shader: string;
  91204. };
  91205. }
  91206. declare module BABYLON {
  91207. /** @hidden */
  91208. export var gridVertexShader: {
  91209. name: string;
  91210. shader: string;
  91211. };
  91212. }
  91213. declare module BABYLON {
  91214. /**
  91215. * The grid materials allows you to wrap any shape with a grid.
  91216. * Colors are customizable.
  91217. */
  91218. export class GridMaterial extends BABYLON.PushMaterial {
  91219. /**
  91220. * Main color of the grid (e.g. between lines)
  91221. */
  91222. mainColor: BABYLON.Color3;
  91223. /**
  91224. * Color of the grid lines.
  91225. */
  91226. lineColor: BABYLON.Color3;
  91227. /**
  91228. * The scale of the grid compared to unit.
  91229. */
  91230. gridRatio: number;
  91231. /**
  91232. * Allows setting an offset for the grid lines.
  91233. */
  91234. gridOffset: BABYLON.Vector3;
  91235. /**
  91236. * The frequency of thicker lines.
  91237. */
  91238. majorUnitFrequency: number;
  91239. /**
  91240. * The visibility of minor units in the grid.
  91241. */
  91242. minorUnitVisibility: number;
  91243. /**
  91244. * The grid opacity outside of the lines.
  91245. */
  91246. opacity: number;
  91247. /**
  91248. * Determine RBG output is premultiplied by alpha value.
  91249. */
  91250. preMultiplyAlpha: boolean;
  91251. private _opacityTexture;
  91252. opacityTexture: BABYLON.BaseTexture;
  91253. private _gridControl;
  91254. /**
  91255. * constructor
  91256. * @param name The name given to the material in order to identify it afterwards.
  91257. * @param scene The scene the material is used in.
  91258. */
  91259. constructor(name: string, scene: BABYLON.Scene);
  91260. /**
  91261. * Returns wehter or not the grid requires alpha blending.
  91262. */
  91263. needAlphaBlending(): boolean;
  91264. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  91265. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91266. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91267. /**
  91268. * Dispose the material and its associated resources.
  91269. * @param forceDisposeEffect will also dispose the used effect when true
  91270. */
  91271. dispose(forceDisposeEffect?: boolean): void;
  91272. clone(name: string): GridMaterial;
  91273. serialize(): any;
  91274. getClassName(): string;
  91275. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  91276. }
  91277. }
  91278. declare module BABYLON {
  91279. /** @hidden */
  91280. export var lavaPixelShader: {
  91281. name: string;
  91282. shader: string;
  91283. };
  91284. }
  91285. declare module BABYLON {
  91286. /** @hidden */
  91287. export var lavaVertexShader: {
  91288. name: string;
  91289. shader: string;
  91290. };
  91291. }
  91292. declare module BABYLON {
  91293. export class LavaMaterial extends BABYLON.PushMaterial {
  91294. private _diffuseTexture;
  91295. diffuseTexture: BABYLON.BaseTexture;
  91296. noiseTexture: BABYLON.BaseTexture;
  91297. fogColor: BABYLON.Color3;
  91298. speed: number;
  91299. movingSpeed: number;
  91300. lowFrequencySpeed: number;
  91301. fogDensity: number;
  91302. private _lastTime;
  91303. diffuseColor: BABYLON.Color3;
  91304. private _disableLighting;
  91305. disableLighting: boolean;
  91306. private _unlit;
  91307. unlit: boolean;
  91308. private _maxSimultaneousLights;
  91309. maxSimultaneousLights: number;
  91310. private _scaledDiffuse;
  91311. constructor(name: string, scene: BABYLON.Scene);
  91312. needAlphaBlending(): boolean;
  91313. needAlphaTesting(): boolean;
  91314. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91315. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91316. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91317. getAnimatables(): BABYLON.IAnimatable[];
  91318. getActiveTextures(): BABYLON.BaseTexture[];
  91319. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91320. dispose(forceDisposeEffect?: boolean): void;
  91321. clone(name: string): LavaMaterial;
  91322. serialize(): any;
  91323. getClassName(): string;
  91324. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  91325. }
  91326. }
  91327. declare module BABYLON {
  91328. /** @hidden */
  91329. export var mixPixelShader: {
  91330. name: string;
  91331. shader: string;
  91332. };
  91333. }
  91334. declare module BABYLON {
  91335. /** @hidden */
  91336. export var mixVertexShader: {
  91337. name: string;
  91338. shader: string;
  91339. };
  91340. }
  91341. declare module BABYLON {
  91342. export class MixMaterial extends BABYLON.PushMaterial {
  91343. /**
  91344. * Mix textures
  91345. */
  91346. private _mixTexture1;
  91347. mixTexture1: BABYLON.BaseTexture;
  91348. private _mixTexture2;
  91349. mixTexture2: BABYLON.BaseTexture;
  91350. /**
  91351. * Diffuse textures
  91352. */
  91353. private _diffuseTexture1;
  91354. diffuseTexture1: BABYLON.Texture;
  91355. private _diffuseTexture2;
  91356. diffuseTexture2: BABYLON.Texture;
  91357. private _diffuseTexture3;
  91358. diffuseTexture3: BABYLON.Texture;
  91359. private _diffuseTexture4;
  91360. diffuseTexture4: BABYLON.Texture;
  91361. private _diffuseTexture5;
  91362. diffuseTexture5: BABYLON.Texture;
  91363. private _diffuseTexture6;
  91364. diffuseTexture6: BABYLON.Texture;
  91365. private _diffuseTexture7;
  91366. diffuseTexture7: BABYLON.Texture;
  91367. private _diffuseTexture8;
  91368. diffuseTexture8: BABYLON.Texture;
  91369. /**
  91370. * Uniforms
  91371. */
  91372. diffuseColor: BABYLON.Color3;
  91373. specularColor: BABYLON.Color3;
  91374. specularPower: number;
  91375. private _disableLighting;
  91376. disableLighting: boolean;
  91377. private _maxSimultaneousLights;
  91378. maxSimultaneousLights: number;
  91379. constructor(name: string, scene: BABYLON.Scene);
  91380. needAlphaBlending(): boolean;
  91381. needAlphaTesting(): boolean;
  91382. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91383. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91384. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91385. getAnimatables(): BABYLON.IAnimatable[];
  91386. getActiveTextures(): BABYLON.BaseTexture[];
  91387. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91388. dispose(forceDisposeEffect?: boolean): void;
  91389. clone(name: string): MixMaterial;
  91390. serialize(): any;
  91391. getClassName(): string;
  91392. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  91393. }
  91394. }
  91395. declare module BABYLON {
  91396. /** @hidden */
  91397. export var normalPixelShader: {
  91398. name: string;
  91399. shader: string;
  91400. };
  91401. }
  91402. declare module BABYLON {
  91403. /** @hidden */
  91404. export var normalVertexShader: {
  91405. name: string;
  91406. shader: string;
  91407. };
  91408. }
  91409. declare module BABYLON {
  91410. export class NormalMaterial extends BABYLON.PushMaterial {
  91411. private _diffuseTexture;
  91412. diffuseTexture: BABYLON.BaseTexture;
  91413. diffuseColor: BABYLON.Color3;
  91414. private _disableLighting;
  91415. disableLighting: boolean;
  91416. private _maxSimultaneousLights;
  91417. maxSimultaneousLights: number;
  91418. constructor(name: string, scene: BABYLON.Scene);
  91419. needAlphaBlending(): boolean;
  91420. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  91421. needAlphaTesting(): boolean;
  91422. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91423. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91424. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91425. getAnimatables(): BABYLON.IAnimatable[];
  91426. getActiveTextures(): BABYLON.BaseTexture[];
  91427. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91428. dispose(forceDisposeEffect?: boolean): void;
  91429. clone(name: string): NormalMaterial;
  91430. serialize(): any;
  91431. getClassName(): string;
  91432. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  91433. }
  91434. }
  91435. declare module BABYLON {
  91436. /** @hidden */
  91437. export var shadowOnlyPixelShader: {
  91438. name: string;
  91439. shader: string;
  91440. };
  91441. }
  91442. declare module BABYLON {
  91443. /** @hidden */
  91444. export var shadowOnlyVertexShader: {
  91445. name: string;
  91446. shader: string;
  91447. };
  91448. }
  91449. declare module BABYLON {
  91450. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  91451. private _activeLight;
  91452. private _needAlphaBlending;
  91453. constructor(name: string, scene: BABYLON.Scene);
  91454. shadowColor: BABYLON.Color3;
  91455. needAlphaBlending(): boolean;
  91456. needAlphaTesting(): boolean;
  91457. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91458. get activeLight(): BABYLON.IShadowLight;
  91459. set activeLight(light: BABYLON.IShadowLight);
  91460. private _getFirstShadowLightForMesh;
  91461. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91462. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91463. clone(name: string): ShadowOnlyMaterial;
  91464. serialize(): any;
  91465. getClassName(): string;
  91466. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  91467. }
  91468. }
  91469. declare module BABYLON {
  91470. /** @hidden */
  91471. export var simplePixelShader: {
  91472. name: string;
  91473. shader: string;
  91474. };
  91475. }
  91476. declare module BABYLON {
  91477. /** @hidden */
  91478. export var simpleVertexShader: {
  91479. name: string;
  91480. shader: string;
  91481. };
  91482. }
  91483. declare module BABYLON {
  91484. export class SimpleMaterial extends BABYLON.PushMaterial {
  91485. private _diffuseTexture;
  91486. diffuseTexture: BABYLON.BaseTexture;
  91487. diffuseColor: BABYLON.Color3;
  91488. private _disableLighting;
  91489. disableLighting: boolean;
  91490. private _maxSimultaneousLights;
  91491. maxSimultaneousLights: number;
  91492. constructor(name: string, scene: BABYLON.Scene);
  91493. needAlphaBlending(): boolean;
  91494. needAlphaTesting(): boolean;
  91495. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91496. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91497. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91498. getAnimatables(): BABYLON.IAnimatable[];
  91499. getActiveTextures(): BABYLON.BaseTexture[];
  91500. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91501. dispose(forceDisposeEffect?: boolean): void;
  91502. clone(name: string): SimpleMaterial;
  91503. serialize(): any;
  91504. getClassName(): string;
  91505. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  91506. }
  91507. }
  91508. declare module BABYLON {
  91509. /** @hidden */
  91510. export var skyPixelShader: {
  91511. name: string;
  91512. shader: string;
  91513. };
  91514. }
  91515. declare module BABYLON {
  91516. /** @hidden */
  91517. export var skyVertexShader: {
  91518. name: string;
  91519. shader: string;
  91520. };
  91521. }
  91522. declare module BABYLON {
  91523. /**
  91524. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  91525. * @see https://doc.babylonjs.com/extensions/sky
  91526. */
  91527. export class SkyMaterial extends BABYLON.PushMaterial {
  91528. /**
  91529. * Defines the overall luminance of sky in interval ]0, 1[.
  91530. */
  91531. luminance: number;
  91532. /**
  91533. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  91534. */
  91535. turbidity: number;
  91536. /**
  91537. * Defines the sky appearance (light intensity).
  91538. */
  91539. rayleigh: number;
  91540. /**
  91541. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  91542. */
  91543. mieCoefficient: number;
  91544. /**
  91545. * Defines the amount of haze particles following the Mie scattering theory.
  91546. */
  91547. mieDirectionalG: number;
  91548. /**
  91549. * Defines the distance of the sun according to the active scene camera.
  91550. */
  91551. distance: number;
  91552. /**
  91553. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  91554. * "inclined".
  91555. */
  91556. inclination: number;
  91557. /**
  91558. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  91559. * an object direction and a reference direction.
  91560. */
  91561. azimuth: number;
  91562. /**
  91563. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  91564. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  91565. */
  91566. sunPosition: BABYLON.Vector3;
  91567. /**
  91568. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  91569. * .sunPosition property.
  91570. */
  91571. useSunPosition: boolean;
  91572. /**
  91573. * Defines an offset vector used to get a horizon offset.
  91574. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  91575. */
  91576. cameraOffset: BABYLON.Vector3;
  91577. private _cameraPosition;
  91578. /**
  91579. * Instantiates a new sky material.
  91580. * This material allows to create dynamic and texture free
  91581. * effects for skyboxes by taking care of the atmosphere state.
  91582. * @see https://doc.babylonjs.com/extensions/sky
  91583. * @param name Define the name of the material in the scene
  91584. * @param scene Define the scene the material belong to
  91585. */
  91586. constructor(name: string, scene: BABYLON.Scene);
  91587. /**
  91588. * Specifies if the material will require alpha blending
  91589. * @returns a boolean specifying if alpha blending is needed
  91590. */
  91591. needAlphaBlending(): boolean;
  91592. /**
  91593. * Specifies if this material should be rendered in alpha test mode
  91594. * @returns false as the sky material doesn't need alpha testing.
  91595. */
  91596. needAlphaTesting(): boolean;
  91597. /**
  91598. * Get the texture used for alpha test purpose.
  91599. * @returns null as the sky material has no texture.
  91600. */
  91601. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91602. /**
  91603. * Get if the submesh is ready to be used and all its information available.
  91604. * Child classes can use it to update shaders
  91605. * @param mesh defines the mesh to check
  91606. * @param subMesh defines which submesh to check
  91607. * @param useInstances specifies that instances should be used
  91608. * @returns a boolean indicating that the submesh is ready or not
  91609. */
  91610. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91611. /**
  91612. * Binds the submesh to this material by preparing the effect and shader to draw
  91613. * @param world defines the world transformation matrix
  91614. * @param mesh defines the mesh containing the submesh
  91615. * @param subMesh defines the submesh to bind the material to
  91616. */
  91617. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91618. /**
  91619. * Get the list of animatables in the material.
  91620. * @returns the list of animatables object used in the material
  91621. */
  91622. getAnimatables(): BABYLON.IAnimatable[];
  91623. /**
  91624. * Disposes the material
  91625. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  91626. */
  91627. dispose(forceDisposeEffect?: boolean): void;
  91628. /**
  91629. * Makes a duplicate of the material, and gives it a new name
  91630. * @param name defines the new name for the duplicated material
  91631. * @returns the cloned material
  91632. */
  91633. clone(name: string): SkyMaterial;
  91634. /**
  91635. * Serializes this material in a JSON representation
  91636. * @returns the serialized material object
  91637. */
  91638. serialize(): any;
  91639. /**
  91640. * Gets the current class name of the material e.g. "SkyMaterial"
  91641. * Mainly use in serialization.
  91642. * @returns the class name
  91643. */
  91644. getClassName(): string;
  91645. /**
  91646. * Creates a sky material from parsed material data
  91647. * @param source defines the JSON representation of the material
  91648. * @param scene defines the hosting scene
  91649. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91650. * @returns a new sky material
  91651. */
  91652. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  91653. }
  91654. }
  91655. declare module BABYLON {
  91656. /** @hidden */
  91657. export var terrainPixelShader: {
  91658. name: string;
  91659. shader: string;
  91660. };
  91661. }
  91662. declare module BABYLON {
  91663. /** @hidden */
  91664. export var terrainVertexShader: {
  91665. name: string;
  91666. shader: string;
  91667. };
  91668. }
  91669. declare module BABYLON {
  91670. export class TerrainMaterial extends BABYLON.PushMaterial {
  91671. private _mixTexture;
  91672. mixTexture: BABYLON.BaseTexture;
  91673. private _diffuseTexture1;
  91674. diffuseTexture1: BABYLON.Texture;
  91675. private _diffuseTexture2;
  91676. diffuseTexture2: BABYLON.Texture;
  91677. private _diffuseTexture3;
  91678. diffuseTexture3: BABYLON.Texture;
  91679. private _bumpTexture1;
  91680. bumpTexture1: BABYLON.Texture;
  91681. private _bumpTexture2;
  91682. bumpTexture2: BABYLON.Texture;
  91683. private _bumpTexture3;
  91684. bumpTexture3: BABYLON.Texture;
  91685. diffuseColor: BABYLON.Color3;
  91686. specularColor: BABYLON.Color3;
  91687. specularPower: number;
  91688. private _disableLighting;
  91689. disableLighting: boolean;
  91690. private _maxSimultaneousLights;
  91691. maxSimultaneousLights: number;
  91692. constructor(name: string, scene: BABYLON.Scene);
  91693. needAlphaBlending(): boolean;
  91694. needAlphaTesting(): boolean;
  91695. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91696. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91697. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91698. getAnimatables(): BABYLON.IAnimatable[];
  91699. getActiveTextures(): BABYLON.BaseTexture[];
  91700. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91701. dispose(forceDisposeEffect?: boolean): void;
  91702. clone(name: string): TerrainMaterial;
  91703. serialize(): any;
  91704. getClassName(): string;
  91705. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  91706. }
  91707. }
  91708. declare module BABYLON {
  91709. /** @hidden */
  91710. export var triplanarPixelShader: {
  91711. name: string;
  91712. shader: string;
  91713. };
  91714. }
  91715. declare module BABYLON {
  91716. /** @hidden */
  91717. export var triplanarVertexShader: {
  91718. name: string;
  91719. shader: string;
  91720. };
  91721. }
  91722. declare module BABYLON {
  91723. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  91724. mixTexture: BABYLON.BaseTexture;
  91725. private _diffuseTextureX;
  91726. diffuseTextureX: BABYLON.BaseTexture;
  91727. private _diffuseTextureY;
  91728. diffuseTextureY: BABYLON.BaseTexture;
  91729. private _diffuseTextureZ;
  91730. diffuseTextureZ: BABYLON.BaseTexture;
  91731. private _normalTextureX;
  91732. normalTextureX: BABYLON.BaseTexture;
  91733. private _normalTextureY;
  91734. normalTextureY: BABYLON.BaseTexture;
  91735. private _normalTextureZ;
  91736. normalTextureZ: BABYLON.BaseTexture;
  91737. tileSize: number;
  91738. diffuseColor: BABYLON.Color3;
  91739. specularColor: BABYLON.Color3;
  91740. specularPower: number;
  91741. private _disableLighting;
  91742. disableLighting: boolean;
  91743. private _maxSimultaneousLights;
  91744. maxSimultaneousLights: number;
  91745. constructor(name: string, scene: BABYLON.Scene);
  91746. needAlphaBlending(): boolean;
  91747. needAlphaTesting(): boolean;
  91748. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91749. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91750. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91751. getAnimatables(): BABYLON.IAnimatable[];
  91752. getActiveTextures(): BABYLON.BaseTexture[];
  91753. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91754. dispose(forceDisposeEffect?: boolean): void;
  91755. clone(name: string): TriPlanarMaterial;
  91756. serialize(): any;
  91757. getClassName(): string;
  91758. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  91759. }
  91760. }
  91761. declare module BABYLON {
  91762. /** @hidden */
  91763. export var waterPixelShader: {
  91764. name: string;
  91765. shader: string;
  91766. };
  91767. }
  91768. declare module BABYLON {
  91769. /** @hidden */
  91770. export var waterVertexShader: {
  91771. name: string;
  91772. shader: string;
  91773. };
  91774. }
  91775. declare module BABYLON {
  91776. export class WaterMaterial extends BABYLON.PushMaterial {
  91777. renderTargetSize: BABYLON.Vector2;
  91778. private _bumpTexture;
  91779. bumpTexture: BABYLON.BaseTexture;
  91780. diffuseColor: BABYLON.Color3;
  91781. specularColor: BABYLON.Color3;
  91782. specularPower: number;
  91783. private _disableLighting;
  91784. disableLighting: boolean;
  91785. private _maxSimultaneousLights;
  91786. maxSimultaneousLights: number;
  91787. /**
  91788. * Defines the wind force.
  91789. */
  91790. windForce: number;
  91791. /**
  91792. * Defines the direction of the wind in the plane (X, Z).
  91793. */
  91794. windDirection: BABYLON.Vector2;
  91795. /**
  91796. * Defines the height of the waves.
  91797. */
  91798. waveHeight: number;
  91799. /**
  91800. * Defines the bump height related to the bump map.
  91801. */
  91802. bumpHeight: number;
  91803. /**
  91804. * Defines wether or not: to add a smaller moving bump to less steady waves.
  91805. */
  91806. private _bumpSuperimpose;
  91807. bumpSuperimpose: boolean;
  91808. /**
  91809. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  91810. */
  91811. private _fresnelSeparate;
  91812. fresnelSeparate: boolean;
  91813. /**
  91814. * Defines wether or not bump Wwves modify the reflection.
  91815. */
  91816. private _bumpAffectsReflection;
  91817. bumpAffectsReflection: boolean;
  91818. /**
  91819. * Defines the water color blended with the refraction (near).
  91820. */
  91821. waterColor: BABYLON.Color3;
  91822. /**
  91823. * Defines the blend factor related to the water color.
  91824. */
  91825. colorBlendFactor: number;
  91826. /**
  91827. * Defines the water color blended with the reflection (far).
  91828. */
  91829. waterColor2: BABYLON.Color3;
  91830. /**
  91831. * Defines the blend factor related to the water color (reflection, far).
  91832. */
  91833. colorBlendFactor2: number;
  91834. /**
  91835. * Defines the maximum length of a wave.
  91836. */
  91837. waveLength: number;
  91838. /**
  91839. * Defines the waves speed.
  91840. */
  91841. waveSpeed: number;
  91842. /**
  91843. * 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.
  91844. */
  91845. waveCount: number;
  91846. /**
  91847. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  91848. * will avoid calculating useless pixels in the pixel shader of the water material.
  91849. */
  91850. disableClipPlane: boolean;
  91851. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  91852. private _mesh;
  91853. private _refractionRTT;
  91854. private _reflectionRTT;
  91855. private _reflectionTransform;
  91856. private _lastTime;
  91857. private _lastDeltaTime;
  91858. private _useLogarithmicDepth;
  91859. private _waitingRenderList;
  91860. private _imageProcessingConfiguration;
  91861. private _imageProcessingObserver;
  91862. /**
  91863. * Gets a boolean indicating that current material needs to register RTT
  91864. */
  91865. get hasRenderTargetTextures(): boolean;
  91866. /**
  91867. * Constructor
  91868. */
  91869. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  91870. get useLogarithmicDepth(): boolean;
  91871. set useLogarithmicDepth(value: boolean);
  91872. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  91873. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  91874. addToRenderList(node: any): void;
  91875. enableRenderTargets(enable: boolean): void;
  91876. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  91877. get renderTargetsEnabled(): boolean;
  91878. needAlphaBlending(): boolean;
  91879. needAlphaTesting(): boolean;
  91880. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91881. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91882. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91883. private _createRenderTargets;
  91884. getAnimatables(): BABYLON.IAnimatable[];
  91885. getActiveTextures(): BABYLON.BaseTexture[];
  91886. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91887. dispose(forceDisposeEffect?: boolean): void;
  91888. clone(name: string): WaterMaterial;
  91889. serialize(): any;
  91890. getClassName(): string;
  91891. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  91892. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  91893. }
  91894. }
  91895. declare module BABYLON {
  91896. /** @hidden */
  91897. export var asciiartPixelShader: {
  91898. name: string;
  91899. shader: string;
  91900. };
  91901. }
  91902. declare module BABYLON {
  91903. /**
  91904. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  91905. *
  91906. * It basically takes care rendering the font front the given font size to a texture.
  91907. * This is used later on in the postprocess.
  91908. */
  91909. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  91910. private _font;
  91911. private _text;
  91912. private _charSize;
  91913. /**
  91914. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  91915. */
  91916. get charSize(): number;
  91917. /**
  91918. * Create a new instance of the Ascii Art FontTexture class
  91919. * @param name the name of the texture
  91920. * @param font the font to use, use the W3C CSS notation
  91921. * @param text the caracter set to use in the rendering.
  91922. * @param scene the scene that owns the texture
  91923. */
  91924. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  91925. /**
  91926. * Gets the max char width of a font.
  91927. * @param font the font to use, use the W3C CSS notation
  91928. * @return the max char width
  91929. */
  91930. private getFontWidth;
  91931. /**
  91932. * Gets the max char height of a font.
  91933. * @param font the font to use, use the W3C CSS notation
  91934. * @return the max char height
  91935. */
  91936. private getFontHeight;
  91937. /**
  91938. * Clones the current AsciiArtTexture.
  91939. * @return the clone of the texture.
  91940. */
  91941. clone(): AsciiArtFontTexture;
  91942. /**
  91943. * Parses a json object representing the texture and returns an instance of it.
  91944. * @param source the source JSON representation
  91945. * @param scene the scene to create the texture for
  91946. * @return the parsed texture
  91947. */
  91948. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  91949. }
  91950. /**
  91951. * Option available in the Ascii Art Post Process.
  91952. */
  91953. export interface IAsciiArtPostProcessOptions {
  91954. /**
  91955. * The font to use following the w3c font definition.
  91956. */
  91957. font?: string;
  91958. /**
  91959. * The character set to use in the postprocess.
  91960. */
  91961. characterSet?: string;
  91962. /**
  91963. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  91964. * This number is defined between 0 and 1;
  91965. */
  91966. mixToTile?: number;
  91967. /**
  91968. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  91969. * This number is defined between 0 and 1;
  91970. */
  91971. mixToNormal?: number;
  91972. }
  91973. /**
  91974. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  91975. *
  91976. * Simmply add it to your scene and let the nerd that lives in you have fun.
  91977. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  91978. */
  91979. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  91980. /**
  91981. * The font texture used to render the char in the post process.
  91982. */
  91983. private _asciiArtFontTexture;
  91984. /**
  91985. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  91986. * This number is defined between 0 and 1;
  91987. */
  91988. mixToTile: number;
  91989. /**
  91990. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  91991. * This number is defined between 0 and 1;
  91992. */
  91993. mixToNormal: number;
  91994. /**
  91995. * Instantiates a new Ascii Art Post Process.
  91996. * @param name the name to give to the postprocess
  91997. * @camera the camera to apply the post process to.
  91998. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  91999. */
  92000. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  92001. }
  92002. }
  92003. declare module BABYLON {
  92004. /** @hidden */
  92005. export var digitalrainPixelShader: {
  92006. name: string;
  92007. shader: string;
  92008. };
  92009. }
  92010. declare module BABYLON {
  92011. /**
  92012. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  92013. *
  92014. * It basically takes care rendering the font front the given font size to a texture.
  92015. * This is used later on in the postprocess.
  92016. */
  92017. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  92018. private _font;
  92019. private _text;
  92020. private _charSize;
  92021. /**
  92022. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  92023. */
  92024. get charSize(): number;
  92025. /**
  92026. * Create a new instance of the Digital Rain FontTexture class
  92027. * @param name the name of the texture
  92028. * @param font the font to use, use the W3C CSS notation
  92029. * @param text the caracter set to use in the rendering.
  92030. * @param scene the scene that owns the texture
  92031. */
  92032. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  92033. /**
  92034. * Gets the max char width of a font.
  92035. * @param font the font to use, use the W3C CSS notation
  92036. * @return the max char width
  92037. */
  92038. private getFontWidth;
  92039. /**
  92040. * Gets the max char height of a font.
  92041. * @param font the font to use, use the W3C CSS notation
  92042. * @return the max char height
  92043. */
  92044. private getFontHeight;
  92045. /**
  92046. * Clones the current DigitalRainFontTexture.
  92047. * @return the clone of the texture.
  92048. */
  92049. clone(): DigitalRainFontTexture;
  92050. /**
  92051. * Parses a json object representing the texture and returns an instance of it.
  92052. * @param source the source JSON representation
  92053. * @param scene the scene to create the texture for
  92054. * @return the parsed texture
  92055. */
  92056. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  92057. }
  92058. /**
  92059. * Option available in the Digital Rain Post Process.
  92060. */
  92061. export interface IDigitalRainPostProcessOptions {
  92062. /**
  92063. * The font to use following the w3c font definition.
  92064. */
  92065. font?: string;
  92066. /**
  92067. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  92068. * This number is defined between 0 and 1;
  92069. */
  92070. mixToTile?: number;
  92071. /**
  92072. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  92073. * This number is defined between 0 and 1;
  92074. */
  92075. mixToNormal?: number;
  92076. }
  92077. /**
  92078. * DigitalRainPostProcess helps rendering everithing in digital rain.
  92079. *
  92080. * Simmply add it to your scene and let the nerd that lives in you have fun.
  92081. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  92082. */
  92083. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  92084. /**
  92085. * The font texture used to render the char in the post process.
  92086. */
  92087. private _digitalRainFontTexture;
  92088. /**
  92089. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  92090. * This number is defined between 0 and 1;
  92091. */
  92092. mixToTile: number;
  92093. /**
  92094. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  92095. * This number is defined between 0 and 1;
  92096. */
  92097. mixToNormal: number;
  92098. /**
  92099. * Instantiates a new Digital Rain Post Process.
  92100. * @param name the name to give to the postprocess
  92101. * @camera the camera to apply the post process to.
  92102. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  92103. */
  92104. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  92105. }
  92106. }
  92107. declare module BABYLON {
  92108. /** @hidden */
  92109. export var brickProceduralTexturePixelShader: {
  92110. name: string;
  92111. shader: string;
  92112. };
  92113. }
  92114. declare module BABYLON {
  92115. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  92116. private _numberOfBricksHeight;
  92117. private _numberOfBricksWidth;
  92118. private _jointColor;
  92119. private _brickColor;
  92120. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92121. updateShaderUniforms(): void;
  92122. get numberOfBricksHeight(): number;
  92123. set numberOfBricksHeight(value: number);
  92124. get numberOfBricksWidth(): number;
  92125. set numberOfBricksWidth(value: number);
  92126. get jointColor(): BABYLON.Color3;
  92127. set jointColor(value: BABYLON.Color3);
  92128. get brickColor(): BABYLON.Color3;
  92129. set brickColor(value: BABYLON.Color3);
  92130. /**
  92131. * Serializes this brick procedural texture
  92132. * @returns a serialized brick procedural texture object
  92133. */
  92134. serialize(): any;
  92135. /**
  92136. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  92137. * @param parsedTexture defines parsed texture data
  92138. * @param scene defines the current scene
  92139. * @param rootUrl defines the root URL containing brick procedural texture information
  92140. * @returns a parsed Brick Procedural BABYLON.Texture
  92141. */
  92142. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  92143. }
  92144. }
  92145. declare module BABYLON {
  92146. /** @hidden */
  92147. export var cloudProceduralTexturePixelShader: {
  92148. name: string;
  92149. shader: string;
  92150. };
  92151. }
  92152. declare module BABYLON {
  92153. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  92154. private _skyColor;
  92155. private _cloudColor;
  92156. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92157. updateShaderUniforms(): void;
  92158. get skyColor(): BABYLON.Color4;
  92159. set skyColor(value: BABYLON.Color4);
  92160. get cloudColor(): BABYLON.Color4;
  92161. set cloudColor(value: BABYLON.Color4);
  92162. /**
  92163. * Serializes this cloud procedural texture
  92164. * @returns a serialized cloud procedural texture object
  92165. */
  92166. serialize(): any;
  92167. /**
  92168. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  92169. * @param parsedTexture defines parsed texture data
  92170. * @param scene defines the current scene
  92171. * @param rootUrl defines the root URL containing cloud procedural texture information
  92172. * @returns a parsed Cloud Procedural BABYLON.Texture
  92173. */
  92174. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  92175. }
  92176. }
  92177. declare module BABYLON {
  92178. /** @hidden */
  92179. export var fireProceduralTexturePixelShader: {
  92180. name: string;
  92181. shader: string;
  92182. };
  92183. }
  92184. declare module BABYLON {
  92185. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  92186. private _time;
  92187. private _speed;
  92188. private _autoGenerateTime;
  92189. private _fireColors;
  92190. private _alphaThreshold;
  92191. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92192. updateShaderUniforms(): void;
  92193. render(useCameraPostProcess?: boolean): void;
  92194. static get PurpleFireColors(): BABYLON.Color3[];
  92195. static get GreenFireColors(): BABYLON.Color3[];
  92196. static get RedFireColors(): BABYLON.Color3[];
  92197. static get BlueFireColors(): BABYLON.Color3[];
  92198. get autoGenerateTime(): boolean;
  92199. set autoGenerateTime(value: boolean);
  92200. get fireColors(): BABYLON.Color3[];
  92201. set fireColors(value: BABYLON.Color3[]);
  92202. get time(): number;
  92203. set time(value: number);
  92204. get speed(): BABYLON.Vector2;
  92205. set speed(value: BABYLON.Vector2);
  92206. get alphaThreshold(): number;
  92207. set alphaThreshold(value: number);
  92208. /**
  92209. * Serializes this fire procedural texture
  92210. * @returns a serialized fire procedural texture object
  92211. */
  92212. serialize(): any;
  92213. /**
  92214. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  92215. * @param parsedTexture defines parsed texture data
  92216. * @param scene defines the current scene
  92217. * @param rootUrl defines the root URL containing fire procedural texture information
  92218. * @returns a parsed Fire Procedural BABYLON.Texture
  92219. */
  92220. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  92221. }
  92222. }
  92223. declare module BABYLON {
  92224. /** @hidden */
  92225. export var grassProceduralTexturePixelShader: {
  92226. name: string;
  92227. shader: string;
  92228. };
  92229. }
  92230. declare module BABYLON {
  92231. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  92232. private _grassColors;
  92233. private _groundColor;
  92234. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92235. updateShaderUniforms(): void;
  92236. get grassColors(): BABYLON.Color3[];
  92237. set grassColors(value: BABYLON.Color3[]);
  92238. get groundColor(): BABYLON.Color3;
  92239. set groundColor(value: BABYLON.Color3);
  92240. /**
  92241. * Serializes this grass procedural texture
  92242. * @returns a serialized grass procedural texture object
  92243. */
  92244. serialize(): any;
  92245. /**
  92246. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  92247. * @param parsedTexture defines parsed texture data
  92248. * @param scene defines the current scene
  92249. * @param rootUrl defines the root URL containing grass procedural texture information
  92250. * @returns a parsed Grass Procedural BABYLON.Texture
  92251. */
  92252. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  92253. }
  92254. }
  92255. declare module BABYLON {
  92256. /** @hidden */
  92257. export var marbleProceduralTexturePixelShader: {
  92258. name: string;
  92259. shader: string;
  92260. };
  92261. }
  92262. declare module BABYLON {
  92263. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  92264. private _numberOfTilesHeight;
  92265. private _numberOfTilesWidth;
  92266. private _amplitude;
  92267. private _jointColor;
  92268. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92269. updateShaderUniforms(): void;
  92270. get numberOfTilesHeight(): number;
  92271. set numberOfTilesHeight(value: number);
  92272. get amplitude(): number;
  92273. set amplitude(value: number);
  92274. get numberOfTilesWidth(): number;
  92275. set numberOfTilesWidth(value: number);
  92276. get jointColor(): BABYLON.Color3;
  92277. set jointColor(value: BABYLON.Color3);
  92278. /**
  92279. * Serializes this marble procedural texture
  92280. * @returns a serialized marble procedural texture object
  92281. */
  92282. serialize(): any;
  92283. /**
  92284. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  92285. * @param parsedTexture defines parsed texture data
  92286. * @param scene defines the current scene
  92287. * @param rootUrl defines the root URL containing marble procedural texture information
  92288. * @returns a parsed Marble Procedural BABYLON.Texture
  92289. */
  92290. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  92291. }
  92292. }
  92293. declare module BABYLON {
  92294. /** @hidden */
  92295. export var normalMapProceduralTexturePixelShader: {
  92296. name: string;
  92297. shader: string;
  92298. };
  92299. }
  92300. declare module BABYLON {
  92301. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  92302. private _baseTexture;
  92303. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92304. updateShaderUniforms(): void;
  92305. render(useCameraPostProcess?: boolean): void;
  92306. resize(size: any, generateMipMaps: any): void;
  92307. isReady(): boolean;
  92308. get baseTexture(): BABYLON.Texture;
  92309. set baseTexture(texture: BABYLON.Texture);
  92310. /**
  92311. * Serializes this normal map procedural texture
  92312. * @returns a serialized normal map procedural texture object
  92313. */
  92314. serialize(): any;
  92315. /**
  92316. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  92317. * @param parsedTexture defines parsed texture data
  92318. * @param scene defines the current scene
  92319. * @param rootUrl defines the root URL containing normal map procedural texture information
  92320. * @returns a parsed Normal Map Procedural BABYLON.Texture
  92321. */
  92322. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  92323. }
  92324. }
  92325. declare module BABYLON {
  92326. /** @hidden */
  92327. export var perlinNoiseProceduralTexturePixelShader: {
  92328. name: string;
  92329. shader: string;
  92330. };
  92331. }
  92332. declare module BABYLON {
  92333. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  92334. time: number;
  92335. timeScale: number;
  92336. translationSpeed: number;
  92337. private _currentTranslation;
  92338. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92339. updateShaderUniforms(): void;
  92340. render(useCameraPostProcess?: boolean): void;
  92341. resize(size: any, generateMipMaps: any): void;
  92342. /**
  92343. * Serializes this perlin noise procedural texture
  92344. * @returns a serialized perlin noise procedural texture object
  92345. */
  92346. serialize(): any;
  92347. /**
  92348. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  92349. * @param parsedTexture defines parsed texture data
  92350. * @param scene defines the current scene
  92351. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  92352. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  92353. */
  92354. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  92355. }
  92356. }
  92357. declare module BABYLON {
  92358. /** @hidden */
  92359. export var roadProceduralTexturePixelShader: {
  92360. name: string;
  92361. shader: string;
  92362. };
  92363. }
  92364. declare module BABYLON {
  92365. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  92366. private _roadColor;
  92367. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92368. updateShaderUniforms(): void;
  92369. get roadColor(): BABYLON.Color3;
  92370. set roadColor(value: BABYLON.Color3);
  92371. /**
  92372. * Serializes this road procedural texture
  92373. * @returns a serialized road procedural texture object
  92374. */
  92375. serialize(): any;
  92376. /**
  92377. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  92378. * @param parsedTexture defines parsed texture data
  92379. * @param scene defines the current scene
  92380. * @param rootUrl defines the root URL containing road procedural texture information
  92381. * @returns a parsed Road Procedural BABYLON.Texture
  92382. */
  92383. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  92384. }
  92385. }
  92386. declare module BABYLON {
  92387. /** @hidden */
  92388. export var starfieldProceduralTexturePixelShader: {
  92389. name: string;
  92390. shader: string;
  92391. };
  92392. }
  92393. declare module BABYLON {
  92394. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  92395. private _time;
  92396. private _alpha;
  92397. private _beta;
  92398. private _zoom;
  92399. private _formuparam;
  92400. private _stepsize;
  92401. private _tile;
  92402. private _brightness;
  92403. private _darkmatter;
  92404. private _distfading;
  92405. private _saturation;
  92406. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92407. updateShaderUniforms(): void;
  92408. get time(): number;
  92409. set time(value: number);
  92410. get alpha(): number;
  92411. set alpha(value: number);
  92412. get beta(): number;
  92413. set beta(value: number);
  92414. get formuparam(): number;
  92415. set formuparam(value: number);
  92416. get stepsize(): number;
  92417. set stepsize(value: number);
  92418. get zoom(): number;
  92419. set zoom(value: number);
  92420. get tile(): number;
  92421. set tile(value: number);
  92422. get brightness(): number;
  92423. set brightness(value: number);
  92424. get darkmatter(): number;
  92425. set darkmatter(value: number);
  92426. get distfading(): number;
  92427. set distfading(value: number);
  92428. get saturation(): number;
  92429. set saturation(value: number);
  92430. /**
  92431. * Serializes this starfield procedural texture
  92432. * @returns a serialized starfield procedural texture object
  92433. */
  92434. serialize(): any;
  92435. /**
  92436. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  92437. * @param parsedTexture defines parsed texture data
  92438. * @param scene defines the current scene
  92439. * @param rootUrl defines the root URL containing startfield procedural texture information
  92440. * @returns a parsed Starfield Procedural BABYLON.Texture
  92441. */
  92442. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  92443. }
  92444. }
  92445. declare module BABYLON {
  92446. /** @hidden */
  92447. export var woodProceduralTexturePixelShader: {
  92448. name: string;
  92449. shader: string;
  92450. };
  92451. }
  92452. declare module BABYLON {
  92453. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  92454. private _ampScale;
  92455. private _woodColor;
  92456. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92457. updateShaderUniforms(): void;
  92458. get ampScale(): number;
  92459. set ampScale(value: number);
  92460. get woodColor(): BABYLON.Color3;
  92461. set woodColor(value: BABYLON.Color3);
  92462. /**
  92463. * Serializes this wood procedural texture
  92464. * @returns a serialized wood procedural texture object
  92465. */
  92466. serialize(): any;
  92467. /**
  92468. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  92469. * @param parsedTexture defines parsed texture data
  92470. * @param scene defines the current scene
  92471. * @param rootUrl defines the root URL containing wood procedural texture information
  92472. * @returns a parsed Wood Procedural BABYLON.Texture
  92473. */
  92474. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  92475. }
  92476. }